/* ===== THEMES ===== */
:root, [data-theme="cream"] {
  --bg: #f7f3eb; --surface: #fffbf3; --surface2: #f0ebe0;
  --border: #e0d6c4; --border2: #d4c9b5;
  --text: #3d3229; --text-dim: #6b5d4f; --text-dimmer: #9a8b7a;
  --accent: #b8860b; --accent-dim: #96700a; --accent-glow: rgba(184,134,11,0.12);
  --green: #2e7d32; --green-dim: rgba(46,125,50,0.10);
  --red: #c62828; --red-dim: rgba(198,40,40,0.10);
  --blue: #1565c0; --blue-dim: rgba(21,101,192,0.10);
  --radius: 12px; --radius-sm: 8px;
  --shadow: rgba(0,0,0,0.08);
}
[data-theme="paper"] {
  --bg: #f0f0ec; --surface: #ffffff; --surface2: #f5f5f2;
  --border: #dcdcd8; --border2: #c8c8c4;
  --text: #1a1a1a; --text-dim: #4a4a4a; --text-dimmer: #8a8a8a;
  --accent: #2962ff; --accent-dim: #1e4fcc; --accent-glow: rgba(41,98,255,0.10);
  --green: #2e7d32; --green-dim: rgba(46,125,50,0.10);
  --red: #c62828; --red-dim: rgba(198,40,40,0.10);
  --blue: #1565c0; --blue-dim: rgba(21,101,192,0.10);
  --shadow: rgba(0,0,0,0.06);
}
[data-theme="sage"] {
  --bg: #e8efe5; --surface: #f2f7ef; --surface2: #dde8d8;
  --border: #c4d4be; --border2: #b0c4a8;
  --text: #2d3a2d; --text-dim: #4a5c4a; --text-dimmer: #7a8c7a;
  --accent: #2e7d32; --accent-dim: #1b5e20; --accent-glow: rgba(46,125,50,0.12);
  --green: #2e7d32; --green-dim: rgba(46,125,50,0.10);
  --red: #c62828; --red-dim: rgba(198,40,40,0.10);
  --blue: #1565c0; --blue-dim: rgba(21,101,192,0.10);
  --shadow: rgba(0,0,0,0.06);
}
[data-theme="ocean"] {
  --bg: #e3edf7; --surface: #eef4fb; --surface2: #d8e6f4;
  --border: #b8cfea; --border2: #a0bfe0;
  --text: #1a2a3a; --text-dim: #3a5068; --text-dimmer: #6a8aa8;
  --accent: #1565c0; --accent-dim: #0d47a1; --accent-glow: rgba(21,101,192,0.12);
  --green: #2e7d32; --green-dim: rgba(46,125,50,0.10);
  --red: #c62828; --red-dim: rgba(198,40,40,0.10);
  --blue: #1565c0; --blue-dim: rgba(21,101,192,0.10);
  --shadow: rgba(0,0,0,0.06);
}
[data-theme="lavender"] {
  --bg: #ece5f0; --surface: #f5f0f7; --surface2: #e4dce8;
  --border: #d0c4d8; --border2: #beb0c8;
  --text: #2d2433; --text-dim: #4f4258; --text-dimmer: #8a7a94;
  --accent: #6a1b9a; --accent-dim: #4a148c; --accent-glow: rgba(106,27,154,0.12);
  --green: #2e7d32; --green-dim: rgba(46,125,50,0.10);
  --red: #c62828; --red-dim: rgba(198,40,40,0.10);
  --blue: #1565c0; --blue-dim: rgba(21,101,192,0.10);
  --shadow: rgba(0,0,0,0.06);
}
[data-theme="dark"] {
  --bg: #1a1b1e; --surface: #25262b; --surface2: #2c2e33;
  --border: #3a3c42; --border2: #4a4c52;
  --text: #e0e0e0; --text-dim: #a8a8b0; --text-dimmer: #707080;
  --accent: #7caef8; --accent-dim: #5a9af0; --accent-glow: rgba(124,174,248,0.15);
  --green: #66bb6a; --green-dim: rgba(102,187,106,0.15);
  --red: #ef5350; --red-dim: rgba(239,83,80,0.15);
  --blue: #64b5f6; --blue-dim: rgba(100,181,246,0.15);
  --shadow: rgba(0,0,0,0.3);
}

/* ===== RESET ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
*:focus, *:focus-visible, *:focus-within {
  outline: none !important;
  box-shadow: none !important;
}
* {
  -webkit-tap-highlight-color: transparent;
  -webkit-focus-ring-color: transparent;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans JP', 'Segoe UI', sans-serif;
  min-height: 100dvh;
  transition: background 0.2s, color 0.2s;
}
body.token-expired {
  background: #fce4ec;
}
/* Session expired overlay */
#session-expired-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.session-expired-box {
  background: #fff; border-radius: 16px;
  padding: 32px 24px; text-align: center;
  max-width: 340px; width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.session-expired-icon { font-size: 48px; margin-bottom: 12px; }
.session-expired-title {
  font-size: 20px; font-weight: 700; color: #c62828; margin-bottom: 8px;
}
.session-expired-msg {
  font-size: 14px; color: #555; line-height: 1.6; margin-bottom: 20px;
}
.session-expired-btn { width: 100%; }
/* Block quiz interaction when token expired */
body.token-expired .choice-btn,
body.token-expired .typing-submit-btn,
body.token-expired #btn-start-quiz {
  pointer-events: none; opacity: 0.4;
}

