/* ==========================================================================
   Popcorn — reusable components
   Every visual pattern in the app should be one of these. Page files compose
   them; they don't reinvent them.
   ========================================================================== */

/* ── Buttons ───────────────────────────────────────────────────────────── */

.btn {
  --btn-h: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  height: var(--btn-h);
  padding-inline: var(--s4);
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
  font-weight: 700;
  letter-spacing: -.005em;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease),
              opacity var(--dur-fast) var(--ease);
}
.btn:active { transform: scale(.975); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }

.btn svg { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn svg.solid { fill: currentColor; stroke: none; }

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: rgba(255, 255, 255, .09);
  color: var(--text);
  backdrop-filter: blur(8px);
}
.btn-secondary:hover { background: rgba(255, 255, 255, .15); }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-strong);
}
.btn-outline:hover { border-color: rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .04); }

.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); background: rgba(255, 255, 255, .06); }

.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: rgba(255, 90, 77, .2); }

/* Destructive-but-quiet, for admin lists. */
.btn-quiet-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(255, 90, 77, .3);
  height: 32px;
  padding-inline: var(--s3);
  font-size: var(--t-xs);
}
.btn-quiet-danger:hover { background: var(--danger-soft); }

.btn-lg { --btn-h: 50px; padding-inline: var(--s5); font-size: var(--t-body); }
.btn-sm { --btn-h: 32px; padding-inline: var(--s3); font-size: var(--t-xs); }

.btn-icon {
  width: var(--btn-h);
  padding: 0;
  border-radius: var(--r-pill);
}
.btn-block { width: 100%; }

/* Button that is busy: keeps its width, shows a spinner. */
.btn[data-busy="true"] { pointer-events: none; opacity: .7; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Chips, badges, pills ──────────────────────────────────────────────── */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding-inline: var(--s2);
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, .08);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  text-transform: uppercase;
  letter-spacing: .08em;
  white-space: nowrap;
}
.chip-accent { background: var(--accent-soft); border-color: rgba(255,200,61,.3); color: var(--accent); }
.chip-ok { background: rgba(67, 209, 122, .12); border-color: rgba(67, 209, 122, .3); color: var(--ok); }
.chip-warn { background: rgba(255, 180, 67, .12); border-color: rgba(255, 180, 67, .3); color: var(--warn); }
.chip-danger { background: var(--danger-soft); border-color: rgba(255, 90, 77, .3); color: var(--danger); }
.chip-plain { background: transparent; }

/* Rating reads as a value, not a label. */
.rating {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text);
  font-size: var(--t-sm);
  font-weight: 700;
}
.rating svg { width: 13px; height: 13px; fill: var(--accent); stroke: none; }

.dot-sep::before {
  content: "·";
  margin-inline: var(--s2);
  color: var(--text-mute);
}

/* ── Poster card ───────────────────────────────────────────────────────── */

/* One link per card (so screen readers announce it once) with the hover
   actions layered over the artwork as siblings, not nested inside it. */
.card-holder {
  position: relative;
  width: var(--poster-w);
  flex: 0 0 auto;
  transition: transform var(--dur) var(--ease);
}
.card-holder:hover { transform: translateY(-4px); }

.card {
  display: block;
  border-radius: var(--r-sm);
  text-align: left;
}

.card-art {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--shadow-1);
  transition: box-shadow var(--dur) var(--ease);
}
.card-holder:hover .card-art,
.card-holder:focus-within .card-art { box-shadow: var(--shadow-2); }

.card-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease);
}
.card-art img.is-loaded { opacity: 1; }

/* Artwork that has no poster still reads as a deliberate surface. */
.card-art-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--s3);
  padding: var(--s4);
  text-align: center;
  background:
    radial-gradient(circle at 70% 12%, rgba(255, 200, 61, .07), transparent 55%),
    linear-gradient(150deg, var(--surface-2), var(--surface-1));
  color: var(--text-mute);
}
.card-art-fallback span {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Landscape box, portrait art: letterbox the poster instead of cropping it. */
.card-art-fallback.has-poster {
  background: linear-gradient(150deg, #131317, #0b0b0d);
  align-content: center;
  padding: var(--s4) var(--s5);
}
.card-art-fallback.has-poster img {
  max-height: 74%;
  width: auto;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-2);
}
.card-art-fallback.has-poster span { font-size: var(--t-xs); -webkit-line-clamp: 2; }

/* Hover affordances. Hidden on touch, where there is no hover. */
.card-overlay {
  position: absolute;
  left: 0; right: 0; top: 0;
  aspect-ratio: 2 / 3;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--s3);
  gap: var(--s2);
  border-radius: var(--r-sm);
  background: linear-gradient(to top, rgba(0, 0, 0, .88) 0%, rgba(0, 0, 0, .35) 45%, transparent 72%);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
.card-holder:hover .card-overlay,
.card-holder:focus-within .card-overlay { opacity: 1; }
.card-overlay .btn-icon { pointer-events: auto; }
.card-wide .card-overlay { aspect-ratio: 16 / 9; }

.card-actions { display: flex; align-items: center; gap: var(--s2); }
.card-actions .btn-icon {
  --btn-h: 34px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  backdrop-filter: blur(6px);
}
.card-actions .btn-icon:hover { background: rgba(255, 255, 255, .3); }
.card-actions .btn-icon.is-primary { background: var(--accent); color: var(--accent-ink); }
.card-actions .btn-icon.is-primary:hover { background: var(--accent-hover); }
.card-actions .btn-icon.is-on { color: var(--accent); }

/* Progress lives on the artwork — it is about the content, not the chrome. */
.card-progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: rgba(0, 0, 0, .55);
}
.card-progress > i {
  display: block;
  height: 100%;
  background: var(--accent);
}

