/* ─── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
input[type="file"] { display: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Force the scrollbar gutter so the page doesn't shift horizontally when
   content grows past the viewport and the scrollbar appears. */
html { overflow-y: scroll; }
/* Without this, iOS landscape inflates text outside form controls: the
   pattern-assist mirror drifts off its input and popovers outgrow their spot. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { font-family: var(--font-sans); font-size: 14px; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; min-height: 100vh; }
main { flex: 1 0 auto; display: flex; flex-direction: column; }

/* ─── Header ────────────────────────────────────────────────────────────────── */
/* Above #picker-backdrop (50), like #wordlist-bar, so the tool drawer's scrim
   leaves the chrome undimmed. */
header { position: relative; z-index: 100; background: var(--hdr-bg); color: white; padding: 6px 20px; display: flex; flex-direction: column; }
.header-row-main { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 44px; }
header h1 { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.1; flex-shrink: 1; min-width: 0; }
.header-logo-link { color: inherit; text-decoration: none; }
.header-byline-group { display: flex; align-items: center; justify-content: center; gap: 7px; flex: 1 1 auto; min-width: 0; color: rgba(255, 255, 255, 0.85); font-size: 14px; line-height: 1.2; flex-wrap: wrap; }
.header-sep { opacity: 0.5; }
.header-byline-group a { color: inherit; text-decoration: none; }
.header-byline a { border-bottom: 1px solid rgba(255,255,255,0.35); transition: border-color 0.15s; }
.header-byline a:hover { border-bottom-color: white; }

.header-utility { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.bubble { display: inline-flex; align-items: center; background: white; color: var(--accent); border-radius: 8px; padding: 1px 7px 2px; font-size: 15px; font-weight: 800; position: relative; margin-left: 9px; line-height: 1.5; vertical-align: middle; }
.bubble::before { content: ''; position: absolute; left: -15px; top: 50%; transform: translateY(-50%); border: 9px solid transparent; border-right-color: white; }
.header-github-link { display: inline-flex; vertical-align: middle; margin-left: 4px; opacity: 0.75; color: white; text-decoration: none; }
.header-github-link:hover { opacity: 1; }

/* `overflow: clip`, not `hidden`: `hidden` would make the view a scroll
   container and trap the in-content sticky stack inside it. */

/* ─── App shell ─────────────────────────────────────────────────────────────── */
#app { background: var(--bg); overflow: clip; flex: 1 1 auto; display: flex; flex-direction: column; }

#add-fab { position: fixed; right: 24px; bottom: 24px; z-index: 40; width: 44px; height: 44px; padding: 0; border: none; border-radius: 50%; background: var(--accent); color: white; font-size: 26px; line-height: 1; box-shadow: 0 4px 14px rgba(0,0,0,0.32); transition: background 0.12s, transform 0.12s, box-shadow 0.12s; }
#add-fab:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 7px 20px rgba(0,0,0,0.38); }
#add-fab:active { transform: translateY(0); box-shadow: 0 3px 10px rgba(0,0,0,0.3); }

/* ─── Wordlist bar ──────────────────────────────────────────────────────────── */
/* z-index above #featured-row (60): the open menu drops over the tool gallery,
   which establishes its own stacking context. */
#wordlist-bar { position: relative; z-index: 61; display: flex; flex-direction: column; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--border2); }
.wls-bar-top { display: flex; align-items: center; gap: 12px; }
.wls { position: relative; min-width: 0; display: flex; }
.wls-trigger { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 360px; padding: 0; font: inherit; line-height: 1.2; color: var(--text); background: none; border: none; cursor: pointer; }
.wls-trigger:hover { color: var(--accent); }
.wls-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.wls-trigger .wordlist-icon { width: 16px; height: 16px; }
.wls-trigger-icon { display: flex; align-items: center; flex-shrink: 0; }
.wls-trigger-label { min-width: 0; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wls-trigger-badge { display: flex; align-items: center; flex-shrink: 0; }
.wls-trigger-badge:empty { display: none; }
.wls-trigger-chevron { flex-shrink: 0; margin-left: 2px; transition: transform 0.15s; }
.wls.open .wls-trigger-chevron { transform: rotate(180deg); }

.wls-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 60; min-width: 240px; max-width: 360px; max-height: 60vh; overflow-y: auto; padding: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.wls:not(.open) .wls-menu { display: none; }
.wls-menu .wordlist-card { border-bottom: none; border-radius: 5px; }
.wls-menu .wordlist-card.selected { border-left: none; padding-left: 14px; }
.wls-menu-section { padding: 6px 10px 3px; font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); user-select: none; }
.wls-menu-section ~ .wls-menu-section { margin-top: 4px; }

.wls-configure-footer { display: flex; align-items: center; justify-content: flex-start; gap: 8px; width: 100%; margin-top: 4px; padding: 9px 10px; font: inherit; color: var(--text); text-align: left; background: none; border: none; border-top: 1px solid var(--border2); border-radius: 0 0 5px 5px; cursor: pointer; }
.wls-configure-footer:hover { background: var(--hover); color: var(--text); }
.wls-configure-footer:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.wls-configure-footer svg { width: 16px; height: 16px; flex-shrink: 0; }

.wls-actions, .wls-dl-slot { display: flex; align-items: center; gap: 8px; }
.wls-actions { flex: 0 0 auto; margin-left: auto; flex-wrap: wrap; }
.wls-actions:empty, .wls-dl-slot:empty, .wls-kebab-slot:empty { display: none; }

/* ─── Splash screen ─────────────────────────────────────────────────────────── */
#splash-screen { position: fixed; inset: 0; z-index: 200; background: var(--bg); color: var(--accent); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 48px; transition: opacity 0.3s; will-change: opacity; }
#splash-screen.done { opacity: 0; pointer-events: none; }
.splash-logo { font-size: 56px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.1; display: inline-flex; align-items: center; opacity: 0; animation: splash-logo-reveal 0.4s ease-out forwards; will-change: opacity; }
.splash-logo .bubble { background: var(--accent); color: var(--bg); font-size: 44px; padding: 3px 20px 6px; border-radius: 16px; margin-left: 27px; }
.splash-logo .bubble::before { left: -45px; border-width: 27px; border-right-color: var(--accent); }
.worm-spinner { display: flex; gap: var(--worm-gap, 10px); --worm-dot: 11px; --worm-rise: -9px; }
.worm-spinner span { width: var(--worm-dot); height: var(--worm-dot); background: var(--accent); border-radius: 50%; animation: worm 1.4s ease-in-out infinite; }
.worm-spinner span:nth-child(2) { animation-delay: 0.2s; }
.worm-spinner span:nth-child(3) { animation-delay: 0.4s; }
@keyframes worm { 0%, 80%, 100% { transform: translateY(0); opacity: 0.45; } 40% { transform: translateY(var(--worm-rise)); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .worm-spinner span { animation: none; opacity: 1; }
}

.splash-spinner { opacity: 0; animation: splash-spinner-reveal 0.4s ease-out 5s forwards; }
@keyframes splash-spinner-reveal { to { opacity: 1; } }

.stream-dots { --worm-dot: 6px; --worm-rise: -5px; --worm-gap: 5px; align-items: flex-end; height: 15px; align-self: center; }
@keyframes splash-logo-reveal { to { opacity: 1; } }

/* ─── Wordlist cards ────────────────────────────────────────────────────────── */
.add-wordlist-icon { font-size: 15px; line-height: 1; width: 16px; text-align: center; flex-shrink: 0; }

/* Wordlist card */
.wordlist-card { padding: 10px 14px; border-bottom: 1px solid var(--border3); cursor: pointer; display: flex; align-items: center; gap: 9px; transition: background 0.1s; }
.wordlist-card:hover { background: var(--hover); }
.wordlist-card.selected { background: var(--sel); border-left: 3px solid var(--accent); padding-left: 11px; }
.card-info { flex: 1; min-width: 0; }
.card-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.card-meta { color: var(--muted); font-size: 11px; margin-top: 2px; display: flex; align-items: center; gap: 5px; }
.card-actions { display: flex; gap: 5px; align-items: center; flex-shrink: 0; }

/* ─── Buttons, inputs & menus ───────────────────────────────────────────────── */
/* Buttons */
button { font-size: 13px; padding: 7px 11px; border-radius: 4px; border: 1px solid var(--border); background: var(--btn-bg); color: var(--text); cursor: pointer; font-family: inherit; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
button:hover:not(:disabled) { background: var(--hover); }
button.primary { background: var(--accent); color: white; border-color: var(--accent); }
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.danger { background: #c0392b; color: white; border-color: #922b21; }
button.danger:hover:not(:disabled) { background: #e74c3c; border-color: #c0392b; }

/* Form inputs — shared chrome; checkboxes, radios, and ranges are excluded so
   they keep native rendering and their focus ring. :where() keeps the base at
   zero specificity so any component rule (invalid states, etc.) still overrides. */
input:where(:not([type="checkbox"], [type="radio"], [type="range"])), select, textarea { background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-radius: 4px; font-family: inherit; font-size: 13px; }
input:where(:not([type="checkbox"], [type="radio"], [type="range"])):focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input:disabled, select:disabled { opacity: 0.5; cursor: not-allowed; }

/* Split button */
.split-btn { position: relative; display: inline-flex; }
.split-btn-main { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: none; }
.split-btn-arrow { border-top-left-radius: 0; border-bottom-left-radius: 0; padding: 5px 8px; display: inline-flex; align-items: center; justify-content: center; }
.split-btn.primary .split-btn-main { background: var(--accent); color: white; border-color: var(--accent); }
.split-btn.primary .split-btn-main:hover:not(:disabled) { background: var(--accent-hover); }
.split-btn.primary .split-btn-arrow { background: var(--accent); color: white; border-color: var(--accent); border-left: 1px solid rgba(255,255,255,0.35); }
.split-btn.primary .split-btn-arrow:hover:not(:disabled) { background: var(--accent-hover); }
.split-btn-menu, .copy-popover { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); z-index: 200; }
.split-btn-menu { position: fixed; inset: auto; margin: 0; padding: 4px 0; overflow: visible; white-space: nowrap; color: var(--text); }
.split-btn-menu button { display: flex; align-items: center; justify-content: flex-start; width: 100%; text-align: left; border: none; background: none; border-radius: 0; padding: 6px 13px; color: var(--text); }
.split-btn-menu button > svg { width: 14px; height: 14px; flex-shrink: 0; margin-right: 8px; }
.split-btn-menu-header { padding: 4px 13px 5px; margin-bottom: 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--faint); border-bottom: 1px solid var(--border2); }
.more-menu-btn { padding-left: 8px; padding-right: 8px; }
.more-menu-btn svg { width: 16px; height: 16px; display: block; }
.more-menu-btn:has(svg) { background: none; border: none; color: var(--text); padding: 4px 6px; }
.more-menu-btn:has(svg):hover:not(:disabled) { background: var(--hover); }
.more-menu-btn.more-menu-labeled { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; padding: 4px 8px; }
.more-menu-btn.more-menu-labeled .more-menu-caret { width: 8px; height: 5px; display: inline-block; }

.copy-popover { position: fixed; display: none; width: 360px; max-width: calc(100vw - 16px); padding: 12px; --copy-arrow-w: 26px; }
.copy-popover.open { display: block; }
.copy-row + .copy-row { margin-top: 12px; }
.copy-row-label { margin-bottom: 4px; }
.copy-row-field { display: flex; gap: 6px; align-items: flex-start; }
.copy-field { flex: 1; min-width: 0; padding: 5px 8px; }
input.copy-field { overflow-x: auto; }
.copy-results { line-height: 1.5; overflow: hidden; resize: none; }
.copy-row-btn { flex: none; }
.copy-row-field > .copy-row-btn { margin-right: calc(var(--copy-arrow-w) - 1px); }
.copy-row-split { flex: none; }
.copy-row-split .split-btn-arrow { width: var(--copy-arrow-w); padding-left: 0; padding-right: 0; }

/* ─── Stats bar & histogram ─────────────────────────────────────────────────── */
#detail-panel { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }


.stats-bar {
  border-bottom: 1px solid var(--border3);
  padding: 10px 18px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px;
  background: var(--surface);
}
.stats-bar-counts { display: flex; align-items: center; gap: 14px; min-width: 0; flex-shrink: 0; }
.stats-bar-distribution { display: flex; align-items: center; gap: 14px; min-width: 0; }
.stats-bar-distribution .range-filter { flex-shrink: 0; }
.stats-bar-controls { display: flex; align-items: center; flex-shrink: 0; justify-self: end; align-self: center; }
/* Coloring (incl. the hover that the base button:hover rule would otherwise win) comes
   from .primary; this only adds the pill shape. */
.results-stale-chip {
  gap: 5px;
  padding: 4px 11px;
  font: inherit; font-size: 12px; font-weight: 600; line-height: 1;
  border: none; border-radius: 999px; white-space: nowrap;
}
.results-stale-chip[hidden] { display: none; }
.results-stale-icon { fill: currentColor; flex-shrink: 0; }
.stats-bar.stats-no-hist .histogram { display: none; }
.stats-bar.stats-no-hist { padding-left: 10px; padding-right: 10px; gap: 8px; }
.stats-bar.stats-no-entries .stat-entries { display: none; }

.sticky-stack { position: sticky; top: 0; z-index: 50; background: var(--surface); }
.sticky-stack > #tool-stack { position: sticky; top: 0; z-index: 53; background: var(--surface); border-bottom: 1px solid var(--border2); }
.sticky-stack > #stats { position: sticky; top: var(--tool-stack-h); z-index: 52; background: var(--surface); }
.sticky-stack > .entry-headers,
.sticky-stack > .group-headers { position: sticky; top: calc(var(--tool-stack-h) + var(--stats-bar-h)); z-index: 51; background: var(--bg); border-bottom: 1px solid var(--border2); }
.sticky-stack .search-bar { border-bottom: none; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { line-height: 1; margin-top: 3px; }
.bar-headline { font-size: 16px; font-weight: 600; }
.stat-entries .stat-value { display: inline-block; min-width: calc(var(--entries-ch, 0) * 1ch); }
.histogram { display: flex; gap: 3px; align-items: stretch; height: 36px; position: relative; cursor: pointer; user-select: none; touch-action: none; flex-shrink: 1; min-width: 80px; }
.histogram-col { width: 7px; display: flex; align-items: flex-end; flex-shrink: 0; }
.histogram-bar { width: 7px; background: var(--score-bg, var(--accent)); border-radius: 2px 2px 0 0; position: relative; z-index: 1; }
.histogram-rect { position: absolute; top: -2px; bottom: -2px; background: var(--accent); opacity: 0.18; border-radius: 4px; pointer-events: none; z-index: 0; transition: left 0.05s ease, width 0.05s ease; }
.histogram-rect[hidden] { display: none; }
html.light-mode .histogram-bar { filter: saturate(1.8) brightness(0.9); }
html.light-mode .histogram-rect { opacity: 0.11; }

/* ─── Search bar ────────────────────────────────────────────────────────────── */
.search-bar { padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--border2); display: grid; grid-template-columns: auto auto auto minmax(0, auto) auto 1fr auto auto; align-items: center; column-gap: 0; row-gap: 6px; position: relative; }
.search-bar > .tool-label { margin-left: 12px; }
.search-bar > .find-replace-caret { margin-left: 4px; }
.search-bar > .tool-row-param-text { padding-left: 12px; }
.search-bar > .find-replace-caret ~ .tool-row-param-text { padding-left: 6px; }
.search-bar > .tool-row-param:not(.tool-row-param-text) { margin-left: 12px; }
.search-bar > .tool-row-asides { margin-left: 12px; }
.search-bar > .tool-row-replace > .tool-row-param-text { grid-column: 4; grid-row: 2; padding-left: 6px; }
.search-bar > .tool-row-replace > .tool-row-asides { grid-column: 5; grid-row: 2; margin-left: 12px; }
/* Collapse, don't remove: dropping this handle from the grid reshuffles the
   auto-placed columns and misaligns the find-replace row under the input. */
.search-bar.solo > .drag-handle { width: 0; padding: 0; overflow: hidden; }
.search-bar.solo > .tool-label { margin-left: 0; }
.range-filter { align-items: flex-start; white-space: nowrap; }

/* ─── Match highlights ──────────────────────────────────────────────────────── */
/* Negative margin cancels the padding's layout width — the highlight box keeps
   its 1px breathing room but a marked character stays exactly as wide as a bare
   one, so a highlighted entry doesn't overflow a column sized to its text. */
mark.search-match { border-radius: 2px; padding: 0 1px; margin: 0 -1px; font-style: normal; }
/* Tool highlight kinds. `removed` marks the character a pair-transform tool
   dropped to get from the a-side to the b-side — strike-through plus a touch
   of opacity reads as "this part was taken away." */
.hl-removed { text-decoration: line-through; opacity: 0.5; }
.hl-ambiguous { background: var(--hl6); color: var(--hl6-fg); border-radius: 2px; padding: 0 1px; margin: 0 -1px; }
.search-match-0 { background: var(--hl0); color: var(--hl0-fg); }
.search-match-1 { background: var(--hl1); color: var(--hl1-fg); }
.search-match-2 { background: var(--hl2); color: var(--hl2-fg); }
.search-match-3 { background: var(--hl3); color: var(--hl3-fg); }
.search-match-4 { background: var(--hl4); color: var(--hl4-fg); }
.search-match-5 { background: var(--hl5); color: var(--hl5-fg); }
.search-match-6 { background: var(--hl6); color: var(--hl6-fg); }
.search-match-7 { background: var(--hl7); color: var(--hl7-fg); }
.search-match-8 { background: var(--hl8); color: var(--hl8-fg); }
mark.find-hit { background: var(--find-bg); color: var(--find-fg); border-radius: 2px; padding: 0 1px; margin: 0 -1px; font-style: normal; }
mark.find-hit.find-current { background: var(--find-current-bg); color: var(--find-current-fg); }

/* Umiaq variable highlights: each variable a stable color (the solver tags ranges
   `umiaq-var-N`) so a tuple's lanes show how their shared chunks line up. */
[class^="hl-umiaq-var-"] { border-radius: 2px; padding: 0 1px; margin: 0 -1px; font-weight: 600; }
.hl-umiaq-var-0 { background: var(--hl0); color: var(--hl0-fg); }
.hl-umiaq-var-1 { background: var(--hl1); color: var(--hl1-fg); }
.hl-umiaq-var-2 { background: var(--hl2); color: var(--hl2-fg); }
.hl-umiaq-var-3 { background: var(--hl3); color: var(--hl3-fg); }
.hl-umiaq-var-4 { background: var(--hl4); color: var(--hl4-fg); }
.hl-umiaq-var-5 { background: var(--hl5); color: var(--hl5-fg); }
.hl-umiaq-var-6 { background: var(--hl6); color: var(--hl6-fg); }
.hl-umiaq-var-7 { background: var(--hl7); color: var(--hl7-fg); }
.hl-umiaq-var-8 { background: var(--hl8); color: var(--hl8-fg); }
/* A highlight ending the entry drops its right bleed: with nothing after the mark
   to absorb the padding-canceling negative margin, its 1px right padding spills
   past the shrink-wrapped cell, and Firefox's text-overflow — which clips at the
   content box, so container padding can't buy it back — lops off the final glyph. */
mark.search-match:last-child,
mark.find-hit:last-child,
.hl-ambiguous:last-child,
[class^="hl-umiaq-var-"]:last-child { padding-right: 0; margin-right: 0; }

/* ─── Entries table ─────────────────────────────────────────────────────────── */
/* The at-rest results display: a single-column list of chain
   rows; each row is a vertical stack of atoms — one per significant transition
   through the tool pipeline — sharing column widths via grid so the eye reads
   straight down each column. */
#entries-table-panel { background: var(--bg); position: relative; }
/* Faded "the results you see are stale, a new run is in flight" treatment —
   the runtime adds .pipeline-running at the start of every run and removes it
   on completion or abort. The visible effects each carry a 100ms
   animation-delay, so a quick run that adds and removes the class within the
   threshold cancels the animations before they ever start — nothing flashes
   on fast keystrokes. The dim lands on #vs-host, not the panel, so the
   spinner overlay stays at full opacity. */
#entries-table-panel.pipeline-running #vs-host {
  animation: pipeline-dim 0.15s ease 0.1s forwards;
}
.pipeline-spinner {
  position: sticky;
  top: calc(var(--sticky-stack-h) + 40px);
  margin: 40px auto -76px;
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  opacity: 0;
  z-index: 5;
  pointer-events: none;
}
#entries-table-panel.pipeline-running .pipeline-spinner {
  animation:
    pipeline-spin 0.8s linear infinite,
    pipeline-reveal 0.15s ease 0.1s forwards;
}
#entries-table-panel.pipeline-running {
  animation: pipeline-room 0.15s linear 0.1s forwards;
}
@keyframes pipeline-dim    { to { opacity: 0.55; } }
@keyframes pipeline-reveal { to { opacity: 1; } }
@keyframes pipeline-spin   { to { transform: rotate(360deg); } }
@keyframes pipeline-room   { to { min-height: 96px; } }
@media (prefers-reduced-motion: reduce) {
  #entries-table-panel.pipeline-running .pipeline-spinner {
    animation: pipeline-reveal 0.15s ease 0.1s forwards;
  }
}
/* Streamed survivors arrive live, not stale, so the dim and ring (which signal
   "results are stale, a run is in flight") are wrong here. The stats-bar stream
   dots carry the in-progress signal instead. */
