/* Hugin — component styles (tokens come from /styles/tokens.css) */

html { overflow-x: clip; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Tooltips (and any other absolute-positioned chrome that extends past
     the trigger) must never trigger a viewport scroll bar. `clip` hides
     the overflow without making the page scrollable. */
  overflow-x: clip;
}

.skip-link {
  position: absolute;
  inset-block-start: -100px;
  inset-inline-start: var(--s-4);
  background: var(--accent);
  color: var(--accent-ink);
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-sm);
  font-weight: 600;
  z-index: 100;
}
.skip-link:focus { inset-block-start: var(--s-4); }

.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;
}

.container {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--s-12) var(--s-8) var(--s-20);
}

@media (max-width: 760px) {
  .container { padding: var(--s-8) var(--s-5) var(--s-16); }
}

/* ===== Topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-5) var(--s-8);
  border-block-end: 1px solid var(--line);
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  position: sticky;
  inset-block-start: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
}

.brand-mark {
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  transform: translateY(2px);
}

.brand-word {
  font-family: var(--font-display);
  font-size: var(--fs-20);
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 14;
}

.brand-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
  padding-inline-start: var(--s-2);
  border-inline-start: 1px solid var(--line);
  padding-block: 2px;
}

@media (max-width: 600px) {
  .brand-eyebrow { display: none; }
}

.topbar-actions {
  display: flex;
  gap: var(--s-2);
  align-items: center;
  /* Prevents layout collapse before topbar.js mounts the actions. */
  min-height: 36px;
}

.nav-link {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  transition: color 120ms ease, background 120ms ease;
}
.nav-link:hover,
.nav-link:focus-visible {
  color: var(--accent);
  background: var(--accent-soft);
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-mute);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 120ms, border-color 120ms, background 120ms;
}
.icon-button:hover,
.icon-button:focus-visible {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
  outline: none;
}

/* ===== Hero ===== */
.hero {
  margin-block-end: var(--s-12);
  max-width: 760px;
}

.hero-title {
  /* Newsreader bookish at saga scale — clamp(44, _, 72) reads like the
     opening line of a chapter, not a marketing yell. Bebas Neue is
     reserved for CTAs and ceremonial section labels. */
  font-family: var(--font-display);
  font-size: clamp(var(--fs-44), 5.5vw, var(--fs-72));
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-block: var(--s-3) var(--s-4);
  font-variation-settings: "opsz" 72;
}

.hero-sub {
  color: var(--ink-mute);
  font-size: var(--fs-18);
  line-height: 1.55;
  max-width: 60ch;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 0;
}

h2 {
  font-size: var(--fs-24);
  letter-spacing: -0.01em;
  margin-block-start: var(--s-1);
}

/* ===== Settings strip ===== */
.settings {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--s-6);
  padding: var(--s-4) var(--s-5);
  margin-block-end: var(--s-8);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-elev);
}

.setting {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  min-width: 160px;
}

.setting label { cursor: pointer; }

select {
  background: var(--bg-inset);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: var(--fs-14);
  transition: border-color 120ms;
}
select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.setting-status {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.setting-status .rune-deco {
  color: var(--accent);
  font-size: 16px;
}

/* ===== Panels ===== */
.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-5);
  margin-block-end: var(--s-12);
}

@media (max-width: 760px) {
  .panels { grid-template-columns: 1fr; }
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-6);
  display: flex;
  flex-direction: column;
}

.panel-head {
  margin-block-end: var(--s-4);
}

.hint {
  color: var(--ink-dim);
  font-size: var(--fs-13);
  margin: 0 0 var(--s-4);
}

textarea {
  width: 100%;
  background: var(--bg-inset);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: var(--s-3);
  font-family: var(--font-mono);
  font-size: var(--fs-13);
  line-height: 1.55;
  resize: vertical;
  min-height: 140px;
  transition: border-color 120ms;
}
textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ===== Buttons ===== */
.btn-primary {
  margin-block-start: var(--s-4);
  align-self: flex-start;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
  padding: 10px 18px;
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--fs-14);
  cursor: pointer;
  transition: filter 120ms, transform 80ms;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Secondary button — cave-quiet. Transparent ground, hairline border,
   muted ink. Hover lifts to the elev surface with a warm-line edge so
   the affordance is felt without painting the page with brand colour.
   Shared across all signed-in pages — was account.css-local before. */
