@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Space+Grotesk:wght@600;700&family=JetBrains+Mono:wght@500&display=swap');

/**
 * main.css — All app styles
 *
 * Sections:
 *   :root + dark theme variables (lines 1-50)
 *   Layout (header, sidebar, panel)
 *   Cards (test, random, stats, map)
 *   Sentence practice (sp-*)
 *   Mobile responsive (@media max-width:700px)
 *
 * Theme variables:
 *   --bg, --surface, --surface2 (backgrounds)
 *   --ink, --ink2, --ink3 (text)
 *   --border, --border2 (lines)
 *   --blue, --green, --amber, --red (status colors)
 *   --r, --r-lg, --r-full (border radius)
 */

:root {
  --blue: rgb(30, 80, 255);
  --blue-bg: rgba(30, 80, 255, 0.08);
  --blue-alpha: rgba(30, 80, 255, 0.1);
  --ink: #1C1917;
  --ink2: #57534E;
  --ink3: #A8A29E;
  --bg: #F8F7F4;
  --surface: #FFFFFF;
  --surface2: #F1F0ED;
  --border: #E7E5E4;
  --border2: #D6D3D1;
  --red: #EF4444;
  --red-bg: #FEE2E2;
  --green: #10B981;
  --green-bg: #D1FAE5;
  --amber: #F59E0B;
  --amber-bg: #FEF3C7;
  --deep-blue: #0A2B7A;
  --deep-green: #065f46;
  --r: 12px;
  --r-lg: 24px;
  --r-full: 99px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
  --font-main: 'Inter', sans-serif;
  --font-head: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  overflow-x: hidden !important;
  max-width: 100% !important;
  width: 100% !important;
}

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
.dcard-t,
.ph-text,
.logo-wrap span {
  font-family: var(--font-head);
  font-weight: 700;
}

.tnav,
.lbtn,
.btn,
.fbtn,
.nav-label {
  font-family: var(--font-head);
  font-weight: 600;
}

body.visual-edit-on [data-i18n],
body.visual-edit-on .ve-editable-hover {
  outline: 2px dashed rgba(30, 80, 255, 0.55);
  outline-offset: 3px;
  cursor: text !important;
}

body.visual-edit-on .bnav-icon,
body.visual-edit-on .mitem-icon,
body.visual-edit-on .cab-icon,
body.visual-edit-on [data-ve-icon-target] {
  cursor: pointer !important;
}

body.visual-edit-on [data-i18n]:hover,
body.visual-edit-on .ve-editable-hover {
  background: rgba(30, 80, 255, 0.08) !important;
}

body.visual-edit-on.visual-review-on .ve-editable-hover {
  outline-color: rgba(245, 158, 11, 0.82);
  background: rgba(245, 158, 11, 0.12) !important;
  cursor: crosshair !important;
}

body.visual-edit-on.visual-layout-on .ve-editable-hover {
  outline-color: rgba(18, 168, 115, 0.8);
  background: rgba(18, 168, 115, 0.08) !important;
  cursor: grab !important;
}

body.visual-edit-on.visual-layout-on .ve-layout-selected {
  outline: 2px solid var(--green) !important;
  outline-offset: 4px !important;
}

#visual-editor-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(360px, calc(100vw - 36px));
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 18px 50px rgba(0,0,0,0.22);
  z-index: 6000;
  display: none;
  box-sizing: border-box;
}

#visual-editor-panel.open {
  display: block;
}

#visual-editor-panel .ve-head,
#visual-editor-panel .ve-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#visual-editor-panel .ve-head {
  margin-bottom: 10px;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

#visual-editor-panel.dragging .ve-head {
  cursor: grabbing;
}

#visual-editor-panel .ve-head span,
#visual-editor-panel .ve-key {
  color: var(--ink3);
  font-size: 11px;
  font-weight: 800;
}

#visual-editor-panel .ve-key {
  margin-bottom: 8px;
  word-break: break-word;
}

#visual-editor-panel .ve-mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
  padding: 3px;
  border: 1px solid var(--border2);
  border-radius: 11px;
  background: var(--surface2);
}

#visual-editor-panel .ve-mode-tabs button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 7px 8px;
  color: var(--ink2);
}

#visual-editor-panel .ve-mode-tabs button.active {
  background: var(--surface);
  color: var(--blue);
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}

#visual-editor-panel .ve-attrs {
  display: none;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: -2px 0 10px;
}

#visual-editor-panel .ve-attrs button {
  padding: 5px 8px;
  font-size: 10px;
  color: var(--ink2);
}