#entries-table-panel.pipeline-running.pipeline-streaming #vs-host { animation: none; opacity: 1; }
#entries-table-panel.pipeline-running.pipeline-streaming .pipeline-spinner { animation: none; opacity: 0; }
.progress-ring {
  position: sticky;
  top: calc(var(--sticky-stack-h) + 40px);
  display: block;   /* an inline <svg> ignores margin:auto — block centers it like the spinner */
  margin: 40px auto -76px;
  width: 36px; height: 36px;
  transform: rotate(-90deg);
  opacity: 0;
  z-index: 5;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.progress-ring circle { fill: none; stroke-width: 3; }
.progress-ring-track { stroke: var(--border); }
.progress-ring-fill {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 100.53px;
  stroke-dashoffset: calc(100.53px - 100.53px * var(--progress, 0));
  transition: stroke-dashoffset 0.2s linear;
}
#entries-table-panel.pipeline-running.has-progress .pipeline-spinner { animation: none; opacity: 0; }
#entries-table-panel.pipeline-running.has-progress .progress-ring { opacity: 1; }
#entries-table-panel.pipeline-running.pipeline-streaming .progress-ring { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .progress-ring-fill { transition: none; } }
#vs-host { position: relative; }
/* No text selection in the rows: a drag is a row-select gesture (see _onRowMouseDown),
   not a text highlight. Copy/Export cover getting entry text out. */
.entries-table-rows { position: relative; user-select: none; }
.entry-row, .entry-headers {
  display: grid;
  grid-template-columns: var(--count-w, 2ch) var(--entry-w, 12ch) var(--len-w, 3ch) var(--score-w, calc(5ch + 12px));
  grid-auto-rows: var(--row-height, 24px);
  align-items: center;
  column-gap: 14px;
  padding: 0 16px;
  white-space: nowrap;
}
/* Font isolated into its own class so off-screen measurement probes can size
   text in the exact face the rows / headers render with. */
.entry-row-font { font-family: var(--font-mono); font-size: 13px; }
.entry-headers-font { font-family: var(--font-sans); font-size: 12px; }
.text-probe { position: absolute; visibility: hidden; white-space: pre; }
/* A row's height is content-driven (atom count × row height): it's a
   position:absolute box with no fixed height, and grid-auto-rows sizes each
   atom's line. The virtual scroller's stride math mirrors that product. */
.entry-row {
  position: absolute; left: 0; right: 0;
  box-shadow: inset 0 -1px 0 var(--border3);
  scroll-margin-top: var(--sticky-stack-h);
  scroll-margin-bottom: 8px;
}
/* Plain, unclickable column labels above the rows. Sit at the bottom of the
   sticky-stack so they ride along with stats/tools/search on scroll. The
   slot-width vars are computed in pixels (see _computeSlotWidths) so the
   header's sans font and the row's mono font produce identical track widths. */
.entry-headers {
  color: var(--muted);
  user-select: none;
}
.entry-headers > * { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.entry-headers .col-len, .entry-headers .col-score { text-align: right; }
.entry-headers .col-comment, .entry-headers .col-source { display: none; }
.entry-headers .col-sort, .group-headers .col-sort { cursor: pointer; border-radius: 3px; }
.entry-headers .col-sort:hover, .group-headers .col-sort:hover { color: var(--text); }
.entry-headers .col-sort:focus-visible, .group-headers .col-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.col-sort .sort-rank { margin-left: 2px; font-size: 9px; font-weight: 700; vertical-align: super; color: var(--accent); font-variant-numeric: tabular-nums; }
.entry-row:hover { background: var(--row-hover); }
.entry-row.active { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.entry-row.selected { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.entry-row.selected:hover { background: color-mix(in srgb, var(--accent) 26%, transparent); }
/* Focus lives on the listbox but is shown on the cursor row (aria-activedescendant),
   so the container's own outline is suppressed in favor of the row ring below. */
.entries-table-rows:focus, .entries-table-rows:focus-visible { outline: none; }
.entries-table-rows:focus .entry-row.cursor { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 2px; }

.entry-row.run-member::before {
  content: '';
  position: absolute;
  left: 6px; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
  opacity: 0.4;
}
.entry-row.run-start::before { top: 4px; border-top-left-radius: 2px; border-top-right-radius: 2px; }
.entry-row.run-end::before { bottom: 4px; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; }

@keyframes skeleton-shimmer { to { background-position: -200% 0; } }
.skeleton-bar {
  height: 10px; border-radius: 3px;
  background: linear-gradient(90deg, var(--surface) 0%, var(--border2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .skeleton-bar { animation: none; background: var(--border3); }
}
/* `.atom` is display:contents — its cells participate directly in the
   .entry-row grid. Explicit grid-column on each cell lets atoms past the
   first wrap onto their own grid row while staying column-aligned with the
   atom above. */
.atom { display: contents; }
.entry-row .atom-count { grid-column: 1; grid-row: 1; text-align: right; color: var(--faint); font-family: var(--font-sans); font-size: 12px; }
.entry-row .atom-entry { grid-column: 2; justify-self: start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; min-width: 0; cursor: pointer; }
.entry-row .atom-len { grid-column: 3; text-align: right; font-family: var(--font-sans); font-size: 12px; }
.entry-row .atom-score { grid-column: 4; cursor: pointer; justify-self: end; }
.atom-score-raw { color: var(--muted); }
.atom-score-arrow { color: var(--faint); padding: 0 4px; }
.entry-row .atom-comment { grid-column: 5; overflow: hidden; text-overflow: ellipsis; min-width: 0; font-family: var(--font-sans); font-size: 12px; }
.entry-row .atom-source  { grid-column: 6; min-width: 0; align-self: stretch; align-items: stretch; gap: 5px; }
.src-slot { flex: 0 0 16px; display: inline-flex; align-items: center; justify-content: center; }
.src-slot--muted .wordlist-icon { filter: grayscale(1); opacity: 0.2; }
.entry-row:hover .src-slot--muted .wordlist-icon { opacity: 1; }
/* Relation glyph (→, ↔, ⊃) prefixing every non-originator atom's entry. */
.atom-glyph { color: var(--faint); user-select: none; }
.entry-row .atom-comment, .entry-row .atom-source { display: none; }

.entry-row .atom-tool { display: none; }
#detail-panel.has-tool-col .entry-row .atom-tool { display: block; grid-column: 5; font-size: 12px; color: var(--muted); }
#detail-panel.has-tool-col .entry-row .atom-comment { grid-column: 6; }
#detail-panel.has-tool-col .entry-row .atom-source  { grid-column: 7; }
#detail-panel.has-tool-col .entry-row, #detail-panel.has-tool-col .entry-headers {
  grid-template-columns: var(--count-w, 2ch) var(--entry-w, 12ch) var(--len-w, 3ch) var(--score-w, calc(5ch + 12px)) var(--toolcol-w, 6ch);
}

/* Comment + source columns appear on every chain shape — a one-atom row and a
   stacked multi-atom row alike — when the viewport has room. They render
   per-atom: each atom line carries its own comment and source, so a chain row
   reads top-to-bottom as where every word in the journey comes from. The two
   columns drop staggered as the viewport narrows: source goes first, leaving the
   more informative comment column longer. */
@media (min-width: 760px) {
  .entry-row, .entry-headers {
    grid-template-columns: var(--count-w, 2ch) var(--entry-w, 12ch) var(--len-w, 3ch) var(--score-w, calc(5ch + 12px)) minmax(0, 1fr);
  }
  .entry-row .atom-comment, .entry-headers .col-comment { display: block; }
  #detail-panel.has-tool-col .entry-row, #detail-panel.has-tool-col .entry-headers {
    grid-template-columns: var(--count-w, 2ch) var(--entry-w, 12ch) var(--len-w, 3ch) var(--score-w, calc(5ch + 12px)) var(--toolcol-w, 6ch) minmax(0, 1fr);
  }
}
@media (min-width: 960px) {
  .entry-row, .entry-headers {
    grid-template-columns: var(--count-w, 2ch) var(--entry-w, 12ch) var(--len-w, 3ch) var(--score-w, calc(5ch + 12px)) minmax(0, 1fr) minmax(0, var(--source-max, 22ch));
  }
  .entry-headers .col-source { display: block; }
  .entry-row .atom-source { display: flex; }
  #detail-panel.has-tool-col .entry-row, #detail-panel.has-tool-col .entry-headers {
    grid-template-columns: var(--count-w, 2ch) var(--entry-w, 12ch) var(--len-w, 3ch) var(--score-w, calc(5ch + 12px)) var(--toolcol-w, 6ch) minmax(0, 1fr) minmax(0, var(--source-max, 22ch));
  }
}

@media (max-width: 480px) {
  .entry-row, .entry-headers {
    grid-template-columns: var(--entry-w, 12ch) var(--len-w, 3ch) var(--score-w, calc(5ch + 12px));
  }
  .entry-row .atom-count, .entry-headers > *:nth-child(1) { display: none; }
  .entry-row .atom-entry { grid-column: 1; }
  .entry-row .atom-len   { grid-column: 2; }
  .entry-row .atom-score { grid-column: 3; }
  #detail-panel.has-tool-col .entry-row, #detail-panel.has-tool-col .entry-headers {
    grid-template-columns: var(--entry-w, 12ch) var(--len-w, 3ch) var(--score-w, calc(5ch + 12px)) var(--toolcol-w, 6ch);
  }
  #detail-panel.has-tool-col .entry-row .atom-tool { grid-column: 4; }
  .group-rownum { display: none; }
}

/* ─── Group rows ────────────────────────────────────────────────────────────── */
.group-row, .group-headers {
  display: flex; align-items: flex-start;
  gap: 14px;
  padding: 0 16px;
  white-space: nowrap;
}
.group-row {
  position: absolute; left: 0; right: 0;
  box-shadow: inset 0 -1px 0 var(--border3);
}
.group-row:hover { background: var(--row-hover); }
.group-row.active { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.group-headers {
  color: var(--muted);
  user-select: none;
}
.group-rownum, .group-count, .group-col, .group-entries-label {
  font-family: var(--font-sans); font-size: 12px;
  height: var(--row-height, 24px);
  line-height: var(--row-height, 24px);
}
.group-rownum, .group-count, .group-col { flex: none; text-align: right; }
.group-entries-label { flex: 1; }
.group-rownum { min-width: var(--group-rownum-w, 2ch); color: var(--faint); }
.group-count  { min-width: var(--group-count-w, 2ch); }
.group-chains {
  flex: 1; display: flex; gap: 18px;
  min-width: 0; overflow: hidden;
  position: relative;
}
.group-chains.is-clipped {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 80px), transparent calc(100% - 60px));
          mask-image: linear-gradient(to right, #000 calc(100% - 80px), transparent calc(100% - 60px));
}
.group-chain {
  flex: none;
  display: grid;
  grid-template-columns: max-content max-content;
  grid-auto-rows: var(--row-height, 24px);
  column-gap: 5px;
  align-items: center;
}
.group-chain .atom { display: contents; }
.group-chain .atom-entry { cursor: pointer; }
.group-chain .atom-score { cursor: pointer; }
.group-chain .atom-noedit { cursor: default; }
.group-chain.skeleton {
  display: flex; align-items: center;
  height: var(--row-height, 24px); width: 64px;
}
.group-chain.skeleton .skeleton-bar { width: 100%; }
.group-anchor {
  flex: none;
  min-width: var(--group-anchor-w, 0);
}
.group-headers .group-anchor {
  font-family: var(--font-sans); font-size: 12px;
  height: var(--row-height, 24px);
  line-height: var(--row-height, 24px);
  text-align: right;
}
.group-row .group-anchor {
  display: grid;
  grid-template-columns: max-content max-content;
  grid-auto-rows: var(--row-height, 24px);
  column-gap: 5px;
  align-items: center;
  justify-content: end;
}
.group-row .group-anchor .atom { display: contents; }
.group-row .group-anchor .atom-entry { cursor: pointer; overflow: hidden; text-overflow: ellipsis; }
.group-row .group-anchor .atom-score { cursor: pointer; }
.group-more {
  position: absolute; right: 12px; top: 0;
  height: var(--row-height, 24px);
  border: none; cursor: pointer;
  background: var(--surface); color: var(--muted);
  font-family: var(--font-sans); font-size: 11px;
  padding: 1px 7px; border-radius: 10px;
}
.group-more:hover { color: var(--text); }
.group-more[hidden] { display: none; }
.group-popover {
  position: fixed; z-index: 600;
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 7px 18px;
  max-width: 340px; max-height: 280px; overflow-y: auto;
  padding: 10px 13px;
  background: var(--bg); border: 1px solid var(--border2);
  border-radius: 8px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}
.group-popover-sentinel { flex-basis: 100%; height: 1px; }

/* ─── Find bar ──────────────────────────────────────────────────────────────── */
/* Appended into .sticky-stack (entries-table.js) — viewport-fixed offsets look
   right when scrolled but land over the gallery at page top. */
.find-bar {
  position: absolute;
  top: calc(100% + 8px);
  right: 16px;
  z-index: 60;
  display: flex; align-items: center; gap: 4px;
  padding: 5px 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow);
}
.find-bar[hidden] { display: none; }
.find-input-wrap { position: relative; display: inline-flex; align-items: center; }
.find-input {
  width: 210px; padding: 4px 68px 4px 8px; font-size: 13px;
  color: var(--text); background: var(--input-bg);
  border: 1px solid var(--border); border-radius: 5px;
}
.find-input:focus { border-color: var(--accent); outline: none; }
.find-input.find-nomatch { border-color: var(--err-fg); }
.find-count { position: absolute; right: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; pointer-events: none; }
.find-bar button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0; font-size: 13px; line-height: 1;
  color: var(--muted); background: none; border: none; border-radius: 4px; cursor: pointer;
}
.find-bar button:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.find-bar button:disabled { opacity: 0.35; cursor: default; }
.entries-footer { padding: 0 22px 36px; color: var(--muted); font-size: 14px; text-align: center; font-style: italic; }
.entries-footer p { margin: 0; padding-top: 36px; }
.entries-footer-btn { display: inline; padding: 0; font: inherit; color: var(--accent); background: none; border: none; cursor: pointer; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.entries-footer-btn:hover { color: var(--accent-hover); }

/* ─── Entry panel ───────────────────────────────────────────────────────────── */
#entry-panel-backdrop { position: fixed; inset: 0; z-index: 599; background: var(--backdrop); opacity: 0; pointer-events: none; transition: opacity 0.28s ease; }
#entry-panel-backdrop.open { opacity: 1; pointer-events: auto; }
#entry-panel { position: fixed; z-index: 600; top: 0; right: 0; bottom: 0; width: var(--entry-panel-w); display: none; flex-direction: column; background: var(--surface); border-left: 1px solid var(--border); box-shadow: -6px 0 24px rgba(0,0,0,0.32); color: var(--text); transform: translateX(100%); transition: transform 0.28s ease, display 0.28s allow-discrete; }
#entry-panel.open { display: flex; transform: translateX(0); }
@starting-style { #entry-panel.open { transform: translateX(100%); } }
/* The scrim is created and opened in one task, so without a starting value it has no
   prior computed style to transition from and the dim snaps while the panel slides. */
@starting-style { #entry-panel-backdrop.open { opacity: 0; } }
#entry-panel.no-anim, #entry-panel-backdrop.no-anim { transition: none; }
.entry-panel-header { flex: none; position: relative; padding: 12px 14px; border-bottom: 1px solid var(--border2); }
.entry-panel-body { flex: 1 1 auto; overflow-y: auto; padding: 12px 14px; font-size: 11px; }

.entry-panel-titlerow { display: flex; align-items: center; gap: 10px; padding-right: 24px; }
.entry-panel-nav { display: flex; align-items: center; gap: 4px; }
.entry-panel-prev, .entry-panel-next { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; border: none; border-radius: 4px; background: none; color: var(--muted); cursor: pointer; }
.entry-panel-prev:hover:not(:disabled), .entry-panel-next:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.entry-panel-prev:disabled, .entry-panel-next:disabled { opacity: 0.35; cursor: default; }
.entry-walk-caret { display: block; flex-shrink: 0; width: 12px; height: 8px; fill: none; stroke: currentColor; pointer-events: none; }
.entry-walk-caret--up { transform: rotate(180deg); }
.entry-panel-walkpos { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); }

.entry-panel-close-back { display: none; }
.entry-panel-title { font-size: 16px; font-weight: 700; color: var(--text); margin: 0; }
/* Grid so Entry sizes to its content before Comment gets the rest (table layout
   squeezes the lone auto column first). Grid display strips table semantics in
   some engines; the ARIA roles in the markup restore them. */
.entry-panel-prov { display: grid; grid-template-columns: auto auto auto minmax(0, 1fr) auto auto; }
.entry-panel-prov thead, .entry-panel-prov tbody, .entry-panel-prov tr { display: contents; }
.entry-panel-prov th { text-align: left; font-weight: 600; color: var(--muted); padding: 2px 8px 4px 0; border-bottom: 1px solid var(--border3); white-space: nowrap; }
.entry-panel-prov td { padding: 3px 8px 3px 0; vertical-align: top; border-bottom: 1px solid var(--border3); }
.entry-panel-prov tr:last-child td { border-bottom: none; }
.entry-panel-prov .entry-panel-prov-mark { padding-right: 4px; }
.entry-panel-prov-winner { color: var(--accent); font-size: 11px; cursor: default; }
.entry-panel-prov-entry { color: var(--text); overflow-wrap: anywhere; }
td.entry-panel-prov-entry { font-family: var(--font-mono); }
/* Hidden bold copy: staging bolds a row, and Firefox's synthesized bold is wider. */
td.entry-panel-prov-entry::after { content: attr(data-text); display: block; height: 0; overflow: hidden; visibility: hidden; font-weight: 700; }
.entry-panel-prov-score { white-space: nowrap; text-align: right; }
.entry-panel-prov th.entry-panel-prov-score { text-align: right; }
.entry-panel-prov-comment { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-panel-prov-source { white-space: nowrap; }
.entry-panel-prov-row--disabled td,
.entry-panel-prov-row--muted td { color: var(--faint); }
.entry-panel-prov-row--disabled .wordlist-icon,
.entry-panel-prov-row--muted .wordlist-icon { filter: grayscale(1); opacity: 0.6; }
.entry-panel-prov-row--disabled .score-badge,
.entry-panel-prov-row--muted .score-badge { opacity: 0.55; }
.entry-panel-prov-row--added td, .entry-panel-prov-row--changed td { font-weight: 700; }
.entry-panel-prov-row--deleted td { text-decoration: line-through; color: var(--faint); }
.entry-panel-prov-row--deleted .score-badge { opacity: 0.55; }
/* The two ↳ lines under Entry — the exists note and the rename hint — are one
   visual thing: muted sentence, accented link. They stay styled as a pair so a
   panel showing either reads the same. */
.entry-panel-note-slot, .entry-panel-suggest-slot { grid-column: 2 / -1; margin-top: -2px; }
.entry-panel-note-slot:empty, .entry-panel-suggest-slot:empty { display: none; }
.entry-panel-note, .entry-panel-suggest { color: var(--muted); }
.entry-panel-note::before, .entry-panel-suggest::before { content: '↳'; margin-right: 5px; }
.entry-panel-note-link, .entry-panel-suggest-link { font: inherit; color: var(--accent); background: none; border: none; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.entry-panel-note-link:hover, .entry-panel-suggest-link:hover { text-decoration: none; }
.entry-panel-prov-action { white-space: nowrap; text-align: right; }
.entry-panel-prov-reserve { visibility: hidden; }
.entry-panel-prov-trash-reserve { display: inline-block; padding: 2px 4px; line-height: 0; }
.entry-panel-prov-trash { position: relative; background: none; border: none; padding: 2px 4px; line-height: 0; border-radius: 4px; color: var(--muted); cursor: pointer; }
.entry-panel-prov-trash:hover { color: #e53935; background: rgba(229, 57, 53, 0.1); }
.entry-panel-prov-trash.staged { color: #e53935; }
.entry-panel-prov-trash.staged::after { content: ''; position: absolute; left: 1px; right: 1px; top: 50%; height: 1.5px; border-radius: 1px; background: currentColor; transform: rotate(-45deg); }
.entry-panel-fields { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: center; font-size: 13px; margin-bottom: 2px; }
.entry-panel-fields label { color: var(--muted); }
.entry-panel-fields input { padding: 4px 7px; border-radius: 3px; width: 100%; box-sizing: border-box; }
.entry-panel-fields input:read-only { background: var(--bg); color: var(--text); cursor: default; }
.entry-panel-fields input.score-input { font-family: var(--font-mono); max-width: 8ch; }
.entry-panel-score-row { display: flex; align-items: center; gap: 24px; }
.entry-panel-length { display: inline-flex; gap: 10px; color: var(--muted); white-space: nowrap; }
.entry-panel-length-value { color: var(--text); }
.score-combo { position: relative; display: inline-flex; align-items: stretch; }
.entry-panel-fields .score-combo .score-input { flex: none; width: 8ch; max-width: none; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.score-combo .score-input { appearance: textfield; -moz-appearance: textfield; }
.score-combo .score-input::-webkit-inner-spin-button,
.score-combo .score-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.score-combo-toggle { flex: none; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; width: 22px; padding: 0; color: var(--muted); background: var(--input-bg); border: 1px solid var(--border); border-left: none; border-radius: 0 3px 3px 0; cursor: pointer; }
.score-combo-toggle:hover:not(:disabled) { color: var(--text); background: var(--hover); }
.score-combo-toggle:disabled { opacity: 0.5; cursor: default; }
.score-combo .score-input:focus + .score-combo-toggle { border-color: var(--accent); }
.score-combo-chevron { transition: transform 0.15s ease; }
.score-combo-toggle[aria-expanded="true"] .score-combo-chevron { transform: rotate(180deg); }
.score-combo--bare .score-combo-toggle,
.score-combo--bare .score-combo-list { display: none; }
.score-combo-list { position: absolute; top: calc(100% + 4px); left: 0; z-index: 5; max-width: min(320px, calc(100dvw - 28px)); max-height: 240px; }
.score-combo-list[hidden] { display: none; }
.entry-panel-foot { flex: none; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--border2); }
.entry-panel-adopt:empty { display: none; }
.entry-panel-adopt-btn { padding: 2px 0; border: none; background: none; color: var(--muted); font: inherit; cursor: pointer; }
.entry-panel-adopt-btn:hover { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.entry-panel-cancel, .entry-panel-close { margin-left: auto; }
.entry-panel-cancel, .entry-panel-close, .entry-panel-save { font: inherit; padding: 4px 12px; border-radius: 4px; cursor: pointer; }
.entry-panel-cancel, .entry-panel-close { background: none; border: 1px solid var(--border); color: var(--text); }
.entry-panel-cancel:hover, .entry-panel-close:hover { background: var(--hover); }
.entry-panel-save { background: var(--accent); border: 1px solid var(--accent); color: white; }
.entry-panel-save:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.entry-panel-save:disabled { opacity: 0.5; cursor: not-allowed; }
.entry-panel-foot:not(.dirty) .entry-panel-cancel,
.entry-panel-foot:not(.dirty) .entry-panel-save { display: none; }
.entry-panel-foot.dirty .entry-panel-close { display: none; }

.entry-panel-foot.nudge .entry-panel-cancel,
.entry-panel-foot.nudge .entry-panel-save { animation: entry-foot-shake 0.4s ease-in-out; }
@keyframes entry-foot-shake {
  0%, 100%  { transform: translateX(0); }
  20%, 60%  { transform: translateX(-4px); }
  40%, 80%  { transform: translateX(4px); }
}
@media (prefers-reduced-motion: reduce) {
  .entry-panel-foot.nudge .entry-panel-cancel,
  .entry-panel-foot.nudge .entry-panel-save { animation: none; box-shadow: 0 0 0 2px var(--accent); }
}

/* The 0fr/1fr row IS the height transition — `height: auto` does not interpolate. The
   children below use padding, not margin, because margin escapes `overflow: hidden` and
   leaves a collapsed block a few pixels tall. */
/* Awaiting the corpus build: the fields are disabled and empty, which alone reads
   as "this entry has no score" rather than "not loaded yet". */
#entry-panel.seed-pending .score-input,
#entry-panel.seed-pending .comment-input {
  background: linear-gradient(90deg, var(--surface) 0%, var(--border2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
  color: transparent;
}
@media (prefers-reduced-motion: reduce) {
  #entry-panel.seed-pending .score-input,
  #entry-panel.seed-pending .comment-input { animation: none; background: var(--border3); }
}
.entry-panel-prov-skel .skeleton-bar { margin-bottom: 5px; }
.entry-panel-prov-skel .skeleton-bar:nth-child(2) { width: 88%; }
.entry-panel-prov-skel .skeleton-bar:nth-child(3) { width: 74%; }
.entry-panel-prov-skel .skeleton-bar:nth-child(4) { width: 81%; margin-bottom: 0; }

.entry-panel-async { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows 0.18s ease, opacity 0.18s ease; }
.entry-panel-async.revealed { grid-template-rows: 1fr; opacity: 1; }
/* padding-bottom clears the focus outline on a bottom-row family item, which the
   overflow above would otherwise clip. */
.entry-panel-async > * { overflow: hidden; min-height: 0; padding-top: 10px; padding-bottom: 3px; }
@media (prefers-reduced-motion: reduce) {
  .entry-panel-async { transition: none; }
}

.entry-panel-lookup { color: var(--text); line-height: 1.45; }
.entry-family-list { line-height: 1.9; }
.entry-family-item { cursor: pointer; white-space: nowrap; }
.entry-family-item:hover .entry-family-entry { color: var(--accent); text-decoration: underline; }
.entry-family-item:focus-visible,
.entry-family-more:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 3px; }
.entry-family-item--current { font-weight: 700; cursor: default; }
.entry-family-item--current:hover .entry-family-entry { color: inherit; text-decoration: none; }
.entry-family-more { border: none; background: none; padding: 0; font: inherit; cursor: pointer; }
.lookup-alt-note { color: var(--muted); font-style: italic; font-size: 10px; margin-bottom: 6px; }
.lookup-sec { margin-bottom: 10px; }
.lookup-sec:last-child { margin-bottom: 0; }
.lookup-sec-head { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 3px; }
.lookup-prose-title, .lookup-def-head { font-weight: 700; margin-bottom: 4px; }
.lookup-prose { display: flex; gap: 10px; }
.lookup-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.lookup-prose-body { min-width: 0; }
.lookup-prose-desc { color: var(--muted); font-size: 10px; margin-bottom: 2px; }
.lookup-prose p { margin: 4px 0; }
.lookup-phon { color: var(--muted); font-weight: 400; font-family: var(--font-mono); }
.lookup-def { margin-bottom: 6px; }
.lookup-pos { font-style: italic; color: var(--muted); }
.lookup-def ol { margin: 2px 0 0; padding-left: 18px; }
.lookup-def li { margin-bottom: 2px; }
.lookup-links { display: flex; flex-wrap: wrap; gap: 10px; }
.lookup-more, .lookup-link { color: var(--accent); text-decoration: none; }
.lookup-more:hover, .lookup-link:hover { text-decoration: underline; }

input.entry-input { font-family: var(--font-mono); }

/* ─── Score badges & popup menus ────────────────────────────────────────────── */
.score-badge { display: inline-block; padding: 1px 5px; border-radius: 3px; font-size: 11px; font-weight: 700; font-family: var(--font-mono); background: var(--score-bg); color: var(--score-fg); }
.score-none { display: inline-block; padding: 1px 5px; font-size: 11px; font-family: var(--font-mono); color: var(--faint); cursor: default; }

/* Score quick-pick listbox */
.score-listbox { margin: 0; padding: 4px; list-style: none; outline: none; font-size: 12px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,0.2); min-width: 200px; overflow-y: auto; }
#score-picker { position: fixed; z-index: 600; max-width: 340px; max-height: calc(100dvh - 16px); }
.score-picker-opt { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 5px; cursor: pointer; }
.score-picker-opt:hover:not(.active) { background: var(--hover); }
.score-picker-opt.active { background: var(--accent); color: white; }
.score-picker-badge { flex: none; width: var(--badge-col); text-align: right; }
.score-picker-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-picker-hint { flex: none; margin-left: 8px; color: var(--muted); font-family: var(--font-mono); font-size: 11px; font-variant-numeric: tabular-nums; }
.score-picker-opt.active .score-picker-hint { color: rgba(255, 255, 255, 0.8); }

@media (max-width: 759px) {
  #score-picker {
    top: auto; right: 0; bottom: 0; left: 0;
    width: auto; min-width: 0; max-width: none;
    max-height: 70dvh; padding: 8px;
    border-radius: 14px 14px 0 0;
    transform: translateY(100%);
    transition: transform 0.28s ease;
  }
  #score-picker:not([hidden]) { transform: translateY(0); }
  @starting-style { #score-picker:not([hidden]) { transform: translateY(100%); } }
  .score-picker-opt { padding: 11px 12px; }
}

/* Per-column sort menu */
#sort-menu { position: fixed; z-index: 600; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,0.2); padding: 4px; font-size: 12px; color: var(--text); min-width: 150px; max-height: calc(100dvh - 16px); overflow-y: auto; }
.menu-header { padding: 2px 9px 5px; margin-bottom: 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--faint); border-bottom: 1px solid var(--border2); }
.menu-list { list-style: none; margin: 0; padding: 0; outline: none; }
.sort-menu-opt { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 5px 9px; border-radius: 5px; cursor: pointer; white-space: nowrap; }
.sort-menu-opt:hover:not(.active) { background: var(--hover); }
.sort-menu-opt.active { background: var(--accent); color: white; }
.sort-menu-arrow { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.sort-menu-opt.active .sort-menu-arrow { color: rgba(255, 255, 255, 0.85); }

@media (max-width: 759px) {
  #sort-menu {
    top: auto; right: 0; bottom: 0; left: 0;
    width: auto; min-width: 0; max-width: none;
    max-height: 70dvh; padding: 8px;
    border-radius: 14px 14px 0 0;
    transform: translateY(100%);
    transition: transform 0.28s ease;
  }
  #sort-menu:not([hidden]) { transform: translateY(0); }
  @starting-style { #sort-menu:not([hidden]) { transform: translateY(100%); } }
  .sort-menu-opt { padding: 11px 12px; }
}

/* ─── Wordlist actions & reorder ────────────────────────────────────────────── */
.detail-date { font-size: 11px; color: var(--muted); white-space: nowrap; }
/* On narrow viewports the actions bar is cramped; drop the "Last updated"
   label entirely. */
@media (max-width: 759px) {
  .detail-date { display: none; }
  .header-byline-group { display: none; }
  /* Touch-comfortable field height lives on the inputs, not the grid rows: a
     row-level floor would also inflate the note/hint rows, which must stay
     collapsed to their text. */
  .entry-panel-fields input { min-height: 30px; }
}
.edit-hint { opacity: 0; flex-shrink: 0; cursor: pointer; user-select: none; transition: opacity 0.15s; }

/* Drag handle */
.drag-handle { color: var(--faint); cursor: grab; font-size: 13px; flex-shrink: 0; padding: 0 1px; user-select: none; touch-action: none; }
.drag-handle:hover { color: var(--muted); }
.drag-handle[aria-hidden] { visibility: hidden; }
.drag-handle:not([aria-hidden]):active { cursor: grabbing; }
/* A viewport-pinned clip box for the drag ghost. overflow: hidden keeps a wide
   ghost dragged past the edge from extending the page (spurious scrollbar);
   pointer-events: none lets elementFromPoint reach the drop targets through it. */
.drag-ghost-layer { position: fixed; inset: 0; z-index: 1000; overflow: hidden; pointer-events: none; }
/* Scoped under the layer so position:absolute outweighs a cloned item's own
   position — .tool-row sets position:relative later in this sheet and would
   otherwise win on source order, stranding the ghost in normal flow (invisible). */
.drag-ghost-layer .drag-ghost { position: absolute; box-sizing: border-box; opacity: 0.95; background: var(--surface); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.wordlist-card.dragging { opacity: 0.4; }
.drop-line { position: absolute; height: 2px; background: var(--accent); border-radius: 1px; box-shadow: 0 0 6px color-mix(in srgb, var(--accent) 55%, transparent); }
.drop-line[hidden] { display: none; }
/* Suppress the browser's horizontal swipe-to-go-back (and pull-to-refresh) for the
   duration of a reorder drag. Reproduces only on touch, so a desktop dev removing
   this won't see the regression — it bites mobile silently. Toggled by makeReorderable. */
html.reorder-dragging { overscroll-behavior: none; }

/* ─── Toggles & settings ────────────────────────────────────────────────────── */
/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 28px; height: 16px; flex-shrink: 0; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider { position: absolute; inset: 0; background: var(--faint); border-radius: 16px; transition: background 0.2s; }
.toggle-slider::before { content: ''; position: absolute; height: 12px; width: 12px; left: 2px; bottom: 2px; background: white; border-radius: 50%; transition: transform 0.2s; }
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(12px); }


/* Settings and help buttons */
.header-icon-btn { background: none; border: none; color: white; font-size: 19px; padding: 4px 8px; border-radius: 4px; cursor: pointer; line-height: 1; font-family: inherit; display: inline-flex; align-items: center; justify-content: center; }
button.header-icon-btn:hover:not(:disabled) { background: var(--hdr-bg-dark); color: white; }
#btn-settings svg { position: relative; top: 1px; }
#btn-help { width: 32px; height: 32px; padding: 0; border-radius: 4px; background: none; }
.icon { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; }
.help-circle { border-radius: 50%; background: white; color: var(--accent); font-size: 12px; font-weight: 800; }

/* Settings dialog */
#settings-dialog { --dialog-w: 340px; }
#edits-conflict-dialog { --dialog-w: 460px; }
.merge-entries-conflict { max-height: 200px; overflow: auto; margin: 4px 0 0; font-size: 12px; }
.splash-reconnect { display: flex; flex-direction: column; gap: 8px; align-items: stretch; min-width: 280px; }
.splash-reconnect.animated { opacity: 0; animation: splash-reconnect-reveal 0.4s ease-out 0.5s forwards; }
@keyframes splash-reconnect-reveal { to { opacity: 1; } }
.splash-reconnect-intro { margin: 0 0 4px; text-align: center; color: var(--muted); font-size: 13px; }
.splash-reconnect-skip { margin-top: 18px; background: none; border: none; color: var(--faint); font-size: 12px; text-decoration: underline; cursor: pointer; font-family: inherit; align-self: center; }
.splash-reconnect-skip:hover { color: var(--muted); }
.dialog-footer-split { justify-content: space-between; }
.merge-entry-row { padding: 4px 0; color: var(--muted); }
.merge-entry-row b { color: var(--text); margin-right: 6px; }
#confirm-dialog, #alert-dialog { --dialog-w: 320px; }
#merge-conflict-dialog { --dialog-w: 380px; }
#sync-dialog { --dialog-w: 440px; }
.sync-diagram { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 6px 0 18px; }
.sync-diagram-icon { width: 28px; height: 28px; flex-shrink: 0; }
.sync-diagram-emoji { font-size: 24px; line-height: 1; flex-shrink: 0; }
.sync-diagram-arrow { color: var(--accent); font-weight: 700; font-size: 20px; line-height: 1; flex-shrink: 0; }
.sync-dialog-lead { line-height: 1.5; color: var(--text); margin: 0 0 16px; }
.sync-dialog-note { display: flex; align-items: flex-start; gap: 7px; line-height: 1.45; font-size: 13px; margin: -6px 0 16px; }
.sync-dialog-note-icon { flex-shrink: 0; }
.sync-dialog-note.attention { color: var(--warn-fg); }
.sync-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.sync-dialog-help { font-size: 12px; text-align: center; margin: 16px 0 0; }
.sync-dialog-help a { color: var(--accent); text-decoration: none; }
.sync-dialog-help a:hover { text-decoration: underline; }
.sync-choices { display: flex; flex-direction: column; gap: 10px; }
.sync-choice { display: block; width: 100%; text-align: left; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; font-family: inherit; }
.sync-choice:hover { border-color: var(--accent); background: var(--hover); }
.sync-choice-title { display: block; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.sync-choice-sub { display: block; font-size: 12px; color: var(--muted); line-height: 1.4; }
.dialog-msg { margin-bottom: 4px; line-height: 1.5; padding-right: 24px; }
.dialog-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.dialog-row:last-child { margin-bottom: 0; }
.dialog-row-label { font-size: 13px; font-weight: 600; }
.dialog-row-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.trash-score-input { flex: none; width: 4.5em; padding: 5px 8px; font-family: var(--font-mono); box-sizing: border-box; }

/* Disabled wordlist */
.wordlist-card.disabled .card-info { opacity: 0.45; }

/* No-data wordlist */
.wordlist-card.no-data .toggle { opacity: 0.35; }
.wordlist-card.no-data .toggle input { pointer-events: none; }


.card-name-row { display: flex; align-items: center; gap: 5px; min-width: 0; }
.badge { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; display: inline-block; box-sizing: border-box; }
.badge[data-severity="info"] { background: #7add9e; }
.badge[data-severity="pending"] { background: var(--accent); }

/* Import zone */
.import-zone { border: 2px dashed var(--border); border-radius: 6px; padding: 24px 16px; text-align: center; color: var(--faint); cursor: pointer; transition: border-color 0.15s, color 0.15s; user-select: none; }
.import-zone:hover, .import-zone.drag-over { border-color: var(--accent); color: var(--accent); }
.import-zone.compact { padding: 14px; font-size: 13px; }

/* ─── Dialogs ───────────────────────────────────────────────────────────────── */
/* Width is a custom property so the mobile bottom-sheet rule can override every
   dialog's width in one place — a plain `width` on each #dialog-id would beat a
   type-selector mobile override on specificity. */
dialog { width: var(--dialog-w, 420px); border-radius: 10px; border: none; box-shadow: var(--shadow); font-family: var(--font-sans); background: var(--bg); color: var(--text); position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); max-height: 90vh; overflow-y: auto; }
dialog:focus { outline: none; }
.dialog-body { padding: 22px; }
dialog::backdrop { background: var(--backdrop); }
dialog h2 { font-size: 16px; margin-bottom: 14px; padding-right: 24px; }
.dialog-close-btn, .dialog-back-btn { background: none; border: none; font-size: 18px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 4px; }
.dialog-close-btn:hover, .dialog-back-btn:hover { background: var(--hover); color: var(--text); }
.dialog-close-btn { position: absolute; top: 10px; right: 12px; z-index: 1; }
.dialog-back-btn { display: inline-flex; margin-left: -6px; }
.dialog-back-btn svg { transform: scaleX(-1); }
.dialog-footer { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border2); display: flex; justify-content: flex-end; gap: 8px; }

/* Mobile bottom sheets. dvh (not vh) keeps the sheet clear of the URL bar. */
@media (max-width: 759px) {
  dialog {
    top: auto; bottom: 0; left: 0;
    width: 100%; max-width: none;
    max-height: 90dvh;
    border-radius: 14px 14px 0 0;
    transform: translateY(100%);
    transition: transform 0.28s ease, overlay 0.28s allow-discrete, display 0.28s allow-discrete;
  }
  dialog[open] { transform: translateY(0); }
  @starting-style { dialog[open] { transform: translateY(100%); } }

  dialog::backdrop {
    opacity: 0;
    transition: opacity 0.28s ease, overlay 0.28s allow-discrete, display 0.28s allow-discrete;
  }
  dialog[open]::backdrop { opacity: 1; }
  @starting-style { dialog[open]::backdrop { opacity: 0; } }
}

@media (max-width: 759px) and (prefers-reduced-motion: reduce) {
  dialog, dialog::backdrop, #score-picker { transition: none; }
}

@media (max-width: 999px) {
  #entry-panel {
    left: 0; width: auto;
    border-left: none; box-shadow: none;
  }
  #entry-panel .dialog-close-btn { left: 4px; right: auto; top: 5px; padding: 9px 12px; font-size: 22px; }
  #entry-panel .entry-panel-close-x { display: none; }
  #entry-panel .entry-panel-close-back { display: inline; }
  #entry-panel .entry-panel-titlerow { padding-left: 36px; padding-right: 0; }
  #entry-panel .entry-panel-title { line-height: 1.5; }
}

@media (prefers-reduced-motion: reduce) {
  #entry-panel, #entry-panel-backdrop { transition: none; }
}

#manage-dialog { --dialog-w: 520px; height: min(800px, 90vh); }
#manage-dialog .dialog-body { height: 100%; box-sizing: border-box; display: flex; flex-direction: column; }
#manage-dialog h2 { display: flex; align-items: center; gap: 4px; }
.manage-views { flex: 1; min-height: 0; overflow: hidden; }
.manage-track { display: flex; height: 100%; transition: transform 0.28s ease; }
#manage-dialog.detail .manage-track { transform: translateX(-100%); }
.manage-home, .manage-detail { flex: 0 0 100%; min-width: 0; overflow-y: auto; box-sizing: border-box; }
@media (prefers-reduced-motion: reduce) {
  .manage-track { transition: none; }
}
.manage-all, .manage-list { margin: 4px 0; background: var(--surface); border: 1px solid var(--border2); border-radius: 6px; }
.manage-all .wordlist-card, .manage-list .wordlist-card:last-child { border-bottom: none; }
.card-caret { flex-shrink: 0; color: var(--faint); }
.manage-merge { padding: 10px 2px 6px; }
.manage-merge > .dialog-row { margin-bottom: 0; }
.manage-merge-note { text-align: right; }
.manage-merge-note.off { visibility: hidden; }
.manage-merge-choice { cursor: pointer; user-select: none; }
.manage-status { margin-left: auto; align-self: center; font-size: 12px; color: var(--muted); }
.delete-link { margin-right: auto; padding: 3px 6px; border: none; background: none; color: var(--err-fg); font-size: 13px; font-family: inherit; cursor: pointer; border-radius: 4px; }
.delete-link:hover { background: var(--del-hover); }
@media (max-width: 759px) {
  #manage-dialog { height: 90dvh; }
}
.manage-add-row { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; padding: 8px 10px; border: 1px dashed var(--border3); border-radius: 6px; background: none; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.1s, color 0.1s, border-color 0.1s; }
.manage-add-row:hover { background: var(--hover); color: var(--accent); border-color: var(--accent); }
.manage-add-row .add-wordlist-icon { font-size: 15px; line-height: 1; }

/* Help dialog diagrams (embedded in FAQ answers) */
.faq-diagram { margin: 6px 0 12px; padding: 12px; border: 1px solid var(--border2); border-radius: 8px; background: var(--surface); display: flex; align-items: center; justify-content: center; gap: 8px; }
.faq-diagram--merge { flex-direction: column; gap: 7px; }
.faq-merge-sources { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }
.faq-merge-sources .wordlist-icon { width: 20px; height: 20px; }
.faq-merge-arrow { color: var(--faint); }
.faq-merge-all { display: flex; flex-direction: column; align-items: center; }
.faq-merge-all-head { display: flex; align-items: center; gap: 6px; }
.faq-merge-all .wordlist-icon { width: 22px; height: 22px; }
.faq-merge-all-name { font-weight: 600; color: var(--text); font-size: 13px; }
.faq-merge-count { color: var(--muted); font-size: 12px; }
.faq-sync-icon { width: 30px; height: 30px; flex-shrink: 0; }
.faq-sync-emoji { font-size: 26px; line-height: 1; flex-shrink: 0; }
.faq-sync-arrow { color: var(--accent); font-weight: 700; font-size: 20px; line-height: 1; flex-shrink: 0; }
.faq-diagram--tools { padding: 0; overflow: hidden; pointer-events: none; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent); }
.faq-tools-strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr); gap: 8px; padding: 10px; }

/* Acknowledgements credits (the "Who do I thank?" answer) */
.acks-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.acks-credit { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text); }
.acks-credit .wordlist-icon { width: 20px; height: 20px; }
.acks-credit-text { display: flex; flex-direction: column; line-height: 1.3; }
.acks-credit-by { font-size: 12px; }

/* FAQ dialog */
#help-dialog { --dialog-w: 560px; }
.faq-section { margin-bottom: 22px; }
.faq-section:last-of-type { margin-bottom: 0; }
.faq-section > h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--faint); margin: 0 0 4px; }
.faq-item { border-top: 1px solid var(--border2); }
.faq-section:not(:last-of-type) > .faq-item:last-child { border-bottom: 1px solid var(--border2); }
.faq-item > summary { display: flex; align-items: baseline; gap: 9px; padding: 11px 2px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; list-style: none; }
.faq-item > summary::-webkit-details-marker { display: none; }
.faq-item > summary::before { content: '▸'; flex-shrink: 0; color: var(--muted); font-size: 11px; transition: transform 0.12s; }
.faq-item[open] > summary::before { transform: rotate(90deg); }
.faq-item > summary:hover { color: var(--accent); }
.faq-answer { padding: 0 2px 13px 20px; }
.faq-answer p { font-size: 13px; line-height: 1.55; color: var(--muted); margin: 0 0 10px; }
.faq-answer p:last-child { margin-bottom: 0; }
.faq-answer ul, .faq-answer ol { margin: 0 0 10px; padding-left: 18px; }
.faq-answer li { font-size: 13px; line-height: 1.5; color: var(--muted); margin-bottom: 5px; }
.faq-answer li:last-child { margin-bottom: 0; }
.faq-answer strong { color: var(--text); font-weight: 600; }
.faq-answer em { color: var(--text); }
.faq-answer code { font-family: var(--font-mono); font-size: 12px; background: var(--surface); padding: 1px 4px; border-radius: 3px; }
.faq-answer kbd { font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--border2); border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px; white-space: nowrap; }
.faq-answer a { color: var(--accent); text-decoration: none; }
.faq-answer a:hover { text-decoration: underline; }
.faq-shot { margin: 0 0 12px; }
.faq-shot img { display: block; max-width: 100%; height: auto; border: 1px solid var(--border2); border-radius: 8px; }
.faq-shot figcaption { font-size: 12px; line-height: 1.45; color: var(--faint); margin-top: 5px; }