/* ===== SCREENS ===== */
.screen { display: none; }
.screen.active { display: block; }
.screen-content {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

/* ===== BOOK SELECT LAYOUT (fixed header + footer) ===== */
.screen-book-layout {
  height: 100dvh;
  display: none;
  flex-direction: column;
  max-width: 680px;
  margin: 0 auto;
}
.screen-book-layout.active { display: flex; }
.book-select-header {
  flex-shrink: 0;
  padding: 16px 16px 0;
}
.book-select-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px;
  -webkit-overflow-scrolling: touch;
}
.book-select-footer {
  flex-shrink: 0;
  padding: 10px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.book-select-footer .range-row,
.book-select-footer .batch-row {
  display: flex; align-items: center; gap: 8px;
}
.book-select-footer-row {
  display: flex; align-items: center; gap: 10px;
}
.book-select-footer-row .range-row,
.book-select-footer-row .batch-row {
  flex: 1; margin: 0;
}
.book-select-footer-row .btn-primary {
  width: auto; min-width: 80px; padding: 10px 20px; flex-shrink: 0;
}

/* ===== LOGIN ===== */
.login-card {
  max-width: 400px; margin: 80px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 32px; text-align: center;
}
.login-title {
  font-family: 'Playfair Display', serif;
  font-size: 28px; font-weight: 700;
  color: var(--accent); margin-bottom: 8px;
}
.login-subtitle {
  color: var(--text-dim); font-size: 14px; margin-bottom: 32px;
}
.ms-login-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  padding: 12px 28px; border-radius: var(--radius-sm);
  font-size: 15px; color: var(--text); cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.ms-login-btn:hover { background: var(--surface2); border-color: var(--border2); }
.ms-login-btn svg { width: 20px; height: 20px; }

/* ===== MODE SELECT ===== */
.mode-cards {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px;
  margin-top: 24px;
}
.mode-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 20px; text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
@media (hover: hover) {
  .mode-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--shadow);
  }
}
.mode-card-icon { font-size: 36px; margin-bottom: 12px; }
.mode-card-title {
  font-family: 'Playfair Display', serif;
  font-size: 20px; font-weight: 700;
  color: var(--accent); margin-bottom: 6px;
}
.mode-card-desc {
  font-size: 13px; color: var(--text-dim);
}
.mode-card-test { border-left: 5px solid #c62828; }
.mode-card-training { border-left: 5px solid #1565c0; }
.mode-card-conj { border-left: 5px solid #6a1b9a; }
.conj-pattern-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 8px; }
.setup-mode-banner.mode-conj { border-left: 5px solid #6a1b9a; background: linear-gradient(90deg, rgba(106,27,154,0.08), transparent); }

/* ===== RECENT BOOKS ===== */
.recent-books-section { padding: 0 0 8px; }
.recent-books-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.recent-book-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.recent-book-item:hover { border-color: var(--accent); background: var(--accent-glow); }
.recent-book-info { flex: 1; min-width: 0; }
.recent-book-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-book-range { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-dimmer); }

/* ===== SECTION HEADING ===== */
.section-heading {
  font-family: 'Playfair Display', serif;
  font-size: 22px; font-weight: 700;
  color: var(--accent); margin-bottom: 4px;
}
.section-sub {
  font-size: 13px; color: var(--text-dimmer);
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 20px;
}

/* ===== SOURCE TABS (book-select) ===== */
.source-tabs {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
}
.source-tab {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  color: var(--text-dim);
  transition: all 0.15s;
}
.source-tab:hover { border-color: var(--accent); }
.source-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ===== THEME LIST ===== */
.theme-item {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
@media (hover: hover) { .theme-item:hover { border-color: var(--accent); } }
.theme-item.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.theme-item input[type="radio"] {
  accent-color: var(--accent);
  width: 16px; height: 16px; flex-shrink: 0;
}
.theme-name {
  font-size: 15px; font-weight: 500;
}
.theme-desc {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--text-dimmer);
}
.theme-count {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--text-dimmer);
  white-space: nowrap;
}
.theme-empty {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; color: var(--text-dimmer);
  padding: 8px 14px;
  font-style: italic;
}
.theme-range-area {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ===== EXPAND BOOK LIST BUTTON ===== */
.btn-expand-list {
  display: block; width: 100%;
  margin-top: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border: 1px dashed var(--border2);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-align: center;
}
.btn-expand-list:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== BOOK SELECT ===== */
.book-list {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 20px;
}
.book-category-header {
  font-family: 'Playfair Display', serif;
  font-size: 15px; font-weight: 700;
  color: var(--accent);
  margin-top: 12px; margin-bottom: 4px;
  padding-left: 4px;
}
.book-category-header:first-child { margin-top: 0; }
.book-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
@media (hover: hover) { .book-item:hover { border-color: var(--accent); } }
.book-item.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.book-item input[type="checkbox"],
.book-item input[type="radio"] {
  accent-color: var(--accent);
  width: 16px; height: 16px; flex-shrink: 0;
}
.book-item-name {
  font-size: 15px; font-weight: 500; flex: 1;
}
.book-item-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--text-dimmer);
}
.range-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px;
}
.range-row label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--text-dim);
}
.range-input {
  width: 70px; padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; color: var(--text);
  text-align: center;
}
.range-input:focus {
  outline: none; border-color: var(--accent);
}

/* ===== QUIZ SETUP ===== */
#screen-quiz-setup {
  height: 100dvh; overflow: hidden;
}
#screen-quiz-setup > .screen-content {
  height: 100%; display: flex; flex-direction: column;
  padding-bottom: 16px; overflow-y: auto;
}
#screen-quiz-setup .section-heading { margin-bottom: 2px; }
#screen-quiz-setup .section-sub { margin-bottom: 6px; }
#screen-quiz-setup .btn-primary { margin-top: auto; flex-shrink: 0; }
.setup-mode-banner {
  display: flex; align-items: flex-start; gap: 6px;
  margin: 8px 0 6px;
  padding: 12px 14px 10px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.setup-mode-banner.mode-test {
  background: linear-gradient(135deg, rgba(198,40,40,0.18), rgba(198,40,40,0.05));
  border-color: rgba(198,40,40,0.35);
  border-left: 6px solid #c62828;
}
.setup-mode-banner.mode-training {
  background: linear-gradient(135deg, rgba(21,101,192,0.18), rgba(21,101,192,0.05));
  border-color: rgba(21,101,192,0.35);
  border-left: 6px solid #1565c0;
}
.setup-mode-copy { min-width: 0; }
.setup-mode-title { font-size: 18px; font-weight: 800; }
.setup-mode-banner.mode-test .setup-mode-title { color: #ffb4ab; }
.setup-mode-banner.mode-training .setup-mode-title { color: #9fc9ff; }
.setup-mode-sub { margin-top: 2px; font-size: 12px; color: var(--text-dim); }
.setup-top-cluster {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.setup-start-btn { margin-top: 0 !important; }
.quiz-type-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 12px;
}
.quiz-type-btn {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
@media (hover: hover) { .quiz-type-btn:hover { border-color: var(--accent); } }
.quiz-type-btn.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.quiz-type-btn .qt-label {
  font-size: 14px; font-weight: 600; margin-bottom: 2px;
}
.quiz-type-btn .qt-desc {
  font-size: 11px; color: var(--text-dimmer);
  font-family: 'JetBrains Mono', monospace;
}
.setup-range-bar {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 0;
}
.setup-range-bar label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; color: var(--text-dim);
}
.setup-range-bar span { color: var(--text-dim); font-size: 13px; }
.setup-range-bar .range-input { width: 65px; }

.pos-filter-row {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px;
}
.chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; padding: 6px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; cursor: pointer;
  color: var(--text-dim);
  transition: all 0.15s;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active {
  background: var(--accent); color: #fff;
  border-color: var(--accent);
}

/* ===== PRIMARY BUTTON ===== */
.btn-primary {
  display: block; width: 100%;
  background: var(--accent);
  color: #fff; border: none;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: var(--accent-dim); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled {
  opacity: 0.5; cursor: not-allowed;
  transform: none;
}
.btn-secondary {
  display: block; width: 100%;
  background: var(--surface);
  color: var(--accent); border: 2px solid var(--accent);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 10px;
}
.btn-secondary:hover { background: var(--accent-glow); }

.btn-derivatives {
  background: var(--blue);
  margin-top: 10px;
}
.btn-derivatives:hover { background: var(--blue); opacity: 0.9; }

/* ===== QUIZ SCREEN (FULLSCREEN LAYOUT) ===== */
.screen-quiz-fullscreen {
  height: 100dvh;
  overflow: hidden;
  display: none;
  flex-direction: column;
  padding: 12px 12px env(safe-area-inset-bottom, 12px);
  max-width: 680px;
  margin: 0 auto;
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--bg);
  overscroll-behavior: none;
  touch-action: pan-y pinch-zoom;
}
.screen-quiz-fullscreen.active {
  display: flex;
}

.quiz-top {
  flex-shrink: 0;
  padding-bottom: 4px;
}
.quiz-header {
  display: flex; justify-content: center;
  align-items: center; margin-bottom: 4px;
  position: relative;
}
.quiz-progress {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; color: var(--text-dim);
}
.quiz-timer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px; font-weight: 600; color: var(--accent);
  min-width: 52px; text-align: right;
  position: absolute; right: 0;
}
.quiz-timer.warning { color: var(--red); }

.progress-bar {
  height: 4px; background: var(--surface2);
  border-radius: 2px; overflow: hidden;
}
.quiz-timer-bar {
  flex-shrink: 0;
  margin: 0;
}
.progress-fill {
  height: 100%; background: var(--accent);
  border-radius: 2px;
}
.progress-fill.timer-blue { background: var(--blue); }
.progress-fill.timer-yellow { background: #f9a825; }
.progress-fill.timer-red { background: var(--red); }

.quiz-question-area {
  flex: 0 0 18%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  padding-bottom: 4px;
}
.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px;
  text-align: center;
  width: 100%;
  cursor: default;
}
.question-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--text-dimmer);
  margin-bottom: 4px; text-transform: uppercase;
  letter-spacing: 0.5px;
}
.question-text {
  font-size: 28px; font-weight: 600;
  line-height: 1.4;
  word-break: break-word;
}
.question-sub {
  font-size: 12px; color: var(--text-dim);
  margin-top: 4px;
  font-family: 'JetBrains Mono', monospace;
}
.question-text-trigger {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  width: 100%;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* Collocation items display (legacy) */
.colloc-items {
  font-size: 18px;
  line-height: 1.6;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
}

/* Phrase quiz display */
.colloc-expanded {
  min-height: 280px;
}
.phrase-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  padding: 0 8px;
}
.phrase-item {
  font-size: 18px;
  line-height: 1.4;
  color: var(--text);
  word-break: break-word;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Listen buttons */
.listen-again-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  font-size: 20px;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-glow);
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s, transform 0.1s;
}
.listen-again-btn:active {
  transform: scale(0.95);
  background: var(--accent-dim);
  color: #fff;
}
.listen-start-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 20px 44px;
  font-size: 24px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  transition: background 0.2s, transform 0.1s;
}
.listen-start-btn:active {
  transform: scale(0.95);
  background: var(--accent-dim);
}