/* A single status flag, when it genuinely changes what the user should do. */
.card-flag {
  position: absolute;
  top: var(--s2);
  left: var(--s2);
  z-index: 2;
}

.card-body { padding: var(--s3) 2px 0; }
.card-title {
  font-size: var(--t-sm);
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.35;
  color: var(--text);
  /* Release names frequently have no spaces to break on. */
  overflow-wrap: anywhere;
}
.card-meta {
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: var(--s2);
  color: var(--text-mute);
  font-size: var(--t-xs);
}
.card:hover .card-title { color: #fff; }

/* Wider "continue watching" variant: landscape art, closer to a decision. */
.card-wide { width: clamp(240px, 26vw, 340px); }
.card-wide .card-art { aspect-ratio: 16 / 9; }
.card-wide .card-body { padding-top: var(--s3); }
.card-wide .card-title { font-size: var(--t-body); }
.card-wide .card-progress { height: 4px; background: rgba(255, 255, 255, .18); }

/* ── Horizontal row ────────────────────────────────────────────────────── */

.row { position: relative; margin-bottom: var(--s7); }
.row-head {
  display: flex;
  align-items: baseline;
  gap: var(--s4);
  margin-bottom: var(--s4);
}
.row-head h2 { font-size: var(--t-h2); font-weight: 700; letter-spacing: -.022em; min-width: 0; }
.row-head .row-link {
  margin-left: auto;
  flex: 0 0 auto;
  white-space: nowrap;
  color: var(--text-mute);
  font-size: var(--t-xs);
  font-weight: 600;
  transition: color var(--dur-fast) var(--ease);
}
.row-head .row-link:hover { color: var(--accent); }

.row-track {
  display: flex;
  gap: var(--s4);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  scroll-behavior: smooth;
  scrollbar-width: none;
  padding-block: var(--s2) var(--s4);
  /* Let cards visually reach the viewport edge while staying aligned. */
  padding-inline: var(--gutter);
  margin-inline: calc(var(--gutter) * -1);
  scroll-padding-inline: var(--gutter);
}
.row-track::-webkit-scrollbar { display: none; }
.row-track > * { scroll-snap-align: start; }

/* Arrow controls: desktop pointer only — touch users swipe. */
.row-nav {
  position: absolute;
  top: calc(50% - var(--s5));
  z-index: 3;
  width: 40px; height: 40px;
  display: grid;
  place-content: center;
  border-radius: var(--r-pill);
  background: rgba(16, 16, 19, .9);
  border: 1px solid var(--line-strong);
  color: var(--text);
  box-shadow: var(--shadow-2);
  opacity: 0;
  transition: opacity var(--dur) var(--ease), background var(--dur-fast) var(--ease);
}
.row-nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.row-nav:hover { background: var(--surface-3); }
.row-nav[disabled] { opacity: 0 !important; pointer-events: none; }
.row-nav.prev { left: calc(var(--gutter) * -1 + 6px); }
.row-nav.next { right: calc(var(--gutter) * -1 + 6px); }
@media (hover: hover) and (pointer: fine) {
  .row:hover .row-nav:not([disabled]) { opacity: 1; }
  .row:focus-within .row-nav:not([disabled]) { opacity: 1; }
}

/* ── Grid ──────────────────────────────────────────────────────────────── */

.grid {
  display: grid;
  gap: var(--s5) var(--s4);
  grid-template-columns: repeat(auto-fill, minmax(clamp(132px, 15.5vw, 184px), 1fr));
}
.grid .card-holder { width: 100%; }

/* ── Section ───────────────────────────────────────────────────────────── */

.section { padding-block: var(--s7); }
.section + .section { border-top: 1px solid var(--line); }
.section-head { margin-bottom: var(--s5); }
.section-head h2 { font-size: var(--t-h2); font-weight: 700; letter-spacing: -.022em; }
.section-head p { margin-top: var(--s2); color: var(--text-dim); max-width: 62ch; }

/* ── Panels, wells, lists ──────────────────────────────────────────────── */

.panel {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s5);
}

