/* ============================================================
   BridgeTalk v6 — Design System
   ============================================================
   Refined, editorial, serious-tool aesthetic. This is
   accessibility infrastructure — clarity comes first,
   visual interest second.

   Type: Fraunces (display, italic-friendly), Inter Tight (body),
         JetBrains Mono (data/labels)
   Theme: dark by default, light by system preference, overridable.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,600;0,9..144,700;1,9..144,500&family=Inter+Tight:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ----- Tokens ----- */
:root {
  --cyan: #22d3ee;
  --violet: #a78bfa;
  --amber: #f59e0b;
  --rose: #fb7185;
  --emerald: #34d399;

  --ff-display: 'Fraunces', Georgia, serif;
  --ff-body: 'Inter Tight', -apple-system, BlinkMacSystemFont, sans-serif;
  --ff-mono: 'JetBrains Mono', Menlo, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

/* DARK (default) */
:root,
[data-theme="dark"] {
  --bg: #060916;
  --bg-elev-1: #0c1326;
  --bg-elev-2: #131c34;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --shadow-1: 0 1px 0 rgba(255,255,255,0.04) inset, 0 8px 32px rgba(0,0,0,0.4);
  --shadow-2: 0 1px 0 rgba(255,255,255,0.06) inset, 0 24px 64px rgba(0,0,0,0.55);
  --gradient-1: radial-gradient(ellipse at 30% 0%, rgba(34, 211, 238, 0.10), transparent 50%),
                radial-gradient(ellipse at 80% 30%, rgba(167, 139, 250, 0.08), transparent 50%);
}

/* LIGHT (system preference, only if user hasn't picked) */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f8fafc;
    --bg-elev-1: #ffffff;
    --bg-elev-2: #f1f5f9;
    --surface: rgba(15, 23, 42, 0.03);
    --surface-strong: rgba(15, 23, 42, 0.06);
    --border: rgba(15, 23, 42, 0.10);
    --border-strong: rgba(15, 23, 42, 0.18);
    --text: #0f172a;
    --text-muted: #475569;
    --text-faint: #94a3b8;
    --shadow-1: 0 1px 2px rgba(15,23,42,0.05), 0 8px 24px rgba(15,23,42,0.06);
    --shadow-2: 0 4px 8px rgba(15,23,42,0.06), 0 24px 48px rgba(15,23,42,0.08);
    --gradient-1: radial-gradient(ellipse at 30% 0%, rgba(34, 211, 238, 0.08), transparent 50%),
                  radial-gradient(ellipse at 80% 30%, rgba(167, 139, 250, 0.06), transparent 50%);
  }
}

[data-theme="light"] {
  --bg: #f8fafc;
  --bg-elev-1: #ffffff;
  --bg-elev-2: #f1f5f9;
  --surface: rgba(15, 23, 42, 0.03);
  --surface-strong: rgba(15, 23, 42, 0.06);
  --border: rgba(15, 23, 42, 0.10);
  --border-strong: rgba(15, 23, 42, 0.18);
  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #94a3b8;
  --shadow-1: 0 1px 2px rgba(15,23,42,0.05), 0 8px 24px rgba(15,23,42,0.06);
  --shadow-2: 0 4px 8px rgba(15,23,42,0.06), 0 24px 48px rgba(15,23,42,0.08);
  --gradient-1: radial-gradient(ellipse at 30% 0%, rgba(34, 211, 238, 0.08), transparent 50%),
                radial-gradient(ellipse at 80% 30%, rgba(167, 139, 250, 0.06), transparent 50%);
}

/* ----- Reset + base ----- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--ff-body);
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image: var(--gradient-1);
  background-attachment: fixed;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

::selection { background: var(--cyan); color: #060916; }

/* ----- Layout shell ----- */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    height: auto;
    position: sticky;
    top: 0;
    padding: var(--space-3) var(--space-4);
    z-index: 50;
  }
  .sidebar .brand { margin-bottom: 0; }
  .sidebar-footer { display: none; }
  .nav { flex-direction: row; gap: 2px; }
  .nav-item { padding: 6px 10px; font-size: 13px; }
  .nav-item .dot { display: none; }
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--bg-elev-1);
  border-right: 1px solid var(--border);
  padding: var(--space-6) var(--space-5);
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-7);
}
.brand-mark {
  font-family: var(--ff-display);
  font-style: italic;
  font-weight: 600;
  font-size: 24px;
  letter-spacing: -0.01em;
}
.brand-mark .accent {
  color: var(--cyan);
}
.brand-version {
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--text-faint);
  margin-left: auto;
  letter-spacing: 0.05em;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14.5px;
  font-weight: 500;
  transition: all 0.15s var(--ease-out);
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
  background: var(--surface-strong);
  color: var(--text);
}
.nav-item .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
}
.nav-item.active .dot { background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }

.sidebar-footer {
  margin-top: auto;
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

.main {
  padding: var(--space-6) var(--space-7);
  max-width: 1400px;
}
@media (max-width: 880px) {
  .main { padding: var(--space-5) var(--space-4); }
}

/* ----- Page header ----- */
.page-header {
  margin-bottom: var(--space-6);
}
.page-eyebrow {
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: var(--space-2);
}
.page-title {
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: clamp(32px, 4.5vw, 56px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-3) 0;
}
.page-title em {
  font-style: italic;
  color: var(--cyan);
  font-weight: 500;
}
.page-lede {
  font-size: 17px;
  color: var(--text-muted);
  max-width: 56ch;
  line-height: 1.5;
}

/* ----- Cards & glass ----- */
.card {
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-1);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.card-title {
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.01em;
  margin: 0;
}
.card-sub {
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
}
.btn:hover:not(:disabled) {
  background: var(--surface-strong);
  border-color: var(--text-faint);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }

.btn-primary {
  background: var(--cyan);
  color: #060916;
  border-color: var(--cyan);
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: #67e8f9;
  border-color: #67e8f9;
}
.btn-primary.is-speaking {
  animation: speakingPulse 1s var(--ease-in-out) infinite;
}
@keyframes speakingPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--cyan); }
  50% { box-shadow: 0 0 0 6px transparent; }
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text); background: var(--surface); }

.btn-icon {
  width: 40px; height: 40px;
  padding: 0;
}

/* ----- Communicate page layout ----- */
.studio {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}
@media (max-width: 1100px) {
  .studio { grid-template-columns: 1fr; }
}

.cam-stage {
  position: relative;
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-2);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.cam-stage::before {
  content: '';
  position: absolute;
  inset: 12px;
  pointer-events: none;
  background:
    linear-gradient(to right, var(--cyan) 24px, transparent 24px) top left/24px 1px no-repeat,
    linear-gradient(to bottom, var(--cyan) 24px, transparent 24px) top left/1px 24px no-repeat,
    linear-gradient(to left, var(--cyan) 24px, transparent 24px) top right/24px 1px no-repeat,
    linear-gradient(to bottom, var(--cyan) 24px, transparent 24px) top right/1px 24px no-repeat,
    linear-gradient(to right, var(--cyan) 24px, transparent 24px) bottom left/24px 1px no-repeat,
    linear-gradient(to top, var(--cyan) 24px, transparent 24px) bottom left/1px 24px no-repeat,
    linear-gradient(to left, var(--cyan) 24px, transparent 24px) bottom right/24px 1px no-repeat,
    linear-gradient(to top, var(--cyan) 24px, transparent 24px) bottom right/1px 24px no-repeat;
  opacity: 0.55;
  z-index: 2;
}

.cam-frame {
  position: relative;
  border-radius: calc(var(--radius-lg) - 4px);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4 / 3;
}
.cam-frame video,
.cam-frame canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
.cam-frame canvas { transform: scaleX(1); }

.cam-chip {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 100px;
  background: rgba(6, 9, 22, 0.65);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-muted);
  max-width: calc(100% - 90px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cam-chip .pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--rose);
  flex-shrink: 0;
}
.cam-chip.live .pulse {
  background: var(--emerald);
  animation: pulse 1.6s var(--ease-in-out) infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--emerald); }
  50% { opacity: 0.6; box-shadow: 0 0 0 8px transparent; }
}

.cam-fps {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  z-index: 3;
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 100px;
  background: rgba(6, 9, 22, 0.65);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--emerald);
}
.cam-fps.hidden { display: none; }

.cam-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4) var(--space-2);
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  text-transform: uppercase;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ----- Recognized box ----- */
.recog-card {
  position: relative;
  overflow: hidden;
}
.recog-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, var(--cyan), transparent 60%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--ease-out);
}
.recog-card.active::after { opacity: 0.06; }
.recog-card.emitted::after { opacity: 0.18; }

