:root {
  --bg: #f6f2ed;
  --panel: #fffdf9;
  --panel-2: #fffaf4;
  --border: #e6ded3;
  --border-strong: #cec3b4;
  --text: #1d2227;
  --muted: #6d716f;
  --accent: #5b54c7;
  --accent-soft: #eceafa;
  --secondary: #3f78b8;
  --secondary-soft: #eaf4ff;
  --track: #ded5c9;
  --jp: #12161a;
  --note: #91632b;
  --note-soft: #fff7e8;
  --danger: #c94236;
  --danger-soft: #fff0ed;
  --danger-border: #efbbb4;
  --success: #21784a;
  --success-soft: #e8f6ee;
  --panel-blur: rgba(255, 253, 249, 0.92);
  --note-border: #ead6ad;
  --code-bg: #f0ebe4;
  font-size: 16px;
}

/* Dark mode — same warm palette inverted; applied via data-theme on <html>
   (set early by an inline <head> script, toggled by theme.js). */
:root[data-theme="dark"] {
  --bg: #1a1715;
  --panel: #232020;
  --panel-2: #2b2725;
  --border: #38332f;
  --border-strong: #4d463f;
  --text: #f1ece4;
  --muted: #a79f94;
  --accent: #7b73e0;
  --accent-soft: #2a2747;
  --secondary: #76aae4;
  --secondary-soft: #1d2a39;
  --track: #3a3531;
  --jp: #f3eee7;
  --note: #d8ad66;
  --note-soft: #2c2417;
  --danger: #ec7a6e;
  --danger-soft: #2e1a18;
  --danger-border: #5a322d;
  --success: #5fc187;
  --success-soft: #16261d;
  --panel-blur: rgba(35, 32, 32, 0.92);
  --note-border: #4a3f28;
  --code-bg: #15120f;
}

:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
}

header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

#logo, #logo-dark {
  height: 38px;
  width: auto;
  display: block;
  flex-shrink: 0;
}
/* Light/dark logo pair: dark-text mark for light theme, light-text mark for dark.
   Swapped on data-theme (set pre-paint by the inline head script → no flash). */
#logo-dark { display: none; }
:root[data-theme="dark"] #logo { display: none; }
:root[data-theme="dark"] #logo-dark { display: block; }

#load-form {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  max-width: 680px;
}

#url-input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.95rem;
}
#url-input:focus { outline: none; border-color: var(--accent); }

#load-btn {
  padding: 0.5rem 1.1rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
}
#load-btn:disabled { opacity: 0.5; cursor: default; }

/* Right-side header controls share one consistent button look (Popular, upvote,
   Share, Sign in). The avatar/UserButton stays anchored at the far right. */
.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.hbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  flex-shrink: 0;
  min-height: 2.35rem;
  padding: 0.45rem 0.7rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.hbtn:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.hbtn:disabled { opacity: 0.5; cursor: default; }
.hbtn.is-active { background: var(--accent-soft); color: var(--accent); }
.hbtn-icon { padding: 0.45rem; }
.theme-icon {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: block; }

/* Study-language switcher: a nav chip showing the current language + a dropdown. */
/* Reserve the chip's width even before lang.js renders it, so the search bar doesn't
   shift when the language loads in. */
#lang-slot { position: relative; display: inline-flex; flex-shrink: 0; min-width: 3.85rem; }
.lang-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 2.35rem;
  padding: 0.4rem 0.6rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.lang-chip:hover { background: var(--accent-soft); color: var(--accent); }
.lang-chip-label { font-size: 1.15rem; line-height: 1; }
.lang-caret { width: 0.85rem; height: 0.85rem; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lang-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 50;
  min-width: 9rem;
  padding: 0.3rem;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(31, 25, 20, 0.18);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.lang-menu[hidden] { display: none; }
.lang-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.6rem;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.lang-option:hover { background: var(--panel-2); }
.lang-option.on { color: var(--accent); font-weight: 700; }
.lang-option.on::after { content: "✓"; margin-left: auto; }
.share-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#source-select {
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  flex-shrink: 0;
}

