/* app.css — the shared app layer between Lantern and the four pages.
 *
 * Load order is lantern.css → app.css → the page's own inline <style>, so a
 * page still wins over anything here.
 *
 * Section (a) is a bridge, not a second token set. What is left of it is exactly
 * the palette vocabulary `/live` grew — and those names are load-bearing for two
 * reasons that outlive the migration: they are the rows in `public/js/tune.js`'s
 * REGISTRY, which edits tokens *by name*, and `live.js` rewrites `--accent` at
 * runtime from the album art. Everything else that used to live here is gone,
 * its consumers now reading `--ln-*` directly. Nothing new belongs in it.
 *
 * Section (b) owns the components the pages genuinely share — above all the DOM
 * that `public/js/lyric-common.js` renders, which three pages used to style
 * three different ways.
 */

/* ========================================================================== *
 * (a) Legacy token alias layer
 * ========================================================================== */

:root {
  --bg: var(--ln-canvas);
  --panel: var(--ln-surface);
  --line: var(--ln-hairline);
  --line2: var(--ln-hairline-faint);
  --txt: var(--ln-ink);
  --mut: var(--ln-ink-secondary);
  --mut2: var(--ln-ink-tertiary);
  --glass: var(--ln-glass);
  --accent: var(--ln-accent);
  --success: var(--ln-positive);
  --warning: var(--ln-caution);
  --danger: var(--ln-critical);
  --ui: var(--ln-font);
  --serif: var(--ln-font-serif);
  --lyric: var(--ln-font-ar);
}

/* ========================================================================== *
 * (b) Shared app components
 * ========================================================================== */

/* A class selector that sets `display` outranks the UA's `[hidden]`, and this
   layer sets a lot of them — so `hidden` has to win outright. */
[hidden] {
  display: none !important;
}

/* Present to assistive tech, absent to the eye — for the dialog headings that
   name an overlay whose title is carried visually by its own controls. Not
   `display: none`, which would take it out of the accessibility tree too. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* -- App shell ------------------------------------------------------------ */

header {
  display: flex;
  align-items: center;
  gap: var(--ln-md);
  padding: var(--ln-lg) var(--ln-xl);
  border-bottom: 1px solid var(--ln-hairline);
  background: color-mix(in srgb, var(--ln-surface) 70%, transparent);
}

.mode-switcher {
  position: relative;
  flex: 0 0 auto;
}
.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--ln-xs);
  padding: var(--ln-xs) 0;
  border: 1px solid transparent;
  background: none;
  color: var(--ln-accent);
  font-family: inherit;
  font-size: var(--ln-fs-title);
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}
/* A transparent 44px hit area around the header controls, so the touch target
   meets the minimum without enlarging what is drawn. */
.mode-btn,
.settings-btn {
  position: relative;
}
.mode-btn::before,
.settings-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100%, 44px);
  height: max(100%, 44px);
  transform: translate(-50%, -50%);
}
.mode-btn h1 {
  font: inherit;
  color: inherit;
  line-height: inherit;
  margin: 0;
}
/* `▾` is U+25BE, a *small* triangle: at micro it read as a full stop next to the
   title. Inline-block because a transform does not apply to an inline box, which
   silently dropped the open-state rotation below. */
.chev {
  display: inline-block;
  color: var(--ln-ink-secondary);
  font-size: var(--ln-fs-callout);
  line-height: 1;
  transition: transform var(--ln-t-tap) var(--ln-ease);
}
.mode-btn[aria-expanded='true'] .chev {
  color: var(--ln-accent);
  transform: rotate(180deg);
}
.mode-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 30;
  min-width: 190px;
  margin-top: var(--ln-xs);
  padding: var(--ln-xs);
  list-style: none;
  border: 1px solid var(--ln-hairline);
  border-radius: var(--ln-r-sm);
  background-color: var(--ln-surface);
  background-image: var(--ln-grain), var(--ln-sheen);
  background-size: var(--ln-grain-size), auto;
  background-repeat: repeat, no-repeat;
  box-shadow: var(--ln-e-floating);
}
.mode-menu.hidden,
.mode-menu[hidden] {
  display: none;
}
.mode-menu a {
  display: block;
  padding: var(--ln-sm) var(--ln-md);
  border-radius: var(--ln-r-xs);
  color: var(--ln-ink);
  font-size: var(--ln-fs-callout);
  text-decoration: none;
}
.mode-menu a:hover {
  background: color-mix(in srgb, currentColor 8%, transparent);
}
.mode-menu a[aria-current='page'] {
  color: var(--ln-accent);
  background: var(--ln-accent-wash);
}