/* Speak quiz */
.speak-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
}
.speak-orb-wrap {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 12px auto;
}
.speak-orb {
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: transparent;
  border: 2.5px solid rgba(210,50,50,0.7);
  box-shadow: 0 0 16px rgba(210,50,50,0.15), inset 0 0 12px rgba(210,50,50,0.06);
  animation: speakOrbPulse 1.6s ease-in-out infinite;
}
.speak-orb-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(210,50,50,0.25);
  animation: speakRingExpand 1.6s ease-out infinite;
}
.speak-orb-whisper {
  border-color: rgba(91,44,111,0.7);
  box-shadow: 0 0 16px rgba(91,44,111,0.15), inset 0 0 12px rgba(91,44,111,0.06);
}
.speak-orb-ring-whisper {
  border-color: rgba(91,44,111,0.25);
}
.speak-whisper-label {
  text-align: center;
  font-size: 13px;
  color: #5b2c6f;
  font-weight: 600;
}
.speak-ready-tap {
  cursor: pointer;
}
.speak-orb-ready {
  border-color: rgba(100,160,220,0.7);
  box-shadow: 0 0 16px rgba(100,160,220,0.15), inset 0 0 12px rgba(100,160,220,0.06);
  animation: speakReadyGlow 2s ease-in-out infinite;
}
.speak-orb-ring-ready {
  border-color: rgba(100,160,220,0.3);
  animation: none;
}
@keyframes speakReadyGlow {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
.speak-tap-label {
  text-align: center;
  font-size: 14px;
  color: #90caf9;
  font-weight: 600;
  margin-top: -4px;
}
@keyframes speakOrbPulse {
  0%, 100% { transform: scale(1); opacity: 0.75; }
  50% { transform: scale(1.08); opacity: 1; }
}
@keyframes speakRingExpand {
  0% { transform: scale(0.7); opacity: 0.5; }
  100% { transform: scale(1.4); opacity: 0; }
}
.speak-mic-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  font-size: 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--red);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}
.speak-mic-btn:active { transform: scale(0.95); }
.speak-error {
  font-size: 14px;
  color: var(--red);
  margin-bottom: 8px;
}
.speak-alts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  width: 100%;
}
.speak-alt-btn {
  padding: 10px 20px;
  font-size: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  transition: border-color 0.2s, background 0.2s;
}
.speak-alt-btn:active {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.speak-2nd-btn {
  padding: 10px 24px;
  font-size: 14px;
  border: 2px solid #5b2c6f;
  border-radius: var(--radius);
  background: rgba(91,44,111,0.1);
  color: #5b2c6f;
  cursor: pointer;
  font-weight: 600;
  margin-top: 4px;
}
.speak-2nd-btn:active {
  background: #5b2c6f;
  color: #fff;
}
.speak-model-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-left: 10px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  color: inherit;
  font-size: 20px;
  cursor: pointer;
  vertical-align: middle;
}
.speak-model-btn:active { transform: scale(0.9); }

