/* ============================================================
   Media Organizer — Main Stylesheet
   Editorial cinema archive. Modern · Sharp · Confident.

   Design tokens live in tokens.css. This file contains:
     1. Reset + base
     2. Global shell (body, header, nav, theme toggle)
     3. Legacy components (panels, buttons, inputs, tables,
        modal, toasts, progress, terminal). These keep older
        per-tab views functional until each tab is redesigned;
        they have been ported to the new token palette and
        had AI-tell anti-patterns (neon glow, border-left
        color stripes, gradient text) removed.
   ============================================================ */

/* ---------- 1. Reset + base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--surface-page);
  color: var(--text-base);
  font-family: var(--font-display);
  font-size: var(--text-base);
  line-height: var(--leading-base);
  font-feature-settings: "ss01", "cv01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color var(--dur-base) var(--ease-out),
              color var(--dur-base) var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

::selection {
  background-color: color-mix(in oklch, var(--accent) 35%, transparent);
  color: var(--text-strong);
}

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
  transition: color var(--dur-fast) var(--ease-out);
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-xs);
}

p { line-height: var(--leading-loose); max-width: var(--readable-measure); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--weight-semi);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: var(--text-strong);
  margin: 0;
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl);  }
h3 { font-size: var(--text-lg);  letter-spacing: var(--tracking-snug); }
h4 { font-size: var(--text-md);  letter-spacing: var(--tracking-snug); }

code, kbd, pre, samp { font-family: var(--font-mono); font-size: 0.95em; }

button { font-family: inherit; }

/* ---------- 2. Global Shell ---------- */

.app-container {
  max-width: var(--shell-max-width);
  margin: 0 auto;
  padding: var(--shell-pad-y) var(--shell-pad-x) var(--space-3xl);
}

/* ---------- Header ---------- */

.glass-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-md) 0 var(--space-lg);
  margin-bottom: var(--space-2xl);
  border-bottom: 1px solid var(--border-subtle);
  background: transparent;
  backdrop-filter: none;
  border-radius: 0;
  position: relative;
  z-index: 100;
}

/* Brand mark — wordmark + small geometric film-perforation hairline */

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-display);
  font-weight: var(--weight-semi);
  font-size: var(--text-md);
  letter-spacing: var(--tracking-tight);
  color: var(--text-strong);
  line-height: 1;
}

/* Brand mark — sharp film-strip glyph, color tracks logo text via currentColor */
.logo__mark {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--text-strong);
  display: block;
}

.logo__wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.15em;
}

.logo .highlight {
  color: var(--text-strong);
  text-shadow: none;
  font-weight: var(--weight-bold);
}

.logo .highlight::before {
  content: "·";
  margin: 0 0.25em;
  color: var(--accent);
  font-weight: var(--weight-bold);
}

/* LIVE monitor badge — quiet text, tiny pulse dot */
.monitor-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-3xs) var(--space-xs);
  margin-left: var(--space-sm);
  font-family: var(--font-display);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border-base);
  border-radius: var(--radius-sm);
}

.monitor-badge .pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 color-mix(in oklch, var(--success) 60%, transparent);
  animation: pulse-quiet 2.4s var(--ease-out) infinite;
}

@keyframes pulse-quiet {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--success) 50%, transparent); }
  50%      { box-shadow: 0 0 0 4px color-mix(in oklch, var(--success) 0%, transparent); }
}

/* ---------- Primary navigation ---------- */

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(var(--space-md), 2vw, var(--space-xl));
}

.nav-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  background: transparent;
  border: 0;
  padding: var(--space-xs) 0;
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-snug);
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out);
}

.nav-btn i {
  font-size: 0.85em;
  color: var(--text-subtle);
  transition: color var(--dur-fast) var(--ease-out);
}

.nav-btn:hover,
.nav-btn:focus-visible {
  color: var(--text-strong);
  outline: none;
}

.nav-btn:hover i,
.nav-btn:focus-visible i {
  color: var(--text-base);
}

