/* Подпись и печать на PDF — single stylesheet.
   Layout: header / workspace (panel with three steps + document viewer).
   Mobile (<768px): viewer on top, the open step below; only one step at a time. */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --viewer-bg: #e9ecf0;
    --text: #1d2330;
    --muted: #5d6576;
    --faint: #8b93a3;
    --line: #dfe3ea;
    --line-strong: #c7cdd8;
    --accent: #2350c8;
    --accent-hover: #1b40a6;
    --accent-soft: #e8eefc;
    --ok: #1d7a46;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --radius: 10px;
    --radius-sm: 7px;
    --panel-w: 380px;
    --focus: 0 0 0 3px rgba(35, 80, 200, .35);
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 8px rgba(16, 24, 40, .06);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text);
    -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
    background: var(--bg);
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
    font-size: 15px;
    line-height: 1.45;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
svg { flex: none; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; margin: -1px; padding: 0; border: 0;
}
.skip-link {
    position: absolute; left: 8px; top: -48px; z-index: 3000;
    background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm);
    box-shadow: var(--shadow); color: var(--accent);
}
.skip-link:focus { top: 8px; }
:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---------- header ---------- */
.app-header {
    flex: none;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.app-header h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.01em; }
.app-header__sub {
    margin: 3px 0 0; color: var(--muted); font-size: 14px;
    display: flex; align-items: center; gap: 6px;
}
.app-header__sub svg { color: var(--ok); }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.app-header__link { flex: none; color: var(--accent); text-decoration: none; font-weight: 500; font-size: 14px; padding: 8px 0; }
.app-header__link:hover { text-decoration: underline; }
.empty-state__more { display: none; margin: 20px 0 0; font-size: 14px; }
.empty-state__more a { color: var(--accent); }

/* ---------- workspace ---------- */
.workspace {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: var(--panel-w) 1fr;
}
.panel {
    background: var(--surface);
    border-right: 1px solid var(--line);
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
}

/* ---------- stepper ---------- */
.stepper {
    list-style: none; margin: 0; padding: 10px 12px;
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
    position: sticky; top: 0; z-index: 2;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.stepper__tab {
    width: 100%; min-height: 40px;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 6px 6px; border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--muted);
    font-size: 13px; font-weight: 550; line-height: 1.15; text-align: left;
    cursor: pointer;
}
.stepper__tab:hover { background: var(--bg); }
.stepper__num, .step__num {
    width: 22px; height: 22px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    font-size: 12px; font-weight: 700;
    border: 1.5px solid var(--line-strong); color: var(--muted); background: var(--surface);
}
.stepper__tab.is-current { color: var(--text); }
.stepper__tab.is-current .stepper__num { border-color: var(--accent); color: var(--accent); }
.stepper__tab.is-done .stepper__num { background: var(--accent); border-color: var(--accent); color: transparent; position: relative; }
.stepper__tab.is-done .stepper__num::after {
    content: ''; position: absolute; width: 9px; height: 5px; top: 6px; left: 5.5px;
    border: solid #fff; border-width: 0 0 2px 2px; transform: rotate(-45deg);
}

/* ---------- steps ---------- */
.steps { padding: 4px 0 24px; }
.step { padding: 18px 20px 20px; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.step__title {
    margin: 0 0 4px; font-size: 16px; font-weight: 650;
    display: flex; align-items: center; gap: 10px;
}
.step.is-current .step__num { border-color: var(--accent); color: var(--accent); }
.step__hint { margin: 0 0 14px; color: var(--muted); font-size: 14px; min-height: 1.45em; }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 40px; padding: 8px 16px;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    background: var(--bg); color: var(--text);
    font-weight: 550; font-size: 15px; line-height: 1.2;
    cursor: pointer; text-decoration: none;
    transition: background-color .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; font-size: 17px; border-radius: var(--radius); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 14px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--accent-hover); }