/* Speak word button (word-review & results) */
.speak-word-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--accent);
  font-size: 16px;
  cursor: pointer;
  vertical-align: middle;
  margin-right: 4px;
  padding: 0;
  flex-shrink: 0;
}
.speak-word-btn:active { transform: scale(0.9); background: var(--accent-dim); color: #fff; }

/* ===== Settings screen ===== */
.settings-group { margin-bottom: 20px; }
.settings-label { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.settings-row { display: flex; align-items: center; gap: 12px; }
.settings-range { flex: 1; accent-color: var(--accent); }
.settings-val { font-size: 14px; font-weight: 600; color: var(--accent); min-width: 48px; text-align: right; font-family: 'JetBrains Mono', monospace; }

.theme-dots { display: flex; gap: 10px; flex-wrap: wrap; }
.theme-dot {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--border); cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.theme-dot:hover { transform: scale(1.1); }
.theme-dot.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.theme-dot[data-theme="cream"] { background: #f7f3eb; }
.theme-dot[data-theme="paper"] { background: #f0f0ec; }
.theme-dot[data-theme="sage"] { background: #e8efe5; }
.theme-dot[data-theme="ocean"] { background: #e3edf7; }
.theme-dot[data-theme="lavender"] { background: #ece5f0; }
.theme-dot[data-theme="dark"] { background: #1a1b1e; }

.quiz-answer-area {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 0 4px;
}

/* ===== CHOICES ===== */
.choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(4, 1fr);
  gap: 6px;
  height: 100%;
}
/* Usage8: dual verb + prep grid container */
.choices-grid-usage8 {
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: 100%;
}
.usage8-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dimmer);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0 2px;
}
.usage8-verb-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(4, 1fr);
  gap: 4px;
  flex: 1;
}
.usage8-prep-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 4px;
  flex: 0.5;
}
.usage8-prep-grid .choice-btn {
  font-size: 15px;
  padding: 4px 2px;
}

/* 6-choice grid for collocation */
.choices-grid-6 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  height: 100%;
}
.choice-btn {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  word-break: break-word;
  line-height: 1.2;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}
@media (hover: hover) {
  .choice-btn:hover:not(.disabled) {
    border-color: var(--accent);
  }
}
.choice-btn.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.choice-btn.correct {
  border-color: var(--green);
  background: var(--green-dim);
  color: var(--green);
  font-weight: 600;
}
.choice-btn.wrong {
  border-color: var(--red);
  background: var(--red-dim);
  color: var(--red);
  opacity: 0.8;
}
.choice-btn.disabled {
  cursor: default;
  pointer-events: none;
}
.choice-btn:focus:not(.correct):not(.wrong),
.choice-btn:focus-visible:not(.correct):not(.wrong) {
  border-color: var(--border);
}

/* ===== SKELL COLLOCATION ===== */

/* Layout: skell question takes remaining space, scrollable */
.quiz-question-area.skell-expanded {
  flex: 1 1 0;
  overflow-y: auto;
  align-items: flex-start;
  padding-bottom: 0;
}
.quiz-question-area.skell-expanded .question-card {
  padding: 8px 12px;
}
/* Answer area shrinks to just fit the grid when skell */
.quiz-question-area.skell-expanded ~ .progress-bar,
.quiz-question-area.skell-expanded ~ .feedback-bar { flex-shrink: 0; }
.quiz-question-area.skell-expanded ~ .quiz-answer-area {
  flex: 0 0 auto;
  padding-bottom: 0;
}

/* Hint labels */
.skell-cat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dimmer);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
  font-family: 'DM Sans', 'Noto Sans JP', sans-serif;
}
.skell-cat-label.skell-question {
  font-size: 15px;
  font-weight: 600;
  margin-top: 14px;
  color: var(--accent);
  text-transform: none;
  letter-spacing: 0;
}

/* Hint words — one per line */
.skell-hint-words {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 19px;
  line-height: 1.55;
  color: var(--text);
  font-family: 'DM Sans', 'Noto Sans JP', sans-serif;
  font-weight: 400;
  padding-left: 4px;
}
.skell-hint-sep {
  height: 10px;
}

/* Choice grid — 2×3, fixed row height */
.choices-grid-skell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 54px 54px 54px;
  gap: 8px;
  width: 100%;
}

/* Choice buttons — clean modern card */
.choices-grid-skell .choice-btn {
  font-family: 'DM Sans', 'Noto Sans JP', sans-serif;
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
  height: 54px;
  box-sizing: border-box;
  border: 1.5px solid var(--border2);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 1px 3px var(--shadow);
  transition: transform 0.1s, box-shadow 0.1s, border-color 0.15s;
}
.choices-grid-skell .choice-btn:active:not(.disabled) {
  transform: scale(0.97);
  box-shadow: 0 0 0 transparent;
}
.choices-grid-skell .choice-btn.correct {
  border-color: var(--green);
  background: var(--green-dim);
  color: var(--green);
  font-weight: 600;
  box-shadow: 0 0 0 2px rgba(46,125,50,0.15);
}
.choices-grid-skell .choice-btn.wrong {
  border-color: var(--red);
  background: var(--red-dim);
  color: var(--red);
  opacity: 0.8;
}

/* ===== TYPING INPUT ===== */
.typing-area {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.typing-input {
  display: block; width: 100%;
  padding: 14px 16px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 18px;
  font-family: 'Noto Sans JP', 'Segoe UI', sans-serif;
  color: var(--text);
  text-align: center;
  transition: border-color 0.15s;
}
.typing-input:focus {
  outline: none;
  border-color: var(--accent);
}
.typing-input:disabled {
  opacity: 0.6;
  background: var(--surface2);
}
.typing-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--red);
  text-align: center;
  min-height: 16px;
}
.typing-hint.typing-hint-answer {
  font-size: 20px;
  font-weight: 700;
  color: var(--green);
  padding: 8px 0;
  min-height: 32px;
}
.typing-submit-btn {
  padding: 16px 24px;
  min-height: 52px;
  touch-action: manipulation;
}
/* Usage desc: IdiomBuilder-style multi-input */
.usage-desc-tokens {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; margin-bottom: 12px;
}
.usage-desc-placeholder {
  display: inline-flex; align-items: center; padding: 8px 14px;
  background: var(--surface2); color: var(--accent); font-weight: 700; font-size: 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.usage-desc-input {
  width: 160px; padding: 10px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 16px; text-align: center;
  background: var(--surface); color: var(--text);
  font-family: 'JetBrains Mono', monospace;
}
.usage-desc-input:focus { border-color: var(--accent); }

/* ===== FEEDBACK ===== */
.feedback-bar {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600;
  text-align: center;
  visibility: hidden;
}

/* Answer flash overlay — stays until next question */
.quiz-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.15s ease-in;
}
.quiz-flash.flash-correct {
  background: rgba(46, 125, 50, 0.18);
  opacity: 1;
}
.quiz-flash.flash-wrong {
  background: rgba(198, 40, 40, 0.18);
  opacity: 1;
}
.feedback-bar.show { visibility: visible; }
.feedback-bar.correct-fb {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid var(--green);
}
.feedback-bar.wrong-fb {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
}
.feedback-answer {
  font-weight: 700; font-size: 18px;
  margin-top: 4px;
}

/* ===== RESULTS ===== */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  margin-bottom: 20px;
}
.result-score {
  font-family: 'Playfair Display', serif;
  font-size: 48px; font-weight: 700;
  color: var(--accent);
}
.result-score-label {
  font-size: 14px; color: var(--text-dim);
  margin-bottom: 16px;
}
.result-stats {
  display: flex; justify-content: center; gap: 24px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; color: var(--text-dim);
}
.result-stat-val {
  font-size: 20px; font-weight: 600;
  color: var(--text); display: block;
}
.dict-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.dict-modal {
  width: min(560px, 100%);
  max-height: 80vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
}
.dict-modal-close {
  float: right;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.dict-modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
}
.dict-modal-body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}
.revision-list {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 16px;
}
.revision-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: left;
}
.revision-item.is-expandable {
  cursor: pointer;
}
.revision-item.rev-correct {
  border-left: 3px solid var(--green);
}
.revision-item.rev-wrong {
  border-left: 3px solid var(--red);
}
.rev-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px;
}
.rev-word {
  font-size: 16px; font-weight: 600;
}
.rev-pos-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; color: var(--text-dimmer);
  background: var(--surface2);
  padding: 2px 6px; border-radius: 8px;
}
.rev-cefr-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; color: var(--accent);
  background: var(--accent-glow);
  padding: 2px 6px; border-radius: 8px;
}
.rev-meaning {
  font-size: 13px; color: var(--text-dim);
}
.revision-item.is-expandable .rev-meaning {
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  border: none;
  background: transparent;
  padding: 0;
  text-align: left;
  width: 100%;
}
.rev-dictionary {
  font-size: 12px;
  color: var(--text);
  margin-top: 6px;
  line-height: 1.45;
}
.rev-dictionary-line + .rev-dictionary-line {
  margin-top: 6px;
}
.rev-etymology {
  font-size: 12px;
  color: var(--text);
  margin-top: 6px;
  line-height: 1.45;
}
.rev-etymology-line + .rev-etymology-line {
  margin-top: 6px;
}
.rev-etymology-label {
  display: inline-block;
  min-width: 4.8rem;
  margin-right: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--accent);
}
/* Minimal Phrases in word detail popup */
.rev-phrases {
  margin-top: 10px;
  border-top: 1px solid var(--border, #e0e0e0);
  padding-top: 8px;
}
.rev-phrases-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
  font-family: 'JetBrains Mono', monospace;
}
.rev-phrase-row {
  display: flex;
  gap: 8px;
  line-height: 1.5;
  font-size: 12px;
}
.rev-phrase-row + .rev-phrase-row {
  margin-top: 1px;
}
.rev-phrase-en {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
}
.rev-phrase-ja {
  flex: 1;
  color: var(--sub, #666);
  font-size: 11px;
}

.rev-phrase-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
}

