/* Emulsion — Swiss / International Typographic Style.
   Paper and ink, one accent, heavy rules. No radii, shadows or gradients. */

:root {
  --bg: #ecebe7;
  --ink: #0e0e0e;
  --mute: #5f5f5b;
  --rule: #0e0e0e;
  --acc: oklch(0.57 0.2 32);
  --on-acc: #ffffff;

  --gutter: clamp(20px, 4vw, 48px);
  --panel-w: 440px;
  --font: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e0e0e;
  --ink: #ecebe7;
  --mute: #8d8d88;
  --rule: #ecebe7;
  --acc: oklch(0.7 0.19 32);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; border-radius: 0; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
[hidden] { display: none !important; }
.acc { color: var(--acc); }

/* ───────────────────────────── type */
.label { font-size: 14px; font-weight: 700; text-transform: uppercase; }
.meta { font-size: 13px; font-weight: 600; text-transform: uppercase; color: var(--mute); }
.lead { margin: 0; font-weight: 500; line-height: 1.15; letter-spacing: -0.015em; font-size: clamp(22px, 2.3vw, 32px); text-wrap: pretty; }
.display-xl, .display-l {
  margin: 0; font-weight: 900; font-stretch: 72%; text-transform: uppercase;
}
.display-xl { font-size: clamp(84px, 20.5vw, 292px); line-height: 0.8; letter-spacing: -0.03em; }
.display-l { font-size: clamp(60px, 8.4vw, 150px); line-height: 0.82; letter-spacing: -0.03em; overflow-wrap: anywhere; }
.row-labels { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }

/* ───────────────────────────── controls */
.link {
  border: 0; padding: 6px 0; background: none;
  font-size: 14px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase;
  transition: opacity .15s;
}
.link:hover { opacity: .75; }
.block {
  border: 0; padding: 12px 16px; min-height: 44px;
  font-size: 14px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase;
  white-space: nowrap; transition: opacity .15s;
}
.block:hover { opacity: .85; }
.block.ink { background: var(--ink); color: var(--bg); }
.block.acc { background: var(--acc); color: var(--on-acc); letter-spacing: 0.06em; }
.block.lg { padding: 18px 26px; font-size: 16px; font-weight: 800; letter-spacing: 0.04em; }
.block:disabled { opacity: .35; pointer-events: none; }

/* ───────────────────────────── shell */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.nav {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px;
  padding: 18px var(--gutter);
}
.wordmark {
  font-size: 44px; font-weight: 900; font-stretch: 72%; line-height: 0.9;
  letter-spacing: -0.02em; text-transform: uppercase;
}
.nav-meta { flex: 1 1 200px; font-size: 13px; font-weight: 600; text-transform: uppercase; color: var(--mute); }
.nav-links { display: flex; align-items: center; gap: 12px 28px; flex-wrap: wrap; }

.app[data-state="empty"] .workspace,
.app[data-state="empty"] .hide-empty { display: none !important; }
.app:not([data-state="empty"]) .landing { display: none; }
.mobile-only { display: none !important; }
.short { display: none; }

/* ───────────────────────────── landing */
.band { border-top: 2px solid var(--rule); padding: clamp(28px, 4vw, 40px) var(--gutter); }
.hero { display: flex; flex-direction: column; gap: 20px; }
.chip {
  display: inline-flex; align-items: center; gap: 10px; padding: 7px 12px;
  background: var(--acc); color: var(--on-acc);
  font-size: 14px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--on-acc); }
.dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 1.5px solid var(--on-acc); animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse { from { transform: scale(.6); opacity: 1; } to { transform: scale(1.8); opacity: 0; } }

.split-row { display: flex; flex-wrap: wrap; gap: 24px 48px; }
.split-row > .label { flex: 1 1 200px; }
.split-content { flex: 3 1 560px; display: flex; flex-direction: column; gap: 24px; }
.split-content .lead { max-width: 880px; font-size: clamp(24px, 3vw, 38px); }
.cta-row { display: flex; align-items: center; gap: 16px 28px; flex-wrap: wrap; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 32px; }
.feature { border-top: 1px solid var(--rule); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.numeral { font-size: clamp(72px, 6.5vw, 88px); font-weight: 900; font-stretch: 72%; line-height: 0.9; color: var(--acc); }
.f-title { font-size: 22px; font-weight: 700; }
.f-text { color: var(--mute); }
.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px;
  padding: 18px var(--gutter); border-top: 1px solid var(--rule);
  font-size: 13px; font-weight: 600; text-transform: uppercase; color: var(--mute);
}

/* reveal on scroll (content visible at load is never hidden) */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .8s cubic-bezier(.2,.7,.2,1), transform .8s cubic-bezier(.2,.7,.2,1); }
.reveal.in { opacity: 1; transform: none; }