#visual-editor-panel .ve-attrs button.active {
  background: var(--blue-alpha);
  border-color: var(--blue);
  color: var(--blue);
}

#visual-editor-panel textarea {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  border: 1px solid var(--border2);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--ink);
  padding: 10px;
  font: inherit;
  font-size: 13px;
  margin-bottom: 10px;
}

#visual-editor-panel .ve-icons {
  display: none;
  margin-bottom: 10px;
}

#visual-editor-panel .ve-review {
  display: none;
  margin-bottom: 10px;
}

#visual-editor-panel .ve-layout {
  display: none;
  margin-bottom: 10px;
}

#visual-editor-panel .ve-layout-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

#visual-editor-panel .ve-layout-grid button {
  min-height: 34px;
}

#visual-editor-panel .ve-layout-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

#visual-editor-panel .ve-layout-row button {
  flex: 1 1 auto;
}

#visual-editor-panel .ve-layout-hint {
  color: var(--ink3);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

#visual-editor-panel .ve-review-row {
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 8px;
  margin-bottom: 8px;
}

#visual-editor-panel .ve-review select {
  min-width: 0;
  border: 1px solid var(--border2);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--ink);
  padding: 9px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

#visual-editor-panel .ve-review-hint,
#visual-editor-panel .ve-review-empty {
  color: var(--ink3);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

#visual-editor-panel .ve-review-list {
  display: grid;
  gap: 6px;
  max-height: 150px;
  overflow: auto;
  margin-top: 10px;
}

#visual-editor-panel .ve-review-item {
  display: grid;
  gap: 3px;
  text-align: left;
  padding: 8px 9px;
  line-height: 1.25;
}

#visual-editor-panel .ve-review-item b {
  color: var(--ink);
  font-size: 11px;
}

#visual-editor-panel .ve-review-item span {
  color: var(--ink2);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#visual-editor-panel #ve-icon-search {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border2);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--ink);
  padding: 9px 10px;
  font: inherit;
  font-size: 13px;
  margin-bottom: 10px;
}

#visual-editor-panel .ve-icon-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  max-height: 260px;
  overflow: auto;
  padding-right: 2px;
}

#visual-editor-panel .ve-icon-controls {
  display: grid;
  gap: 9px;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--border2);
  border-radius: 10px;
  background: var(--surface2);
}

#visual-editor-panel .ve-control-row {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--ink2);
  font-size: 11px;
  font-weight: 900;
}

#visual-editor-panel .ve-color-grid {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

#visual-editor-panel .ve-color-dot {
  width: 22px;
  height: 22px;
  min-width: 22px;
  padding: 0;
  border-radius: 999px;
  background: var(--dot-color);
  border-color: var(--border2);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}

#visual-editor-panel .ve-color-dot[data-color=""] {
  background:
    linear-gradient(135deg, transparent 0 45%, var(--red) 46% 54%, transparent 55%),
    conic-gradient(var(--ink), var(--blue), var(--green), var(--amber), var(--ink));
}

#visual-editor-panel .ve-color-dot.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-alpha), inset 0 0 0 1px rgba(0,0,0,0.12);
}

#visual-editor-panel .ve-color-dot:disabled,
#visual-editor-panel .ve-stroke-row input:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

#visual-editor-panel .ve-stroke-row {
  grid-template-columns: 68px minmax(0, 1fr) 32px;
}

#visual-editor-panel .ve-stroke-row input {
  width: 100%;
  accent-color: var(--blue);
}

#visual-editor-panel .ve-stroke-row b {
  color: var(--ink);
  text-align: right;
  font-size: 11px;
}

#visual-editor-panel .ve-icon-option {
  min-height: 68px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
  line-height: 1.1;
}

#visual-editor-panel .ve-icon-option.active {
  background: var(--blue-alpha);
  border-color: var(--blue);
  color: var(--blue);
}

#visual-editor-panel .ve-icon-option span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}

.hsk-ui-icon {
  width: 1.35em;
  height: 1.35em;
  display: inline-block;
  vertical-align: -0.22em;
  color: currentColor;
  flex: 0 0 auto;
}

#visual-editor-panel button {
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--ink);
  border-radius: 9px;
  padding: 8px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

#visual-editor-panel #ve-save {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

#visual-editor-panel #ve-close {
  width: 28px;
  height: 28px;
  padding: 0;
}

#visual-editor-panel #ve-export-box {
  display: none;
  margin-top: 10px;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
}