.nav-btn:focus-visible {
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-xs);
}

.nav-btn.active {
  color: var(--text-strong);
}

.nav-btn.active i {
  color: var(--accent);
}

/* Active indicator: precise hairline beneath the label */
.nav-btn.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  transform-origin: center;
  animation: nav-indicator-in var(--dur-base) var(--ease-out);
}

@keyframes nav-indicator-in {
  from { transform: scaleX(0); opacity: 0; }
  to   { transform: scaleX(1); opacity: 1; }
}

/* Logout — placed at the right end with a quiet hairline divider */
.nav-btn.logout-btn {
  margin-left: var(--space-md);
  padding-left: var(--space-md);
  border-left: 1px solid var(--border-subtle);
  color: var(--text-subtle);
}

.nav-btn.logout-btn:hover {
  color: var(--danger);
}

.nav-btn.logout-btn:hover i {
  color: var(--danger);
}

/* ---------- Theme toggle (Auto / Light / Dark) ---------- */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  gap: 0;
}

.theme-toggle__option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  color: var(--text-subtle);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.theme-toggle__option:hover {
  color: var(--text-base);
}

.theme-toggle__option:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.theme-toggle__option[aria-pressed="true"] {
  background: var(--surface-page);
  color: var(--text-strong);
  box-shadow: var(--shadow-sm);
}

.theme-toggle__option svg {
  width: 14px;
  height: 14px;
}

/* ---------- Hamburger (mobile) ---------- */

.hamburger-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border-base);
  color: var(--text-base);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-base);
  transition: border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.hamburger-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-strong);
}

@media (max-width: 880px) {
  .glass-header {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "logo controls"
      "nav  nav";
    gap: var(--space-sm);
  }
  .logo { grid-area: logo; }
  .header-controls { grid-area: controls; display: flex; gap: var(--space-sm); align-items: center; }
  .hamburger-btn { display: inline-flex; align-items: center; gap: var(--space-2xs); }
  .nav-links {
    grid-area: nav;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-subtle);
  }
  .nav-links.is-open { display: flex; }
  .nav-btn {
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--border-subtle);
    justify-content: flex-start;
    min-height: 44px; /* touch target */
  }
  .nav-btn.active::after { display: none; }
  .nav-btn.active {
    color: var(--accent);
  }
  .nav-btn.logout-btn {
    border-left: 0;
    margin-left: 0;
    padding-left: 0;
  }
}

/* Provide a default header-controls container even on desktop */
@media (min-width: 881px) {
  .header-controls {
    display: inline-flex;
    align-items: center;
    gap: var(--space-md);
  }
  .hamburger-btn { display: none; }
}

/* ---------- Tab content visibility ---------- */

.tab-content { display: none; }
.tab-content.active {
  display: block;
  animation: tab-fade-in var(--dur-base) var(--ease-out);
}

@keyframes tab-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hidden { display: none !important; }

.row { display: flex; gap: var(--space-sm); align-items: center; flex-wrap: wrap; }

.large { font-size: var(--text-md); padding: var(--space-sm) var(--space-xl); }

/* ---------- Custom scrollbar — quiet, editorial ---------- */
::-webkit-scrollbar       { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-base);
  border-radius: var(--radius-pill);
  border: 2px solid var(--surface-page);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

* { scrollbar-width: thin; scrollbar-color: var(--border-base) transparent; }


/* ============================================================
   3. Legacy components — softened, awaiting per-tab redesign
   ============================================================ */

/* ---------- Glass panel (now: paper card) ---------- */
.glass-panel {
  background: var(--surface-1);
  backdrop-filter: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: none;
}

/* ---------- Inputs ---------- */
.glass-input {
  background: var(--surface-1);
  border: 1px solid var(--border-base);
  color: var(--text-strong);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  width: 100%;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}

.glass-input::placeholder { color: var(--text-subtle); }

.glass-input:hover { border-color: var(--border-strong); }

