@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-display: swap; src: url(../fonts/atkinson-400.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-display: swap; src: url(../fonts/atkinson-700.woff2) format("woff2"); }

:root {
  --bg: #f3f0e8;
  --panel: #ffffff;
  --panel-2: #faf8f3;
  --ink: #1b1a17;
  --muted: #625c51;
  --line: #e4dfd3;
  --accent: #f2c230;
  --accent-soft: #fbefc4;
  --accent-ink: #1b1a17;
  --blue: #1d4ed8;
  --ok: #18794e;
  --warn: #b45309;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(27, 26, 23, .05), 0 8px 28px rgba(27, 26, 23, .07);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --top-h: 68px;
  font-family: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14130f; --panel: #1e1c17; --panel-2: #24221c; --ink: #f3efe4; --muted: #b3ac9c; --line: #34312a;
    --shadow: none; --blue: #93b4ff; --accent-soft: #3d331a;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 16px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; z-index: 50; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
button { -webkit-tap-highlight-color: transparent; }

/* ---------- top bar ---------- */
.top { height: var(--top-h); display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 0 22px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; gap: 12px; align-items: center; }
.logo { width: 38px; height: 38px; }
.logo rect { fill: var(--ink); }
.logo circle { fill: var(--accent); }
h1 { font-size: 1.3rem; margin: 0; letter-spacing: -.01em; line-height: 1.1; }
.tag { margin: 0; color: var(--muted); font-size: .86rem; }
.topright { display: flex; align-items: center; gap: 10px; }
.privacy { display: flex; align-items: center; gap: 8px; margin: 0; padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2); font-size: .85rem; }
.privacy svg { width: 16px; height: 16px; fill: var(--ok); }
.gh { font-size: .85rem; color: var(--ink); text-decoration: none; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); }
.gh:hover { background: var(--panel-2); }

/* ---------- app shell: fills the viewport ---------- */
.app { display: grid; grid-template-columns: 300px minmax(0, 1fr) 360px; gap: 16px; padding: 16px; height: calc(100dvh - var(--top-h)); }
.rail { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; min-height: 0; padding-right: 2px; scrollbar-width: thin; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.rail.right #side { display: flex; flex-direction: column; gap: 12px; }
.rail.right #side[hidden] { display: none; }

.ph { font-size: 1rem; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.ph .num { width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: var(--panel); font-size: .75rem; display: inline-grid; place-items: center; }
.sub { font-size: .9rem; margin: 0 0 10px; }
.hint { color: var(--muted); font-size: .86rem; margin: 8px 0 0; }
.hint.small { font-size: .8rem; }

/* ---------- input rail ---------- */
.drop { display: flex; gap: 12px; align-items: center; padding: 16px; border: 2px dashed var(--line); border-radius: 12px; cursor: pointer; transition: border-color .2s var(--ease), background .2s var(--ease); }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop svg { width: 28px; height: 28px; flex: none; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.drop span { font-size: .92rem; line-height: 1.35; }
.drop small { color: var(--muted); }
.samples { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sample { border: 1px solid var(--line); border-radius: 12px; padding: 5px 5px 6px; background: #fff; cursor: pointer; display: flex; flex-direction: column; gap: 3px; font: inherit; font-size: .72rem; line-height: 1.2; color: #333; text-align: center; transition: transform .15s var(--ease), border-color .15s, box-shadow .15s; }
.sample img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.sample:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.sample[aria-pressed="true"] { border: 2px solid var(--ink); }
.opts summary { cursor: pointer; font-weight: 700; font-size: .95rem; }
.opts label { display: flex; flex-direction: column; gap: 4px; font-size: .86rem; margin-top: 10px; color: var(--muted); }
.opts label.check, .check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
select, input[type="text"] { font: inherit; font-size: .9rem; padding: 7px 9px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); width: 100%; }

/* ---------- stage ---------- */
.stage { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.stagebar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 14px 0; border-bottom: 1px solid var(--line); min-height: 50px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tabs button { font: inherit; font-size: .9rem; background: none; border: 0; padding: 10px 12px; border-bottom: 3px solid transparent; color: var(--muted); cursor: pointer; white-space: nowrap; transition: color .15s, border-color .2s var(--ease); }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 700; }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; margin-bottom: 6px; }
.seg button { font: inherit; font-size: .82rem; border: 0; background: none; padding: 5px 12px; border-radius: 999px; cursor: pointer; color: var(--muted); transition: background .2s var(--ease), color .2s; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--panel); }

.canvasarea { position: relative; flex: 1; min-height: 0; background:
  radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--ink) 9%, transparent) 1px, transparent 0) 0 0 / 18px 18px, var(--panel-2); }