#visual-editor-tip-chip {
  position: fixed;
  z-index: 6500;
  display: none;
  border: 1px solid var(--blue);
  border-radius: 999px;
  background: var(--blue);
  color: white;
  box-shadow: 0 10px 28px rgba(0,0,0,0.22);
  padding: 7px 10px;
  font: inherit;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

#visual-editor-tip-chip.show {
  display: block;
}

/* ─── CROSSWORD MODE ─── */
.cw-wrap {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 24px;
  box-sizing: border-box;
}

.cw-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.cw-head-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.cw-head h2 {
  margin: 0 0 4px;
  font-size: 24px;
  color: var(--ink);
}

.cw-head p {
  margin: 0;
  color: var(--ink3);
  font-size: 13px;
  font-weight: 700;
}

.cw-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  color: var(--blue);
  font-weight: 900;
}

.cw-progress div {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface2);
}

.cw-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.cw-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 380px;
  gap: 22px;
  align-items: start;
}

.cw-board-card,
.cw-side {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 18px;
  box-sizing: border-box;
}

.cw-board-card {
  overflow: auto;
}

.cw-grid {
  display: grid;
  grid-template-columns: repeat(var(--cw-cols), 36px);
  grid-auto-rows: 36px;
  gap: 0;
  justify-content: center;
  width: max-content;
  min-width: 100%;
  padding: 24px 12px;
  border-radius: 0;
  background: #fff;
}

.cw-cell {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 0;
  background: #fff;
  border: 1.5px solid #555;
  color: #111;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 18px;
  font-weight: 950;
  cursor: pointer;
  padding: 0;
  margin: -1px 0 0 -1px;
}

.cw-cell.blocked {
  background: transparent;
  border: 0;
  pointer-events: none;
}

.cw-cell.active {
  background: #eaf2ff;
  box-shadow: inset 0 0 0 2px var(--blue);
  z-index: 1;
}

.cw-cell.solved {
  background: #f7fff9;
  color: #111;
}

.cw-num {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 9px;
  line-height: 1;
  font-weight: 900;
  color: #111;
}

.cw-char {
  line-height: 1;
  transform: translateY(2px);
  letter-spacing: 0;
}

.cw-answer-box {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--border2);
  border-radius: 10px;
  background: var(--surface2);
}

.cw-answer-box label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 950;
}

.cw-answer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.cw-answer-row input {
  min-width: 0;
  height: 42px;
  border: 1px solid var(--border2);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  font-size: 16px;
  font-weight: 850;
  text-transform: lowercase;
}

.cw-answer-box small {
  display: block;
  margin-top: 8px;
  color: var(--ink3);
  font-size: 12px;
  font-weight: 750;
}

.cw-active-answer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 10px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border2);
  border-radius: 12px;
  background: var(--surface2);
}

.cw-active-answer b {
  color: var(--blue);
  font-size: 12px;
  font-weight: 950;
}

.cw-active-answer span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cw-active-answer em {
  grid-column: 2;
  color: var(--ink3);
  font-style: normal;
  font-size: 12px;
  font-weight: 750;
}

.cw-message {
  margin-top: 14px;
  color: var(--ink3);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.cw-clues {
  display: grid;
  gap: 14px;
  max-height: 560px;
  overflow: auto;
  padding-right: 3px;
}

.cw-clue-group {
  display: grid;
  gap: 8px;
}

.cw-clue-title {
  color: var(--ink3);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.cw-clue {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 4px 8px;
  text-align: left;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 10px;
  cursor: pointer;
}

.cw-clue b {
  color: var(--blue);
  font-size: 12px;
}

.cw-clue span {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
}

.cw-clue span strong {
  margin-right: 6px;
  font-size: 17px;
  font-weight: 950;
}

.cw-clue em {
  grid-column: 2;
  color: var(--ink3);
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
}

.cw-clue.active {
  border-color: var(--blue);
  background: var(--blue-alpha);
}

.cw-clue.solved {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.08);
}

.cw-clue.wrong {
  border-color: var(--red);
}

.cw-bank-title {
  margin: 16px 0 8px;
  color: var(--ink3);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.cw-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cw-word {
  border: 1px solid var(--border2);
  border-radius: 999px;
  background: var(--surface2);
  color: var(--ink);
  padding: 8px 12px;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
}

.cw-word.used {
  opacity: .35;
  cursor: default;
}

.tmc-desc {
  color: var(--ink3);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  margin-top: -6px;
}

.hanzi-choice-wrap {
  max-width: 560px;
}

.hanzi-choice-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--ink);
  font-family: var(--font-head);
  font-size: 24px;
  font-weight: 900;
  line-height: 1.2;
}