.header-group {
  display: flex;
  align-items: center;
  gap: var(--ln-sm);
}
.header-group label {
  color: var(--ln-ink-secondary);
  font-size: var(--ln-fs-caption);
}

.settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-left: auto;
  border: 1px solid var(--ln-hairline);
  border-radius: var(--ln-r-xs);
  background: none;
  color: var(--ln-ink-secondary);
  cursor: pointer;
  transition:
    color var(--ln-t-tap) var(--ln-ease),
    border-color var(--ln-t-tap) var(--ln-ease),
    background-color var(--ln-t-tap) var(--ln-ease);
}
.settings-btn:hover {
  color: var(--ln-ink);
  background: color-mix(in srgb, currentColor 8%, transparent);
}
.settings-btn[aria-expanded='true'] {
  color: var(--ln-accent);
  border-color: color-mix(in srgb, var(--ln-accent) 42%, transparent);
  background: var(--ln-accent-wash);
}
.settings-btn svg {
  display: block;
  width: 18px;
  height: 18px;
}

.settings-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ln-md);
  padding: var(--ln-md) var(--ln-xl);
  border-bottom: 1px solid var(--ln-hairline);
  background: var(--ln-well);
}
.settings-panel.hidden,
.settings-panel[hidden] {
  display: none;
}

/* Hamsa pronunciation controls use the same compact chip language as the
   dictionary actions. The speaker glyph and accent tint distinguish generated
   Lebanese audio without introducing a competing shape. */
.tts-settings {
  display: flex;
  align-items: center;
  gap: var(--ln-sm);
}
.tts-settings label {
  color: var(--ln-ink-secondary);
  font-size: var(--ln-fs-caption);
}
.tts-settings .ln-select {
  min-width: 180px;
}
.tts-play.loading {
  cursor: wait;
  opacity: .62;
}
.tts-play:focus-visible {
  outline: 2px solid var(--ln-accent);
  outline-offset: 2px;
}

/* -- Auth gate ----------------------------------------------------------- */

#password-gate,
.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: var(--ln-lg);
  background: color-mix(in srgb, var(--ln-media) 66%, transparent);
  backdrop-filter: blur(8px);
}
#password-gate.hidden,
.gate[hidden] {
  display: none;
}
.gate-box {
  width: min(400px, 100%);
  padding: var(--ln-xl);
  border: 1px solid var(--ln-hairline);
  border-radius: var(--ln-r-lg);
  background-color: var(--ln-surface);
  background-image: var(--ln-grain), var(--ln-sheen);
  background-size: var(--ln-grain-size), auto;
  background-repeat: repeat, no-repeat;
  box-shadow: var(--ln-e-floating);
  color: var(--ln-ink);
  text-align: center;
}
.gate-box h2 {
  margin: 0 0 var(--ln-sm);
  font-size: var(--ln-fs-title);
  font-weight: 600;
}
.gate-box p {
  margin: 0 0 var(--ln-lg);
  color: var(--ln-ink-secondary);
  font-size: var(--ln-fs-callout);
}
.gate-error {
  margin-top: var(--ln-sm);
  color: var(--ln-critical);
  font-size: var(--ln-fs-caption);
}
.gate-actions {
  display: flex;
  gap: var(--ln-sm);
}
.gate-register {
  display: flex;
  gap: var(--ln-sm);
  margin-top: var(--ln-md);
}
.gate-register input {
  flex: 1;
}
.gate-cancel {
  border: 0;
  background: none;
  color: var(--ln-ink-secondary);
  font: inherit;
  font-size: var(--ln-fs-callout);
  cursor: pointer;
}
.gate-cancel:hover {
  color: var(--ln-ink);
}

/* -- Lyric / caption renderer (the lyric-common.js contract) -------------- */

