/* Brickline Sign — design system. WCAG 2.1 AA colors in both themes. */
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-var.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Atkinson Hyperlegible'; src: url('/fonts/AtkinsonHyperlegible-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson Hyperlegible'; src: url('/fonts/AtkinsonHyperlegible-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Dancing Script'; src: url('/fonts/DancingScript-600.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Great Vibes'; src: url('/fonts/GreatVibes-400.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Caveat'; src: url('/fonts/Caveat-600.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Allura'; src: url('/fonts/Allura-400.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Sacramento'; src: url('/fonts/Sacramento-400.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Homemade Apple'; src: url('/fonts/HomemadeApple-400.woff2') format('woff2'); font-display: swap; }

@font-face { font-family: 'Inter'; src: url('/fonts/Inter-var-cyrillic.woff2') format('woff2'); font-weight: 100 900; font-display: swap; unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Caveat'; src: url('/fonts/Caveat-cyrillic.woff2') format('woff2'); font-display: swap; unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Great Vibes'; src: url('/fonts/GreatVibes-cyrillic.woff2') format('woff2'); font-display: swap; unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Marck Script'; src: url('/fonts/MarckScript-latin.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Marck Script'; src: url('/fonts/MarckScript-cyrillic.woff2') format('woff2'); font-display: swap; unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Bad Script'; src: url('/fonts/BadScript-latin.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Bad Script'; src: url('/fonts/BadScript-cyrillic.woff2') format('woff2'); font-display: swap; unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }

:root {
  --scale: 1;
  --bg: #f6f7fb; --bg2: #ffffff; --surface: #ffffff; --surface2: #eef0f7; --border: #d5d9e6;
  --text: #121527; --muted: #4a5068; --brand: #4338ca; --brand-2: #7c3aed; --brand-ink: #ffffff;
  --ok: #0f7a4f; --warn: #9a5b00; --bad: #b42318; --info: #0b67a6;
  --ok-bg: #e3f6ec; --warn-bg: #fff4dc; --bad-bg: #fde8e6; --info-bg: #e2f0fb;
  --focus: #f59e0b; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.08);
  --radius: 14px; --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --lh: 1.55;
  color-scheme: light;
}
[data-theme='dark'] {
  --bg: #0c0e1a; --bg2: #111427; --surface: #161a30; --surface2: #1e2340; --border: #343b63;
  --text: #eef0fb; --muted: #b3b8d4; --brand: #8b8cff; --brand-2: #c084fc; --brand-ink: #0c0e1a;
  --ok: #4ade80; --warn: #fbbf24; --bad: #f87171; --info: #60a5fa;
  --ok-bg: #0f2c1e; --warn-bg: #33270b; --bad-bg: #3a1414; --info-bg: #0e2640;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}
[data-contrast='high'] { --border: #000; --muted: #1d2033; --brand: #2a1fa8; }
[data-theme='dark'][data-contrast='high'] { --border: #fff; --muted: #e6e8f5; --brand: #b5b6ff; --bg: #000; --surface: #000; --surface2: #111; }
[data-font='readable'] { --font: 'Atkinson Hyperlegible', 'Inter', system-ui, sans-serif; }
[data-spacing='wide'] { --lh: 1.9; letter-spacing: .02em; word-spacing: .08em; }
[data-links='underline'] a { text-decoration: underline !important; }
[data-motion='reduce'] *, [data-motion='reduce'] *::before, [data-motion='reduce'] *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

html { font-size: calc(100% * var(--scale)); -webkit-text-size-adjust: 100%; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: var(--lh); font-size: 1rem; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--brand); }
a:hover { text-decoration: underline; }
img, svg, canvas { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); letter-spacing: -.02em; }
h2 { font-size: 1.45rem; letter-spacing: -.01em; }
h3 { font-size: 1.12rem; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--brand); color: var(--brand-ink); padding: 10px 16px; border-radius: 8px; z-index: 1000; font-weight: 700; }
.skip:focus { top: 8px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; font-size: .85rem; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }
.center { text-align: center; }
.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }

/* Buttons & inputs (44px targets) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 650; cursor: pointer; text-decoration: none !important; transition: transform .08s, background .15s, border-color .15s; }
.btn:hover { border-color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-color: transparent; }
[data-theme='dark'] .btn.primary { color: #0c0e1a; }
.btn.danger { color: var(--bad); border-color: currentColor; background: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface2); }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.btn.lg { min-height: 54px; padding: 14px 26px; font-size: 1.08rem; }
.btn.block { width: 100%; }
.icon { width: 1.25em; height: 1.25em; flex: none; }
label { font-weight: 600; display: block; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg2); color: var(--text); font: inherit; }
textarea { min-height: 96px; resize: vertical; }
.input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 3px solid color-mix(in srgb, var(--focus) 70%, transparent); outline-offset: 1px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; cursor: pointer; }
.check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--brand); flex: none; }
.hint { color: var(--muted); font-size: .875rem; margin-top: 4px; }
.err { color: var(--bad); font-weight: 600; }

/* Cards, badges */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--surface2); color: var(--text); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--info-bg); color: var(--text); border-left: 4px solid var(--info); }
.notice.warn { background: var(--warn-bg); border-color: var(--warn); }
.notice.ok { background: var(--ok-bg); border-color: var(--ok); }
.notice.bad { background: var(--bad-bg); border-color: var(--bad); }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg2) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar .wrap { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none !important; letter-spacing: -.01em; }
.logo-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); display: grid; place-items: center; color: #fff; }
.nav-links { display: flex; gap: 4px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav-links a:not(.btn) { padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 600; }
.nav-links a:not(.btn):hover { background: var(--surface2); }

/* Footer + Brickline badge (static, separated from controls) */
footer.site { margin-top: auto; border-top: 1px solid var(--border); background: var(--bg2); padding: 28px 0 36px; font-size: .9rem; }
footer.site .wrap { display: flex; flex-wrap: wrap; gap: 18px 28px; align-items: center; justify-content: space-between; }
footer.site nav { display: flex; flex-wrap: wrap; gap: 6px 16px; }
footer.site nav a { color: var(--muted); padding: 6px 2px; }
.bw-badge { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted) !important; padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; text-decoration: none !important; margin: 8px 0; }
.bw-badge:hover { color: var(--text) !important; }