.hanzi-choice-title strong {
  color: var(--blue);
  font-size: 28px;
}

.hanzi-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.hanzi-choice-card {
  min-height: 180px;
  border: 2px solid var(--border2);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 18px;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.hanzi-choice-card:hover:not(:disabled) {
  border-color: var(--blue);
  box-shadow: 0 12px 26px rgba(30, 80, 255, .12);
  transform: translateY(-2px);
}

.hanzi-choice-card:active:not(:disabled) {
  transform: scale(.98);
}

.hanzi-choice-hz {
  font-size: clamp(44px, 8vw, 72px);
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0;
}

.hanzi-choice-meta {
  max-width: 100%;
  color: var(--ink3);
  font-size: 12px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hanzi-choice-card.correct {
  border-color: var(--green);
  background: rgba(16, 185, 129, .12);
  box-shadow: 0 12px 28px rgba(16, 185, 129, .16);
}

.hanzi-choice-card.wrong {
  border-color: var(--red);
  background: rgba(239, 68, 68, .12);
}

.hanzi-choice-card.picked {
  transform: scale(1.01);
}

@media (max-width: 820px) {
  .cw-wrap {
    padding: 14px;
    padding-bottom: 92px;
  }
  .cw-layout {
    grid-template-columns: 1fr;
  }
  .cw-grid {
    grid-template-columns: repeat(var(--cw-cols), 30px);
    grid-auto-rows: 30px;
    justify-content: start;
  }
  .cw-cell {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }
  .cw-answer-row {
    grid-template-columns: 1fr;
  }
  .hanzi-choice-title {
    font-size: 22px;
  }
  .hanzi-choice-card {
    min-height: 155px;
    border-radius: 16px;
    padding: 14px;
  }
}

@media (max-width: 480px) {
  .hanzi-choice-grid {
    gap: 12px;
  }
  .hanzi-choice-card {
    min-height: 138px;
  }
  .hanzi-choice-meta {
    display: none;
  }
}

.ve-review-marker {
  position: fixed;
  z-index: 5900;
  width: 22px;
  height: 22px;
  border: 2px solid var(--surface);
  border-radius: 999px;
  background: var(--amber);
  color: white;
  box-shadow: 0 8px 22px rgba(0,0,0,0.24);
  padding: 0;
  font: inherit;
  font-size: 11px;
  font-weight: 900;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
}

.ve-review-marker.priority-high {
  background: var(--red);
}

.ve-review-marker.priority-low {
  background: var(--green);
}

.ve-layout-guide {
  position: fixed;
  z-index: 5890;
  pointer-events: none;
  background: rgba(18, 168, 115, 0.75);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.8);
}

.ve-layout-guide.vertical {
  top: 0;
  bottom: 0;
  width: 1px;
}

.ve-layout-guide.horizontal {
  left: 0;
  right: 0;
  height: 1px;
}

/* ─── HEADER ─── */
header {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 100;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
}

.u-srs-box {
  display: flex;
  align-items: center;
  gap: 5px;
  position: relative;
  z-index: 20;
}
.u-srs-counter {
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  background: var(--green);
  padding: 3px 10px;
  border-radius: var(--r-full);
  opacity: 0.75;
}
.u-srs-help {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  opacity: 0.75;
  cursor: help;
  position: relative;
}
.u-srs-help::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 150%;
  top: 50%;
  transform: translateY(-50%) scale(0.8);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  width: 190px;
  line-height: 1.4;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transition: all 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.u-srs-help::before {
  content: '';
  position: absolute;
  left: 125%;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: rgba(0,0,0,0.85);
  opacity: 0;
  transition: 0.2s;
}
.u-srs-help:hover::after {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}
.u-srs-help:hover::before {
  opacity: 1;
}

.status-confident {
  background-color: var(--deep-green) !important;
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 4px,
    rgba(255, 255, 255, 0.1) 4px,
    rgba(255, 255, 255, 0.1) 8px
  ) !important;
  color: white !important;
}

.u-srs-counter.status-confident, .u-srs-help.status-confident {
  opacity: 0.9;
}

.u-srs-counter.status-waiting,
.u-srs-help.status-waiting {
  background-color: rgba(16, 185, 129, 0.16) !important;
  background-image: repeating-linear-gradient(
    45deg,
    rgba(16, 185, 129, 0.18),
    rgba(16, 185, 129, 0.18) 4px,
    rgba(255, 255, 255, 0.22) 4px,
    rgba(255, 255, 255, 0.22) 8px
  ) !important;
  color: var(--green) !important;
  border: 1px solid rgba(16, 185, 129, 0.28);
  opacity: 1;
}

