/* Gridfunction — site styles. Plain CSS, no build step. */

:root {
  --ink: #1b2433;
  --muted: #535d70;
  --line: #dbe1e9;
  --line-strong: #c3ccd8;
  --soft: #f4f6f9;
  --panel: #ffffff;
  --brand: #2457d6;
  --brand-dark: #1a44ae;
  --brand-soft: #edf2ff;
  --danger: #b4352c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 6px 20px rgba(16, 24, 40, 0.06);
  --warn: #8a5a00;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.6 var(--font);
  color: var(--ink);
  background: #fff;
}
img, svg, canvas { display: block; }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-dark); }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.75rem, 3.4vw, 2.5rem); }
h2 { font-size: clamp(1.3rem, 2.2vw, 1.7rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
code { font: 0.9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--soft); padding: 0.1em 0.3em; border-radius: 4px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
h2:focus { outline: none; }

.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 16px; top: -60px; background: #fff; padding: 8px 12px; border-radius: 6px; z-index: 50; box-shadow: var(--shadow); }
.skip-link:focus { top: 12px; }
.small { font-size: 0.875rem; color: var(--muted); }

/* Header and footer */
.site-header { border-bottom: 1px solid var(--line); background: #fff; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; }
.logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 750; font-size: 1.15rem; color: var(--ink); text-decoration: none; letter-spacing: -0.02em; }
.logo:hover { color: var(--ink); }
.logo-mark { flex: none; width: 26px; height: 26px; background: url('/assets/favicon.svg') center / contain no-repeat; }
/* The same file is the favicon, so the logo and the browser tab always match. */
.main-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.main-nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 6px; font-weight: 550; font-size: 0.93rem; }
.main-nav a:hover, .main-nav a[aria-current="page"] { color: var(--ink); background: var(--soft); }
.site-footer { margin-top: 64px; border-top: 1px solid var(--line); background: var(--soft); padding: 28px 0; }
.footer-row { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.footer-row nav { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: flex-start; max-width: 620px; }
.footer-row nav a { color: var(--muted); font-size: 0.9rem; }

/* Intro */
.intro { padding-top: 28px; padding-bottom: 18px; }
.lede { font-size: 1.06rem; color: var(--muted); max-width: 760px; }

/* Tool */
.tool { padding: 0; }
.tool > * { margin-left: 0; margin-right: 0; }
.tool-head, .type-picker, .workspace { background: var(--panel); border: 1px solid var(--line); }
.tool-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 18px; border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0; }
.tool-head h2 { font-size: 1.02rem; margin: 0; }
.type-picker { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)) minmax(170px, 1.4fr); gap: 8px; padding: 12px 18px 16px; border-top: 0; border-bottom: 0; }
.type-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-size: 0.86rem; font-weight: 600; color: var(--muted); text-align: center; line-height: 1.2; }
.type-btn svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.2; }
.type-btn svg.filled { fill: currentColor; stroke: none; }
.type-btn svg .accent { stroke: #e2574c; }
.type-btn svg .bold { stroke-width: 2.2; }
.type-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.type-btn[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.type-all { display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); font-size: 0.82rem; font-weight: 650; color: var(--muted); }
.type-all select { width: 100%; }

.workspace { display: grid; grid-template-columns: minmax(300px, 370px) minmax(0, 1fr); border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow); }
.settings-panel { grid-column: 1; grid-row: 1; border-right: 1px solid var(--line); min-width: 0; }
.preview-panel { grid-column: 2; grid-row: 1; background: #fff; padding: 14px 18px 16px; position: sticky; top: 0; align-self: start; min-width: 0; border-radius: 0 0 var(--radius) 0; }

.preview-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.preview-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.preview-title strong { font-size: 1.02rem; }
.preview-title span { color: var(--muted); font-size: 0.9rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; font-weight: 650; font-size: 0.92rem; cursor: pointer; color: var(--ink); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-quiet { font-weight: 600; color: var(--muted); }
.btn[disabled] { opacity: 0.6; cursor: progress; }
.btn-small { min-height: 32px; padding: 0 10px; gap: 6px; font-size: 0.84rem; flex: none; }
.btn-small svg { width: 16px; height: 16px; }
.pages-field { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; font-size: 0.88rem; color: var(--muted); font-weight: 600; }
.pages-field input[type="number"] { width: 64px; height: 40px; }

.stage-wrap { position: relative; }
.stage { position: relative; display: flex; height: clamp(420px, calc(100vh - 230px), 900px); padding: 16px; border-radius: 8px; background-color: #e9edf3; background-image: radial-gradient(#d7dde7 0.9px, transparent 0.9px); background-size: 14px 14px; overflow: hidden; }
/* margin:auto centers the page and, unlike align-items, keeps every edge reachable when it is zoomed. */
.stage canvas { flex: none; margin: auto; max-width: 100%; max-height: 100%; background: #fff; box-shadow: 0 2px 4px rgba(16, 24, 40, 0.08), 0 10px 30px rgba(16, 24, 40, 0.12); }
.stage.zoomed { overflow: auto; }
.stage.zoomed canvas { max-width: none; max-height: none; }
@media (hover: hover) and (pointer: fine) {
  .stage canvas { cursor: zoom-in; }
  .stage.zoomed canvas { cursor: zoom-out; }
}
.stage-notice { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 80%; margin: 0; padding: 12px 16px; border-radius: 8px; background: #fff; border: 1px solid #f0c4bf; color: var(--danger); font-weight: 600; text-align: center; box-shadow: var(--shadow); }
.toast { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 3; width: max-content; max-width: calc(100% - 24px); margin: 0; padding: 8px 14px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 0.88rem; font-weight: 600; line-height: 1.35; text-align: center; box-shadow: 0 6px 20px rgba(16, 24, 40, 0.25); pointer-events: none; }
.toast.bad { background: var(--danger); }
.drop-hint { position: absolute; inset: 10px; z-index: 2; display: none; align-items: center; justify-content: center; padding: 12px; border: 2px dashed var(--brand); border-radius: 10px; background: rgba(237, 242, 255, 0.92); color: var(--brand); font-weight: 700; text-align: center; pointer-events: none; }
.stage-wrap.dragging .drop-hint { display: flex; }
.print-tip { margin: 10px 0 0; font-size: 0.85rem; color: var(--muted); }

/* Settings */
.settings { padding: 6px 18px 18px; }
.group { border: 0; margin: 0; padding: 14px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.group:last-of-type { border-bottom: 0; }
legend, details.group > summary { font-size: 0.78rem; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 0; margin-bottom: 10px; }
details.group > summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; margin: 0; }
/* A legend sits on the fieldset's top edge, so the space above it has to be its own padding. */
fieldset.group { padding-top: 0; }
fieldset.group > legend { padding-top: 14px; margin-bottom: 8px; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::after { content: "+"; font-size: 1.2rem; font-weight: 500; color: var(--muted); }
details.group[open] > summary::after { content: "–"; }
.details-body { padding-top: 12px; }
.row { display: grid; gap: 12px; margin-bottom: 12px; }
.row.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; margin-bottom: 12px; }
.row .field { margin-bottom: 0; }
.label { font-size: 0.86rem; font-weight: 650; color: var(--ink); display: flex; justify-content: space-between; gap: 8px; }
.label output { font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.field-check { justify-content: flex-end; }
.field-check .check { min-height: 38px; }
.field-note { margin: 0; font-size: 0.82rem; font-weight: 600; color: var(--warn); }
select, input[type="number"], input[type="text"] { width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; min-width: 0; }
select { padding-right: 6px; }
input[type="number"]:focus, input[type="text"]:focus, select:focus { border-color: var(--brand); }
input[type="number"]:focus-visible, input[type="text"]:focus-visible, select:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
input[type="range"] { width: 100%; accent-color: var(--brand); }
input[type="color"] { width: 46px; height: 36px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; cursor: pointer; }
.input-unit { display: flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; overflow: hidden; }
.input-unit:focus-within { border-color: var(--brand); outline: 2px solid var(--brand); outline-offset: 1px; }
.input-unit input { border: 0; height: 36px; border-radius: 0; outline: none !important; }
.input-unit .unit { display: flex; align-items: center; padding: 0 10px; background: var(--soft); color: var(--muted); font-size: 0.85rem; border-left: 1px solid var(--line); white-space: nowrap; }
.segmented { display: flex; border: 1px solid var(--line-strong); border-radius: 7px; overflow: hidden; height: 38px; background: #fff; }
.segmented label { flex: 1; position: relative; display: flex; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 0.86rem; font-weight: 600; color: var(--muted); padding: 0 6px; white-space: nowrap; }
.segmented label + label span { border-left: 1px solid var(--line); }
.segmented input:checked + span { background: var(--brand-soft); color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.segmented input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: -3px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 31px; }
.chips button { border: 1px solid var(--line-strong); background: #fff; border-radius: 999px; padding: 4px 11px; font-size: 0.84rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.chips button:hover { border-color: var(--brand); color: var(--brand); }
.chips button[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.checks { display: grid; gap: 8px; margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 0.92rem; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); margin: 0; }
.color-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.swatches { display: flex; gap: 8px; }
.swatches button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; background: var(--c); box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; padding: 0; }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--brand); }
.hint { font-size: 0.84rem; color: var(--muted); margin: 6px 0 10px; }
.field > .hint { margin: 0; min-height: 1.6em; }
.hint.warn { color: var(--warn); font-weight: 600; }
.error { color: var(--danger); font-size: 0.86rem; font-weight: 600; margin: 4px 0 0; min-height: 1px; }
.upload { display: flex; flex-direction: column; gap: 3px; padding: 14px; border: 1.5px dashed var(--line-strong); border-radius: 9px; text-align: center; cursor: pointer; background: var(--soft); }
.upload strong { color: var(--brand); }
.upload span { font-size: 0.82rem; color: var(--muted); }
.upload:hover { border-color: var(--brand); }
#imageUpload:focus-visible + .upload { border-color: var(--brand); outline: 2px solid var(--brand); outline-offset: 2px; }
.settings-note { margin: 14px 0 0; font-size: 0.86rem; color: var(--muted); }
.link-button { border: 0; background: none; padding: 0; color: var(--brand); font-weight: 650; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; font-size: inherit; }
.link-button.danger { color: var(--danger); }
.ad-note { font-size: 0.85rem; color: var(--muted); margin-top: 6px; }

/* Content sections */
.section { margin-top: 56px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head p { color: var(--muted); max-width: 680px; margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button { border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; padding: 6px 13px; font-size: 0.86rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.filters button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; text-align: left; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; cursor: pointer; }
.card:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.card[aria-current="true"] { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.card canvas { width: 100%; height: auto; aspect-ratio: 240 / 190; border-bottom: 1px solid var(--line); background: #fff; }
.card-name { font-weight: 700; padding: 10px 12px 0; }
.card-desc { font-size: 0.86rem; color: var(--muted); padding: 2px 12px 12px; }
.card[hidden] { display: none; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; }
.steps { margin: 0; padding-left: 1.3em; display: grid; gap: 12px; }
.sizes { width: 100%; border-collapse: collapse; font-size: 0.92rem; margin-bottom: 14px; }
.sizes th, .sizes td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.sizes th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.faq { display: grid; grid-template-columns: 1fr 1fr; gap: 0 36px; }
.faq details { border-bottom: 1px solid var(--line); padding: 14px 0; }
.faq summary { cursor: pointer; font-weight: 650; }
.faq p { margin: 10px 0 0; color: var(--muted); }

/* Articles (guides, about, privacy) */
.article { max-width: 780px; margin: 0 auto; padding: 32px 20px 0; }
.article .lede { margin-bottom: 1.6em; }
.article h2 { margin-top: 1.6em; }
.article li { margin-bottom: 0.4em; }
.article table { width: 100%; border-collapse: collapse; font-size: 0.92rem; margin: 1em 0 1.5em; }
.article th, .article td { text-align: left; vertical-align: top; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.article th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
/* "x′ =" is a variable name: keep its case */
.article th.keep-case, table.stack td[data-label$="="]::before { text-transform: none; font-size: 0.9rem; letter-spacing: 0; }
@media (max-width: 700px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; margin-bottom: 12px; }
  table.stack td { border: 0; padding: 6px 0; }
  table.stack td::before { content: attr(data-label); display: block; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
}
.breadcrumb { font-size: 0.88rem; margin-bottom: 1.2em; }
.toc { margin: 1.2em 0 1.6em; padding: 12px 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
.toc ol { margin: 0; padding-left: 1.4em; columns: 2 16em; column-gap: 2em; }
.toc li { margin: 0.15em 0; break-inside: avoid; }
.gpc-note { font-size: 0.85rem; color: var(--muted); margin: 8px 0 0; }
.callout { padding: 14px 16px; border-left: 4px solid var(--brand); background: var(--brand-soft); border-radius: 0 8px 8px 0; margin: 1.4em 0; }
.callout.warn { border-left-color: var(--danger); background: #fff4f2; }
.btn-link { display: inline-flex; align-items: center; min-height: 42px; padding: 0 16px; border-radius: 8px; background: var(--brand); color: #fff; font-weight: 700; text-decoration: none; }
.btn-link:hover { background: var(--brand-dark); color: #fff; }
.choice-panel { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--soft); margin: 1.4em 0; }
.choice-panel .actions { margin: 12px 0 0; }

/* Responsive */
@media (max-width: 1080px) {
  .type-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .type-all { grid-column: 1 / -1; flex-direction: row; align-items: center; }
  .type-all span { white-space: nowrap; }
}
@media (max-width: 860px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .preview-panel { grid-column: 1; grid-row: 1; position: static; border-radius: 0; border-bottom: 1px solid var(--line); }
  .settings-panel { grid-column: 1; grid-row: 2; border-right: 0; }
  .stage { height: auto; padding: 14px; }
  .stage.zoomed { max-height: 72vh; }
  .two-col, .faq { grid-template-columns: minmax(0, 1fr); }
  .main-nav a:not([href$="#tool"]):not([href^="/guides"]) { display: none; }
}
@media (max-width: 520px) {
  .container { padding: 0 14px; }
  .type-picker { padding: 10px 12px 12px; gap: 6px; }
  .type-btn { font-size: 0.8rem; padding: 8px 4px; }
  .tool-head, .preview-panel { padding-left: 12px; padding-right: 12px; }
  .settings { padding: 4px 12px 14px; }
  .actions .btn { flex: 1 1 auto; }
  .pages-field { margin-left: 0; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .row.two { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* Windows high-contrast themes drop backgrounds and shadows, so selected states get an outline. */
@media (forced-colors: active) {
  .type-btn[aria-pressed="true"], .chips button[aria-pressed="true"], .filters button[aria-pressed="true"],
  .segmented input:checked + span, .card[aria-current="true"] { outline: 2px solid Highlight; outline-offset: -3px; }
  .swatches button, .logo-mark { forced-color-adjust: none; }
  .swatches button[aria-pressed="true"] { outline: 2px solid Highlight; outline-offset: 2px; }
  .toast { border: 1px solid CanvasText; }
}

/* Printing: the app swaps in an exact-size vector sheet before printing. */
#print-sheet { display: none; }
@media print {
  ins.adsbygoogle, .adsbygoogle, .google-auto-placed, iframe { display: none !important; }
  html.printing body > *:not(#print-sheet) { display: none !important; }
  html.printing body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
  html.printing #print-sheet { display: block !important; overflow: hidden; }
  html.printing #print-sheet svg { display: block; }
  .site-header, .site-footer, .skip-link { display: none; }
}