.list { display: flex; flex-direction: column; }
.list-item {
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: var(--s4);
  border-bottom: 1px solid var(--line);
  transition: background var(--dur-fast) var(--ease);
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: rgba(255, 255, 255, .025); }
.list-item-body { flex: 1; min-width: 0; }
.list-item-body strong { display: block; font-size: var(--t-sm); font-weight: 600; }
.list-item-body small { display: block; margin-top: 2px; color: var(--text-mute); font-size: var(--t-xs); }
.list-item-actions { display: flex; align-items: center; gap: var(--s2); }

/* ── Progress bar ──────────────────────────────────────────────────────── */

.progress {
  height: 6px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .1);
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width var(--dur-slow) var(--ease);
}
.progress.is-warn > i { background: var(--warn); }
.progress.is-danger > i { background: var(--danger); }
/* Indeterminate: the server is working but can't report a percentage. */
.progress.is-indeterminate > i {
  width: 35% !important;
  animation: slide 1.4s var(--ease) infinite;
}
@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(340%); }
}

/* ── Forms ─────────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: var(--s2); }
.field > label, .field-label {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text-mute);
}
.field-hint { color: var(--text-mute); font-size: var(--t-xs); line-height: 1.5; }

.input, .select {
  width: 100%;
  height: 44px;
  padding-inline: var(--s3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: var(--t-sm);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.input::placeholder { color: var(--text-mute); }
.input:hover, .select:hover { border-color: var(--line-strong); }
.input:focus, .select:focus { border-color: var(--accent); background: var(--surface-1); }

.select {
  appearance: none;
  padding-right: var(--s7);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%236d6d78' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m5 8 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s3) center;
  background-size: 16px;
  cursor: pointer;
}
.select option { background: var(--surface-3); color: var(--text); }

/* Switch */
.switch { display: flex; align-items: center; gap: var(--s3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 40px; height: 22px;
  flex: 0 0 auto;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .14);
  position: relative;
  transition: background var(--dur) var(--ease);
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.switch input:checked + .switch-track { background: var(--accent-soft); }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: var(--accent); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-text strong { display: block; font-size: var(--t-sm); font-weight: 600; }
.switch-text small { display: block; margin-top: 2px; color: var(--text-mute); font-size: var(--t-xs); }

/* ── Segmented control / tabs ──────────────────────────────────────────── */

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.segmented button {
  padding: 8px var(--s4);
  border-radius: 7px;
  color: var(--text-dim);
  font-size: var(--t-sm);
  font-weight: 600;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-selected="true"] { background: rgba(255, 255, 255, .1); color: var(--text); }

/* ── Menu / dropdown ───────────────────────────────────────────────────── */

.menu-wrap { position: relative; }
.menu {
  position: absolute;
  top: calc(100% + var(--s2));
  right: 0;
  z-index: 120;
  min-width: 232px;
  padding: var(--s2);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  transform-origin: top right;
  animation: menu-in var(--dur-fast) var(--ease-out);
}
@keyframes menu-in {
  from { opacity: 0; transform: scale(.96) translateY(-4px); }
}
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  padding: var(--s3);
  border-radius: var(--r-sm);
  color: var(--text-dim);
  font-size: var(--t-sm);
  font-weight: 500;
  text-align: left;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.menu-item:hover { background: rgba(255, 255, 255, .07); color: var(--text); }
.menu-item svg { width: 17px; height: 17px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger:hover { background: var(--danger-soft); }
.menu-head {
  padding: var(--s3);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--s2);
}
.menu-head strong { display: block; font-size: var(--t-sm); }
.menu-head small { display: block; margin-top: 2px; color: var(--text-mute); font-size: var(--t-xs); }
.menu-sep { height: 1px; background: var(--line); margin: var(--s2) 0; }

/* ── Modal / sheet ─────────────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: var(--s5);
  background: var(--surface-scrim);
  backdrop-filter: blur(6px);
  animation: fade-in var(--dur) var(--ease);
}
@keyframes fade-in { from { opacity: 0; } }

.modal-panel {
  width: min(100%, 560px);
  max-height: min(86vh, 780px);
  display: flex;
  flex-direction: column;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  animation: panel-in var(--dur) var(--ease-out);
}
@keyframes panel-in {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
}
.modal-panel.is-wide { width: min(100%, 760px); }
.modal-head {
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: var(--s5);
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { flex: 1; font-size: var(--t-h3); font-weight: 700; }
.modal-body { padding: var(--s5); overflow-y: auto; }
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s3);
  padding: var(--s4) var(--s5);
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, .2);
}

/* On narrow screens a sheet from the bottom beats a centred dialog. */
@media (max-width: 640px) {
  .modal { padding: 0; place-items: end stretch; }
  .modal-panel {
    width: 100%;
    max-height: 90vh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-panel.is-wide { width: 100%; }
}

/* ── Toasts ────────────────────────────────────────────────────────────── */

.toast-stack {
  position: fixed;
  z-index: 180;
  right: var(--s5);
  bottom: var(--s5);
  display: flex;
  flex-direction: column-reverse;
  gap: var(--s2);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 260px;
  max-width: min(420px, calc(100vw - var(--s6)));
  padding: var(--s3) var(--s4);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-left: 2px solid var(--accent);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-3);
  color: var(--text);
  font-size: var(--t-sm);
  pointer-events: auto;
  animation: toast-in var(--dur) var(--ease-out);
}
.toast[data-tone="error"] { border-left-color: var(--danger); }
.toast[data-tone="warn"] { border-left-color: var(--warn); }
.toast.is-leaving { animation: toast-out var(--dur) var(--ease) forwards; }
.toast svg { width: 17px; height: 17px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.toast[data-tone="error"] svg { color: var(--danger); }
.toast .toast-text { flex: 1; min-width: 0; }
.toast .toast-action {
  color: var(--accent);
  font-size: var(--t-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }

@media (max-width: 640px) {
  .toast-stack { left: var(--s3); right: var(--s3); bottom: calc(var(--tabbar-h) + var(--s3) + env(safe-area-inset-bottom)); }
  .toast { min-width: 0; max-width: none; }
}

/* ── Skeletons ─────────────────────────────────────────────────────────── */

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .05), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.6s var(--ease) infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

.skeleton-card { width: var(--poster-w); flex: 0 0 auto; }
.skeleton-card .skeleton-art { aspect-ratio: 2 / 3; border-radius: var(--r-sm); }
.skeleton-card .skeleton-line { height: 11px; margin-top: var(--s3); border-radius: var(--r-xs); }
.skeleton-card .skeleton-line.short { width: 55%; }
.grid .skeleton-card { width: 100%; }
.skeleton-card.is-wide { width: clamp(240px, 26vw, 340px); }
.skeleton-card.is-wide .skeleton-art { aspect-ratio: 16 / 9; }
.skeleton-text { height: 12px; border-radius: var(--r-xs); }
.skeleton-title { height: 30px; width: min(320px, 60%); border-radius: var(--r-sm); }

/* ── State panel: empty / error / offline ──────────────────────────────── */

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--s3);
  padding: var(--s9) var(--s5);
  max-width: 520px;
  margin-inline: auto;
}
.state-mark {
  width: 56px; height: 56px;
  display: grid;
  place-content: center;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-mute);
  margin-bottom: var(--s2);
}
.state-mark svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.state h2 { font-size: var(--t-h3); font-weight: 700; }
.state p { color: var(--text-dim); font-size: var(--t-sm); max-width: 44ch; }
.state-actions { display: flex; flex-wrap: wrap; gap: var(--s3); justify-content: center; margin-top: var(--s2); }
.state[data-tone="error"] .state-mark { color: var(--danger); border-color: rgba(255, 90, 77, .3); background: var(--danger-soft); }
.state[data-tone="warn"] .state-mark { color: var(--warn); border-color: rgba(255, 180, 67, .3); background: rgba(255, 180, 67, .1); }