/* Import guide dialog */
#import-guide-dialog { --dialog-w: 480px; }
.guide-intro { margin: 0 0 14px 0; font-size: 13px; color: var(--text); line-height: 1.5; }
.subscription-note { background: var(--callout-bg); border: 1px solid var(--callout-border); border-radius: 5px; padding: 9px 12px; margin-bottom: 16px; font-size: 12px; color: var(--callout-fg); }
.guide-steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; counter-reset: guide-step; }
.guide-step { display: flex; gap: 12px; align-items: flex-start; font-size: 13px; line-height: 1.5; counter-increment: guide-step; }
.guide-step::before { content: counter(guide-step); flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: white; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin-top: 1px; }
.guide-step-body { flex: 1; min-width: 0; }
.guide-step-body .import-zone { margin-top: 8px; }
.guide-step-body a { color: var(--accent); text-decoration: none; word-break: break-all; }
.guide-step-body a:hover { text-decoration: underline; }

/* Wordlist form (Add wordlist, Manage's General tab) */
#add-wordlist-dialog { --dialog-w: 520px; }
.configure-section { margin-bottom: 18px; }
.configure-section:last-child { margin-bottom: 0; }
.configure-section-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.configure-icon-name-row { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 8px; }
.configure-icon-name-row .configure-section-label { margin-bottom: 0; }
.config-name-input { width: 100%; padding: 6px 8px; box-sizing: border-box; }
.config-name-input.invalid { border-color: #ea4335; background: var(--error-bg); }
.publisher-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.publisher-chip { border: 1px solid var(--border); border-radius: 16px; padding: 4px 12px; font-size: 12px; font-weight: 600; background: var(--btn-bg); color: var(--muted); cursor: pointer; font-family: inherit; display: inline-flex; align-items: center; gap: 5px; line-height: 1; }
.publisher-chip:hover:not(.active) { background: var(--hover); color: var(--text); }
.publisher-chip.active { background: var(--accent); color: white; border-color: var(--accent); }
.publisher-chip .wordlist-icon { width: 13px; height: 13px; }
.rules-option-row { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.rules-option-lbl { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.rules-option-row select { padding: 5px 8px; font-size: 12px; cursor: pointer; }
.rules-preview-wrap { margin-top: 10px; background: var(--surface); border: 1px solid var(--border2); border-radius: 6px; padding: 8px 14px; }
.url-check-icon { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 14px; line-height: 1; pointer-events: none; }
.url-input.config-url-input { padding-right: 26px; }
.source-meta { font-size: 11px; color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.source-url-meta { max-height: 0; opacity: 0; overflow: hidden; margin-top: 0; transition: max-height 0.2s ease, opacity 0.2s ease, margin-top 0.2s ease; }
.source-url-meta.visible { max-height: 40px; opacity: 1; margin-top: 6px; }
.url-check-warn    { color: var(--warn-fg); }
.url-check-error   { color: var(--err-fg); }
.url-check-ok-icon  { color: var(--ok-fg);  font-weight: 700; }
.url-check-err-icon { color: var(--err-fg); font-weight: 700; }
.url-check-spinner { width: 13px; height: 13px; border: 2px solid var(--border2); border-top-color: var(--accent); border-radius: 50%; animation: url-check-spin 0.6s linear infinite; }
@keyframes url-check-spin { to { transform: rotate(360deg); } }

/* Icon picker */
.icon-picker-trigger { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); user-select: none; }
.icon-picker-trigger:hover { background: var(--hover); }
.icon-picker-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-preview-box { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-picker-popup { position: fixed; inset: auto; margin: 0; padding: 0; width: 280px; color: var(--text); border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: 0 4px 20px rgba(0,0,0,0.18); overflow: hidden; }
.icon-picker-tabs { display: flex; border-bottom: 1px solid var(--border); }
.icon-picker-tab { flex: 1; border: none; border-radius: 0; padding: 6px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface); cursor: pointer; font-family: inherit; }
.icon-picker-tab.active { color: var(--accent); background: var(--sel); }
.icon-picker-tab:hover:not(.active) { background: var(--hover); }
.icon-picker-pane { padding: 10px 12px; display: none; }
.icon-picker-pane.active { display: block; }
.icon-emoji-btn[data-auto] .wordlist-icon-initials { width: 22px; height: 22px; }
.icon-emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.icon-emoji-btn { background: none; border: 1px solid transparent; border-radius: 4px; font-size: 18px; line-height: 1; padding: 4px 2px; cursor: pointer; text-align: center; font-family: inherit; }
.icon-emoji-btn:hover { background: var(--hover); border-color: var(--border); }
.icon-emoji-btn.selected { background: var(--sel); border-color: var(--accent); }

/* URL input component */
.url-input-wrap { position: relative; display: flex; align-items: center; }
.url-input-icon { position: absolute; left: 8px; color: var(--muted); pointer-events: none; flex-shrink: 0; }
.url-input { width: 100%; padding: 6px 8px 6px 28px; box-sizing: border-box; }

/* Initials icon */
.wordlist-icon-initials text { fill: white; }
.ic-0  { fill: #5C6BC0; }
.ic-1  { fill: #1E88E5; }
.ic-2  { fill: #00ACC1; }
.ic-3  { fill: #00897B; }
.ic-4  { fill: #43A047; }
.ic-5  { fill: #FB8C00; }
.ic-6  { fill: #E53935; }
.ic-7  { fill: #D81B60; }
.ic-8  { fill: #8E24AA; }
.ic-9  { fill: #5E35B1; }
.ic-10 { fill: #3949AB; }
.ic-11 { fill: #0277BD; }

/* Update Summary dialog */
#update-summary-dialog { --dialog-w: 480px; overflow: hidden; padding: 0; max-height: min(560px, 85vh); }
#update-summary-dialog[open] { display: flex; flex-direction: column; }
.usd-header { padding: 18px 22px 14px; flex-shrink: 0; }
.usd-header h2 { margin-bottom: 4px; padding-right: 24px; }
.usd-count { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.usd-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.usd-pill { padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; cursor: pointer; border: 1px solid transparent; background: none; font-family: inherit; transition: opacity 0.15s; }
.usd-pill:hover { opacity: 0.75; }
.usd-pill-added    { background: var(--usd-added-bg);    color: var(--usd-added-fg);    }
.usd-pill-deleted  { background: var(--usd-deleted-bg);  color: var(--usd-deleted-fg);  }
.usd-pill-rescored { background: var(--usd-rescored-bg); color: var(--usd-rescored-fg); }
.usd-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; border-top: 1px solid var(--border2); padding-bottom: 12px; }
.usd-sizer { position: relative; }
.usd-row { position: absolute; left: 0; right: 0; height: 24px; display: flex; align-items: center; }
.usd-section-header { padding: 0 22px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; background: var(--surface); border-bottom: 1px solid var(--border3); }
.usd-entry-row { padding: 0 22px 0 19px; border-left: 3px solid transparent; }
.usd-entry-row:hover { background: var(--row-hover); }
.usd-entry-col { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 12px; }
.usd-score-col { flex-shrink: 0; display: flex; align-items: center; gap: 4px; }
.usd-added    { border-left-color: var(--usd-added-fg);    }
.usd-deleted  { border-left-color: var(--usd-deleted-fg);  }
.usd-rescored { border-left-color: var(--usd-rescored-fg); }
.usd-deleted .usd-entry-col { text-decoration: line-through; color: var(--muted); }
.usd-old-score { color: var(--muted); font-size: 12px; }
.usd-arrow { color: var(--faint); font-size: 11px; }
.usd-skel { padding: 0 22px 0 19px; }
.usd-skel-bar { display: block; width: 40%; }

/* ─── Notifications ─────────────────────────────────────────────────────────── */
/* Notification stack — toasts and the fetch panel share one bottom-center column */
#notify-stack { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 1000; pointer-events: none; }

/* Toast */
#toast-container { order: 1; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #333; color: white; padding: 9px 15px; border-radius: 6px; font-size: 13px; opacity: 0; transition: opacity 0.25s; max-width: 360px; overflow-wrap: break-word; pointer-events: none; }
.toast.show { opacity: 1; }
.toast.show, .toast.dismissing { pointer-events: auto; }

/* Fetch status (download manager) — one panel, one row per in-flight fetch */
#fetch-status { order: 2; width: min(320px, calc(100vw - 36px)); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; }
#fetch-status[hidden] { display: none; }
.fetch-row { padding: 8px 11px; }
.fetch-row + .fetch-row { border-top: 1px solid var(--border2); }
.fetch-row-name { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fetch-row-meta { margin-top: 2px; font-size: 11px; color: var(--muted); }
.fetch-bar { position: relative; height: 3px; margin-top: 6px; border-radius: 2px; background: var(--border2); overflow: hidden; }
.fetch-bar span { position: absolute; top: 0; left: -40%; height: 100%; width: 40%; background: var(--accent); border-radius: 2px; }

/* ─── Rescore editor ────────────────────────────────────────────────────────── */
.rule-row { display: flex; align-items: center; gap: 5px; margin-bottom: 3px; }
.rule-in, .rule-out { padding: 2px 6px; border-radius: 3px; font-size: 12px; font-family: var(--font-mono); text-align: center; }
.rule-in  { width: 80px; }
.rule-out { width: 80px; }
.rule-in::placeholder, .rule-query::placeholder, .rule-out::placeholder { color: var(--faint); }
.rule-in.invalid, .rule-out.invalid { border-color: #ea4335; background: var(--error-bg); }
.rule-row-wrap { flex-wrap: wrap; margin-bottom: 8px; }

/* The condition: a transparent textarea over a layer that draws the same text
   highlighted. Both must share every metric below, or the colors drift off the
   letters as the text grows. */
.rule-query-box { position: relative; flex: 1; min-width: 0; align-self: flex-start; background: var(--input-bg); border: 1px solid var(--border); border-radius: 3px; }
.rule-query-box:focus-within { border-color: var(--accent); }
.rule-query-hl, .rule-query-box > .rule-query { margin: 0; padding: 2px 6px; border: 0; font-family: var(--font-mono); font-size: 12px; line-height: 18px; letter-spacing: normal; white-space: pre-wrap; overflow-wrap: anywhere; text-align: left; }
.rule-query-hl { position: absolute; inset: 0; pointer-events: none; color: var(--text); }
.rule-query-box > .rule-query { position: relative; display: block; width: 100%; min-height: 22px; resize: none; overflow: hidden; background: transparent; color: transparent; caret-color: var(--text); }
.rule-query-box > .rule-query:focus { outline: none; }
.rule-query-box > .rule-query::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.rule-query-static { flex: 2; min-width: 0; font-family: var(--font-mono); font-size: 12px; padding: 2px 6px; overflow-wrap: anywhere; }
.q-field { color: var(--q-field); }
.q-value { color: var(--q-value); }
.q-op { color: var(--q-op); }
.q-punct { color: var(--q-punct); }
.q-err { text-decoration: underline wavy var(--q-err); text-decoration-thickness: 1.5px; text-underline-offset: 3px; text-decoration-skip-ink: none; }

.rule-status, .rule-foot { flex-basis: 100%; padding-left: 17px; font-size: 11.5px; color: var(--muted); }
.rule-status:empty { display: none; }
.rule-status.err { color: var(--q-err); }
.rule-status code, .rules-ref code { font-family: var(--font-mono); font-size: 11px; }
.rule-status code { color: var(--q-field); }
.rule-foot { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.rule-meta { flex: 0 1 auto; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.rule-foot > .rule-note-wrap { flex: 1 1 0; padding-block: 0; }
.rule-count { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rule-meta-note { color: var(--faint); }
.rule-meta-off { color: var(--q-err); }
.rules-rest { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.rules-rest:empty { display: none; }
.rules-ref { margin-top: 10px; }
.rules-ref > summary { font-size: 12px; padding: 8px 2px; }
.rules-ref-body { overflow-x: auto; padding-bottom: 8px; }
.rules-ref table { border-collapse: collapse; font-size: 12px; }
.rules-ref th { text-align: left; font-weight: 600; color: var(--muted); padding: 3px 10px 3px 0; }
.rules-ref td { vertical-align: top; padding: 3px 10px 3px 0; color: var(--muted); }
.rules-ref td:first-child { white-space: nowrap; }

.rule-suggest { position: fixed; inset: auto; margin: 0; max-height: min(320px, 60vh); }
.rule-suggest .score-picker-opt { align-items: baseline; }
.rule-suggest-status { padding: 4px 8px 6px; margin-bottom: 2px; border-bottom: 1px solid var(--border2); color: var(--muted); }
.rule-suggest-status.err { color: var(--q-err); }
.rule-suggest-status code { font-family: var(--font-mono); color: var(--q-field); }
.rule-suggest-group { display: flex; justify-content: space-between; padding: 7px 8px 2px; font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.rule-suggest-label { flex: none; min-width: 84px; font-family: var(--font-mono); white-space: nowrap; }
.rule-suggest-label b { font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.rule-suggest-field { color: var(--q-field); }
.rule-suggest-value { color: var(--q-value); }
.rule-suggest-op { color: var(--q-op); }
.score-picker-opt.active .rule-suggest-label { color: inherit; }
.rule-suggest .score-picker-label { color: var(--muted); }
.rule-suggest .score-picker-opt.active .score-picker-label { color: rgba(255, 255, 255, 0.85); }
.rule-suggest-hint { margin-top: 4px; padding: 6px 8px 2px; border-top: 1px solid var(--border2); color: var(--muted); }
.rule-suggest-hint code { font-family: var(--font-mono); color: var(--q-value); }
.rule-suggest-foot { margin-top: 4px; padding: 6px 8px 2px; border-top: 1px solid var(--border2); color: var(--faint); font-family: var(--font-mono); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rule-arrow { color: var(--faint); font-size: 14px; width: 14px; text-align: center; flex-shrink: 0; }
.rule-note-wrap { flex: 1; min-width: 0; display: flex; align-items: center; cursor: text; border-radius: 3px; padding: 2px 3px; gap: 3px; }
.rule-note-wrap:hover { background: var(--bg); }
.rule-note-text { flex: 0 1 auto; min-width: 0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.4; }
.rule-note-text:empty::before { content: 'add note…'; font-style: italic; color: var(--faint); pointer-events: none; }
@media (hover: hover) {
  .rule-note-text:empty::before { color: transparent; }
  .rule-row:hover .rule-note-text:empty::before { color: var(--faint); }
}
.rule-note-pencil { font-size: 11px; color: var(--faint); }
.rule-row:hover .rule-note-wrap.has-note .rule-note-pencil { opacity: 1; }
.rule-note-input { flex: 1; padding: 1px 4px; border: 1px solid var(--accent); border-radius: 3px; font-size: 12px; outline: none; min-width: 0; }
.rule-del { border: none; background: none; cursor: pointer; font-size: 15px; padding: 0; line-height: 1; border-radius: 3px; font-family: inherit; color: var(--faint); }
@media (hover: hover) {
  .rule-del { color: transparent; }
  .rule-row:hover .rule-del { color: var(--faint); }
}
.rule-del:hover { color: #e53935 !important; background: var(--del-hover); }

.rule-add-btn { margin-top: 4px; padding: 2px 10px; border: 1px dashed var(--border); background: transparent; color: var(--muted); border-radius: 3px; font-size: 12px; line-height: 1.4; cursor: pointer; font-family: inherit; }
.rule-add-btn:hover { color: var(--text); border-color: var(--accent); }

.manage-section-head { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.manage-section-head .configure-section-label { margin-bottom: 0; }
.rescore-kebab .more-menu-btn { width: 22px; height: 22px; padding: 0; border: none; border-radius: 50%; background: none; color: var(--text); font-size: 16px; font-weight: 700; letter-spacing: 0; }
.rescore-kebab .more-menu-btn:hover:not(:disabled), .rescore-kebab.open .more-menu-btn { background: var(--border); }

/* ─── Tool gallery ──────────────────────────────────────────────────────────── */
#featured-row { padding: 32px; border-bottom: 1px solid var(--border3); position: relative; background: var(--bg); z-index: 60; }
#featured-row.expanded { border-bottom-color: transparent; }

#picker-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 50; opacity: 0; pointer-events: none; transition: opacity 220ms ease; }
body.picker-expanded #picker-backdrop { opacity: 1; }

.picker-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-bottom: 14px; gap: 8px; }
.picker-search-wrap { grid-column: 2; position: relative; display: flex; align-items: center; width: min(440px, 100%); justify-self: center; }
.picker-search-wrap > svg { position: absolute; left: 10px; pointer-events: none; color: var(--muted); }
.picker-search-wrap > input { width: 100%; padding: 8px 10px 8px 32px; }
.picker-close { grid-column: 3; justify-self: end; font: inherit; font-size: 16px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--muted); cursor: pointer; }
.picker-close:hover { color: var(--text); border-color: var(--accent); }

.featured-cards { display: grid; gap: 8px; justify-content: center; }
.picker-gallery { position: absolute; top: 100%; left: 0; right: 0; max-height: 0; overflow-y: auto; scrollbar-gutter: stable; transition: max-height 240ms ease; background: var(--bg); border-bottom: 0 solid var(--border); z-index: 100; }
#featured-row.expanded .picker-gallery { max-height: 65vh; border-bottom-width: 1px; }
.picker-gallery-inner { padding: 32px; display: flex; flex-wrap: wrap; align-items: flex-start; align-content: start; gap: 8px; }

.tool-card { position: relative; flex: 0 0 175px; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; background: var(--surface); cursor: pointer; user-select: none; display: flex; flex-direction: column; min-width: 0; transition: background 0.1s, border-color 0.1s, box-shadow 0.1s; }
.tool-card:hover { background: var(--hover); border-color: var(--accent); }
.tool-card.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tool-card.disabled { cursor: not-allowed; opacity: 0.4; }
.tool-card.disabled:hover { background: var(--surface); border-color: var(--border); }
.tool-card-name { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-card-desc { font-size: 11px; color: var(--muted); margin-top: 4px; height: 2.6em; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; }
.tool-card-example { font-family: var(--font-mono); font-size: 11px; color: var(--faint); margin-top: auto; padding-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.featured-more-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px dashed var(--border); border-radius: 6px; padding: 10px 12px; background: transparent; color: var(--muted); font: inherit; cursor: pointer; min-width: 0; transition: background 0.1s, border-color 0.1s, color 0.1s; }
.featured-more-tile:hover { border-color: var(--accent); color: var(--accent); background: var(--hover); }
.featured-more-tile-count { font-size: 18px; font-weight: 700; line-height: 1; }
.featured-more-tile-label { font-size: 11px; font-weight: 600; color: inherit; margin-top: 3px; }
.featured-more-tile-chevron { color: inherit; margin-top: 5px; transition: transform 0.15s; }
#featured-row.expanded .featured-more-tile-chevron { transform: rotate(180deg); }

@media (max-width: 759px) {
  #featured-row, .picker-gallery-inner { padding: 14px 16px 18px; }
  .picker-bar { grid-template-columns: 1fr auto; }
  .picker-search-wrap { grid-column: 1; justify-self: stretch; width: 100%; }
  .picker-close { grid-column: 2; }
  .featured-cards { display: flex; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
  .featured-cards::-webkit-scrollbar { display: none; }
  .tool-card, .featured-more-tile { flex: 0 0 130px; }
}


.gallery-cat-group { display: flex; gap: 8px; flex: 0 0 auto; }
/* Separate categories via a trailing margin on the item before a group, not a
   leading margin on the group — a leading margin would indent a group that
   wraps to the start of a row; trailing slack just vanishes at a row's end. */
.picker-gallery-inner > :has(+ .gallery-cat-group) { margin-right: 16px; }
.gallery-cat-chip { flex: 0 0 auto; align-self: stretch; writing-mode: vertical-rl; transform: rotate(180deg); display: flex; align-items: center; justify-content: center; width: 24px; padding: 10px 0; border-radius: 999px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; user-select: none; background: var(--chl, var(--surface)); color: var(--chl-fg, var(--muted)); }
.hl-cat-0 { --chl: var(--hl0); --chl-fg: var(--hl0-fg); }
.hl-cat-1 { --chl: var(--hl1); --chl-fg: var(--hl1-fg); }
.hl-cat-2 { --chl: var(--hl2); --chl-fg: var(--hl2-fg); }
.hl-cat-3 { --chl: var(--hl3); --chl-fg: var(--hl3-fg); }
.hl-cat-4 { --chl: var(--hl4); --chl-fg: var(--hl4-fg); }
.hl-cat-5 { --chl: var(--hl5); --chl-fg: var(--hl5-fg); }
.hl-cat-6 { --chl: var(--hl6); --chl-fg: var(--hl6-fg); }
.hl-cat-7 { --chl: var(--hl7); --chl-fg: var(--hl7-fg); }
.hl-cat-8 { --chl: var(--hl8); --chl-fg: var(--hl8-fg); }
.gallery-empty { flex: 0 0 100%; border: 1px dashed var(--border); border-radius: 6px; padding: 18px 14px; text-align: center; color: var(--muted); }
.gallery-empty p { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.gallery-empty small { font-size: 11px; line-height: 1.5; display: block; }
.tool-card-all-btn {
  position: absolute; top: 3px; right: 4px;
  background: none; border: none;
  font: inherit; font-size: 13px; line-height: 1;
  padding: 3px 5px; border-radius: 4px;
  color: var(--faint); cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.tool-card-all-btn:hover { color: var(--accent); background: var(--hover); }
.tool-card-all-btn.active { color: var(--accent); }
.tool-card-all-btn.disabled { cursor: not-allowed; opacity: 0.35; }
.tool-card-all-btn.disabled:hover { color: var(--faint); background: none; }
.tool-card-all-btn.disabled.active { opacity: 1; }
.tool-card-all-btn.disabled.active:hover { color: var(--accent); background: none; }

/* ─── Tool rows ─────────────────────────────────────────────────────────────── */
#tool-stack { background: var(--surface); position: relative; }
/* Tool rows and the search bar share min-height so a row with no params
   doesn't shrink below the height of an input-bearing row, and the search
   bar (visually the bottom row of the stack) lines up with them. */
.tool-row, .search-bar { min-height: 42px; --tool-control-h: 30px; }
.tool-row { position: relative; display: grid; grid-template-columns: auto auto auto minmax(0, auto) auto 1fr auto auto; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--border2); column-gap: 0; row-gap: 6px; overflow: hidden; }
.tool-row > .tool-label { margin-left: 12px; }
/* The tool name and its handle sit on the first control line, not centered
   against a multi-line body (e.g. a Rebus row with several pairs). */
.tool-row > .tool-label, .tool-row > .drag-handle,
.search-bar > .tool-label, .search-bar > .drag-handle { align-self: start; min-height: var(--tool-control-h); }
.tool-row > .drag-handle, .search-bar > .drag-handle { display: inline-flex; align-items: center; }
.tool-row > .find-replace-caret { margin-left: 4px; }
/* Pin the input to its column so it lands there with or without a preceding
   find/replace caret — otherwise a caret-less tool's input slides up into the
   caret column, leaving col4 as dead space that strands the error icon. */
.tool-row > .tool-row-param { grid-column: 4; }
.tool-row > .tool-row-param-text { padding-left: 12px; }
.tool-row > .find-replace-caret ~ .tool-row-param-text { padding-left: 6px; }
.tool-row > .tool-row-param:not(.tool-row-param-text) { margin-left: 12px; }
.tool-row > .tool-row-asides { margin-left: 12px; }
.tool-row > .tool-row-remove { grid-column: -2 / -1; margin-left: 12px; }
.tool-row > .tool-row-invert, .search-bar > .tool-row-invert,
.tool-row > .tool-row-reverse { grid-column: 7; margin-left: 8px; }
.tool-row > .tool-row-invert + .tool-row-remove,
.tool-row > .tool-row-reverse + .tool-row-remove { margin-left: 2px; }
.tool-row > .tool-row-replace > .tool-row-param-text { grid-column: 4; grid-row: 2; padding-left: 6px; }
.tool-row > .tool-row-replace > .tool-row-asides { grid-column: 5; grid-row: 2; margin-left: 12px; }
.tool-row:last-child { border-bottom: none; }
.tool-row.dragging { opacity: 0.4; }
/* One-shot accent pulse on a newly added tool row — draws the eye to it.
   add() rebuilds the rows, so the new row's element is always fresh and
   flashRow only needs to set the class once. */
.tool-row.flash { animation: tool-row-flash 0.7s ease-out; }
@keyframes tool-row-flash {
  0%   { background: color-mix(in srgb, var(--accent) 28%, transparent); }
  100% { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .tool-row.flash { animation: none; }
}
/* Insertion cursor — shown while hovering a gallery card to indicate
   where the new tool will land. Drawn as a right-pointing caret + line
   ( >─── ) so it reads as "insert here" rather than just "this position."
   Parented in .search-bar, sitting at top: -1px so it straddles the seam
   between the last tool row and the search bar (or the top of the stack
   when no user tools exist yet). */
.tool-stack-cursor { position: absolute; top: -1px; left: 10px; right: 10px; height: 2px; background: var(--accent); pointer-events: none; box-shadow: 0 0 6px color-mix(in srgb, var(--accent) 55%, transparent); }
.tool-stack-cursor::before { content: ''; position: absolute; left: 0; top: 50%; width: 0; height: 0; transform: translateY(-50%); border-style: solid; border-width: 4px 0 4px 7px; border-color: transparent transparent transparent var(--accent); }
.tool-label { white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.tool-row-icon { position: relative; font-size: 16px; line-height: 1; color: var(--muted); flex-shrink: 0; }
.tool-row-icon-glyph { display: inline-flex; transition: filter 0.12s, opacity 0.12s; }
.tool-row-name { font-size: 13px; font-weight: 600; color: var(--text); }
.tool-row-name-suffix { font-weight: 400; color: var(--muted); }
.tool-row-asides { display: flex; align-items: center; gap: 6px; }
/* contents, not a flex box: the replace input must be a grid item in the
   pattern's own column so their widths track together — a wrapper sizes it
   independently and it drifts from the pattern by font environment. */
.tool-row-replace { display: contents; }
.tool-row-replace[hidden] { display: none; }
.tool-row-param { display: flex; align-items: center; gap: 4px; min-height: var(--tool-control-h); font-size: 12px; color: var(--muted); }
.tool-row-param label { display: flex; align-items: center; gap: 5px; white-space: nowrap; cursor: pointer; user-select: none; }
.tool-row-match { gap: 2px; }
.match-mode-toggle { font-size: 12px; }
.match-mode-toggle:hover { color: var(--text); }
.match-mode-toggle:focus-within { color: var(--text); }
.choice-arrow { display: inline-flex; align-items: center; justify-content: center; padding: 3px 4px; background: none; border: none; cursor: pointer; color: var(--muted); }
.choice-arrow:hover:not(:disabled) { color: var(--text); }
.choice-arrow:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; border-radius: 3px; }
.choice-arrow .more-menu-caret { width: 8px; height: 5px; display: block; }
.choice-menu button::before { content: ""; display: inline-block; width: 1.2em; }
.choice-menu button[aria-checked="true"]::before { content: "✓"; }
.tool-row-param-text { width: 200px; max-width: 100%; min-width: 0; justify-self: start; }
.tool-row-param-text .clearable-input { flex: 1 1 auto; }
/* Must be an explicit width, not a max-width bump: the grid column is content-sized,
   so a cap alone silently leaves the box at the input's intrinsic ~200px. */
.tool-row[data-tool="umiaq"] .tool-row-param-text { width: 300px; }
.find-replace-caret { width: 16px; height: var(--tool-control-h); padding: 0; background: none; border: none; cursor: pointer; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.find-replace-caret:hover { color: var(--text); }
.find-replace-caret:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; border-radius: 3px; }
.find-replace-caret-glyph { transition: transform 0.15s; }
.find-replace-caret[aria-expanded="true"] .find-replace-caret-glyph { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) {
  .find-replace-caret-glyph { transition: none; }
}
.tool-row-param input[type="text"],
.range-filter input[type="text"] { font-family: var(--font-mono); }
.tool-row-param input[type="text"] { width: 100%; min-width: 0; padding: 5px 24px 5px 8px; }
.range-filter input[type="text"] { width: 60px; padding: 4px 20px 4px 6px; }
.range-filter input.invalid { border-color: #ea4335; background: var(--error-bg); }
.length-range-off { opacity: 0.5; }
.length-range-off input[type="text"] { cursor: not-allowed; background: var(--surface); color: var(--muted); }
.tool-row-param input.tool-row-num { font-family: var(--font-sans); padding: 5px 8px; width: 5em; }
.tool-row-range-wrap { display: inline-flex; flex-direction: column; align-items: stretch; gap: 1px; }
.tool-row-range-wrap input[type="range"] { width: 110px; margin: 0; padding: 0; height: 16px; accent-color: var(--accent); }
.tool-row-range-wrap input[type="range"]:focus { outline: none; }
.tool-row-range-ticks { display: flex; justify-content: space-between; font-size: 10px; line-height: 1; color: var(--faint); padding: 0 2px; }
.clearable-input { position: relative; display: inline-flex; align-items: center; }
.clearable-input .clear-btn, .clearable-input .score-range-btn { position: absolute; right: 4px; }
.clearable-input.has-all-toggle .clear-btn { right: 28px; }
.clearable-input.has-all-toggle input { padding-right: 50px; }
.clearable-input.all-on input { background: var(--surface); pointer-events: none; transition: background 0.2s ease; }
.clearable-input.has-all-toggle input { transition: background 0.2s ease; }
.clearable-input.all-on input::placeholder { color: var(--accent); opacity: 1; }
.clearable-input.all-on .clear-btn { display: none; }
.clear-btn, .score-range-btn { background: none; border: none; padding: 2px 3px; cursor: pointer; color: var(--muted); display: flex; align-items: center; line-height: 1; border-radius: 3px; flex-shrink: 0; }
.clear-btn:hover, .score-range-btn:hover { color: var(--text); background: var(--hover); }
.clear-btn[hidden] { display: none; }

.tool-row-all-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: none; padding: 0; width: 22px; height: 22px; border-radius: 4px; cursor: pointer; color: var(--muted); display: flex; align-items: center; justify-content: center; line-height: 1; transition: color 0.15s, background 0.15s; }
.tool-row-all-toggle:hover { color: var(--accent); background: var(--hover); }
.tool-row-all-toggle.active { color: var(--accent); background: var(--hover); }
.tool-row-all-toggle.disabled { cursor: not-allowed; opacity: 0.35; }
.tool-row-all-toggle.disabled:hover { color: var(--muted); background: none; }
.tool-row-all-toggle .ast-glyph { font-size: 15px; line-height: 1; display: inline-block; }

.tool-row-invert, .tool-row-reverse { padding: 5px; background: none; border: 0; cursor: pointer; color: var(--faint); display: flex; align-items: center; justify-content: center; line-height: 1; transition: color 0.15s; }
.tool-row-invert > svg, .tool-row-reverse > svg { display: block; }
.tool-row-invert:focus-visible, .tool-row-reverse:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; border-radius: 4px; }
.tool-row-invert.active { color: #e53935; }
.tool-row-reverse.active { color: var(--accent); }
.tool-row-invert.disabled { opacity: 0.4; cursor: default; }
@media (hover: hover) {
  .tool-row-invert:not(.active):not(.disabled):hover,
  .tool-row-reverse:not(.active):hover { color: var(--text); }
}
@media (prefers-reduced-motion: reduce) {
  .tool-row-invert, .tool-row-reverse, .tool-row-icon-glyph { transition: none; }
}

/* Deliberately redundant with the button: keep both — dropping this red slash on the
   tool's own icon loses inversion's at-a-glance read on the row. */
.tool-row.inverted > .tool-label .tool-row-icon-glyph,
.search-bar.inverted > .tool-label .tool-row-icon-glyph { filter: grayscale(1); opacity: 0.5; }
.tool-row.inverted > .tool-label .tool-row-icon::after,
.search-bar.inverted > .tool-label .tool-row-icon::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 22px; height: 2px;
  border-radius: 1px; background: #e53935; pointer-events: none;
  transform: translate(-50%, -50%) rotate(-45deg);
}
.tool-row-remove { background: none; border: none; color: var(--faint); cursor: pointer; padding: 5px; border-radius: 4px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.tool-row-remove:hover { color: var(--text); background: var(--hover); }
.tool-row-remove-placeholder { width: 24px; height: 24px; }
.search-bar > .tool-row-remove-placeholder { grid-column: -2 / -1; }
.search-bar.solo > .tool-row-remove-placeholder { width: 0; }
.tool-row > .tool-row-error-btn { grid-column: 6; justify-self: start; margin-left: 12px; }

/* Rebus pair list */
.tool-row > .rebus-pairs { margin-left: 12px; }
.rebus-pairs { display: flex; flex-direction: column; gap: 6px; padding: 2px 0; }
.rebus-pair { display: flex; align-items: center; gap: 6px; }
.rebus-pair .clearable-input { flex: 0 1 120px; }
.rebus-pair input.entry-input { width: 100%; min-width: 0; padding: 5px 24px 5px 8px; }
.rebus-arrow { color: var(--muted); flex: 0 0 auto; }
.rebus-pair-add, .rebus-pair-remove { background: none; border: none; color: var(--faint); cursor: pointer; padding: 4px; border-radius: 4px; line-height: 1; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.rebus-pair-add { padding: 2px; }
.rebus-pair-add:hover, .rebus-pair-remove:hover { color: var(--text); background: var(--hover); }

/* Rebus symbol suggestions popup */
.symbol-suggest { padding: 6px; }
.symbol-grid { display: grid; grid-template-columns: repeat(9, 28px); gap: 2px; }
.symbol-cell { font-size: 16px; line-height: 1; height: 28px; padding: 0; display: flex; align-items: center; justify-content: center; background: none; border: 1px solid transparent; border-radius: 4px; cursor: pointer; color: var(--text); }
.symbol-cell:hover { background: var(--hover); border-color: var(--border2); }
.tool-row-error-btn { background: none; border: none; padding: 0; cursor: default; font-size: 16px; line-height: 1; }
.tool-row-error-btn[hidden] { display: none; }
.tool-row-error-popover { position: fixed; z-index: 220; max-width: 320px; padding: 8px 11px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 6px; font-size: 12px; line-height: 1.4; box-shadow: 0 4px 14px rgba(0,0,0,0.25); overflow-wrap: anywhere; }
.tool-row-error-popover[hidden] { display: none; }
/* `@supports (-webkit-touch-callout)` tests for iOS Safari, which auto-zooms
   a focused input under 16px (Android and desktop browsers don't). */
@supports (-webkit-touch-callout: none) {
  .tool-row, .search-bar { --tool-control-h: 34px; }
  .tool-row-param input[type="text"],
  .tool-row-param input[type="number"],
  .range-filter input[type="text"],
  .entry-panel-fields input,
  .picker-search-wrap > input { font-size: 16px; }
}

/* ─── Sync sign & discovery banner ──────────────────────────────────────────── */
.sync-sign { display: inline-flex; align-items: center; gap: 6px; max-width: 220px;
  padding: 6px 9px; background: none; border: none; border-radius: 4px;
  font-family: inherit; font-size: 12px; line-height: 1.4; color: var(--text); cursor: pointer; }
.sync-sign:hover { background: var(--hover); }
.sync-sign.attention { color: var(--warn-fg); }
.sync-line-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 1px; }
.sync-ring { flex-shrink: 0; transform: rotate(-90deg); }
.sync-ring circle {
  fill: none; stroke-width: 2; stroke-linecap: round;
  stroke: var(--ok-fg);
  /* Dash and gap each a full turn, so offset 0 is a closed ring and one -2 sweep
     drains then refills without ever reversing. Halving it yanks the refill
     counter-clockwise. */
  stroke-dasharray: 1 1;
  stroke-dashoffset: 0;
}
.sync-sign--warn .sync-ring circle { stroke: var(--warn-fg); }
.sync-sign--saving .sync-ring circle {
  stroke: var(--accent);
  /* Duration is mirrored by SYNC_BUSY_PERIOD_MS in ui/sync-indicators.js. */
  animation: sync-ring-drain 0.9s linear infinite;
}
@keyframes sync-ring-drain {
  to { stroke-dashoffset: -2; }
}
@media (prefers-reduced-motion: reduce) {
  .sync-sign--saving .sync-ring circle { animation: none; }
}

#discovery-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 9px 16px; font-size: 13px; border-bottom: 1px solid var(--border2); }
html.light-mode #discovery-banner { background: color-mix(in srgb, var(--accent) 7%, var(--bg)); }
html.dark-mode #discovery-banner { background: color-mix(in srgb, var(--accent) 15%, var(--bg)); }
#discovery-banner p { flex: 1 1 240px; margin: 0; line-height: 1.45; color: var(--text); }
.discovery-banner-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.discovery-banner-import { font-size: 12px; padding: 4px 12px; }
.discovery-banner-close { background: none; border: none; font-size: 13px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 7px; border-radius: 4px; }
.discovery-banner-close:hover { background: var(--hover); color: var(--text); }

/* ─── Shared primitives ─────────────────────────────────────────────────────── */
/* Segmented control */
.seg-ctrl { display: flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.seg-btn { border: none; border-radius: 0; padding: 4px 10px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--btn-bg); cursor: pointer; font-family: inherit; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.active { background: var(--sel); color: var(--accent); }
.seg-btn:hover:not(.active) { background: var(--hover); }

.of-section { margin-bottom: 22px; }
.of-ctrls { margin-top: 12px; }
.of-flags { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(3, auto); grid-auto-flow: column; gap: 8px 16px; }
.of-flag { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; cursor: pointer; }
.of-flag input { cursor: pointer; }
.of-case { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.of-case-label { font-size: 13px; font-weight: 600; }

/* Empty states */
.no-rules { font-size: 12px; color: var(--faint); font-style: italic; margin-bottom: 3px; }
.stats-bar.stats-empty .stat-value { color: var(--faint); }
.stats-bar.stats-empty .histogram { visibility: hidden; }

/* Wordlist icons */
.wordlist-icon { width: 16px; height: 16px; flex-shrink: 0; vertical-align: middle; cursor: default; }
.wordlist-icon-img { border-radius: 3px; display: inline-block; }
.wordlist-name-icon { display: inline; white-space: nowrap; }
.wordlist-name-icon .wordlist-icon { width: 1em; height: 1em; vertical-align: -0.1em; }

/* Popup help */
.popup-help { position: fixed; z-index: 9999; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; font-size: 11px; color: var(--muted); line-height: 1.6; max-width: 380px; box-shadow: 0 4px 12px rgba(0,0,0,0.18); opacity: 0; transition: opacity 0.15s; }
.popup-help:not(.open) { pointer-events: none; }
.popup-help.open { opacity: 1; }
.popup-help .help-grid { column-count: 2; column-gap: 22px; }
.popup-help .help-grid.one-col { column-count: 1; }
.popup-help span { display: flex; align-items: baseline; gap: 5px; margin-bottom: 2px; break-inside: avoid; }
.popup-help kbd { font-family: var(--font-mono); font-size: 11px; color: var(--text); white-space: nowrap; }
.popup-help .help-ghost { font-style: italic; font-weight: 400; color: var(--text); }
.popup-help .help-link { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
.popup-help .help-link a { color: var(--accent); text-decoration: none; }
.popup-help .help-link a:hover { text-decoration: underline; }

/* Pattern assist */
/* Input above the highlight layer, whose backgrounds would hide the caret. */
.assist-field { background: var(--input-bg); border-radius: 4px; }
.assist-field input[data-assist] { position: relative; background: transparent; color: transparent; caret-color: var(--text); }
.assist-field input[data-assist]::selection { color: transparent; background: color-mix(in srgb, var(--accent) 35%, transparent); }
.assist-hl { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; overflow: hidden; pointer-events: none; color: var(--text); }
.assist-hl-text { white-space: pre; }
.assist-bad { color: var(--q-err); }
.assist-pair { outline: 1px solid var(--accent); border-radius: 2px; }
.assist-target { background: color-mix(in srgb, var(--accent) 22%, transparent); border-radius: 2px; }
.assist-panel { position: fixed; inset: auto; margin: 0; padding: 0; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,0.2); font-size: 12px; line-height: 1.5; color: var(--text); }
.assist-panel button, .assist-panel a { pointer-events: auto; }
.assist-panel:popover-open { display: flex; flex-direction: column; }
.assist-panel.above { flex-direction: column-reverse; }
.assist-panel > div { padding: 6px 10px; }
.assist-panel > div + div { border-top: 1px solid var(--border2); }
.assist-panel.above > div + div { border-top: 0; border-bottom: 1px solid var(--border2); }
.assist-panel.compact .assist-cheat { display: none; }
.assist-panel { opacity: 0; transition: opacity 0.4s ease, overlay 0.4s allow-discrete, display 0.4s allow-discrete; }
/* Display and overlay transition only on close. Reopened mid-fade-out, WebKit
   reverses the display transition and keeps display: none, so placement
   measures the panel at zero height and parks it over the box. */
.assist-panel:popover-open { opacity: 1; transition: opacity 0.4s ease; }
@starting-style { .assist-panel:popover-open { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .assist-panel { transition: none; } }
.assist-panel code, .assist-panel kbd { font-family: var(--font-mono); }
.assist-quiet { color: var(--muted); }
.assist-error { background: var(--error-bg); box-shadow: inset 3px 0 var(--q-err); }
.assist-hint { background: var(--callout-bg); box-shadow: inset 3px 0 var(--callout-border); }
.assist-hint.tip { background: transparent; box-shadow: inset 3px 0 var(--accent); }
.assist-fixes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.assist-fix { font-size: 12px; padding: 3px 8px; border-color: var(--accent); color: var(--accent); background: var(--bg); }
.assist-fix:hover:not(:disabled) { background: var(--accent); color: white; }
.assist-cheat-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.assist-cheat-grid { display: grid; grid-template-columns: max-content 1fr 20px max-content 1fr; }
.assist-cheat-row { display: grid; grid-template-columns: subgrid; grid-column: 1 / 3; column-gap: 8px; align-items: baseline; justify-content: stretch; padding: 2px 4px; border: 0; border-radius: 4px; background: none; font-size: 11.5px; line-height: 1.4; color: var(--muted); text-align: left; }
.assist-cheat-row:nth-child(even) { grid-column: 4 / 6; }
button.assist-cheat-row:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.assist-cheat-row kbd { font-size: 11.5px; color: var(--text); white-space: nowrap; }
@media (max-width: 559px) {
  .assist-cheat-grid { grid-template-columns: max-content 1fr; }
  .assist-cheat-row:nth-child(even) { grid-column: 1 / 3; }
}
.assist-cheat-dense { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border2); }
.assist-cheat-dense-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
.assist-cheat-dense .assist-cheat-row { display: flex; gap: 6px; grid-column: auto; font-size: 11px; }
.assist-cheat-dense .assist-cheat-row kbd { font-size: 11px; color: var(--muted); }
.assist-panel > .assist-lines { padding: 0; }
.assist-lines-copy { display: block; width: 100%; margin: 0; padding: 6px 10px; border: 0; border-radius: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.assist-lines-copy:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.assist-lines code { display: block; font-size: 12px; overflow-wrap: anywhere; }
.assist-cheat-link { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border2); }
.assist-cheat-link a { color: var(--accent); text-decoration: none; }
.assist-cheat-link a:hover { text-decoration: underline; }

/* Dialog helpers */
.dialog-actions { text-align: right; }

@keyframes shake {
  0%, 100%  { transform: translateX( 0px); }
  20%       { transform: translateX(-4px); }
  60%       { transform: translateX( 4px); }
  80%       { transform: translateX(-2px); }
}
.shake { animation: shake 0.3s ease; }

/* Shared icons */
.icon-trash  { width: 14px; height: 14px; display: inline-block; vertical-align: middle; }

/* Toast undo link */
.toast .toast-action { margin-left: 10px; color: #90caf9; text-decoration: underline; cursor: pointer; }

/* ─── New-tools reveal ──────────────────────────────────────────────────────── */
.nt-overlay {
  --gold: #ffd96b; --gold-deep: #c98a2a;
  --glow: var(--gold); --glow-soft: #ffe9a8;
  position: fixed; inset: 0; z-index: 250;
  opacity: 0; pointer-events: none; transition: opacity .4s ease;
}
.nt-overlay.show { opacity: 1; pointer-events: auto; }
/* The scroll layer sits ABOVE the backdrop (separate sibling, not a child of it),
   so its scrollbar renders over the blur rather than behind it when loot overflows. */
.nt-scroll {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  /* Pad the top so the chest sits at viewport center no matter how many cards
     follow (~banner 52px + half the 340px scene = 222px). The cards flow below
     and scroll; the chest stays put instead of being shoved up by a tall stack.
     overflow-x is clipped because the 600px rays would otherwise scroll sideways. */
  padding: max(28px, calc(50vh - 222px)) 16px 28px;
  overflow-x: hidden; overflow-y: auto;
}
/* Don't let a short viewport compress the chest scene (its 3D chest is a fixed
   size and would spill out of a shrunk box onto the banner) — overflow + scroll. */
.nt-scroll > * { flex-shrink: 0; }
html.nt-scroll-lock { overflow: hidden; padding-right: var(--nt-sbw, 0px); }

/* The dimming backdrop is its own layer so dismiss can fade it (and the chest)
   while the cards keep flying — fading the overlay itself would take them too. */
.nt-backdrop {
  position: fixed; inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%,
    color-mix(in srgb, color-mix(in srgb, var(--accent) 16%, var(--bg)) 70%, transparent) 0%,
    color-mix(in srgb, var(--bg) 70%, transparent) 70%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
html.light-mode .nt-backdrop {
  background: radial-gradient(120% 90% at 50% 45%,
    color-mix(in srgb, color-mix(in srgb, gray 14%, var(--bg)) 70%, transparent) 0%,
    color-mix(in srgb, var(--bg) 70%, transparent) 70%);
}
/* animation:none cancels the banner's entrance keyframes, whose fill:forwards
   would otherwise pin opacity:1 and keep it from fading with the rest. */
.nt-overlay.dismissing .nt-backdrop,
.nt-overlay.dismissing .nt-scene,
.nt-overlay.dismissing .nt-banner { animation: none; opacity: 0; transition: opacity .3s ease; }

.nt-dismiss {
  position: relative; z-index: 10; margin-top: 32px;
  font-family: inherit; font-size: 14px; font-weight: 700; letter-spacing: .03em;
  color: #3a2a06;
  background: linear-gradient(var(--glow), var(--gold-deep));
  border: 1px solid color-mix(in srgb, var(--gold-deep) 80%, #000);
  border-radius: 999px; padding: 10px 28px; cursor: pointer;
  opacity: 0; pointer-events: none;
  transition: opacity .35s ease, transform .1s ease, box-shadow .15s ease;
  box-shadow: 0 4px 18px rgba(0,0,0,.28);
}
.nt-dismiss.show { opacity: 1; pointer-events: auto; }
/* Scoped past the app's generic `button:hover` (which would paint it --hover,
   i.e. near-white in light / near-black in dark): the button stays gold. */
.nt-overlay .nt-dismiss:hover { background: linear-gradient(#ffe48d, #d89a37); }
.nt-overlay .nt-dismiss:active { transform: translateY(1px); }
.nt-dismiss:focus { outline: none; }
.nt-dismiss:focus-visible { outline: 2px solid color-mix(in srgb, var(--glow) 70%, transparent); outline-offset: 2px; }

.nt-banner {
  position: relative; z-index: 10;
  font-size: 13px; font-weight: 700; letter-spacing: .22em; text-indent: .22em;
  text-transform: uppercase; color: var(--glow); opacity: 0;
  margin-bottom: 22px; padding: 7px 18px; border-radius: 999px;
  background: #1a1822;
  border: 1px solid color-mix(in srgb, var(--glow) 38%, transparent);
  text-shadow: 0 0 10px color-mix(in srgb, var(--glow) 55%, transparent);
  box-shadow: 0 2px 16px rgba(0,0,0,.28);
}
html.light-mode .nt-banner { background: #63606a; }
.nt-banner.in { animation: nt-banner-in .5s ease forwards; }
@keyframes nt-banner-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.nt-scene { position: relative; width: 360px; height: 340px; display: grid; place-items: center; perspective: 1100px; perspective-origin: 50% 42%; }

/* No CSS filter here: a filtered element overlapping the backdrop-filter
   backdrop renders a visible seam at its bounds in Chrome. */
.nt-rays {
  position: absolute; width: 600px; height: 600px; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--glow) 72%, transparent) 0deg 7deg, transparent 7deg 20deg);
  opacity: 0;
  -webkit-mask-image: radial-gradient(circle, black 18%, transparent 62%);
          mask-image: radial-gradient(circle, black 18%, transparent 62%);
  animation: nt-spin 14s linear infinite; animation-play-state: paused;
}
.nt-overlay.show .nt-rays { animation-play-state: running; }
.nt-scene.open .nt-rays { opacity: .8; transition: opacity .25s ease; }
@keyframes nt-spin { to { transform: rotate(360deg); } }

.nt-aura {
  position: absolute; width: 360px; height: 360px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--glow) 55%, transparent) 0%, transparent 66%);
  opacity: 0;
}
.nt-scene.charging .nt-aura { animation: nt-aura-pulse 1.1s ease-in-out infinite; }
.nt-scene.open .nt-aura { opacity: .95; transition: opacity .25s ease; }
@keyframes nt-aura-pulse { 0%,100% { opacity: .25; transform: scale(.92); } 50% { opacity: .6; transform: scale(1.04); } }

.nt-chest { position: relative; width: 200px; height: 92px; transform-origin: 50% 100%; transform-style: preserve-3d; }
.nt-scene.appear .nt-chest { animation: nt-chest-pop .6s cubic-bezier(.34,1.56,.64,1); }
@keyframes nt-chest-pop { from { transform: translateY(70px) scale(.45); } to { transform: translateY(0) scale(1); } }
.nt-scene.charging .nt-chest { animation: nt-chest-shake .45s ease-in-out infinite; }
@keyframes nt-chest-shake {
  0%,100% { transform: translate(0,0) rotate(0); }
  20% { transform: translate(-3px,1px) rotate(-1.2deg); }
  40% { transform: translate(3px,-1px) rotate(1.2deg); }
  60% { transform: translate(-2px,1px) rotate(-.8deg); }
  80% { transform: translate(2px,-1px) rotate(.8deg); }
}
.nt-scene.windup .nt-chest { animation: nt-chest-windup .32s cubic-bezier(.5,0,.6,1) forwards; }
@keyframes nt-chest-windup {
  0% { transform: scale(1,1); }
  60% { transform: scale(1.1,.86) translateY(7px); }
  100% { transform: scale(.97,1.05) translateY(-3px); }
}

.nt-chest-3d {
  --w: 200px; --h: 92px; --d: 118px;
  --lid-closed: 0deg; --lid-open: 104deg;
  position: absolute; inset: 0;
  transform-style: preserve-3d; transform-origin: 50% 50%; transform: rotateX(0deg);
}

.nt-cf { position: absolute; top: 0; left: 0; }
.nt-cf-front, .nt-cf-back { width: var(--w); height: var(--h); background: linear-gradient(#7a4a24, #5d3417 60%, #4a2911); border: 2px solid #34200f; }
.nt-cf-front { transform: translateZ(calc(var(--d) / 2)); box-shadow: inset 0 -12px 20px rgba(0,0,0,.4); }
.nt-cf-back { transform: translateZ(calc(var(--d) / -2)) rotateY(180deg); }
.nt-cf-left, .nt-cf-right { width: var(--d); height: var(--h); left: calc((var(--w) - var(--d)) / 2); background: linear-gradient(#693e1e, #46270f); border: 2px solid #34200f; }
.nt-cf-left { transform: rotateY(-90deg) translateZ(calc(var(--w) / 2)); }
.nt-cf-right { transform: rotateY(90deg) translateZ(calc(var(--w) / 2)); }
.nt-cf-bottom { width: var(--w); height: var(--d); top: calc((var(--h) - var(--d)) / 2); background: #2e1d0c; transform: rotateX(90deg) translateZ(calc(var(--h) / 2)); }

.nt-glow {
  position: absolute; left: 50%; top: 0; width: calc(var(--w) * .82); height: var(--d);
  transform: translate(-50%, -32%); border-radius: 50%;
  background: radial-gradient(ellipse at 50% 50%, #fff 0%, var(--glow-soft) 40%, var(--glow) 68%, transparent 82%);
  opacity: 0; pointer-events: none;
}
.nt-scene.open .nt-glow { opacity: .95; animation: nt-glow-pulse 1.6s ease-in-out infinite; }
@keyframes nt-glow-pulse { 0%,100% { opacity: .8; } 50% { opacity: 1; } }

.nt-lid {
  position: absolute; left: 50%; top: 0; width: 0; height: 0;
  transform-style: preserve-3d; transform-origin: 0 0;
  transform: translateZ(calc(var(--d) / -2)) rotateX(var(--lid-closed));
}
.nt-scene.open .nt-lid { animation: nt-lid-open .6s cubic-bezier(.3,.8,.35,1) forwards; }
@keyframes nt-lid-open {
  0% { transform: translateZ(calc(var(--d) / -2)) rotateX(var(--lid-closed)); }
  72% { transform: translateZ(calc(var(--d) / -2)) rotateX(116deg); }
  100% { transform: translateZ(calc(var(--d) / -2)) rotateX(var(--lid-open)); }
}
.nt-seg {
  position: absolute; left: 0; top: 0; width: var(--w); margin-left: calc(var(--w) / -2);
  border-left: 2px solid #34200f; border-right: 2px solid #34200f;
  background:
    linear-gradient(90deg,
      transparent 30px, var(--gold-deep) 31px, var(--gold) 39px, #fff6d8 44px, var(--gold) 49px, var(--gold-deep) 57px, transparent 58px,
      transparent 141px, var(--gold-deep) 142px, var(--gold) 150px, #fff6d8 155px, var(--gold) 160px, var(--gold-deep) 168px, transparent 169px),
    linear-gradient(#8a5529, #6d3f1d);
}
.nt-lid-under {
  position: absolute; left: 0; top: 0; width: var(--w); height: var(--d);
  margin-left: calc(var(--w) / -2); margin-top: calc(var(--d) / -2);
  transform: translateZ(calc(var(--d) / 2)) rotateX(90deg);
  background: radial-gradient(ellipse at 50% 45%, #d8ad77, #a87b4a 70%, #875f36);
  border: 2px solid #5a3a1c; box-shadow: inset 0 0 26px rgba(0,0,0,.5);
}

.nt-band {
  position: absolute; width: 24px; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold) 45%, #fff6d8 50%, var(--gold) 55%, var(--gold-deep));
  box-shadow: 0 0 0 1px rgba(0,0,0,.25);
}
.nt-band-l { left: 32px; }
.nt-band-r { right: 32px; }
.nt-lock {
  position: absolute; left: 50%; top: -15px; transform: translateX(-50%);
  width: 32px; height: 30px; border-radius: 5px;
  background: radial-gradient(circle at 50% 35%, #fff6d8, var(--gold) 40%, var(--gold-deep) 90%);
  border: 2px solid #6e4a14;
}
.nt-lock::after {
  content: ""; position: absolute; left: 50%; top: 12px; transform: translateX(-50%);
  width: 6px; height: 9px; border-radius: 0 0 3px 3px; background: #4a2f0a;
}

.nt-flash {
  position: absolute; width: 300px; height: 300px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, var(--glow-soft) 30%, transparent 70%);
  opacity: 0; pointer-events: none; z-index: 6;
}
.nt-particle { position: absolute; border-radius: 50%; pointer-events: none; z-index: 6; }

.nt-loot { position: relative; z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 30px; padding: 0 16px; }
.nt-line { display: flex; gap: 12px; justify-content: center; }
.nt-overlay .tool-card {
  flex: 0 0 200px;
  pointer-events: none; cursor: default;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--glow) 40%, transparent), 0 0 22px color-mix(in srgb, var(--glow) 35%, transparent);
}
/* Narrower on phones so two fit per row (matches CARD_W in buildLoot). */
@media (max-width: 759px) {
  .nt-overlay .tool-card { flex: 0 0 160px; }
  /* Override the desktop centering: on short phone viewports it drops the loot
     and dismiss button below the fold. Pin the scene high and trim its height. */
  .nt-scroll { padding-top: 80px; }
  .nt-scene { height: 280px; }
}

@media (prefers-reduced-motion: reduce) {
  .nt-rays, .nt-aura, .nt-glow { animation: none !important; }
  .nt-banner.in { animation: none; opacity: 1; transform: none; }
  .nt-scene.open .nt-lid { animation: none; transform: translateZ(calc(var(--d) / -2)) rotateX(var(--lid-open)); }
}


/* questrel.com/grawlix: answer words link to their definition page (ui/entries-table.js defLink). */
a.def-link { color: inherit; text-decoration: none; }
a.def-link:hover, a.def-link:focus-visible { text-decoration: underline; text-underline-offset: 2px; }