.line-block {
  position: relative; /* anchors .dialect-tag */
  padding: var(--ln-md) 0;
  border-bottom: 1px solid var(--ln-hairline-faint);
}
.line-block:first-child {
  padding-top: 0;
}
.line-block.english {
  padding: var(--ln-md) 0;
}
/* A failed line keeps its lyric, so the failure has to read off the edge and
   the retry row — which live outside `.line-en` because /live can hide that. */
.line-block.line-failed {
  border-inline-start: 2px solid color-mix(in srgb, var(--ln-critical) 55%, transparent);
  padding-inline-start: var(--ln-sm);
}
.line-block.line-failed .line-ar {
  opacity: 0.72;
}
.line-actions {
  margin-top: var(--ln-sm);
}
.line-block.pending .line-ar {
  opacity: 0.55;
  transition: opacity var(--ln-t-move) var(--ln-ease);
}

.line-ar {
  font-family: var(--ln-font-ar);
  font-size: var(--ln-fs-ar-row);
  line-height: var(--ln-lh-ar);
  direction: rtl;
  unicode-bidi: isolate;
  text-align: right;
  color: var(--ln-ink);
}
.line-en {
  margin-top: var(--ln-sm);
  color: var(--ln-ink-secondary);
  font-family: var(--ln-font-serif);
  font-size: var(--ln-fs-caption);
  font-style: italic;
  line-height: 1.55;
  direction: ltr;
}
/* An English-only sung line is the line, not a gloss under one. */
.line-en-primary {
  color: var(--ln-ink);
  font-size: var(--ln-fs-body);
  line-height: 1.6;
  direction: ltr;
}

.lyric-word {
  font-family: var(--ln-font-ar);
  padding: 1px 2px;
  border-bottom: 1px dotted var(--ln-ink-tertiary);
  border-radius: var(--ln-xs);
  cursor: pointer;
  unicode-bidi: isolate;
  transition:
    background-color var(--ln-t-tap) var(--ln-ease),
    border-color var(--ln-t-tap) var(--ln-ease),
    color var(--ln-t-tap) var(--ln-ease);
}
.lyric-word:hover {
  border-bottom-color: var(--ln-accent);
  background: var(--ln-accent-wash);
}
.lyric-word.active {
  border-bottom-color: var(--ln-accent);
  background: var(--ln-accent-wash);
  color: var(--ln-accent);
}
/* The word being spoken right now (podcast word-sync). */
.lyric-word.spoken {
  border-bottom-color: var(--ln-ember);
  background: color-mix(in srgb, var(--ln-ember) 16%, transparent);
}

.lyric-section {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--ln-sm);
  padding: var(--ln-xl) 0 var(--ln-sm);
  border-bottom: 1px solid var(--ln-hairline-faint);
}
.lyric-section:first-child {
  padding-top: 0;
}
.lyric-section-title {
  color: var(--ln-accent);
  font-size: var(--ln-fs-micro);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.lyric-section-sub {
  display: inline-flex;
  align-items: baseline;
  gap: var(--ln-xs);
  color: var(--ln-ink-secondary);
  font-size: var(--ln-fs-caption);
}
.lyric-section-sub::before {
  content: '·';
  color: var(--ln-ink-tertiary);
}

.lyric-break {
  display: flex;
  justify-content: center;
  padding: var(--ln-md) 0;
  border-bottom: 1px solid var(--ln-hairline-faint);
}
.lyric-break > span {
  display: inline-block;
  padding: var(--ln-xs) var(--ln-md);
  border: 1px dashed var(--ln-hairline);
  border-radius: var(--ln-r-pill);
  color: var(--ln-ink-secondary);
  font-size: var(--ln-fs-caption);
  font-style: italic;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Lantern's `.ln-skeleton` recipe under the class name lyric-common.js emits,
   plus the line-sized box it needs. CSS has no way to say "and also that rule",
   so the declarations are repeated — but the gradient, the `ln-shimmer`
   keyframes and its reduced-motion rule are the package's, so there is one
   shimmer in the app rather than two that drifted apart. */
.line-skeleton {
  display: inline-block;
  height: 14px;
  border-radius: var(--ln-r-xs);
  background: linear-gradient(
    90deg,
    var(--ln-surface-quiet) 25%,
    color-mix(in srgb, var(--ln-surface-quiet), var(--ln-ink) 5%) 37%,
    var(--ln-surface-quiet) 63%
  );
  background-size: 400% 100%;
  animation: ln-shimmer 1.4s ease-in-out infinite;
  color: transparent;
  user-select: none;
}
.line-skeleton.tall {
  height: 24px;
  margin-bottom: var(--ln-hair);
}

.line-retry {
  padding: var(--ln-xs) var(--ln-sm);
  border: 1px dashed color-mix(in srgb, var(--ln-critical) 55%, transparent);
  border-radius: var(--ln-r-xs);
  background: none;
  color: var(--ln-critical);
  font: inherit;
  font-size: var(--ln-fs-caption);
  cursor: pointer;
}
.line-retry:hover {
  background: color-mix(in srgb, var(--ln-critical) 12%, transparent);
}

.dialect-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--ln-xs) var(--ln-sm);
  border: 1px solid color-mix(in srgb, var(--ln-accent) 42%, transparent);
  border-radius: var(--ln-r-pill);
  background: var(--ln-accent-wash);
  color: var(--ln-accent);
  font-size: var(--ln-fs-micro);
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
}
.dialect-tag {
  position: absolute;
  top: var(--ln-md);
  left: 0;
  padding: var(--ln-hair) var(--ln-sm);
  border: 1px solid var(--ln-hairline);
  border-radius: var(--ln-r-pill);
  color: var(--ln-ink-secondary);
  font-size: var(--ln-fs-micro);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  pointer-events: none;
}

