:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, sans-serif;
  color: #172721;
  background: #f5f7f4;
  --brand: #145b45;
  --muted: #53665d;
  --border: #dce5df;
  --soft: #edf4ef;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
header {
  min-height: 65px;
  padding: 12px max(20px, calc((100vw - 1170px) / 2));
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; gap: 10px; align-items: center; text-decoration: none; color: inherit; font-size: 19px; font-weight: 780; }
.brand span { display: grid; place-items: center; width: 33px; height: 33px; border-radius: 10px; background: var(--brand); color: white; }
.account { padding: 5px 10px; border-radius: 99px; background: var(--soft); color: var(--brand); font-size: 12px; font-weight: 750; }
.account:empty { display: none; }
main { max-width: 1210px; margin: auto; padding: 0 20px 40px; }
.intro { padding: 29px 0 19px; }
.eyebrow { margin: 0 0 8px; color: var(--brand); letter-spacing: .16em; font-size: 10px; font-weight: 800; }
h1 { margin: 0; letter-spacing: -.055em; font-size: clamp(35px, 5vw, 56px); line-height: 1.06; }
.intro p:last-child { margin: 9px 0 0; color: var(--muted); }
.tabs, .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs { border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabs button { border-radius: 9px 9px 0 0; background: none; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button[aria-pressed=true] { color: var(--brand); background: #e7f1ea; border-bottom-color: var(--brand); }
button, .button {
  display: inline-block;
  min-height: 44px;
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--brand);
  color: white;
  font: 650 14px system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
button:disabled { opacity: .48; cursor: default; }
.secondary { background: var(--soft); color: #254336; border-color: var(--border); }
.danger { background: #fcf0ee; color: #892e2e; }
.card {
  min-width: 0;
  padding: 22px;
  margin-bottom: 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 15px;
  box-shadow: 0 4px 15px #122f2010;
}
.split { display: grid; grid-template-columns: minmax(290px, .84fr) minmax(0, 1.16fr); gap: 16px; align-items: start; }
.panel { max-width: 820px; }
h2 { font-size: 19px; margin: 0 0 13px; letter-spacing: -.025em; }
label { display: block; font-size: 13px; font-weight: 680; }
textarea, select, input[type=number] {
  display: block;
  width: 100%;
  padding: 10px;
  margin-top: 5px;
  border: 1px solid #ccd9d0;
  border-radius: 8px;
  color: inherit;
  background: #fcfdfb;
  font: 16px system-ui, sans-serif;
}
textarea { min-height: 185px; resize: vertical; }
input[type=color] { display: block; margin-top: 5px; width: 52px; height: 36px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.preview { background: #eaf0ec; }
.preview-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.preview-head span, .hint, .legal { color: var(--muted); font-size: 13px; line-height: 1.55; }
#pages { max-height: 680px; overflow: auto; padding: 6px; }
.sheet { display: block; width: 100%; height: auto; background: #fff; border-radius: 2px; box-shadow: 0 3px 12px #17272128; margin-bottom: 14px; }
.sheet[data-interactive] { cursor: pointer; }
#calibration { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#calibration p { color: var(--muted); }
#pad { display: block; width: 100%; max-width: 850px; touch-action: none; aspect-ratio: 640 / 192; border: 1px solid #b8cfc0; border-radius: 9px; margin: 0 0 14px; background: #fcfdfb; }
#pad-labels { display: flex; max-width: 850px; margin: 12px 0 5px; font-size: clamp(17px, 3vw, 24px); font-weight: 650; color: var(--muted); text-align: center; }
#pad-labels span { flex: 1; min-width: 0; }
.input-tools { display: flex; align-items: center; gap: 9px; margin-top: 12px; flex-wrap: wrap; }
.input-tools select { width: auto; margin: 0; min-height: 42px; }
.input-tools output { color: var(--muted); font-size: 13px; }
#flow-samples[aria-pressed=true] { background: var(--brand); color: #fff; }
.profile-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.profile-stats div { background: var(--soft); border-radius: 10px; padding: 12px; }
.profile-stats dt { font-weight: 680; }
.profile-stats dd { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
#profile .actions { margin: 13px 0; }
.request { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--border); }
.request span { flex: 1; overflow-wrap: anywhere; }
.settings summary, .legal summary { cursor: pointer; }
.legal summary { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.legal a { color: var(--brand); margin-right: 12px; }
.legal p { max-width: 740px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
@media (max-width: 740px) {
  main { padding-inline: 14px; }
  .split { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .tabs { gap: 2px; }
  .tabs button { padding-inline: 9px; }
}
@page A4Sheet { size: A4; margin: 0; }
@page A5Sheet { size: A5; margin: 0; }
@page LetterSheet { size: letter; margin: 0; }
@media print {
  header, .intro, .tabs, .controls, .preview-head, .legal, #gate, #owner, #calibration, #profile, #word-hint { display: none !important; }
  main, .split, .preview, #pages { display: block; margin: 0; padding: 0; max-height: none; overflow: visible; border: 0; }
  .sheet { width: 100%; height: auto; box-shadow: none; margin: 0; break-after: page; break-inside: avoid; }
  .sheet:last-child { break-after: auto; }
  .sheet.a4 { page: A4Sheet; }
  .sheet.a5 { page: A5Sheet; }
  .sheet.letter { page: LetterSheet; }
}

.owner-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.owner-stats dd { color: var(--brand); font-size: 24px; font-weight: 750; }
#owner-search { width: 100%; margin-top: 5px; min-height: 44px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; font: 16px system-ui, sans-serif; }
.request small { display: block; margin-top: 4px; color: var(--muted); }

.size-control { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin: 13px 0; }
.size-control output { color: var(--brand); font-size: 13px; font-weight: 750; }
.size-control input { grid-column: 1 / -1; width: 100%; min-height: 32px; margin: 0; accent-color: var(--brand); }
#export-ready { margin-top: 12px; padding: 12px; border-radius: 9px; background: var(--soft); }
#export-ready p { margin: 8px 0 0; }

#comparison { margin-bottom: 15px; }
#comparison summary { cursor: pointer; }
#comparison-pages { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#comparison-pages figure { margin: 8px 0; min-width: 0; }
#comparison-pages canvas { display: block; width: 100%; height: auto; background: white; }
.word-option { margin-top: 12px; }
@media print { #comparison { display: none; } }

#sample-library { margin: 16px 0; }
#sample-library summary { cursor: pointer; }
#library-variants { display: flex; flex-wrap: wrap; gap: 12px; }
#library-variants figure { flex: 1 1 145px; max-width: 230px; margin: 0; padding: 10px; border: 1px solid var(--border); border-radius: 9px; }
#library-variants canvas { display: block; width: 100%; height: auto; background: #fcfdfb; }
#library-variants figcaption { margin: 7px 0; font-size: 13px; }

#page-nav { display: flex; gap: 8px; overflow-x: auto; margin: 8px 0; padding: 4px; }
#page-nav button { flex: 0 0 72px; padding: 5px; font-size: 12px; }
#page-nav canvas { display: block; width: 100%; height: auto; background: white; margin-bottom: 4px; }
@media print { #page-nav, .preview-tools { display: none !important; } }

@media (orientation: landscape) { #calibration #pad, #calibration #pad-labels { max-width: none; } }
.pad-focus header, .pad-focus .intro, .pad-focus .tabs, .pad-focus .legal,
.pad-focus #cal-instructions, .pad-focus #calibration .pair, .pad-focus #flow-samples, .pad-focus .input-tools { display: none; }
.pad-focus main { max-width: none; padding-top: 12px; }
.pad-focus #pad, .pad-focus #pad-labels { max-width: none; }
#pad-stroke-log { max-height: 180px; overflow: auto; }

canvas.erasing { cursor: crosshair; }

.pad-toolbar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; width: fit-content; max-width: 100%; padding: 4px; margin: 12px 0 8px; border: 1px solid #dbe3f2; border-radius: 14px; background: #f5f8ff; }
.pad-toolbar .pad-tool { display: grid; place-items: center; width: 46px; height: 46px; min-width: 0; margin: 0; padding: 0; border: 0; border-radius: 10px; background: transparent; color: #263951; }
.pad-toolbar .pad-tool[aria-pressed="true"] { background: #dce8ff; color: #18449b; box-shadow: inset 0 -3px #3468c7; }
.pad-toolbar .pad-tool:disabled { opacity: .35; }
.pad-tool svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pad-divider { align-self: stretch; width: 1px; margin: 8px 2px; background: #dbe3f2; }
#pad-tool-name { padding: 0 8px; font-size: .84rem; color: #43536d; }

#pages.fit-page .sheet { width: auto; max-width: 100%; max-height: min(62vh, 650px); object-fit: contain; margin-inline: auto; }
#import-comparison { display: flex; flex-wrap: wrap; gap: 8px; }
#import-comparison figure { margin: 0; }
#import-comparison canvas { max-width: 100%; background: #fff; border: 1px solid #dbe3f2; }
.demo-badge { display: inline-block; width: fit-content; color: #624200; background: #fff0c7; padding: 2px 6px; border-radius: 6px; }
#report-status { white-space: pre-wrap; user-select: text; }