.u-srs-counter.status-due,
.u-srs-help.status-due {
  background-color: var(--amber) !important;
  color: white !important;
  opacity: 0.9;
}
.mt-c { background-color: var(--deep-green) !important; color: white !important; border-color: var(--deep-green) !important; }

.logo em {
  color: var(--blue);
  font-style: normal;
}

.top-nav {
  display: flex;
  gap: 2px;
  padding: 0 10px 5px 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.top-nav::-webkit-scrollbar {
  display: none;
}

.tnav {
  padding: 6px 13px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  background: transparent;
  color: var(--ink2);
  border: none;
  border-radius: var(--r);
  transition: .15s;
  white-space: nowrap;
  font-weight: 500;
}

.tnav.active {
  background: var(--blue);
  color: #fff;
}

.tnav:hover:not(.active) {
  background: var(--surface2);
}

/* Hide "Strokes" (Practice) section on desktop */
@media (min-width: 701px) {
  #nav-practice {
    display: none !important;
  }
}


/* ── LANG SELECTOR ────────────────────────────────────────── */
.lang-selector {
  position: relative;
}

.lang-curr {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--r-full);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-head);
}

.lang-curr:hover {
  border-color: var(--blue);
  background: var(--bg);
}

.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  display: none;
  flex-direction: column;
  min-width: 150px;
  z-index: 1000;
  overflow: hidden;
  padding: 4px;
}

.lang-menu.show {
  display: flex;
  animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.lang-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.1s;
  border-radius: 8px;
}

.lang-item:hover {
  background: var(--surface2);
  color: var(--blue);
}

.lang-item span {
  font-size: 16px;
}

.lsw-wrap {
  position: relative;
  flex: 1;
  display: flex;
  min-width: 0;
}

.lsw {
  display: flex;
  flex: 1;
  background: var(--surface2);
  border-radius: var(--r-full);
  padding: 2px;
  gap: 1px;
  border: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}

.lsw::-webkit-scrollbar {
  display: none;
}

.lbtn {
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: transparent;
  color: var(--ink3);
  border: none;
  border-radius: var(--r-full);
  transition: .12s;
  white-space: nowrap;
  scroll-snap-align: center;
  flex-shrink: 0;
}

.lbtn.active {
  background: #fff;
  color: var(--blue);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
}

/* ─── LAYOUT ─── */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
  background: var(--bg);
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: 260px;
  min-width: 220px;
  max-width: 60vw;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.resizer {
  width: 10px;
  cursor: col-resize;
  position: absolute;
  top: 0;
  right: -5px;
  bottom: 0;
  z-index: 100;
  background: transparent;
  transition: background 0.2s;
}

.resizer:hover, .resizer.active {
  background: var(--blue-alpha);
  border-right: 2px solid var(--blue);
}

.sbar-top {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  flex-shrink: 0;
  z-index: 10;
}

.search-wrap {
  position: relative;
  width: 100%;
  min-height: 42px;
  display: block !important;
  visibility: visible !important;
}

.search-wrap input {
  width: 100%;
  height: 42px;
  padding: 0 12px 0 40px;
  border: 1px solid var(--border2);
  border-radius: var(--r);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface2) !important;
  color: var(--ink);
  outline: none;
  box-sizing: border-box;
  display: block !important;
}

.search-wrap input:focus {
  border-color: var(--blue);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--blue-alpha);
}

.search-wrap::before {
  content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23A8A29E' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  pointer-events: none;
  opacity: 0.8;
}

.filter-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }

.fbtn {
  flex: 0 0 auto;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-head);
  cursor: pointer;
  border: 1px solid var(--border2);
  border-radius: var(--r-full);
  background: var(--surface2);
  color: var(--ink2);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.fbtn:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-bg);
}

.fbtn.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  box-shadow: 0 4px 12px var(--blue-alpha);
}

.fbtn.fh.active {
  background: var(--red);
  border-color: var(--red);
  box-shadow: 0 4px 12px var(--red-bg);
}

.fbtn.fe.active {
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 4px 12px var(--green-bg);
}

.topics-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.topics-row::-webkit-scrollbar { display: none; }

.tbtn {
  flex: 0 0 auto;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-head);
  cursor: pointer;
  border: 1px solid var(--border2);
  border-radius: var(--r-full);
  background: var(--surface2);
  color: var(--ink2);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tbtn:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-bg);
}