/* ───────────────────────────── editor: desktop = fixed-height two columns */
.workspace {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-w);
  border-top: 2px solid var(--rule);
}
@media (min-width: 961px) {
  .app:not([data-state="empty"]) { height: 100dvh; }
  .app:not([data-state="empty"]) .workspace { overflow: hidden; }
  .main, .panel { min-height: 0; overflow-y: auto; }
}
.main {
  display: flex; flex-direction: column; gap: 16px;
  padding: 28px var(--gutter) 28px;
}
.stock-note { margin-bottom: 4px; }
@media (max-height: 1000px) and (min-width: 961px) {
  .stock-note { display: none; }
  .display-l { font-size: clamp(56px, 6.2vw, 110px); }
}

.viewer {
  position: relative; flex: 1 1 0; min-height: 320px;
  display: grid; place-items: center; overflow: hidden;
}
.viewer.zoomed { place-items: start; overflow: auto; cursor: grab; outline: 1px solid var(--rule); }
.viewer.zoomed.dragging { cursor: grabbing; }
.viewer.zoomed .canvas-wrap { margin: auto; }
.canvas-wrap { position: relative; line-height: 0; }
#view { display: block; background: var(--ink); }

.split { position: absolute; inset: 0; touch-action: none; cursor: ew-resize; }
.split-line { position: absolute; top: 0; bottom: 0; left: var(--x, 50%); width: 2px; margin-left: -1px; background: #ecebe7; }
.split-knob {
  position: absolute; top: 50%; left: var(--x, 50%);
  width: 38px; height: 38px; margin: -19px 0 0 -19px;
  display: grid; place-items: center; background: #ecebe7; color: #0e0e0e;
  font-size: 16px; font-weight: 900; line-height: 1;
}
.tag {
  position: absolute; top: 16px; padding: 7px 10px; line-height: 1;
  font-size: 13px; font-weight: 700; text-transform: uppercase;
}
.tag.left { left: 16px; background: #0e0e0e; color: #ecebe7; }
.tag.right { right: 16px; background: #ecebe7; color: #0e0e0e; }

.busy {
  position: absolute; inset: 0; z-index: 3;
  display: grid; place-content: center; justify-items: center; gap: 14px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}
.bar { position: relative; width: 160px; height: 2px; background: color-mix(in srgb, var(--ink) 20%, transparent); overflow: hidden; }
.bar::after { content: ""; position: absolute; top: 0; bottom: 0; width: 40%; background: var(--acc); animation: slide 1s cubic-bezier(.4,0,.2,1) infinite; }
@keyframes slide { from { left: -40%; } to { left: 100%; } }

.tools {
  display: flex; align-items: stretch; flex-wrap: wrap;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.tool {
  border: 0; border-right: 1px solid var(--rule); padding: 14px 20px; min-height: 46px;
  background: transparent; font-size: 14px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase;
  transition: background .25s, color .25s;
}
.tool:hover { background: var(--acc); color: var(--on-acc); }
.tool[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.tools-hint { flex: 1; align-self: center; text-align: right; padding: 8px 0 8px 16px; }

.roll { display: flex; flex-direction: column; gap: 12px; }
.sheet { display: flex; gap: 16px; align-items: flex-end; overflow-x: auto; padding: 4px 4px 2px; scrollbar-width: thin; }
.thumb {
  position: relative; flex: none; border: 0; padding: 0; background: none;
  display: flex; flex-direction: column; gap: 6px; text-align: left;
}
.thumb canvas { display: block; height: 72px; width: auto; }
.thumb[aria-current="true"] canvas { outline: 3px solid var(--acc); outline-offset: 3px; }
.thumb .num { font-size: 28px; font-weight: 900; font-stretch: 72%; line-height: 0.9; }
.thumb[aria-current="true"] .num { color: var(--acc); }
.thumb .x {
  position: absolute; top: 0; right: 0; width: 22px; height: 22px;
  display: none; place-items: center; background: var(--ink); color: var(--bg);
  font-size: 14px; font-weight: 700; line-height: 1;
}
.thumb:hover .x, .thumb:focus-visible .x { display: grid; }
.thumb.loading .ph { width: 96px; height: 72px; background: color-mix(in srgb, var(--ink) 12%, transparent); animation: blink 1s ease-in-out infinite alternate; }
@keyframes blink { to { opacity: .4; } }
.add-thumb {
  flex: none; width: 72px; height: 72px; margin-bottom: 31px;
  border: 1px solid var(--rule); background: transparent;
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  transition: background .25s, color .25s;
}
.add-thumb:hover { background: var(--acc); color: var(--on-acc); border-color: var(--acc); }

/* ───────────────────────────── panel */
.panel { border-left: 2px solid var(--rule); scrollbar-width: thin; }
.p-sec { padding: 22px 32px 22px; border-top: 2px solid var(--rule); }
.panel > .p-sec:first-child { border-top: 0; padding-top: 28px; }
.p-sec > .row-labels { margin-bottom: 14px; }
.sec-label { margin-bottom: 12px; }

.stocks { display: flex; flex-direction: column; border-top: 1px solid var(--rule); }
.stock {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 9px 10px; min-height: 48px; border: 0; border-bottom: 1px solid var(--rule);
  background: transparent; text-align: left;
  transition: background .25s, color .25s;
}
.stock .name { font-size: 30px; font-weight: 800; font-stretch: 80%; line-height: 1; text-transform: uppercase; }
.stock .maker { font-size: 13px; font-weight: 700; text-transform: uppercase; }
.stock:hover, .stock[aria-checked="true"] { background: var(--acc); color: var(--on-acc); }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 28px; }
.slider { display: flex; flex-direction: column; gap: 2px; }
.slider .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.slider label { font-size: 13px; font-weight: 600; text-transform: uppercase; cursor: pointer; }
.slider output { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.slider output.changed { color: var(--acc); }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 0;
  background: transparent; color: var(--ink); cursor: pointer; touch-action: pan-y;
}
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: currentColor; }
input[type="range"]::-moz-range-track { height: 2px; background: currentColor; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; margin-top: -6px;
  background: currentColor; border: 0; border-radius: 0;
}
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; background: currentColor; border: 0; border-radius: 0; }
input[type="range"]:hover { color: var(--acc); }
input[type="range"]:focus-visible { outline-offset: 4px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.seg { display: flex; border: 1px solid var(--rule); }
.seg button {
  flex: 1 1 0; min-height: 40px; padding: 10px 6px; border: 0; border-left: 1px solid var(--rule);
  background: transparent; font-size: 13px; font-weight: 700; text-transform: uppercase;
  transition: background .25s, color .25s;
}
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--acc); color: var(--on-acc); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.out-meta { padding-top: 6px; }
.reset { margin-top: 18px; color: var(--mute); font-size: 13px; }

/* ───────────────────────────── overlays */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 30;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  max-width: min(92vw, 520px); padding: 12px 16px;
  background: var(--ink); color: var(--bg);
  font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--acc); color: var(--on-acc); }

