:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #ffffff;
  --ink: #121212;
  --muted: #6b6b6b;
  --line: #d4d4d4;
  --faint: #e8e8e8;
  --accent: #1a1a1a;
  --accent-soft: #f5f5f5;
  --warn: #c0392b;
  --ok: #2e7d32;
  --focus: rgba(0,0,0,0.15);
  --radius: 2px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --fm: "JetBrains Mono", "SF Mono", "Menlo", monospace;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

u {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 2px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
  font-size: 15px;
  line-height: 1.5;
}

button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  touch-action: manipulation;
  transition: background-color 0.1s;
}

.app {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  color: var(--ink);
  padding: 32px 20px;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar .eyebrow { color: var(--accent); }

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 2px;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.range {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.set-card {
  display: grid;
  gap: 4px;
  border-radius: var(--radius);
  background: rgba(0,122,255,0.04);
  padding: 16px;
}

.auth-section {
  display: grid;
  gap: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 20px;
}

.auth-label {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.auth-section input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  font: inherit;
  font-size: 15px;
  width: 100%;
  transition: border-color 0.1s;
}
.auth-section input:focus {
  outline: none;
  border-color: var(--ink);
  background: #fff;
}
.auth-section input::placeholder { color: var(--muted); }

.auth-error {
  margin: 0;
  font-size: 13px;
  color: var(--warn);
  font-weight: 500;
}

.auth-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.auth-btns button {
  min-height: 42px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

#authLoginBtn {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

#authRegisterBtn {
  background: transparent;
  color: var(--ink);
}

#authLoggedIn strong {
  display: block;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-logout-btn {
  width: 100%;
  min-height: 36px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--warn);
  border-color: var(--line);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.ranking-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.1s;
}

.ranking-btn:hover {
  background: var(--accent-soft);
}

.ranking-btn[active] {
  background: var(--accent-soft);
  color: var(--ink);
  border-color: var(--ink);
}

.set-card span,
.set-card small,
.player-card small { color: var(--muted); font-size: 12px; }

.set-card strong,
.player-card strong { font-size: 18px; font-weight: 700; }

.category-nav {
  display: grid;
  gap: 6px;
  overflow-y: auto;
  max-height: 56vh;
  padding-right: 4px;
}

.category-nav[hidden] { display: none; }

.category-btn {
  display: grid;
  grid-template-columns: minmax(78px, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 42px;
  min-width: 0;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  font-size: 13px;
  font-weight: 500;
}
.category-btn:hover { background: var(--accent-soft); }
.category-btn span { white-space: nowrap; }

.category-btn[aria-current="true"] {
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 600;
  border-color: var(--ink);
}

.category-btn small { color: inherit; opacity: 0.6; font-size: 11px; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: auto;
  min-width: 0;
}

.stats div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 14px 10px;
  text-align: center;
}

.stats span {
  display: block;
  font-size: 22px;
  font-weight: 800;
}

.stats small { color: var(--muted); font-size: 11px; }

.workspace {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 20px;
  padding: 24px 32px;
  min-width: 0;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

h2 {
  margin-bottom: 0;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.controls,
.actions,
.section-head {
  display: flex;
  gap: 10px;
  align-items: center;
}

.icon-btn {
  width: 44px;
  height: 44px;
  font-size: 22px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
}

.text-btn,
.actions button,
.section-head button {
  min-height: 40px;
  padding: 0 18px;
  border-radius: var(--radius);
  font-weight: 500;
}

.progress {
  height: 4px;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--faint);
}

#progressBar {
  width: 0%;
  height: 100%;
  background: var(--ink);
  border-radius: var(--radius);
  transition: width 0.3s ease;
}

.quiz-panel,
.word-list,
.start-panel,
.result-panel,
.ranking-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.quiz-panel,
.start-panel,
.result-panel,
.ranking-panel {
  padding: 24px 28px;
}

.start-panel h3,
.result-panel h3,
.ranking-panel h3 {
  margin-bottom: 12px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

#startQuizBtn {
  display: block;
  width: 100%;
  max-width: 420px;
  min-height: 52px;
  margin-top: 20px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.1s;
}
#startQuizBtn:hover {
  background: #333;
}

