/* ===== THEMES (shared with VocBuilder) ===== */
: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="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 { outline: none !important; box-shadow: none !important; }
* { -webkit-tap-highlight-color: transparent; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Source Serif 4', Georgia, serif;
  min-height: 100dvh;
  transition: background 0.2s, color 0.2s;
}

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

/* ===== 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);
  cursor: pointer; font-size: 15px; color: var(--text);
  transition: background 0.15s;
}
.ms-login-btn:hover { background: var(--surface2); }
.ms-login-btn svg { width: 20px; height: 20px; }

/* ===== MODE SELECT ===== */
.section-heading {
  font-family: 'Playfair Display', serif;
  font-size: 22px; font-weight: 700;
  color: var(--accent); margin-bottom: 4px;
}
.section-sub { color: var(--text-dim); font-size: 14px; margin-bottom: 16px; }

.mode-cards {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-bottom: 8px;
}
.mode-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 16px;
  cursor: pointer; text-align: center; transition: all 0.15s;
}
.mode-card:hover { border-color: var(--accent); background: var(--accent-glow); }
.mode-card-icon { font-size: 32px; margin-bottom: 8px; }
.mode-card-title { font-weight: 600; font-size: 16px; margin-bottom: 4px; }
.mode-card-desc { color: var(--text-dim); font-size: 13px; }
.mode-card-test { border-left: 5px solid #c62828; }
.mode-card-training { border-left: 5px solid #1565c0; }

/* ===== SOURCE SELECT TABS ===== */
.source-tabs {
  display: flex; gap: 0; margin-bottom: 16px;
  background: var(--surface2); border-radius: var(--radius-sm);
  padding: 3px; border: 1px solid var(--border);
}
.source-tab {
  flex: 1; padding: 10px 8px;
  background: transparent; border: none; border-radius: 6px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  color: var(--text-dim); transition: all 0.15s;
}
.source-tab.active {
  background: var(--surface); color: var(--accent);
  box-shadow: 0 1px 3px var(--shadow);
}
.source-panel { display: none; }
.source-panel.active { display: block; }

/* ===== CHAPTER / FOCUS LIST ===== */
.chapter-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
/* ===== SCREEN NAV (unified BACK + TOP) ===== */
.screen-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.screen-nav .chapter-header { margin-bottom: 0; flex: 1; }
.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); }

.btn-back {
  background: none; border: none; cursor: pointer;
  font-size: 20px; color: var(--accent); padding: 4px;
}
.chapter-card, .focus-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
  margin-bottom: 8px; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  transition: all 0.15s;
}
@media (hover: hover) {
  .chapter-card:hover, .focus-card:hover { border-color: var(--accent); background: var(--accent-glow); }
}
.chapter-info, .focus-info { flex: 1; min-width: 0; }
.chapter-name, .focus-name { font-weight: 600; font-size: 15px; }
.chapter-meta, .focus-meta { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.focus-name { font-size: 14px; }
.chapter-progress { width: 80px; text-align: right; flex-shrink: 0; }
.progress-bar {
  height: 6px; background: var(--surface2); border-radius: 3px;
  overflow: hidden; margin-bottom: 4px;
}
.progress-fill {
  height: 100%; background: var(--green);
  border-radius: 3px; transition: width 0.3s;
}
.progress-label { font-size: 12px; color: var(--text-dimmer); }

/* Focus chapter grouping header */
.focus-chapter-header {
  font-weight: 700; font-size: 14px; color: var(--accent);
  margin: 16px 0 8px; padding-bottom: 4px;
  border-bottom: 2px solid var(--accent-glow);
}
.focus-chapter-header:first-child { margin-top: 0; }

/* Focus range bar */
.focus-range-bar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px; padding: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); flex-wrap: wrap;
}
.btn-focus-go {
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 8px 18px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}

