/* ============================= THEME TOKENS ============================= */
:root{
  --radius-s:8px; --radius-m:14px; --radius-l:22px;
  --font-display:'Space Grotesk',sans-serif;
  --font-mono:'IBM Plex Mono',monospace;
  --font-body:'Inter',sans-serif;
  color-scheme:light;
  /* Native <option> list colours (pre-theme paint falls back to the light set). */
  --select-bg:#FFFFFF; --select-fg:#14171A;
  --select-active-bg:#E9E7E2; --select-active-fg:#14171A;
}
:root[data-theme="white"]{
  --bg:#FDFDFC; --surface:#FFFFFF; --surface-2:#F2F1EE; --border:rgba(20,23,26,.10);
  --text:#14171A; --text-dim:#5B6169; --accent:#FF4C29; --accent-2:#0EA5A4; --accent-hover:#FF4C29; --accent-hover-fg:#FFFFFF;
  --success:#1E9E5A; --error:#E23E3E; --glass:rgba(255,255,255,.6); --shadow:0 10px 40px rgba(20,23,26,.08);
  color-scheme:light;
  --select-bg:#FFFFFF; --select-fg:#14171A;
  --select-active-bg:#E9E7E2; --select-active-fg:#14171A;
}
:root[data-theme="black"]{
  --bg:#000000; --surface:#0C0C0C; --surface-2:#171717; --border:rgba(255,255,255,.10);
  --text:#EDEDED; --text-dim:#8A8A8A; --accent:#C6FF3D; --accent-2:#5CC8FF; --accent-hover:#C6FF3D; --accent-hover-fg:#14171A;
  --success:#7CE38B; --error:#FF6B6B; --glass:rgba(20,20,20,.55); --shadow:0 10px 40px rgba(0,0,0,.6);
  color-scheme:dark;
  --select-bg:#171717; --select-fg:#EDEDED;
  --select-active-bg:#2B2B2B; --select-active-fg:#FFFFFF;
}
:root[data-theme="ocean"]{
  --bg:#071426; --surface:#0C1E36; --surface-2:#102844; --border:rgba(220,232,245,.10);
  --text:#DCE8F5; --text-dim:#8AA1B8; --accent:#2BB3C0; --accent-2:#F2A65A; --accent-hover:#2BB3C0; --accent-hover-fg:#14171A;
  --success:#5FD4A0; --error:#FF7A7A; --glass:rgba(12,30,54,.55); --shadow:0 10px 40px rgba(0,0,0,.5);
  color-scheme:dark;
  --select-bg:#102844; --select-fg:#DCE8F5;
  --select-active-bg:#1B3B60; --select-active-fg:#FFFFFF;
}
:root[data-theme="green"]{
  --bg:#071B12; --surface:#0C2418; --surface-2:#10301F; --border:rgba(217,242,227,.10);
  --text:#D9F2E3; --text-dim:#82A895; --accent:#35D07F; --accent-2:#F2C14E; --accent-hover:#35D07F; --accent-hover-fg:#14171A;
  --success:#7CE38B; --error:#FF7A7A; --glass:rgba(12,36,24,.55); --shadow:0 10px 40px rgba(0,0,0,.5);
  color-scheme:dark;
  --select-bg:#10301F; --select-fg:#D9F2E3;
  --select-active-bg:#19492E; --select-active-fg:#FFFFFF;
}
:root[data-theme="brown"]{
  --bg:#1C130D; --surface:#241914; --surface-2:#2E1F17; --border:rgba(239,227,214,.10);
  --text:#EFE3D6; --text-dim:#A8917E; --accent:#C97B3D; --accent-2:#5FA391; --accent-hover:#C97B3D; --accent-hover-fg:#14171A;
  --success:#7CC98A; --error:#E36A5C; --glass:rgba(36,25,20,.55); --shadow:0 10px 40px rgba(0,0,0,.5);
  color-scheme:dark;
  --select-bg:#2E1F17; --select-fg:#EFE3D6;
  --select-active-bg:#422D22; --select-active-fg:#FFF7EE;
}

*{box-sizing:border-box; margin:0; padding:0;}
html,body{height:100%;}
body{
  background:var(--bg); color:var(--text); font-family:var(--font-body);
  transition:background .4s ease, color .4s ease; min-height:100vh;
  overflow-x:hidden;
}
body[dir="rtl"]{direction:rtl;}
a{color:inherit;}
button{font-family:inherit; cursor:pointer;}
::selection{background:var(--accent); color:var(--bg);}
::-webkit-scrollbar{width:10px; height:10px;}
::-webkit-scrollbar-thumb{background:var(--border); border-radius:10px;}
:focus-visible{outline:2px solid var(--accent); outline-offset:2px;}
.container{max-width:1180px; margin:0 auto; padding:0 24px;}

/* ============================= NAV ============================= */
.navbar{
  position:sticky; top:0; z-index:40; backdrop-filter:blur(16px);
  background:var(--glass); border-bottom:1px solid var(--border);
}
.nav-inner{display:flex; align-items:center; gap:12px; min-height:68px; min-width:0; padding-block:8px;}
.brand{display:flex; align-items:center; gap:10px; font-family:var(--font-display); font-weight:700; font-size:20px; letter-spacing:-.02em; flex-shrink:0;}
.brand svg{display:block;}
.brand .caret{display:inline-block; width:3px; height:16px; background:var(--accent); margin-inline-start:2px; animation:blink 1.1s steps(1) infinite;}
@keyframes blink{50%{opacity:0;}}
.nav-links{display:flex; align-items:center; gap:2px; flex:1 1 auto; min-width:0; flex-wrap:wrap;}
.nav-link{
  display:inline-flex; align-items:center; justify-content:center; min-height:40px;
  padding:9px 13px; border:none; background:transparent; color:var(--text-dim);
  font-size:13.5px; font-weight:600; border-radius:999px; white-space:nowrap; transition:.2s;
  text-decoration:none;
}
.nav-link:hover{color:var(--text); background:var(--surface-2);}
.nav-link.active{color:var(--bg); background:var(--text);}
.nav-right{display:flex; align-items:center; gap:10px; flex-shrink:0;}
.theme-dots{display:flex; gap:8px; align-items:center; padding:4px 8px; background:var(--surface-2); border-radius:999px;}
.theme-dot{position:relative; width:24px; height:24px; border-radius:50%; border:2px solid transparent; cursor:pointer; transition:.15s;}
.theme-dot::after{content:''; position:absolute; inset:-4px; border-radius:50%; /* 32px hit area around the 24px swatch */}
.theme-dot.active{border-color:var(--accent); transform:scale(1.15);}
.lang-select, .select{
  background:var(--surface-2); color:var(--text); border:1px solid var(--border); border-radius:999px;
  padding:8px 12px; min-height:40px; font-size:13px; font-weight:600; font-family:inherit;
  transition:background-color .15s, color .15s, border-color .15s;
}
.select:hover{
  background:var(--accent); color:#14171A; border-color:var(--accent);
}