main {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(420px, 1fr);
  gap: 0;
  height: calc(100vh - 63px);
}

#video-pane {
  border-right: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

#player-wrap {
  position: sticky;
  top: 0;
  aspect-ratio: 16 / 9;
  width: 100%;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}
#player, #player iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

#speed-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.speed-label {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
#speed-readout {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  cursor: pointer;
  width: 4.5ch;
  text-align: right;
}

#speed-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 200px;
  height: 20px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
#speed-slider:focus { outline: none; }
/* WebKit track + fill (fill driven by the --fill custom property in JS) */
#speed-slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--fill, 50%), var(--track) var(--fill, 50%));
}
#speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 1px 4px rgba(31, 25, 20, 0.22);
}
/* Firefox track + native progress fill */
#speed-slider::-moz-range-track { height: 6px; border-radius: 999px; background: var(--track); }
#speed-slider::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--accent); }
#speed-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(31, 25, 20, 0.22);
}

/* --- Now-playing panel (big current line + progress) --- */
#now-playing {
  margin-top: 0.85rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem 1rem;
}
#now-playing[hidden] { display: none; }
#np-progress {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.85rem;
}
#np-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s linear;
}
#np-jp {
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  font-size: 1.7rem;
  line-height: 1.45;
  color: var(--jp);
}
#np-jp.np-placeholder { font-size: 0.92rem; color: var(--muted); font-family: inherit; }
#np-romaji { font-size: 1rem; color: var(--muted); margin-top: 0.3rem; }
#np-en { font-size: 1.05rem; color: var(--text); margin-top: 0.35rem; }

/* --- Chat panel (conversation practice) --- */
#chat-panel {
  margin-top: 0.85rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.8rem 0.8rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
#chat-panel[hidden] { display: none; }
#chat-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-bottom: 0.65rem;
  margin-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}
#chat-avatar {
  width: 2.4rem;
  height: 2.4rem;
  flex-shrink: 0;
  border-radius: 26%;
  overflow: hidden;
  background: #ffe7df;
  box-shadow: 0 0 0 1px var(--border);
  display: inline-flex;
}
#chat-avatar svg, #chat-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
#chat-id { min-width: 0; }
#chat-name {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--secondary);
}
#chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2faf5b;
  flex-shrink: 0;
}
#chat-tagline {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.3;
  margin-top: 0.12rem;
}
#chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.3rem 0.1rem;
}
.chat-empty { color: var(--muted); font-size: 0.85rem; padding: 0.5rem 0.2rem; }
.chat-msg {
  max-width: 85%;
  padding: 0.5rem 0.7rem;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.chat-user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chat-assistant { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-jp { font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif; }
.chat-tr-toggle {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--secondary);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.chat-tr { margin-top: 0.3rem; font-size: 0.85rem; color: var(--muted); }
.chat-typing { padding: 0.7rem 0.8rem; }
.typing-dots { display: inline-flex; align-items: center; gap: 4px; }
.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.35;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40% { transform: translateY(-4px); opacity: 1; }
}
#chat-suggestions { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.5rem 0 0.1rem; }
.chat-suggestion {
  font-size: 0.78rem;
  color: var(--secondary);
  background: var(--secondary-soft);
  border: none;
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  text-align: left;
}
.chat-suggestion:hover { filter: brightness(0.97); }
#chat-form { display: flex; gap: 0.4rem; margin-top: 0.6rem; }
#chat-input {
  flex: 1;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.9rem;
}
#chat-input:focus { outline: none; border-color: var(--accent); }
#chat-mic {
  width: 2.35rem;
  min-width: 2.35rem;
  height: 2.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.mic-icon {
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#chat-mic:hover:not(:disabled) { filter: brightness(0.97); }
#chat-mic:disabled { opacity: 0.5; cursor: default; }
#chat-mic.recording {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}
#chat-send {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}
#chat-send:hover { filter: brightness(1.05); }

#lesson-pane {
  overflow-y: auto;
  padding: 1rem 1.25rem 4rem;
}

