:root {
  --bg: #0d1218;
  --surface: #141c24;
  --surface-2: #1c2632;
  --border: #263342;
  --text: #e6edf3;
  --muted: #8b9bb0;
  --primary: #5cc8ff;
  --primary-dim: rgba(92, 200, 255, 0.14);
  --secondary: #6ee7b7;
  --secondary-dim: rgba(110, 231, 183, 0.14);
  --warm: #fbbf24;
  --warm-dim: rgba(251, 191, 36, 0.14);
  --radius: 14px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at top right, #162230 0%, var(--bg) 52%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(13, 18, 24, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 0 14px rgba(92, 200, 255, 0.6);
}

.brand-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.3px;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

.nav-tabs {
  display: flex;
  gap: 6px;
  background: var(--surface);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.nav-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.nav-btn:hover {
  color: var(--text);
}

.nav-btn.active {
  background: var(--primary-dim);
  color: var(--primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ability-pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--secondary);
  font-weight: 600;
}

.main-container {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 72px;
  flex: 1;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

h1, h2, h3 {
  margin: 0 0 8px;
  font-weight: 650;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary);
  color: #07131c;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn:hover {
  opacity: 0.92;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--primary);
}

.ghost-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.ghost-btn:hover {
  color: var(--text);
  border-color: var(--muted);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
}

.chip.active {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: var(--primary);
}

.chip-probe {
  background: var(--warm-dim);
  border-color: rgba(251, 191, 36, 0.4);
  color: var(--warm);
}

.chip-sweet {
  background: var(--secondary-dim);
  border-color: rgba(110, 231, 183, 0.35);
  color: var(--secondary);
}

/* Auth View */
.auth-wrap {
  max-width: 440px;
  margin: 64px auto 0;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.input, .textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.input:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.textarea {
  min-height: 150px;
  resize: vertical;
}

/* FIM Ring */
.fim-hero {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.ring-box {
  position: relative;
  width: 96px;
  height: 96px;
  flex-shrink: 0;
}

.ring-box svg {
  transform: rotate(-90deg);
}

.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.ring-label small {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

/* Queue Card */
.queue-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.queue-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.queue-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.queue-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* Player */
.player-stage {
  background: #080c11;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
  position: relative;
}

.player-stage video, .player-stage audio {
  width: 100%;
  max-height: 380px;
  border-radius: 10px;
}

.subtitle-box {
  margin-top: 18px;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  min-height: 116px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.subtitle-target {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.5;
}

.word-token {
  padding: 2px 5px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.word-token:hover {
  background: var(--primary-dim);
  color: var(--primary);
}

.word-token.tapped {
  background: var(--warm-dim);
  color: var(--warm);
}

.subtitle-native {
  font-size: 16px;
  color: var(--muted);
}

.player-controls {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.control-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.gentle-banner {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--warm-dim);
  border: 1px solid rgba(251, 191, 36, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Progress Bar */
.bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-top: 6px;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}

/* Probe Options */
.option-btn {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
}

.option-btn:hover {
  border-color: var(--primary);
}

.option-btn.selected {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.option-unsure {
  border-style: dashed;
  color: var(--muted);
}

/* Context Gloss Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

.gloss-drawer {
  width: 100%;
  max-width: 600px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px 24px;
  box-shadow: var(--shadow);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.gloss-lemma {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}

.gloss-ipa {
  margin-left: 10px;
  font-size: 14px;
  color: var(--muted);
}

.gloss-pos {
  margin-left: 8px;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
}

.gloss-meaning {
  font-size: 17px;
  margin-bottom: 10px;
}

.gloss-example {
  font-size: 14px;
  color: var(--muted);
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 10px;
  margin-bottom: 12px;
}

.gloss-footer {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.calm-note {
  font-size: 12px;
  color: var(--secondary);
}

.blindspot-tag {
  font-size: 12px;
  color: var(--warm);
}

.icon-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 60;
  background: var(--surface-2);
  border: 1px solid var(--primary);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 14px;
}

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

.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px;
  }
  .topbar-right {
    justify-content: space-between;
  }
}
