/* ab design system tokens (warm stone, one ember accent, Geist). */
:root {
  --color-stone-50: #faf9f7;
  --color-stone-100: #f4f2ee;
  --color-stone-150: #ece9e3;
  --color-stone-200: #e0ddd4;
  --color-stone-300: #c9c4b8;
  --color-stone-400: #a39e90;
  --color-stone-500: #79756a;
  --color-stone-600: #56534a;
  --color-stone-700: #3b3934;
  --color-stone-800: #24231f;
  --color-stone-900: #171613;
  --color-stone-950: #0e0d0b;

  --color-ember-50: #fff3ec;
  --color-ember-100: #ffe3d0;
  --color-ember-200: #ffc39a;
  --color-ember-300: #ff9a5a;
  --color-ember-400: #ff7a2e;
  --color-ember-500: #ff5a1f;
  --color-ember-600: #e9430e;
  --color-ember-700: #c2330a;
  --color-ember-800: #922608;
  --color-ember-900: #5c1804;

  --color-bg: var(--color-stone-50);
  --color-bg-subtle: var(--color-stone-100);
  --color-bg-muted: var(--color-stone-150);
  --color-surface: #ffffff;
  --color-surface-2: var(--color-stone-50);
  --color-elevated: #ffffff;
  --color-border: var(--color-stone-200);
  --color-border-strong: var(--color-stone-300);
  --color-fg: var(--color-stone-900);
  --color-fg-2: var(--color-stone-700);
  --color-fg-3: var(--color-stone-500);
  --color-accent: var(--color-ember-500);
  --color-accent-hover: var(--color-ember-600);
  --color-accent-fg: #ffffff;
  --color-accent-soft: var(--color-ember-100);
  --color-success: #0a7c5a;
  --color-warning: #b45309;
  --color-danger: #b42318;
  --color-link: var(--color-ember-700);

  --font-ui: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 16px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-3xl: 36px;
  --text-4xl: 48px;

  --leading-tight: 1.1;
  --leading-snug: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65;
  --tracking-tight: -0.02em;
  --tracking-label: 0.06em;

  --radius-sm: 4px;
  --radius: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(23, 22, 19, 0.05), 0 1px 1px rgba(23, 22, 19, 0.03);
  --shadow-lg: 0 12px 28px -8px rgba(23, 22, 19, 0.12), 0 4px 8px rgba(23, 22, 19, 0.05);

  --focus-ring-color: var(--color-ember-400);
  --ease-ab: cubic-bezier(0.2, 0, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: var(--color-stone-950);
    --color-bg-subtle: var(--color-stone-900);
    --color-bg-muted: var(--color-stone-800);
    --color-surface: #1a1916;
    --color-surface-2: var(--color-stone-900);
    --color-elevated: #2a2823;
    --color-border: #2b2926;
    --color-border-strong: #3a3834;
    --color-fg: var(--color-stone-50);
    --color-fg-2: var(--color-stone-300);
    --color-fg-3: var(--color-stone-400);
    --color-accent: var(--color-ember-400);
    --color-accent-hover: var(--color-ember-300);
    --color-accent-fg: var(--color-stone-950);
    --color-accent-soft: rgba(255, 122, 46, 0.14);
    --color-success: #34d399;
    --color-warning: #f59e0b;
    --color-danger: #f87171;
    --color-link: var(--color-ember-300);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 14px 32px -8px rgba(0, 0, 0, 0.6);
  }
}

/* Base ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-fg);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--color-ember-300); color: var(--color-stone-950); }

*:focus { outline: none; }
*:focus-visible {
  outline: 2px solid var(--focus-ring-color);
  outline-offset: 2px;
  border-radius: inherit;
  transition: none !important;
}

[hidden] { display: none !important; }

p { margin: 0; line-height: var(--leading-relaxed); color: var(--color-fg-2); text-wrap: pretty; }
h1, h2, h3 { margin: 0; color: var(--color-fg); }
a { color: var(--color-link); text-decoration: underline; text-decoration-color: var(--color-ember-300); text-underline-offset: 3px; }

.eyebrow {
  margin: 0;
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--color-fg-3);
}

.numeral {
  font-weight: 500;
  font-feature-settings: "lnum" 1, "tnum" 1;
  letter-spacing: -0.01em;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Layout -------------------------------------------------------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  max-width: 752px;
  margin: 0 auto;
  padding: 20px 16px;
}
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.wordmark { font-weight: 600; font-size: var(--text-lg); letter-spacing: var(--tracking-tight); line-height: 1.1; }
.brand .eyebrow { font-size: 11px; }

.account { position: relative; }
.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-fg-2);
  cursor: pointer;
}
.avatar:hover, .avatar[aria-expanded="true"] { background: var(--color-bg-muted); color: var(--color-fg); }
.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 10;
  min-width: 200px;
  padding: 6px;
  background: var(--color-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.account-env {
  padding: 6px 10px 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-xs);
  color: var(--color-fg-3);
}
.menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-fg);
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
}
.menu-item:hover { background: var(--color-bg-muted); }

.page {
  max-width: 752px;
  margin: 0 auto;
  padding: 8px 16px 96px;
  display: flex;
  flex-direction: column;
  gap: 48px;
}

.status-line { color: var(--color-fg-3); font-size: var(--text-sm); }

/* Hero ---------------------------------------------------------- */
.hero { display: flex; flex-direction: column; align-items: flex-start; gap: 20px; padding-top: 32px; }
.hero-title {
  font-weight: 600;
  font-size: clamp(var(--text-3xl), 7vw, var(--text-4xl));
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}
.deco-underline { display: block; width: 48px; height: 3px; background: var(--color-accent); border-radius: 2px; margin-top: -8px; }
.lede { font-size: var(--text-lg); max-width: 34em; }
.apple-button:empty { display: none; }
.hero .apple-auth-button { max-width: 100%; }