.btn-secondary {
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  padding: 9px 16px;
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--fs-13);
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-elev-2);
  border-color: var(--warm-line);
}
.btn-secondary:focus-visible {
  outline: none;
  background: var(--bg-elev-2);
  border-color: var(--warm-line);
  box-shadow: 0 0 0 1px var(--warm-line);
}
.btn-secondary:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.btn-sm {
  padding: 6px 12px;
  font-size: var(--fs-13);
}

/* ===== Drop zone ===== */
.drop-zone {
  flex: 1;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-sm);
  padding: var(--s-6);
  text-align: center;
  color: var(--ink-dim);
  background: var(--bg-inset);
  transition: border-color 120ms, background 120ms;
}
.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.file-link {
  color: var(--accent);
  cursor: pointer;
  border-block-end: 1px solid var(--accent-line);
}
.file-link:hover { border-block-end-color: var(--accent); }

.file-list {
  margin: var(--s-4) 0 0;
  padding: 0;
  list-style: none;
  text-align: start;
  font-size: var(--fs-13);
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.file-list li {
  font-family: var(--font-mono);
  color: var(--ink);
  padding: 4px 0;
  border-block-end: 1px dashed var(--line);
}

/* ===== Jobs list ===== */
.jobs-head {
  margin-block-end: var(--s-5);
}

.empty {
  color: var(--ink-dim);
  font-size: var(--fs-14);
  padding: var(--s-8) 0;
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.empty[hidden] { display: none; }
.empty .rune-deco {
  color: var(--accent);
  font-size: 22px;
}

/* VOL-321 — Nordic imagery on empty / not-found surfaces. When an
   .empty-illustration is present anywhere inside an empty state, the
   layout flips to a centered column so the image sits above the
   rune + sentence. Works on `.empty`, `.reading-empty`,
   `.marginalia-empty`, `.recall-empty` — same rule, one source. */
.empty-illustration {
  display: block;
  inline-size: 100%;
  max-inline-size: 280px;
  block-size: auto;
  margin-inline: auto;
  margin-block-end: var(--s-3);
  opacity: 0.85;
  /* Pointer-none so it never steals focus/clicks from the link
     buttons that some empty states ship beneath it. */
  pointer-events: none;
}
:where(.empty, .reading-empty, .marginalia-empty, .recall-empty):has(.empty-illustration) {
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--s-2);
}

/* Skeleton placeholders shown while EventSource resolves the initial
   /api/events hello payload — prevents a flash of the empty state for
   users who do have jobs. */
.jobs-skeleton {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.jobs-skeleton[hidden] { display: none; }
.job-skeleton {
  height: 92px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background:
    linear-gradient(
      90deg,
      var(--bg-elev) 0%,
      var(--bg-elev-2) 50%,
      var(--bg-elev) 100%
    );
  background-size: 200% 100%;
  animation: jobs-skeleton-shimmer 1400ms ease-in-out infinite;
}
@keyframes jobs-skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .job-skeleton { animation: none; }
}

.jobs-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.job-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-5);
  transition: border-color 120ms;
}

.job-card.running { border-color: var(--accent-line); }
.job-card.completed { border-inline-start: 2px solid var(--status-completed); }
.job-card.failed { border-inline-start: 2px solid var(--status-failed); }

.job-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-4);
  margin-block-end: var(--s-3);
}