/* -- Word card ----------------------------------------------------------- */

.word-card {
  display: flex;
  flex-direction: column;
  gap: var(--ln-sm);
  min-width: 220px;
  /* `100vw` includes the scrollbar, but it cannot bite here: `min()` caps the
     card at 360px, so the viewport term only wins below a ~384px viewport —
     narrow enough that there is no classic scrollbar to over-count. */
  max-width: min(360px, calc(100vw - var(--ln-xl)));
  padding: var(--ln-md);
  border: 1px solid var(--ln-hairline);
  border-radius: var(--ln-r-md);
  background-color: var(--ln-surface);
  background-image: var(--ln-grain), var(--ln-sheen);
  background-size: var(--ln-grain-size), auto;
  background-repeat: repeat, no-repeat;
  box-shadow: var(--ln-e-floating);
  color: var(--ln-ink);
}
/* Anchored under its caption rather than floating over the page. */
.word-card.inline {
  position: relative;
  width: min(390px, 100%);
  min-width: 0;
  margin: var(--ln-sm) 0 var(--ln-xs) auto;
  box-shadow: var(--ln-e-raised);
}
.word-card .main-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--ln-lg);
}
.word-card .word-en {
  color: var(--ln-ink-secondary);
  font-size: var(--ln-fs-callout);
  line-height: 1.4;
}
.word-card .word-ar {
  flex: 0 0 auto;
  font-family: var(--ln-font-ar);
  font-size: var(--ln-fs-ar-row);
  font-weight: 600;
  line-height: var(--ln-lh-ar);
  direction: rtl;
  unicode-bidi: isolate;
  text-align: right;
  color: var(--ln-ink);
}
.word-card .word-chips {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ln-xs);
  direction: ltr;
}
.word-definitions {
  padding: var(--ln-sm) var(--ln-md);
  border-inline-start: 2px solid color-mix(in srgb, var(--ln-accent) 45%, transparent);
  border-radius: 0 var(--ln-r-xs) var(--ln-r-xs) 0;
  background: var(--ln-well);
  color: var(--ln-ink-secondary);
  font-size: var(--ln-fs-caption);
  line-height: 1.45;
}
.word-definitions ul {
  margin: 0;
  padding-inline-start: var(--ln-lg);
}
.word-definitions-label {
  margin-bottom: var(--ln-hair);
  color: var(--ln-ink-tertiary);
  font-size: var(--ln-fs-micro);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.word-contextual-meaning {
  color: var(--ln-accent);
  font-size: var(--ln-fs-caption);
  line-height: 1.45;
}
.dict-caveat {
  padding-top: var(--ln-xs);
  border-top: 1px solid var(--ln-hairline-faint);
  color: var(--ln-ink-tertiary);
  font-size: var(--ln-fs-micro);
  font-style: italic;
}

/* -- Chips --------------------------------------------------------------- */

/* One capsule for the dictionary actions, whether they were rendered by
   lyric-common (`.chip`) or by index.html's own decorator (`.dict-btn`). Each
   variant only swaps `--chip-color`. */
.chip,
.dict-btn {
  --chip-color: var(--ln-ink-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ln-xs);
  min-width: 26px;
  height: 26px;
  padding: 0 var(--ln-xs);
  border: 1px solid color-mix(in srgb, var(--chip-color) 38%, transparent);
  border-radius: var(--ln-r-xs);
  background: color-mix(in srgb, var(--chip-color) 10%, transparent);
  color: var(--chip-color);
  font-family: inherit;
  font-size: var(--ln-fs-micro);
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--ln-t-tap) var(--ln-ease),
    border-color var(--ln-t-tap) var(--ln-ease),
    color var(--ln-t-tap) var(--ln-ease);
}
.chip svg,
.dict-btn svg {
  display: block;
  width: 13px;
  height: 13px;
}
.chip:hover:not(:disabled),
.dict-btn:hover:not([disabled]) {
  background: color-mix(in srgb, var(--chip-color) 20%, transparent);
  border-color: color-mix(in srgb, var(--chip-color) 60%, transparent);
}
.chip:disabled,
.dict-btn[disabled] {
  opacity: 0.4;
  cursor: default;
}
.word-chips.loading-chips .chip {
  opacity: 0.4;
  pointer-events: none;
}
.chip.play,
.dict-btn.play,
.tts-play {
  --chip-color: var(--ln-accent);
}
.chip.playing,
.dict-btn.play.playing {
  background: color-mix(in srgb, var(--chip-color) 24%, transparent);
}
.chip.check,
.dict-btn.check {
  --chip-color: var(--ln-positive);
}
.chip.check.non-lebanese {
  --chip-color: var(--ln-ink-tertiary);
}
.chip.examples,
.dict-btn.examples {
  --chip-color: var(--ln-caution);
}
.chip.star {
  --chip-color: var(--ln-ember);
}
.chip.star.starred {
  border-color: transparent;
  background: var(--ln-ember);
  color: var(--ln-on-ember);
}

