/* Plan2Scale web — mirrors the desktop app's shell and measured density
   (packages/desktop/renderer/styles.css). Same tokens, same control family,
   two-column workspace: controls left, full-height preview pane right.
   SKIN NOTE: the drafting-sheet motif (sketch 002) survives as the tick
   band + token block below; a variant swap re-skins tokens only. */

:root {
  --paper: #faf7f2;
  --ink: #22252a;
  --muted: #666d79; /* 4.88:1 on --paper; #6b7280 passed with zero margin (4.52) */
  --line: #e5e0d8;
  --line-strong: #6f6a61; /* control-boundary token: >=5:1 against card AND page */
  --accent: #b45309;
  --accent-dark: #92400e;
  --card: #ffffff;
  --canvas: #f2ede4; /* sheet-canvas tone: between paper and paper-card, both schemes */
  --ink-soft: #4b5563; /* helper text ON canvas: 6.48:1 (muted was 4.47 — reviewer-flagged) */
  --ok: #39652f;
  --err: #8c2f2f;
  color-scheme: light;
}

/* Same palette the desktop owner toggle uses (token remap only) */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #1b1a17;
    --card: #242320;
    --ink: #ece7de;
    --muted: #a49e92;
    --line: #34322c;
    --line-strong: #8f8879;
    --accent: #e07b39;
    --accent-dark: #d97f45; /* AA: 5.29:1 on --card; #c9682c measured 4.12:1 (fail) */
    --canvas: #201f1c;
    --ink-soft: #b3ada1; /* 7.38:1 on dark canvas */
    --err: #ef7070;
  }
  .primary, button.primary, a.primary { color: #14130f; }
  .drop { border-color: #4a473f; }
  .drop.dragover { background: #2a2823; }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* The trial JS toggles the `hidden` ATTRIBUTE on containers whose own rules
   set `display` (flex/grid). Author display beats the UA `[hidden]` rule, so
   without this every pane renders at once. Keep [hidden] authoritative. */
[hidden] { display: none !important; }

html { height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: var(--card); padding: 8px 12px; z-index: 5; }

/* ---------- slim header strip (desktop header: title + rule on one line) ---------- */
.appbar {
  display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap;
  padding: 8px 16px 6px; border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.appbar h1 { font-size: 17px; letter-spacing: 0.4px; }
.appbar .tagline { color: var(--muted); font-size: 12.5px; }
.appbar .printrule { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.appbar .printrule b { color: var(--ink); }
.appnav { display: flex; gap: 14px; font-size: 12.5px; }
.navline { padding: 6px 16px 1px; flex: 0 0 auto; } /* aux menu row inside the work area */

a { color: var(--ink); }
nav a, .appfoot a, .landingcopy a, .privacy a, .limits a, .nextsteps a, .prose a {
  text-decoration: none; border-bottom: 1px solid var(--line-strong);
}
a:hover { color: var(--accent-dark); }
:focus-visible { outline: 2px solid var(--accent-dark); outline-offset: 2px; }

/* the drafting motif carried from variant 002: ruler tick band */
.tickrule {
  height: 9px; border-bottom: 1px solid var(--line); flex: 0 0 auto;
  background: repeating-linear-gradient(90deg, var(--line-strong) 0 1px, transparent 1px 10px);
  background-size: 100% 4px; background-repeat: no-repeat; background-position: bottom;
  opacity: 0.6;
}

/* ---------- two-column workspace (desktop #work: fixed controls + 1fr pane) ---------- */
main { flex: 1 1 auto; min-height: 0; }
.shell {
  display: grid;
  grid-template-columns: 430px minmax(340px, 1fr);
  gap: 16px;
  padding: 8px 16px 10px;
  width: 100%;
  min-height: 100%;
  /* No max-width cap: the desktop #work fills the window at every size.
     A 1220px cap left ~110px dead gutters per side at 1440 and misaligned
     the shell against the full-bleed appbar/appfoot. */
}

/* left column: the trial, dense like the desktop leftcol */
.leftcol { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.drop {
  flex: 1;
  border: 2px dashed #c9c1b4; border-radius: 14px; background: var(--card);
  padding: 26px 20px 16px; text-align: center;
  /* space-evenly: at landing the content distributes through the whole zone,
     so airiness reads as rhythm, not as a hole above the fine print */
  display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; gap: 6px;
}
.drop.dragover { border-color: var(--accent); background: #fffdf9; }
/* Hero cluster stays centered; privacy/limits fine print anchors the box floor */
.drop .privacy { margin-top: auto; }
.drop .big { font-size: 21px; font-weight: 600; }
.muted { color: var(--muted); font-size: 13px; }
.filebtn span {
  display: inline-block; margin-top: 4px; padding: 8px 16px; border-radius: 9px;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
}
.filebtn span:hover { background: var(--accent-dark); }
.privacy { font-size: 13px; color: var(--ink-soft); margin-top: 8px; }
.limits { font-size: 12px; color: var(--ink-soft); }
.steps { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 16px 0 0; padding: 0; counter-reset: step; }
.steps li { counter-increment: step; font-size: 12.5px; color: var(--ink-soft); border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 12px; }
.steps li::before { content: counter(step); font-weight: 700; color: var(--accent-dark); margin-right: 6px; }

/* flex-grow so .actionrow's margin-top:auto actually pins the Make button
   to the column bottom (desktop actionrow behaviour); without it the button
   floats mid-column above a dead band */
#flow { display: flex; flex-direction: column; gap: 8px; min-height: 0; flex: 1 1 auto; }

.fileline { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-weight: 600; font-size: 14px; min-inline-size: 0; }
.fileline .name { display: inline-flex; min-inline-size: 0; overflow: hidden; }
.fileline .name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-inline-size: 0; }
.fileline .name span:last-child { flex: 0 0 auto; } /* the extension survives shrinking */

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 6px 11px; }
.panel ul { margin: 2px 0 2px 18px; font-size: 13.5px; }
.panel p { font-size: 13.5px; }

.scale-answer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
/* Confirmed scale must be visually loud, not just a copy change — suggestion
   vs applied is the one state users must never misread. */
#scaleAnswer.scale-confirmed { outline: 2px solid #58c27d; outline-offset: 4px; border-radius: 6px; }
.scale-answer label { font-weight: 600; font-size: 13.5px; }
.scale-answer input {
  font: inherit; font-size: 13.5px; padding: 5px 9px; width: 9ch;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--card); color: var(--ink);
}
button.act {
  border: 1px solid var(--line-strong); border-radius: 9px; background: var(--card);
  color: var(--accent-dark); font: inherit; font-size: 13px; padding: 6px 12px; cursor: pointer;
}
.note { font-size: 12px; color: var(--muted); }
.linkish {
  background: none; border: none; color: var(--accent-dark); text-decoration: underline;
  cursor: pointer; font: inherit; font-size: 13px; padding: 0; white-space: nowrap; flex: 0 0 auto;
}

.rowlabel { font-weight: 600; font-size: 13.5px; margin-bottom: 4px; }

/* option cards: the desktop .option family (radio, dense, ✓ on picked) */
.options { display: flex; flex-direction: column; gap: 6px; }
.option {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 11px;
  padding: 7px 11px; cursor: pointer; font-size: 13.5px;
}
.option:hover { border-color: var(--accent); }
.option:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.option .optwrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.option .optlabel { font-weight: 600; }
.option:has(input:checked) .optlabel::after { content: " ✓"; color: var(--accent-dark); }
.tag { font-size: 11px; color: var(--accent-dark); text-transform: uppercase; letter-spacing: 0.06em; }

.exactrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.exactrow label { font-size: 13.5px; font-weight: 600; }
.exactrow input {
  font: inherit; font-size: 13.5px; padding: 5px 9px; width: 10ch;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--card); color: var(--ink);
}
.exactrow .note { flex-basis: 100%; }
.fitnotes { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* controls: desktop-style panel, hairline furniture grid, no heavy padding */
.controls { background: var(--card); border: 1px solid var(--line-strong); border-radius: 11px; padding: 0 12px 4px; }
details.more summary { font-weight: 600; font-size: 13.5px; padding: 6px 0; cursor: pointer; color: var(--ink); }
.furniture { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.rowitem { display: flex; align-items: center; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.rowitem.fullspan { grid-column: 1 / -1; }
.furniture input[type="text"], .furniture select {
  font: inherit; font-size: 13px; padding: 4px 8px; max-width: 18ch;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--card); color: var(--ink);
}
.furniture input.grow { flex: 1; min-width: 0; max-width: none; }

.actionrow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: auto; }
button.primary, a.primary {
  border: none; border-radius: 9px; cursor: pointer; font: inherit; font-weight: 600;
  background: var(--accent); color: #fff; padding: 10px 18px; font-size: 14.5px; text-decoration: none;
  display: inline-block;
}
button.primary:hover, a.primary:hover { background: var(--accent-dark); color: #fff; }
button.primary:disabled { background: #d6cfc4; cursor: default; color: #4a463f; }
#make { flex: 1; }

.dlrow { margin-top: 6px; }
.receipt .done { color: var(--ok); font-weight: 700; font-size: 13.5px; }
.receipt ul { margin-top: 4px; }
.nextsteps { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.errorpanel { border-color: #e4b1b1; background: #fdf2f2; }
.errorpanel .err { color: var(--err); font-weight: 700; font-size: 13.5px; }

/* ---------- right pane: info cards at rest, export-true preview once loaded ---------- */
.rightpane { min-width: 0; min-height: 0; display: flex; }
/* ---------- right pane: the app's paper canvas in every state ----------
   Desktop keeps a full-height paper surface even with nothing loaded; the
   web rightpane mirrors it — landing cards sit ON the canvas, preview too,
   so empty space reads as canvas margin (app behaviour), not sloppiness. */
.landingcanvas, .previewwrap {
  flex: 1 1 auto; min-height: 0; width: 100%;
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--canvas); padding: 18px 20px;
}
.canvashead { font-size: 13px; color: var(--ink-soft); margin: 2px 2px 12px; }
/* The canvas shows the product's real outputs at rest: solid paper sheets —
   a single reprint and a tiled set — not dashed placeholders (owner pass v9) */
.samples { flex: 1 1 auto; min-height: 120px; display: flex; gap: 56px; align-items: center; justify-content: center; padding: 10px 0 18px; flex-wrap: wrap; }
@media (max-width: 640px) { .samples { display: none; } } /* the copy block carries phones alone */
.papersheet { width: 300px; background: #fbfaf7; color: #22252a; border-radius: 6px; padding: 14px 14px 10px; box-shadow: 0 3px 14px rgba(0,0,0,.22); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.papersheet .pageart { position: relative; }
.single .pageart { width: 268px; height: 342px; }
.artframe { position: absolute; inset: 18px 18px 50px; border: 1.5px solid #b9b2a6; border-radius: 2px; }
.proofline { position: absolute; left: 18px; right: 18px; bottom: 30px; height: 3px; background: #8a8378; border-radius: 2px; }
.proofline::before, .proofline::after { content: ""; position: absolute; top: -4px; width: 2px; height: 11px; background: #8a8378; }
.proofline::before { left: 0; } .proofline::after { right: 0; }
.grid4 { display: flex; flex-wrap: wrap; width: 252px; gap: 0; }
.grid4 i { width: 131px; height: 184px; border: 1.5px solid #b9b2a6; background: #fbfaf7; box-shadow: 0 1px 4px rgba(0,0,0,.14); }
.grid4 i:nth-child(2), .grid4 i:nth-child(4) { margin-left: -14px; } /* overlap = how tiling actually prints */
.grid4 i:nth-child(3), .grid4 i:nth-child(4) { margin-top: -14px; }
.slabel { font-size: 12.5px; color: #454c59; text-align: center; letter-spacing: .2px; }
/* One consolidated pitch block instead of three floating cards (owner pass):
   kicker for hierarchy + lead claim + trust/upsell line, anchored at canvas foot */
.landingcopy { border-top: 1px solid var(--line); padding-top: 18px; flex: 0 0 auto; }
/* kicker rides a hairline that spans the pane — the block occupies full width
   typographically, so the prose line-ends don't read as a right-edge void */
.landingcopy .kicker { display: flex; align-items: center; gap: 14px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--accent-dark); margin-bottom: 10px; white-space: nowrap; }
.landingcopy .kicker::after { content: ""; flex: 1; height: 1px; background: var(--line); }
/* reviewer pass: lines run near full pane width with balanced wrap so whitespace distributes evenly */
.landingcopy .lead { font-size: 16px; line-height: 1.7; max-width: 92ch; text-wrap: balance; }
.landingcopy .sub { margin-top: 12px; font-size: 13.5px; color: var(--ink-soft); line-height: 1.6; max-width: 106ch; text-wrap: balance; }

.previewhead { font-size: 14px; letter-spacing: 0.3px; margin-bottom: 8px; }
.preview {
  flex: 1 1 auto; min-height: 200px;
  display: grid; gap: 12px; justify-content: center; align-content: center;
  overflow: auto; /* unavoidable big grids scroll in-pane instead of clipping */
}
.sheet { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 6px; box-shadow: 0 3px 12px rgba(0, 0, 0, 0.07); }
.sheet .frame { position: relative; line-height: 0; overflow: hidden; border-radius: 4px; }
.planart { position: absolute; z-index: 1; }
.sheet .paper { fill: #ffffff; stroke: var(--line); stroke-width: 3; }
.sheet .usable { fill: none; stroke: var(--muted); stroke-width: 2; stroke-dasharray: 8 6; }
.sheet .plan { fill: var(--accent); opacity: 0.22; stroke: var(--accent); stroke-width: 3; }
.sheetlabel { margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
#previewnote { flex: 0 0 auto; margin-top: 8px; font-size: 12px; }

/* ---------- prose pages (privacy, how-it-works, download, support) ---------- */
.prose { max-width: 70ch; margin: 22px auto 0; padding: 0 24px 10px; }
.prose h1 { font-size: 24px; margin-bottom: 10px; }
.prose h2 { font-size: 16.5px; margin: 18px 0 6px; }
.prose p, .prose ul, .prose ol { margin-bottom: 10px; font-size: 14.5px; }
.prose ul, .prose ol { margin-left: 22px; }
code { font-family: Consolas, monospace; background: var(--card); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: 0.92em; }
.draftflag { font-size: 12px; color: var(--err); border: 1px dashed var(--err); border-radius: 6px; padding: 2px 8px; display: inline-block; margin-bottom: 10px; }
.internal { font-size: 12.5px; color: var(--muted); border-top: 1px dashed var(--line-strong); margin-top: 24px; padding-top: 10px; max-width: 70ch; }
.placeholder { border-bottom: 1px dashed var(--err); }

main.prose { display: block; }
.appbar h1 a { color: inherit; text-decoration: none; border-bottom: none; }
/* copy pages carry the brand as .brand, not a second h1 (single-h1 outline) */
.appbar .brand { font-size: 17px; letter-spacing: 0.4px; font-weight: 600; }
.appbar .brand a { color: inherit; text-decoration: none; border-bottom: none; }

.appfoot {
  flex: 0 0 auto; border-top: 1px solid var(--line);
  padding: 8px 16px 9px; color: var(--muted); font-size: 12.5px;
  display: flex; gap: 18px; align-items: baseline; flex-wrap: wrap;
}
.appfoot a { color: var(--muted); }
.appfoot .spacer { margin-left: auto; }

/* ---------- desktop band: viewport-locked app shell (like the Electron app:
   page never scrolls; controls column scrolls internally; preview pane is
   fixed-height so its sheet grid always fills the visible pane) ---------- */
@media (min-width: 901px) {
  body { height: 100dvh; overflow: hidden; }
  main.shell { height: 100%; min-height: 0; overflow: hidden; }
  .leftcol { overflow-y: auto; overflow-x: hidden; }
  .rightpane { height: 100%; }
  .navline { padding-bottom: 0; }
}

/* ---------- responsive: single column below 900px ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; min-height: 0; }
  .appbar .printrule { margin-left: 0; flex-basis: 100%; }
  .preview { align-content: start; }
  .drop { min-height: 34vh; }
}
/* header furniture totals ~1140px; hide the tagline before the strip wraps
   into the two-line chrome that eats vertical budget at 901–1140px */
@media (max-width: 1140px) {
  .appbar .tagline { display: none; }
}
@media (max-width: 640px) {
  .appbar { padding: 6px 12px 5px; }
  .shell { padding: 6px 12px 8px; }
  .furniture { grid-template-columns: 1fr; }
}
/* short-viewport density bands, ported from the desktop's measured ones:
   at 1280x720 the whole trial + receipt state must stay in the viewport */
@media (min-width: 901px) and (max-height: 740px) {
  .tickrule { display: none; }
  .leftcol { gap: 4px; }
  .panel { padding: 3px 9px; }
  .controls { padding: 0 10px 2px; }
  .option { padding: 5px 10px; }
  .rowitem { padding: 1px 0; }
  button.primary, a.primary { padding: 7px 16px; }
  .landingcopy .lead { font-size: 13.5px; }
  .landingcopy .sub { font-size: 12px; }
  .single .pageart { width: 185px; height: 236px; } /* samples must not crowd the copy at 720px height */
  .grid4 { width: 176px; }
  .grid4 i { width: 92px; height: 129px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