.tbtn.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  box-shadow: 0 4px 12px var(--blue-alpha);
}

/* ─── CUSTOM DROPDOWNS FOR FILTERS ─── */
.filter-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}

.custom-dropdown {
  flex: 1 1 118px;
  position: relative;
  min-width: 0;
}

.dropdown-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink1);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
  text-align: left;
  min-width: 0;
}

.dropdown-trigger:hover {
  border-color: var(--blue);
  background: var(--surface);
  box-shadow: 0 4px 12px var(--blue-alpha);
}

.dropdown-trigger .curr-val {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.dropdown-trigger .arrow {
  font-size: 8px;
  opacity: 0.5;
  transition: transform 0.2s ease;
}

.custom-dropdown.open .dropdown-trigger {
  border-color: var(--blue);
  background: var(--surface);
}

.custom-dropdown.open .arrow {
  transform: rotate(180deg);
  color: var(--blue);
  opacity: 1;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 14px;
  z-index: 1000;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  overflow: hidden;
  max-height: 280px;
  overflow-y: auto;
  box-sizing: border-box;
  width: max(100%, min(220px, calc(100vw - 32px)));
  max-width: calc(100vw - 32px);
  animation: ddFadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#dropdown-topic .dropdown-menu {
  left: auto;
  right: 0;
}

@keyframes ddFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-menu::-webkit-scrollbar {
  width: 4px;
}
.dropdown-menu::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 2px;
}

.dd-item {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink1);
  cursor: pointer;
  transition: all 0.1s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dd-item:hover {
  background: var(--surface2);
  color: var(--blue);
}

.dd-item.active {
  background: var(--blue-alpha);
  color: var(--blue);
  font-weight: 700;
}

/* Custom add */
.custom-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.crow {
  display: flex;
  gap: 4px;
}

.crow input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border2);
  border-radius: var(--r);
  font-size: 12px;
  font-family: inherit;
  background: var(--bg);
  color: var(--ink);
  outline: none;
  min-width: 0;
  transition: .15s;
}

.crow input:focus {
  border-color: var(--blue);
  background: #fff;
}

.crow button {
  padding: 6px 10px;
  border: 1px solid var(--border2);
  border-radius: var(--r);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  font-weight: 600;
}

.crow button:hover {
  opacity: .9;
}

.cstatus {
  font-size: 11px;
  color: var(--ink3);
  min-height: 14px;
}

.wcount {
  padding: 6px 12px;
  font-size: 11px;
  color: var(--ink3);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

.wlist {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  align-content: start;
  min-width: 0;
}

/* For narrow sidebar, switch back to single column */
@media (max-width: 500px) {
  .wlist {
    grid-template-columns: 1fr;
  }
}

.wlist::-webkit-scrollbar {
  width: 3px;
}

.wlist::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 2px;
}

/* Word items */
.wi {
  display: grid;
  grid-template-columns: 4px 72px minmax(0, 1fr) minmax(0, auto);
  align-items: center;
  padding: 12px 14px;
  gap: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--surface);
  position: relative;
  min-height: 64px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.wi:hover {
  background: var(--surface2);
  z-index: 20;
}

.wi.sel {
  background: var(--blue-bg);
  border-right: 3px solid var(--blue);
}

.wi-badge {
  width: 4px;
  height: 24px;
  border-radius: 2px;
  background: transparent;
}

.wc .wi-badge { background: var(--deep-green); }
.wg .wi-badge { background: var(--green); }
.wy .wi-badge { background: var(--amber); }
.wr .wi-badge { background: var(--red); }

.wi-hz {
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  line-height: 1.1;
}

.wi-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
}