/* Source start bar (bottom of chapter/focus panels) */
.source-start-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; margin-top: 12px;
  background: var(--surface); border: 2px solid var(--accent);
  border-radius: var(--radius); position: sticky; bottom: 0;
}
.source-sel-count { font-size: 14px; font-weight: 600; color: var(--accent); }
.btn-source-start {
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 10px 24px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.chapter-card.selected, .focus-card.selected {
  border-color: var(--accent); background: var(--accent-glow);
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* ===== QUIZ SETUP ===== */
.setup-mode-banner {
  display: flex; align-items: flex-start; gap: 6px;
  width: 100%;
  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-dimmer); }
.setup-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px;
}
.setup-title {
  font-weight: 700; font-size: 16px; margin-bottom: 10px;
  color: var(--accent);
}
.setup-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.setup-row:last-child { margin-bottom: 0; }
.setup-label { font-size: 14px; font-weight: 600; min-width: 36px; }
.setup-input {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px;
  font-size: 14px; color: var(--text); width: 80px;
  font-family: 'JetBrains Mono', monospace;
}
.radio-group { display: flex; flex-wrap: wrap; gap: 8px; }
.radio-label {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 14px;
  cursor: pointer; font-size: 14px; transition: all 0.15s;
}
.radio-label:has(input:checked) {
  background: var(--accent-glow); border-color: var(--accent); color: var(--accent);
}
.radio-label input { display: none; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 6px; }
.checkbox-label {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 10px;
  cursor: pointer; font-size: 13px; transition: all 0.15s;
}
.checkbox-label:has(input:checked) {
  background: var(--accent-glow); border-color: var(--accent);
}
.checkbox-label input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--accent); }
.setup-hint { font-size: 12px; color: var(--text-dimmer); }

.btn-primary {
  display: block; width: 100%;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 14px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-secondary {
  display: block; width: 100%;
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
  font-size: 16px; cursor: pointer; margin-top: 8px;
}
.setup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.setup-actions .btn-secondary,
.setup-actions .btn-primary {
  margin-top: 0;
}

/* ===== QUIZ SCREEN ===== */
.quiz-screen.active {
  display: flex; flex-direction: column;
  position: fixed; inset: 0;
  height: 100dvh; background: var(--bg);
  z-index: 100;
}
.quiz-header {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
}
.quiz-header-left { display: flex; align-items: center; gap: 10px; }
.btn-quit {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--text-dim); padding: 4px;
}
#quiz-progress { font-size: 14px; color: var(--text-dim); font-family: 'JetBrains Mono', monospace; }
.mode-badge {
  font-size: 11px; font-weight: 700; padding: 3px 8px;
  border-radius: 4px; text-transform: uppercase;
}
.mode-training { background: var(--blue-dim); color: var(--blue); }
.mode-test { background: var(--red-dim); color: var(--red); }

/* Timer: bar shrinks from left (right-aligned, width decreases) */
.timer-container {
  flex-shrink: 0; height: 4px; background: var(--surface2);
  display: flex; justify-content: flex-end;
}
.timer-fill {
  height: 100%; transition: width 1s linear;
}
.timer-green { background: var(--green); }
.timer-yellow { background: #f9a825; }
.timer-red { background: var(--red); }

.quiz-body {
  flex: 1; overflow-y: auto;
  padding: 16px; display: flex; flex-direction: column;
  max-width: 680px; margin: 0 auto; width: 100%;
}
#quiz-area { flex: 1; }
#timer-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; color: var(--text-dimmer);
}

/* ===== QUIZ CONTENT ===== */
.quiz-focus {
  font-size: 15px; font-weight: 600; color: var(--blue);
  background: var(--blue-dim); display: inline-block;
  padding: 4px 12px; border-radius: 4px; margin-bottom: 8px;
}
.quiz-ja {
  font-size: 17px; line-height: 1.6; margin-bottom: 12px;
  color: var(--text);
}
.quiz-notes {
  font-size: 13px; color: var(--text-dimmer); margin-bottom: 8px;
  font-style: italic;
}
.en-alt-note {
  color: var(--red); font-style: normal; font-weight: 600;
}
.quiz-grammar {
  font-size: 13px; color: var(--accent); margin-bottom: 16px;
  padding: 6px 10px; background: var(--accent-glow);
  border-radius: var(--radius-sm);
}
.quiz-sentence {
  font-size: 18px; line-height: 1.7; margin-bottom: 16px;
  font-family: 'Source Serif 4', Georgia, serif;
}
.keypart-sentence { letter-spacing: 0.5px; }
.keypart-multi { line-height: 2.4; }
.keypart-static { white-space: pre-wrap; }
.keypart-inline-input {
  display: inline-block; vertical-align: baseline;
  background: var(--surface); border: 2px solid var(--border);
  border-radius: 6px; padding: 4px 8px;
  font-size: 16px; color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  text-align: center; width: 3ch; min-width: 3ch;
}
.keypart-inline-input:focus { border-color: var(--accent); }
.keypart-inline-input::placeholder { color: var(--text-dimmer); }