.job-title-block {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.job-label {
  font-family: var(--font-display);
  font-size: var(--fs-16);
  font-weight: 500;
  font-variation-settings: "opsz" 18;
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-url {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-dim);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job-url:hover { color: var(--accent); }

.job-status {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  white-space: nowrap;
}
.job-status.queued    { color: var(--status-queued);    border-color: rgba(126,122,142,0.35); }
.job-status.running   { color: var(--status-running);   border-color: var(--accent-line); background: var(--accent-soft); }
.job-status.completed { color: var(--status-completed); border-color: rgba(110,156,124,0.35); }
.job-status.failed    { color: var(--status-failed);    border-color: rgba(156,74,74,0.35); }

.progress-bar {
  height: 2px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  margin-block-end: var(--s-3);
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-line), var(--accent));
  transition: width 220ms ease-out;
}

.job-card.completed .progress-fill { background: var(--status-completed); }
.job-card.failed .progress-fill { background: var(--status-failed); }

.job-message {
  margin: 0;
  font-size: var(--fs-13);
  color: var(--ink-mute);
}

.job-meta {
  display: flex;
  gap: var(--s-5);
  margin-block-start: var(--s-2);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
}
.job-meta span:empty { display: none; }

.job-text {
  margin-block-start: var(--s-3);
}

.job-text summary {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  padding: var(--s-1) 0;
  list-style: none;
}
.job-text summary::-webkit-details-marker { display: none; }
.job-text summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 120ms;
}
.job-text[open] summary::before { transform: rotate(90deg); }

.job-text pre {
  margin-block-start: var(--s-3);
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--s-4);
  max-height: 340px;
  overflow: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: var(--font-body);
  font-size: var(--fs-14);
  line-height: 1.7;
  color: var(--ink);
}

.job-actions {
  display: none;
  gap: var(--s-2);
  margin-block-start: var(--s-4);
  flex-wrap: wrap;
}

.job-card.completed .job-actions { display: flex; }

.job-actions button,
.job-actions a {
  background: transparent;
  color: var(--ink-mute);
  border: 1px solid var(--line-strong);
  padding: 6px 14px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: all 120ms;
}

.job-actions button:hover,
.job-actions a:hover {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

/* ===== Auto-Saga ===== */
/* Explicit [hidden] handling — needed because .saga-body has display:flex,
   which overrides the browser's default `[hidden] { display: none }`. */
.job-saga[hidden],
.saga-body[hidden],
.saga-actions[hidden] { display: none; }

.job-saga {
  margin-block-start: var(--s-4);
  border-block-start: 1px solid var(--line);
  padding-block-start: var(--s-4);
}

.saga-error {
  font-size: var(--fs-13);
  color: var(--status-failed);
  font-family: var(--font-mono);
  line-height: 1.55;
  padding: var(--s-3);
  background: rgba(156, 80, 80, 0.06);
  border: 1px solid rgba(156, 80, 80, 0.20);
  border-radius: var(--r-sm);
  margin-block-start: var(--s-3);
}

.saga-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-3);
  margin-block-end: var(--s-3);
}

.saga-status {
  font-size: 11px;
  letter-spacing: 0.08em;
}
.saga-status.pending::before { content: "ᚾ "; color: var(--accent); }
.saga-status.ready::before   { content: "✓ "; color: var(--status-completed); }
.saga-status.failed::before  { content: "✗ "; color: var(--status-failed); }

.saga-body {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  margin-block-start: var(--s-3);
}

.saga-body section {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.saga-tldr-text {
  font-family: var(--font-display);
  font-size: var(--fs-18);
  line-height: 1.5;
  color: var(--ink);
  max-width: 70ch;
}

.saga-chapters-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  border-inline-start: 1px solid var(--line);
  padding-inline-start: var(--s-4);
}
.saga-chapters-list li {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: var(--s-3);
  align-items: baseline;
  font-size: var(--fs-14);
}
.saga-chapters-list .ts {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
}

.saga-quotes-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.saga-quotes-list li {
  font-family: var(--font-display);
  font-size: var(--fs-16);
  line-height: 1.55;
  color: var(--ink);
  border-inline-start: 2px solid var(--accent-line);
  padding-inline-start: var(--s-4);
  font-style: italic;
}
.saga-quotes-list .speaker {
  display: block;
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  margin-block-start: var(--s-1);
}