#lesson-controls {
  position: sticky;
  top: -1rem;
  margin: -1rem -1.25rem 0.5rem;
  padding: 0.55rem 1.25rem;
  background: var(--panel-blur);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.follow-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.follow-toggle input { accent-color: var(--accent); cursor: pointer; margin: 0; }

.status { padding: 1.5rem 0.5rem; }
.muted { color: var(--muted); }

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
  margin-right: 0.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  padding: 0.75rem 1rem;
  border-radius: 8px;
}

/* --- segment cards --- */
.segment {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem 1rem;
  margin-bottom: 0.9rem;
  background: var(--panel);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.segment:hover { border-color: var(--border-strong); }
.segment.active {
  border-color: var(--secondary);
  box-shadow: inset 0 0 0 1px var(--secondary);
  background: var(--secondary-soft);
}

.seg-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.ts {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--secondary);
  background: var(--secondary-soft);
  border: none;
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
  cursor: pointer;
  flex-shrink: 0;
}
.ts:hover { filter: brightness(1.2); }

.jp {
  font-size: 1.35rem;
  color: var(--jp);
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  line-height: 1.5;
}
.romaji { color: var(--muted); font-size: 0.95rem; margin-top: 0.15rem; }
.en { margin-top: 0.35rem; font-size: 1rem; }

details.notes-detail { margin-top: 0.5rem; }
details.notes-detail > summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  font-size: 0.78rem;
  color: var(--note);
  background: var(--note-soft);
  border: 1px solid var(--note-border);
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
  user-select: none;
}
details.notes-detail > summary::-webkit-details-marker { display: none; }
.notes-body {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--note);
  background: var(--note-soft);
  border-left: 3px solid var(--note);
  padding: 0.4rem 0.7rem;
  border-radius: 0 6px 6px 0;
}

details.breakdown {
  margin-top: 0.65rem;
  border-top: 1px dashed var(--border);
  padding-top: 0.5rem;
}
details.breakdown > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
details.breakdown[open] > summary { color: var(--secondary); margin-bottom: 0.4rem; }
.bd-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.bd-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s ease;
}
details.breakdown[open] > summary .bd-icon { transform: rotate(180deg); }
.bd-status { display: inline-flex; align-items: center; }
.spinner.sm { width: 11px; height: 11px; border-width: 2px; margin: 0; }

.breakdown-body { font-size: 0.92rem; }
.breakdown-body table {
  border-collapse: collapse;
  margin: 0.5rem 0;
  font-size: 0.85rem;
}
.breakdown-body th, .breakdown-body td {
  border: 1px solid var(--border);
  padding: 0.3rem 0.55rem;
  text-align: left;
}
.breakdown-body code {
  background: var(--code-bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}
.breakdown-body p:first-child { margin-top: 0; }

@media (max-width: 820px) {
  header { position: static; }
  main { grid-template-columns: 1fr; height: auto; }
  /* Freeze the video at the top; the transcript scrolls beneath it. */
  #video-pane {
    position: sticky;
    top: 0;
    z-index: 8;
    display: block;
    overflow: visible;
    background: var(--bg);
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
  }
  #player-wrap { position: static; }
  #lesson-pane { overflow: visible; }
  #lesson-controls { position: static; top: auto; margin-top: 0; }
  #now-playing { padding: 0.7rem 0.85rem 0.8rem; margin-top: 0.6rem; }
  #np-jp { font-size: 1.3rem; }
  #np-en { font-size: 0.95rem; }
  #chat-messages { height: 200px; }
}

@media (max-width: 480px) {
  header {
    gap: 0.65rem 0.75rem;
    padding: 0.7rem 1rem;
  }
  #load-btn { padding: 0.5rem 0.85rem; }
  #share-btn {
    width: 2.35rem;
    padding: 0;
  }
  .share-label { display: none; }
}