.glass-input:focus,
.glass-input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 22%, transparent);
}

/* ---------- Buttons ---------- */
.glass-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: var(--weight-medium);
  font-size: var(--text-sm);
  letter-spacing: var(--tracking-snug);
  text-transform: none;
  line-height: 1;
  min-height: 38px;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

.glass-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.glass-btn:active { transform: translateY(1px); }

/* Modal close buttons (file browser, request history, dup modal). UA focus
   ring is suppressed by the global <button> reset, so re-add it via the
   shared --focus-ring token; otherwise keyboard users have no focus cue. */
.close-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Filmweb brand crimson — restrained partner-brand hint for the Filmweb
   checkbox icon in Settings. Token defined in tokens.css; light + dark
   parity. Never hardcode #DC143C inline (banned by STYLING.md). */
.settings-icon--filmweb {
  color: var(--brand-filmweb);
  margin-right: 4px;
}

/* Compact variant — used in dense toolbars (Memory tab, alias add row,
   Scan tab inline controls). Reverts to a 44×44 touch target on phones
   so it doesn't fall below the project's a11y baseline. */
.glass-btn.small {
  min-height: 32px;
  padding: var(--space-2xs) var(--space-md);
  font-size: var(--text-xs);
  gap: var(--space-3xs);
}

@media (max-width: 720px) {
  .glass-btn.small {
    min-height: 44px;
    padding: var(--space-xs) var(--space-md);
    font-size: var(--text-sm);
  }
}

.glass-btn.primary {
  background: var(--accent);
  color: var(--accent-on);
  border-color: var(--accent);
  box-shadow: none;
}

.glass-btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: none;
  transform: none;
}

.glass-btn.secondary {
  background: var(--surface-2);
  color: var(--text-strong);
  border-color: var(--border-base);
}

.glass-btn.secondary:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.glass-btn.success {
  background: var(--success);
  color: var(--surface-page);
  border-color: var(--success);
  width: 100%;
}

.glass-btn.danger {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in oklch, var(--danger) 50%, var(--border-base));
}

.glass-btn.danger:hover {
  background: color-mix(in oklch, var(--danger) 10%, transparent);
  box-shadow: none;
}

.success-feedback {
  background: var(--accent-soft) !important;
  border: 1px solid color-mix(in oklch, var(--accent) 40%, var(--border-base)) !important;
  color: var(--text-strong) !important;
  box-shadow: none !important;
}

/* Brief outline pulse to confirm an auto-save fired on a settings field. */
.autosaved-flash {
  animation: autosaved-pulse 0.9s ease-out;
}
@keyframes autosaved-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in oklch, var(--accent) 60%, transparent); }
  50%  { box-shadow: 0 0 0 4px color-mix(in oklch, var(--accent) 25%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--accent) 0%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .autosaved-flash { animation: none; }
}

/* ---------- Tables ---------- */
.glass-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-md);
  table-layout: fixed;
  font-size: var(--text-sm);
}

.glass-table th,
.glass-table td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.glass-table th {
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  font-size: var(--text-2xs);
  letter-spacing: var(--tracking-caps);
  border-bottom-color: var(--border-base);
}

.glass-table tr:hover td { background: var(--surface-2); }

.glass-table th:nth-child(1), .glass-table td:nth-child(1) { width: 30%; }
.glass-table th:nth-child(2), .glass-table td:nth-child(2) { width: 25%; }
.glass-table th:nth-child(3), .glass-table td:nth-child(3) { width: 60px; }
.glass-table th:nth-child(4), .glass-table td:nth-child(4) { width: 80px; }
.glass-table th:nth-child(5), .glass-table td:nth-child(5) { width: 60px; text-align: center; }
.glass-table th:nth-child(6), .glass-table td:nth-child(6) { width: 80px; text-align: center; }
.glass-table th:nth-child(7), .glass-table td:nth-child(7) { width: 60px; padding: 12px 2px; text-align: center; }
.glass-table th:nth-child(8), .glass-table td:nth-child(8) { width: 50px; text-align: center; }