.saga-actions-list {
  margin: 0;
  padding-inline-start: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  color: var(--ink);
  font-size: var(--fs-14);
}

.saga-runes-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--s-3);
}
.saga-runes-list li {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--s-3) var(--s-4);
  background: var(--bg-inset);
}
.saga-runes-list .q {
  font-family: var(--font-display);
  font-size: var(--fs-15);
  color: var(--ink);
  margin-block-end: var(--s-2);
}
.saga-runes-list .a {
  font-size: var(--fs-13);
  color: var(--ink-mute);
  line-height: 1.55;
}

/* ===== Footer ===== */
.footer {
  padding: var(--s-6) var(--s-8);
  border-block-start: 1px solid var(--line);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

/* ===== User widget (topbar dropdown) ===== */
.user-menu {
  position: relative;
  display: inline-flex;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 6px var(--s-3) 6px var(--s-2);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  color: var(--ink-mute);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  transition: color 120ms, border-color 120ms, background 120ms;
  max-width: 220px;
}
.user-chip:hover,
.user-chip:focus-visible {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
  outline: none;
}

.user-chip-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.user-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: none;
}

.user-chip-caret {
  font-size: 10px;
  color: var(--ink-dim);
}

.user-menu-panel {
  position: absolute;
  inset-block-start: calc(100% + var(--s-2));
  inset-inline-end: 0;
  min-width: 220px;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-3);
  padding: var(--s-3);
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  z-index: 20;
}
.user-menu-panel[hidden] { display: none; }

.user-menu-email {
  font-size: 11px;
  color: var(--ink-dim);
  padding: var(--s-1) var(--s-2);
  margin: 0 0 var(--s-1);
  border-block-end: 1px solid var(--line);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-item {
  display: block;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: start;
  font-family: var(--font-body);
  font-size: var(--fs-13);
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.user-menu-item:hover,
.user-menu-item:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
  outline: none;
}
.user-menu-action { color: var(--status-failed); }
.user-menu-action:hover,
.user-menu-action:focus-visible {
  background: rgba(156, 80, 80, 0.10);
  color: var(--status-failed);
}

@media (max-width: 480px) {
  .user-chip-name { display: none; }
  .user-chip { padding: 6px; }
}

/* ===== Shared status banner (billing + account + index goodbye) ===== */
.status-banner {
  margin-block-end: var(--s-8);
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--bg-elev);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--fs-15);
}
.status-banner[data-status="success"] {
  border-color: color-mix(in oklab, var(--status-completed) 50%, var(--line));
  background: color-mix(in oklab, var(--status-completed) 12%, var(--bg-elev));
}
.status-banner[data-status="cancel"] {
  border-color: color-mix(in oklab, var(--status-failed) 40%, var(--line));
  background: color-mix(in oklab, var(--status-failed) 8%, var(--bg-elev));
}
.status-banner[data-status="error"] {
  border-color: color-mix(in oklab, var(--status-failed) 60%, var(--line));
  background: color-mix(in oklab, var(--status-failed) 14%, var(--bg-elev));
}
/* `.status-banner` has `display: flex`, which overrides the browser's
   default `[hidden] { display: none }`. Restore the hidden behavior so
   the goodbye banner stays put unless explicitly shown via JS. */
.status-banner[hidden] { display: none; }

/* ===== Shared usage meter (billing + account) ===== */
.usage-block {
  margin-block-start: var(--s-5);
}
.usage-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-block-end: var(--s-2);
}
.usage-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.usage-numbers {
  font-size: var(--fs-15);
  color: var(--ink);
}
.usage-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-inset);
  border-radius: var(--r-full);
  overflow: hidden;
}
.usage-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-full);
  transition: width 400ms ease;
}
.usage-fill[data-state="warning"] { background: var(--status-running); }
.usage-fill[data-state="over"] { background: var(--status-failed); }
/* When the candle meter carries the visual, the bar becomes a quiet,
   slimmer baseline beneath it — the screen-reader progressbar anchor and
   a graceful fallback if the candles don't paint. */