/* Native dropdown lists -------------------------------------------------------
   Dark themes used to render light text on the browser's white popup. The
   `color-scheme` declarations on the theme roots above fix the popup chrome and
   mobile/webview pickers; the solid per-theme colours below fix the option rows
   themselves in Chromium, Edge and Firefox. Every value is an opaque hex so the
   system popup cannot blend it with a white background. */
select option,
select optgroup{
  background-color:var(--select-bg);
  color:var(--select-fg);
}
select optgroup{font-weight:700;}
select option:checked{
  background-color:var(--select-active-bg);
  color:var(--select-active-fg);
}
select option:hover{
  background-color:var(--accent-hover);
  color:var(--accent-hover-fg);
}
select option:disabled{color:var(--text-dim);}
.user-pill{font-size:13px; font-weight:600; color:var(--text-dim); white-space:nowrap; max-width:140px; overflow:hidden; text-overflow:ellipsis;}
.hide{display:none !important;}

/* Below ~1100px the six nav links no longer fit beside the brand and controls,
   so they move to their own row and wrap instead of scrolling/clipping. */
@media (max-width:1100px){
  .nav-inner{flex-wrap:wrap; min-height:0; padding-block:10px 8px;}
  .brand{order:1;}
  .nav-right{order:2; margin-inline-start:auto;}
  .nav-links{order:3; flex:0 0 100%; width:100%; margin-top:8px;}
}
@media (max-width:760px){
  .nav-right .user-pill{display:none;}
  .lang-select{max-width:118px; font-size:12px; padding:8px 9px;}
}
@media (max-width:480px){
  .brand{font-size:16px;}
  .brand svg{width:26px; height:26px;}
  .theme-dots{gap:5px; padding:4px 5px;}
  .lang-select{max-width:92px; font-size:11.5px; padding:7px 8px;}
  .nav-links{gap:4px;}
  .nav-link{padding:8px 11px;}
}

/* ============================= HERO ============================= */
.hero{padding-block:64px 30px; position:relative;}
.hero-grid{display:grid; grid-template-columns:1.1fr .9fr; gap:48px; align-items:center;}
.eyebrow{font-family:var(--font-mono); font-size:12px; letter-spacing:.14em; text-transform:uppercase; color:var(--accent); margin-bottom:14px;}
.hero h1{font-family:var(--font-display); font-size:clamp(36px,5vw,58px); line-height:1.02; letter-spacing:-.03em; font-weight:700;}
.hero h1 .accent-word{color:var(--accent);}
.hero p.lead{margin-top:18px; color:var(--text-dim); font-size:17px; max-width:46ch; line-height:1.55;}
.hero-cta{display:flex; gap:12px; margin-top:26px;}
.btn{padding:13px 22px; border-radius:999px; font-weight:700; font-size:14px; border:1px solid transparent; text-decoration:none; transition:.2s;}
.btn-primary{background:var(--accent); color:var(--bg);}
.btn-primary:hover{filter:brightness(1.08); transform:translateY(-1px);}
.btn-ghost{background:transparent; border-color:var(--border); color:var(--text);}
.btn-ghost:hover{background:var(--surface-2);}
.hero-demo{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-l);
  padding:22px; box-shadow:var(--shadow); font-family:var(--font-mono); font-size:15px; line-height:1.8; color:var(--text-dim);
  min-height:150px;
}
.hero-demo .typed{color:var(--text);}
.hero-demo .cursor2{display:inline-block; width:2px; height:1em; background:var(--accent); vertical-align:-.15em; animation:blink 1s steps(1) infinite;}

/* ============================= VIEWS ============================= */
.view{display:none; padding:10px 0 90px;}
.view.active{display:block;}
.section-title{font-family:var(--font-display); font-size:26px; font-weight:700; letter-spacing:-.02em; margin:0 0 6px;}
.section-sub{color:var(--text-dim); font-size:14px; margin-bottom:22px;}

/* pill groups */
.pillbar{display:flex; gap:8px; flex-wrap:wrap; margin-bottom:16px;}
.pill{
  display:inline-flex; align-items:center; justify-content:center; min-height:40px; text-align:center;
  background:var(--surface); border:1px solid var(--border); color:var(--text-dim);
  padding:9px 16px; border-radius:999px; font-size:13px; font-weight:600; transition:.15s;
}
.pill:hover{color:var(--text); border-color:var(--accent);}
.pill.active{background:var(--text); color:var(--bg); border-color:var(--text);}

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

/* ============================= TYPING STAGE ============================= */
.stage-top{display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:12px; margin-bottom:18px;}
.stat-row{display:flex; gap:26px; flex-wrap:wrap;}
.stat{font-family:var(--font-mono);}
.stat .num{font-size:26px; font-weight:600; color:var(--accent); line-height:1;}
.stat .lbl{font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:var(--text-dim); margin-top:4px;}
.timer-ring{font-family:var(--font-mono); font-size:22px; font-weight:600; background:var(--surface-2); padding:10px 18px; border-radius:12px;}
.exam-stage-side{display:flex; align-items:center; gap:10px;}
.exam-end-btn{font-size:12px; padding:9px 14px; min-height:40px; color:var(--text-dim);}
.exam-end-btn:hover{color:var(--text); border-color:var(--accent);}