.wi-py {
  font-size: 14px;
  color: var(--blue);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wi-ru {
  font-size: 12px;
  color: var(--ink3);
  margin-top: 3px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wi-b {
  font-size: 14px;
  opacity: 0.8;
  margin-left: 8px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.srs-bars {
  display: inline-grid;
  grid-template-columns: repeat(4, 24px);
  gap: 4px;
  align-items: center;
  flex: 0 0 auto;
  margin-top: 6px;
}

.srs-bar {
  position: relative;
  width: 24px;
  height: 4px;
  border-radius: 999px;
  background: var(--border2);
}

.srs-bar.locked {
  background:
    repeating-linear-gradient(135deg, rgba(120, 113, 108, 0.28) 0 2px, transparent 2px 5px),
    var(--border2);
}

.srs-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.srs-bar.due .srs-fill {
  background: var(--amber);
}

.srs-bar.risk .srs-fill {
  background: var(--red);
}

.srs-bar.complete .srs-fill {
  background: var(--deep-green);
}

.srs-bar:hover {
  z-index: 40;
}

.srs-bar:hover::selection {
  background: transparent;
}

.srs-bar::after {
  content: attr(data-tooltip);
  display: block;
  opacity: 0;
  visibility: hidden;
  position: absolute;
  left: 50%;
  top: calc(100% + 10px);
  transform: translateX(-50%);
  width: 240px;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--surface);
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  pointer-events: none;
  z-index: 42;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}

.srs-bar::before {
  content: "";
  opacity: 0;
  visibility: hidden;
  position: absolute;
  left: 50%;
  top: calc(100% + 6px);
  transform: translateX(-50%) rotate(45deg);
  width: 8px;
  height: 8px;
  background: var(--ink);
  z-index: 41;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}

.srs-bar:hover::after,
.srs-bar:hover::before {
  opacity: 1;
  visibility: visible;
}

.custom-word-item .srs-bars {
  margin-left: auto;
  margin-top: 0;
}

.w-more-btn {
  grid-column: 1 / -1;
  padding: 24px;
  text-align: center;
  color: var(--blue);
  font-weight: 700;
  cursor: pointer;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.w-more-btn:hover {
  background: var(--blue-bg);
}

.infinite-scroll-trigger {
  grid-column: 1 / -1;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wi-skeleton {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 12px;
}

.wi-skeleton div {
  background: var(--surface2);
  border-radius: 4px;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 0.6; }
  50% { opacity: 0.3; }
  100% { opacity: 0.6; }
}

/* ─── PANEL ─── */
.panel {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden !important;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  min-height: 0;
  contain: layout;
}

.panel::-webkit-scrollbar {
  width: 4px;
}

.panel::-webkit-scrollbar-thumb {
  background: var(--border2);
}

/* Empty state */
.ph {
  text-align: center;
  color: var(--ink3);
  padding: 40px 20px;
}

.phb {
  display: block;
  font-size: 48px;
  margin-bottom: 8px;
  opacity: .4;
}

.ph-text {
  font-size: 15px;
}

/* ─── CARDS ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  width: 100%;
  box-shadow: var(--shadow);
}

.card-sm {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
  width: 100%;
}

/* ─── BUTTONS ─── */
.btn {
  padding: 8px 16px;
  border-radius: var(--r);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--ink);
  transition: .15s;
  font-weight: 500;
}

.btn:hover {
  background: var(--surface2);
  border-color: var(--border);
}

.btn:active {
  transform: scale(.98);
}

.btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.btn-primary:hover {
  opacity: .9;
  background: var(--blue);
}

.btn-red {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.btn-red:hover {
  opacity: .9;
  background: var(--red);
}

.btn-green {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.btn-green:hover {
  opacity: .9;
}

.btn-amber {
  background: var(--amber);
  color: #fff;
  border-color: var(--amber);
}

.btn-amber:hover {
  opacity: .9;
}

/* Legacy aliases */
.btn-dk {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.btn-dk:hover {
  opacity: .85;
  background: var(--ink);
}

/* ─── PRACTICE MODE ─── */
.whdr {
  text-align: center;
  min-height: 80px;
  position: relative;
}

.wfull {
  font-size: 28px;
  letter-spacing: .05em;
  font-weight: 300;
}

.wpy {
  font-size: 13px;
  color: var(--ink3);
  margin-top: 3px;
}

.wru {
  font-size: 16px;
  font-weight: 600;
  margin-top: 4px;
  color: var(--blue);
}

.cdots {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

.dot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--surface2);
  color: var(--ink2);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border);
  user-select: none;
}

.dot:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-bg);
}

.dot.cur {
  background: var(--blue) !important;
  color: #fff !important;
  border-color: var(--blue) !important;
  transform: scale(1.08);
  box-shadow: 0 4px 10px rgba(30, 80, 255, 0.25);
}

.dot.dn {
  background: var(--green-bg) !important;
  color: var(--deep-green) !important;
  border-color: var(--green) !important;
}

.cwrap {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-lg);
  flex-shrink: 0;
  display: block;
  overflow: hidden;
}

.cgrid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.clbl {
  font-size: 12px;
  color: var(--ink3);
  text-align: center;
}

.clbl strong {
  font-size: 16px;
  color: var(--ink);
  font-weight: 600;
}

