:root {
  --bg: #0f1020;
  --panel: #1a1b34;
  --text: #e7e8f5;
  --muted: #a3a5c4;
  --accent: #6366f1;
  --accent-hover: #7c7ef5;
  --border: #2a2c4f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(120% 120% at 50% 0%, #1a1b34 0%, var(--bg) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 16px 24px;
}

.app {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.title {
  margin: 4px 0 0;
  font-size: 1.6rem;
  letter-spacing: 0.5px;
}

.btn-install {
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 9px;
  cursor: pointer;
}
.btn-install:hover { background: var(--accent-hover); }

.text {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  padding: 14px;
  font-size: 1.05rem;
  line-height: 1.4;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
}

.text:focus { border-color: var(--accent); }

/* Language toggle + play button on one row. */
.row {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.lang {
  display: inline-flex;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  gap: 4px;
}

.lang-btn {
  min-width: 52px;
  padding: 0 14px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lang-btn.is-active {
  color: #fff;
  background: var(--accent);
}

/* Destination toggle: play locally vs send into Discord. */
.dest {
  display: flex;
  padding: 4px;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.dest-btn {
  flex: 1;
  padding: 10px 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.dest-btn.is-active {
  color: #fff;
  background: var(--accent);
}

/* Voice-channel picker, shown only in Discord mode. */
.target {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.target[hidden] { display: none; }
.target-select {
  flex: 1 1 auto;
  min-width: 0;
  padding: 12px 14px;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
}
.target-select:focus { border-color: var(--accent); }
.target-refresh {
  flex: 0 0 auto;
  width: 46px;
  font-size: 1.2rem;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}
.target-refresh:hover { color: var(--text); border-color: var(--accent); }
.target-refresh:active { transform: scale(0.96); }

.volume[hidden] { display: none; }

/* "Also post in chat" checkbox, shown only in Discord mode. */
.postchat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  font-size: 0.9rem;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}
.postchat[hidden] { display: none; }
.postchat input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.btn {
  flex: 1;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:not(:disabled):hover { background: var(--accent-hover); }

/* Volume */
.volume {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.volume-label {
  font-size: 0.85rem;
  color: var(--muted);
}
.volume-label output { color: var(--text); font-weight: 600; }
.volume input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.status {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

/* Login overlay */
.login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 8, 18, 0.85);
  backdrop-filter: blur(4px);
  z-index: 10;
}
.login[hidden] { display: none; }

.login-card {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
}
.login-title { margin: 0; font-size: 1.15rem; }

.login-input {
  padding: 12px 14px;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
}
.login-input:focus { border-color: var(--accent); }

.login-error {
  margin: 0;
  min-height: 1em;
  font-size: 0.85rem;
  color: #ff8f9c;
}

/* History */
.history { display: flex; flex-direction: column; gap: 8px; }

.history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.history-title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
}
.link:hover { color: var(--text); }

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

.replay {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  font-size: 0.9rem;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 9px;
  cursor: pointer;
}
.replay:hover { background: var(--accent-hover); }
.replay:active { transform: scale(0.96); }

.history-text {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0;
}
.history-text:hover { color: var(--accent-hover); }

.badge {
  flex: 0 0 auto;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
}