.recog-word {
  font-family: var(--ff-display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(48px, 7vw, 88px);
  line-height: 1;
  letter-spacing: -0.02em;
  margin: var(--space-3) 0;
  min-height: 1em;
}
.recog-word.empty { color: var(--text-faint); font-style: normal; }
.recog-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.recog-conf-bar {
  flex: 1;
  height: 4px;
  background: var(--surface-strong);
  border-radius: 100px;
  overflow: hidden;
  position: relative;
}
.recog-conf-bar > div {
  position: absolute;
  inset: 0;
  width: 0%;
  background: linear-gradient(to right, var(--cyan), var(--violet));
  transition: width 0.2s var(--ease-out);
  border-radius: 100px;
}

/* ----- Top-3 alternatives ladder ----- */
.top3 {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.top3.hidden { display: none; }
.top3-row {
  display: grid;
  grid-template-columns: 22px 1fr 38px;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.top3-letter {
  font-family: var(--ff-display);
  font-weight: 600;
  font-style: italic;
  font-size: 16px;
  color: var(--text-faint);
  text-align: center;
}
.top3-best .top3-letter { color: var(--cyan); }
.top3-bar {
  height: 3px;
  background: var(--surface-strong);
  border-radius: 100px;
  overflow: hidden;
}
.top3-bar > div {
  height: 100%;
  background: var(--text-faint);
  border-radius: 100px;
  transition: width 0.18s var(--ease-out);
}
.top3-best .top3-bar > div { background: linear-gradient(to right, var(--cyan), var(--violet)); }
.top3-pct { text-align: right; color: var(--text-faint); }

/* ----- Sentence panel ----- */
.sentence-panel { display: flex; flex-direction: column; }
.sentence-display {
  font-family: var(--ff-display);
  font-weight: 500;
  font-size: clamp(22px, 2.6vw, 30px);
  line-height: 1.35;
  letter-spacing: -0.01em;
  min-height: 3.5em;
  padding: var(--space-4);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  word-break: break-word;
}
.tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--space-4);
  min-height: 28px;
}
.token {
  font-family: var(--ff-mono);
  font-size: 11.5px;
  padding: 4px 9px;
  border-radius: 100px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.token-spell { color: var(--violet); border-color: var(--violet); }
.token-active {
  background: var(--cyan);
  color: #060916;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.25);
}

.sentence-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ----- History panel ----- */
.history-panel { margin-top: var(--space-5); }
.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 320px;
  overflow-y: auto;
  padding: var(--space-2);
  background: var(--surface);
  border-radius: var(--radius-md);
}
.history-empty {
  font-family: var(--ff-mono);
  font-size: 12px;
  color: var(--text-faint);
  padding: var(--space-4);
  text-align: center;
}
.history-item {
  padding: var(--space-3);
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.15s var(--ease-out);
}
.history-item:hover { border-color: var(--border-strong); }
.history-meta {
  font-family: var(--ff-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.history-text {
  font-size: 14px;
  color: var(--text);
  margin-bottom: var(--space-2);
  word-break: break-word;
}
.history-actions {
  display: flex;
  gap: 4px;
}
.history-actions .btn { font-size: 11px; height: 26px; padding: 0 8px; }

/* ----- Vocab browser ----- */
.vocab-browser {
  margin-top: var(--space-5);
}
.vocab-search {
  width: 100%;
  height: 36px;
  padding: 0 var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 13px;
  margin-bottom: var(--space-3);
}
.vocab-search:focus {
  outline: none;
  border-color: var(--cyan);
}
.vocab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--space-3);
  max-height: 280px;
  overflow-y: auto;
  padding: var(--space-2);
  background: var(--surface);
  border-radius: var(--radius-md);
}
.vocab-chip {
  font-family: var(--ff-mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 100px;
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.vocab-empty {
  font-family: var(--ff-mono);
  font-size: 11.5px;
  color: var(--text-faint);
  padding: var(--space-3);
}

/* ----- Status line ----- */
.status-line {
  font-family: var(--ff-mono);
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

/* ----- Landing page hero ----- */
.hero {
  padding: var(--space-8) var(--space-7);
  max-width: 1200px;
  margin: 0 auto;
}
.hero-eyebrow {
  font-family: var(--ff-mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.hero-title {
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: clamp(48px, 8vw, 112px);
  line-height: 0.96;
  letter-spacing: -0.035em;
  margin: 0 0 var(--space-5) 0;
  max-width: 16ch;
}
.hero-title em { font-style: italic; color: var(--cyan); font-weight: 500; }
.hero-lede {
  font-size: 19px;
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 56ch;
  margin-bottom: var(--space-6);
}
.hero-cta {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-8);
  padding: var(--space-5) 0;
  border-top: 1px solid var(--border);
}
.hero-stat-num {
  font-family: var(--ff-display);
  font-weight: 600;
  font-style: italic;
  font-size: 44px;
  line-height: 1;
  color: var(--cyan);
  letter-spacing: -0.02em;
}
.hero-stat-label {
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 6px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-8);
  padding: 0 var(--space-7);
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}
.feature {
  padding: var(--space-5);
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}
.feature:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.feature-num {
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.1em;
  margin-bottom: var(--space-2);
}
.feature-title {
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: 19px;
  margin: 0 0 var(--space-2) 0;
  letter-spacing: -0.005em;
}
.feature p { color: var(--text-muted); margin: 0; font-size: 14.5px; }
.feature code {
  font-family: var(--ff-mono);
  font-size: 12.5px;
  padding: 1px 5px;
  background: var(--surface-strong);
  border-radius: 4px;
}

/* ----- How-to section ----- */
.how-to {
  margin: var(--space-8) auto;
  padding: 0 var(--space-7);
  max-width: 1200px;
}
.how-to-title {
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: clamp(28px, 3.5vw, 42px);
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-5) 0;
}
.how-to-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
}
.how-to-card {
  padding: var(--space-5);
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  position: relative;
}
.how-to-num {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.08em;
}
.how-to-sign {
  font-family: var(--ff-display);
  font-style: italic;
  font-weight: 500;
  font-size: 28px;
  letter-spacing: -0.01em;
  color: var(--cyan);
  margin-bottom: var(--space-2);
}
.how-to-step {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

/* ----- Honest disclosure box ----- */
.disclosure {
  margin: var(--space-7) auto;
  max-width: 880px;
  padding: var(--space-5) var(--space-5);
  background: var(--surface);
  border-left: 3px solid var(--amber);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.disclosure h4 {
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
  margin: 0 0 var(--space-2) 0;
}
.disclosure p { margin: 0; color: var(--text-muted); font-size: 14.5px; line-height: 1.55; }
.disclosure p + p { margin-top: var(--space-2); }

/* ----- Utility ----- */
.row { display: flex; align-items: center; gap: var(--space-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.col { display: flex; flex-direction: column; gap: var(--space-3); }
.hidden { display: none !important; }

/* ----- Mode toggle ----- */
.mode-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}
.mode-btn {
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
}
.mode-btn:hover { color: var(--text-muted); }
.mode-btn.active {
  background: var(--bg-elev-1);
  color: var(--cyan);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ----- Settings overlay panel ----- */
.overlay-panel {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 22, 0.55);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease-out);
}
.overlay-panel.open {
  opacity: 1;
  pointer-events: auto;
}
[data-theme="light"] .overlay-panel,
:root:not([data-theme]) .overlay-panel {
  background: rgba(15, 23, 42, 0.35);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .overlay-panel {
    background: rgba(15, 23, 42, 0.35);
  }
}

.panel-card {
  width: 100%;
  max-width: 440px;
  height: 100vh;
  background: var(--bg-elev-1);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-2);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s var(--ease-out);
  overflow-y: auto;
}
.overlay-panel.open .panel-card { transform: translateX(0); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-elev-1);
  z-index: 2;
}
.panel-title {
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.01em;
  margin: 0;
}
.panel-section {
  padding: var(--space-5);
  border-bottom: 1px solid var(--border);
}
.panel-section-title {
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 var(--space-4) 0;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}
.setting-row.stacked {
  flex-direction: column;
  align-items: stretch;
}
.setting-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.setting-label {
  font-size: 14px;
  color: var(--text);
}
.setting-value {
  font-family: var(--ff-mono);
  font-size: 12px;
  color: var(--cyan);
}
.setting-hint {
  font-family: var(--ff-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  margin-top: 4px;
}
.setting-input {
  height: 32px;
  padding: 0 var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--surface-strong);
  border-radius: 100px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--cyan);
  cursor: pointer;
  border: 2px solid var(--bg-elev-1);
  box-shadow: 0 0 0 1px var(--cyan);
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--cyan);
  cursor: pointer;
  border: 2px solid var(--bg-elev-1);
}
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 38px;
  height: 22px;
  border-radius: 100px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.18s var(--ease-out);
}
input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.18s var(--ease-out), background 0.18s var(--ease-out);
}
input[type="checkbox"]:checked {
  background: var(--cyan);
  border-color: var(--cyan);
}
input[type="checkbox"]:checked::after {
  transform: translateX(16px);
  background: #060916;
}

.kbd-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  font-size: 12px;
  color: var(--text-muted);
}
kbd {
  display: inline-block;
  font-family: var(--ff-mono);
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  color: var(--text);
  margin-right: 6px;
  min-width: 24px;
  text-align: center;
}

.panel-footer {
  padding: var(--space-5);
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  position: sticky;
  bottom: 0;
  background: var(--bg-elev-1);
  border-top: 1px solid var(--border);
}

/* ----- Hint toast ----- */
.hint-toast {
  position: fixed;
  bottom: var(--space-5);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  font-size: 13px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out);
  pointer-events: none;
  z-index: 90;
  max-width: 90vw;
}
.hint-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.hint-toast strong { color: var(--cyan); margin-right: 6px; }