.views, .view { height: 100%; }
.view { padding: 18px; display: flex; justify-content: center; align-items: center; animation: fadein .35s var(--ease); }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.paper { background: #fff; border-radius: 4px; box-shadow: 0 0 0 1px #dcd6c7, 0 14px 36px rgba(0,0,0,.12); overflow: hidden; }
.paper.fit { height: 100%; max-width: 100%; aspect-ratio: auto; display: flex; }
.paper.fit svg, .paper.fit img { height: 100%; width: auto; max-width: 100%; display: block; }
.paper.fit p { padding: 24px; color: #555; }
.fitbox { height: 100%; display: flex; justify-content: center; align-items: center; }
.fitbox canvas { max-height: 100%; max-width: 100%; border-radius: 6px; box-shadow: 0 0 0 1px #dcd6c7, 0 14px 36px rgba(0,0,0,.12); background: #fff; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; height: 100%; width: 100%; }
.compare figure { margin: 0; display: flex; flex-direction: column; min-height: 0; align-items: center; }
.compare figcaption { font-size: .85rem; font-weight: 700; margin-bottom: 8px; }
.compare .paper.fit { flex: 1; min-height: 0; height: auto; }

.status { margin: 0; padding: 10px 16px; font-size: .9rem; border-top: 1px solid var(--line); background: var(--panel); }
.status.error { color: #b91c1c; }

/* 3D relief */
.view.relief { padding: 0; position: relative; flex-direction: column; align-items: stretch; }
.relief-stage { flex: 1; min-height: 0; background: #2a2823; cursor: grab; }
.relief-stage canvas { display: block; width: 100%; height: 100%; }
.relief-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: #1f1d19; color: #e9e3d4; flex-wrap: wrap; }
.relief-note { font-size: .82rem; flex: 1; min-width: 200px; color: #cfc7b4; }
.btn.small { font-size: .82rem; padding: 7px 12px; }

/* empty state */
.empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px; max-width: 640px; margin: 0 auto; animation: fadein .4s var(--ease); }
.empty h2 { font-size: 1.7rem; letter-spacing: -.015em; margin: 18px 0 8px; line-height: 1.2; }
.empty p { color: var(--muted); margin: 0 0 18px; }
.hero-dots { display: grid; grid-template-columns: repeat(2, 22px); gap: 12px 18px; padding: 18px 22px; background: var(--ink); border-radius: 18px; }
.hero-dots i { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); }
.hero-dots i:nth-child(2), .hero-dots i:nth-child(5) { opacity: .2; }

/* loading overlay */
.loading { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--panel-2) 72%, transparent); backdrop-filter: blur(3px); animation: fadein .2s var(--ease); z-index: 5; }
.loadcard { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 26px 30px; width: min(380px, 90%); text-align: center; }
.spinner { display: inline-grid; grid-template-columns: repeat(2, 16px); gap: 9px 13px; padding: 14px 17px; border-radius: 14px; background: var(--ink); }
.spinner i { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); opacity: .18; animation: dot 1.5s ease-in-out infinite; }
/* braille dots 1-2-3 down the left, 4-5-6 down the right, lit in reading order */
.spinner i:nth-child(1) { animation-delay: 0s; }
.spinner i:nth-child(3) { animation-delay: .15s; }
.spinner i:nth-child(5) { animation-delay: .3s; }
.spinner i:nth-child(2) { animation-delay: .45s; }
.spinner i:nth-child(4) { animation-delay: .6s; }
.spinner i:nth-child(6) { animation-delay: .75s; }
@keyframes dot { 0%, 100% { opacity: .18; transform: scale(.85); } 35% { opacity: 1; transform: scale(1.05); } }
@media (prefers-reduced-motion: reduce) { .spinner i { animation-duration: 3s; } .view, .empty, .loading { animation: none; } }
.loadmsg { font-weight: 700; margin: 14px 0 10px; }
.loadsteps { list-style: none; padding: 0; margin: 0 auto; text-align: left; display: inline-flex; flex-direction: column; gap: 5px; font-size: .86rem; color: var(--muted); }
.loadsteps li { display: flex; align-items: center; gap: 8px; transition: color .2s; }
.loadsteps li::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); flex: none; transition: all .2s var(--ease); }
.loadsteps li.active { color: var(--ink); font-weight: 700; }
.loadsteps li.active::before { border-color: var(--accent); border-top-color: transparent; animation: spin .8s linear infinite; }
.loadsteps li.done { color: var(--ink); }
.loadsteps li.done::before { background: var(--ok); border-color: var(--ok); }
@keyframes spin { to { transform: rotate(360deg); } }
.elapsed { margin: 12px 0 0; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- right rail ---------- */
.how { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: .9rem; }
.how b { font-weight: 700; }
.labels { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; }
.labels li { display: grid; grid-template-columns: auto 1fr auto; gap: 3px 8px; align-items: center; padding: 7px 8px; border: 1px solid var(--line); border-radius: 12px; transition: border-color .15s, background .15s; }
.labels li.removed { opacity: .45; }
.labels .badge { width: 22px; height: 22px; border-radius: 50%; font-size: .72rem; font-weight: 700; color: #fff; display: grid; place-items: center; }
.labels input { padding: 4px 7px; font-size: .88rem; }
.labels .br { grid-column: 2 / -1; font-size: 1rem; letter-spacing: .04em; color: var(--muted); overflow-wrap: anywhere; line-height: 1.3; }
.labels .meta { grid-column: 2 / -1; font-size: .74rem; color: var(--muted); }
.labels .meta .fix { color: var(--ok); }
.labels .acts { display: flex; gap: 4px; }
.labels .x, .labels .m { font: inherit; font-size: .85rem; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 2px 8px; cursor: pointer; color: var(--muted); }
.labels .x:hover, .labels .m:hover { color: var(--ink); border-color: var(--ink); }
.labels li:hover, .labels li.hl { border-color: var(--accent); background: var(--accent-soft); }
.legend { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 8px; }
.legend li { display: flex; gap: 10px; align-items: center; font-size: .86rem; }
.legend svg { width: 34px; height: 34px; flex: none; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.rules { width: 100%; border-collapse: collapse; font-size: .8rem; }
.rules th { text-align: left; color: var(--muted); font-weight: 700; padding: 4px; border-bottom: 1px solid var(--line); }
.rules td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rules td.ok::before { content: "✓ "; color: var(--ok); font-weight: 700; }
.rules td.warn::before { content: "! "; color: var(--warn); font-weight: 700; }
.rules td.base { color: var(--muted); }
.exports { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { font: inherit; font-size: .9rem; padding: 9px 14px; border-radius: 11px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; transition: transform .12s var(--ease), filter .15s, box-shadow .15s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,.08); }
.btn:active { transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.btn.big { font-size: 1rem; padding: 12px 20px; border-radius: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- smaller screens: stack and scroll normally ---------- */
@media (max-width: 1180px) {
  .app { grid-template-columns: 280px minmax(0, 1fr); height: auto; min-height: calc(100dvh - var(--top-h)); }
  .rail.right { grid-column: 1 / -1; overflow: visible; }
  .stage { height: calc(100dvh - var(--top-h) - 32px); min-height: 520px; }
  .rail.left { overflow: visible; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; padding: 12px 16px; }
  .top { height: auto; padding: 10px 16px; flex-wrap: wrap; }
  .privacy { font-size: .78rem; }
  .compare { grid-template-columns: 1fr; height: auto; }
  .view { height: auto; }
  .stage { height: auto; min-height: 70vh; }
  .paper.fit { height: auto; }
  .paper.fit svg { width: 100%; height: auto; }
}