.rev-answer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--red);
  margin-top: 4px;
}
.rev-retry {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--accent);
  margin-top: 4px;
}

/* ===== BATCH CONTROLS (training) ===== */
.batch-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.batch-row label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; color: var(--text-dim);
}
.btn-batch {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px; cursor: pointer;
  color: var(--text);
  transition: background 0.15s;
}
.btn-batch:hover { background: var(--border); }

/* ===== FLASHCARD ===== */
.fc-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.fc-progress {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; color: var(--text-dim);
}
.fc-direction-toggle {
  display: flex; gap: 6px;
}

.fc-card-wrapper {
  perspective: 1000px;
  margin-bottom: 24px;
}
.fc-card {
  position: relative;
  width: 100%;
  min-height: 260px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}
.fc-card.flipped {
  transform: rotateY(180deg);
}
.fc-card-front,
.fc-card-back {
  position: absolute;
  width: 100%;
  min-height: 260px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
}
.fc-card-back {
  transform: rotateY(180deg);
}
.fc-text {
  font-size: 26px; font-weight: 600;
  line-height: 1.5;
  word-break: break-word;
  margin-bottom: 12px;
}
.fc-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; color: var(--text-dim);
  margin-bottom: 8px;
}
.fc-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--text-dimmer);
  margin-top: auto;
}

.fc-swipe-hints {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-top: auto;
  padding-top: 12px;
}
.fc-swipe-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-dimmer);
}
.fc-hint-left { color: var(--green); }
.fc-hint-right { color: var(--red); }

/* ===== HISTORY / CALENDAR ===== */
.calendar-nav {
  display: flex; align-items: center; justify-content: center;
  gap: 16px; margin-bottom: 16px;
}
.calendar-nav-btn {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; width: 36px; height: 36px;
  font-size: 18px; color: var(--text); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.calendar-nav-btn:hover { background: var(--surface2); border-color: var(--accent); }
.calendar-nav-title {
  font-family: 'Playfair Display', serif;
  font-size: 18px; font-weight: 700;
  color: var(--accent); min-width: 140px; text-align: center;
}
.calendar-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; margin-bottom: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--text-dimmer);
}
.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px; margin-bottom: 20px;
}
.calendar-cell {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 4px;
  min-height: 64px; cursor: default;
  transition: border-color 0.15s, background 0.15s;
  display: flex; flex-direction: column; align-items: center;
}
.calendar-cell.empty {
  background: transparent; border-color: transparent;
}
.calendar-cell.has-data {
  cursor: pointer;
}
@media (hover: hover) {
  .calendar-cell.has-data:hover {
    border-color: var(--accent); background: var(--accent-glow);
  }
}
.calendar-cell.selected {
  border-color: var(--accent); background: var(--accent-glow);
  box-shadow: 0 2px 8px var(--shadow);
}
.calendar-cell.today {
  border-color: var(--accent);
}
.cal-day {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; font-weight: 600;
  color: var(--text); margin-bottom: 4px;
}
.calendar-cell.today .cal-day { color: var(--accent); }
.cal-trained {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; color: var(--blue);
  background: var(--blue-dim); border-radius: 6px;
  padding: 1px 4px; margin-top: 1px;
  white-space: nowrap;
}
.cal-tested {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; color: var(--red);
  background: var(--red-dim); border-radius: 6px;
  padding: 1px 4px; margin-top: 1px;
  white-space: nowrap;
}
.calendar-monthly-summary {
  display: flex; justify-content: center; gap: 20px;
  padding: 10px 0; margin-bottom: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}
.cal-summary-trained {
  color: var(--blue); font-weight: 600;
}
.cal-summary-tested {
  color: var(--red); font-weight: 600;
}
.cal-summary-distinct {
  color: var(--green); font-weight: 600;
}
.calendar-detail {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.calendar-detail-title {
  font-family: 'Playfair Display', serif;
  font-size: 16px; font-weight: 700;
  color: var(--accent); margin-bottom: 12px;
}
.calendar-detail-list {
  display: flex; flex-direction: column; gap: 8px;
}
.history-loading,
.history-empty {
  text-align: center;
  color: var(--text-dimmer);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  padding: 32px 0;
}
.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.history-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--text-dimmer);
  margin-bottom: 4px;
}
.history-detail {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 6px;
}
.history-mode,
.history-grade,
.history-range,
.history-quiz {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text-dim);
}
.history-mode {
  background: var(--accent-glow);
  color: var(--accent);
}
.history-item.hist-test { border-left: 3px solid var(--red); }
.history-item.hist-training { border-left: 3px solid var(--blue); }
.history-item.hist-fc { border-left: 3px solid var(--accent); }
.history-mode.hist-test { background: var(--red-dim); color: var(--red); }
.history-mode.hist-training { background: var(--blue-dim); color: var(--blue); }
.history-mode.hist-fc { background: var(--accent-glow); color: var(--accent); }
.history-score-row {
  display: flex; align-items: center; gap: 12px;
}
.history-score {
  font-family: 'Playfair Display', serif;
  font-size: 20px; font-weight: 700;
  color: var(--accent);
}
.history-stat,
.history-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; color: var(--text-dim);
}
.history-pts {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; font-weight: 600; color: var(--accent);
}


/* ===== WORD LIST ===== */
.btn-wordlist {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; padding: 4px 10px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; color: var(--text-dim);
  white-space: nowrap; flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.btn-wordlist:hover {
  background: var(--accent-glow); border-color: var(--accent); color: var(--accent);
}
.wl-sort-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px;
}
.wl-sort-row label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; color: var(--text-dim);
}
.wl-sort-select {
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; color: var(--text);
  cursor: pointer;
}
.wl-sort-select:focus {
  outline: none; border-color: var(--accent);
}