/* Save and Add to deck are the two save verbs, and they are never a bare glyph:
   one ★ beside one deck icon cannot say which of them schedules the word. The
   label IS the affordance, so it is what survives a narrow card. */
.chip.labelled {
  min-width: 0;
  padding: 0 var(--ln-sm);
  font-size: var(--ln-fs-micro);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.chip.labelled .chip-label {
  white-space: nowrap;
}
/* Add to deck is the primary of the pair — it is the one that creates
   something. */
.chip.deck {
  --chip-color: var(--ln-accent);
  border-color: transparent;
  background: var(--ln-accent);
  color: var(--ln-on-accent);
}
.chip.deck:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ln-accent) 86%, black);
  border-color: transparent;
}
.chip.deck.done,
.chip.deck.done:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--ln-positive) 55%, transparent);
  background: color-mix(in srgb, var(--ln-positive) 14%, transparent);
  color: var(--ln-positive);
}
.chip.deck[aria-busy='true'] {
  opacity: 0.6;
}
/* Matched through the English gloss rather than the Arabic spelling. */
.dict-btn.via-english {
  border-style: dashed;
}

/* -- Examples dialog (livingarabic) -------------------------------------- */

dialog.la-dialog {
  inset: 0;
  width: 100%;
  max-width: min(640px, 92vw);
  max-height: 80vh;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--ln-hairline);
  border-radius: var(--ln-r-lg);
  background-color: var(--ln-surface);
  background-image: var(--ln-grain), var(--ln-sheen);
  background-size: var(--ln-grain-size), auto;
  background-repeat: repeat, no-repeat;
  box-shadow: var(--ln-e-floating);
  color: var(--ln-ink);
}
dialog.la-dialog::backdrop {
  background: color-mix(in srgb, var(--ln-media) 55%, transparent);
  backdrop-filter: blur(3px);
}
.la-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ln-md);
  padding: var(--ln-md) var(--ln-lg);
  border-bottom: 1px solid var(--ln-hairline);
}
.la-dialog-header h3,
.la-dialog-title {
  flex: 1;
  margin: 0;
  font-family: var(--ln-font-ar);
  font-size: var(--ln-fs-ar-caption);
  font-weight: 600;
  line-height: var(--ln-lh-ar);
  direction: rtl;
  unicode-bidi: isolate;
  text-align: right;
  color: var(--ln-ink);
}
.la-dialog-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--ln-r-xs);
  background: none;
  color: var(--ln-ink-secondary);
  font: inherit;
  font-size: var(--ln-fs-title);
  line-height: 1;
  cursor: pointer;
}
.la-dialog-close:hover {
  background: color-mix(in srgb, currentColor 8%, transparent);
  color: var(--ln-ink);
}
.la-dialog-body {
  max-height: calc(80vh - 56px);
  padding: var(--ln-sm) var(--ln-lg) var(--ln-lg);
  overflow-y: auto;
}
.la-example {
  padding: var(--ln-md) 0;
  border-bottom: 1px solid var(--ln-hairline-faint);
}
.la-example:last-child {
  border-bottom: none;
}
.la-example .ar {
  font-family: var(--ln-font-ar);
  font-size: var(--ln-fs-ar-caption);
  line-height: var(--ln-lh-ar);
  direction: rtl;
  unicode-bidi: isolate;
  text-align: right;
  color: var(--ln-ink);
}
.la-example .en {
  margin-top: var(--ln-xs);
  color: var(--ln-ink-secondary);
  font-size: var(--ln-fs-caption);
  line-height: 1.5;
}

