/*
 * HandWritten: the tool's own components, styled in the site's design language (11 Nov 2026, on the UltraCompress Pro
 * template, after GIF Forge, whose shared block the first part of this file follows). Base: /libs/site-pages.css
 * (tokens, Inter and Space Grotesk, theme toggle, focus rings) and /libs/shared-nav.css (the site's header and footer).
 * The second part is the original's components (the settings panels, the handwriting, pen, paper and look pickers, the
 * swatches, the pages beside the settings with their bar and thumbnails, the signature maker) on the site's tokens. The
 * scripts build their parts with the original's class names (hand, pick, swatch, chip, seg, thumb ...), so those names
 * are styled here. The paper, the ink and the handwriting tiles keep paper colours in both themes: they are the page.
 * The handwriting fonts are in fonts/fonts.css (fonts/LICENSES.txt). Light is the default; dark applies when <html> has
 * no data-theme. Written once from GIF Forge's file and the original's style.css, then edited by hand: the source.
 */

/* ----- Tokens the tool adds ----- */
:root {
    --surface: #ffffff;
    --surface-2: #f3f4f8;
    --ring: rgba(139, 92, 246, 0.18);
    --app-max: 1600px;
    --line: rgba(0, 0, 0, 0.1);
    --line-strong: rgba(0, 0, 0, 0.24);
    --ok: #166534;
    --bad: #b91c1c;
    --warn: #92400e;
    --warn-soft: rgba(217, 119, 6, 0.1);
    --desk: #e3e5eb;           /* around the page, like a desk */
    --sheet: #fbfbf7;          /* the paper of the handwriting tiles */
    --sheet-ink: #1f3d9c;
    --sheet-rule: rgba(92, 138, 196, 0.45);
    --sheet-label: #555c6b;    /* the style's name on a paper tile */
    --head: 81px;              /* the site's header */
}
:root:not([data-theme="light"]) {
    --surface: #14141f;
    --surface-2: rgba(255, 255, 255, 0.05);
    --line: rgba(255, 255, 255, 0.1);
    --line-strong: rgba(255, 255, 255, 0.26);
    --ok: #4ade80;
    --bad: #f87171;
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.1);
    --desk: #08090c;
}
@media (max-width: 639.98px) { :root { --head: 65px; } }

/* ----- Page: full width, the page provides the side space ----- */
.container.app-container { max-width: calc(var(--app-max) + 2 * var(--content-gutter)); margin-top: 16px; }
@media (min-width: 640px) { .container.app-container { margin-top: 24px; } }

/* ----- The site header is the first thing on the page and stays at the top ----- */
body { padding-top: 0; }
body > header { position: sticky; top: 0; z-index: 50; }
header .site-nav { position: relative; top: auto; }
.theme-toggle { top: 90px; }
@media (max-width: 639.98px) { .theme-toggle { top: 75px; } } /* the header is 81 px tall from 640 px, 65 px below */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ----- Hero ----- */
.app-hero { margin: 0 0 2rem; text-align: center; }
.app-brand { display: inline-flex; align-items: center; gap: 12px; margin-bottom: 1.25rem; font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 700; font-size: 1.1rem; color: var(--text-strong); }
.app-brand img { width: 44px; height: 44px; border-radius: 12px; display: block; }
.app-hero h1 { margin-bottom: 0.75rem; }
.app-tagline { color: var(--text-2); font-size: 1.125rem; line-height: 1.6; max-width: 46rem; margin: 0 auto; }

/* ----- Small helpers ----- */
main [hidden], .dialog [hidden], body > [hidden] { display: none !important; } /* the scripts hide parts that carry their own display */
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.hint { color: var(--text-3); font-size: 0.82rem; font-weight: 400; line-height: 1.45; margin: 0; }
.hint:empty { display: none; }
.row { display: flex; align-items: center; gap: 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--link); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.link:hover { color: var(--link-hover); }
code { font-size: 0.85em; padding: 1px 6px; border-radius: 6px; background: var(--code-bg); color: var(--code-text); }
kbd { font-family: inherit; font-size: 0.72rem; font-weight: 700; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--chip-border); border-bottom-width: 2px; background: var(--chip); color: var(--text-strong); }

