/* LexiMatch web: the Mac app's look (Views/Theme.swift palette), light and dark. */

:root {
  --primary: #4F46E5;
  --on-primary: #FFFFFF;
  --primary-container: #E0E7FF;
  --secondary: #0D9488;
  --tertiary: #D97706;
  --background: #F5F6FB;
  --surface: #FFFFFF;
  --surface-variant: #EEF0F7;
  --text: #111827;
  --muted: #5B6275;
  --outline: #D5D9E6;
  --outline-variant: #E6E9F2;
  --success: #16A34A;
  --success-container: #DCFCE7;
  --danger: #E11D48;
  --danger-container: #FFE4E6;
  --hero-start: #4F46E5;
  --hero-end: #7C3AED;
  --sidebar: #ECEDF2;
  --sidebar-select: rgba(79, 70, 229, 0.14);
  --orange: #EA580C;
  --red: #DC2626;

  --pair0: #4F46E5; --pair0-bg: #E0E7FF;
  --pair1: #0D9488; --pair1-bg: #CCFBF1;
  --pair2: #D97706; --pair2-bg: #FEF3C7;
  --pair3: #DB2777; --pair3-bg: #FCE7F3;
  --pair4: #0284C7; --pair4-bg: #E0F2FE;
  --pair5: #7C3AED; --pair5-bg: #EDE9FE;

  --shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #A5B4FC;
    --on-primary: #1E1B4B;
    --primary-container: #3730A3;
    --secondary: #5EEAD4;
    --tertiary: #FBBF24;
    --background: #0E1120;
    --surface: #171B2E;
    --surface-variant: #22273D;
    --text: #E5E7EB;
    --muted: #A3A9BD;
    --outline: #363C57;
    --outline-variant: #2A2F47;
    --success: #4ADE80;
    --success-container: #14532D;
    --danger: #FB7185;
    --danger-container: #4C0519;
    --hero-start: #3730A3;
    --hero-end: #6D28D9;
    --sidebar: #141729;
    --sidebar-select: rgba(165, 180, 252, 0.18);
    --orange: #FB923C;
    --red: #F87171;
    --pair0: #A5B4FC; --pair0-bg: #312E81;
    --pair1: #5EEAD4; --pair1-bg: #134E4A;
    --pair2: #FCD34D; --pair2-bg: #78350F;
    --pair3: #F9A8D4; --pair3-bg: #831843;
    --pair4: #7DD3FC; --pair4-bg: #0C4A6E;
    --pair5: #C4B5FD; --pair5-bg: #4C1D95;
    --shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --primary: #A5B4FC; --on-primary: #1E1B4B; --primary-container: #3730A3; --secondary: #5EEAD4; --tertiary: #FBBF24;
  --background: #0E1120; --surface: #171B2E; --surface-variant: #22273D; --text: #E5E7EB; --muted: #A3A9BD;
  --outline: #363C57; --outline-variant: #2A2F47; --success: #4ADE80; --success-container: #14532D;
  --danger: #FB7185; --danger-container: #4C0519; --hero-start: #3730A3; --hero-end: #6D28D9;
  --sidebar: #141729; --sidebar-select: rgba(165, 180, 252, 0.18); --orange: #FB923C; --red: #F87171;
  --pair0: #A5B4FC; --pair0-bg: #312E81; --pair1: #5EEAD4; --pair1-bg: #134E4A; --pair2: #FCD34D; --pair2-bg: #78350F;
  --pair3: #F9A8D4; --pair3-bg: #831843; --pair4: #7DD3FC; --pair4-bg: #0C4A6E; --pair5: #C4B5FD; --pair5-bg: #4C1D95;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--background);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

#root { height: 100%; }

button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }

.rounded-num { font-family: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.success { color: var(--success); }
.danger { color: var(--danger); }
.bold { font-weight: 700; }
.semibold { font-weight: 600; }
.italic { font-style: italic; }
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.spacer { flex: 1; }
.wrap { flex-wrap: wrap; }
.center { display: flex; align-items: center; justify-content: center; }
.hidden { display: none !important; }

/* ---------- layout ---------- */

.loading { height: 100%; display: flex; align-items: center; justify-content: center; color: var(--muted); }

.shell { display: flex; height: 100%; }

.sidebar {
  width: 230px;
  flex: none;
  background: var(--sidebar);
  border-right: 1px solid var(--outline-variant);
  display: flex;
  flex-direction: column;
  padding-top: 18px;
}

.profile-button {
  display: flex; align-items: center; gap: 10px; margin: 0 14px 12px; padding: 4px; border: none;
  background: none; text-align: left; cursor: pointer; border-radius: 10px;
}
.profile-button:hover { background: var(--sidebar-select); }
.profile-button .name { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }

.nav { list-style: none; margin: 0; padding: 4px 10px; flex: 1; overflow-y: auto; }
.nav button {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: none; border-radius: 8px;
  background: none; cursor: pointer; font-size: 14px; text-align: left; margin-bottom: 2px;
}
.nav button:hover { background: rgba(127, 127, 127, 0.1); }
.nav button.active { background: var(--sidebar-select); color: var(--primary); font-weight: 600; }
.nav svg { width: 17px; height: 17px; color: var(--primary); flex: none; }

.sidebar-foot { padding: 12px 14px 16px; display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--outline-variant); }
.sidebar-foot .t1 { font-size: 12px; font-weight: 600; }
.sidebar-foot .t2 { font-size: 11px; color: var(--muted); }