.btn-secondary { background: var(--accent-soft); color: var(--accent); }
.btn-secondary:not(:disabled):hover { background: #dbe4fa; }
.btn-outline { background: var(--surface); border-color: var(--line-strong); }
.btn-outline:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:not(:disabled):hover { background: var(--bg); color: var(--text); }
.btn-link { background: none; color: var(--accent); padding-left: 0; padding-right: 0; min-height: 36px; font-weight: 500; }
.btn-link:not(:disabled):hover { text-decoration: underline; }
.btn[aria-busy="true"] { cursor: progress; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }
.step > .btn + .btn, .step > .btn-block { margin-top: 10px; }
.step > #addTextBtn { margin-top: 6px; }
#step-2 .btn-link { min-height: 44px; }

.icon-btn {
    width: 38px; height: 38px; border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--text);
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:not(:disabled):hover { background: var(--bg); }
.icon-btn:disabled { opacity: .35; cursor: default; }

/* ---------- step 1: dropzone ---------- */
.dropzone {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 18px 16px; text-align: center;
    border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
    background: var(--bg); color: var(--muted); cursor: pointer;
    transition: border-color .15s, background-color .15s;
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone svg { color: var(--accent); }
.dropzone__title { color: var(--accent); font-weight: 650; font-size: 16px; }
.dropzone__note { font-size: 13px; }
.doc-info {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 10px 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
}
.doc-info > svg { color: var(--accent); }
.doc-info__text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.doc-info__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-info__meta { color: var(--muted); font-size: 13px; }

/* ---------- step 2: library ---------- */
.checker {
    background-color: #fff;
    background-image:
        linear-gradient(45deg, #f0f2f5 25%, transparent 25%, transparent 75%, #f0f2f5 75%),
        linear-gradient(45deg, #f0f2f5 25%, transparent 25%, transparent 75%, #f0f2f5 75%);
    background-size: 12px 12px;
    background-position: 0 0, 6px 6px;
}
.library { display: grid; gap: 12px; margin-bottom: 12px; }
.library__title { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: none; }
.library__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.asset { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.asset--empty {
    color: var(--faint); font-size: 13px; padding: 10px 12px;
    border: 1px dashed var(--line); border-radius: var(--radius-sm); width: 100%;
}
.asset__place {
    width: 96px; height: 68px; padding: 6px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: border-color .15s, box-shadow .15s;
}
.asset__place img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.asset__place:hover { border-color: var(--accent); }
.asset--last .asset__place { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.asset__del {
    position: absolute; top: -7px; right: -7px;
    width: 24px; height: 24px; border-radius: 50%;
    border: 1px solid var(--line); background: var(--surface); color: var(--muted);
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
    opacity: 0; transition: opacity .15s;
}
.asset:hover .asset__del, .asset:focus-within .asset__del { opacity: 1; }
.asset__del:hover { color: var(--danger); border-color: var(--danger); }
.asset__del::after { content: ''; position: absolute; inset: -10px; } /* 44 px touch target, 24 px look */
@media (hover: none) { .asset__del { opacity: 1; } }
.asset__set { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); cursor: pointer; }
.asset__set input { margin: 0; accent-color: var(--accent); }
.library__note { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.library-transfer { display: flex; flex-wrap: wrap; align-items: center; gap: 0 16px; margin-top: 6px; }
.library-transfer__note { flex-basis: 100%; font-size: 12px; line-height: 1.4; color: var(--muted); margin: 0; }

/* adding: two buttons, one line of advice, draw + tips */
.add-ink { margin-top: 12px; }
.step > .btn + .add-ink, .step > .library + .add-ink { margin-top: 12px; }
.add-ink__buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.add-ink__buttons .btn { min-height: 48px; padding: 8px 6px; line-height: 1.15; }
.add-ink__hint { margin: 8px 0 0; font-size: 13px; line-height: 1.4; color: var(--muted); }
.add-ink__more { display: flex; flex-direction: column; align-items: flex-start; margin-top: 2px; }
.add-ink__more > .btn-link { min-height: 44px; }
.tips { width: 100%; }
.tips summary {
    display: flex; align-items: center; gap: 6px; min-height: 44px;
    cursor: pointer; color: var(--accent); font-size: 14px; font-weight: 500;
    list-style: none; border-radius: 4px;
}
.tips summary::-webkit-details-marker { display: none; }
.tips summary::before {
    content: ''; width: 7px; height: 7px; flex: none; margin: 0 3px 0 2px;
    border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(-45deg);
    transition: transform .15s;
}
.tips[open] summary::before { transform: rotate(45deg); }
.tips summary:hover { text-decoration: underline; }
.tips__list { margin: 0; padding: 0 0 0 20px; font-size: 14px; display: grid; gap: 3px; }
.tips__stamp { margin: 6px 0 4px; font-size: 14px; color: var(--muted); }

/* after upload: three cut-outs to choose from */
.ink-confirm {
    border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
    display: grid; gap: 12px; margin-top: 12px; min-width: 0;
}
.ink-confirm__status { margin: 0; color: var(--muted); font-size: 14px; }
.ink-variants { border: 0; margin: 0; padding: 0; min-width: 0;
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ink-variants__legend { float: left; width: 100%; padding: 0; margin: 0 0 8px; font-size: 14px; font-weight: 600; grid-column: 1 / -1; }
.ink-variant { position: relative; display: flex; min-width: 0; }
.ink-variant input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.ink-variant__card {
    flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding: 4px 4px 6px;
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface);
    text-align: center; transition: border-color .15s, box-shadow .15s;
}
.ink-variant input:checked + .ink-variant__card { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--accent-soft); }
.ink-variant input:focus-visible + .ink-variant__card { box-shadow: 0 0 0 1px var(--accent), var(--focus); }
.ink-variant input:disabled + .ink-variant__card { opacity: .6; }
.ink-variant__img, .ink-variant__doc {
    height: 58px; border-radius: 5px; border: 1px solid var(--line);
    display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 3px;
}
.ink-variant__img img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.ink-variant__doc { position: relative; background: #fff; align-items: flex-start; justify-content: flex-start; }
.ink-variant__text {
    font: 8.5px/1.25 Georgia, 'Times New Roman', serif; color: #222; text-align: left;
    overflow-wrap: anywhere;
}
.ink-variant__doc img {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    max-width: 92%; max-height: 92%; object-fit: contain;
}
.ink-variant__name { font-size: 13px; font-weight: 650; line-height: 1.2; }
.ink-variant__note { font-size: 11.5px; color: var(--muted); line-height: 1.2; }
.ink-variant input:checked + .ink-variant__card .ink-variant__name { color: var(--accent); }
.ink-issues {
    list-style: none; margin: 0; padding: 8px 10px; display: grid; gap: 4px;
    border-radius: var(--radius-sm); background: #fff6e5; border-left: 3px solid #c77700;
    font-size: 13.5px; line-height: 1.35; color: #5c3b00;
}
.ink-kind span { min-height: 40px; }
.ink-confirm__actions, .draw-pad__actions { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.ink-confirm__actions .btn, .draw-pad__actions .btn { min-height: 44px; padding: 8px 10px; min-width: 0; }

/* focus moves into these after processing: keep them clear of the sticky stepper */
.ink-confirm, .draw-pad, .ink-variant input, .draw-pad__title { scroll-margin-top: 96px; scroll-margin-bottom: 24px; }

/* draw a signature */
.draw-pad { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; margin-top: 12px; }
.draw-pad__title { margin: 0; font-size: 14px; font-weight: 600; outline: none; }
.draw-pad__frame { position: relative; max-width: 600px; }
.draw-pad__canvas {
    display: block; width: 100%; aspect-ratio: 5 / 2;
    background: #fff; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
    touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none;
}
.draw-pad__line { position: absolute; left: 8%; right: 8%; bottom: 24%; border-bottom: 1px solid var(--line); pointer-events: none; }
.draw-pad__title:focus { box-shadow: none; }

/* segmented control (radio pills) */
.segmented { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.segmented legend { font-size: 13px; color: var(--muted); padding: 0; margin-bottom: 6px; width: 100%; float: left; }
.segmented legend + * { clear: left; }
.segmented label { position: relative; flex: 1 1 0; min-width: 0; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
    display: flex; align-items: center; justify-content: center;
    min-height: 36px; padding: 6px 10px; border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong); background: var(--surface);
    font-size: 14px; white-space: nowrap; cursor: pointer;
}
.segmented input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.segmented input:focus-visible + span { box-shadow: var(--focus); }
.segmented:disabled { opacity: .5; }
/* labels of different length (e.g. «Вид скана»): wider labels get more room, and wrap rather than clip */
/* long labels: three equal columns, text wraps inside the pill instead of the row wrapping */
/* four looks: a 2×2 grid, so each pill keeps its label on one or two lines even at 390 px */
.segmented--fit { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.segmented--fit legend { grid-column: 1 / -1; margin-bottom: 0; } /* floated legend is a grid item: span the row */
.segmented--fit label { display: flex; }
.segmented--fit span { flex: 1; display: flex; align-items: center; justify-content: center;
    white-space: normal; text-align: center; line-height: 1.15; padding: 6px 4px; }

/* ---------- step 3: export ---------- */
.export-progress { margin-top: 12px; }
.progress { height: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; border: 1px solid var(--line); }
.progress__fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.export-progress__row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; font-size: 14px; color: var(--muted); }
.server-confirm, .error-message {
    margin: 12px 0 0; padding: 12px; border-radius: var(--radius); font-size: 14px;
}
.server-confirm { background: var(--accent-soft); }
.server-confirm p { margin: 0 0 10px; }
.error-message { background: var(--danger-soft); color: var(--danger); }

.settings { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 8px; }
.settings summary {
    cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 550;
    padding: 6px 0; list-style-position: inside; border-radius: 4px;
}
.settings summary:hover { color: var(--text); }
.settings__body { display: grid; gap: 14px; padding-top: 8px; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { margin: 2px 0 0; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.check input:disabled + span { opacity: .5; }

.only-mobile { display: none; }

/* ---------- viewer ---------- */
.viewer { position: relative; min-width: 0; min-height: 0; background: var(--viewer-bg); display: flex; flex-direction: column; }
.viewer__toolbar {
    position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 5;
    display: flex; align-items: center; gap: 2px; padding: 4px;
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
}
.viewer__sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.canvas-scroll {
    flex: 1; min-height: 0; overflow: auto;
    -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    display: flex; justify-content: center; align-items: flex-start;
    position: relative;
}
.pages-container {
    display: flex; flex-direction: column; align-items: center; gap: 34px;
    padding: 64px 20px 40px;
    transform-origin: center top;
}
body[data-doc="empty"] .pages-container,
body[data-doc="error"] .pages-container { padding-top: 40px; min-height: 100%; justify-content: center; }

.empty-state { display: none; max-width: 440px; width: 100%; text-align: center; color: var(--muted); }
body[data-doc="empty"] .empty-state,
body[data-doc="error"] .empty-state { display: block; }
.empty-state__drop {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 44px 24px; border-radius: 14px;
    border: 2px dashed var(--line-strong); background: rgba(255, 255, 255, .6);
    cursor: pointer; transition: border-color .15s, background-color .15s;
}
.empty-state__drop:hover { border-color: var(--accent); background: #fff; }
.empty-state__drop svg { color: var(--accent); margin-bottom: 4px; }
.empty-state__drop strong { color: var(--text); font-size: 17px; }
.empty-state__how { text-align: left; margin: 24px auto 0; padding-left: 22px; font-size: 14px; display: grid; gap: 6px; max-width: 360px; }

/* pages created by the editor */
.page-wrapper {
    position: relative; background: #fff;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .12), 0 4px 14px rgba(16, 24, 40, .08);
    outline: none;
}
.page-wrapper.active { box-shadow: 0 0 0 2px var(--accent), 0 4px 14px rgba(16, 24, 40, .1); }
.page-wrapper:focus-visible { box-shadow: var(--focus); }
.page-wrapper canvas { display: block; max-width: 100%; touch-action: pan-y; }
.page-label {
    position: absolute; top: -22px; left: 0;
    font-size: 12px; color: var(--muted); pointer-events: none;
}

.loading-overlay {
    position: absolute; inset: 0; z-index: 20;
    background: rgba(233, 236, 240, .75);
    display: flex; align-items: center; justify-content: center;
}
.loading-overlay__box {
    display: flex; align-items: center; gap: 12px;
    background: var(--surface); padding: 14px 20px; border-radius: var(--radius); box-shadow: var(--shadow);
    font-size: 15px;
}
.spinner {
    width: 22px; height: 22px; border-radius: 50%;
    border: 3px solid var(--line); border-top-color: var(--accent);
    animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- global overlays ---------- */
.drop-veil {
    position: fixed; inset: 10px; z-index: 2500; pointer-events: none;
    border: 3px dashed var(--accent); border-radius: 18px;
    background: rgba(232, 238, 252, .7);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 650; color: var(--accent);
}
.toast {
    position: fixed; left: 50%; bottom: 24px; z-index: 2600;
    transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
    max-width: min(560px, calc(100vw - 32px));
    padding: 10px 16px; border-radius: var(--radius);
    background: #1d2330; color: #fff; font-size: 14px; box-shadow: var(--shadow);
    transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

/* ---------- tablet ---------- */
@media (max-width: 1023.98px) {
    :root { --panel-w: 330px; }
    .step { padding: 16px; }
}

/* ---------- mobile ---------- */
@media (max-width: 767.98px) {
    body { font-size: 15px; }
    .app-header { padding: 10px 16px; }
    .app-header__link { display: none; }
    .empty-state__more { display: block; }
    .app-header h1 { font-size: 16px; }
    .app-header__sub { font-size: 13px; }

    .workspace { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
    .viewer { grid-row: 1; }
    .panel {
        grid-row: 2; border-right: 0; border-top: 1px solid var(--line);
        max-height: 50dvh;
        box-shadow: 0 -6px 18px rgba(16, 24, 40, .08);
        padding-bottom: env(safe-area-inset-bottom);
    }
    /* No document yet: the panel is the whole screen */
    body[data-doc="empty"] .viewer, body[data-doc="error"] .viewer { display: none; }
    body[data-doc="empty"] .workspace, body[data-doc="error"] .workspace { grid-template-rows: auto; }
    body[data-doc="empty"] .panel, body[data-doc="error"] .panel { grid-row: 1; max-height: none; box-shadow: none; border-top: 0; }

    .stepper { padding: 8px; }
    .stepper__tab { font-size: 12.5px; flex-direction: column; gap: 3px; text-align: center; min-height: 48px; }
    .stepper__tab[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
    .step { display: none; padding: 14px 16px 18px; border-bottom: 0; }
    .step.is-open { display: flex; flex-direction: column; }
    .step.is-open > .btn { align-self: stretch; }
    .step.is-open > .btn-link { align-self: flex-start; }
    #toExportBtn { order: -1; margin: 0 0 12px; }
    #step-2 .step__hint { order: -3; }
    #step-2 .library, #step-2 .library__note { order: -2; }
    .step__title { display: none; }
    .only-mobile { display: inline-flex; }
    .dropzone { padding: 32px 16px; }

    .pages-container { padding: 64px 10px 24px; gap: 30px; }
    .viewer__toolbar { top: 8px; }
    .asset__place { width: 88px; height: 62px; }
    .toast { bottom: calc(50dvh + 12px); }
    body[data-doc="empty"] .toast { bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
    .btn, .segmented span, .asset__place, .dropzone, .ink-variant__card { border: 1px solid CanvasText; }
    .ink-variant input:checked + .ink-variant__card { outline: 3px solid Highlight; }
    .stepper__tab[aria-selected="true"] { outline: 2px solid Highlight; }
}