.type-box{
  position:relative; font-family:var(--font-mono); font-size:22px; line-height:1.85; letter-spacing:.01em;
  padding:26px 28px; min-height:180px; max-height:340px; overflow-y:auto; overflow-x:hidden;
  user-select:none; outline:none; cursor:text;
  word-break:break-word; overflow-wrap:anywhere; white-space:normal;
  overscroll-behavior:contain; scroll-margin-block:16px;
}
.type-box .ch{display:inline;}
.type-box.locked{opacity:.55; pointer-events:none;}
.type-box .ch{color:var(--text-dim); border-bottom:2px solid transparent; transition:color .05s;}
.type-box .ch.correct{color:var(--text);}
.type-box .ch.wrong{color:var(--error); background:color-mix(in srgb, var(--error) 15%, transparent); border-radius:3px;}
.type-box .ch.current{border-bottom:2px solid var(--accent); animation:caretPulse 1s ease-in-out infinite;}
@keyframes caretPulse{50%{border-color:transparent;}}
.type-box.rtl{direction:rtl; text-align:right;}
.blur-veil{position:absolute; inset:0; display:flex; align-items:center; justify-content:center; background:var(--glass); backdrop-filter:blur(6px); border-radius:var(--radius-l); font-weight:700; font-size:15px; color:var(--text-dim);}
.stage-actions{display:flex; gap:10px; margin-top:18px;}

.results-overlay{
  display:none; text-align:center; padding:40px 20px;
}
.results-overlay.show{display:block;}
.results-grid{display:grid; grid-template-columns:repeat(4,1fr); gap:16px; max-width:640px; margin:22px auto 0;}
.results-grid .box{background:var(--surface-2); border-radius:14px; padding:18px 8px;}
.results-grid .box .v{font-family:var(--font-mono); font-size:28px; font-weight:700; color:var(--accent);}
.results-grid .box .l{font-size:11px; color:var(--text-dim); margin-top:4px; text-transform:uppercase; letter-spacing:.06em;}

/* content picker */
.source-grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(230px,1fr)); gap:14px; margin-bottom:20px;}
.source-card{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-m); padding:16px; cursor:pointer; transition:.15s;}
.source-card:hover{border-color:var(--accent); transform:translateY(-2px);}
.source-card.active{border-color:var(--accent); box-shadow:0 0 0 2px var(--accent) inset;}
.source-card.disabled{opacity:.45; cursor:not-allowed;}
.source-card.disabled:hover{transform:none; border-color:var(--border);}
.source-card h3{font-size:14px; margin-bottom:4px;}
.source-card p{font-size:12px; color:var(--text-dim);}
.tag{display:inline-block; font-size:10px; font-family:var(--font-mono); padding:2px 8px; border-radius:999px; background:var(--surface-2); color:var(--text-dim); margin-top:8px;}

.info-banner{
  background:color-mix(in srgb, var(--accent) 10%, var(--surface)); border:1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  color:var(--text); font-size:12.5px; line-height:1.5; padding:11px 16px; border-radius:12px; margin-bottom:14px;
}
.info-banner.kbd{background:var(--surface-2); border-color:var(--border); color:var(--text-dim);}
.dropzone{
  border:2px dashed var(--border); border-radius:var(--radius-m); padding:26px; text-align:center; color:var(--text-dim); font-size:13px;
  transition:.15s; margin-bottom:16px;
}
.dropzone.drag{border-color:var(--accent); color:var(--accent); background:var(--surface-2);}
.fmt-row{display:flex; gap:6px; justify-content:center; margin-top:10px; flex-wrap:wrap;}
.fmt-chip{font-family:var(--font-mono); font-size:10px; background:var(--surface-2); padding:3px 8px; border-radius:6px;}

/* Exam */
.exam-form{display:grid; grid-template-columns:1fr 1fr; gap:14px;}
.field{display:flex; flex-direction:column; gap:6px;}
.field label{font-size:12px; color:var(--text-dim); font-weight:600;}
.field input, .field select{
  background:var(--surface-2); border:1px solid var(--border); border-radius:10px; padding:11px 13px; color:var(--text); font-size:14px; font-family:inherit;
}
table{width:100%; border-collapse:collapse; font-size:13px; margin-top:6px;}
th,td{text-align:start; padding:10px 12px; border-bottom:1px solid var(--border);}
th{color:var(--text-dim); font-weight:600; font-size:11px; text-transform:uppercase; letter-spacing:.05em;}
tbody tr:nth-child(even) td{background:color-mix(in srgb, var(--surface-2) 55%, transparent);}
tr:hover td{background:var(--surface-2);}
#rosterTable{font-size:12px;}
#rosterTable th, #rosterTable td{padding:7px 6px;}
#rosterTable td:nth-child(1), #rosterTable td:nth-child(4), #rosterTable td:nth-child(5),
#rosterTable td:nth-child(6), #rosterTable td:nth-child(7), #rosterTable td:nth-child(8),
#rosterTable th:nth-child(1), #rosterTable th:nth-child(4), #rosterTable th:nth-child(5),
#rosterTable th:nth-child(6), #rosterTable th:nth-child(7), #rosterTable th:nth-child(8){white-space:nowrap;}
#rosterTable td:nth-child(1),
#rosterTable td:nth-child(5),
#rosterTable td:nth-child(6),
#rosterTable td:nth-child(7),
#rosterTable th:nth-child(1),
#rosterTable th:nth-child(5),
#rosterTable th:nth-child(6),
#rosterTable th:nth-child(7){text-align:center; font-variant-numeric:tabular-nums;}

/* Tables scroll inside their card instead of pushing the whole page sideways. */
.table-scroll{max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; overscroll-behavior-x:contain; margin-top:6px;}
.table-scroll table{margin-top:0; min-width:560px;}
.table-scroll #rosterTable{min-width:720px;}
.roster-head{display:flex; flex-wrap:wrap; justify-content:space-between; align-items:center; gap:10px; margin-bottom:10px;}
.roster-head .btn{white-space:normal; min-height:40px;}
.roster-note{font-size:12px; line-height:1.65; color:var(--text-dim); margin-top:14px; max-width:90ch;}