.wordlist-items {
  display: flex; flex-direction: column; gap: 6px;
}
.wl-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.wl-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--text-dimmer);
  min-width: 36px;
}
.wl-content {
  flex: 1; min-width: 0;
}
.wl-en {
  font-size: 15px; font-weight: 600;
  white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
.wl-ja {
  font-size: 12px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
.wl-pos {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; color: var(--text-dimmer);
  min-width: 20px; text-align: center;
}
.wl-cefr {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; color: var(--accent);
  min-width: 24px; text-align: center;
}
.wl-progress {
  display: flex; align-items: center; gap: 6px;
  min-width: 80px;
}
.wl-progress-bar {
  flex: 1; height: 6px;
  background: var(--surface2);
  border-radius: 3px; overflow: hidden;
}
.wl-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}
.wl-progress-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; color: var(--text-dim);
  min-width: 28px; text-align: right;
}

/* ===== WORD REVIEW ===== */
.wr-summary {
  display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px;
}
.wr-stat {
  font-size: 12px; font-weight: 600; padding: 3px 10px;
  border-radius: 12px;
}
.wr-stat-total { background: var(--surface2); color: var(--text); }
.wr-stat-mastered { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.wr-stat-progress { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.wr-stat-new { background: var(--surface2); color: var(--text-dim); }
.wr-controls {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.wr-cards {
  display: flex; flex-direction: column; gap: 8px;
}
.wr-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}
@media (hover: hover) { .wr-card:hover { border-color: var(--accent); } }
.wr-card-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap;
}
.wr-card-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--text-dimmer); min-width: 32px;
}
.wr-card-pos {
  font-size: 11px; color: var(--text-dim);
  background: var(--surface2); padding: 1px 6px; border-radius: 4px;
}
.wr-card-cefr {
  font-size: 11px; color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
}
.wr-card-progress {
  margin-left: auto; display: flex; align-items: center; gap: 6px; min-width: 70px; flex: 1 1 120px;
}
.wr-card-progress-bar {
  flex: 1; height: 5px; background: var(--surface2);
  border-radius: 3px; overflow: hidden;
}
.wr-card-progress-fill {
  height: 100%; border-radius: 3px; transition: width 0.3s;
}
.wr-card-progress-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; color: var(--text-dim); min-width: 28px; text-align: right;
}
.wr-card-en {
  font-size: 17px; font-weight: 700; margin-bottom: 4px;
}
.wr-card-ja {
  font-size: 13px; color: var(--text-dim); line-height: 1.5;
  transition: opacity 0.2s;
}
.wr-card-ja.wr-hidden {
  opacity: 0; user-select: none; pointer-events: none;
}
.wr-card-usage {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
}
.wr-usage-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  line-height: 1.6;
}
.wr-usage-pattern {
  color: var(--accent);
  font-weight: 500;
  white-space: nowrap;
}
.wr-usage-ja {
  color: var(--text-dim);
  text-align: right;
  flex-shrink: 1;
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed; top: 16px; right: 16px;
  z-index: 9999; display: flex;
  flex-direction: column; gap: 8px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 13px;
  box-shadow: 0 4px 12px var(--shadow);
  animation: toastIn 0.2s ease;
  max-width: 360px;
}
.toast.error { border-color: var(--red); color: var(--red); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== SESSION EXPIRED ===== */
#session-expired-overlay {
  position: fixed; inset: 0;
  background: rgba(180, 30, 30, 0.85);
  z-index: 99999;
  display: flex; align-items: center; justify-content: center;
  animation: sessionExpiredIn 0.3s ease;
}
@keyframes sessionExpiredIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.session-expired-box {
  background: #fff; border-radius: 16px;
  padding: 40px 32px; text-align: center;
  max-width: 320px; width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.session-expired-icon { font-size: 48px; margin-bottom: 12px; }
.session-expired-title {
  font-size: 22px; font-weight: 700;
  color: #b41e1e; margin-bottom: 8px;
}
.session-expired-msg {
  font-size: 14px; color: #555;
  line-height: 1.6; margin-bottom: 24px;
}
.session-expired-btn {
  background: #b41e1e !important;
  border-color: #b41e1e !important;
  font-size: 16px; padding: 12px 32px;
}

/* ===== LOADING ===== */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.3);
  display: none; align-items: center;
  justify-content: center; z-index: 9998;
}
.loading-overlay.show { display: flex; }
.loading-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 40px;
  text-align: center;
  box-shadow: 0 8px 32px var(--shadow);
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; color: var(--text-dim);
}

/* ===== SCREEN NAV (unified BACK + TOP) ===== */
.screen-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.screen-nav .btn-back { margin-bottom: 0; }
.screen-nav .btn-back-group { display: flex; align-items: center; gap: 12px; }
.site-top-link {
  font-size: 12px; color: var(--text-dimmer);
  text-decoration: none; font-family: 'JetBrains Mono', monospace;
  white-space: nowrap; transition: color 0.15s;
}
.site-top-link:hover { color: var(--accent); }

/* ===== BACK BUTTON ===== */
.btn-back {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none;
  color: var(--text-dim);
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer; padding: 4px 0;
  margin-bottom: 16px;
  transition: color 0.15s;
}
.btn-back:hover { color: var(--accent); }
.btn-back svg { width: 16px; height: 16px; }

