/* Layerpop v0.2.0 - shared styles. The home page is bright ("Bright pop"); the editor stays dark. */
:root {
  /* Editor (dark) tokens. Layout: stage + timeline on the left, controls on the right */
  --bg: #0D0F14;
  --panel: #151821;
  --raised: #1D212C;
  --line: #272C39;
  --ink: #EEF0F5;
  --muted: #949BAA;
  --accent: #4C6BFF;
  --accent-ink: #FFFFFF;
  --ok: #3CCB8C;
  --cobalt: #2B4BFF;
  --coral: #FF5A4E;
  --sun: #FFC533;
  --mint: #1FC8A0;
  --paper: #F4F5F7;
  --night: #14161C;
  --display: 'Syne', 'Arial Black', system-ui, sans-serif;
  --body: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--body); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { color: var(--ink); background: var(--raised); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; cursor: pointer; }
button:hover { border-color: #46506A; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 0; }
.brand { text-decoration: none; font: 800 23px/1 var(--display); letter-spacing: -0.02em; }

/* ---------- Editor header ---------- */
.top { display: flex; align-items: center; gap: 18px; padding: 14px clamp(16px, 4vw, 40px); border-bottom: 1px solid var(--line); }
.crumb { color: var(--muted); font-size: 14px; }
.crumb b { color: var(--ink); font-weight: 600; }

/* ---------- Home page (bright) ---------- */
/* Layout: centred column; hero with three tilted live previews; coloured category pills; outlined template cards */
body.home { background: var(--paper); color: var(--night); font-size: 17px; color-scheme: light; --edge: 2px solid var(--night); }
body.home :focus-visible { outline-color: var(--cobalt); }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }
.nav { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 26px; min-height: 84px; }
.nav nav { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 24px; margin-left: auto; font-weight: 600; }
.nav nav a { text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.nav nav a:hover { color: var(--cobalt); }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 50px; padding: 0 24px; border: var(--edge); border-radius: 999px; font-weight: 700; text-decoration: none; background: #FFFFFF; color: var(--night); transition: transform .12s, box-shadow .12s; }
.btn.main { background: var(--cobalt); color: #FFFFFF; box-shadow: 4px 4px 0 var(--night); }
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--night); color: var(--night); }
.btn.main:hover { color: #FFFFFF; }
.nav .btn { min-height: 46px; padding: 0 20px; box-shadow: none; }
.hero { display: flex; flex-direction: column; align-items: center; gap: 24px; text-align: center; padding: 36px 0 64px; }
.hero h1 { margin: 0; font: 800 clamp(44px, 7.4vw, 86px)/1 var(--display); letter-spacing: -0.03em; max-width: 12em; text-wrap: balance; }
.hero h1 span { display: inline-block; background: var(--sun); border: var(--edge); border-radius: 16px; padding: 0 0.18em; transform: rotate(-2deg); }
.hero p { margin: 0; font-size: clamp(17px, 1.6vw, 20px); max-width: 34em; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.trio { display: flex; flex-wrap: wrap; justify-content: center; gap: 22px; width: 100%; padding-top: 22px; }
.trio .tilt { flex: 1 1 280px; max-width: 380px; border: var(--edge); border-radius: 18px; overflow: hidden; box-shadow: 6px 6px 0 var(--night); background: var(--night); text-decoration: none; }
.trio .tilt:nth-child(1) { transform: rotate(-3deg); }
.trio .tilt:nth-child(2) { transform: translateY(18px); }
.trio .tilt:nth-child(3) { transform: rotate(3deg); }
.trio canvas, .card canvas { display: block; width: 100%; aspect-ratio: 16 / 9; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; padding: 34px 0 36px; }
.chip { min-height: 48px; padding: 0 20px; border: var(--edge); border-radius: 999px; font-weight: 700; font-size: 15px; color: var(--night); background: #FFFFFF; }
.chip span { margin-left: 8px; font-variant-numeric: tabular-nums; opacity: .75; }
.chip:hover { border-color: var(--night); transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--night); }
.chip[aria-pressed=true] { background: var(--night); color: #FFFFFF; }
.chip:disabled { opacity: .5; cursor: default; transform: none; box-shadow: none; background: #FFFFFF; color: var(--night); }
.c0 { background: var(--cobalt); color: #FFFFFF; } .c1 { background: var(--sun); } .c2 { background: var(--coral); } .c3 { background: var(--mint); } .c4 { background: #FFFFFF; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 28px; padding-bottom: 80px; }
.card { display: flex; flex-direction: column; background: #FFFFFF; border: var(--edge); border-radius: 20px; overflow: hidden; text-decoration: none; box-shadow: 6px 6px 0 var(--night); transition: transform .12s, box-shadow .12s; }
.card:hover, .card:focus-visible { transform: translate(-2px, -2px); box-shadow: 9px 9px 0 var(--night); }
.card .shot { background: var(--night); border-bottom: var(--edge); }
.card .meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px 17px; }
.card h3 { margin: 0; font: 700 18px/1.25 var(--body); }
.tag { border: var(--edge); border-radius: 999px; padding: 3px 11px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.state { text-align: center; padding: 0 0 60px; margin: 0; }
.state:empty { display: none; }
.how { padding-bottom: 80px; display: flex; flex-direction: column; gap: 28px; }
.how h2 { margin: 0; font: 800 clamp(32px, 4vw, 46px)/1.05 var(--display); letter-spacing: -0.02em; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
.step { border: var(--edge); border-radius: 20px; padding: 26px; display: flex; flex-direction: column; gap: 8px; }
.step b { font: 800 44px/1 var(--display); }
.step h3 { margin: 0; font: 800 24px/1.1 var(--display); }
.step p { margin: 0; font-size: 16px; }
.foot { border-top: var(--edge); padding: 22px 0; font-size: 15px; font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .btn, .card, .chip { transition: none; } }

/* ---------- Editor ---------- */
body.editor { height: 100vh; display: flex; flex-direction: column; font-size: 14px; }
body.editor main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 380px; }
.left { padding: 20px 20px 16px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.stage-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
#stage { position: relative; border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
  background-color: #20242E;
  background-image: linear-gradient(45deg, #2B303C 25%, transparent 25%, transparent 75%, #2B303C 75%), linear-gradient(45deg, #2B303C 25%, transparent 25%, transparent 75%, #2B303C 75%);
  background-size: 24px 24px; background-position: 0 0, 12px 12px; }
#stage.opaque { background: #000; }
#preview { display: block; width: 100%; height: 100%; }
#loadMsg { display: none; color: var(--muted); max-width: 46ch; text-align: center; }
body.failed #stage, body.failed .timeline, body.failed aside > * { display: none; }
body.failed #loadMsg { display: block; }
body:not(.ready):not(.failed) .timeline, body:not(.ready):not(.failed) aside { visibility: hidden; }
.timeline { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.tl-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tl-bar button { padding: 5px 10px; font-size: 12.5px; }
.tl-bar .play { min-width: 68px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; margin-left: 8px; }
.check input { accent-color: var(--accent); }
#time { margin-left: auto; font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; white-space: pre; }
.tl-track { position: relative; height: 70px; margin: 0 6px; user-select: none; touch-action: none; }
.tl-scrub { position: absolute; inset: 0 0 auto 0; height: 26px; cursor: pointer; border-bottom: 1px solid var(--line); }
#tlRuler { display: block; width: 100%; height: 26px; }
.tl-phases { position: absolute; left: 0; right: 0; top: 32px; height: 34px; }
.seg { position: absolute; top: 0; height: 100%; background: color-mix(in srgb, var(--c) 26%, #151821); border: 1px solid var(--c); border-radius: 4px; overflow: hidden; }
.seg + .seg { border-left-width: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.seg-name { position: absolute; left: 8px; right: 12px; top: 0; line-height: 32px; font-size: 12px; font-weight: 600; white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.handle { position: absolute; right: 0; top: 0; width: 11px; height: 100%; cursor: ew-resize; background: var(--c); opacity: .9; }
.handle::after { content: ""; position: absolute; left: 4px; top: 9px; bottom: 9px; width: 3px; border-left: 1px solid #17100B; border-right: 1px solid #17100B; }
.handle:hover { opacity: 1; filter: brightness(1.2); }
.tl-end { position: absolute; top: 26px; bottom: 0; width: 0; border-left: 1px dashed #6B7684; pointer-events: none; }
.tl-head { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px solid #fff; pointer-events: none; z-index: 3; }
.tl-head::before { content: ""; position: absolute; left: -7px; top: 0; border: 6px solid transparent; border-top: 8px solid #fff; }
.tl-fields-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.tl-fields { display: flex; gap: 10px; flex-wrap: wrap; flex: 1; }
.tl-field label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11.5px; margin-bottom: 3px; }
.tl-field label i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.tl-field input { width: 84px; padding: 5px 7px; }
.tl-field.total output { display: block; padding: 6px 0; font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
#resetTiming { padding: 5px 10px; font-size: 12.5px; }
body.dragging, body.dragging * { cursor: ew-resize !important; }
body.busy .timeline { opacity: .5; pointer-events: none; }
aside { border-left: 1px solid var(--line); background: var(--panel); overflow-y: auto; padding: 4px 18px 24px; }
aside section { padding: 16px 0; border-bottom: 1px solid var(--line); }
aside section:last-child { border-bottom: 0; }
aside h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
#fields { display: flex; flex-direction: column; gap: 10px; }
.field { display: grid; grid-template-columns: 118px minmax(0, 1fr); align-items: center; gap: 10px; }
.field label { color: var(--muted); font-size: 13px; }
.field-table { grid-template-columns: 1fr; }
.field-color { grid-template-columns: 118px 44px 1fr; }
.hex { font-family: var(--mono); font-size: 12px; color: var(--muted); }
input[type=text], input[type=number], select, textarea { width: 100%; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; }
textarea { font: 12px/1.5 var(--mono); resize: vertical; white-space: pre; overflow-x: auto; }
input[type=color] { width: 44px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
.formats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.formats button { text-align: left; padding: 9px 10px; }
.formats button b { display: block; font-weight: 600; font-size: 13px; }
.formats button span { display: block; color: var(--muted); font-size: 11.5px; }
.formats button[aria-pressed=true] { border-color: var(--accent); background: #1A2040; box-shadow: inset 0 0 0 1px var(--accent); }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.settings label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.settings [hidden] { display: none; }
.settings.three { margin: 0; }
.settings.three > :first-child { grid-column: 1 / -1; }
.primary { width: 100%; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; padding: 10px 12px; margin-top: 10px; }
.primary:hover { border-color: #AAB8FF; }
.progress { height: 4px; background: var(--bg); border-radius: 2px; margin: 14px 0 8px; overflow: hidden; }
#bar { height: 100%; width: 0; background: var(--ok); }
.statusline { display: flex; align-items: center; gap: 10px; min-height: 30px; }
#status { color: var(--muted); font-size: 12px; flex: 1; overflow-wrap: anywhere; }
#cancel { display: none; padding: 4px 10px; }
body.busy #cancel { display: inline-block; }
body.busy .primary, body.busy .formats button { opacity: .45; pointer-events: none; }
#log { margin: 10px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
#log li { font-family: var(--mono); font-size: 11.5px; background: var(--bg); border: 1px solid var(--line); border-left: 3px solid var(--ok); border-radius: 4px; padding: 6px 8px; overflow-wrap: anywhere; }
@media (max-width: 900px) {
  body.editor { height: auto; }
  body.editor main { grid-template-columns: 1fr; }
  aside { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
}