#startPanelHint {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 8px;
}

.name-form {
  display: grid;
  gap: 12px;
  max-width: 520px;
}

.name-form label {
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.name-form div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.name-form input {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 16px;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  transition: border-color 0.1s;
}
.name-form input:focus { outline: none; border-color: var(--ink); }

.name-form button,
#restartBtn,
#rankingCloseBtn {
  min-height: 44px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  padding: 0 20px;
  font-weight: 600;
}

.password-row {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.password-row label {
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.password-row label small { font-weight: 400; opacity: 0.7; }

.password-row input {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 16px;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

.password-hint {
  margin: 0;
  font-size: 13px;
  color: var(--warn);
  font-weight: 500;
}

.ranking-header {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.ranking-summary {
  color: var(--muted);
  margin: -8px 0 16px;
  font-size: 13px;
}

.wordlist-scroll { padding-right: 8px; }

#wordlistTitle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.wl-title-main { min-width: 0; }

.wl-jump-controls {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.wordlist-cat {
  margin-bottom: 16px;
  padding: 18px 20px;
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.wordlist-cat:hover {
  border-color: var(--ink);
}

.wordlist-cat h4 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.2px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.wl-cat-num {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: #eef1f5;
  padding: 2px 7px;
  border-radius: 4px;
  min-width: 36px;
  text-align: center;
  display: inline-block;
}

.wordlist-words {
  margin: 0;
  font-size: 13px;
  line-height: 2;
  color: var(--ink);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
}
.wordlist-words[hidden] {
  display: none;
}

.wl-word {
  font-weight: 700;
  color: var(--ink);
  font-size: 13px;
  background: #fff;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid #eef1f5;
  white-space: nowrap;
  position: relative;
  user-select: none;
}

.wl-word.wl-clickable {
  cursor: pointer;
}

.wl-word.wl-clickable:hover {
  background: #f0f4f8;
}

.wl-word.wl-known {
  background: #e8f5e9;
  border-color: #a5d6a7;
  color: #2e7d32;
}

.wl-word.wl-wrong {
  background: #ffebee;
  border-color: #ef9a9a;
  color: #c62828;
}

.wl-check {
  display: inline-block;
  margin-right: 2px;
  color: #2e7d32;
  font-size: 11px;
  font-weight: 800;
}

.wl-meaning {
  font-weight: 400;
  color: var(--muted);
  margin-left: 3px;
  font-size: 12px;
}

.wl-sep {
  display: none;
}

/* ── Wordlist2 (extra words) ── */
.wordlist2-entries {
  margin: 0;
  font-size: 13px;
  line-height: 1.8;
  color: var(--ink);
}

.wl2-entry {
  margin-bottom: 10px;
  padding: 4px 0;
}

.wl2-word {
  font-weight: 700;
  color: var(--ink);
  font-size: 13px;
  background: #fff;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid #eef1f5;
  display: inline-block;
  white-space: nowrap;
  position: relative;
  user-select: none;
}
.wl2-word .wl-check {
  display: inline-block;
  margin-right: 2px;
  color: #2e7d32;
  font-size: 11px;
  font-weight: 800;
}

.wl2-meaning {
  font-weight: 400;
  color: var(--muted);
  margin-left: 4px;
  font-size: 12px;
}

.wl2-word.wl-clickable {
  cursor: pointer;
}
.wl2-word.wl-clickable:hover {
  background: #f0f4f8;
}
.wl2-word.wl-known {
  background: #e8f5e9;
  border-color: #a5d6a7;
  color: #2e7d32;
}

.wl2-example {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  margin-left: 2px;
  line-height: 1.5;
  font-style: italic;
}

@media (max-width: 840px) {
  .wordlist-scroll {
    padding-right: 4px;
  }

  .wordlist-cat {
    padding: 10px 12px;
    margin-bottom: 10px;
    border-radius: 8px;
  }

  .wordlist-cat h4 {
    font-size: 13px;
  }

  .wordlist-words {
    font-size: 13px;
    line-height: 2.2;
    gap: 3px 10px;
  }

  .wl-word {
    font-size: 13px;
    padding: 2px 7px;
  }

  .wl-meaning {
    font-size: 12px;
  }

  .wl2-entry {
    margin-bottom: 8px;
  }

  .wl2-word {
    font-size: 13px;
    padding: 2px 7px;
  }

  .wl2-meaning {
    font-size: 12px;
  }

  .wl2-example {
    font-size: 12px;
    margin-top: 2px;
    margin-left: 4px;
  }

  .wl-cat-header-row {
    gap: 4px;
  }

  .wl-example-btn,
  .wl-usage-btn {
    font-size: 11px;
    padding: 4px 8px;
  }

  #wordlistTitle {
    align-items: stretch;
    gap: 10px;
    max-width: calc(100vw - 66px);
  }

  .wl-title-main {
    flex: 1 1 100%;
  }

  .wl-jump-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    max-width: calc(100vw - 66px);
  }

  .wl-jump-btn {
    min-height: 36px;
    width: 100%;
    padding: 0 10px;
    text-align: center;
  }

  .wl-detail {
    padding: 8px 10px;
  }

  .wl-detail-list li {
    font-size: 12px;
    padding: 6px 8px;
  }

  .wl-coll-indicator {
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .wordlist-scroll {
    padding-right: 2px;
  }

  .wordlist-cat {
    padding: 8px 10px;
    margin-bottom: 8px;
    border-radius: 6px;
  }

  .wordlist-cat h4 {
    font-size: 12px;
  }

  .wordlist-words {
    font-size: 14px;
    line-height: 2.4;
    gap: 4px 10px;
  }

  .wl-word {
    font-size: 14px;
    padding: 3px 8px;
  }

  .wl-meaning {
    font-size: 12px;
  }

  .wl-example-btn,
  .wl-usage-btn {
    font-size: 10px;
    padding: 3px 7px;
  }
}

.wl-cat-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wl-cat-header {
  cursor: default;
  user-select: none;
  flex: 1;
  margin: 0;
}

.wl-cat-header.wl-has-coll {
  cursor: pointer;
}

.wl-cat-header.wl-has-coll:hover {
  color: var(--accent);
}

.wl-jump-btn {
  display: inline-block;
  margin-left: 0;
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  vertical-align: middle;
  transition: all 0.15s ease;
}
.wl-jump-btn:hover {
  background: var(--accent);
  color: #fff;
}
.wl-hideknown-btn.wl-hideknown-on {
  background: var(--accent);
  color: #fff;
}
.wl-toggle-mid-btn.wl-toggle-mid-on,
.wl-toggle-high-btn.wl-toggle-high-on {
  background: #856404;
  color: #fff;
}

.wl-fold-indicator {
  display: inline-block;
  margin-left: 6px;
  font-size: 12px;
  color: var(--muted);
  transition: transform 120ms ease;
}

.wl-example-btn {
  flex-shrink: 0;
  padding: 2px 10px;
  border: 1px solid var(--accent-soft);
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 120ms ease;
  white-space: nowrap;
}

.wl-example-btn:hover {
  background: #c5e0e0;
}

.wl-detail-examples {
  border-left: 3px solid #e8a838;
}

.wl-diff-btn {
  flex-shrink: 0;
  padding: 2px 10px;
  border: 1px solid var(--accent-soft);
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 120ms ease;
  white-space: nowrap;
}
.wl-diff-btn:hover {
  background: #d5d5d5;
}

.wl-usage-btn {
  flex-shrink: 0;
  padding: 2px 10px;
  border: 1px solid #c5d5e0;
  border-radius: 5px;
  background: #e8f0f8;
  color: #3a6d8c;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 120ms ease;
  white-space: nowrap;
}

.wl-usage-btn:hover {
  background: #d0e0f0;
}

.wl-detail-usage {
  border-left: 3px solid #3a6d8c;
}

.wl-usage {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink);
  line-height: 1.6;
  padding-left: 4px;
  font-style: italic;
}

.wl-detail-usage .wl-detail-list li {
  padding: 8px 10px;
}

.wl-detail-usage .wl-detail-word {
  display: block;
  margin-bottom: 2px;
  font-size: 14px;
}

.wl-detail {
  margin-top: 6px;
  margin-bottom: 4px;
  padding: 10px 12px;
  background: #f8fafb;
  border-radius: 8px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
}

.wl-detail-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 5px;
}

.wl-detail-list li {
  padding: 5px 10px;
  background: #fff;
  border-radius: 5px;
  border: 1px solid #eef1f5;
  font-size: 13px;
  line-height: 1.55;
}

.wl-detail-word {
  color: var(--accent);
  font-size: 13px;
}

.wl-detail-note {
  color: var(--ink);
}

.wl-example {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  font-style: italic;
  padding-left: 4px;
  border-left: 2px solid var(--accent-soft);
}

@media (max-width: 840px) {
  .wl-detail {
    padding: 8px 10px;
  }
  .wl-detail-list li {
    font-size: 12px;
    padding: 4px 8px;
  }
  .wl-coll-indicator {
    font-size: 12px;
  }
}

.prompt-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.prompt-kicker {
  margin-bottom: 4px;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.meaning {
  margin-bottom: 0;
  font-size: 32px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.counter {
  min-width: 72px;
  text-align: right;
  padding-top: 4px;
}

.counter span {
  font-size: 26px;
  font-weight: 700;
  font-family: var(--fm);
}

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

.quiz-noexplain-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.quiz-noexplain-btn.on {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 20px;
}

.option {
  min-height: 72px;
  padding: 16px 12px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.1s, border-color 0.1s;
}
.option:hover {
  border-color: var(--ink);
  background: var(--accent-soft);
}
.option strong {
  display: block;
  margin-bottom: 0;
  font-size: 16px;
}
  overflow-wrap: anywhere;
  font-size: 20px;
}

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

.option.correct {
  border-color: var(--ok);
  background: #f0faf2;
}

.option.wrong {
  border-color: var(--warn);
  background: #fef5f5;
}

.option.selected {
  border-color: var(--ink);
  background: var(--accent-soft);
}

.quiz-nav-btn {
  width: 52px; height: 52px;
  border-radius: var(--radius);
  font-size: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background-color 0.1s, border-color 0.1s;
}
.quiz-nav-btn:hover { border-color: var(--ink); background: var(--accent-soft); }
.quiz-nav-btn:disabled { opacity: 0.3; cursor: default; }

.quiz-submit-btn {
  flex: 1;
  min-height: 52px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  border: 1px solid var(--ink);
  cursor: pointer;
  transition: background-color 0.1s;
}
.quiz-submit-btn:hover { background: #333; border-color: #333; }
.quiz-submit-btn:disabled { opacity: 0.4; cursor: default; background: var(--muted); border-color: var(--muted); }

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}

.feedback {
  margin-top: 18px;
  border-left: 3px solid var(--ink);
  padding: 12px 14px;
  background: transparent;
  color: var(--ink);
}

.feedback.ok {
  border-left-color: var(--ok);
  color: var(--ink);
}

.feedback.no {
  border-left-color: var(--warn);
  color: var(--ink);
}

.feedback p {
  margin: 6px 0 12px;
}

.prompt-explain {
  border-left: 2px solid var(--ink);
  color: var(--ink);
  padding-left: 10px;
}

.explain-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.explain-list li {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(0, 1.6fr);
  gap: 12px;
  align-items: start;
  border-top: 1px solid var(--faint);
  padding-top: 10px;
  color: var(--ink);
}

.explain-list li.chosen {
  background: var(--accent-soft);
  padding: 10px;
}

.explain-term {
  display: grid;
  gap: 6px;
}

.explain-cat {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0;
}

.explain-term b {
  overflow-wrap: anywhere;
}

.explain-term span {
  justify-self: start;
  border-radius: var(--radius);
  background: var(--accent-soft);
  padding: 2px 8px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.explain-copy {
  color: var(--muted);
  display: grid;
  gap: 6px;
}

.explain-copy p {
  margin: 0;
}

.explain-copy strong {
  color: var(--ink);
}

.explain-note {
  border-left: 3px solid var(--accent-soft);
  padding-left: 10px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.explain-synonyms {
  font-size: 13px;
  color: var(--muted);
}

.explain-why {
  margin-top: 2px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.45;
}

.explain-why em {
  font-style: normal;
  font-weight: 700;
}

.explain-example {
  margin: 6px 0;
  padding: 6px 10px;
  background: #f8fafb;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  font-style: italic;
  border-left: 3px solid #c5d5e0;
}

.correct-why {
  background: #e9f6ef;
  color: var(--ok);
}

.wrong-contrast {
  display: block;
  margin-top: 4px;
  padding: 6px 10px;
  background: #fff5f5;
  border-radius: 4px;
  color: #8b0000;
  font-size: 13px;
  line-height: 1.6;
}

.wrong-why {
  background: #fff0ea;
  color: var(--warn);
  line-height: 1.7;
  font-size: 14px;
}

.correct-why {
  line-height: 1.7;
  font-size: 14px;
}

.status-correct {
  background: #d4edda;
  color: var(--ok);
}

.status-wrong-selected {
  background: #ffe0d6;
  color: var(--warn);
}

.status-wrong {
  background: #f0f0f0;
  color: var(--muted);
}

.feedback-header {
  margin-bottom: 12px;
  font-size: 20px;
}

.feedback-prompt {
  margin-bottom: 16px;
  padding: 14px;
  background: #f6f8fb;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.feedback-prompt p {
  margin: 4px 0;
}

.explain-section-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin: 16px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
}
.explain-section-label.collapsed {
  opacity: 0.6;
}
.explain-list.detailed.hidden {
  display: none;
}

.leaderboard {
  margin: 18px 0;
}

.leaderboard h4 {
  margin: 0 0 10px;
}

.ranking-note {
  color: var(--muted);
  margin: -2px 0 12px;
}

.leaderboard ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style-position: inside;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.leaderboard small {
  color: var(--muted);
}

.actions {
  justify-content: flex-end;
  margin-top: 20px;
}

.actions[hidden] {
  display: none;
}

.actions-top {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.actions button:nth-child(2) {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.actions button:disabled,
.actions button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.52;
  pointer-events: none;
}

.word-list {
  overflow: hidden;
}

.section-head {
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.section-head h3 {
  margin: 0;
  font-size: 18px;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.word-item {
  min-height: 76px;
  background: white;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.word-item b {
  display: block;
  margin-bottom: 4px;
}

.word-item span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.word-list.collapsed .word-grid {
  display: none;
}

@media (max-width: 840px) {
  .app {
    grid-template-columns: 1fr;
    overflow-x: hidden;
  }

  .sidebar {
    gap: 16px;
    min-height: auto;
    border-right: 0;
    padding: 16px 20px;
    width: 100%;
    max-width: 100vw;
  }

  .workspace {
    padding: 16px 12px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .wordlist-words {
    grid-template-columns: 1fr;
    gap: 4px 0;
  }

  .wordlist-cat {
    padding: 10px 8px;
    margin-bottom: 8px;
    max-width: 100%;
    overflow: hidden;
  }

  .wl-word {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .set-card,
  .player-card,
  .category-nav {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
  }

  .category-nav {
    max-height: min(220px, 32vh);
  }

  .workspace {
    gap: 14px;
    padding: 16px;
  }

  .stats {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
  }

  .stats div {
    padding: 10px 12px;
  }

  .toolbar,
  .prompt-row {
    align-items: stretch;
    flex-direction: column;
  }

  .counter {
    text-align: left;
  }

  .quiz-panel,
  .start-panel,
  .result-panel,
  .ranking-panel {
    padding: 16px;
  }

  .actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .actions button {
    width: 100%;
    min-width: 0;
    padding: 0 8px;
  }

  .actions-top {
    margin-top: 12px;
    padding-top: 12px;
  }

  .options,
  .word-grid,
  .name-form div,
  .explain-list li,
  .leaderboard li {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .set-card,
  .player-card,
  .category-nav,
  .stats {
    max-width: 100%;
  }

  /* Mobile quiz: compact, content-first */
  .workspace {
    padding: 10px 8px;
    gap: 8px;
  }
  .appbar {
    padding: 0;
  }
  .quiz-panel {
    padding: 16px 12px;
    border-radius: var(--radius);
  }
  .prompt-row {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
  }
  .prompt-kicker {
    font-size: 11px;
  }
  .meaning {
    font-size: 28px;
    line-height: 1.15;
  }
  .counter {
    text-align: left;
    padding-top: 0;
  }
  .counter span {
    font-size: 22px;
  }
  .counter small {
    font-size: 12px;
  }
  .options {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: 12px;
  }
  .option {
    min-height: 56px;
    padding: 12px 8px;
    font-size: 14px;
    border-radius: var(--radius);
  }
  .option strong {
    font-size: 14px;
  }
  .option span {
    font-size: 12px;
  }
  .actions {
    display: grid;
    grid-template-columns: 48px 1fr 48px;
    gap: 6px;
  }
  .quiz-nav-btn {
    width: 48px;
    height: 48px;
    font-size: 18px;
  }
  .quiz-submit-btn {
    min-height: 48px;
    font-size: 15px;
  }
  .feedback {
    padding: 10px 12px;
    font-size: 13px;
  }
}

/* Logic Quiz */
.logic-mode-btn {
  border-color: rgba(255,255,255,0.2) !important;
  background: rgba(100,150,200,0.15) !important;
}

.logic-header {
  margin-bottom: 16px;
}

.logic-header h3 {
  margin-bottom: 4px;
  font-size: 24px;
}

.logic-question {
  font-size: 17px;
  line-height: 1.7;
  margin: 16px 0 20px;
  padding: 14px 18px;
  background: #f8fafb;
  border-radius: 8px;
  border-left: 4px solid var(--accent);
  color: var(--ink);
}

#logicOptions .option {
  text-align: left;
  padding: 14px 18px;
  font-size: 16px;
}

#logicOptions .option:hover {
  background: #f0f4f8;
}

#logicOptions .option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

#logicOptions .option.correct {
  border-color: #8fc7a8;
  background: #ecf8f1;
}

#logicOptions .option.wrong {
  border-color: #dda08c;
  background: #fff1ec;
}

.logic-counter {
  font-size: 16px;
  font-weight: 700;
  color: var(--muted);
  min-width: 60px;
}

@media (max-width: 840px) {
  .logic-question {
    font-size: 15px;
    padding: 10px 14px;
  }
  #logicOptions .option {
    font-size: 14px;
    padding: 12px 14px;
  }
}

/* ===== Study Dashboard ===== */
.dashboard-panel {
  background: transparent;
  border: none;
  padding: 0;
}
.dash {
  display: grid;
  gap: 18px;
  max-width: 760px;
}
.dash-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 28px 0;
  border-radius: 0;
  border-bottom: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
}
.dash-hero-icon {
  font-size: 28px;
  width: auto;
  height: auto;
  background: transparent;
  border-radius: 0;
  flex: 0 0 auto;
}
.dash-hero-text { min-width: 0; }
.dash-hero-eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}
.dash-hero-title {
  margin: 0 0 4px;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--ink);
}
.dash-hero-sub {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.dash-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.dash-stats-xl {
  grid-template-columns: repeat(6, 1fr);
}
.dash-stat {
  display: grid;
  gap: 2px;
  padding: 14px 12px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  text-align: center;
  transition: background-color 0.1s;
}
.dash-stat[cursor="pointer"]:hover,
.dash-stat[onclick]:hover {
  background: var(--accent-soft);
}
.dash-stat-num {
  font-size: 26px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
  font-family: var(--fm);
}
.dash-stat-num small {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.dash-stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.dash-stat-icon {
  font-size: 28px;
  line-height: 1.1;
  display: block;
}
.dash-section-label {
  margin: 6px 0 -4px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
}
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
}
.dash-card {
  --c: var(--ink);
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 14px 14px;
  min-height: 64px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.1s, border-color 0.1s;
}
.dash-card:hover {
  background: var(--accent-soft);
  border-color: var(--ink);
}
.dash-card:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.dash-card-icon {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-size: 22px;
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.dash-card-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.dash-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}
.dash-card-badge {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--warn);
  border-radius: var(--radius);
  padding: 1px 7px;
  line-height: 1.5;
}
.dash-card-desc {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-card[data-accent="teal"],
.dash-card[data-accent="indigo"],
.dash-card[data-accent="blue"],
.dash-card[data-accent="green"],
.dash-card[data-accent="slate"],
.dash-card[data-accent="gold"],
.dash-card[data-accent="rose"],
.dash-card[data-accent="amber"],
.dash-card[data-accent="plum"] { --c: var(--ink); }

@media (max-width: 840px) {
  .dash-stats-xl {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 480px) {
  .dash-hero { flex-direction: column; align-items: flex-start; padding: 20px 0; gap: 8px; }
  .dash-hero-title { font-size: 22px; }
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .dash-card { min-height: 60px; padding: 12px; }
  .dash-stat-num { font-size: 22px; }
  .dash-stats-xl {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .dash-stat {
    padding: 10px 6px;
  }
  .dash-stat-icon {
    font-size: 22px;
  }
}

/* Navigation lives in the dashboard now — hide the duplicate sidebar buttons
   (kept in the DOM so the dashboard cards can still trigger them). */
#synonymDrillBtn,
#logicModeBtn,
#myinfoBtn,
#rankingBtn,
#wordlistBtn,
#wordlist2Btn,
#wordcheckBtn,
#wordcheck201Btn {
  display: none !important;
}

/* ===== Sidebar removed — single-column layout ===== */
.sidebar { display: none !important; }
.app { grid-template-columns: 1fr; }

.appbar {
  display: flex;
  align-items: center;
}
.appbrand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  padding: 2px 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
}
.appbrand:hover { color: var(--muted); }

.appbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  transition: background-color 0.1s;
}
.appbar-btn:hover { background: var(--accent-soft); color: var(--ink); border-color: var(--line); }

/* Login / 내정보 box relocated into the dashboard (light surface) */
.dashboard-panel #authSection {
  max-width: 420px;
  margin-bottom: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.dashboard-panel .auth-label { color: var(--muted); }
.dashboard-panel .auth-section input {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}
.dashboard-panel .auth-section input::placeholder { color: var(--muted); }
.dashboard-panel #authLoggedIn strong { color: var(--ink); }
.dashboard-panel .auth-logout-btn {
  color: var(--muted);
  border-color: var(--line);
}

/* Category picker relocated into the workspace (bottom section) */
.cat-nav-wrapper {
  margin-top: 8px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
}
.cat-nav-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  padding: 0 20px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}
.cat-nav-toggle::after {
  content: '▾';
  font-size: 12px;
  color: var(--muted);
  transition: transform 0.2s ease;
}
.cat-nav-toggle.expanded::after {
  transform: rotate(180deg);
}
.cat-nav-body {
  display: none;
  padding: 0 16px 16px;
}
.cat-nav-body.open {
  display: block;
}
.workspace .category-nav {
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  max-width: 100%;
  max-height: 42vh;
  overflow-y: auto;
  gap: 5px;
}
.workspace .category-btn {
  min-height: 36px;
  padding: 4px 10px;
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 12px;
  border-radius: var(--radius);
}
.workspace .category-btn span {
  font-size: 12px;
}
.workspace .category-btn small {
  font-size: 10px;
}
.workspace .category-btn[aria-current="true"] {
  border-color: var(--ink);
  background: var(--accent-soft);
  color: var(--ink);
}
.workspace .category-btn small { color: var(--muted); opacity: 1; }

@media (max-width: 480px) {
  .workspace .category-nav {
    grid-template-columns: repeat(4, 1fr);
    max-height: 36vh;
    gap: 4px;
  }
  .workspace .category-btn {
    min-height: 32px;
    padding: 2px 6px;
    font-size: 11px;
    border-radius: 8px;
  }
  .workspace .category-btn span {
    font-size: 11px;
  }
  .workspace .category-btn small {
    font-size: 9px;
  }
  .cat-nav-toggle {
    min-height: 44px;
    padding: 0 16px;
    font-size: 13px;
  }
}

/* ===== Dashboard hero holds the greeting + login / 내정보 ===== */
#dashHeader.dash-hero {
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}
.dash-hero-top {
  display: flex;
  align-items: center;
  gap: 16px;
}
.dash-hero-mypage {
  margin-left: auto;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.1s;
}
.dash-hero-mypage:hover {
  background: var(--accent-soft);
}
.dash-hero #authSection {
  margin: 0;
  max-width: none;
  background: transparent;
  border: 1px solid var(--line);
}
.dash-hero .auth-label { color: var(--muted); }
.dash-hero .auth-section input {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}
.dash-hero .auth-section input::placeholder { color: var(--muted); }
.dash-hero #authLoginBtn { background: var(--ink); color: #fff; border-color: var(--ink); }
.dash-hero #authRegisterBtn { background: transparent; color: var(--ink); border-color: var(--line); }

/* Logged-in: show name + logout, spaced nicely across the hero bar */
.dash-hero #authLoggedIn:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.dash-hero #authLoggedIn .auth-label { display: none; }
.dash-hero #authLoggedIn strong {
  color: var(--ink);
  font-size: 14px;
  margin-right: auto;
}
.dash-hero .auth-logout-btn {
  margin: 0;
  width: auto;
  color: var(--warn);
  border-color: var(--line);
  background: transparent;
  padding: 6px 18px;
  font-size: 13px;
}

/* ===== Minimalist utility classes (extracted from inline styles) ===== */

#mainTitle { cursor: pointer; }

.version-tag {
  font-size: 9px;
  color: var(--muted);
  text-align: center;
  margin: 8px 0 0;
}

.set-card[hidden] { display: none; }

#noExplainIndicator {
  font-size: 11px;
  font-weight: 600;
  margin-left: 8px;
  padding: 3px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
#noExplainIndicator:hover { background: var(--accent-soft); color: var(--ink); }
#noExplainIndicator.on { background: var(--accent-soft); color: var(--warn); }

#quizModeLabel {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

/* Wordcheck extracted styles */
.wc-progress { font-size: 13px; color: var(--muted); }
.wc-question { font-size: 17px; font-weight: 600; margin: 0 0 16px; }
.wc-choices { display: grid; gap: 8px; margin-bottom: 16px; }
.wc-submit {
  min-height: 44px;
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.wc-next { display: none; min-height: 40px; margin-top: 8px; }
.wc-feedback {
  display: none;
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.wc-result { display: none; text-align: center; padding: 20px; }
.wc-retry { min-height: 40px; margin-top: 8px; }

.grammar-content { max-height: 70vh; overflow-y: auto; }

.panel-close-btn { margin-top: 16px; }