.usage-bar--baseline {
  height: 3px;
  margin-block-start: var(--s-3);
  opacity: 0.6;
}
.usage-note {
  margin-block-start: var(--s-3);
  font-size: var(--fs-13);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   Home — compact transcribe surface (panels + lang strip + well).
   Mirrors the Stitch reference's structure (two side-by-side
   compact cards on top, a "Recent" stream below) on top of the
   cave palette. Replaces the older .settings + tall .panel + tall
   .job-card layout while leaving the old rules dormant.
   ============================================================ */

/* Alcove panels — each verse is a frame carved into the cave wall.
   Composition: warm-tinted upper half (hearth bg) holds the illuminated
   plate; an elevated lower shelf holds the title + input. A hairline
   divider marks where the two surfaces meet. Hover/focus warms the
   border and breathes a soft ember glow inside. */
.panel-verse {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  /* Niche shape — top corners generous (archway), bottom corners tight
     (the alcove sits on the floor). Breaks the rectangle-card silhouette
     into something architectural. */
  border-radius: 14px 14px 4px 4px;
  background:
    radial-gradient(ellipse 85% 60% at 50% -8%, rgba(196, 91, 46, 0.18) 0%, rgba(196, 91, 46, 0.04) 45%, transparent 75%),
    linear-gradient(to bottom, var(--bg-hearth) 0%, var(--bg-hearth-2) 42%, var(--bg-elev) 64%);
  overflow: hidden;
  /* Quiet alcove — no border or shadow change on hover. Only the plate
     image zooms and the slot border warms. See rules further below. */
  box-shadow:
    inset 0 1px 0 rgba(207, 200, 182, 0.06),
    0 16px 36px -18px rgba(0, 0, 0, 0.6);
}

/* Plate — sits inside the top of the alcove, flush to the frame.
   Fixed aspect-ratio keeps both panels' plates at identical heights
   regardless of source-image proportions, so the shelves below align.
   object-fit: cover crops the image to fill the slot. */
.panel-plate {
  margin: 0;
  position: relative;
  overflow: hidden;
  /* Wide band — keeps the illustration legible as the verse prelude
     while staying shorter than the original 2:1 to honour compaction. */
  aspect-ratio: 600 / 250;
}
.panel-plate img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  -webkit-mask-image: linear-gradient(to bottom, #000 86%, transparent 100%);
          mask-image: linear-gradient(to bottom, #000 86%, transparent 100%);
  opacity: 0.88;
  transform: scale(1);
  transform-origin: center 55%;
  transition: opacity 520ms ease, transform 700ms ease;
}
/* Hover/focus signature — only two effects: the plate image zooms (ken-burns
   style, clipped by the overflow:hidden plate) and the slot border warms.
   The alcove itself stays static — no border, no glow, no movement. */
.panel-verse:hover .panel-plate img,
.panel-verse:focus-within .panel-plate img {
  opacity: 1;
  transform: scale(1.06);
}

/* Shelf — content lives here, on a slightly more elevated surface.
   Two-tone divider at top: a hairline ink line plus a 1px warm
   highlight above, like candle light catching the lip of the shelf
   from below. A small ornamental knot sits centred on the seam
   (::before) and a faint stone-grain noise grounds the surface (::after). */
.panel-body {
  position: relative;
  isolation: isolate;
  padding: var(--s-4) var(--s-5) var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  background: var(--bg-elev);
  border-block-start: 1px solid var(--line-strong);
  box-shadow:
    inset 0 1px 0 rgba(196, 91, 46, 0.12),
    inset 0 2px 0 rgba(207, 200, 182, 0.03);
}
/* Knotwork ornament — centred on the plate/shelf seam, like a manuscript's
   chapter divider. Single SVG data-URI: a diamond knot flanked by hairlines.
   Sits half on the plate, half on the shelf. */
.panel-body::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 52px;
  height: 14px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 18' fill='none' stroke='%23C45B2E' stroke-width='1' stroke-linecap='round' stroke-linejoin='round'><path d='M0,9 L 20,9 M 44,9 L 64,9'/><path d='M 24,9 L 32,3 L 40,9 L 32,15 Z'/><path d='M 28,9 L 36,9 M 32,5 L 32,13'/></svg>");
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  opacity: 0.85;
  pointer-events: none;
  z-index: 2;
  /* Tiny warm halo behind the knot so it reads as lit, not stuck on. */
  filter: drop-shadow(0 0 6px rgba(196, 91, 46, 0.35));
}
/* Stone-grain noise — material weight on the shelf surface. Sits below
   content via z-index, multiplies into the dark surface for grit. */
