/* Layout: login splits brand panel / form; app = sticky topbar + centered panes; editor = three-column workspace (pages · paper · fields). */
:root {
  --bg: #f2f5f6;
  --surface: #ffffff;
  --surface-2: #eaf0f2;
  --line: #d6dfe3;
  --fg: #12222c;
  --muted: #5a6c77;
  --accent: #0a7560;
  --accent-ink: #ffffff;
  --accent-soft: #dff1eb;
  --brand: #0e2836;
  --brand-ink: #e9f3f1;
  --ok: #1d7f47;
  --ok-soft: #e1f3e8;
  --warn: #a8670f;
  --warn-soft: #fbefd9;
  --danger: #bf3326;
  --danger-soft: #fbe5e2;
  --canvas: #d5dde1;
  --field: rgba(10, 117, 96, .08);
  --field-line: rgba(10, 117, 96, .5);
  --paper-ink: #111827;
  --shadow: 0 1px 2px rgba(14, 40, 54, .06), 0 6px 20px rgba(14, 40, 54, .06);
  --font-body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  --font-display: "Readex Pro", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1216; --surface: #121c22; --surface-2: #19262d; --line: #263740; --fg: #e3ecef; --muted: #8ea2ac;
    --accent: #2bb38f; --accent-ink: #052119; --accent-soft: #113a30; --brand: #08151c; --brand-ink: #dbeee9;
    --ok: #4cc283; --ok-soft: #12321f; --warn: #e3a54a; --warn-soft: #3a2a10; --danger: #f07164; --danger-soft: #3d1a16;
    --canvas: #081014; --field: rgba(43, 179, 143, .10); --field-line: rgba(43, 179, 143, .55);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1216; --surface: #121c22; --surface-2: #19262d; --line: #263740; --fg: #e3ecef; --muted: #8ea2ac;
  --accent: #2bb38f; --accent-ink: #052119; --accent-soft: #113a30; --brand: #08151c; --brand-ink: #dbeee9;
  --ok: #4cc283; --ok-soft: #12321f; --warn: #e3a54a; --warn-soft: #3a2a10; --danger: #f07164; --danger-soft: #3d1a16;
  --canvas: #081014; --field: rgba(43, 179, 143, .10); --field-line: rgba(43, 179, 143, .55);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.6 var(--font-body); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.3; margin: 0; text-wrap: balance; }
p { margin: 0; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--surface-2); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; height: 46px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--fg); flex: none; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.on { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; background: transparent; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font-weight: 500; padding: 0; }
.link:hover { text-decoration: underline; }

