@font-face { font-family: "Geist"; src: url("/fonts/Geist-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Geist"; src: url("/fonts/Geist-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("/fonts/Fraunces-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("/fonts/Fraunces-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }

:root {
  --paper: #ECEEF2;
  --surface: #FFFFFF;
  --ink: #18202E;
  --muted: #586172;
  --line: #D3D8E0;
  --cobalt: #2B44C4;
  --cobalt-deep: #1F3399;
  --cobalt-soft: #E2E6F9;
  --done: #146C4B;
  --done-soft: #DCEFE6;
  --warn: #8A5600;
  --warn-soft: #F7EAD2;
  --fail: #B42318;
  --fail-soft: #FBE3E0;
  --gutter: 20px;
  --tap: 52px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 500 16px/1.5 "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
main { max-width: 600px; margin: 0 auto; padding: 0 var(--gutter) 64px; }
h1, h2, h3 { font-family: "Fraunces", Georgia, serif; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 30px; line-height: 1.12; }
h2 { font-size: 21px; line-height: 1.25; }
h3 { font-size: 17px; line-height: 1.3; }
p { margin: 0; }
a { color: var(--cobalt); }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0 14px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 14px; height: 26px; border-radius: 4px; background: var(--ink); position: relative; overflow: hidden; flex: none; }
.brand-mark::after { content: ""; position: absolute; left: 2px; right: 2px; bottom: 2px; height: 11px; border-radius: 2px; background: var(--cobalt); }
.brand b { color: var(--ink); font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 18px; display: block; line-height: 1.1; }
.brand span { font-size: 12.5px; color: var(--muted); display: block; }
.iconbtn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.iconbtn svg { width: 20px; height: 20px; }

/* ---------- buttons, fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 20px; border-radius: 14px;
  border: 0; background: var(--cobalt); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s; }
.btn:hover { background: var(--cobalt-deep); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.full { width: 100%; }
.btn.quiet { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.quiet:hover { background: var(--surface); }
.btn.danger { background: transparent; color: var(--fail); border: 1px solid #E8B4AE; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 15px; }
.input, .textarea { width: 100%; border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px; padding: 14px; font-size: 16px; }
.input:focus, .textarea:focus { border-color: var(--cobalt); outline: none; box-shadow: 0 0 0 3px var(--cobalt-soft); }
.textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.paste-row { display: flex; gap: 8px; }
.paste-row .input { flex: 1; min-width: 0; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; cursor: pointer; padding: 4px 0; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--cobalt); flex: none; }
.error-text { color: var(--fail); font-size: 14.5px; }

/* ---------- compose (home) ---------- */
.compose { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px var(--gutter) 20px; display: grid; gap: 16px; margin-top: 4px; }
.compose h1 { font-size: 27px; }
.compose details summary { cursor: pointer; color: var(--muted); font-size: 15px; list-style: none; display: flex; align-items: center; gap: 6px; min-height: 32px; }
.compose details summary::before { content: "+"; font-weight: 600; width: 16px; }
.compose details[open] summary::before { content: "−"; }
.compose details > div { display: grid; gap: 14px; padding-top: 10px; }
.hint { font-size: 14px; color: var(--muted); }

.banner { border-radius: 14px; padding: 14px 16px; font-size: 15px; display: flex; gap: 12px; align-items: flex-start; margin: 14px 0 0; }
.banner.warn { background: var(--warn-soft); color: #5B3A00; }
.banner.fail { background: var(--fail-soft); color: #7A1810; }
.banner a, .banner button.link { color: inherit; font-weight: 600; }
button.link { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }

/* ---------- job list ---------- */
.section-title { margin: 30px 0 10px; font-size: 19px; }
.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.row { border-bottom: 1px solid var(--line); }
.row a { display: grid; grid-template-columns: 92px 1fr; gap: 14px; padding: 14px 0; color: inherit; text-decoration: none; align-items: center; }
.thumb { width: 92px; aspect-ratio: 16 / 9; border-radius: 8px; object-fit: cover; background: #D9DDE4; display: block; }
.row-title { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-status { font-size: 14px; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.running { background: var(--cobalt); animation: pulse 1.6s ease-in-out infinite; }
.dot.queued { background: var(--warn); }
.dot.done { background: var(--done); }
.dot.failed, .dot.cancelled { background: var(--fail); }
.empty { padding: 26px 0; color: var(--muted); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- job page ---------- */
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--ink); text-decoration: none; font-weight: 600; }
.job-head { display: grid; gap: 6px; margin: 6px 0 22px; }
.job-head h1 { font-size: 26px; }

.progress { display: grid; grid-template-columns: 116px 1fr; gap: 22px; align-items: start; }
/* the one bold element: a 9:16 frame that fills as the steps complete, then becomes the cover */
.frame { position: relative; width: 116px; aspect-ratio: 9 / 16; border-radius: 22px; border: 2.5px solid var(--ink); background: var(--surface); overflow: hidden; }
.frame-fill { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--p, 0) * 100%); background: var(--cobalt); transition: height .9s cubic-bezier(.2, .7, .2, 1); }
.frame-fill::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: rgba(255,255,255,.55); }
.frame-ticks { position: absolute; inset: 0; pointer-events: none; }
.frame-ticks i { position: absolute; right: 0; width: 10px; height: 1.5px; background: var(--ink); opacity: .3; }
.frame-pct { position: absolute; left: 0; right: 0; top: 12px; text-align: center; font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 22px; mix-blend-mode: difference; color: #fff; }
.frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.frame.failed { border-color: var(--fail); }
.frame.failed .frame-fill { background: var(--fail); }

.now h2 { font-size: 22px; }
.now .note { margin-top: 6px; color: var(--ink); }
.now .eta { margin-top: 8px; font-size: 14.5px; color: var(--muted); }
.steps { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 2px; counter-reset: step; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 26px 1fr; gap: 10px; font-size: 14.5px; color: var(--muted); min-height: 26px; align-items: center; }
.steps li::before { content: counter(step); width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.steps li.done { color: var(--ink); }
.steps li.done::before { content: "✓"; border-color: var(--done); background: var(--done); color: #fff; }
.steps li.current { color: var(--ink); font-weight: 600; }
.steps li.current::before { border-color: var(--cobalt); background: var(--cobalt); color: #fff; animation: pulse 1.6s ease-in-out infinite; }

.reassure { margin-top: 18px; font-size: 14.5px; color: var(--muted); display: grid; gap: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.feed { margin-top: 28px; }
.feed ol { list-style: none; margin: 10px 0 0; padding: 0; border-left: 2px solid var(--line); }
.feed li { padding: 6px 0 6px 14px; font-size: 14.5px; position: relative; color: var(--muted); line-height: 1.4; }
.feed li time { font-size: 12.5px; color: var(--muted); margin-right: 8px; font-variant-numeric: tabular-nums; }
.feed li.ev-progress { color: var(--ink); font-weight: 600; }
.feed li.ev-progress::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--cobalt); }
.feed li.ev-claude { font-family: "Fraunces", Georgia, serif; font-weight: 400; color: var(--ink); }

/* ---------- results ---------- */
.results { margin-top: 26px; display: grid; gap: 14px; }
.versions { display: flex; gap: 8px; flex-wrap: wrap; }
.versions button { min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; }
.versions button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.tiles { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 62%); gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px;
  margin: 0 calc(-1 * var(--gutter)); padding-left: var(--gutter); padding-right: var(--gutter); scroll-padding-left: var(--gutter); }
@media (min-width: 620px) { .tiles { grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); overflow: visible; margin: 0; padding: 0; } }
.tile { scroll-snap-align: start; display: grid; gap: 10px; }
.tile .media { width: 100%; aspect-ratio: 9 / 16; border-radius: 16px; background: #10141C; object-fit: cover; display: block; }
.tile h3 { font-family: "Geist", system-ui, sans-serif; font-size: 15.5px; font-weight: 600; }
.tile .btn { min-height: 46px; font-size: 15px; }

.caption { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: grid; gap: 12px; }
.caption pre { margin: 0; white-space: pre-wrap; word-wrap: break-word; font: 500 14.5px/1.55 "Geist", system-ui, sans-serif; max-height: 300px; overflow: auto; }
.notes { font-size: 14px; color: var(--muted); white-space: pre-wrap; }
.revise { margin-top: 30px; display: grid; gap: 12px; }
.history { margin-top: 30px; }
.history li { font-size: 14.5px; color: var(--muted); padding: 6px 0; }

/* ---------- PIN ---------- */
.pin-wrap { min-height: calc(100vh - 40px); min-height: calc(100dvh - 40px); display: grid; align-content: center; justify-items: center; gap: 22px; padding: 30px 0; text-align: center; }
.pin-wrap h1 { font-size: 32px; }
.pin-dots { display: flex; gap: 12px; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--ink); transition: background .12s, transform .12s; }
.pin-dots span.on { background: var(--ink); transform: scale(1.05); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; }
.keypad button { height: 64px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); font-size: 24px; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.keypad button:active { background: var(--cobalt-soft); }
.keypad button.ghost { border-color: transparent; background: transparent; font-size: 15px; color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- settings ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px var(--gutter); display: grid; gap: 16px; margin-top: 6px; }

/* ---------- status, toast ---------- */
.net { position: sticky; top: 0; z-index: 5; background: var(--warn-soft); color: #5B3A00; text-align: center; font-size: 14px; padding: 8px 12px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px; z-index: 10; max-width: calc(100vw - 40px); }

@media (max-width: 380px) {
  :root { --gutter: 16px; }
  .progress { grid-template-columns: 92px 1fr; gap: 16px; }
  .frame { width: 92px; border-radius: 18px; }
  .keypad { grid-template-columns: repeat(3, 68px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