.icon-button {
  width: 30px; height: 30px; border-radius: 8px; border: none; background: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted);
}
.icon-button:hover { background: rgba(127, 127, 127, 0.14); color: var(--text); }
.icon-button svg { width: 17px; height: 17px; }

.detail { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.titlebar {
  height: 52px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 20px;
  border-bottom: 1px solid var(--outline-variant); background: var(--surface);
}
.titlebar .title { font-size: 15px; font-weight: 700; }
.titlebar .subtitle { font-size: 12px; color: var(--muted); }
.titlebar .menu-toggle { display: none; }

.page { flex: 1; overflow-y: auto; overflow-x: hidden; background: var(--background); }
.page-inner { max-width: 960px; margin: 0 auto; padding: 28px; display: flex; flex-direction: column; gap: 18px; }

/* ---------- section menu ---------- */

.section-menu { position: relative; margin: 0 12px 8px; }
.section-menu > button {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: none; border-radius: 8px;
  background: var(--surface-variant); cursor: pointer; font-size: 13px; font-weight: 600; text-align: left;
}
.section-menu > button:disabled { opacity: 0.5; cursor: default; }
.section-menu > button svg.books { width: 15px; height: 15px; color: var(--primary); }
.section-menu > button .chev { width: 10px; height: 12px; color: var(--muted); }
.section-menu > button .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.popup {
  position: absolute; z-index: 50; min-width: 100%; background: var(--surface); border: 1px solid var(--outline);
  border-radius: 9px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18); padding: 5px;
}
.popup button {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border: none; background: none;
  border-radius: 6px; cursor: pointer; text-align: left; font-size: 13px; white-space: nowrap;
}
.popup button:hover { background: var(--primary); color: #fff; }
.popup button .check { width: 16px; text-align: center; font-weight: 700; }

/* ---------- building blocks ---------- */

.card {
  background: var(--surface); border: 1px solid var(--outline-variant); border-radius: 18px; padding: 18px;
  box-shadow: var(--shadow); min-width: 0;
}
.card.p16 { padding: 16px; }
.card.clickable { cursor: pointer; }
.card h3 { margin: 0; font-size: 16px; font-weight: 600; }

.pill {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}

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

.segbar { position: relative; height: 10px; border-radius: 999px; overflow: hidden; display: flex; flex: 1; min-width: 40px; }
.segbar > div { height: 100%; transition: width 0.5s ease; }

.stat-tile { flex: 1; }
.stat-tile .t { font-size: 12px; font-weight: 500; color: var(--muted); }
.stat-tile .v { font-size: 26px; font-weight: 700; margin: 4px 0; }
.stat-tile .s { font-size: 12px; color: var(--muted); }

.num-badge {
  border-radius: 50%; color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none;
}

.keycap {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; font-weight: 600; color: var(--muted);
  min-width: 18px; height: 18px; padding: 0 3px; border-radius: 5px; background: var(--surface-variant);
  border: 0.5px solid var(--outline); display: inline-flex; align-items: center; justify-content: center; flex: none;
}

.speak {
  width: 26px; height: 26px; border: none; background: none; cursor: pointer; color: var(--muted); border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.speak:hover { color: var(--primary); background: var(--surface-variant); }
.speak svg { width: 14px; height: 14px; }

.big-button {
  min-height: 46px; width: 100%; border-radius: 14px; border: 1.5px solid transparent; background: var(--primary);
  color: var(--on-primary); font-size: 15px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; padding: 0 16px; transition: transform 0.12s, opacity 0.12s;
}
.big-button:active:not(:disabled) { transform: scale(0.98); opacity: 0.85; }
.big-button:disabled { opacity: 0.4; cursor: default; }
.big-button.outline { background: transparent; color: var(--primary); border-color: color-mix(in srgb, var(--primary) 50%, transparent); }
.big-button.gray { background: transparent; color: var(--muted); border-color: color-mix(in srgb, var(--muted) 50%, transparent); }
.big-button svg { width: 14px; height: 14px; }

.btn {
  border: 1px solid var(--outline); background: var(--surface); border-radius: 7px; padding: 4px 12px; cursor: pointer;
  font-size: 13px; line-height: 20px; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-variant); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.primary:hover:not(:disabled) { opacity: 0.9; background: var(--primary); }
.btn.danger { color: var(--danger); }
.link { border: none; background: none; color: var(--primary); cursor: pointer; padding: 0; font-size: 13px; }
.link:hover { text-decoration: underline; }

.banner { padding: 14px; border-radius: 14px; font-size: 14px; font-weight: 600; }

.segmented { display: inline-flex; background: var(--surface-variant); border-radius: 8px; padding: 2px; gap: 2px; flex-wrap: wrap; }
.segmented button {
  border: none; background: none; padding: 4px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text);
}
.segmented button.on { background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); font-weight: 600; }