/* Memory tab styles: see memory.css */

/* ---------- Logs tab: [Raw] [Timeline] sub-view bar + Activity Timeline ---------- */
.logs-viewbar {
  display: inline-flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  padding: var(--space-2xs);
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill, 999px);
}

.logs-viewbar__btn {
  background: transparent;
  border: 0;
  padding: var(--space-2xs) var(--space-sm);
  border-radius: var(--radius-pill, 999px);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-snug);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
}
.logs-viewbar__btn:hover { color: var(--text-base); background: var(--surface-2); }
.logs-viewbar__btn.is-active { background: var(--accent-soft); color: var(--text-strong); }

.timeline {
  list-style: none;
  margin: 0;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.timeline__empty {
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-align: center;
  padding: var(--space-md);
}

.timeline__row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--space-sm);
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
}

.timeline__icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
}

.timeline__row--success .timeline__icon { color: oklch(60% 0.15 145); }   /* green */
.timeline__row--queue   .timeline__icon { color: oklch(70% 0.13 90); }    /* yellow */
.timeline__row--memory  .timeline__icon { color: oklch(60% 0.18 300); }   /* purple */
.timeline__row--integrity .timeline__icon { color: oklch(58% 0.20 25); }  /* red */
.timeline__row--error   .timeline__icon { color: oklch(58% 0.22 25); }    /* red, slightly more saturated than integrity */

.timeline__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
  min-width: 0;
}

.timeline__summary {
  color: var(--text-strong);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline__detail {
  color: var(--text-muted);
  font-size: var(--text-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline__when {
  color: var(--text-subtle);
  font-size: var(--text-2xs);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Timeline controls (Q4) ----------
   Filter chips + search input live above the list. The search box uses the
   same icon-prefixed pattern as the Library filter bar so the two don't drift.
*/
.timeline-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
  padding: var(--space-sm) var(--space-md) 0;
}

.timeline-controls__search {
  position: relative;
  flex: 1 1 240px;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-2xs) var(--space-sm);
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.timeline-controls__search > i {
  color: var(--text-subtle);
  font-size: var(--text-xs);
}

.timeline-controls__search-input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-base);
  font: inherit;
  font-size: var(--text-sm);
  outline: none;
  padding: var(--space-3xs) 0;
}

.timeline-controls__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs);
}

.timeline-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-3xs) var(--space-sm);
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.timeline-chip > i { font-size: 0.75em; }

.timeline-chip:hover { background: var(--surface-2); color: var(--text-base); }

.timeline-chip.is-active {
  background: var(--accent-soft);
  color: var(--text-strong);
  border-color: var(--accent);
}

.timeline-chip:not(.is-active) {
  opacity: 0.6;
}

/* ---------- Day-grouping headers (Q4) ----------
   Sticky inside the scroll panel so the user always knows which day they're
   reading. Lowercase tracking-out caps to keep the editorial voice. */
.timeline__day-header {
  position: sticky;
  top: 0;
  z-index: 1;
  list-style: none;
  margin: var(--space-sm) 0 var(--space-2xs);
  padding: var(--space-2xs) var(--space-xs);
  background: var(--surface-base);
  color: var(--text-subtle);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-subtle);
}

.timeline__day-header:first-child { margin-top: 0; }

/* ---------- Inline expand (Q4) ----------
   The base row stays a 3-column grid (icon/body/when); when expanded we add
   a chevron column and a full-width detail row underneath via grid-template
   adjustments. Click affordance via cursor:pointer + hover surface lift. */
.timeline__row {
  cursor: pointer;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  position: relative;
}

.timeline__row:hover {
  border-color: var(--accent);
}