/* --- A-B loop button --- */
.loop-btn {
  font-size: 0.9rem;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.12rem 0.4rem;
  cursor: pointer;
  flex-shrink: 0;
}
.loop-btn:hover { color: var(--accent); border-color: var(--accent); }
.loop-btn.looping { color: #fff; background: var(--accent); border-color: var(--accent); }

/* --- Quiz button --- */
.quiz-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 7px;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
}
.quiz-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.thumb-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.15em;
}
.quiz-btn:hover { filter: brightness(1.06); }
/* Compact, secondary (soft) variant living in Yui's chat header — Send stays the
   one filled primary action; this is demoted to a tinted button to ease the
   "too many loud buttons" weight. */
.chat-quiz {
  margin-left: auto;
  align-self: stretch;
  padding: 0.55rem 0.85rem;
  font-size: 0.8rem;
  color: var(--accent);
  background: var(--accent-soft);
}
.chat-quiz:hover { filter: brightness(0.97); }
.chat-quiz .quiz-icon { width: 0.95rem; height: 0.95rem; }

/* --- Quiz overlay --- */
#quiz-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(29, 34, 39, 0.55);
}
#quiz-overlay[hidden] { display: none; }
.quiz-modal {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.6rem 1.5rem 1.3rem;
  box-shadow: 0 20px 60px rgba(31, 25, 20, 0.28);
}
.quiz-close {
  position: absolute;
  top: 0.55rem;
  right: 0.8rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.quiz-close:hover { color: var(--text); }

#quiz-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 1.1rem;
  padding-bottom: 0.9rem;
  padding-right: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.quiz-yui-avatar {
  width: 2.8rem;
  height: 2.8rem;
  flex-shrink: 0;
  border-radius: 26%;
  overflow: hidden;
  background: #ffe7df;
  box-shadow: 0 0 0 1px var(--border);
}
.quiz-yui-avatar svg, .quiz-yui-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.quiz-yui-name { font-weight: 700; font-size: 1rem; color: var(--secondary); }
.quiz-yui-sub { font-size: 0.8rem; font-weight: 700; color: var(--muted); margin-top: 0.1rem; }

.quiz-progress {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.8rem;
}
.quiz-play {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--secondary);
  background: var(--secondary-soft);
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  margin-bottom: 1rem;
}
.quiz-play:hover { filter: brightness(0.97); }
.quiz-prompt { font-size: 1.05rem; font-weight: 600; line-height: 1.4; margin-bottom: 0.5rem; }
.quiz-jp {
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  font-size: 1.2rem;
  color: var(--jp);
  margin-bottom: 0.9rem;
}
.quiz-choices { display: flex; flex-direction: column; gap: 0.5rem; }
.quiz-choice {
  text-align: left;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.quiz-choice:hover:not(:disabled) { border-color: var(--secondary); }
.quiz-choice:disabled { cursor: default; }
.quiz-choice.correct { border-color: var(--success); background: var(--success-soft); color: var(--success); font-weight: 600; }
.quiz-choice.wrong { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }

.quiz-feedback { margin-top: 1rem; }
.fb-correct { color: var(--success); font-size: 0.9rem; margin-bottom: 0.8rem; }
.fb-wrong { color: var(--danger); font-size: 0.9rem; margin-bottom: 0.8rem; }
.quiz-next, .quiz-done {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1.1rem;
  cursor: pointer;
}
.quiz-next:hover, .quiz-done:hover { filter: brightness(1.06); }

.quiz-results { text-align: center; padding: 1.5rem 0 0.5rem; }
.quiz-score { font-size: 2.4rem; font-weight: 800; color: var(--accent); }
.quiz-result-actions { display: flex; gap: 0.6rem; justify-content: center; margin-top: 1.2rem; }
.quiz-retake {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--secondary);
  background: var(--panel-2);
  border: 1px solid var(--secondary);
  border-radius: 8px;
  padding: 0.5rem 1.1rem;
  cursor: pointer;
}
.quiz-retake:hover { background: var(--secondary-soft); }