.checkbox { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; flex: none; }

.divider { height: 1px; background: var(--outline-variant); }

.field {
  border: 1px solid var(--outline); background: var(--surface); border-radius: 7px; padding: 6px 9px; font-size: 13px; outline: none;
}
.field:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }

/* ---------- avatar and profile ---------- */

.avatar {
  border-radius: 50%; overflow: hidden; flex: none; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--hero-start), var(--hero-end)); color: #fff; font-weight: 700;
  border: 1.5px solid rgba(255, 255, 255, 0.6); font-family: ui-rounded, -apple-system, system-ui, sans-serif;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.points-pill {
  font-size: 12px; font-weight: 700; color: var(--pair2); background: var(--pair2-bg); padding: 3px 8px; border-radius: 999px;
  display: inline-block; white-space: nowrap;
}

.profile-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 3px 4px 3px 3px; background: var(--surface-variant); border-radius: 999px;
}
.profile-chip .n { font-size: 13px; font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- home ---------- */

.greeting h1 { font-size: 28px; margin: 0 0 2px; font-weight: 700; }
.hero {
  border-radius: 22px; padding: 22px; color: #fff; background: linear-gradient(135deg, var(--hero-start), var(--hero-end));
  display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0;
}
.hero .big { font-size: 44px; font-weight: 700; line-height: 1; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; font-weight: 500; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.ring { position: relative; flex: none; }
.ring svg { transform: rotate(-90deg); display: block; }
.ring .inner { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.ring circle { transition: stroke-dashoffset 0.9s ease-out; }

.grid2 { display: flex; gap: 16px; align-items: stretch; }
.grid2 > * { flex: 1; }
.grid2 > .goal-col { flex: none; width: 300px; }

.mode-tile {
  flex: 1; display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 18px; background: var(--surface);
  border: 1px solid var(--outline-variant); cursor: pointer; text-align: left;
}
.mode-tile:hover:not(:disabled) { background: var(--surface-variant); }
.mode-tile:disabled { opacity: 0.55; cursor: default; }
.mode-tile .e { font-size: 28px; }

.unit-row { display: flex; align-items: center; gap: 12px; }
.unit-row .name { width: 240px; flex: none; }

/* ---------- quiz ---------- */

.quiz { display: flex; flex-direction: column; height: 100%; background: var(--background); outline: none; }
.quiz-head {
  display: flex; align-items: center; gap: 14px; padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--outline-variant);
}
.close-x {
  width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--surface-variant); color: var(--muted);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.close-x svg { width: 13px; height: 13px; }
.combo { font-size: 13px; font-weight: 700; color: var(--pair2); background: var(--pair2-bg); padding: 4px 10px; border-radius: 999px; animation: pop 0.3s; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.quiz-body { flex: 1; overflow-y: auto; overflow-x: hidden; }
.quiz-inner { max-width: 980px; margin: 0 auto; padding: 18px 28px; display: flex; flex-direction: column; gap: 14px; animation: slidein 0.35s ease; }
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.match { display: flex; gap: 16px; align-items: flex-start; }
.match .words { width: 300px; flex: none; display: flex; flex-direction: column; gap: 10px; }
.match .answers { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.word-card, .answer-card {
  border-radius: 16px; padding: 12px 14px; min-height: 64px; border: 1px solid var(--outline-variant); background: var(--surface);
  cursor: pointer; transition: background 0.2s, border-color 0.2s, transform 0.25s, box-shadow 0.25s; user-select: none;
}
.word-card:hover, .answer-card.enabled:hover { background: var(--surface-variant); }
.word-card.selected { background: var(--primary-container); border: 2px solid var(--primary); transform: scale(1.02); box-shadow: 0 3px 8px color-mix(in srgb, var(--primary) 25%, transparent); padding: 11px 13px; }
.word-card .w { font-size: 19px; font-weight: 700; flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.2; }
.word-card .w.long { font-size: 16px; }
.word-card .sub { padding-left: 34px; font-size: 12px; color: var(--muted); }
.word-card .fix { padding-left: 34px; font-size: 13px; font-weight: 500; color: var(--success); margin-top: 4px; }
.word-card .note { padding-left: 34px; font-size: 13px; font-style: italic; color: var(--muted); margin-top: 4px; white-space: pre-line; }
.answer-card { display: flex; align-items: center; gap: 12px; }
.answer-card .txt { flex: 1; font-size: 15px; white-space: pre-line; }
.answer-card .empty-dot { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--outline); flex: none; }
.answer-card.dim { opacity: 0.75; cursor: default; }
.answer-card.enabled { border-color: color-mix(in srgb, var(--primary) 45%, transparent); }

.right { background: var(--success-container) !important; border-color: var(--success) !important; }
.wrong { background: var(--danger-container) !important; border-color: var(--danger) !important; }

.chip-word {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 4px 5px 8px; border-radius: 999px; border: 1px solid var(--outline-variant);
  background: var(--surface); cursor: pointer; transition: transform 0.25s; user-select: none;
}
.chip-word.selected { background: var(--primary-container); border: 2px solid var(--primary); transform: scale(1.06); padding: 4px 3px 4px 7px; }
.chip-word .w { font-size: 17px; font-weight: 700; }
.sentence .blank-filled { font-weight: 700; text-decoration: underline; }
.sentence .blank { color: var(--outline); }

.quiz-foot {
  display: flex; align-items: center; gap: 16px; padding: 14px 28px; background: var(--surface); border-top: 1px solid var(--outline-variant);
}
.quiz-foot .big-button { width: 260px; flex: none; }
.result-dot { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.result-dot svg { width: 13px; height: 13px; }

.odd-row { padding: 16px; border-radius: 16px; border: 1px solid var(--outline-variant); background: var(--surface); cursor: pointer; transition: background 0.25s; }

/* ---------- confetti ---------- */

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 80; }

/* ---------- words table ---------- */

.words-layout { display: flex; height: 100%; }
.words-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.words-tools { display: flex; align-items: center; gap: 12px; padding: 10px 16px; flex-wrap: wrap; }
.table-wrap { flex: 1; overflow: auto; }
table.words { width: 100%; border-collapse: collapse; font-size: 13px; }
table.words th {
  position: sticky; top: 0; background: var(--surface); text-align: left; font-weight: 600; font-size: 12px; color: var(--muted);
  padding: 6px 10px; border-bottom: 1px solid var(--outline-variant); cursor: pointer; white-space: nowrap; user-select: none;
}
table.words td { padding: 5px 10px; border-bottom: 1px solid var(--outline-variant); white-space: nowrap; }
table.words tr { cursor: pointer; }
table.words tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-variant) 45%, transparent); }
table.words tbody tr.sel { background: var(--primary); color: var(--on-primary); }
table.words tbody tr.sel .muted { color: var(--on-primary); opacity: 0.85; }
.word-detail { width: 300px; flex: none; background: var(--surface); border-left: 1px solid var(--outline-variant); overflow-y: auto; }
.word-detail .inner { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.word-detail .h { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.word-detail .b { font-size: 14px; white-space: pre-line; user-select: text; }

/* ---------- history ---------- */

.round-card { background: var(--surface); border: 1px solid var(--outline-variant); border-radius: 16px; overflow: hidden; }
.round-card .head { display: flex; align-items: center; gap: 12px; padding: 14px; cursor: pointer; }
.round-card .q { display: flex; align-items: center; gap: 12px; padding: 8px 14px; }
.chev-icon { width: 14px; height: 14px; color: var(--muted); transition: transform 0.25s; }
.chev-icon.open { transform: rotate(180deg); }
.bottom-bar { display: flex; align-items: center; padding: 12px 24px; background: var(--surface); border-top: 1px solid var(--outline-variant); gap: 12px; }

.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.badge-tile {
  display: flex; align-items: center; gap: 12px; padding: 12px; min-height: 64px; border-radius: 14px;
  border: 1px solid var(--outline-variant); background: color-mix(in srgb, var(--surface-variant) 50%, transparent);
}
.badge-tile.got { background: var(--surface); border-color: color-mix(in srgb, var(--primary) 30%, transparent); }

/* ---------- ranking ---------- */

.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.fact { background: var(--surface-variant); border-radius: 12px; padding: 10px; min-width: 0; }
.fact .t { font-size: 11px; font-weight: 500; color: var(--muted); }
.fact .v { font-size: 17px; font-weight: 700; }
.fact .s { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 14px; }
.top-tile { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: var(--surface-variant); flex: 1; min-width: 0; }
.top-tile.me { background: var(--primary-container); }

/* ---------- modal ---------- */

.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.32); z-index: 60; display: flex; align-items: flex-start;
  justify-content: center; padding: 6vh 16px; overflow-y: auto; animation: fade 0.15s;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  background: var(--surface); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); padding: 24px; max-width: 100%;
  border: 1px solid var(--outline-variant); animation: sheetin 0.2s ease;
}
@keyframes sheetin { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h2 { margin: 0 0 12px; font-size: 18px; }
.alert { width: 380px; text-align: center; }
.alert .msg { font-size: 13px; color: var(--muted); margin: 6px 0 18px; white-space: pre-line; text-align: left; }
.sheet-buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* Settings: macOS grouped form */
.settings { width: 620px; padding: 0; background: var(--background); overflow: hidden; }
.settings .head { display: flex; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--outline-variant); background: var(--surface); }
.settings .body { padding: 18px 20px 24px; max-height: 74vh; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.group-title { font-size: 13px; font-weight: 600; margin: 0 0 6px 4px; }
.group { background: var(--surface); border: 1px solid var(--outline-variant); border-radius: 10px; }
.group > .item { padding: 10px 14px; display: flex; align-items: center; gap: 10px; min-height: 40px; flex-wrap: wrap; }
.group > .item + .item { border-top: 1px solid var(--outline-variant); }
.group .caption { font-size: 11px; color: var(--muted); }
.stepper { display: inline-flex; border: 1px solid var(--outline); border-radius: 6px; overflow: hidden; }
.stepper button { border: none; background: var(--surface); width: 26px; height: 22px; cursor: pointer; font-size: 14px; line-height: 1; }
.stepper button + button { border-left: 1px solid var(--outline); }
.stepper button:disabled { opacity: 0.35; cursor: default; }
.toggle { position: relative; width: 34px; height: 20px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: var(--outline); border-radius: 999px; transition: 0.2s; cursor: pointer; }
.toggle span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: 0.2s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.toggle input:checked + span { background: var(--primary); }
.toggle input:checked + span::before { transform: translateX(14px); }
select.field { padding-right: 24px; }
.pin-field { width: 120px; text-align: center; font-size: 18px; letter-spacing: 6px; }

/* Cropper */
.crop-area { position: relative; width: 300px; height: 300px; overflow: hidden; border-radius: 6px; background: #000; touch-action: none; cursor: grab; }
.crop-area img { position: absolute; left: 50%; top: 50%; user-select: none; pointer-events: none; max-width: none; }
.crop-area .mask { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at center, transparent 149px, rgba(0, 0, 0, 0.45) 150px); }
.crop-area .ring-line { position: absolute; inset: 0; border-radius: 50%; border: 2px solid #fff; pointer-events: none; }
.camera video { width: 360px; max-width: 100%; border-radius: 10px; background: #000; transform: scaleX(-1); }

/* Welcome / join */
.center-page { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 32px 16px; background: var(--background); }

/* ---------- small screens ---------- */

@media (max-width: 760px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 70; transform: translateX(-100%); transition: transform 0.25s; box-shadow: 0 0 40px rgba(0, 0, 0, 0.25);
  }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 65; background: rgba(0, 0, 0, 0.3); }
  .titlebar .menu-toggle { display: inline-flex; }
  .page-inner { padding: 16px; }
  .grid2, .stack-sm { flex-direction: column; }
  .grid2 > .goal-col { width: auto; }
  .match { flex-direction: column; }
  .match .words { width: 100%; }
  .quiz-inner { padding: 14px 16px; }
  .quiz-foot { padding: 12px 16px; }
  .quiz-foot .big-button { width: auto; flex: 1; }
  .quiz-foot .result-text { display: none; }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .unit-row .name { width: 120px; }
  .word-detail { position: fixed; inset: 0 0 0 auto; width: min(320px, 90vw); z-index: 70; box-shadow: 0 0 40px rgba(0, 0, 0, 0.25); }
  .settings { width: 100%; }
  .greeting h1 { font-size: 22px; }
  .hide-sm { display: none !important; }
}