.panel-body::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 220px 220px;
  opacity: 0.10;
  mix-blend-mode: overlay;
}
.panel-body > * {
  position: relative;
  z-index: 1;
}

.panel-body .eyebrow {
  margin: 0;
  color: var(--ink-dim);
}
.panel-body h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-24);
  font-weight: 500;
  line-height: 1.1;
  color: var(--ink);
  letter-spacing: -0.005em;
}
/* Illuminated drop cap — first letter of the verse title takes ember
   colour and grows half a step, like a manuscript initial. Subtle warm
   glow behind it sells "lit from within". */
.panel-body h2::first-letter {
  font-family: var(--font-display);
  font-size: 1.4em;
  font-weight: 500;
  color: var(--warm);
  letter-spacing: 0.01em;
  margin-inline-end: 0.02em;
  text-shadow: 0 0 14px rgba(196, 91, 46, 0.32);
}
.panel-sub {
  margin: 0 0 var(--s-1);
  font-family: var(--font-body);
  font-size: var(--fs-14);
  line-height: 1.55;
  color: var(--ink-mute);
  max-width: 44ch;
}
.panel-hint {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* Reduced motion — keep the alcove static. */
@media (prefers-reduced-motion: reduce) {
  .panel-verse,
  .panel-plate img { transition: none; }
}

/* URL form — slot carved into the shelf: prefix icon + input + arrow submit.
   Single-line: fixed height matches the drop-zone for shelf alignment. */
.url-form {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  height: 48px;
  padding: 0 var(--s-3);
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.32),
    inset 0 0 0 1px rgba(0, 0, 0, 0.20);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.url-form:focus-within {
  border-color: var(--warm-line);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.32),
    inset 0 0 0 1px rgba(196, 91, 46, 0.10);
}
.url-form-prefix {
  color: var(--ink-faint);
  display: inline-flex;
  flex-shrink: 0;
}
.url-form textarea {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  resize: none;
  font-family: var(--font-mono);
  font-size: var(--fs-13);
  line-height: 1.5;
  color: var(--ink);
  padding: 0;
  /* Locked to a single line — overrides the global textarea min-height:140px. */
  height: 1.5em;
  min-height: 0;
  max-height: 1.5em;
  overflow: hidden;
  white-space: nowrap;
}
/* Suppress the global `textarea:focus-visible { box-shadow }` moss ring —
   the URL form's container border is the only frame we want. */
.url-form textarea:focus,
.url-form textarea:focus-visible {
  border: 0;
  box-shadow: none;
}
.url-form textarea::placeholder { color: var(--ink-faint); }
.url-form-submit {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--warm-line);
  border-radius: var(--r-sm);
  background: var(--warm-soft);
  color: var(--warm);
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}
.url-form-submit:hover {
  background: var(--warm);
  color: var(--accent-ink);
  transform: translateX(1px);
}
.url-form-submit:focus-visible {
  outline: 1px solid var(--warm-line);
  outline-offset: 3px;
}
.url-form-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* Drop zone — mirrors the URL form slot exactly: same height, padding,
   gap, border, bg-inset, inset shadow. Internal structure also mirrors:
   prefix glyph (left) + content (flex middle) + warm CTA (right). */
