/* Little Lantern for YouTube — overlay styling (mirrors the reader's look). */
.ll-root {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  pointer-events: none;
  font-family: "Nunito", "Noto Sans SC", system-ui, sans-serif;
  text-align: initial;
  /* Status palette — overridden per learner from their Profile → Display prefs
     (site defaults here). */
  --ll-learning: #f2b33d;
  --ll-known: #9ba15a;
  --ll-needs: #e8917f;
  --ll-underline: 3px;
}
.ll-root * { box-sizing: border-box; }

/* Anchored inside the YouTube player: the overlay covers the player so the
   controls can sit top-right and the subtitle card bottom-centre, over video. */
.ll-root.ll--in-player { position: absolute; inset: 0; }

/* Controls: one grouped cream pill, centred at the top of the video, with the
   Little Lantern branding on the left (like the reference). */
.ll-toolbar {
  pointer-events: auto;
  position: absolute;
  top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 1px;
  padding: 3px 6px 3px 4px;
  background: rgba(250, 243, 231, 0.96);
  border: 1px solid #eadcc0;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}
.ll-brand {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 9px 0 8px; margin-right: 3px; border-right: 1px solid #eadcc0;
  font-family: "Baloo 2", "Nunito", system-ui, sans-serif;
  font-weight: 800; font-size: 0.9rem; color: #3a2a1c; white-space: nowrap;
}
.ll-brand__icon {
  width: 1.4rem; height: 1.4rem; flex: 0 0 auto;
  background-image: url("icons/lantern.png"); /* JS sets the exact chrome-extension URL too */
  background-position: center; background-size: contain; background-repeat: no-repeat;
}
.ll-brand { cursor: move; touch-action: none; } /* the top bar is draggable */

/* Minimised state: the ✕ hides the overlay to this small restore button. */
.ll-restore {
  pointer-events: auto; position: fixed; z-index: 2147483002;
  left: 10px; top: 45%; transform: translateY(-50%);
  width: 2.3rem; height: 2.3rem; border-radius: 50%;
  background: rgba(250, 243, 231, 0.96); border: 1px solid #eadcc0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.ll-restore[hidden] { display: none; }
.ll-restore:hover { background: #fff8ec; }
.ll-overlay.ll--min .ll-sidebar,
.ll-overlay.ll--min .ll-dock,
.ll-overlay.ll--min .ll-settings { display: none !important; }

/* "Adding grammar…" indicator — shown while a first-time AI tagging pass runs. */
.ll-tagging {
  pointer-events: none;
  position: absolute; top: 12px; left: 12px;
  display: none; align-items: center; gap: 6px;
  padding: 5px 11px;
  background: rgba(250, 243, 231, 0.94);
  border: 1px solid #eadcc0; border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  color: #6f5842; font-size: 0.8rem; font-weight: 700;
  font-family: "Nunito", "Noto Sans SC", system-ui, sans-serif;
}
.ll-tagging.is-on { display: inline-flex; }
.ll-tagging__dot { width: 8px; height: 8px; border-radius: 50%; background: #b94436; animation: ll-pulse 1s ease-in-out infinite; }
@keyframes ll-pulse { 0%, 100% { opacity: 0.3; transform: scale(0.75); } 50% { opacity: 1; transform: scale(1.1); } }

/* Subtitle card — cream, bottom-centre, over the lower part of the video. */
.ll-bar {
  pointer-events: auto;
  position: absolute;
  left: 50%; bottom: 9%;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(46rem, 92%);
  display: flex;
  padding: 0.55rem 0.9rem;
  background: rgba(250, 243, 231, 0.88);
  border: 1px solid #eadcc0;
  border-radius: 18px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
.ll-bar__subs { flex: 1; min-width: 0; text-align: center; }
.ll-note { color: #8a7358; font-size: 0.8rem; }
/* Resize grip for the caption card (drag to change width). */
.ll-bar__grip {
  position: absolute; right: 2px; bottom: 2px; width: 12px; height: 12px;
  cursor: nwse-resize; touch-action: none; opacity: 0.32;
  background: linear-gradient(135deg, transparent 0 60%, #b58e5e 60% 70%, transparent 70% 80%, #b58e5e 80% 90%, transparent 90%);
}
.ll-bar__grip:hover { opacity: 0.7; }
/* Caption text scales with the grip's downward drag (var set by JS). */
.ll-bar .ll-char-hz { font-size: calc(1.95rem * var(--ll-bar-scale, 1)); }
.ll-bar .ll-char-py { font-size: calc(0.78rem * var(--ll-bar-scale, 1)); height: calc(0.96rem * var(--ll-bar-scale, 1)); color: #b0714f; }
.ll-bar .ll-plain { font-size: calc(1.75rem * var(--ll-bar-scale, 1)); }

/* Chinese line — word chips with per-character pinyin, tinted by status. */
.ll-zh { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.15rem 0.35rem; line-height: 1.15; }
.ll-plain { color: #4a3626; align-self: flex-end; font-size: 1.75rem; }
.ll-word {
  display: inline-flex; align-items: flex-end; gap: 1px;
  cursor: pointer; border-radius: 6px; padding: 0 2px;
  transition: background 0.12s ease;
}
.ll-word:hover { background: rgba(200, 155, 60, 0.18); }
.ll-word:focus-visible { outline: 2px solid #b94436; outline-offset: 1px; }
.ll-char { display: inline-flex; flex-direction: column; align-items: center; }
.ll-char-py {
  font-family: "Nunito", "Noto Sans SC", system-ui, sans-serif;
  font-size: 0.76rem; font-weight: 600;
  color: #a1907b;
  line-height: 1; height: 0.94rem;
}
.ll-root.ll--no-pinyin .ll-char-py { display: none; }
/* Pinyin visibility by learning status (matches the site + app readers):
   known → hidden, learning → 50% faded, needs-practice / new → full, and a
   custom marker hides it like known. Opacity (not display) keeps the line's
   pinyin row aligned. Only while pinyin is on (not .ll--no-pinyin). */
.ll-root:not(.ll--no-pinyin) .ll-word.ll--known .ll-char-py,
.ll-root:not(.ll--no-pinyin) .ll-word.ll--marker .ll-char-py { opacity: 0; }
.ll-root:not(.ll--no-pinyin) .ll-word.ll--learning .ll-char-py { opacity: 0.5; }
.ll-char-hz {
  font-family: var(--ll-hz-font, "KaiTi", "楷体", "Kaiti SC", "STKaiti", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif);
  font-size: 1.95rem; line-height: 1.05; color: #3a2a1c;
  border-bottom: var(--ll-underline, 3px) solid transparent;
}
/* Unrated word = clean, no mark at all (no colour, no underline). */
.ll-word.ll--new .ll-char-hz { color: #2f2013; border-bottom-color: transparent; }

/* Default "colour" mode: tint the hanzi in the status colour with a legibility
   stroke behind it (exactly like the site's reader). */
.ll-root:not([data-ll-highlight="underline"]) .ll-word:not(.ll--new) .ll-char-hz {
  -webkit-text-stroke: 0.5px rgba(45, 32, 22, 0.5);
  paint-order: stroke fill;
}
.ll-root:not([data-ll-highlight="underline"]) .ll-word.ll--learning .ll-char-hz { color: var(--ll-learning); }
.ll-root:not([data-ll-highlight="underline"]) .ll-word.ll--known .ll-char-hz { color: var(--ll-known); }
.ll-root:not([data-ll-highlight="underline"]) .ll-word.ll--needs .ll-char-hz { color: var(--ll-needs); }

/* "underline" mode: ink text, underline in the status colour. */
.ll-root[data-ll-highlight="underline"] .ll-word.ll--learning .ll-char-hz { border-bottom-color: var(--ll-learning); }
.ll-root[data-ll-highlight="underline"] .ll-word.ll--known .ll-char-hz { border-bottom-color: var(--ll-known); }
.ll-root[data-ll-highlight="underline"] .ll-word.ll--needs .ll-char-hz { border-bottom-color: var(--ll-needs); }

/* "Known — no colour": known words read like untracked ones. */
.ll-root[data-known-no-color] .ll-word.ll--known .ll-char-hz {
  color: #2f2013 !important; -webkit-text-stroke: 0 !important; border-bottom-color: rgba(123, 92, 67, 0.28) !important;
}

/* Custom word markers (cosmetic) override the status colour, like the site. */
.ll-root:not([data-ll-highlight="underline"]) .ll-word.ll--marker .ll-char-hz {
  color: var(--ll-marker) !important;
  -webkit-text-stroke: 0.5px rgba(45, 32, 22, 0.5); paint-order: stroke fill;
}
.ll-root[data-ll-highlight="underline"] .ll-word.ll--marker .ll-char-hz {
  border-bottom-color: var(--ll-marker) !important;
}

.ll-en { margin-top: 0.25rem; color: #5a4636; font-size: 1.02rem; min-height: 1.1rem; }

/* Controls — borderless buttons inside the grouped toolbar pill. */
.ll-ctl {
  min-width: 1.8rem; height: 1.8rem; padding: 0 0.4rem;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: 999px;
  color: #6f5842; font-weight: 700; font-size: 0.82rem; cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.ll-ctl:hover { background: rgba(123, 92, 67, 0.16); color: #b94436; }
/* Active toggle (拼 / EN when on) — filled pill so on/off state is obvious. */
.ll-ctl.is-on { background: #b94436; color: #fff8ee; }
.ll-ctl.is-on:hover { background: #a53a2d; color: #fff8ee; }
.ll-account.is-in span { background: #b94436; color: #fff8ee; border-radius: 50%; padding: 0.12rem 0.3rem; font-size: 0.68rem; line-height: 1; }

/* Transcript sidebar */
/* Transcript panel — fixed to the right of the video, over YouTube's related /
   playlist column (viewport-anchored, so it clears the video). */
.ll-sidebar {
  pointer-events: auto;
  position: fixed; top: 90px; right: 12px; bottom: 16px;
  width: min(402px, 30vw);
  display: flex; flex-direction: column;
  background: rgba(250, 243, 231, 0.98);
  border: 1px solid #eadcc0; border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.42); overflow: hidden;
  container: ll-sidebar / inline-size;
}
.ll-sidebar[hidden] { display: none; }
.ll-sidebar__head { position: sticky; top: 0; z-index: 3; display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0.75rem; border-bottom: 1px solid #eadcc0; background: rgba(250, 243, 231, 0.98); color: #3a2a1c; font-family: "Baloo 2", "Nunito", system-ui, sans-serif; cursor: move; user-select: none; touch-action: none; }
/* Resize grip in the bottom-right corner. */
.ll-sidebar__grip {
  position: absolute; right: 2px; bottom: 2px; width: 12px; height: 12px;
  cursor: nwse-resize; touch-action: none; opacity: 0.3;
  background:
    linear-gradient(135deg, transparent 0 60%, #b58e5e 60% 70%, transparent 70% 80%, #b58e5e 80% 90%, transparent 90%);
}
.ll-sidebar__grip:hover { opacity: 0.7; }
.ll-sidebar__list { overflow-y: auto; padding: 0.25rem 0.3rem; flex: 1 1 auto; min-height: 3rem; scrollbar-width: thin; scrollbar-color: rgba(123, 92, 67, 0.35) transparent; }
.ll-sidebar__list::-webkit-scrollbar, .ll-dock::-webkit-scrollbar { width: 8px; }
.ll-sidebar__list::-webkit-scrollbar-track, .ll-dock::-webkit-scrollbar-track { background: transparent; }
.ll-sidebar__list::-webkit-scrollbar-thumb, .ll-dock::-webkit-scrollbar-thumb { background: rgba(123, 92, 67, 0.32); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
.ll-sidebar__empty { margin: 0; padding: 1rem 0.9rem; color: #8a7358; font-size: 0.88rem; line-height: 1.45; }
.ll-cue {
  position: relative;
  display: grid; grid-template-columns: 44px 1fr; gap: 0.1rem 0.4rem; align-items: start;
  width: 100%; text-align: left;
  padding: 0.28rem 1.45rem 0.28rem 0.7rem; background: none; border: none; border-radius: 9px; cursor: pointer;
  transition: background 0.12s ease;
}
/* Quiet seek affordance on hover, at the far right of the row. */
.ll-cue::after { content: "\25B8"; position: absolute; right: 0.55rem; top: 0.42rem; color: #bd7050; opacity: 0; font-size: 0.85rem; transition: opacity 0.12s ease; pointer-events: none; }
.ll-cue:hover::after { opacity: 0.6; }
.ll-cue.is-active::after { opacity: 0.5; }
/* Per-line English, shown when hovering the transcript line. */
.ll-cue__en {
  display: none; grid-column: 2; margin: 0.1rem 0 0.05rem;
  color: #6f5842; font-size: calc(0.95rem * var(--ll-transcript-scale, 1)); line-height: 1.35;
  font-family: "Nunito", "Noto Sans SC", system-ui, sans-serif;
}
.ll-cue:hover .ll-cue__en, .ll-cue.is-active .ll-cue__en { display: block; }
.ll-cue:hover { background: rgba(123, 92, 67, 0.07); }
/* Selected line: soft terracotta wash across the whole row + a 2px accent edge. */
.ll-cue.is-active { background: rgba(185, 68, 54, 0.1); box-shadow: inset 2px 0 0 #b94436; }
/* Lines the video hasn't reached yet stay hidden — the transcript grows with playback. */
.ll-cue.is-future { display: none; }
/* Timestamp = metadata: a narrow, muted, fixed-width column so all lines align. */
.ll-cue__time { grid-column: 1; grid-row: 1; color: #bd7050; font-weight: 600; font-size: calc(0.72rem * var(--ll-transcript-scale, 1)); font-variant-numeric: tabular-nums; padding-top: 0.34rem; }
/* "English & Grammar · Ready / Refining" — a quiet status beside the title, with
   an ⓘ whose hover explains the instant-tag + background-refine flow. */
.ll-sidebar__title { display: inline-flex; align-items: baseline; gap: 0.55rem; flex: 1 1 auto; min-width: 0; }
.ll-sidebar__status { display: inline-flex; align-items: center; gap: 0.3rem; min-width: 0; color: #a1907b; font-family: "Nunito", system-ui, sans-serif; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.01em; white-space: nowrap; }
.ll-sidebar__status > [data-ll-status-text] { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* Narrow panels drop the "English & Grammar ·" prefix so the head never crowds. */
@container ll-sidebar (max-width: 370px) { .ll-sidebar__status-pre { display: none; } }
.ll-sidebar__status[hidden] { display: none; }
.ll-sidebar__status.is-refining { color: #bd7050; }
.ll-sidebar__status.is-checking::before, .ll-sidebar__status.is-refining::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: ll-pulse 1s ease-in-out infinite; }
.ll-sidebar__info { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 0.9rem; height: 0.9rem; border: 1px solid currentColor; border-radius: 50%; font-family: Georgia, "Times New Roman", serif; font-size: 0.62rem; font-style: italic; font-weight: 700; line-height: 1; cursor: help; opacity: 0.75; outline: none; }
.ll-sidebar__info:hover, .ll-sidebar__info:focus-visible { color: #bd7050; opacity: 1; }
.ll-sidebar__tip {
  display: none; position: absolute; left: 0.75rem; top: calc(100% - 3px); z-index: 6; /* anchored to the (sticky) head so it never clips */
  width: 236px; padding: 0.5rem 0.65rem;
  font-family: "Nunito", system-ui, sans-serif; font-style: normal;
  background: #fffdf7; border: 1px solid #eadcc0; border-radius: 9px; box-shadow: 0 6px 18px rgba(60, 40, 20, 0.14);
  color: #5c4a3a; font-size: 0.74rem; font-weight: 500; line-height: 1.4; letter-spacing: 0; white-space: normal; text-align: left; cursor: default;
}
.ll-sidebar__info:hover .ll-sidebar__tip, .ll-sidebar__info:focus-visible .ll-sidebar__tip { display: block; }
.ll-sidebar__tools { display: inline-flex; align-items: center; gap: 1px; flex: none; }
.ll-sidebar__tools .ll-ctl { min-width: 1.5rem; height: 1.5rem; font-size: 0.95rem; }
.ll-cue__text { grid-column: 2; grid-row: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.12rem 0.3rem; }
.ll-cue__text .ll-char-hz { font-size: calc(1.5rem * var(--ll-transcript-scale, 1)); border-bottom-width: 2px; }
/* Transcript pinyin (shown while 拼 is on) scales with the transcript text. */
.ll-cue__text .ll-char-py { font-size: calc(0.68rem * var(--ll-transcript-scale, 1)); height: calc(0.86rem * var(--ll-transcript-scale, 1)); }
/* Room under transcript lines for the grammar dash / book marker. */
.ll-root[data-ll-grammar-marker="book"] .ll-cue__text { padding-bottom: 0.7rem; row-gap: 0.75rem; }
.ll-cue__text .ll-gram-book { width: 1.05rem; height: 1.05rem; bottom: -0.32rem; }

/* Word popover */
/* Dictionary + grammar stack in a right-side dock (under the transcript), each a
   calm card sitting on a slightly larger cream "mat" (the spread shadow). */
/* Dock sits INSIDE the transcript panel, below the lines (one unified panel). */
.ll-dock {
  flex: 0 0 auto; max-height: 58%; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 12px 12px 12px;
  margin-top: 6px; border-top: 1px solid #eadcc0;
  scrollbar-width: thin; scrollbar-color: rgba(123, 92, 67, 0.35) transparent;
}
.ll-dock:empty { display: none; margin: 0; border: 0; }
/* Dictionary + grammar are clean inner cards that belong to the panel — thin warm
   border + a very soft shadow (no heavy cream "mat", no inner scrollbar). */
.ll-popover {
  pointer-events: auto; position: relative; width: 100%;
  padding: 1rem 1.05rem 0.95rem;
  background: #fffaf0; border: 1px solid #ecdcc0; border-radius: 14px;
  box-shadow: 0 4px 14px rgba(58, 42, 28, 0.10);
  color: #3a2a1c;
}
.ll-popover[hidden] { display: none; }
.ll-pop__close, .ll-gram-panel__close {
  position: absolute; top: 8px; right: 10px; z-index: 1;
  width: 1.6rem; height: 1.6rem; min-width: 0; min-height: 0; padding: 0;
  border: none; background: none; color: #8a7358; font-size: 0.95rem; line-height: 1;
  cursor: pointer; border-radius: 8px;
}
.ll-pop__close:hover, .ll-gram-panel__close:hover { background: rgba(123, 92, 67, 0.14); color: #b94436; }
.ll-pop__top { display: flex; align-items: center; gap: 0.5rem; padding-right: 1.7rem; }
.ll-pop__audio {
  border: none; background: rgba(123, 92, 67, 0.12); border-radius: 999px;
  width: 1.7rem; height: 1.7rem; min-width: 0; min-height: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.9rem; line-height: 1; color: #6f5842; cursor: pointer;
  transition: background 0.12s ease, transform 0.12s ease;
}
.ll-pop__audio[hidden] { display: none; }
.ll-pop__audio:hover { background: rgba(123, 92, 67, 0.22); }
.ll-pop__audio.is-playing { transform: scale(1.12); background: rgba(185, 68, 54, 0.18); }
.ll-pop__hz { font-family: var(--ll-hz-font, "KaiTi", "楷体", "Kaiti SC", "STKaiti", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif); font-size: 1.95rem; line-height: 1.1; }

/* --- settings panel -------------------------------------------------------- */
.ll-settings {
  pointer-events: auto; position: fixed; z-index: 2147483001;
  top: 90px; right: 12px; width: 17rem; padding: 0.4rem 0.4rem 0.6rem;
  background: rgba(250, 243, 231, 0.98); border: 1px solid #eadcc0; border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4); color: #3a2a1c;
  font-family: "Nunito", "Noto Sans SC", system-ui, sans-serif;
}
.ll-settings[hidden] { display: none; }
.ll-settings__head { display: flex; justify-content: space-between; align-items: center; padding: 0.4rem 0.5rem 0.5rem; font-family: "Baloo 2", "Nunito", system-ui, sans-serif; border-bottom: 1px solid #eadcc0; }
.ll-set-row { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.5rem 0.5rem 0; }
.ll-set-row > span { font-size: 0.9rem; font-weight: 700; color: #6f5842; }
.ll-seg { display: inline-flex; background: #efe4cf; border-radius: 999px; padding: 2px; gap: 2px; }
.ll-seg button {
  border: none; background: transparent; cursor: pointer; border-radius: 999px;
  padding: 0.22rem 0.55rem; font-size: 0.82rem; font-weight: 700; color: #6f5842;
  font-family: "Noto Sans SC", "Nunito", system-ui, sans-serif; white-space: nowrap;
}
.ll-seg button.is-active { background: #b94436; color: #fff8ee; }
.ll-seg button:not(.is-active):hover { background: rgba(123, 92, 67, 0.14); }
.ll-pop__hsk { margin-left: auto; align-self: flex-start; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.02em; color: #6f8256; background: rgba(143, 163, 122, 0.22); border-radius: 999px; padding: 0.12rem 0.5rem; white-space: nowrap; }
.ll-pop__py { color: #b94436; font-weight: 700; font-size: 1.02rem; margin: 0.15rem 0 0.5rem; }
.ll-pop__defs { margin: 0 0 0.7rem; padding-left: 1.1rem; color: #4a3626; font-size: 0.95rem; line-height: 1.5; }
.ll-pop__def { color: #6f5842; font-size: 0.9rem; margin-bottom: 0.5rem; }
/* Status choices in one clean horizontal row. */
.ll-pop__actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.ll-statusbtn {
  padding: 0.42rem 0.3rem; border-radius: 9px; border: 1.5px solid rgba(123, 92, 67, 0.28);
  background: #fff; color: #4a3626; font-weight: 700; font-size: 0.8rem; line-height: 1.15; cursor: pointer;
  text-align: center;
}
.ll-statusbtn:hover { border-color: #b94436; }
.ll-statusbtn.ll--learning.is-active { background: var(--ll-learning); border-color: var(--ll-learning); color: #3a2a12; }
.ll-statusbtn.ll--known.is-active { background: var(--ll-known); border-color: var(--ll-known); color: #263016; }
.ll-statusbtn.ll--needs.is-active { background: var(--ll-needs); border-color: var(--ll-needs); color: #4a1810; }
.ll-statusbtn.ll--new.is-active { background: #efe2c8; border-color: #cbb996; }
.ll-pop__signin { margin-top: 0.2rem; }
.ll-pop__signin .ll-statusbtn { width: 100%; background: #b94436; color: #fff8ee; border-color: #b94436; }
.ll-pop__locked { margin-top: 0.2rem; text-align: center; }
.ll-pop__lockmsg { margin: 0 0 0.45rem; font-size: 0.85rem; color: #6f5842; }
.ll-pop__planbtn { width: 100%; background: #b94436; color: #fff8ee; border-color: #b94436; }
.ll-pop__planbtn:hover { background: #a5382c; }

/* --- grammar highlighting (mirrors the site reader) --------------------- */
/* A .ll-gram wraps just the grammar particle(s) inside a word, coloured purple by
   default and by the point's status once rated. HOW it's marked follows the
   learner's Profile → Grammar marker setting (synced via display prefs):
   "dash" (default dashed line) or "book" (a book icon replaces the dash). */
.ll-gram {
  --gcolor: #8067a5;
  position: relative;
  cursor: pointer;
  border-radius: 3px;
}
.ll-gram[data-gstatus="known"] { --gcolor: var(--ll-known, #9ba15a); }
.ll-gram[data-gstatus="learning"] { --gcolor: var(--ll-learning, #f2b33d); }
.ll-gram[data-gstatus="needs_practice"] { --gcolor: var(--ll-needs, #e8917f); }
.ll-gram:hover { background-color: rgba(128, 103, 165, 0.12); }

/* DASH mode (default): dashed line under the particle, coloured by status. */
.ll-root:not([data-ll-grammar-marker="book"]) .ll-gram {
  background-image: repeating-linear-gradient(to right, var(--gcolor) 0, var(--gcolor) 7px, transparent 7px, transparent 13px);
  background-position: center calc(100% - 1px);
  background-size: calc(100% - 6px) 2px;
  background-repeat: no-repeat;
}
.ll-root:not([data-ll-grammar-marker="book"]) .ll-gram-book { display: none; }

/* BOOK mode: the book icon sits centred UNDER the word (on the line), like the
   site reader; no dashed line. */
.ll-gram-book {
  display: none;
  position: absolute;
  left: 50%; bottom: -0.1rem;
  transform: translate(-50%, 50%);
  width: 1.15rem; height: 1.15rem;
  color: var(--gcolor); line-height: 1; opacity: 0.85;
  pointer-events: auto; cursor: pointer;
  transition: opacity 0.12s ease;
}
.ll-gram-book:hover { opacity: 1; }
.ll-root[data-ll-grammar-marker="book"] .ll-gram-book { display: inline-flex; align-items: center; justify-content: center; }
.ll-gram-book svg { width: 100%; height: 100%; display: block; }
/* Room under the caption line so the under-word book isn't clipped. */
.ll-root[data-ll-grammar-marker="book"] .ll-zh { padding-bottom: 0.7rem; }
.ll-gram-name { display: none; } /* labels mode unused in the extension */

/* Untracked point: keep the text, drop the dash/book (mirrors the site). */
.ll-gram--untracked { background-image: none !important; }
.ll-gram--untracked .ll-gram-book { display: none !important; }

/* Grammar explanation panel — matches the dictionary card in the dock. */
.ll-gram-panel {
  pointer-events: auto; position: relative; width: 100%;
  padding: 1rem 1.05rem 0.95rem;
  background: #fffaf0; border: 1px solid #ecdcc0; border-radius: 14px;
  box-shadow: 0 4px 14px rgba(58, 42, 28, 0.10); color: #3a2a1c;
  font-family: "Nunito", "Noto Sans SC", system-ui, sans-serif;
}
.ll-gram-panel[hidden] { display: none; }
.ll-gram-panel__close {
  position: absolute; top: 6px; right: 8px; width: 1.6rem; height: 1.6rem;
  background: none; border: none; color: #8a7358; font-size: 1rem; cursor: pointer; border-radius: 6px;
}
.ll-gram-panel__close:hover { background: rgba(123, 92, 67, 0.12); }
.ll-gram-panel__eyebrow { margin: 0 1.7rem 0 0; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; color: #6f8256; }
.ll-gram-panel__title { margin: 0.2rem 0 0.15rem; font-size: 1.18rem; font-weight: 800; line-height: 1.2; }
.ll-gram-panel__cn { margin: 0 0 0.45rem; color: #6f5842; font-size: 0.92rem; }
.ll-gram-panel__pattern { display: inline-block; margin: 0 0 0.55rem; font-weight: 800; color: #6a5cb0; background: rgba(106, 92, 176, 0.12); border-radius: 8px; padding: 0.18rem 0.55rem; font-size: 0.9rem; }
.ll-gram-panel__explain { margin: 0 0 0.6rem; color: #4a3626; font-size: 0.93rem; line-height: 1.5; }
.ll-gram-eg { background: #faf3e7; border: 1px solid #ecdcc0; border-radius: 10px; padding: 0.55rem 0.7rem; margin-bottom: 0.6rem; }
.ll-gram-eg__zh { margin: 0; font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 1.05rem; color: #3a2a1c; }
.ll-gram-eg__py { margin: 0.1rem 0 0; color: #a1907b; font-size: 0.8rem; font-weight: 600; }
.ll-gram-eg__en { margin: 0.1rem 0 0; color: #6f5842; font-size: 0.85rem; }
.ll-gram-track { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.35rem; font-size: 0.86rem; color: #4a3626; }
.ll-gram-switch {
  flex: 0 0 auto; width: 2.4rem; height: 1.35rem; padding: 2px;
  background: #d8c8ad; border: none; border-radius: 999px; cursor: pointer; transition: background 0.15s ease;
}
.ll-gram-switch.is-on { background: var(--ll-learning, #f2b33d); }
.ll-gram-knob { display: block; width: 1.05rem; height: 1.05rem; background: #fffaf0; border-radius: 50%; transition: transform 0.15s ease; }
.ll-gram-switch.is-on .ll-gram-knob { transform: translateX(1.05rem); }
.ll-gram-status { margin-bottom: 0.25rem; }
.ll-gram-status__label { display: block; margin-bottom: 0.25rem; font-size: 0.8rem; color: #6f5842; }
.ll-gram-panel__more { display: inline-block; margin-top: 0.2rem; color: #b94436; font-weight: 700; font-size: 0.85rem; text-decoration: none; }
.ll-gram-panel__more:hover { text-decoration: underline; }

/* ===================== DARK MODE (Settings → Theme) ===================== */
[data-ll-theme="dark"] :is(.ll-bar, .ll-toolbar, .ll-sidebar, .ll-popover, .ll-gram-panel, .ll-settings, .ll-restore, .ll-tagging) {
  background: #25211e; border-color: #443c33; color: #f3ebdd;
}
/* Detail cards sit visibly INSIDE the panel: a touch lighter + warm border. */
[data-ll-theme="dark"] :is(.ll-popover, .ll-gram-panel) { background: #2e2925; border-color: #4a4038; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45); }
[data-ll-theme="dark"] .ll-bar { background: rgba(37, 33, 30, 0.86); }
[data-ll-theme="dark"] :is(.ll-toolbar, .ll-sidebar, .ll-settings, .ll-restore) { box-shadow: 0 8px 26px rgba(0, 0, 0, 0.55); }
[data-ll-theme="dark"] .ll-bar { box-shadow: 0 10px 28px rgba(0, 0, 0, 0.62); }
/* text */
[data-ll-theme="dark"] .ll-char-hz,
[data-ll-theme="dark"] .ll-word.ll--new .ll-char-hz,
[data-ll-theme="dark"] .ll-brand,
[data-ll-theme="dark"] .ll-sidebar__head { color: #f3ebdd; }
/* Soften the learner-status colours in dark so they read as sophisticated,
   not neon. Base (unrated) hanzi stays warm ivory above. */
[data-ll-theme="dark"] .ll-word:not(.ll--new) .ll-char-hz { filter: saturate(0.8) brightness(1.06); }
[data-ll-theme="dark"] .ll-char-py { color: #c2ab90; }
[data-ll-theme="dark"] .ll-bar .ll-char-py { color: #e0a888; }
[data-ll-theme="dark"] .ll-sidebar__head { background: #25211e; }
[data-ll-theme="dark"] .ll-cue__time { color: #c97862; }
[data-ll-theme="dark"] .ll-cue::after { color: #c97862; }
/* Darker, thinner scrollbars. */
[data-ll-theme="dark"] :is(.ll-sidebar__list, .ll-dock) { scrollbar-color: rgba(255, 255, 255, 0.18) transparent; }
[data-ll-theme="dark"] :is(.ll-sidebar__list, .ll-dock)::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); background-clip: content-box; }
[data-ll-theme="dark"] .ll-dock { border-top-color: #3a332b; }
[data-ll-theme="dark"] .ll-plain { color: #cbbba4; }
[data-ll-theme="dark"] .ll-en { color: #bfb09a; }
[data-ll-theme="dark"] :is(.ll-note, .ll-tagging, .ll-sidebar__empty, .ll-pop__close, .ll-gram-panel__close, .ll-settings__head, .ll-set-row > span) { color: #a99a86; }
[data-ll-theme="dark"] .ll-ctl { color: #c9b9a2; }
[data-ll-theme="dark"] .ll-ctl:hover { background: rgba(255, 255, 255, 0.1); color: #f0c9b0; }
/* transcript */
[data-ll-theme="dark"] .ll-cue:hover { background: rgba(255, 255, 255, 0.06); }
[data-ll-theme="dark"] .ll-cue.is-active { background: rgba(210, 120, 90, 0.1); box-shadow: inset 2px 0 0 #d2785a; }
[data-ll-theme="dark"] .ll-cue__en { color: #b3a48f; }
[data-ll-theme="dark"] :is(.ll-sidebar__head, .ll-settings__head) { border-color: #3a3229; }
[data-ll-theme="dark"] .ll-sidebar__status { color: #8f8170; }
[data-ll-theme="dark"] .ll-sidebar__status.is-refining { color: #c97862; }
[data-ll-theme="dark"] .ll-sidebar__status.is-checking { color: #a99a86; }
[data-ll-theme="dark"] .ll-sidebar__info:hover, [data-ll-theme="dark"] .ll-sidebar__info:focus-visible { color: #d2785a; }
[data-ll-theme="dark"] .ll-sidebar__tip { background: #2e2925; border-color: #4a4038; color: #c9baa4; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45); }
/* dictionary */
[data-ll-theme="dark"] :is(.ll-pop__defs, .ll-pop__def, .ll-pop__lockmsg) { color: #c9baa4; }
[data-ll-theme="dark"] .ll-pop__audio { background: rgba(255, 255, 255, 0.08); color: #cbbba4; }
[data-ll-theme="dark"] .ll-pop__audio:hover { background: rgba(255, 255, 255, 0.16); }
/* grammar */
[data-ll-theme="dark"] .ll-gram-panel__cn { color: #b3a48f; }
[data-ll-theme="dark"] .ll-gram-panel__explain { color: #d3c4ae; }
[data-ll-theme="dark"] .ll-gram-eg { background: #322c27; border-color: #463d33; }
[data-ll-theme="dark"] .ll-gram-eg__zh { color: #f3ebdd; }
[data-ll-theme="dark"] .ll-gram-eg__en { color: #bfb09a; }
[data-ll-theme="dark"] :is(.ll-gram-track, .ll-gram-status__label) { color: #c9baa4; }
/* status buttons + segmented controls */
[data-ll-theme="dark"] .ll-statusbtn { background: #322d28; border-color: #4d4238; color: #d8cab4; }
[data-ll-theme="dark"] .ll-statusbtn:hover { border-color: #d16a5a; }
[data-ll-theme="dark"] .ll-seg { background: #35302b; }
[data-ll-theme="dark"] .ll-seg button { color: #c9baa4; }
[data-ll-theme="dark"] .ll-seg button:not(.is-active):hover { background: rgba(255, 255, 255, 0.08); }
