:root {
  --bg: #ffffff;
  --surface: #f5f7fa;
  --fg: #14171f;
  --muted: #5a6476;
  --line: #e2e6ed;
  --accent: #2a5ae3;
  --accent-fg: #ffffff;
  --ok: #17784a;
  --warn: #9a5a00;
  --bad: #b3232d;
  --banner: #fff6d6;
  --banner-fg: #5c4500;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 16px; line-height: 1.5; }
p { margin: 0; }
h1, h2 { margin: 0; text-wrap: balance; }
img, canvas, video { max-width: 100%; }
[hidden] { display: none !important; }

.test-banner { background: var(--banner); color: var(--banner-fg); font-size: 14px; padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-top: max(10px, env(safe-area-inset-top, 0px)); }
.test-banner p { max-width: 560px; margin: 0 auto; }

.topbar { display: flex; align-items: center; gap: 10px; max-width: 560px; margin: 0 auto; padding-block: 14px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); font-weight: 600; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #2a5ae3, #19a3a3); }

.page { max-width: 560px; margin: 0 auto; display: grid; gap: 24px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-bottom: max(48px, env(safe-area-inset-bottom, 0px)); }
.cover canvas { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; border-radius: 14px; background: var(--surface); }
.summary { display: grid; gap: 10px; }
.summary h1 { font-size: 26px; line-height: 1.2; }
.by, .meta { color: var(--muted); font-size: 14px; }
.money { font-size: 15px; color: var(--muted); }
.money b { color: var(--fg); font-size: 22px; }
.track { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.track > div { height: 100%; background: var(--accent); border-radius: 999px; }
.cta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.story { display: grid; gap: 10px; }
.story h2 { font-size: 18px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; font-size: 16px; min-height: 48px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.small { min-height: 40px; font-size: 14px; padding: 8px 12px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible, .icon-btn:focus-visible, select:focus-visible, input:focus-visible, .chips button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--fg); }
select, input[type="text"] { font: inherit; font-size: 16px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; min-width: 0; width: 100%; }
input[type="file"] { font: inherit; font-size: 13px; color: var(--muted); max-width: 100%; }

.lab { border: 1px dashed var(--line); border-radius: 14px; background: var(--surface); }
.lab summary { cursor: pointer; padding: 14px 16px; font-weight: 600; font-size: 15px; }
.lab-body { display: grid; gap: 14px; padding: 0 16px 16px; min-width: 0; }
.lab-opts { display: grid; gap: 12px; }
.device { font-family: var(--mono); font-size: 12px; color: var(--muted); word-break: break-word; }
.caps { width: 100%; border-collapse: collapse; font-size: 13px; }
.caps td { padding: 6px 0; border-top: 1px solid var(--line); vertical-align: top; }
.caps tr:first-child td { border-top: 0; }
.caps td.k { width: 48%; padding-right: 10px; }
.caps td.v { font-family: var(--mono); font-size: 12px; word-break: break-word; }
.yes { color: var(--ok); }
.no { color: var(--bad); }
.maybe { color: var(--warn); }
.runs { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.runs .err { color: var(--bad); }
.hint { font-size: 13px; color: var(--muted); }
.hint.err { color: var(--bad); }

.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(12, 16, 24, 0.5); }
.sheet { position: relative; width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; background: var(--bg); border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
@media (min-width: 640px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 18px; } }
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--bg); padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 17px; }
.icon-btn { width: 40px; height: 40px; border-radius: 999px; border: 0; background: var(--surface); color: var(--fg); font-size: 16px; cursor: pointer; }
.sheet-body { display: grid; gap: 12px; padding: 14px 16px 18px; }
.preview-row { display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: start; }
.preview { width: 150px; aspect-ratio: 9 / 16; border-radius: 12px; overflow: hidden; background: #0d1422; }
.preview canvas, .preview video { display: block; width: 100%; height: 100%; object-fit: cover; }
.preview-side { display: grid; gap: 10px; min-width: 0; }
.progress { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width 120ms linear; }
.share-actions { display: grid; gap: 10px; }
.feedback { display: grid; gap: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
.feedback .q { font-weight: 600; font-size: 14px; margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { font: inherit; font-size: 14px; padding: 8px 12px; min-height: 40px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }

@media (prefers-reduced-motion: reduce) { .progress > div { transition: none; } }