/* ===== おすすめ PANEL ===== */
.recommend-preview { margin-top: 12px; }
.recommend-summary { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.recommend-list { max-height: 300px; overflow-y: auto; }
.recommend-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.recommend-item-id {
  color: var(--text-dimmer); font-family: 'JetBrains Mono', monospace;
  font-size: 12px; min-width: 35px;
}
.recommend-item-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recommend-item-pct {
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  color: var(--text-dimmer); min-width: 35px; text-align: right;
}
.recommend-more { font-size: 12px; color: var(--text-dimmer); padding: 6px 0; text-align: center; }
.recommend-book-select { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }

/* ===== MY LIST PANEL ===== */
.mylist-header { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.btn-mylist-new {
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 8px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.mylist-card {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
  margin-bottom: 8px; transition: all 0.15s;
}
.mylist-info { flex: 1; cursor: pointer; }
.mylist-info:hover { color: var(--accent); }
.mylist-name { font-weight: 600; font-size: 15px; }
.mylist-meta { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.mylist-delete {
  background: none; border: none; cursor: pointer;
  font-size: 20px; color: var(--text-dimmer); padding: 4px 8px;
}
.mylist-delete:hover { color: var(--red); }

/* ===== WEAK RATIO SLIDER ===== */
.setup-card-inline {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
}
.weak-slider-row { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.weak-label { font-size: 14px; font-weight: 600; color: var(--accent); }
.weak-slider {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 6px; background: var(--surface2); border-radius: 3px; outline: none;
}
.weak-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  border: 2px solid var(--surface); box-shadow: 0 1px 4px var(--shadow);
}
.weak-slider::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  border: 2px solid var(--surface);
}
.weak-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px; font-weight: 600; min-width: 40px; color: var(--accent);
}

/* ===== BOOKMARK BUTTONS ===== */
.bookmark-btn-wrap { display: inline-flex; align-items: center; }
.bookmark-btn {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--text-dimmer); padding: 2px 6px;
  transition: color 0.15s;
}
.bookmark-btn:hover { color: var(--accent); }
.bookmark-btn.bookmarked { color: var(--accent); }

/* List dropdown */
.list-dropdown {
  position: absolute; right: 0; top: 100%; z-index: 50;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: 0 4px 16px var(--shadow);
  min-width: 180px; overflow: hidden;
}
.list-dropdown-item {
  padding: 10px 14px; font-size: 14px; cursor: pointer;
  border-bottom: 1px solid var(--border); transition: background 0.1s;
}
.list-dropdown-item:last-child { border-bottom: none; }
.list-dropdown-item:hover { background: var(--surface2); }
.list-dropdown-item.in-list { color: var(--accent); font-weight: 600; }
.list-dropdown-new { color: var(--accent); font-weight: 600; }

/* MyList hint in results */
.mylist-hint { font-size: 11px; color: var(--accent); margin-top: 2px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 520px) {
  .screen-content { padding: 16px 12px 60px; }
  .mode-cards { grid-template-columns: 1fr 1fr; }
  .quiz-type-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .question-text { font-size: 18px; }
  .login-card { margin: 40px 16px; padding: 32px 20px; }
  .result-stats { gap: 16px; }
  .fc-text { font-size: 22px; }
  .calendar-grid { gap: 2px; }
  .calendar-cell { min-height: 52px; padding: 4px 2px; }
  .cal-day { font-size: 11px; }
  .cal-trained, .cal-tested { font-size: 8px; padding: 1px 3px; }
  .calendar-nav-title { font-size: 16px; min-width: 120px; }
  .fc-card-front,
  .fc-card-back { min-height: 220px; padding: 24px 16px; }
  .wl-progress { min-width: 60px; }

  .screen-quiz-fullscreen { padding: 8px 8px env(safe-area-inset-bottom, 8px); }
  .question-card { padding: 10px 12px; }
  .question-text { font-size: 17px; }
  .question-sub { font-size: 11px; margin-top: 2px; }
  .choices-grid { gap: 4px; }
  .choices-grid-6 { gap: 4px; }
  .choices-grid-skell { gap: 6px; grid-template-rows: 50px 50px 50px; width: 100%; }
  .choices-grid-skell .choice-btn { font-size: 20px; height: 50px; }
  .choice-btn { padding: 4px 6px; font-size: 18px; border-width: 1.5px; }
  .feedback-bar { padding: 6px 12px; font-size: 14px; min-height: 38px; }
  .colloc-items { font-size: 14px; }
  .skell-hint-words { font-size: 17px; }
  .quiz-question-area.skell-expanded { flex: 1 1 0; }
  .quiz-question-area.skell-expanded ~ .quiz-answer-area { padding-bottom: 0; }
}

/* Tablet landscape */
@media (min-width: 521px) and (max-width: 1024px) and (orientation: landscape) {
  .screen-quiz-fullscreen { padding: 12px 24px env(safe-area-inset-bottom, 12px); }
  .choices-grid { gap: 8px; }
  .choices-grid-6 { gap: 8px; }
  .choice-btn { padding: 8px 10px; font-size: 20px; }
}

/* Phone landscape — compact quiz-setup & quiz screen */
@media (max-height: 500px) and (orientation: landscape) {
  #screen-quiz-setup > .screen-content {
    padding: 6px 20px 6px;
    gap: 0;
  }
  #screen-quiz-setup .btn-back {
    padding: 2px 6px; font-size: 12px;
    display: inline-flex; margin-right: 8px;
  }
  #screen-quiz-setup .section-heading { font-size: 14px; margin-bottom: 0; }
  #screen-quiz-setup .section-sub { font-size: 11px; margin-bottom: 2px; }
  .setup-mode-banner { padding: 8px 10px; margin: 4px 0; }
  .setup-mode-title { font-size: 14px; }
  .setup-mode-sub { font-size: 10px; }
  .setup-top-cluster { padding: 8px 10px; margin-bottom: 6px; gap: 6px; }
  .quiz-type-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-bottom: 4px;
  }
  .quiz-type-btn { padding: 5px 4px; }
  .quiz-type-btn .qt-label { font-size: 11px; margin-bottom: 0; }
  .quiz-type-btn .qt-desc { display: none; }
  .setup-range-bar { padding: 4px 10px; margin-bottom: 4px; font-size: 11px; }
  .setup-range-bar .range-input { width: 50px; height: 26px; font-size: 12px; }
  .pos-filter-row { margin-bottom: 4px; }
  .chip { padding: 3px 8px; font-size: 10px; }
  #screen-quiz-setup .btn-primary {
    margin-top: 4px; padding: 8px 16px; font-size: 14px;
  }
  .setup-card-inline { margin-top: 4px !important; padding: 6px 10px; }
  .weak-slider-row { gap: 4px; }
  #training-batch-row .batch-row { gap: 4px; }
  #screen-quiz-setup .section-heading[style*="font-size:16px"] {
    font-size: 12px !important; margin-top: 4px !important;
  }

  /* Quiz play screen in phone landscape */
  .screen-quiz-fullscreen { padding: 4px 12px env(safe-area-inset-bottom, 4px); }
  .quiz-question-area { flex: 0 0 auto; padding-bottom: 2px; }
  .question-card { padding: 4px 10px; }
  .question-text { font-size: 16px; }
  .question-sub { font-size: 10px; margin-top: 1px; }
  .quiz-header { margin-bottom: 2px; }
  .choices-grid { gap: 3px; }
  .choices-grid-6 { gap: 3px; }
  .usage8-verb-grid { gap: 3px; }
  .usage8-prep-grid { gap: 3px; }
  .usage8-prep-grid .choice-btn { font-size: 13px; }
  .choice-btn { padding: 2px 6px; font-size: 15px; border-width: 1.5px; min-height: 0; }
  .feedback-bar { padding: 3px 10px; font-size: 13px; min-height: 28px; }
  .listen-again-btn { padding: 6px 16px; font-size: 16px; }
  .listen-start-btn { padding: 10px 24px; font-size: 18px; }
  .speak-orb-wrap { width: 60px; height: 60px; margin: 4px auto; }
}

/* Portrait (phone + tablet): 1-column stacked choices */
@media (orientation: portrait) {
  .choices-grid {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(8, 1fr);
    gap: 3px;
  }
  .choices-grid-6 {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(6, 1fr);
    gap: 3px;
  }
  .choice-btn {
    padding: 2px 12px;
    font-size: 17px;
    text-align: center;
    justify-content: center;
  }
  .choices-grid-skell {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 48px 48px 48px;
    gap: 6px;
    width: 100%;
  }
  .choices-grid-skell .choice-btn {
    font-size: 19px;
    height: 48px;
  }
  /* Usage8 portrait: keep 2-col verb, 4-col prep */
  .usage8-verb-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(4, 1fr);
    gap: 3px;
  }
  .usage8-prep-grid {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 3px;
  }
  .usage8-prep-grid .choice-btn { font-size: 14px; }
  .quiz-question-area { flex: 0 0 15%; }
  .quiz-question-area.skell-expanded { flex: 1 1 0; }
  .quiz-question-area.skell-expanded ~ .quiz-answer-area { padding-bottom: 0; }
  .quiz-answer-area { padding-bottom: 8vh; }
}

/* ===== TEACHER STYLES ===== */