/* Accessibility menu */
.a11y-btn { position: fixed; right: 16px; bottom: 16px; z-index: 90; width: 52px; height: 52px; border-radius: 50%; border: 2px solid #fff; background: #1e3a8a; color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow); }
.has-tabbar .a11y-btn { bottom: 88px; }
.a11y-panel { position: fixed; right: 16px; bottom: 80px; z-index: 95; width: min(360px, calc(100vw - 32px)); max-height: calc(100vh - 110px); overflow: auto; }
.has-tabbar .a11y-panel { bottom: 152px; max-height: calc(100vh - 180px); }
.seg { display: flex; border: 1.5px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; min-height: 44px; padding: 0 10px; white-space: nowrap; border: 0; background: var(--surface); color: var(--text); font: inherit; font-weight: 650; cursor: pointer; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed='true'] { background: var(--brand); color: #fff; }
[data-theme='dark'] .seg button[aria-pressed='true'] { color: #0c0e1a; }

/* Modal & toasts */
.modal-back { position: fixed; inset: 0; background: rgba(8,10,20,.55); z-index: 200; display: grid; place-items: center; padding: 16px; }
.modal { width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 18px; border: 1px solid var(--border); box-shadow: var(--shadow); padding: 22px; }
.modal.wide { width: min(900px, 100%); }
.modal header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.modal header h2 { margin: 0; flex: 1; }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 300; display: flex; flex-direction: column; gap: 8px; width: min(520px, calc(100vw - 32px)); }
.toast { background: #111527; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600; }
.toast.bad { background: #9f1c12; }
.toast.ok { background: #0d6b45; }

/* App shell */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: calc(100vh - 64px); }
.side { border-right: 1px solid var(--border); background: var(--bg2); padding: 16px 12px; position: sticky; top: 64px; height: calc(100vh - 64px); overflow: auto; }
.side a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: var(--text); text-decoration: none !important; font-weight: 600; min-height: 44px; }
.side a:hover { background: var(--surface2); }
.side a[aria-current='page'] { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
.side .sect { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 16px 12px 6px; font-weight: 700; }
.main { padding: 24px clamp(14px, 3vw, 36px) 120px; min-width: 0; }
.tabbar { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 60; background: var(--bg2); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .72rem; font-weight: 700; color: var(--muted); text-decoration: none !important; padding: 6px 2px; min-height: 52px; border-radius: 10px; }
  .tabbar a[aria-current='page'] { color: var(--brand); }
  .tabbar a.new { color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2)); margin: 0 4px; }
}
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 1.7rem; margin: 0; flex: 1; }
.stat { padding: 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); text-decoration: none !important; color: var(--text); display: block; }
.stat b { display: block; font-size: 1.9rem; line-height: 1.1; }
.stat span { color: var(--muted); font-weight: 600; font-size: .9rem; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip { border: 1.5px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 8px 14px; font: inherit; font-weight: 650; cursor: pointer; white-space: nowrap; min-height: 40px; }
.chip[aria-pressed='true'] { background: var(--brand); border-color: var(--brand); color: #fff; }
[data-theme='dark'] .chip[aria-pressed='true'] { color: #0c0e1a; }
.list { display: flex; flex-direction: column; gap: 10px; }
.item { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none !important; }
.item:hover { border-color: var(--brand); }
.item .t { font-weight: 700; }
.doc-ico { width: 42px; height: 52px; border-radius: 6px; background: var(--surface2); border: 1px solid var(--border); display: grid; place-items: center; flex: none; color: var(--brand); }
.progress { height: 8px; border-radius: 99px; background: var(--surface2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }

/* Wizard */
.steps { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; counter-reset: st; padding: 0; list-style: none; }
.steps li { flex: 1 1 120px; padding: 10px 12px; border-radius: 10px; background: var(--surface2); font-weight: 700; color: var(--muted); font-size: .9rem; }
.steps li[aria-current='step'] { background: var(--brand); color: #fff; }
[data-theme='dark'] .steps li[aria-current='step'] { color: #0c0e1a; }
.steps li.done { color: var(--ok); }
.drop { border: 2.5px dashed var(--border); border-radius: 16px; padding: 36px 16px; text-align: center; background: var(--surface); cursor: pointer; }
.drop.over { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--surface)); }
.signer-row { display: grid; grid-template-columns: 34px 1fr 1fr auto; gap: 10px; align-items: end; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
@media (max-width: 700px) { .signer-row { grid-template-columns: 34px 1fr; } .signer-row .r-actions { grid-column: 1 / -1; } }
.order-num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; }

/* Editor */
.editor { display: grid; grid-template-columns: 240px 1fr 260px; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .editor { grid-template-columns: 1fr; } .palette { position: static !important; } }
.palette { position: sticky; top: 80px; }
/* short desktop windows (e.g. 1280x800): keep every field type (Checkbox…) and the zoom buttons reachable above the sticky Back/Next bar */
@media (min-width: 1101px) { .palette { max-height: calc(100vh - 170px); overflow-y: auto; overscroll-behavior: contain; } }
.palette .ftype { display: flex; align-items: center; gap: 10px; width: 100%; margin-bottom: 6px; justify-content: flex-start; cursor: grab; touch-action: none; }
@media (max-width: 1100px) { .palette .ftypes { display: flex; gap: 6px; overflow-x: auto; } .palette .ftype { width: auto; flex: none; } }
.pages { display: flex; flex-direction: column; align-items: center; gap: 40px; min-width: 0; padding-top: 28px; }
.page-wrap { position: relative; box-shadow: var(--shadow); background: #fff; width: 100%; max-width: var(--page-max, 860px); border-radius: 4px; }
.page-wrap canvas { display: block; width: 100%; height: auto; border-radius: 4px; }
.page-label { position: absolute; left: -2px; top: -26px; font-size: .78rem; color: var(--muted); font-weight: 700; }
.fbox { position: absolute; border: 2px solid var(--c, #4f46e5); background: color-mix(in srgb, var(--c, #4f46e5) 16%, transparent); border-radius: 5px; color: #111; font-size: clamp(9px, 1.25vw, 13px); font-weight: 700; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; user-select: none; cursor: move; text-align: center; line-height: 1.1; padding: 1px; }
.fbox.sel { outline: 3px solid var(--focus); outline-offset: 1px; z-index: 3; }
.fbox .rs { position: absolute; right: -2px; bottom: -2px; width: 16px; height: 16px; background: var(--c, #4f46e5); cursor: nwse-resize; border-radius: 4px 0 4px 0; }
.fbox img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }
.fbox.req::after { content: '*'; position: absolute; top: -2px; right: 3px; color: var(--bad); font-size: 14px; }
.fbox.ro { pointer-events: none; cursor: default; border-style: dashed; background: rgba(255,255,255,.4); }
.fbox.mine { cursor: pointer; animation: pulse 2s infinite; }
.fbox.filled { animation: none; background: rgba(255,255,255,.2); border-style: solid; }
.fbox input.ftext { width: 100%; height: 100%; border: 0; background: transparent; font: inherit; color: #111; padding: 0 4px; font-weight: 600; }
.fbox input.ftext:focus { outline: none; background: #fff; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 45%, transparent); } 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--c) 0%, transparent); } }

/* Signature pad */
.pad { width: 100%; height: 200px; border: 2px dashed var(--border); border-radius: 12px; background: #fff; touch-action: none; cursor: crosshair; display: block; }
.type-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.type-opt { border: 2px solid var(--border); border-radius: 12px; background: #fff; color: #111; padding: 10px; font-size: 2rem; cursor: pointer; min-height: 72px; text-align: left; overflow: hidden; white-space: nowrap; }
.type-opt[aria-pressed='true'] { border-color: var(--brand); outline: 3px solid color-mix(in srgb, var(--brand) 40%, transparent); }
.saved-sig { background: #fff; border: 2px solid var(--border); border-radius: 12px; padding: 8px; height: 90px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.saved-sig img { max-height: 70px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: none; font: inherit; font-weight: 700; padding: 12px 14px; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; min-height: 44px; }
.tabs button[aria-selected='true'] { color: var(--brand); border-color: var(--brand); }

/* Signer bar */
.signbar { position: sticky; top: 0; z-index: 40; background: var(--bg2); border-bottom: 1px solid var(--border); }
.signbar .wrap { display: flex; align-items: center; gap: 10px; min-height: 64px; flex-wrap: wrap; padding: 8px 0; }

/* Landing */
.hero { padding: clamp(40px, 8vw, 96px) 0 40px; background: radial-gradient(1200px 500px at 10% -10%, color-mix(in srgb, var(--brand) 22%, transparent), transparent), radial-gradient(900px 500px at 100% 0, color-mix(in srgb, var(--brand-2) 18%, transparent), transparent); }
.hero p.lead { font-size: 1.2rem; color: var(--muted); max-width: 640px; }
.grad { background: linear-gradient(135deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.feature .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); margin-bottom: 10px; }
.price { font-size: 2.4rem; font-weight: 800; }
.plan.best { border: 2px solid var(--brand); }
section.block { padding: 48px 0; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { overflow-wrap: anywhere; position: relative; padding: 0 0 14px 26px; border-left: 2px solid var(--border); margin-left: 8px; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); }
.qr { background: #fff; padding: 10px; border-radius: 10px; display: inline-block; }
.legal { max-width: 820px; }
.legal h2 { margin-top: 1.6em; }
@media print { .topbar, .a11y-btn, .tabbar, footer.site, .side { display: none !important; } }
[data-theme='dark'] .tabbar a.new { color: #0c0e1a; }

/* ===== v5 polish: premium surfaces, dashboard, landing mockup ===== */
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-feature-settings: 'cv11', 'ss01'; }
.card { transition: border-color .15s, box-shadow .2s; }
.btn.primary { box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--brand) 70%, transparent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.light { background: #fff; color: #3730a3; border-color: transparent; box-shadow: 0 8px 22px -10px rgba(0,0,0,.45); }
.btn.light:hover { background: #f1f0ff; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; font-weight: 800; color: var(--brand); margin: 0 0 .5em; }
.back-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 650; text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.lbl { font-weight: 650; margin-bottom: 6px; }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 22px 0; }
.ticks { list-style: none; padding: 0; margin: 10px 0 16px; display: grid; gap: 6px; }
.ticks li { position: relative; padding-left: 26px; }
.ticks li::before { content: ''; position: absolute; left: 0; top: .2em; width: 18px; height: 18px; border-radius: 50%; background: var(--ok-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230f7a4f' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7'/%3E%3C/svg%3E") center/12px no-repeat; }
.hero ul.ticks { display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--muted); }
@media (max-width: 640px) { .hide-sm { display: none !important; } }

/* side nav CTA */
.side-cta { margin: 4px 0 6px; }
.side a.side-cta, .side a.side-cta:hover { color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2)); justify-content: center; }
[data-theme='dark'] .side a.side-cta { color: #0c0e1a; }

/* dashboard hello card */
.hello-card { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; padding: clamp(20px, 3vw, 30px); border-radius: 20px; color: #fff; background: radial-gradient(600px 220px at 90% -40%, rgba(255,255,255,.22), transparent 60%), linear-gradient(135deg, #3730a3, #6d28d9); box-shadow: 0 18px 40px -22px #3730a3; margin-bottom: 16px; position: relative; overflow: hidden; }
.hello-card::after { content: ''; position: absolute; right: -40px; bottom: -60px; width: 220px; height: 220px; border-radius: 50%; border: 28px solid rgba(255,255,255,.07); pointer-events: none; }
.hello-card h1 { font-size: clamp(1.5rem, 3.2vw, 2.1rem); margin: 0 0 .25em; color: #fff; }
.hello-card p { margin: 0; color: #e9e7ff; }
.hello-card .eyebrow { color: #d9d6ff; }
[data-contrast='high'] .hello-card { background: #1e1b4b; }

/* stats */
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
button.stat { font: inherit; text-align: left; cursor: pointer; min-height: 44px; transition: transform .1s, border-color .15s, box-shadow .2s; }
button.stat:hover { border-color: var(--brand); box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-ic { width: 38px; height: 38px; border-radius: 11px; display: grid !important; place-items: center; margin-bottom: 10px; }
.stat-ic .icon { width: 20px; height: 20px; }
.stat-ic.ok { background: var(--ok-bg); color: var(--ok) !important; }
.stat-ic.warn { background: var(--warn-bg); color: var(--warn) !important; }
.stat-ic.bad { background: var(--bad-bg); color: var(--bad) !important; }
.stat-ic.info { background: var(--info-bg); color: var(--info) !important; }

/* loading skeleton */
.skeleton { display: grid; gap: 12px; padding: 8px 0; }
.skeleton i { display: block; height: 72px; border-radius: 14px; background: linear-gradient(90deg, var(--surface2), color-mix(in srgb, var(--surface2) 40%, var(--surface)), var(--surface2)); background-size: 200% 100%; animation: sk 1.2s ease-in-out infinite; }
.skeleton i:first-child { height: 120px; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* empty state */
.empty { padding: 36px 20px; }
.empty-art { width: 180px; height: auto; margin: 0 auto 10px; display: block; }

/* wizard */
.steps li { display: flex; align-items: center; gap: 8px; }
.steps .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--muted); font-size: .85rem; flex: none; border: 1.5px solid var(--border); }
.steps li[aria-current='step'] .n { background: #fff; color: var(--brand); border-color: #fff; }
.steps li.done .n { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.drop { transition: border-color .15s, background .15s; }
.drop:hover { border-color: var(--brand); }
.drop-ic { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; margin: 0 auto 12px; background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
.drop-ic .icon { width: 30px; height: 30px; }
.drop strong { display: block; font-size: 1.1rem; }
.wz-nav { position: sticky; bottom: 0; z-index: 30; justify-content: space-between; padding: 12px 0; margin-top: 18px; background: linear-gradient(to top, var(--bg) 70%, transparent); }
@media (max-width: 860px) { .wz-nav { bottom: calc(64px + env(safe-area-inset-bottom)); } }

/* success */
.success-hero { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.success-hero h1 { margin: 0; }
.success-ic { width: 56px; height: 56px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; background: var(--ok-bg); color: var(--ok); box-shadow: 0 0 0 8px color-mix(in srgb, var(--ok) 12%, transparent); }
.success-ic .icon { width: 28px; height: 28px; }
.success-ic.big { width: 84px; height: 84px; margin: 6px auto 4px; }
.success-ic.big .icon { width: 42px; height: 42px; }
.success-ic.sm { width: 30px; height: 30px; font-weight: 800; box-shadow: none; }
.done-card { padding: clamp(22px, 4vw, 40px); }
.link-card { border-left: 4px solid var(--brand); }

/* plans */
.plans .plan { display: flex; flex-direction: column; }
.plans .plan .btn, .plan .btn { margin-top: auto; }
.plan { position: relative; }
.plan.best .badge { position: absolute; top: -12px; right: 16px; }
.plan.best { box-shadow: 0 20px 44px -24px color-mix(in srgb, var(--brand) 70%, transparent); }

/* landing */
.hero-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } .mock { max-width: 420px; margin: 8px auto 0; } }
.hero h1 { font-size: clamp(2.2rem, 5.2vw, 3.6rem); letter-spacing: -.03em; }
.mock { position: relative; padding: 18px 26px 30px 8px; }
.mock-doc { background: #fff; color: #1b1f36; border-radius: 16px; padding: 22px 22px 26px; box-shadow: 0 30px 60px -28px rgba(30,27,75,.55), 0 0 0 1px rgba(30,27,75,.08); transform: rotate(-2deg); }
.mock-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 1rem; }
.mock-logo { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, #4338ca, #7c3aed); }
.mock .ln { display: block; height: 8px; border-radius: 6px; background: #e7e9f3; margin: 8px 0; }
.mock-sig { margin-top: 20px; border-bottom: 1.5px solid #9aa0bd; padding-bottom: 2px; width: 62%; position: relative; }
.mock-sig small { position: absolute; left: 0; bottom: -20px; font-size: .7rem; color: #5b6180; }
.mock-sig.two { width: 50%; margin-top: 34px; }
.mock-ink { font-family: 'Great Vibes', 'Dancing Script', cursive; font-size: 2.3rem; color: #0b1a5c; line-height: 1.1; display: block; }
.mock-tag { display: inline-block; padding: 6px 12px; border-radius: 8px; font-weight: 700; font-size: .85rem; background: #fff3c4; border: 2px dashed #d39b00; color: #6b4a00; }
.mock-chip { position: absolute; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: .85rem; }
.mock-chip small { display: block; color: var(--muted); }
.mock-chip.c1 { right: 0; top: 34%; }
.mock-chip.c2 { left: -6px; bottom: 0; flex-direction: column; align-items: flex-start; gap: 0; }
.mock-lock { font-weight: 800; color: var(--brand); }
@media (prefers-reduced-motion: no-preference) { .mock-doc { animation: floaty 6s ease-in-out infinite; } }
@keyframes floaty { 0%, 100% { transform: rotate(-2deg) translateY(0); } 50% { transform: rotate(-2deg) translateY(-6px); } }
.strip { border-block: 1px solid var(--border); background: var(--bg2); }
.strip-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 22px 0; text-align: center; }
.strip-grid b { display: block; font-size: 1.5rem; letter-spacing: -.02em; }
.strip-grid span { color: var(--muted); font-size: .9rem; }
@media (max-width: 640px) { .strip-grid { grid-template-columns: repeat(2, 1fr); row-gap: 18px; } }
.feature { transition: transform .15s, box-shadow .2s, border-color .15s; }
.feature:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--brand) 50%, var(--border)); }
.feature h3 { margin-top: 2px; }
.steps4 { list-style: none; padding: 0; margin: 20px 0 24px; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.steps4 li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.steps4 .n { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2)); margin-bottom: 10px; }
[data-theme='dark'] .steps4 .n { color: #0c0e1a; }
.steps4 p { margin: 0; }
details.faq { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0 18px; }
details.faq summary { cursor: pointer; font-weight: 700; padding: 14px 0; min-height: 44px; list-style-position: outside; }
details.faq[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 10px; }
details.faq p { padding-bottom: 6px; }
.cta-band { background: radial-gradient(800px 300px at 50% 0, color-mix(in srgb, var(--brand) 16%, transparent), transparent); }
.legal { line-height: 1.7; }
.item-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.item .grow { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .tpl-item { flex-wrap: wrap; }
  .tpl-item .grow { flex: 1 1 calc(100% - 60px); }
  .tpl-item .item-actions { flex: 1 1 100%; }
  .tpl-item .item-actions .btn.primary { flex: 1; }
  a.item { flex-wrap: wrap; }
  a.item > .stack { flex: 1 1 100%; text-align: left !important; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  a.item > .stack > * + * { margin-top: 0; }
}

/* ===== responsive hardening for large text (165%) and long Russian words ===== */
h1, h2, h3, .t, .stat span, .badge, .btn, .chip, label, .lbl, summary, td, th, p, li { overflow-wrap: break-word; }
h1, h2, .stat span { -webkit-hyphens: auto; hyphens: auto; }
@media (min-width: 641px) { h1, h2 { -webkit-hyphens: manual; hyphens: manual; } }
.hero-grid > *, .grid > *, .shell > *, .row > * { min-width: 0; }
.btn { max-width: 100%; white-space: normal; text-align: center; }
@media (max-width: 640px) {
  .hero h1 { font-size: clamp(1.9rem, 9vw, 2.6rem); }
  table.tbl thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.tbl, table.tbl tbody, table.tbl tr, table.tbl td { display: block; width: 100%; }
  table.tbl tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
  table.tbl td { border: 0; padding: 2px 0; }
  table.tbl td:first-child { font-weight: 700; }
  .mock { padding-right: 12px; }
  .mock-chip.c1 { right: 4px; }
}
@media (max-width: 860px) {
  .tabbar a { font-size: clamp(11px, .72rem, 14px); line-height: 1.15; text-align: center; overflow-wrap: anywhere; min-width: 0; }
}
/* keep focused/scrolled-to controls clear of the sticky top bar and bottom tab bar (WCAG 2.4.11) */
html { scroll-padding-top: 84px; scroll-padding-bottom: 96px; }
.editor > *, .palette, .palette .ftypes, .wz > * { min-width: 0; max-width: 100%; }
/* never cover the wizard's Next/Send button with the accessibility button */
body:has(.wz-nav) .a11y-btn { bottom: 92px; }
@media (max-width: 860px) { body:has(.wz-nav) .a11y-btn { bottom: calc(150px + env(safe-area-inset-bottom)); } }