.panel-verse .drop-zone {
  /* flex: none overrides the base `.drop-zone { flex: 1 }` which sets
     flex-basis: 0 and would otherwise collapse the explicit height in
     a column flex parent (.panel-body). */
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0 var(--s-3);
  height: 48px;
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink-mute);
  font-family: var(--font-body);
  font-size: var(--fs-14);
  cursor: pointer;
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.32),
    inset 0 0 0 1px rgba(0, 0, 0, 0.20);
  transition: border-color 200ms ease, background 200ms ease, color 200ms ease, box-shadow 200ms ease;
}
/* dragover — real file-drop gesture: light up the slot fully with the
   warm hearth tone so the user sees "yes, drop here". */
.panel-verse .drop-zone.dragover {
  border-color: var(--warm-line);
  color: var(--ink);
  background: var(--bg-hearth);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.32),
    inset 0 0 24px rgba(196, 91, 46, 0.14);
}

/* Panel-hover slot treatment — the corresponding slot's border warms,
   identical between URL form and drop-zone. Pairs with the image-zoom
   above as the only two hover effects on the alcove. */
.panel-verse:hover .url-form,
.panel-verse:hover .drop-zone,
.panel-verse:focus-within .url-form,
.panel-verse:focus-within .drop-zone {
  border-color: var(--warm-line);
}
/* Prefix glyph — mirrors .url-form-prefix: faint ink, fixed, no flex grow. */
.drop-zone-prefix {
  color: var(--ink-faint);
  display: inline-flex;
  flex-shrink: 0;
}
/* Text — fills the middle like the textarea does in url-form. */
.drop-zone-text {
  flex: 1;
  min-width: 0;
  text-align: start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drop-zone .file-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.panel-verse .file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-dim);
}
.panel-verse .file-list:empty { display: none; }

/* Language strip — compact and unobtrusive, between panels and the well. */
.lang-strip {
  margin-block: var(--s-8) var(--s-4);
  display: flex;
  align-items: center;
  gap: var(--s-4);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-dim);
}
.lang-strip .eyebrow { margin: 0; color: var(--ink-dim); }
.lang-strip select {
  background: transparent;
  color: var(--ink-mute);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--s-1) var(--s-2);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.06em;
  cursor: pointer;
}
.lang-strip select:focus-visible {
  outline: 1px solid var(--accent-line);
  outline-offset: 2px;
}
.lang-strip-status {
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  letter-spacing: 0.08em;
}

/* The Well — section with header on top and compact rows below. */
.well {
  margin-block-start: var(--s-10);
}
.well-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s-5);
  margin-block-end: var(--s-6);
}
.well-medallion {
  margin: 0;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  overflow: hidden;
  /* Mímir's well sits inside a circular medallion as an illuminated
     initial for the section — feels like a manuscript page anchor
     rather than a panel image. */
  background: radial-gradient(circle at center, var(--bg-hearth) 0%, transparent 70%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.well-medallion img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.92;
  -webkit-mask-image: radial-gradient(circle at center, #000 60%, transparent 100%);
          mask-image: radial-gradient(circle at center, #000 60%, transparent 100%);
}
.well-head-titles { min-width: 0; }
.well-head-titles .eyebrow {
  margin: 0 0 var(--s-1);
  color: var(--ink-dim);
}
.well-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-30);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.well-link {
  color: var(--ink-mute);
  text-decoration: none;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transition: color 160ms ease;
}
.well-link:hover { color: var(--warm); }

/* Job row — the entire row is a single anchor (`.job-row-link`). The LI
   is just a separator that holds the divider line; the anchor inside
   handles layout, hover and click. When the transcript is not yet
   completed, the anchor has no href and reads as inert (no pointer
   cursor, no hover warm-up). */
.jobs-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.job-row {
  border-block-start: 1px solid var(--line);
}
.job-row:first-child { border-block-start: 0; }
.job-row-link {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--s-4);
  align-items: center;
  padding: var(--s-3) var(--s-2);
  background: transparent;
  text-decoration: none;
  color: inherit;
  transition: background 160ms ease;
}
.job-row-link[href] { cursor: pointer; }
@media (hover: hover) {
  .job-row-link[href]:hover { background: color-mix(in oklab, var(--bg-elev) 40%, transparent); }
  .job-row-link[href]:hover .job-label { color: var(--ink); }
}
.job-row-glyph {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  background: var(--bg-inset);
  color: var(--accent);
}
.job-row[data-status="completed"] .job-row-glyph { color: var(--warm); }
.job-row[data-status="failed"] .job-row-glyph { color: var(--status-failed); }

.job-row-body { min-width: 0; }
.job-row-title { margin: 0 0 2px; }
.job-row-title .job-label {
  font-family: var(--font-display);
  font-size: var(--fs-16);
  line-height: 1.3;
  color: var(--ink-mute);
  word-break: break-word;
  transition: color 160ms ease;
}
.job-row-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: baseline;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
}
.job-row-meta .job-status { text-transform: uppercase; letter-spacing: 0.14em; }
.job-row-meta .job-status.running { color: var(--accent); }
.job-row-meta .job-status.completed { color: var(--status-completed); }
.job-row-meta .job-status.failed { color: var(--status-failed); }
.job-row-meta .job-status.queued { color: var(--status-queued); }
.job-row-meta .job-message:empty { display: none; }
.job-row-meta .job-duration:empty { display: none; }