.mode-card-accent { border-left: 3px solid var(--accent); }
.mode-card-teacher { border-left: 3px solid #6366f1; }

/* Teacher class selector */
.teacher-class-select {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
  flex-wrap: wrap;
}
.teacher-class-select label { font-size: 14px; color: var(--text-dim); }
.teacher-class-select select {
  padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 14px;
}

/* Teacher tabs */
.teacher-tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.teacher-tab {
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-dim); cursor: pointer;
  font-size: 13px; transition: all .15s;
}
.teacher-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Quiz table */
.tq-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tq-table th { text-align: left; padding: 6px 8px; border-bottom: 2px solid var(--border); color: var(--text-dim); font-size: 12px; }
.tq-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.tq-title-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tq-actions { display: flex; gap: 4px; }

.tq-toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.tq-section-label { font-weight: 600; font-size: 14px; margin: 12px 0 6px; color: var(--text); }

/* Lock badges */
.lock-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.5px;
}
.lock-off { background: var(--surface2); color: var(--text-dim); }
.lock-main { background: #dcfce7; color: #166534; }
.lock-retry { background: #fef3c7; color: #92400e; }

/* Small/tiny buttons */
.btn-small { padding: 4px 12px; font-size: 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text); }
.btn-small:hover { background: var(--surface2); }
.btn-tiny { padding: 2px 8px; font-size: 11px; border-radius: 4px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text); }
.btn-tiny:hover { background: var(--surface2); }
.btn-danger-tiny { color: #dc2626; border-color: #fca5a5; }
.btn-danger-tiny:hover { background: #fee2e2; }

/* Quiz create form */
.tq-form { max-width: 500px; }
.tq-row { margin-bottom: 10px; }
.tq-row label { font-size: 13px; color: var(--text-dim); display: block; margin-bottom: 3px; }
.tq-row select, .tq-row input[type="number"] {
  padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 14px; width: 100%;
}
.tq-row input[type="checkbox"] { margin-right: 6px; }
.tq-row-inline {
  display: flex; align-items: center; gap: 6px; margin-bottom: 10px; flex-wrap: wrap;
}
.tq-row-inline label { font-size: 13px; color: var(--text-dim); }
.tq-row-inline input[type="number"] {
  width: 70px; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 14px;
}
.tq-row-inline span { color: var(--text-dim); }
.tq-section { font-weight: 600; font-size: 13px; margin: 14px 0 6px; color: var(--text); }
.tq-divider { border-top: 1px dashed var(--border); margin: 20px 0; }

/* Monitor screen */
.monitor-summary {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; font-size: 13px;
}
.ms-done { color: #166534; font-weight: 600; }
.ms-active { color: #1e40af; }
.ms-wait { color: var(--text-dim); }
.ms-absent { color: #991b1b; }

.monitor-controls { margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.monitor-footer { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.monitor-auto-refresh { font-size: 12px; color: var(--text-dim); }

.monitor-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.monitor-table th { text-align: left; padding: 6px 8px; border-bottom: 2px solid var(--border); color: var(--text-dim); font-size: 12px; }
.monitor-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.monitor-table tr.st-done { }
.monitor-table tr.st-active { background: #eff6ff; }
.monitor-table tr.st-wait { }
.monitor-table tr.st-absent { opacity: 0.5; }

/* Student quiz list */
.my-quizzes-list { display: flex; flex-direction: column; gap: 8px; }
.mq-item {
  padding: 12px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); cursor: default; transition: all .15s;
}
.mq-item.mq-open, .mq-item.mq-retake { cursor: pointer; }
.mq-item.mq-open:hover, .mq-item.mq-retake:hover { background: var(--surface2); }
.mq-item.mq-locked { opacity: 0.4; pointer-events: none; }
.mq-item.mq-done { border-left: 3px solid #22c55e; }
.mq-item.mq-open { border-left: 3px solid var(--accent); }
.mq-item.mq-retake { border-left: 3px solid #f59e0b; }
.mq-item.mq-absent { border-left: 3px solid #ef4444; opacity: 0.6; }

.mq-item-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.mq-item-info { font-size: 12px; color: var(--text-dim); }
.mq-item-status { font-size: 13px; margin-top: 4px; font-weight: 500; }

/* Teacher: clickable student rows */
.tr-clickable { cursor: pointer; }
.tr-clickable:hover { background: var(--accent-glow, rgba(0,120,212,0.06)); }

/* ===== SUPER SEARCH ===== */
.ss-section {
  margin: 20px 0; padding: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.ss-section-label {
  font-size: 16px; font-weight: 700; color: var(--accent); margin-bottom: 10px;
}
.ss-section-hint {
  font-size: 12px; font-weight: 400; color: var(--text-dim); margin-left: 8px;
}
.ss-cat-label {
  font-size: 12px; font-weight: 600; color: var(--text-dim);
  margin: 10px 0 4px; text-transform: uppercase; letter-spacing: 0.5px;
}
.ss-cat-label:first-child { margin-top: 0; }
.ss-cat-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ss-chip { font-size: 12px; padding: 5px 12px; }
.ss-text-input { width: 100%; padding: 10px 12px; font-size: 15px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); box-sizing: border-box; }
.ss-text-input:focus { outline: none; border-color: var(--accent); }
.ss-cascade-row { display: flex; gap: 6px; flex-wrap: wrap; }
.ss-cascade-select { flex: 1; min-width: 100px; padding: 8px; font-size: 13px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.ss-cascade-select:disabled { opacity: 0.5; }
.ss-cascade-select:focus { outline: none; border-color: var(--accent); }

.ss-results-summary {
  font-size: 15px; font-weight: 600; color: var(--accent);
  margin: 20px 0 12px; padding: 12px 16px;
  background: var(--accent-glow); border-radius: var(--radius-sm);
}
.ss-results-actions {
  display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap;
}
.ss-btn-sm { font-size: 12px; padding: 6px 14px; }
.ss-results-list {
  max-height: 60vh; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.ss-result-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  cursor: pointer; font-size: 13px; transition: background 0.1s;
}
.ss-result-item:hover { background: var(--surface2); }
.ss-result-item:last-child { border-bottom: none; }
.ss-result-item input[type="checkbox"] {
  width: 16px; height: 16px; flex-shrink: 0; accent-color: var(--accent);
}
.ss-word-lemma {
  font-weight: 600; color: var(--text); min-width: 100px;
  font-family: 'DM Sans', sans-serif;
}
.ss-word-pos {
  font-size: 11px; color: var(--text-dimmer); min-width: 24px;
  font-family: 'JetBrains Mono', monospace;
}
.ss-word-cefr {
  font-size: 10px; color: #fff; background: var(--accent); border-radius: 3px;
  padding: 1px 5px; font-weight: 600; min-width: 22px; text-align: center;
}
.ss-cefr-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ss-word-meaning {
  color: var(--text-dim); flex: 1; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis;
}

/* Super Search: list picker */
.ss-picker-count {
  font-size: 13px; color: var(--text-dim); margin-bottom: 12px;
}
.ss-picker-btn {
  display: block; width: 100%; text-align: left;
  padding: 10px 14px; margin-bottom: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  font-size: 14px; color: var(--text); transition: all 0.15s;
}
.ss-picker-btn:hover { border-color: var(--accent); background: var(--surface2); }
.ss-picker-new { color: var(--accent); font-weight: 600; }
