@font-face { font-family: "FS Display"; src: url(../fonts/bigshoulders.ttf) format("truetype"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "FS Text"; src: url(../fonts/archivo.ttf) format("truetype"); font-weight: 100 900; font-display: swap; }

:root {
  --ink: #0C0D0B; --raised: #171815; --raised2: #22231F; --bone: #F4F1EA; --muted: rgba(244,241,234,.6);
  --hair: rgba(244,241,234,.12); --volt: #C6F432; --on-accent: #14140F; --accent: var(--volt);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ink); color: var(--bone); font: 400 17px/1.5 "FS Text", system-ui, sans-serif; min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--volt); text-underline-offset: 3px; }
[hidden] { display: none !important; }

.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: max(14px, env(safe-area-inset-top)) 20px 8px; max-width: 1180px; margin: 0 auto; }
.brand { color: var(--bone); text-decoration: none; font-weight: 800; letter-spacing: .3em; font-size: 15px; }
.bar-note { color: var(--muted); font-size: 13px; text-align: right; }

.screen { max-width: 1180px; margin: 0 auto; padding: 0 20px max(24px, env(safe-area-inset-bottom)); }
#import { max-width: 680px; }
.kicker { color: var(--muted); font-weight: 700; letter-spacing: .22em; font-size: 13px; margin: 28px 0 14px; }
h1 { font: 800 clamp(64px, 17vw, 120px)/.9 "FS Display", Impact, sans-serif; margin: 0 0 20px; letter-spacing: -.01em; }
h1 em { font-style: normal; color: var(--volt); }
.lead { color: var(--muted); font-size: 19px; margin: 0 0 28px; }
.steps { list-style: none; padding: 0; margin: 0 0 28px; counter-reset: s; border-bottom: 1px solid var(--hair); }
.steps li { counter-increment: s; display: grid; grid-template-columns: 52px 1fr; grid-template-rows: auto auto; padding: 14px 0; border-top: 1px solid var(--hair); }
.steps li::before { content: "0" counter(s); font: 800 30px/1 "FS Display", sans-serif; color: var(--volt); grid-row: span 2; }
.steps b { font-size: 13px; letter-spacing: .18em; text-transform: uppercase; }
.steps span { color: var(--muted); }
.error { background: rgba(255,61,90,.13); color: #FF8A80; border-radius: 14px; padding: 14px; white-space: pre-line; }
#sources { margin-bottom: 18px; position: relative; }
.demo { display: block; width: 100%; min-height: 48px; margin-top: 6px; font-weight: 700; }
.hint { color: var(--muted); font-size: 15px; text-align: center; margin: 12px 0 0; }
.hint.small { font-size: 14px; }

.big { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 60px; border-radius: 18px; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 18px; transition: transform .16s cubic-bezier(.2,.8,.2,1), opacity .2s; }
.big:active, .ghost:active, .chip:active, .tile:active { transform: scale(.97); }
.big[aria-busy="true"] { opacity: .6; pointer-events: none; }
.ghost { min-height: 60px; border-radius: 18px; background: var(--raised2); font-weight: 700; font-size: 18px; transition: transform .16s; }
.text { min-height: 44px; padding: 0 10px; font-weight: 700; }

/* editor */
.ed-top { display: flex; margin: 0 -10px; }
.ed-grid { display: grid; gap: 12px; }
.ed-grid > * { min-width: 0; }
.ed-preview { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.stage { position: relative; width: min(100%, calc((100dvh - 390px) * 9 / 16), 420px); min-width: 240px; aspect-ratio: 9 / 16; border-radius: 22px; overflow: hidden; background: var(--raised) center / cover no-repeat; }
.stage.feed { aspect-ratio: 4 / 5; width: min(100%, calc((100dvh - 390px) * 4 / 5), 470px); }
.stage.checker { background-color: #2A2B27; background-image: conic-gradient(#353631 25%, transparent 0 50%, #353631 0 75%, transparent 0); background-size: 24px 24px; }
.stage.checker.light { background-color: #E9E6DE; background-image: conic-gradient(#D9D5CB 25%, transparent 0 50%, #D9D5CB 0 75%, transparent 0); }
.stage.photo { background-size: cover; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.stage.sticker canvas { inset: 18px; width: calc(100% - 36px); height: calc(100% - 36px); }
.stage .busy { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }

.tabs { display: flex; justify-content: center; max-width: 100%; }
.tabs button { flex: none; display: flex; flex-direction: column; align-items: center; gap: 5px; min-height: 44px; padding: 6px 14px; font-size: 13px; font-weight: 700; letter-spacing: .18em; color: rgba(244,241,234,.45); transition: color .2s; }
.tabs.small { justify-content: flex-start; overflow-x: auto; scrollbar-width: none; margin: 0 -20px; padding: 0 14px; }
.tabs.small::-webkit-scrollbar { display: none; }
.tabs.small button { padding: 6px 7px; font-size: 12px; min-height: 36px; letter-spacing: .12em; }
@media (max-width: 420px) { .tabs:not(.small) button { padding: 6px 9px; letter-spacing: .12em; } }
.tabs button::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.tabs button[aria-selected="true"] { color: var(--bone); }
.tabs button[aria-selected="true"]::after { background: var(--accent); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 20px; margin: 0 -20px; scrollbar-width: none; overscroll-behavior-x: contain; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 999px; background: var(--raised2); font-size: 16px; font-weight: 600; white-space: nowrap; transition: background-color .2s, color .2s, transform .16s; }
.chip[aria-pressed="true"] { background: var(--chip, var(--accent)); color: var(--on-accent); }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(244,241,234,.45); }
.chip .badge { width: 20px; height: 20px; border-radius: 50%; background: var(--on-accent); color: var(--chip, var(--accent)); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.chip .x { margin-right: -8px; padding: 0 6px; opacity: .6; }
.chips .note { flex: none; align-self: center; color: var(--muted); font-size: 14px; white-space: nowrap; }

.tools { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-top: 14px; }
.tile { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; text-align: left; min-height: 64px; padding: 10px 0 10px 14px; border-radius: 16px; background: var(--raised); box-shadow: inset 0 0 0 1px var(--hair); transition: transform .16s; }
.tile b { font-size: 12px; letter-spacing: .18em; color: var(--muted); }
.tile.on b { color: var(--bone); }
.tile span { grid-column: 1; font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile i { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-style: normal; font-size: 26px; color: var(--muted); width: 44px; text-align: center; }
.actions { display: grid; grid-template-columns: minmax(0, .38fr) minmax(0, .62fr); gap: 10px; margin-top: 12px; }

dialog { background: var(--raised); color: var(--bone); border: 0; border-radius: 22px; padding: 22px; width: min(92vw, 380px); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog label { display: block; font-weight: 700; margin-bottom: 10px; }
dialog input { width: 100%; min-height: 48px; border-radius: 12px; border: 1px solid var(--hair); background: var(--ink); color: var(--bone); font: inherit; font-size: 17px; padding: 0 14px; }
dialog menu { display: flex; gap: 10px; justify-content: flex-end; padding: 0; margin: 18px 0 0; }
dialog .big { width: auto; min-height: 48px; padding: 0 22px; font-size: 16px; }

.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--bone); color: var(--on-accent); padding: 12px 18px; border-radius: 14px; font-weight: 600; max-width: calc(100vw - 32px); box-shadow: 0 10px 30px rgba(0,0,0,.35); z-index: 10; }
body.dragging::after { content: ""; position: fixed; inset: 12px; border: 3px dashed var(--volt); border-radius: 24px; pointer-events: none; }

@media (min-width: 900px) {
  .ed-grid { grid-template-columns: minmax(0, 1fr) 440px; align-items: start; gap: 40px; }
  .ed-preview { position: sticky; top: 12px; }
  .stage { width: min(100%, calc((100dvh - 160px) * 9 / 16)); }
  .stage.feed { width: min(100%, calc((100dvh - 160px) * 4 / 5)); }
  .ed-controls { padding-top: 24px; }
  .tabs.small { margin: 0 -7px; padding: 0; overflow: visible; }
  .chips { flex-wrap: wrap; overflow: visible; margin: 0; padding: 4px 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
