@layer reset, base, components, utilities;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body { margin: 0; }
  button, input, textarea, select { font: inherit; color: inherit; }
}

@layer base {
  :root {
    --bg: #0e0f12;
    --fg: #e8eaed;
    --muted: #9aa0a6;
    --accent: #4cd97b;
    --accent-fg: #04150a;
    --surface: #1a1c20;
    --surface-2: #23262b;
    --border: #2c2f35;
    --danger: #ff7a7a;
    --radius: 8px;
  }
  body {
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
  }
  code, pre { font-family: ui-monospace, 'SF Mono', Consolas, monospace; }
  a { color: var(--accent); text-decoration: none; }
  a:hover { text-decoration: underline; }
  h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; }
}

@layer components {
  .shell { display: grid; grid-template-rows: auto 1fr; min-height: 100vh; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 24px; border-bottom: 1px solid var(--border); background: var(--surface);
  }
  .topbar h1 { font-size: 18px; margin: 0; }
  .topbar nav { display: flex; gap: 16px; }
  .topbar nav a { color: var(--muted); padding: 4px 8px; border-radius: var(--radius); }
  .topbar nav a.active { color: var(--accent); background: var(--surface-2); }
  .topbar .who { color: var(--muted); font-size: 14px; }

  main { max-width: 880px; margin: 0 auto; padding: 24px 16px 64px; width: 100%; }

  .card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; margin-bottom: 20px;
  }
  .card h2 { margin: 0 0 12px; font-size: 18px; }

  button.primary {
    padding: 8px 14px; background: var(--accent); color: var(--accent-fg);
    border: 0; border-radius: var(--radius); font-weight: 600; cursor: pointer;
  }
  button.ghost {
    padding: 6px 12px; background: transparent; color: var(--fg);
    border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
  }
  button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }

  input[type="text"], input[type="password"], input[type="number"],
  textarea, select, input[type="file"] {
    padding: 10px 12px; background: var(--surface-2);
    border: 1px solid var(--border); border-radius: var(--radius); color: var(--fg);
  }

  .centered { max-width: 420px; margin: 64px auto; }
  .stack-sm > * + * { margin-top: 8px; }

  .msg { color: var(--muted); font-size: 14px; }
  .msg.error { color: var(--danger); }
  .msg.ok { color: var(--accent); }
  .new-key-note { margin-top: 12px; }
  pre.key {
    background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius);
    overflow-x: auto; font-size: 13px;
  }

  .pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
  .pill.ok { background: rgba(76, 217, 123, 0.12); color: var(--accent); }
  .pill.warn { background: rgba(255, 122, 122, 0.12); color: var(--danger); }

  /* Sub-row under a failed transcode row — shows whatever error fields
     the runner sent (error_code + error text), nothing translated or
     editorialized. Lighter border so it visibly belongs to the row above. */
  tr.error-row td {
    background: rgba(255, 122, 122, 0.06);
    border-top: 0;
    padding-top: 0;
    padding-left: 24px;
    font-size: 13px;
  }
  tr.error-row code { color: var(--danger); }

  /* Sub-row under a succeeded transcode row — one row per variant.
     Same visual containment pattern as .error-row so the rendition
     list visibly belongs to the job above. */
  tr.variant-row td {
    background: var(--surface-2);
    border-top: 0;
    padding-top: 6px;
    padding-bottom: 6px;
    padding-left: 24px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 12px;
  }
  tr.variant-row .variant-name {
    font-family: ui-monospace, 'SF Mono', Consolas, monospace;
    color: var(--accent);
    min-width: 60px;
  }
  table { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: auto; }
  th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
  th { color: var(--muted); font-weight: 500; }
  /* Long URLs, IDs, and hashes in <code> tags shouldn't push column
     widths past the card. overflow-wrap: anywhere lets them break on
     any character; min-width: 0 lets the cell shrink. */
  td code, th code { overflow-wrap: anywhere; word-break: break-word; }
  td, th { min-width: 0; }

  /* Last-resort scroll for any card whose contents still overflow. */
  .card { overflow-x: auto; }

  .tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
  .tabs button {
    background: none; border: 0; padding: 8px 12px; color: var(--muted);
    border-bottom: 2px solid transparent; cursor: pointer;
  }
  .tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

  video {
    width: 100%; max-height: 60vh; background: black;
    border-radius: var(--radius); margin-top: 12px;
  }

  .drop-zone {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 32px; text-align: center; color: var(--muted);
    cursor: pointer; transition: border-color 0.15s;
  }
  .drop-zone.over { border-color: var(--accent); color: var(--accent); }
  .progress-bar {
    height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden;
    margin: 8px 0;
  }
  .progress-bar > span { display: block; height: 100%; background: var(--accent); }

  kbd, .obs-hint {
    background: var(--surface-2); border-radius: 4px; padding: 1px 6px;
    font-family: ui-monospace, monospace; font-size: 12px;
  }
}