.quiz-input {
  width: 100%; background: var(--surface);
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 16px; font-size: 16px; color: var(--text);
  font-family: 'JetBrains Mono', monospace;
}
.quiz-input:focus { border-color: var(--accent); }
.complete-input-wide { font-size: 15px; }

.input-area {
  display: flex; gap: 8px; align-items: stretch; margin-top: 12px;
}
.input-area .quiz-input { flex: 1; }
.btn-submit {
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 12px 24px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: opacity 0.15s;
}
.btn-submit:hover { opacity: 0.9; }
.btn-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* Pen-input delete buttons */
.input-pen-btns {
  display: flex; gap: 4px; flex-direction: column;
}
.btn-pen {
  background: var(--surface2); color: var(--text-dim); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px 10px;
  font-size: 16px; cursor: pointer; line-height: 1;
  transition: background 0.15s;
}
.btn-pen:hover { background: var(--border); }
.btn-pen-clear { font-size: 12px; font-weight: 700; }

/* ===== COMPLETE HINT =====
   Per-character slot UI. Requires a monospace font so that every slot is
   exactly 1ch wide and the underlines line up to form a continuous guide. */
.complete-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px; line-height: 1.8; margin-bottom: 12px;
  letter-spacing: 0; word-spacing: 0;
  color: var(--text-dim);
}
.hint-word { display: inline-block; margin-right: 6px; }
/* Letter slots: fixed 1ch width + bottom border. The border stays visible
   regardless of whether the learner has typed in the slot, so the
   character-count guide never disappears and never jitters in width. */
.char-correct, .char-wrong, .char-typed, .char-dash {
  display: inline-block;
  width: 1ch;
  text-align: center;
  border-bottom: 2px solid var(--text-dimmer);
  margin: 0;
  padding: 0;
  vertical-align: baseline;
}
.char-correct { color: var(--green); }
.char-wrong { color: var(--red); background: var(--red-dim); }
.char-typed { color: var(--text); }
.char-prefill { color: var(--text-dimmer); }
.char-dash { color: var(--text-dimmer); }
/* Word boundary: a 1ch gap with no border, so the underline breaks
   cleanly between words and a typed space never looks like a hyphen. */
.char-space {
  display: inline-block;
  width: 1ch;
  vertical-align: baseline;
}

.complete-error .quiz-input { border-color: var(--red); background: var(--red-dim); }