/* Arcade */
.game-grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(230px,1fr)); gap:16px;}
.game-card{
  position:relative; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-m);
  overflow:hidden; cursor:pointer; transition:transform .18s, border-color .18s, box-shadow .18s;
}
.game-card:hover{transform:translateY(-4px); border-color:color-mix(in srgb, var(--ga) 65%, var(--border)); box-shadow:0 16px 34px rgba(0,0,0,.22);}
a.game-card{display:block; color:inherit; text-decoration:none;}
a.game-card:hover{color:inherit;}
.gc-poster{
  position:relative; height:104px; display:flex; align-items:center; justify-content:center; overflow:hidden;
  background:
    radial-gradient(120% 120% at 20% 0%, color-mix(in srgb, var(--ga) 70%, #000) 0%, transparent 62%),
    linear-gradient(135deg, var(--ga), var(--gb));
}
.gc-poster::before{content:''; position:absolute; inset:0; background:repeating-linear-gradient(115deg, rgba(255,255,255,.13) 0 2px, transparent 2px 16px); opacity:.55;}
.gc-emoji{font-size:44px; filter:drop-shadow(0 8px 16px rgba(0,0,0,.42)); transform:translateY(2px); z-index:1;}
.gc-cat{position:absolute; top:8px; inset-inline-start:10px; font-family:var(--font-mono); font-size:9px; letter-spacing:.12em; text-transform:uppercase; color:rgba(255,255,255,.88); background:rgba(0,0,0,.25); border:1px solid rgba(255,255,255,.22); padding:3px 7px; border-radius:999px;}
.gc-shine{position:absolute; top:-40%; left:-40%; width:55%; height:180%; background:linear-gradient(90deg, transparent, rgba(255,255,255,.28), transparent); transform:rotate(18deg); transition:left .55s ease;}
.game-card:hover .gc-shine{left:120%;}
.gc-body{padding:14px 16px 16px;}
.gc-body h3{font-family:var(--font-display); font-size:15px; margin-bottom:4px;}
.gc-body p{font-size:11.5px; color:var(--text-dim); line-height:1.45; min-height:33px;}
.gc-foot{display:flex; align-items:center; justify-content:space-between; margin-top:10px; font-family:var(--font-mono); font-size:10px; color:var(--text-dim);}
.gc-foot b{color:var(--accent);}
.gc-play{width:24px; height:24px; display:grid; place-items:center; border-radius:50%; background:var(--surface-2); color:var(--text); font-size:9px;}
.game-card:hover .gc-play{background:var(--accent); color:var(--bg);}

.game-card-pad{padding:18px;}
.game-stage-head{display:flex; justify-content:space-between; align-items:flex-start; gap:14px; flex-wrap:wrap; margin-bottom:14px;}
.game-stage-title{font-family:var(--font-display); font-weight:700; font-size:20px;}
.game-stage-sub{font-size:12px; color:var(--text-dim); margin-top:2px;}
.game-stage-actions{display:flex; gap:8px;}
.game-head-btn{padding:8px 16px; min-height:40px; font-size:12px;}
.game-stage{position:relative; height:clamp(420px, 62vh, 620px); background:#07070f; border-radius:var(--radius-m); overflow:hidden; margin-top:0; padding:0;}
.arcade-wrap{position:relative; width:100%; height:100%; overflow:hidden; background:#07070f;}
.arcade-wrap:fullscreen{width:100vw; height:100vh; border-radius:0;}
.arcade-canvas{display:block; width:100%; height:100%;}
.arcade-hud{
  position:absolute; top:0; left:0; right:0; display:flex; align-items:center; gap:16px; padding:10px 14px;
  font-family:var(--font-mono); font-size:11px; color:rgba(255,255,255,.55);
  background:linear-gradient(180deg, rgba(4,4,10,.92) 0%, rgba(4,4,10,.72) 55%, transparent 100%); z-index:6; pointer-events:none;
}
.ah-group{display:flex; align-items:baseline; gap:6px;}
.ah-label{font-size:9px; letter-spacing:.12em; text-transform:uppercase; color:rgba(255,255,255,.45);}
.ah-val{font-size:13px; color:#fff; font-weight:700;}
.ah-hearts{color:#ff5f6d; letter-spacing:2px;}
.ah-actions{margin-inline-start:auto; gap:6px; pointer-events:auto;}
.ah-btn{width:36px; height:36px; border-radius:8px; border:1px solid rgba(255,255,255,.18); background:rgba(255,255,255,.07); color:#fff; font-size:11px; display:grid; place-items:center; cursor:pointer;}
.ah-btn:hover{background:rgba(255,255,255,.16);}
.arcade-overlay{position:absolute; inset:0; display:none; align-items:center; justify-content:center; background:rgba(3,4,12,.62); backdrop-filter:blur(4px); z-index:8;}
.arcade-overlay.show{display:flex;}
.ao-card{background:linear-gradient(160deg, rgba(24,26,46,.98), rgba(9,10,22,.98)); border:1px solid rgba(255,255,255,.16); border-radius:20px; padding:30px 36px; text-align:center; min-width:min(340px,86%); box-shadow:0 30px 70px rgba(0,0,0,.6);}
.ao-kicker{font-family:var(--font-mono); font-size:11px; letter-spacing:.18em; text-transform:uppercase; color:var(--ga);}
.ao-score{font-family:var(--font-display); font-size:54px; font-weight:800; line-height:1.05; color:#fff; margin-top:4px;}
.ao-label{font-size:10px; letter-spacing:.16em; text-transform:uppercase; color:rgba(255,255,255,.45);}
.ao-best{margin-top:12px; font-family:var(--font-mono); font-size:12px; color:rgba(255,255,255,.6);}
.ao-best.is-best{color:#ffd166;}
.ao-actions{display:flex; gap:10px; justify-content:center; margin-top:20px;}
.ao-actions .btn{padding:11px 20px; font-size:13px;}
/* The pause/game-over card is always dark, so the theme's ghost button would
   render dark-on-dark in the light theme. Force a light ghost variant there. */
.arcade-overlay .btn-ghost{color:#fff; border-color:rgba(255,255,255,.4); background:rgba(255,255,255,.08);}
.arcade-overlay .btn-ghost:hover{color:#fff; border-color:rgba(255,255,255,.65); background:rgba(255,255,255,.18);}

/* practice selects */
.select-row{display:flex; align-items:center; gap:10px; margin-bottom:16px; flex-wrap:wrap;}
.select-row label{font-size:12px; font-weight:600; color:var(--text-dim);}
.select-row select{max-width:100%; min-width:240px;}

/* Passage selector -------------------------------------------------------------
   Native <option> popups cannot be width-constrained, so the Passage select is
   rendered as a trigger + listbox. The real <select> stays in the DOM (hidden)
   as the state holder, so chapter selection, language re-rendering and
   loadPracticeText() keep their existing code path. */
.select-row .passage-native{display:none;}
.passage-dd{position:relative; flex:0 1 420px; min-width:0; max-width:100%; box-sizing:border-box;}
.passage-trigger{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  width:100%; max-width:100%; box-sizing:border-box;
  min-height:40px; padding:8px 14px; border-radius:999px;
  background:var(--surface-2); border:1px solid var(--border); color:var(--text);
  font-family:inherit; font-size:13px; font-weight:600; text-align:start; cursor:pointer;
  transition:background-color .15s, color .15s, border-color .15s;
}
.passage-trigger:hover{border-color:var(--accent);}
.passage-trigger:focus-visible{outline:2px solid var(--accent); outline-offset:2px;}
.passage-value{flex:1 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.passage-chevron{
  flex:0 0 auto; width:7px; height:7px; margin-block-start:-3px;
  border-inline-end:2px solid var(--text-dim); border-block-end:2px solid var(--text-dim);
  transform:rotate(45deg); transition:transform .15s, margin .15s;
}
.passage-dd.open .passage-chevron{transform:rotate(225deg); margin-block-start:3px;}
.passage-menu{
  position:absolute; inset-inline-start:0; top:calc(100% + 6px); z-index:30;
  width:100%; max-width:100%; box-sizing:border-box;
  max-height:min(320px, 50dvh); overflow-y:auto; overscroll-behavior:contain;
  padding:6px; background:var(--select-bg); color:var(--select-fg);
  border:1px solid var(--border); border-radius:14px; box-shadow:var(--shadow);
}
.passage-menu[hidden]{display:none;}
.passage-option{
  display:block; width:100%; box-sizing:border-box; padding:9px 10px; border-radius:9px;
  font-size:13px; line-height:1.35; text-align:start;
  white-space:normal; overflow-wrap:anywhere; cursor:pointer;
}
.passage-option:hover,
.passage-option.is-active{background:var(--accent-hover); color:var(--accent-hover-fg);}
.passage-option[aria-selected="true"]{font-weight:700;}
.passage-option[aria-selected="true"]::before{content:'✓'; margin-inline-end:7px; color:var(--accent); font-weight:700;}

/* Analytics */
.analytics-grid{display:grid; grid-template-columns:2fr 1fr; gap:18px;}
.mini-stat{background:var(--surface-2); border-radius:12px; padding:14px 16px; margin-bottom:10px;}
.mini-stat .v{font-family:var(--font-mono); font-size:22px; font-weight:700;}
.mini-stat .l{font-size:11px; color:var(--text-dim);}
.empty-state{text-align:center; padding:60px 20px; color:var(--text-dim);}

/* Guide */
.tips-grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(260px,1fr)); gap:16px;}
.tip-card{padding:20px;}
.tip-num{font-family:var(--font-mono); color:var(--accent); font-size:12px; margin-bottom:8px;}

/* FAQ */
.faq-item{border-bottom:1px solid var(--border);}
.faq-q{width:100%; text-align:start; background:transparent; border:none; color:var(--text); padding:16px 4px; font-size:15px; font-weight:600; display:flex; justify-content:space-between; align-items:center;}
.faq-a{max-height:0; overflow:hidden; transition:max-height .25s ease; color:var(--text-dim); font-size:14px; line-height:1.6;}
.faq-item.open .faq-a{max-height:300px; padding-bottom:16px;}
.faq-plus{transition:.25s;}
.faq-item.open .faq-plus{transform:rotate(45deg);}

/* Modal */
.modal-backdrop{position:fixed; inset:0; background:rgba(0,0,0,.6); backdrop-filter:blur(4px); display:flex; align-items:center; justify-content:center; z-index:100;}
.modal{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-l); padding:34px; width:min(420px,92vw); box-shadow:var(--shadow); text-align:center;}
.modal input{width:100%; margin-top:16px; padding:13px 16px; border-radius:12px; border:1px solid var(--border); background:var(--surface-2); color:var(--text); font-size:15px;}
.modal .btn{width:100%; margin-top:14px;}

footer{border-top:1px solid var(--border); padding:44px 0 0; color:var(--text-dim); font-size:13px; margin-top:40px;}
.footer-grid{display:grid; grid-template-columns:1.3fr 0.9fr 0.9fr 1.1fr 0.9fr; gap:24px; padding-bottom:30px;}
.footer-brand p{margin-top:10px; font-size:13px; line-height:1.6; max-width:32ch;}
.footer-col .footer-heading{font-size:12px; text-transform:uppercase; letter-spacing:.07em; color:var(--text); margin-bottom:12px; font-weight:700;}
.footer-link{display:flex; align-items:center; width:100%; min-height:36px; background:none; border:none; text-align:start; color:var(--text-dim); font-size:13px; padding:5px 0; cursor:pointer; text-decoration:none; font-family:inherit;}
.footer-link:hover{color:var(--accent);}
.footer-note{font-size:12.5px; line-height:1.6;}
.footer-bottom{display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:12px; border-top:1px solid var(--border); padding-block:18px; font-size:12px;}
@media (max-width:760px){ .footer-grid{grid-template-columns:1fr 1fr;} }
@media (max-width:480px){ .footer-grid{grid-template-columns:1fr;} }

@media (max-width:860px){
  .hero-grid{grid-template-columns:1fr;}
  .exam-form{grid-template-columns:1fr;}
  .analytics-grid{grid-template-columns:1fr;}
  .results-grid{grid-template-columns:repeat(2,1fr);}
  .footer-grid{grid-template-columns:repeat(2,1fr);}
}
@media (max-width:640px){
  /* Two rows of nav links would otherwise stay pinned over a short keyboard viewport. */
  .navbar{position:static;}
  .container{padding-inline:16px;}
  .hero{padding-block:40px 20px;}
  .hero h1{font-size:clamp(30px,8vw,44px);}
  .hero-cta{flex-wrap:wrap;}
  .hero-cta .btn{flex:1 1 auto; text-align:center;}
  .hero-demo{font-size:13px; padding:16px;}
  .type-box{font-size:clamp(16px,4.5vw,20px); padding:18px 16px; min-height:140px; max-height:280px;}
  /* Keep the typing box usable when a virtual keyboard shortens the viewport. */
  @supports (height: 1dvh){ .type-box{max-height:min(280px, 46dvh);} }
  .stat .num{font-size:20px;}
  .stat-row{gap:18px 22px;}
  .timer-ring{font-size:17px; padding:8px 12px;}
  .exam-stage-side{flex-wrap:wrap;}
  .card-pad{padding:18px;}
  .stage-top{gap:14px;}
  /* 16px prevents iOS Safari from zooming the page when a field is focused. */
  .field input, .field select, .contact-form textarea, .modal input{font-size:16px;}
  .results-grid{grid-template-columns:repeat(2,1fr); gap:10px;}
  .results-grid .box{padding:14px 6px;}
  .results-grid .box .v{font-size:22px;}
  .section-title{font-size:21px;}
  .modal{padding:24px 20px;}
  .g-grid{grid-template-columns:repeat(4,1fr); padding:16px; gap:8px;}
  .game-stage{height:380px;}
  .g-memory-word{font-size:20px; flex-wrap:wrap;}
  .exam-form{gap:12px;}
  table{font-size:12px;}
  th,td{padding:8px 8px;}
}
@media (max-width:400px){
  /* Keep brand + language + theme dots on one row on 375px phones. */
  .nav-inner{gap:12px;}
  .brand{font-size:15px;}
  .brand svg{width:24px; height:24px;}
  .brand .caret{display:none;}
  .nav-right{gap:6px;}
  .lang-select{max-width:84px; font-size:11px; padding:7px;}
  .theme-dots{gap:8px; padding:3px 4px;}
  .pill{padding:8px 12px; font-size:12.5px;}
  .source-grid{grid-template-columns:1fr;}
  .tips-grid{grid-template-columns:1fr;}
  .results-grid{grid-template-columns:1fr 1fr;}
  .g-grid{grid-template-columns:repeat(3,1fr);}
}

/* ============================= Standalone pages: privacy / terms / contact / 404 ============================= */
.simple-page{padding-block:52px 70px;}
.simple-page .page-head{margin-bottom:34px;}
.simple-page .page-head h1{font-family:var(--font-display); font-size:32px; font-weight:700; letter-spacing:-.02em; margin-bottom:8px; overflow-wrap:break-word;}
.simple-page .page-head .updated{font-size:13px; color:var(--text-dim);}
.simple-page .page-intro{font-size:15px; color:var(--text-dim); max-width:64ch; line-height:1.65; margin-top:14px;}
.legal-section{padding:22px 0; border-top:1px solid var(--border);}
.legal-section:first-of-type{border-top:none;}
.legal-section h2{font-size:16px; font-weight:700; margin-bottom:8px;}
.legal-section p{font-size:14px; color:var(--text-dim); line-height:1.7; max-width:70ch; overflow-wrap:break-word;}
.legal-section h2{overflow-wrap:break-word;}
.legal-contact-note{margin-top:28px; font-size:13.5px; color:var(--text-dim);}
.legal-contact-note a{color:var(--accent); text-decoration:none;}
.legal-contact-note a:hover{text-decoration:underline;}
.legal-links{display:flex; flex-wrap:wrap; gap:8px 18px; margin-top:10px; font-size:13.5px;}
.legal-links a{display:inline-flex; align-items:center; min-height:36px; color:var(--accent); text-decoration:none; font-weight:600;}
.legal-links a:hover{text-decoration:underline;}

.contact-form{display:grid; grid-template-columns:1fr 1fr; gap:14px; max-width:640px; margin-top:26px;}
.contact-form .field.full{grid-column:1 / -1;}
.contact-form textarea{
  background:var(--surface-2); border:1px solid var(--border); border-radius:10px; padding:11px 13px; color:var(--text); font-size:14px; font-family:inherit; resize:vertical; min-height:120px;
}
.contact-form .btn{grid-column:1 / -1; justify-self:start; margin-top:4px;}
.contact-note{font-size:12.5px; color:var(--text-dim); margin-top:10px; max-width:60ch; line-height:1.6;}
.contact-status{margin-top:14px; padding:11px 14px; border-radius:10px; border:1px solid var(--border); background:var(--surface-2); color:var(--text); font-size:13px; line-height:1.55;}
.contact-status[hidden]{display:none;}
.contact-status.is-success{color:var(--success); border-color:color-mix(in srgb, var(--success) 45%, var(--border));}
.contact-status.is-error{color:var(--error); border-color:color-mix(in srgb, var(--error) 45%, var(--border));}
.contact-direct{margin-top:30px; padding-top:22px; border-top:1px solid var(--border); font-size:13.5px; color:var(--text-dim);}
.contact-direct a{display:inline-flex; align-items:center; justify-content:center; min-height:36px; min-width:36px; color:var(--accent); text-decoration:none; font-weight:600;}
.contact-direct a:hover{text-decoration:underline;}

.notfound-wrap{min-height:60vh; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; padding:60px 24px;}
.notfound-wrap .nf-code{font-family:var(--font-display); font-size:74px; font-weight:800; color:var(--accent); line-height:1;}
.notfound-wrap h1{font-size:22px; font-weight:700; margin:14px 0 8px;}
.notfound-wrap p{color:var(--text-dim); font-size:14px; max-width:44ch; margin-bottom:24px;}

.simple-nav-back{display:inline-flex; align-items:center; gap:6px; min-height:40px; font-size:13px; color:var(--text-dim); text-decoration:none; padding:8px 0;}
.simple-nav-back:hover{color:var(--accent);}

@media (max-width:640px){
  .simple-page{padding-block:36px 56px;}
  .simple-page .page-head h1{font-size:27px;}
  .contact-form{grid-template-columns:1fr;}
  .contact-form .field.full{grid-column:auto;}
  /* Must follow the base textarea rule above to win the cascade. */
  .contact-form textarea{font-size:16px;}
}

/* ============================= Arcade responsive ============================= */
@media (max-width:760px){
  .game-grid{grid-template-columns:repeat(2,1fr); gap:12px;}
  .game-stage{height:430px;}
  .ah-btn{width:36px; height:36px;}
  .arcade-hud{gap:10px; padding:8px 10px;}
  .ah-label{font-size:8px;}
  .game-stage-title{font-size:17px;}
  .game-stage-sub{font-size:11px;}
  .ao-card{padding:24px 22px;}
  .ao-score{font-size:44px;}
}
@media (max-width:420px){
  .game-stage{height:400px;}
  .arcade-hud{flex-wrap:wrap; gap:6px 12px; font-size:10px;}
  .ah-label{display:none;}
  .ah-actions{margin-inline-start:0;}
  .gc-poster{height:92px;}
  .gc-emoji{font-size:38px;}
  .select-row select{min-width:0; width:100%;}
}
@media (max-width:360px){
  .game-grid{grid-template-columns:1fr;}
}

/* ============================= RESPONSIVE HARDENING ============================= */
/* Added after a layout audit at 320/375/390/430/768/820/1024/1280 in EN, UR and AR.
   Everything below is additive: themes, palette, typography scale and behaviour
   are untouched. */

/* Language picker -------------------------------------------------------------
   A list of 19 native language names cannot fit inside a phone-width pill, so on
   <=760px the closed control renders the two-letter code and lets the native
   <select> (invisible, full-size, 16px to stop iOS zoom) open the real menu with
   every full name. Desktop keeps the original visible <select>. */
.lang-field{display:inline-flex; align-items:center; position:relative; flex:0 0 auto;}
.lang-code{display:none;}

/* Phone and tablet-portrait layout (<=760px) --------------------------------
   The wrapped nav rows are useless once they scroll away and harmful while
   pinned, so the nav stops being sticky at this width. */
@media (max-width:760px){
  .navbar{position:static;}

  .lang-field{
    min-height:40px; padding-inline:12px 26px;
    background:var(--surface-2); border:1px solid var(--border); border-radius:999px;
  }
  .lang-field .lang-code{display:inline-block; font-size:12px; font-weight:700; letter-spacing:.06em; line-height:1;}
  .lang-field::after{
    content:''; position:absolute; inset-inline-end:11px; top:50%; width:5px; height:5px;
    border-inline-end:2px solid var(--text-dim); border-block-end:2px solid var(--text-dim);
    transform:translateY(-70%) rotate(45deg); pointer-events:none;
  }
  .lang-field .lang-select{
    position:absolute; inset:0; width:100%; height:100%; min-height:0; padding:0;
    border:0; background:transparent; opacity:0; font-size:16px; max-width:none;
  }
  .lang-field .lang-select:focus-visible{outline:none;}
  .lang-field:focus-within{outline:2px solid var(--accent); outline-offset:2px;}
}

/* Touch devices: phones and tablets both need >=40px controls. The compact
   language chip above stays phone/tablet-portrait only (it needs the space). */
@media (max-width:1024px){
  /* Dots keep their 24px touch target on every screen size. */
  .theme-dots{gap:8px;}
  .theme-dot::after{inset:-4px;}
  .footer-link{display:flex; align-items:center; min-height:40px; width:100%; padding:6px 0;}
  .ah-btn{width:36px; height:36px;}
  .legal-links a, .legal-contact-note a, .contact-direct a{display:inline-block; padding-block:8px;}
  .simple-nav-back{min-height:40px; padding-block:10px;}
}

a.brand{padding-block:7px;}

@media (max-width:400px){
  .lang-field{padding-inline:10px 24px;}
  .theme-dots{gap:6px;}
}

/* Passage picker on phones: full-width trigger (no 240px intrinsic minimum),
   16px text (no Safari focus zoom) and a popup that can never exceed it. */
@media (max-width:430px){
  .select-row .passage-dd{flex:1 1 100%; width:100%;}
  .passage-trigger{min-height:44px; font-size:16px;}
  .passage-menu{max-height:min(300px, 48dvh);}
  .passage-option{font-size:15px; padding:10px;}
}

/* iOS Safari zooms the whole page when it focuses a control whose font-size is
   below 16px. Enforce 16px for every remaining select/input on phones. */
@media (max-width:640px){
  .select, #chapterSelect, #exDuration, #exPassage,
  .modal input, .contact-form textarea{font-size:16px;}
}

/* Short viewports: landscape tablets and any viewport with an on-screen keyboard
   open. The typing surface must stay inside what is actually visible. */
@media (max-height:560px){
  .navbar{position:static;}
  .type-box{max-height:min(340px,46vh); min-height:120px;}
}
@supports (height:1dvh){
  @media (max-height:560px){
    .type-box{max-height:min(340px,46dvh);}
  }
}

/* Long translated words (German compounds, transliterations) must not widen a
   grid column: break them and let the track shrink below its min-content size. */
body{overflow-wrap:break-word;}
.hero-grid > *, .analytics-grid > *, .footer-grid > *,
.game-grid > *, .source-grid > *, .tips-grid > *, .results-grid > *{min-width:0;}
.hero h1{hyphens:auto; overflow-wrap:anywhere;}

/* Final horizontal guard: no viewport may scroll sideways. `clip` (unlike
   `hidden`) does not create a scroll container, so the sticky desktop navbar
   keeps working while any stray wide child is clipped instead of panned. */
html, body{overflow-x:clip;}

/* Exam form -------------------------------------------------------------------
   A grid item defaults to min-width:auto, so the native width of an <input>
   pushed the single-column form wider than a 320px viewport. */
.exam-form > .field{min-width:0;}
.field input, .field select{width:100%; min-width:0; max-width:100%;}

/* FAQ -------------------------------------------------------------------------
   The open state capped answers at 300px, which silently cut longer translated
   answers. 1200px is still finite (for the height transition) but never clips. */
.faq-item.open .faq-a{max-height:1200px; transition:max-height .3s ease;}

/* Modal -----------------------------------------------------------------------
   Centre when there is room, scroll when a keyboard/landscape viewport is
   shorter than the dialog instead of clipping it off-screen. */
.modal-backdrop{align-items:flex-start; justify-content:center; overflow-y:auto; overscroll-behavior:contain; padding:16px;}
.modal{margin:auto;}

/* RTL typography --------------------------------------------------------------
   letter-spacing separates the cursive joins of Arabic and Urdu; remove the
   tracking used for Latin small caps when the document is right-to-left. */
[dir="rtl"] .eyebrow,
[dir="rtl"] .stat .lbl,
[dir="rtl"] th,
[dir="rtl"] .gc-cat,
[dir="rtl"] .ah-label,
[dir="rtl"] .ao-kicker,
[dir="rtl"] .ao-label,
[dir="rtl"] .results-grid .box .l,
[dir="rtl"] .footer-col .footer-heading{letter-spacing:0;}

/* The "back" arrow must point right when reading right-to-left. */
[dir="rtl"] .simple-nav-back [aria-hidden="true"]{display:inline-block; transform:scaleX(-1);}

/* ============================= SEO LANDING PAGES ============================= */
/* Visually hidden but still available to screen readers and search engines. */
.sr-only{
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0;
}

/* Keyboard-only skip link: hidden above the viewport until focused. */
.skip-link{
  position:absolute; inset-inline-start:16px; top:-64px; z-index:300;
  background:var(--accent); color:var(--bg); font-weight:700; font-size:14px;
  padding:11px 18px; border-radius:0 0 12px 12px; text-decoration:none;
  transition:top .15s ease;
}
.skip-link:focus{top:0;}

/* Landing-page rhythm: the shared hero sits above these sections. */
.landing-sections{padding-block:10px 70px;}
.landing-section{padding-block:30px; border-top:1px solid var(--border);}
.landing-section:first-child{border-top:none; padding-top:8px;}
.landing-section > p{font-size:15px; color:var(--text-dim); line-height:1.7; max-width:72ch; margin-top:12px;}
.landing-section > p + p{margin-top:12px;}
.landing-section a{color:var(--accent); text-underline-offset:2px;}
.landing-section a.game-card{color:inherit; text-decoration:none;}
.landing-section a.game-card:hover{color:inherit;}
.landing-section ul, .landing-section ol{margin:14px 0 0; padding-inline-start:22px; color:var(--text-dim); font-size:14px; line-height:1.8;}
.landing-section li + li{margin-top:6px;}
.landing-section .source-grid{margin-top:22px; margin-bottom:0;}
.landing-section .game-grid{margin-top:22px;}
a.source-card{display:block; color:inherit; text-decoration:none;}
a.source-card:hover{color:inherit;}
a.source-card h3, .source-card h3{font-size:14px; margin-bottom:4px; font-family:var(--font-display); font-weight:700;}
a.source-card p{font-size:12px; color:var(--text-dim); line-height:1.55;}
a.source-card:focus-visible{outline:2px solid var(--accent); outline-offset:2px;}
.landing-section .tips-grid{margin-top:22px;}
.tip-card h3{font-size:14px; margin-bottom:6px;}
.tip-card p{font-size:13px; color:var(--text-dim); line-height:1.55;}

/* Benchmark table (typing-test page). */
.table-scroll{overflow-x:auto; -webkit-overflow-scrolling:touch; margin-top:18px;}
.wpm-table{width:100%; border-collapse:collapse; font-size:14px; min-width:420px;}
.wpm-table th, .wpm-table td{text-align:start; padding:11px 14px; border-bottom:1px solid var(--border);}
.wpm-table th{font-size:12px; text-transform:uppercase; letter-spacing:.06em; color:var(--text);}
.wpm-table td{color:var(--text-dim);}
.wpm-table tr:last-child td{border-bottom:none;}

/* JS-free FAQ accordion used on the landing pages. */
details.faq-item{border-bottom:1px solid var(--border);}
summary.faq-q{cursor:pointer; list-style:none;}
summary.faq-q::-webkit-details-marker{display:none;}
summary.faq-q::marker{content:"";}
details.faq-item[open] .faq-a{max-height:1200px; padding-bottom:16px;}
details.faq-item[open] .faq-plus{transform:rotate(45deg);}
.faq-a p{margin:0;}

/* Language strip: real crawlable URLs for every translated interface. */
.footer-langs{
  display:flex; flex-wrap:wrap; align-items:baseline; gap:6px 14px;
  padding-block:16px; border-top:1px solid var(--border); font-size:12px;
}
.footer-langs .lbl{color:var(--text); font-weight:700; font-size:11px; text-transform:uppercase; letter-spacing:.07em;}
.footer-langs a{color:var(--text-dim); text-decoration:none; line-height:1.7;}
.footer-langs a:hover{color:var(--accent);}
.footer-langs a[aria-current="page"]{color:var(--accent); font-weight:700;}

@media (max-width:600px){
  .landing-section{padding-block:24px;}
  .landing-section > p{font-size:14px;}
}

/* Narrow-phone navigation is handled by the existing responsive rules. */


/* Themed language dropdown (assets/lang-select.js). Native <option> hover is not
   styleable in Chromium, so the menu is rebuilt as buttons. The hidden select keeps
   every existing change listener and routing rule working. */
.lang-dd{position:relative; display:inline-flex; min-width:0;}
.lang-select.lang-native, .lang-native{display:none !important;}
.lang-trigger{
  display:inline-flex; align-items:center; justify-content:space-between; gap:8px;
  background:var(--surface-2); color:var(--text); border:1px solid var(--border); border-radius:999px;
  padding:8px 12px; min-height:40px; min-width:132px; max-width:180px;
  font-size:13px; font-weight:600; font-family:inherit; cursor:pointer;
  transition:border-color .15s, background-color .15s;
}
.lang-trigger:focus-visible{outline:2px solid var(--accent); outline-offset:2px;}
.lang-trigger-text{overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.lang-chevron{flex:0 0 auto; width:6px; height:6px; margin-block-start:-3px;
  border-inline-end:2px solid var(--text-dim); border-block-end:2px solid var(--text-dim);
  transform:rotate(45deg); transition:transform .15s, margin .15s;}
.lang-dd.open .lang-chevron{transform:rotate(225deg); margin-block-start:3px;}
.lang-menu{
  position:absolute; top:calc(100% + 6px); inset-inline-start:0; z-index:80;
  min-width:100%; width:max-content; max-width:min(280px, calc(100vw - 32px));
  max-height:min(340px, 60vh); overflow-y:auto; overscroll-behavior:contain; padding:6px;
  background:var(--select-bg); color:var(--select-fg); border:1px solid var(--border);
  border-radius:14px; box-shadow:var(--shadow);
}
.lang-option{
  display:block; width:100%; text-align:start; border:0; background:transparent; color:inherit;
  padding:8px 10px; border-radius:9px; font:inherit; font-size:13px; font-weight:500; cursor:pointer;
}
.lang-option:hover, .lang-option:focus-visible, .lang-option.is-active{
  background:var(--accent-hover); color:var(--accent-hover-fg); outline:none;
}
.lang-group{
  font-family:var(--font-mono); font-size:10px; letter-spacing:.08em; text-transform:uppercase;
  color:var(--text-dim); padding:9px 10px 4px;
}
.theme-select-dd{display:block; width:100%;}
.theme-select-dd .lang-trigger,
.theme-select-trigger{width:100%; max-width:none; min-width:0;}
.theme-select-dd .lang-menu,
.theme-select-menu{width:100%; max-width:none;}
@media (max-width:1100px){
  .lang-trigger{min-width:118px; max-width:140px;}
}
@media (max-width:760px){
  .lang-field .lang-dd{position:static; display:block;}
  .lang-field .lang-trigger{
    position:absolute; inset:0; width:100%; height:100%; min-height:0; padding:0;
    border:0; background:transparent; opacity:0; max-width:none; min-width:0;
  }
  .lang-field .lang-menu{inset-inline:0; width:100%; max-width:none;}
}