.drop-veil {
  position: fixed; inset: 0; z-index: 40; pointer-events: none;
  display: grid; place-items: center;
  background: var(--bg); outline: 2px solid var(--rule); outline-offset: -12px;
  opacity: 0; transition: opacity .15s;
}
.drop-veil span { font-size: clamp(96px, 24vw, 320px); font-weight: 900; font-stretch: 72%; line-height: .8; text-transform: uppercase; letter-spacing: -0.03em; }
.drop-veil.show { opacity: 1; }

.develop-bar {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; height: 64px; padding: 0 20px; border: 0;
  background: var(--acc); color: var(--on-acc);
  font-size: 16px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
}
.develop-bar span:last-child { font-size: 22px; }
.develop-bar:disabled { opacity: .5; }

/* ───────────────────────────── narrow: one tall sheet */
@media (max-width: 960px) {
  :root { --panel-w: 100%; }
  .workspace { display: flex; flex-direction: column; }
  .panel { border-left: 0; }
  .panel > .p-sec:first-child { border-top: 2px solid var(--rule); padding-top: 18px; }
  .p-sec { padding: 18px var(--gutter) 20px; }
  .main { padding: 18px var(--gutter) 20px; gap: 12px; }
  .viewer { flex: none; min-height: 0; }
  .viewer.zoomed { height: 70vh; }
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }
  .nav-meta { display: none; }
  .nav { padding: 14px var(--gutter); }
  .wordmark { font-size: 34px; flex: 1; }
  .nav { flex-wrap: nowrap; gap: 12px; }
  .nav-links { gap: 8px; flex-wrap: nowrap; }
  .nav-links .link { border: 1px solid var(--rule); padding: 0 12px; min-height: 44px; }
  .nav-links .block { min-width: 44px; padding: 0 12px; }
  .long { display: none; }
  .short { display: inline; }
  .tools-hint { display: none; }
  .tool { flex: 1 1 0; }
  .tool:last-of-type { border-right: 0; }
  .stock .name { font-size: 26px; }
  .grid2 { gap: 8px 20px; }
  .thumb canvas { height: 60px; }
  .thumb .num { font-size: 22px; }
  .add-thumb { width: 60px; height: 60px; margin-bottom: 26px; }
  .chip { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}