/* ===== REORDER ===== */
.reorder-sentence {
  font-size: 17px; line-height: 2.4;
  padding: 12px; margin-bottom: 16px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius);
  word-spacing: 2px;
}
.reorder-static { color: var(--text); }
.reorder-punct { color: var(--text); }
.reorder-slot {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 60px; min-height: 34px;
  background: var(--surface); border: 1px dashed var(--border2);
  border-radius: var(--radius-sm);
  vertical-align: middle; margin: 2px 0;
  transition: border-color 0.15s;
}
.reorder-slot:empty { border-style: dashed; }
.reorder-slot:not(:empty) { border-style: solid; border-color: var(--accent); }
.reorder-tiles {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 16px; justify-content: center;
}
.reorder-tile {
  background: var(--accent-glow); border: 1px solid var(--accent);
  color: var(--accent); border-radius: var(--radius-sm);
  padding: 10px 16px; font-size: 15px; font-weight: 600;
  cursor: grab; user-select: none;
  transition: all 0.15s; min-width: 50px; text-align: center;
}
.reorder-tile:active { cursor: grabbing; opacity: 0.7; }
.reorder-tile.selected { background: var(--accent); color: #fff; }
.reorder-tile.placed {
  background: transparent; border-color: transparent;
  color: var(--accent); cursor: pointer;
  padding: 4px 8px; font-size: 16px; min-width: auto;
}

/* ===== FEEDBACK ===== */
.feedback {
  text-align: center; padding: 20px; margin-bottom: 16px;
  border-radius: var(--radius);
}
.feedback-correct { background: var(--green-dim); }
.feedback-wrong { background: var(--red-dim); }
.feedback-icon { font-size: 40px; margin-bottom: 8px; }
.feedback-label { font-size: 20px; font-weight: 700; }
.feedback-correct .feedback-label { color: var(--green); }
.feedback-wrong .feedback-label { color: var(--red); }

.feedback-detail { margin-bottom: 16px; }
.feedback-answer { margin-top: 12px; }
.answer-label { font-size: 12px; color: var(--text-dimmer); text-transform: uppercase; margin-bottom: 4px; }
.answer-text {
  font-size: 16px; padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
}
.correct-text { background: var(--green-dim); color: var(--green); }
.wrong-text { background: var(--red-dim); color: var(--red); }

.feedback-actions { text-align: center; }
.btn-next {
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 14px 48px;
  font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn-next:hover { opacity: 0.9; }

/* ===== RESULTS ===== */
.results-header { text-align: center; margin-bottom: 24px; }
.results-score {
  font-family: 'Playfair Display', serif;
  font-size: 64px; font-weight: 700; color: var(--accent);
}
.results-detail { font-size: 16px; color: var(--text-dim); }
.results-breakdown {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 24px;
}
.results-row {
  display: flex; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.results-row:last-child { border-bottom: none; }
.results-actions { display: flex; flex-direction: column; gap: 8px; }

/* ===== HISTORY ===== */
.history-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 8px;
}
.history-date { font-size: 13px; color: var(--text-dimmer); margin-bottom: 4px; }
.history-info { display: flex; align-items: center; gap: 8px; font-size: 14px; }

/* ===== SENTENCE LIST ===== */
.sentlist-search-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px;
}
.sentlist-search-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.sentlist-search-input { width: 100%; }
.sentlist-search-meta { margin-top: 8px; font-size: 12px; color: var(--text-dim); }
.sentlist-chapter { margin-bottom: 24px; }
.sentlist-chapter-title {
  font-weight: 700; font-size: 16px; color: var(--accent);
  margin-bottom: 10px; padding-bottom: 6px;
  border-bottom: 2px solid var(--accent-glow);
}
.sentlist-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; margin-bottom: 10px;
  border: 1px solid var(--border2); border-radius: 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 95%, white 5%), var(--surface));
  box-shadow: 0 6px 16px var(--shadow);
  font-size: 13px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.sentlist-item:hover {
  border-color: var(--accent); background: color-mix(in srgb, var(--accent-glow) 55%, var(--surface));
  transform: translateY(-1px);
}
.sentlist-item.expanded {
  border-color: var(--accent);
  box-shadow: 0 10px 24px var(--shadow);
}
.sentlist-id { color: var(--text-dimmer); min-width: 35px; font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.sentlist-content { flex: 1; min-width: 0; }
.sentlist-en { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; font-weight: 700; line-height: 1.5; }
.sentlist-ja { color: var(--text-dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; }
.sentlist-focus { color: var(--accent); font-size: 11px; font-family: 'JetBrains Mono', monospace; margin-top: 6px; }
.sentlist-item.expanded .sentlist-en,
.sentlist-item.expanded .sentlist-ja {
  white-space: normal; overflow: visible; text-overflow: clip;
}
.sentlist-mastery {
  min-width: 60px; display: flex; align-items: center; gap: 4px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
}
.mini-bar {
  height: 4px; border-radius: 2px; transition: width 0.3s;
}
.mastery-high { background: var(--green); }
.mastery-mid { background: #f9a825; }
.mastery-low { background: var(--red); }

/* ===== SENTENCE EDIT (pa_admin) ===== */
.sentlist-edit-btn {
  background: none; border: 1px solid var(--border); border-radius: 4px;
  color: var(--text-dim); cursor: pointer; font-size: 14px;
  padding: 2px 6px; flex-shrink: 0; transition: all 0.15s;
}
.sentlist-edit-btn:hover { border-color: var(--accent); color: var(--accent); }
.se-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.5); display: flex;
  align-items: center; justify-content: center; padding: 16px;
}
.se-modal {
  background: var(--bg); border-radius: var(--radius);
  width: 100%; max-width: 520px; max-height: 90vh;
  display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.se-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.se-title { font-weight: 700; font-size: 16px; color: var(--accent); }
.se-close {
  background: none; border: none; font-size: 24px;
  color: var(--text-dim); cursor: pointer; padding: 0 4px;
}
.se-close:hover { color: var(--text); }
.se-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.se-field { margin-bottom: 12px; }
.se-label {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--text-dim); margin-bottom: 4px; text-transform: uppercase;
  letter-spacing: 0.5px;
}
.se-input {
  width: 100%; padding: 8px 10px; font-size: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: inherit; box-sizing: border-box;
}
.se-input:focus { border-color: var(--accent); outline: none; }
textarea.se-input { resize: vertical; min-height: 40px; }
.se-footer {
  display: flex; gap: 8px; padding: 12px 20px;
  border-top: 1px solid var(--border); justify-content: flex-end;
}
.se-btn-save {
  padding: 8px 20px; background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  font-weight: 600; font-size: 13px;
}
.se-btn-save:hover { opacity: 0.9; }
.se-btn-cancel {
  padding: 8px 16px; background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px;
}
.se-btn-cancel:hover { border-color: var(--text-dim); }

/* ===== LOADING & TOAST ===== */
.loading-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.4); display: flex;
  align-items: center; justify-content: center;
}
.loading-box {
  background: var(--surface); border-radius: var(--radius);
  padding: 24px 32px; text-align: center;
  box-shadow: 0 4px 24px var(--shadow);
}
.loading-text, .empty-text, .error-text {
  text-align: center; padding: 24px; color: var(--text-dim); font-size: 14px;
}
.error-text { color: var(--red); }