/* -- Odds and ends ------------------------------------------------------- */

.banner {
  display: flex;
  align-items: center;
  gap: var(--ln-sm);
  padding: var(--ln-sm) var(--ln-md);
  border: 1px solid color-mix(in srgb, var(--ln-critical) 30%, transparent);
  border-radius: var(--ln-r-sm);
  background: color-mix(in srgb, var(--ln-critical) 12%, transparent);
  color: var(--ln-critical);
  font-size: var(--ln-fs-callout);
  text-align: center;
}
.banner[hidden] {
  display: none;
}

/* Same deal as `.line-skeleton`: Lantern's `.ln-spinner` under the class name
   index.html emits, borrowing its `ln-spin` keyframes and reduced-motion rule.
   The two deltas are deliberate — this one is always the accent rather than
   `currentColor`, and it sits inline in a line of text. The size default was
   16px here against 18px in the package; they now agree. */
.loading {
  display: inline-block;
  width: var(--ln-spinner-size, 18px);
  height: var(--ln-spinner-size, 18px);
  border: 2px solid color-mix(in srgb, currentColor 22%, transparent);
  border-top-color: var(--ln-accent);
  border-radius: 50%;
  vertical-align: middle;
  animation: ln-spin 0.7s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .loading {
    animation-duration: 1.6s;
  }
}