.timeline__row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.timeline__chevron {
  color: var(--text-subtle);
  font-size: var(--text-xs);
  width: 1em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.timeline__row--expanded {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  grid-template-rows: auto auto;
  background: var(--surface-2);
}

.timeline__expansion {
  grid-column: 1 / -1;
  margin-top: var(--space-xs);
  padding-top: var(--space-xs);
  border-top: 1px solid var(--border-subtle);
}

.timeline__detail-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-2xs) var(--space-md);
  margin: 0;
  font-size: var(--text-xs);
}

.timeline__detail-grid dt {
  color: var(--text-subtle);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  font-size: var(--text-2xs);
  padding-top: 2px;
}

.timeline__detail-grid dd {
  color: var(--text-base);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  flex-wrap: wrap;
  min-width: 0;
}

.timeline__detail-empty {
  margin: 0;
  color: var(--text-subtle);
  font-size: var(--text-xs);
}

.timeline__path {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: var(--text-2xs);
  color: var(--text-base);
  background: var(--surface-1);
  padding: 1px var(--space-2xs);
  border-radius: var(--radius-sm);
  word-break: break-all;
  flex: 1 1 auto;
  min-width: 0;
}

.timeline__copy {
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-subtle);
  cursor: pointer;
  padding: 2px var(--space-2xs);
  font-size: var(--text-2xs);
  display: inline-flex;
  align-items: center;
}

.timeline__copy:hover {
  color: var(--text-base);
  background: var(--surface-2);
}

.timeline__poster {
  width: 56px;
  height: auto;
  border-radius: var(--radius-sm);
  display: block;
}

.timeline__chipline {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--space-xs);
  border-radius: 999px;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  font-size: var(--text-2xs);
  color: var(--text-base);
}

/* ---------- Status badges ---------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-xs);
  border-radius: var(--radius-sm);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

.status-new {
  background: color-mix(in oklch, var(--success) 14%, transparent);
  color: var(--success);
}

.status-dup {
  background: color-mix(in oklch, var(--danger) 14%, transparent);
  color: var(--danger);
}

.status-conflict {
  background: color-mix(in oklch, var(--warning) 16%, transparent);
  color: var(--warning);
  border: 1px solid color-mix(in oklch, var(--warning) 30%, var(--border-base));
}

.conflict-details {
  font-size: var(--text-2xs);
  color: var(--text-muted);
  margin-top: var(--space-3xs);
  display: block;
}

.omdb-usage-badge {
  margin-left: auto;
  background: var(--surface-2);
  padding: var(--space-2xs) var(--space-sm);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  margin-top: var(--space-sm);
}

/* ---------- Search box ---------- */
.search-box {
  position: relative;
  margin: var(--space-lg) 0;
}

.search-box i {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  font-size: var(--text-base);
  pointer-events: none;
}

.search-box .glass-input {
  padding-left: calc(var(--space-md) * 2 + 18px);
  font-size: var(--text-md);
  box-shadow: none;
}

#searchResultsArea { margin-top: var(--space-xl); animation: tab-fade-in var(--dur-base) var(--ease-out); }

/* ---------- Terminal (Logs tab) ----------
   Theme-fit: a deep "ink panel" in light mode, a recess BELOW the
   page surface in dark mode. Never the flipped light box that
   --surface-inverse produced under [data-theme="dark"]. */
.terminal {
  background: var(--terminal-bg);
  color: var(--terminal-ink);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.5;
  letter-spacing: 0;
  min-height: 300px;
  max-height: 600px;
  overflow-y: auto;
  overflow-wrap: anywhere;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--terminal-border);
  scrollbar-color: var(--terminal-border) transparent;
}

.terminal:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.terminal::-webkit-scrollbar-track { background: transparent; }
.terminal::-webkit-scrollbar-thumb { background: var(--terminal-border); }
.terminal::-webkit-scrollbar-thumb:hover {
  background: color-mix(in oklch, var(--terminal-border) 70%, var(--terminal-ink));
}

#terminalOutput {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.log-line {
  margin: 0;
  max-width: none;            /* override global p { max-width: 68ch } */
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--terminal-ink);
}