.fb {
  height: 22px;
  font-size: 12px;
  color: var(--ink3);
  display: flex;
  align-items: center;
  font-weight: 500;
}

.fbok {
  color: var(--green);
}

.fberr {
  color: var(--red);
}

.ctrls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.errs {
  font-size: 11px;
  color: var(--ink3);
  text-align: center;
}

.errs span {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  display: block;
}

/* Related */
.related {
  width: 100%;
  max-width: 420px;
}

.rel-t {
  font-size: 10px;
  color: var(--ink3);
  letter-spacing: .06em;
  margin-bottom: 6px;
  text-transform: uppercase;
  font-weight: 600;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  padding: 4px 10px;
  border: 1px solid var(--border2);
  border-radius: var(--r-full);
  font-size: 13px;
  cursor: pointer;
  background: var(--surface);
  color: var(--ink);
  transition: .12s;
  font-weight: 500;
}

.chip:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-bg);
}

/* Complete */
.compbox {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px 32px;
  box-shadow: var(--shadow-md);
  max-width: 400px;
  width: 100%;
}

.comphz {
  font-size: 48px;
  margin-bottom: 6px;
}

.compt {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.comps {
  font-size: 13px;
  color: var(--ink2);
  margin-bottom: 20px;
  line-height: 1.6;
}

.compb {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ─── TEST MODE ─── */
.test-wrap {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.test-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.test-score {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--ink3);
}

.test-score span {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  display: block;
  text-align: center;
}

.test-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
}

.test-hz {
  font-size: 56px;
  margin-bottom: 4px;
  font-weight: 300;
}

.test-py {
  font-size: 14px;
  color: var(--ink3);
}

.test-prog {
  font-size: 12px;
  color: var(--ink3);
  font-weight: 500;
}

.topts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.topt {
  padding: 12px 10px;
  border: 1.5px solid var(--border2);
  border-radius: var(--r);
  font-size: 13px;
  cursor: pointer;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  line-height: 1.4;
  text-align: center;
  transition: .15s;
  font-weight: 500;
}

.topt:hover:not(:disabled) {
  background: var(--blue-bg);
  border-color: var(--blue);
}

.topt.tc {
  background: var(--green-bg);
  border-color: var(--green);
  color: var(--green);
}

.topt.tw {
  background: var(--red-bg);
  border-color: var(--red);
  color: var(--red);
}

.topt:disabled {
  cursor: default;
}

/* Matching Mode */
.match-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.match-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.match-btn {
  padding: 12px 8px;
  border: 2px solid var(--border2);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: 0.2s;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  box-shadow: var(--shadow);
  word-break: break-word;
}

.match-btn:hover:not(.matched) {
  background: var(--blue-bg);
  border-color: var(--blue);
}

.match-btn.sel {
  border-color: var(--blue);
  background: var(--blue-bg);
  color: var(--blue);
}

.match-btn.matched {
  opacity: 0.3;
  cursor: default;
  background: var(--surface2);
  border-color: transparent;
}

.match-btn.wrong {
  border-color: var(--red);
  background: var(--red-bg);
  color: var(--red);
}

/* Input Mode */
.test-input-wrap {
  margin-top: 15px;
}

.test-input {
  width: 100%;
  padding: 20px;
  font-size: 24px;
  text-align: center;
  border-radius: var(--r-lg);
  border: 2px solid var(--border2);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-zh);
  outline: none;
}

.test-input:focus {
  border-color: var(--blue);
}

.test-input.tc {
  border-color: var(--green);
  background: var(--green-bg);
}

.test-input.tw {
  border-color: var(--red);
  background: var(--red-bg);
}

/* ─── RANDOM MODE ─── */
.rand-wrap {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rand-score {
  display: flex;
  gap: 16px;
  justify-content: center;
  font-size: 12px;
  color: var(--ink3);
}

.rand-score span {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  display: block;
  text-align: center;
}

.rmsw {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.rmbtn {
  padding: 6px 14px;
  border-radius: var(--r-full);
  font-size: 12px;
  cursor: pointer;
  border: 1.5px solid var(--border2);
  background: var(--surface);
  color: var(--ink2);
  font-family: inherit;
  transition: .12s;
  font-weight: 500;
}

.rmbtn.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

/* ─── DASHBOARD / HOME ─── */
.dash {
  width: 100%;
  max-width: 1000px;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 20px;
  padding: 10px;
  box-sizing: border-box;
}

@media(max-width: 850px) {
  .dash {
    grid-template-columns: 1fr;
  }
}