.job-row .progress-bar {
  margin-block-start: var(--s-2);
  height: 2px;
  background: var(--line);
  border-radius: var(--r-full);
  overflow: hidden;
}
.job-row[data-status="completed"] .progress-bar,
.job-row[data-status="failed"] .progress-bar { display: none; }
.job-row .progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 240ms ease;
}
.job-row[data-status="failed"] .progress-fill { background: var(--status-failed); }

/* Arrow — purely decorative now. Visible only when the row's link has
   an href (transcript completed). The whole anchor catches the click;
   the arrow just signals where it leads. */
.job-row-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  color: var(--ink-mute);
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}
.job-row-arrow[hidden] { display: none; }
@media (hover: hover) {
  .job-row-link[href]:hover .job-row-arrow {
    color: var(--warm);
    background: var(--warm-soft);
    transform: translateX(2px);
  }
}

/* Skeleton — same row height as the real rows while loading. */
.jobs-skeleton[hidden] { display: none; }
.jobs-skeleton .job-row-skeleton {
  height: 56px;
  border-block-start: 1px solid var(--line);
  background: linear-gradient(90deg, transparent 0%, var(--bg-elev) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.6s ease infinite;
}
@keyframes skeleton-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (max-width: 760px) {
  .panels {
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
  }
  .well-title { font-size: var(--fs-24); }
  .job-row { padding-block: var(--s-2); }
  .job-row-glyph { width: 32px; height: 32px; }
}

/* ===== Tooltip — cave-styled, minimalist =====
   Replaces the native browser title="" tooltip with a small vellum panel
   that matches the rest of the app. Use [data-tooltip="..."] on any
   hoverable element (we keep aria-label separately for screen readers).
   Hover-only so touch devices don't sticky a tooltip on tap. */
@media (hover: hover) {
  [data-tooltip] {
    position: relative;
  }
  [data-tooltip]:hover::after,
  [data-tooltip]:focus-visible::after {
    content: attr(data-tooltip);
    position: absolute;
    inset-block-end: calc(100% + 6px);
    inset-inline-start: 50%;
    transform: translateX(-50%);
    background: var(--bg-elev-2);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: var(--fs-12);
    letter-spacing: 0.04em;
    padding: var(--s-1) var(--s-3);
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-2);
    white-space: nowrap;
    pointer-events: none;
    z-index: 100;
    opacity: 0;
    animation: tooltip-rise 160ms ease forwards;
    animation-delay: 240ms;
  }
}
@keyframes tooltip-rise {
  from { opacity: 0; transform: translateX(-50%) translateY(2px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  [data-tooltip]:hover::after,
  [data-tooltip]:focus-visible::after { animation-delay: 0ms; opacity: 1; }
}