/* Log levels — colors tuned to read on the dark terminal interior in
   BOTH themes (the interior is dark in light- and dark-mode alike,
   so a single set of level colors works). */
.log-line.debug   { color: var(--terminal-muted); }
.log-line.info    { color: var(--terminal-ink); }
.log-line.success { color: var(--terminal-success); }
.log-line.warn,
.log-line.warning { color: var(--terminal-warning); }
.log-line.error,
.log-line.critical { color: var(--terminal-error); }

/* ---------- Modal system ----------
   Base .modal is the backdrop + centering layer. .modal-content is
   the panel. Default size = sm (~420px); use --md / --lg variants
   for forms / list browsers. Centering of TEXT is opt-in via
   .modal-content--centered (used by short confirm/cleanup dialogs);
   form-style modals stay left-aligned for legibility. */
.modal {
  position: fixed; inset: 0;
  /* No `backdrop-filter: blur(...)` — glassmorphism is in the
     `.impeccable.md` ban list. The scrim is deepened (0.55 → 0.68)
     so the page behind the dialog stays readable as "off" without
     needing a blur. */
  background: oklch(15% 0.012 var(--hue-neutral) / 0.68);
  display: flex; justify-content: center; align-items: center;
  padding: var(--space-md);
  z-index: 1000;
  animation: modal-backdrop-in var(--dur-fast) var(--ease-out);
}

/* The shared confirm dialog (`App.confirm`) is opened ON TOP of other modals
   — e.g. the duplicate-resolve modal calls App.confirm before destructive
   actions. Without an explicit higher z-index, the confirm modal would be
   covered by whatever modal is later in the DOM. */
#confirmModal { z-index: 1100; }

.modal.hidden { display: none; }

.modal-content {
  background: var(--surface-1);
  border: 1px solid var(--border-base);
  width: 420px;
  max-width: 100%;
  max-height: calc(100vh - 2 * var(--space-md));
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow-y: auto;
  animation: modal-panel-in var(--dur-base) var(--ease-out);
}

.modal-content--centered { text-align: center; }
.modal-content--md { width: 560px; }
.modal-content--lg { width: 720px; }

@keyframes modal-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes modal-panel-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .modal,
  .modal-content {
    animation: none;
  }
}

.modal-actions {
  margin-top: var(--space-lg);
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  flex-wrap: wrap;
}

.modal-content--centered .modal-actions { justify-content: center; }

/* Visually-hidden helper for screen-reader-only labels */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Progress ---------- */
.progress-container {
  width: 100%;
  height: 6px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  margin-top: var(--space-sm);
  overflow: hidden;
  position: relative;
  border: 0;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  box-shadow: none;
  transition: width var(--dur-slow) var(--ease-out);
  border-radius: var(--radius-pill);
}

/* ---------- Toasts (border-left color stripes REMOVED — was AI tell) ---------- */
.toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: var(--surface-1);
  border: 1px solid var(--border-base);
  color: var(--text-strong);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 280px;
  max-width: 420px;
  transform: translateX(120%);
  transition: transform var(--dur-base) var(--ease-out);
  pointer-events: auto;
  backdrop-filter: none;
}

.toast.show { transform: translateX(0); }

.toast i { font-size: var(--text-md); flex-shrink: 0; }

.toast.success i   { color: var(--success); }
.toast.error i     { color: var(--danger);  }
.toast.info i      { color: var(--accent);  }
.toast.processing i{ color: var(--text-muted); }

/* Status accent for toasts done via icon color and a 1px tint on the
   border, NOT a 4px border-left stripe (which is in the absolute_bans). */
.toast.success    { border-color: color-mix(in oklch, var(--success) 35%, var(--border-base)); }
.toast.error      { border-color: color-mix(in oklch, var(--danger) 35%, var(--border-base)); }
.toast.info       { border-color: color-mix(in oklch, var(--accent) 35%, var(--border-base)); }

/* ---------- Misc legacy ---------- */
#btnScan { margin-right: var(--space-md); }