/* Technical detail stays available but never leads. */
.details-disclosure {
  margin-top: var(--s4);
  width: 100%;
  text-align: left;
}
.details-disclosure > summary {
  cursor: pointer;
  color: var(--text-mute);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  text-transform: uppercase;
  letter-spacing: .1em;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
}
.details-disclosure > summary::-webkit-details-marker { display: none; }
.details-disclosure > summary::before {
  content: "";
  width: 6px; height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform var(--dur-fast) var(--ease);
}
.details-disclosure[open] > summary::before { transform: rotate(45deg); }
.details-disclosure pre {
  margin-top: var(--s3);
  padding: var(--s3);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text-mute);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
}

/* ── Avatar ────────────────────────────────────────────────────────────── */

.avatar {
  width: 34px; height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-content: center;
  border-radius: var(--r-pill);
  background: linear-gradient(150deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: var(--t-xs);
  font-weight: 700;
  text-transform: uppercase;
}

/* ── Utilities ─────────────────────────────────────────────────────────── */

.divider { height: 1px; background: var(--line); border: 0; margin: 0; }
.hide-mobile { display: initial; }
.only-mobile { display: none; }
@media (max-width: 860px) {
  .hide-mobile { display: none !important; }
  .only-mobile { display: initial; }
}
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-accent { color: var(--accent); font-weight: 600; }
.link-accent:hover { text-decoration: underline; text-underline-offset: 3px; }
.link-quiet { color: var(--text-dim); }
.link-quiet:hover { color: var(--text); }