.message { color: var(--color-danger); max-width: 36em; }

/* Panels and banners -------------------------------------------- */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.section-title { font-weight: 600; font-size: var(--text-xl); letter-spacing: -0.01em; }
.setup code { font-family: var(--font-mono); font-size: 0.92em; background: var(--color-bg-muted); padding: 2px 6px; border-radius: var(--radius-sm); }

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.banner p { color: var(--color-fg); }

/* Drop zone ----------------------------------------------------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 48px 20px;
  border: 1.5px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color 120ms var(--ease-ab), background-color 120ms var(--ease-ab);
}
.dropzone:hover { border-color: var(--color-fg-3); }
.dropzone.is-over { border-color: var(--color-accent); background: var(--color-accent-soft); }
.dropzone:has(input:focus-visible) { outline: 2px solid var(--focus-ring-color); outline-offset: 2px; }
.dropzone-title { font-weight: 600; font-size: var(--text-lg); color: var(--color-fg); }
.dropzone-hint { font-size: var(--text-sm); color: var(--color-fg-3); margin-bottom: 8px; }

/* Buttons ------------------------------------------------------- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-fg);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms var(--ease-ab), border-color 120ms var(--ease-ab);
}
.btn:hover { background: var(--color-bg-subtle); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-accent-fg); }
.btn-primary:hover, .dropzone:hover .btn-primary { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--color-fg-2); }
.btn-ghost:hover { background: var(--color-bg-muted); }
.btn-danger { color: var(--color-danger); }
.btn-small { min-height: 30px; padding: 0 10px; }

/* Queue and library rows ---------------------------------------- */
.block-head { display: flex; align-items: center; justify-content: space-between; min-height: 30px; margin-bottom: 8px; }
.count { color: var(--color-fg-2); margin-left: 6px; }

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.rows:empty { display: none; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-top: 1px solid var(--color-border);
}
.row:first-child { border-top: 0; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.row-title { font-weight: 500; color: var(--color-fg); overflow-wrap: anywhere; }
.row-meta { font-size: var(--text-sm); color: var(--color-fg-3); font-feature-settings: "tnum" 1; overflow-wrap: anywhere; }
.row-status { font-size: var(--text-sm); color: var(--color-fg-2); }
.row-status.is-done { color: var(--color-success); }
.row-status.is-error { color: var(--color-danger); }
.row-status.is-muted { color: var(--color-fg-3); }
.row-warning { font-size: var(--text-sm); color: var(--color-warning); }
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }

.bar { height: 4px; background: var(--color-bg-muted); border-radius: var(--radius-full); overflow: hidden; margin: 4px 0 2px; }
.bar > span { display: block; height: 100%; width: 0; background: var(--color-accent); border-radius: inherit; transition: width 200ms var(--ease-ab); }

.note { font-size: var(--text-sm); color: var(--color-fg-3); margin-top: 10px; }

/* Dialog -------------------------------------------------------- */
.dialog {
  max-width: min(440px, calc(100vw - 32px));
  padding: 24px;
  color: var(--color-fg);
  background: var(--color-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(14, 13, 11, 0.45); }
.dialog form { display: flex; flex-direction: column; gap: 12px; }
.dialog h3 { font-weight: 600; font-size: var(--text-lg); }
.dialog-file { font-weight: 500; color: var(--color-fg); overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

@media (max-width: 520px) {
  .row:has(.row-actions > :nth-child(2)) { flex-wrap: wrap; }
  .row:has(.row-actions > :nth-child(2)) .row-actions { width: 100%; justify-content: flex-end; }
  .dropzone { padding: 36px 16px; }
  .top { padding-top: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