.count {
  color: var(--ln-accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.saved-list {
  display: flex;
  flex-direction: column;
  gap: var(--ln-xs);
}
.saved-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: var(--ln-md);
  width: 100%;
  padding: var(--ln-sm) var(--ln-md);
  border: 1px solid var(--ln-hairline-faint);
  border-radius: var(--ln-r-sm);
  background: none;
  color: var(--ln-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    background-color var(--ln-t-tap) var(--ln-ease),
    border-color var(--ln-t-tap) var(--ln-ease);
}
.saved-item:hover {
  border-color: var(--ln-hairline);
  background: color-mix(in srgb, currentColor 6%, transparent);
}
.saved-item:focus-visible {
  outline: 2px solid var(--ln-accent);
  outline-offset: 2px;
}
.saved-item .info {
  display: flex;
  flex-direction: column;
  gap: var(--ln-hair);
  min-width: 0;
}
.saved-item .song,
.saved-item .artist,
.saved-item .when {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.saved-item .song {
  font-size: var(--ln-fs-callout);
  font-weight: 600;
}
.saved-item .artist {
  color: var(--ln-ink-secondary);
  font-size: var(--ln-fs-caption);
}
.saved-item .when {
  color: var(--ln-ink-tertiary);
  font-size: var(--ln-fs-micro);
  font-variant-numeric: tabular-nums;
}
.saved-item .delete {
  padding: var(--ln-xs) var(--ln-sm);
  border: 0;
  border-radius: var(--ln-r-xs);
  background: none;
  color: var(--ln-ink-tertiary);
  font: inherit;
  cursor: pointer;
  opacity: 0;
  transition:
    opacity var(--ln-t-tap) var(--ln-ease),
    color var(--ln-t-tap) var(--ln-ease);
}
.saved-item:hover .delete {
  opacity: 1;
}
.saved-item .delete:hover {
  color: var(--ln-critical);
  background: color-mix(in srgb, var(--ln-critical) 12%, transparent);
}

/* ========================================================================== *
 * (c) Portable-link portal (`/open/**`)
 * ========================================================================== *
 *
 * The only pages here with no HTML file of their own: `src/open-links.js`
 * server-renders them so a crawler gets real preview tags without running any
 * JS. Their styles live in this shared sheet rather than in a per-response
 * inline <style>, which keeps every portal document under a `style-src 'self'`
 * CSP and lets the browser cache the sheet it already has.
 *
 * Every rule is gated on `body.portal`, so nothing here reaches the six real
 * pages that also load this file.
 */

body.portal {
  margin: 0;
  min-height: 100dvh;
}
body.portal * {
  box-sizing: border-box;
}
body.portal .portal-main {
  --ln-page-width: 620px;
  display: grid;
  gap: var(--ln-lg);
  min-height: 100dvh;
  align-content: center;
}
body.portal .portal-card {
  display: grid;
  gap: var(--ln-md);
  padding: var(--ln-xl);
}
body.portal .portal-card > * {
  margin: 0;
}
body.portal .portal-kicker {
  color: var(--ln-accent);
  font-size: var(--ln-fs-micro);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
body.portal .portal-title {
  font-size: var(--ln-fs-title);
  letter-spacing: -0.02em;
}
body.portal .portal-sub,
body.portal .portal-source {
  color: var(--ln-ink-secondary);
  font-size: var(--ln-fs-callout);
}
body.portal .portal-note,
body.portal .portal-meta {
  max-width: 54ch;
  color: var(--ln-ink-secondary);
  font-size: var(--ln-fs-callout);
}
body.portal .portal-en {
  max-width: 54ch;
  font-size: var(--ln-fs-body);
}
/* The Arabic runs already carry `.ln-ar` (direction: rtl + unicode-bidi:
   isolate) and `dir="rtl"`; this only spaces them. */
body.portal .portal-ar {
  margin-block: var(--ln-xs);
}
body.portal .portal-actions .ln-btn {
  justify-self: start;
  text-decoration: none;
}
body.portal .portal-family,
body.portal .portal-forms {
  display: grid;
  gap: var(--ln-xs);
  margin: 0;
  padding: 0;
  list-style: none;
}
/* Two columns rather than a flex row, so the Arabic hugs one edge down the whole
   list instead of shifting with every word's width. A grid item is blockified,
   which is what lets `.ln-ar`'s own `text-align` finally apply to it. */
body.portal .portal-family li,
body.portal .portal-forms li {
  display: grid;
  grid-template-columns: minmax(0, 7rem) minmax(0, 1fr);
  align-items: baseline;
  gap: var(--ln-md);
  padding-block: var(--ln-xs);
  border-top: 1px solid var(--ln-hairline-faint);
}
body.portal .portal-family-ar {
  text-align: right;
}
body.portal .portal-family-en {
  color: var(--ln-ink-secondary);
  font-size: var(--ln-fs-callout);
}
body.portal .portal-form-label {
  color: var(--ln-ink-tertiary);
  font-size: var(--ln-fs-micro);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
body.portal .portal-credit,
body.portal .portal-nav {
  color: var(--ln-ink-tertiary);
  font-size: var(--ln-fs-caption);
}
body.portal .portal-nav {
  margin: 0;
  text-align: center;
}
body.portal .portal-nav a {
  color: var(--ln-accent);
}
body.portal .portal-line {
  display: grid;
  gap: var(--ln-xs);
}
body.portal .portal-line .portal-ar {
  margin-block: 0;
}
/* The second line is context, never the shared line — say so visually. */
body.portal .portal-line.is-context {
  opacity: 0.6;
}