/* Form controls */
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
.field input, .field select, .field textarea, .input { height: 42px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 12px; color: var(--fg); font-size: 15px; font-weight: 400; width: 100%; }
.field textarea { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.req { color: var(--danger); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; color: var(--fg); }
.check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
.form-grid { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.login-art { background: var(--brand); color: var(--brand-ink); padding-block: 48px; padding-inline: max(32px, env(safe-area-inset-left, 0px)) 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; position: relative; overflow: hidden; }
.login-art::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px); background-size: 28px 28px; mask-image: linear-gradient(160deg, #000 20%, transparent 85%); }
.login-art > * { position: relative; }
.brandmark { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 20px; }
.brandmark svg { width: 34px; height: 34px; }
.login-art h2 { font-size: clamp(28px, 3.2vw, 40px); font-weight: 600; max-width: 15ch; }
.login-art .lede { color: color-mix(in srgb, var(--brand-ink) 72%, transparent); max-width: 44ch; margin-top: 14px; font-size: 16px; }
.feat { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; max-width: 46ch; }
.feat li { display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: start; }
.feat li span:first-child { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); }
.feat svg { width: 18px; height: 18px; }
.feat b { display: block; font-weight: 600; }
.feat small { color: color-mix(in srgb, var(--brand-ink) 65%, transparent); font-size: 13px; }
.sheet { width: min(320px, 100%); background: #fbfcfc; color: #1b2b35; border-radius: 6px; padding: 18px 18px 22px; transform: rotate(-3deg); box-shadow: 0 24px 50px rgba(0,0,0,.35); font-size: 11px; align-self: flex-start; }
.sheet .s-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #0a7560; padding-bottom: 8px; margin-bottom: 12px; font-weight: 600; font-size: 12px; }
.sheet .s-row { display: grid; gap: 3px; margin-bottom: 9px; }
.sheet .s-box { height: 18px; border: 1px solid #c5d0d5; border-radius: 2px; background: rgba(10,117,96,.07); padding: 0 6px; line-height: 17px; font-size: 10px; color: #111; }
.sheet .s-sig { font-family: "Aref Ruqaa", serif; font-size: 22px; color: #1d3fa6; line-height: 1; height: 30px; border-bottom: 1px solid #c5d0d5; }
.sheet .s-stamp { position: absolute; }
.login-foot { font-size: 12px; color: color-mix(in srgb, var(--brand-ink) 55%, transparent); }

.login-panel { display: grid; place-items: center; padding-block: 40px; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }
.login-card { width: min(400px, 100%); display: grid; gap: 18px; }
.login-card h1 { font-size: 28px; }
.login-card .sub { color: var(--muted); margin-top: 6px; }
.pw { position: relative; }
.pw input { padding-left: 74px; }
.pw button { position: absolute; left: 6px; top: 6px; height: 30px; padding: 0 10px; border: 0; border-radius: 6px; background: var(--surface-2); color: var(--muted); font-size: 12px; cursor: pointer; }
.err { color: var(--danger); font-size: 13px; min-height: 1em; }
.err:empty { display: none; }
.caps { font-size: 12px; color: var(--warn); }
.note { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }
.note svg { width: 16px; height: 16px; margin-top: 2px; }
.login-mobile-brand { display: none; }

/* ---------- Developer credit ---------- */
.dev-credit { display: inline-flex; align-items: center; gap: 8px; direction: ltr; font-size: 11.5px; color: var(--muted); text-decoration: none; opacity: .8; transition: opacity .15s; }
.dev-credit:hover { opacity: 1; }
.dev-credit img { height: 19px; width: auto; display: block; }
.dev-credit b { font-weight: 600; color: inherit; }
.dev-credit .lg-l { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .dev-credit .lg-l { display: block; } :root:not([data-theme="light"]) .dev-credit .lg-d { display: none; } }
:root[data-theme="dark"] .dev-credit .lg-l { display: block; }
:root[data-theme="dark"] .dev-credit .lg-d { display: none; }
.dev-credit.on-brand { color: color-mix(in srgb, var(--brand-ink) 60%, transparent); }
.dot-sep { opacity: .5; margin: 0 2px; }
.credit-mobile { display: none; text-align: center; }
.site-foot { display: flex; justify-content: center; padding: 18px 16px calc(22px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }

/* ---------- App shell ---------- */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 50; background: var(--surface); }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1240px; margin: 0 auto; height: 62px; display: flex; align-items: center; gap: 18px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.topbar .brandmark { font-size: 18px; color: var(--fg); }
.topbar .brandmark svg { width: 28px; height: 28px; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.nav button { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 0; background: none; border-radius: 8px; color: var(--muted); cursor: pointer; font-weight: 500; white-space: nowrap; }
.nav button svg { width: 18px; height: 18px; }
.nav button:hover { color: var(--fg); background: var(--surface-2); }
.nav button.on { color: var(--accent); background: var(--accent-soft); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 600; font-size: 14px; flex: none; }
.user-meta { line-height: 1.2; font-size: 13px; }
.user-meta small { color: var(--muted); font-size: 11px; }

/* ---------- Modal / toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(6, 16, 22, .5); z-index: 100; display: grid; place-items: center; padding: 16px; animation: fade .15s ease; }
.modal { width: min(460px, 100%); max-height: calc(100% - 32px); overflow: auto; background: var(--surface); border-radius: 14px; box-shadow: 0 30px 60px rgba(0,0,0,.3); display: flex; flex-direction: column; }
.modal.wide { width: min(620px, 100%); }
.modal > header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 6px; }
.modal > header h3 { font-size: 18px; }
.modal-body { padding: 10px 20px 18px; display: grid; gap: 14px; }
.modal > footer { display: flex; gap: 8px; justify-content: flex-start; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal > footer:empty { display: none; }
@keyframes fade { from { opacity: 0; } }
.toasts { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100% - 32px); }
.toast { background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); animation: up .2s ease; transition: opacity .3s, transform .3s; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes up { from { opacity: 0; transform: translateY(8px); } }

/* Signature dialog */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.sig-pad { position: relative; height: 200px; border: 1px solid var(--line); border-radius: 10px; background: #fff; touch-action: none; overflow: hidden; }
.sig-pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.sig-line { position: absolute; left: 24px; right: 24px; bottom: 46px; border-bottom: 1px dashed #b9c4ca; pointer-events: none; }
.sig-hint { position: absolute; bottom: 18px; right: 24px; font-size: 12px; color: #8a979e; pointer-events: none; }
.sig-opts { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.sig-opts input[type=range] { width: 100px; accent-color: var(--accent); }
.sig-fonts { display: grid; gap: 8px; }
.sig-fonts button { height: 70px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: #111827; cursor: pointer; font-size: 30px; overflow: hidden; white-space: nowrap; padding: 0 16px; }
.sig-fonts button.on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.sig-saved { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.sig-saved .s { position: relative; height: 80px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; display: grid; place-items: center; padding: 8px; }
.sig-saved .s.on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.sig-saved .s img { max-height: 100%; max-width: 100%; }
.sig-saved .s .rm { position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--danger-soft); color: var(--danger); cursor: pointer; font-size: 11px; }
.upload-prev { min-height: 120px; border: 1.5px dashed var(--line); border-radius: 10px; display: grid; place-items: center; background: #fff; color: #6b7a82; cursor: pointer; padding: 12px; text-align: center; font-size: 13px; }
.upload-prev img { max-height: 160px; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.spin { width: 22px; height: 22px; border: 2.5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/*WS*/
/* ---------- Forms workspace ---------- */
.topbar-in { height: 60px; }
.type-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 0 1 420px; }
.type-wrap span { font-size: 12px; color: var(--muted); white-space: nowrap; font-weight: 500; }
.type-sel { height: 38px; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: 8px; background: var(--accent-soft); color: var(--fg); font-weight: 600; padding: 0 10px; min-width: 0; width: 100%; font-size: 14px; }
.type-sel:focus { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.spacer { flex: 1; }
.save-state { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.save-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.save-state.saving::before { background: var(--warn); }
.save-state.error::before { background: var(--danger); }

.toolbar { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 61px); z-index: 18; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 2px 8px rgba(14, 40, 54, .04); }
.toolbar-in { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 8px; padding-block: 8px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); overflow-x: auto; scrollbar-width: thin; }
.tgroup { display: flex; align-items: center; gap: 6px; flex: none; }
.tlabel { font-size: 12px; color: var(--muted); white-space: nowrap; }
.toolbar .sep { width: 1px; height: 24px; background: var(--line); flex: none; }
.input.sm { height: 32px; font-size: 13px; padding: 0 10px; }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.sm svg { width: 16px; height: 16px; }
.goto-sel { width: 190px; }
.fsel { width: 58px; padding: 0 4px; }
.fsel:disabled, .icon-btn:disabled { opacity: .4; }
#tsize { width: 84px; accent-color: var(--accent); }
.toolbar .search { min-width: 0; max-width: none; flex: none; }
.toolbar .search input { width: 170px; padding-right: 34px; }
.toolbar .search svg { top: 7px; right: 10px; }
.search-count { position: absolute; left: 10px; top: 7px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.count-pill { font-size: 11px; background: var(--surface-2); border-radius: 999px; padding: 1px 7px; color: var(--muted); font-variant-numeric: tabular-nums; }
.btn.on, #t-hide.on { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.filled-count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.filled-count b { color: var(--accent); font-size: 14px; font-variant-numeric: tabular-nums; }
.filled-by { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.filled-by input { width: 120px; }
.filled-by input.req-missing { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.more { position: relative; }
.menu { position: fixed; z-index: 40; margin-top: 6px; min-width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.16); padding: 6px; display: grid; }
.menu button { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; background: none; border-radius: 7px; cursor: pointer; text-align: right; font-size: 14px; }
.menu button svg { width: 17px; height: 17px; color: var(--muted); }
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }
.menu button.danger svg { color: var(--danger); }

.ws { max-width: 1000px; margin: 0 auto; padding-block: 18px 40px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: grid; gap: 22px; }
.pages, .appendix { display: grid; gap: 26px; }
.pages .loading { position: static; padding: 80px 0; text-align: center; }
.type-banner { background: var(--surface); border: 1px solid var(--line); border-inline-start: 3px solid var(--accent); border-radius: 10px; padding: 12px 16px; display: grid; gap: 10px; font-size: 14px; }
.tb-main { display: flex; gap: 10px; align-items: flex-start; }
.tb-main svg { width: 18px; height: 18px; color: var(--accent); margin-top: 3px; }
.tb-missing { display: grid; gap: 8px; font-size: 13px; }
.miss-list { display: flex; flex-wrap: wrap; gap: 6px; }
.miss-item { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px 4px 10px; font-size: 13px; }
.miss-item.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.miss-item svg { width: 14px; height: 14px; color: var(--ok); }
.miss-add { border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--surface); color: var(--accent); border-radius: 6px; padding: 2px 8px; font-size: 12px; cursor: pointer; font-weight: 500; }
.miss-add:hover { background: var(--accent); color: var(--accent-ink); }

.page-wrap { display: grid; gap: 8px; }
.page-label { display: flex; align-items: center; gap: 10px; font-size: 13px; min-width: 0; }
.page-label .pno { min-width: 26px; height: 22px; padding: 0 6px; border-radius: 6px; background: var(--brand); color: var(--brand-ink); display: inline-grid; place-items: center; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.page-label .pt { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.page-label .pc { margin-inline-start: auto; font-size: 12px; color: var(--accent); white-space: nowrap; }
.page-el, .doc-page { position: relative; width: 100%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 8px 28px rgba(14, 40, 54, .10); border-radius: 2px; direction: ltr; user-select: none; }
.page-el > img, .doc-page > img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.fld { position: absolute; margin: 0; border: 0; background: rgba(40, 90, 200, .09); color: #16397d; font-family: var(--font-body); font-weight: 500; text-align: center; line-height: 1; border-radius: 1px; outline: none; transition: background .12s, box-shadow .12s; user-select: text; }
textarea.fld { resize: none; overflow: hidden; line-height: 1.2; text-align: start; }
.fld:hover { background: rgba(40, 90, 200, .17); }
.fld:focus { background: rgba(40, 90, 200, .12); box-shadow: inset 0 0 0 1.4px #2e5bd0, 0 0 0 3px rgba(46, 91, 208, .2); }
.chk { position: absolute; display: grid; place-items: center; background: rgba(40, 90, 200, .09); cursor: pointer; border-radius: 1px; }
.chk:hover { background: rgba(40, 90, 200, .2); }
.chk .mark { color: #16397d; font-weight: 800; line-height: 1; display: none; }
.chk.on .mark { display: block; }
.chk:focus-visible { outline: 2px solid #2e5bd0; outline-offset: 1px; }
.hide-fields .fld, .hide-fields .chk { background: transparent !important; box-shadow: none !important; }
.fld.search-match { background: rgba(224, 168, 0, .22) !important; box-shadow: inset 0 0 0 2px #e0a800; }
.fld.search-cur { background: rgba(224, 82, 43, .22) !important; box-shadow: inset 0 0 0 2.4px #e0522b; }
.sig-stamp { position: absolute; cursor: grab; touch-action: none; z-index: 3; }
.sig-stamp:active { cursor: grabbing; }
.sig-stamp img { width: 100%; height: 100%; display: block; pointer-events: none; }
.sig-stamp:hover { outline: 1.5px dashed #2e5bd0; outline-offset: 2px; }
.sig-del { position: absolute; top: -11px; right: -11px; width: 22px; height: 22px; border-radius: 50%; background: var(--danger); color: #fff; border: 2px solid #fff; cursor: pointer; font-size: 11px; line-height: 1; padding: 0; display: none; }
.sig-h { position: absolute; right: -6px; bottom: -6px; width: 12px; height: 12px; border-radius: 3px; background: #2e5bd0; border: 2px solid #fff; cursor: nwse-resize; display: none; }
.sig-stamp:hover .sig-del, .sig-stamp:hover .sig-h { display: block; }
@media (hover: none) { .sig-del, .sig-h { display: block; } }
body.placing .page-el { cursor: crosshair; }
body.placing .fld, body.placing .chk { pointer-events: none; }
.place-hint { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 60; background: var(--fg); color: var(--bg); padding: 8px 8px 8px 16px; border-radius: 999px; display: flex; align-items: center; gap: 10px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: calc(100% - 32px); }
.place-hint span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.place-hint .btn { height: 30px; border-radius: 999px; }

.ph-del { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%; background: rgba(20, 16, 14, .7); color: #fff; border: 0; cursor: pointer; font-size: 12px; }
.ph-drop { display: flex; align-items: center; gap: 14px; border: 1.5px dashed var(--line); border-radius: 12px; padding: 18px 20px; background: var(--surface); cursor: pointer; transition: background .15s, border-color .15s; }
.ph-drop:hover, .ph-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.ph-drop svg { width: 26px; height: 26px; color: var(--accent); }
.ph-drop b { display: block; }
.ph-drop small { color: var(--muted); }
.ph-page { position: relative; width: 100%; aspect-ratio: 1 / 1.414; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 8px 28px rgba(14, 40, 54, .10); padding: 5%; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 3%; }
.ph-cell { position: relative; border: 1px solid #e6e2d8; border-radius: 4px; overflow: hidden; display: grid; place-items: center; background: #faf9f6; }
.ph-cell img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.ph-num { position: absolute; bottom: 6px; left: 8px; font-size: 11px; font-weight: 600; color: #6b7a82; background: rgba(255,255,255,.85); padding: 1px 6px; border-radius: 4px; }

.pages-panel { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 120px); right: max(16px, env(safe-area-inset-right, 0px)); width: min(380px, calc(100% - 32px)); max-height: calc(100% - 180px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.2); z-index: 30; padding: 12px 14px; display: grid; gap: 8px; align-content: start; }
.pages-panel header { display: flex; align-items: center; gap: 4px; position: sticky; top: -12px; background: var(--surface); padding-block: 4px; }
.pages-panel p { font-size: 12px; }
.pp-row { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.pp-row:last-child { border-bottom: 0; }
.pp-row input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; margin: 0; }
.pp-row .pno { width: 22px; color: var(--muted); font-size: 12px; font-weight: 600; flex: none; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login-mobile-brand { display: flex; color: var(--fg); }
  .credit-mobile { display: block; }
  .user-meta, .save-state { display: none; }
  .topbar .brandmark span, .type-wrap > span { display: none; }
  .topbar-in { gap: 10px; }
  .toolbar .btn .t, .tlabel { display: none; }
  .toolbar .btn.sm { padding: 0 9px; }
  .goto-sel { width: 130px; }
  .toolbar .search input { width: 120px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.toolbar .search { position: relative; display: block; }
.toolbar .search svg { position: absolute; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
@media (min-width: 901px) { .toolbar-in { flex-wrap: wrap; overflow: visible; row-gap: 8px; } }