.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%); z-index: 300;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 24px;
  font-size: 14px; box-shadow: 0 4px 16px var(--shadow);
  animation: toast-in 0.3s ease;
}
.toast-success { border-color: var(--green); color: var(--green); }
.toast-error { border-color: var(--red); color: var(--red); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== SESSION EXPIRED ===== */
.session-expired-overlay {
  position: fixed; inset: 0; z-index: 250;
  background: rgba(0,0,0,0.5); display: flex;
  align-items: center; justify-content: center;
}
.session-expired-box {
  background: var(--surface); border-radius: var(--radius);
  padding: 32px; text-align: center; max-width: 360px;
}

/* ===== THEME PICKER ===== */
.theme-row {
  display: flex; gap: 8px; margin-top: 8px;
}
.theme-dot {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--border); cursor: pointer;
  transition: border-color 0.15s;
}
.theme-dot:hover, .theme-dot.active { border-color: var(--accent); }

/* ===== おすすめ 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; }

/* ===== 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 ===== */
.weak-slider-row {
  display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
}
.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; }

/* ===== RESULTS ITEMS ===== */
.results-items { margin-bottom: 16px; }
.result-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  font-size: 13px; gap: 8px;
}
.result-item-correct { }
.result-item-wrong { background: var(--red-dim); }
.result-item-main { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.result-item-mark { font-weight: 700; font-size: 14px; }
.result-item-correct .result-item-mark { color: var(--green); }
.result-item-wrong .result-item-mark { color: var(--red); }
.result-item-id { color: var(--text-dimmer); font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.result-item-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-item-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.mylist-hint { font-size: 11px; color: var(--accent); white-space: nowrap; }

/* ===== SPEAK MODE ===== */
.btn-speak-hint {
  background: var(--surface2); color: var(--text-dim); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 16px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.btn-speak-hint:hover { background: var(--border); }

.speak-mic-btn {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent);
  color: var(--accent); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.2s; position: relative;
}
.speak-mic-btn:hover { background: var(--accent-glow); }
.speak-mic-btn.listening {
  background: var(--red-dim); border-color: var(--red); color: var(--red);
  animation: speak-pulse 1.5s ease-in-out infinite;
}
@keyframes speak-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(198,40,40,0.4); }
  50% { box-shadow: 0 0 0 16px rgba(198,40,40,0); }
}
.speak-mic-label {
  font-size: 13px; color: var(--text-dimmer); margin-top: 8px;
}
.speak-transcript {
  min-height: 60px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px; line-height: 1.6;
  font-family: 'Source Serif 4', Georgia, serif;
}
.speak-transcript .interim { color: var(--text-dimmer); }
.speak-transcript .final { color: var(--text); }
.speak-unsupported {
  text-align: center; padding: 24px; color: var(--red);
  font-size: 15px; line-height: 1.6;
  background: var(--red-dim); border-radius: var(--radius);
  margin-top: 20px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 520px) {
  .setup-actions { grid-template-columns: 1fr; }
  .sentlist-search-row { grid-template-columns: 1fr; }
  .setup-mode-banner { flex-direction: column; align-items: flex-start; }
  .setup-mode-title { font-size: 16px; }
  .setup-mode-sub { font-size: 11px; }
  .mode-cards { grid-template-columns: 1fr; }
  .quiz-ja { font-size: 15px; }
  .complete-hint { font-size: 15px; }
  .reorder-sentence { font-size: 15px; line-height: 2.2; }
  .reorder-tile { padding: 8px 12px; font-size: 14px; }
  .reorder-slot { min-width: 50px; min-height: 30px; }
  .results-score { font-size: 48px; }
  .source-tab { font-size: 13px; padding: 8px 4px; }
  .focus-range-bar { padding: 8px; }
}