/* ----- Buttons (the scripts' class names: btn, primary, ghost, danger, small-btn) ----- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 20px; border: 1px solid var(--surface-border); border-radius: 9999px; background: var(--surface); color: var(--text-strong); font-family: inherit; font-weight: 600; font-size: 0.925rem; line-height: 1.2; text-align: center; text-decoration: none; cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, color 0.2s ease, background 0.2s ease; }
.btn .ico { width: 17px; height: 17px; }
.btn:hover:not([disabled]) { border-color: var(--brand); color: var(--link); transform: translateY(-2px); }
.btn.primary { background: var(--gradient-brand); color: #fff; border-color: transparent; box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3); }
.btn.primary:hover:not([disabled]) { color: #fff; border-color: transparent; box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(185, 28, 28, 0.35); }
.btn.danger:hover:not([disabled]) { background: var(--danger-strong); color: #fff; border-color: transparent; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn.small-btn, .small-btn { min-height: 38px; padding: 7px 15px; font-size: 0.85rem; }
label.btn { cursor: pointer; }
label.btn:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--surface-border); background: var(--surface); cursor: pointer; display: inline-grid; place-items: center; color: var(--text-strong); flex: none; padding: 0; font-family: inherit; transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease; }
.icon-btn:hover:not([disabled]) { border-color: var(--brand); color: var(--link); }
.icon-btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.icon-btn:focus-visible, .link:focus-visible, .btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ----- Toolbar: the five parts as pill tabs ----- */
.app-shell { margin: 0 0 3rem; scroll-margin-top: 90px; }
.app-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin: 0 0 1.25rem; }
.toolbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.view-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 9999px; background: var(--surface-2); max-width: 100%; overflow-x: auto; scrollbar-width: thin; }
.view-tab { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 16px; border: 0; border-radius: 9999px; background: transparent; font-family: inherit; font-size: 0.85rem; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease; }
.view-tab .ico { width: 16px; height: 16px; }
.view-tab:hover { color: var(--link); }
.view-tab[aria-current="page"] { background: var(--gradient-brand); color: #fff; box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3); }
.view-tab:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand); color: #fff; font-size: 0.72rem; font-weight: 700; display: inline-grid; place-items: center; line-height: 1; }
.view-tab[aria-current="page"] .badge { background: #fff; color: #5b21b6; }
@media (min-width: 1024px) { .view-tab.tab-pages { display: none; } } /* the pages sit beside the settings */
.shell-hint { margin-top: 18px; color: var(--text-3); font-size: 0.85rem; }

/* ----- Fields ----- */
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; border: 0; padding: 0; margin: 0; }
.label { font-weight: 600; font-size: 0.875rem; color: var(--text-strong); }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.val { color: var(--text-2); font-size: 0.85rem; text-align: right; }
.input, .select, .textarea { width: 100%; min-width: 0; min-height: 44px; padding: 10px 14px; background: var(--field); border: 1px solid var(--field-border); border-radius: 12px; font-family: inherit; font-size: 0.95rem; color: var(--text); outline: none; transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--placeholder); }
.select { width: auto; max-width: 100%; cursor: pointer; }
.select-sm { min-height: 38px; padding: 6px 12px; font-size: 0.875rem; border-radius: 9999px; }
.textarea { resize: vertical; min-height: 280px; line-height: 1.6; display: block; overflow-wrap: anywhere; }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; min-width: 0; }
.input-row .btn { flex: none; }
.check-row { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 0.925rem; color: var(--text); padding: 4px 0; }
.check-row input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; max-width: 100%; align-self: flex-start; }
.seg button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 13px; border-radius: 9999px; border: 1px solid var(--chip-border); background: var(--surface); font-family: inherit; font-size: 0.85rem; font-weight: 600; color: var(--text-2); cursor: pointer; transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease; }
.seg button:hover:not([disabled]) { border-color: var(--brand); color: var(--link); transform: translateY(-1px); }
.seg button[aria-checked="true"], .seg button[aria-checked="true"]:hover:not([disabled]) { background: var(--gradient-brand); color: #fff; border-color: transparent; }
.seg button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.seg-sm button { min-height: 32px; padding: 4px 11px; font-size: 0.8rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 5px 13px; border-radius: 9999px; border: 1px solid var(--chip-border); background: var(--chip); font-family: inherit; font-size: 0.85rem; font-weight: 600; color: var(--text-2); cursor: pointer; transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease; }
.chip:hover { border-color: var(--brand); color: var(--link); transform: translateY(-1px); }
.chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.chip[aria-checked="true"] { background: var(--gradient-brand); color: #fff; border-color: transparent; }
/* text in Indian scripts (the group names, the samples, what you type, the messages) falls back to the tool's own fonts on
   devices without Indian system fonts */
#groupChips .chip, #sampleSel, main .input, main .textarea, .toast { font-family: 'Inter', system-ui, sans-serif, "Kalam", "Farsan", "Galada", "Kavivanar"; }
/* sliders: the filled part follows the value (the script sets --p) */
main input[type="range"] { width: 100%; height: 28px; margin: 0; background: transparent; accent-color: var(--brand); -webkit-appearance: none; appearance: none; cursor: pointer; }
main input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--brand) var(--p, 50%), var(--line-strong) var(--p, 50%)); }
main input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line-strong); }
main input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--brand); }
main input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%; background: #fff; border: 2px solid var(--brand); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
main input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid var(--brand); }
main input[type="range"]:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
main input[type="range"]:disabled { opacity: 0.4; cursor: not-allowed; }
fieldset.group { border: 0; border-top: 1px solid var(--surface-border); padding: 16px 0 0; margin: 0; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
fieldset.group legend { float: left; width: 100%; padding: 0; margin: 0 0 2px; font-weight: 700; font-size: 1rem; color: var(--text-strong); }
fieldset.group legend + * { clear: both; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 480px) { .grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sliders { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px 24px; }
@media (min-width: 480px) { .sliders { grid-template-columns: repeat(2, minmax(0, 1fr)); } .sliders .span2 { grid-column: 1 / -1; } }
.slider { gap: 4px; }

/* ----- Write: the settings beside the pages ----- */
.studio { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; }
.controls { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.panel { display: none; flex-direction: column; gap: 22px; min-width: 0; }
body[data-panel="text"] .panel[data-panel="text"],
body[data-panel="writing"] .panel[data-panel="writing"],
body[data-panel="paper"] .panel[data-panel="paper"] { display: flex; }
.preview { display: none; flex-direction: column; gap: 12px; min-width: 0; }
body[data-panel="preview"] .preview { display: flex; }
body[data-panel="preview"] .controls > .panel { display: none; }
@media (min-width: 1024px) {
    .studio { grid-template-columns: minmax(340px, 420px) minmax(0, 1fr); gap: 40px; }
    .preview { display: flex; position: sticky; top: calc(var(--head) + 16px); height: calc(100vh - var(--head) - 32px); min-height: 480px; }
    body[data-panel="preview"] .panel[data-panel="text"] { display: flex; }
}

/* ----- Text ----- */
.editor-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.tool { width: 38px; height: 38px; display: inline-grid; place-items: center; padding: 0; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--text-2); cursor: pointer; transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease; }
.tool:hover { background: var(--surface); border-color: var(--surface-border); color: var(--link); }
.tool:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.bar-gap { flex: 1; }

/* ----- Writing: handwriting, pens, swatches ----- */
.hands, .sig-styles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
/* an odd last tile takes the whole row, so no row is left with a gap */
.hands .hand:last-child:nth-child(odd), .sig-styles .hand:last-child:nth-child(odd) { grid-column: 1 / -1; }
.hand { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 0; min-height: 78px; padding: 6px 10px; text-align: left; overflow: hidden; border: 1px solid var(--surface-border); border-radius: 12px; background: var(--sheet); color: var(--sheet-ink); cursor: pointer; font-family: inherit; transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease; }
.hand:hover { border-color: var(--brand); transform: translateY(-2px); }
.hand:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.hand[aria-checked="true"] { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.hand[aria-checked="true"]::after { content: ""; position: absolute; top: 6px; right: 6px; width: 18px; height: 18px; border-radius: 50%; background: #7c3aed url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5L20 7'/%3E%3C/svg%3E") center / 12px no-repeat; }
.hand-sample { display: block; font-size: 25px; line-height: 44px; white-space: nowrap; overflow: hidden; text-overflow: clip; padding-right: 16px; background: linear-gradient(transparent 33px, var(--sheet-rule) 33px, var(--sheet-rule) 34px, transparent 34px); }
.hand-name { font-size: 0.75rem; color: var(--sheet-label); font-family: 'Inter', system-ui, sans-serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.own-font { display: flex; flex-direction: column; gap: 10px; }
.pens { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.pick { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 4px; min-width: 0; border: 1px solid var(--surface-border); border-radius: 12px; background: var(--surface); color: var(--text-strong); text-align: center; cursor: pointer; font-family: inherit; transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease; }
.pick:hover { border-color: var(--brand); transform: translateY(-2px); }
.pick:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.pick[aria-checked="true"] { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.pick canvas { display: block; width: 100%; height: auto; border-radius: 8px; background: var(--sheet); }
.pick span { font-size: 0.78rem; font-weight: 600; line-height: 1.2; padding: 0 2px 2px; overflow-wrap: anywhere; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch { position: relative; width: 36px; height: 36px; border-radius: 50%; padding: 0; flex: none; cursor: pointer; border: 3px solid var(--surface); background: var(--c); box-shadow: 0 0 0 1px var(--line-strong); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.swatch:hover { transform: translateY(-2px); }
.swatch:focus-visible, .swatch-custom:focus-within { outline: 2px solid var(--brand); outline-offset: 3px; }
.swatch[aria-checked="true"], .swatch-custom.on { box-shadow: 0 0 0 2px var(--brand); }
.swatch[aria-checked="true"]::after, .swatch-custom.on::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5L20 7'/%3E%3C/svg%3E") center / 15px no-repeat; }
.swatch.light[aria-checked="true"]::after { filter: invert(1) brightness(0.3); }
.swatch-custom { background: conic-gradient(#e33, #ec3, #3c5, #3ad, #63e, #e3a, #e33); overflow: hidden; }
.swatch-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; border: 0; padding: 0; }

/* ----- Paper ----- */
.papers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.papers canvas { aspect-ratio: 4 / 3; object-fit: cover; object-position: top; }
.finishes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.finishes canvas { aspect-ratio: 1 / 1.25; object-fit: contain; background: var(--desk); }

/* ----- Pages ----- */
.pv-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pager, .zoom { display: flex; align-items: center; gap: 4px; }
.page-info { min-width: 92px; text-align: center; font-size: 0.9rem; color: var(--text-2); }
.zoom-fit { min-width: 64px; }
.dl { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 250px; padding: 6px; background: var(--surface); border: 1px solid var(--surface-border); border-radius: 14px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2); display: flex; flex-direction: column; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 8px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--text); text-align: left; font-family: inherit; font-size: 0.9rem; cursor: pointer; }
.menu button:hover, .menu button:focus-visible { background: var(--tint-brand); color: var(--link); outline: none; }
.page-note { margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: 0.9rem; font-weight: 600; }
.stage { position: relative; flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; background: var(--desk); border-radius: 16px; padding: 12px; display: flex; align-items: flex-start; justify-content: safe center; }
@media (min-width: 640px) { .stage { padding: 24px; } }
.sheet { flex: none; line-height: 0; margin: auto; }
.sheet canvas { display: block; border-radius: 1px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 6px 18px rgba(20, 24, 34, 0.16), 0 24px 48px -16px rgba(20, 24, 34, 0.25); }
.sheet.is-photo canvas { border-radius: 6px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25); }
.stage-msg { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); max-width: calc(100% - 32px); color: var(--text-2); font-size: 0.9rem; background: var(--surface); padding: 8px 14px; border-radius: 12px; box-shadow: var(--surface-shadow); line-height: 1.4; text-align: center; }
.thumbs { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: thin; }
.thumbs:empty { display: none; }
.thumb { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px; border: 1px solid transparent; border-radius: 10px; background: transparent; font-family: inherit; font-size: 0.75rem; color: var(--text-2); cursor: pointer; }
.thumb canvas { display: block; width: 64px; height: auto; border-radius: 2px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); background: var(--sheet); }
.thumb:hover { border-color: var(--surface-border); }
.thumb:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.thumb[aria-current="true"] { border-color: var(--brand); color: var(--text-strong); font-weight: 700; }
@media (max-width: 1023.98px) { .preview .stage { flex: none; scrollbar-gutter: auto; } }
@media (max-width: 520px) {
    .pv-bar, .dl { gap: 6px; }
    .pv-bar #shuffle span, .pi-word { display: none; }
    .page-info { min-width: 52px; }
}

/* ----- Signature ----- */
.sign { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; align-items: start; }
@media (min-width: 1024px) { .sign { grid-template-columns: minmax(340px, 460px) minmax(0, 1fr); gap: 40px; } .sign-out { position: sticky; top: calc(var(--head) + 24px); } }
.sign-controls, .sign-out, .sig-typed, .sig-drawn { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.view-head h2 { margin: 0; font-size: 1.5rem; color: var(--text-strong); }
.lead { margin: 6px 0 0; color: var(--text-2); max-width: 64ch; }
.sig-styles .hand-sample { font-size: 30px; line-height: 52px; background: none; }
.sig-styles .hand { min-height: 72px; }
.pad-wrap { position: relative; border: 1px solid var(--field-border); border-radius: 14px; overflow: hidden; background: var(--sheet); }
.pad-wrap::after { content: ""; position: absolute; left: 6%; right: 6%; bottom: 28%; border-bottom: 1px dashed #9aa3b5; pointer-events: none; }
.pad { display: block; width: 100%; height: 220px; touch-action: none; cursor: crosshair; position: relative; z-index: 1; }
.sig-card { border: 1px solid var(--surface-border); border-radius: 16px; min-height: 240px; padding: 8px; display: grid; place-items: center; overflow: hidden; background: var(--sheet) linear-gradient(transparent calc(68% - 1px), var(--sheet-rule) calc(68% - 1px), var(--sheet-rule) 68%, transparent 68%); }
.sig-card.clear { background-color: #ffffff; background-image: linear-gradient(45deg, #e9ebf0 25%, transparent 25%, transparent 75%, #e9ebf0 75%), linear-gradient(45deg, #e9ebf0 25%, transparent 25%, transparent 75%, #e9ebf0 75%); background-size: 20px 20px; background-position: 0 0, 10px 10px; }
.sig-card canvas { display: block; max-width: 100%; height: auto; }

/* ----- Windows ----- */
.dialog { margin: auto; border: 1px solid var(--surface-border); border-radius: 20px; padding: 0; width: min(560px, calc(100vw - 16px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35); }
.dialog.wide { width: min(760px, calc(100vw - 16px)); }
.dialog::backdrop { background: rgba(10, 10, 20, 0.6); backdrop-filter: blur(6px); }
.dialog[open] { animation: pop 0.2s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(10px); } }
.dialog-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; margin: 0; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-head h2 { margin: 0; font-size: 1.2rem; color: var(--text-strong); }
.dialog-head .icon-btn { border-radius: 50%; }
.help p { max-width: 75ch; color: var(--text-2); margin: 0; }
.help h3 { font-size: 1rem; margin: 6px 0 0; color: var(--text-strong); }
.help a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
.stage:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.examples { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; color: var(--text-2); }
.cheat { border-collapse: collapse; font-size: 0.9rem; width: 100%; }
.cheat td { padding: 7px 8px 7px 0; border-bottom: 1px solid var(--surface-border); vertical-align: top; color: var(--text-2); }
.cheat td:first-child { white-space: nowrap; width: 1%; padding-right: 16px; }
.keys { display: grid; gap: 6px; margin: 0; }
.keys div { display: flex; gap: 12px; }
.keys dt { min-width: 9rem; }
.keys dd { margin: 0; color: var(--text-2); }

/* ----- Toasts ----- */
.toasts { position: fixed; bottom: 24px; right: 24px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; max-width: calc(100vw - 32px); pointer-events: none; }
.toast { pointer-events: auto; background: #0a0a14; color: #fff; border: 1px solid rgba(255, 255, 255, 0.12); border-left: 4px solid var(--brand); border-radius: 14px; padding: 12px 16px; display: flex; align-items: center; gap: 14px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3); min-width: 260px; max-width: 420px; font-size: 0.875rem; font-weight: 500; overflow-wrap: anywhere; animation: slideIn 0.3s ease; transition: opacity 0.3s ease, transform 0.3s ease; }
.toast button { background: none; border: 0; padding: 0; color: #c4b5fd; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; white-space: nowrap; min-height: 32px; flex: none; }
.toast.leaving { opacity: 0; transform: translateX(40px); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ----- Information sections ----- */
.info-section { margin: 0 0 2.5rem; }
.info-section h2 { font-size: 1.75rem; margin: 0 0 1.25rem; }
.info-section .info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.info-three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 1rem 0 1.5rem; }
.info-stack { display: grid; gap: 12px; }
.info-card { background: var(--surface); border: 1px solid var(--surface-border); border-radius: 16px; box-shadow: var(--surface-shadow); padding: 20px; transition: transform 0.3s ease, box-shadow 0.3s ease; }
.info-card:hover { transform: translateY(-4px); box-shadow: var(--surface-hover-shadow); }
.info-card--small { padding: 16px; box-shadow: none; }
.info-card h3 { margin: 0 0 0.75rem; font-size: 1.15rem; }
.info-card p { color: var(--text-2); margin-bottom: 0.75rem; }
.info-card p:last-child { margin-bottom: 0; }
.step-card { position: relative; padding-top: 24px; }
.step-num { position: absolute; top: -16px; left: 20px; width: 34px; height: 34px; border-radius: 50%; background: var(--gradient-brand); color: #fff; font-weight: 700; font-size: 0.95rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3); }
.step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 0.75rem; }
.step-head h3 { margin: 0; }
.step-emoji { font-size: 1.6rem; line-height: 1; }
.info-section details.info-card { padding: 0; }
.info-section details.info-card summary { cursor: pointer; padding: 16px 20px; font-weight: 600; color: var(--text-strong); list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.info-section details.info-card summary::-webkit-details-marker { display: none; }
.info-section details.info-card summary::after { content: '+'; color: var(--link); font-weight: 700; font-size: 1.2rem; line-height: 1; flex-shrink: 0; }
.info-section details.info-card[open] summary::after { content: '\2212'; }
.info-section details.info-card p { padding: 0 20px 16px; margin: 0; }

/* ----- Phones and tablets ----- */
@media (max-width: 1023.98px) and (min-width: 640px) {
    .info-section .info-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 639px) {
    .app-hero { margin-bottom: 1.5rem; }
    .app-tagline { font-size: 1rem; }
    .app-toolbar { gap: 10px; }
    /* five tabs at 16 px do not fit one row on a phone: three, then two */
    .app-toolbar .view-tabs { width: 100%; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); overflow: visible; border-radius: 24px; }
    .app-toolbar .view-tab { grid-column: span 2; padding: 8px 6px; gap: 5px; min-width: 0; }
    .app-toolbar .view-tab:nth-child(n+4) { grid-column: span 3; }
    .toolbar-right { width: 100%; }
    .toolbar-right .btn { flex: 1 1 auto; }
    .toasts { bottom: 16px; right: 16px; left: 16px; align-items: stretch; }
    .toast { min-width: 0; max-width: none; }
    .dialog-body { padding: 16px; }
    .info-section h2 { font-size: 1.4rem; }
    .info-section .info-grid, .info-three { grid-template-columns: 1fr; }
    .info-card { padding: 16px; }
    .step-num { left: 16px; }
    /* five pens: three, then two, every row full */
    .pens { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .pens .pick { grid-column: span 2; }
    .pens .pick:nth-child(n+4) { grid-column: span 3; }
    .cheat td:first-child { white-space: normal; }
}
@media (max-width: 459px) {
    .view-tab .ico { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .btn, .info-card, .dialog, .dialog[open], .toast, .seg button, .chip, .view-tab, .hand, .pick, .swatch, .tool { transition: none; animation: none; }
    .btn:hover:not([disabled]), .info-card:hover, .hand:hover, .pick:hover, .swatch:hover, .seg button:hover:not([disabled]), .chip:hover { transform: none; }
}
@media print {
    .app-toolbar, .controls, .pv-bar, .thumbs, .toasts, .theme-toggle, .shell-hint { display: none !important; }
    .stage { background: none; padding: 0; overflow: visible; }
    .sheet canvas { box-shadow: none; }
}
/* Phones: 16 px text, 44 px tap targets (AdSense audit H-04, 8 Oct 2026). The pages, the tiles' pictures and the pad are drawings. */
@media (max-width: 639.98px) {
    main button, main select, main summary, main [role="button"], main label.btn,
    main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="range"]):not([type="color"]) { min-height: 44px; }
    main .seg button, main .view-tab, main .chip, main .btn.small-btn, main .select-sm { min-height: 44px; }
    main .icon-btn, main .tool { width: 44px; height: 44px; min-width: 44px; }
    main input[type="range"] { min-height: 44px; }
    main .swatch { width: 44px; height: 44px; }
    main .check-row input { width: 22px; height: 22px; }
    main .seg button { min-width: 44px; }
    main .check-row { min-height: 44px; align-items: center; }
    main .thumb { min-width: 44px; }
    main :is(p, li, dt, dd, .hint, .label, .val, .input, .select, .textarea, kbd, .seg button, .chip, .lead, .btn, .view-tab, .shell-hint, .page-info, .pick span, .hand-name, legend, .check-row) { font-size: 1rem; }
    .dialog button, .dialog .btn { min-height: 44px; }
    .dialog .icon-btn { width: 44px; height: 44px; }
    .dialog :is(p, li, td, kbd, dt, dd, .btn) { font-size: 1rem; }
    .menu button { min-height: 44px; font-size: 1rem; }
}
