:root {
  --paper: #f5f2e9;
  --paper-deep: #ebe6d8;
  --card: #fff;
  --ink: #17211f;
  --blue: #294be0;
  --lime: #d9ef73;
  --red: #d23a2f;
  --green: #1f9d6b;
  --line: rgba(23, 33, 31, 0.14);
  --line-strong: rgba(23, 33, 31, 0.28);
  --muted: #5c665f;
  --sans: "DM Sans", system-ui, sans-serif;
  --display: "Manrope", system-ui, sans-serif;
  --mono: "DM Mono", ui-monospace, monospace;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 33, 31, 0.06), 0 8px 24px rgba(23, 33, 31, 0.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100svh;
  background: linear-gradient(180deg, rgba(217, 239, 115, 0.26), transparent 260px), var(--paper);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.ico { width: 20px; height: 20px; flex: none; }

/* Top bar */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  height: 64px; padding: 0 24px;
  background: rgba(245, 242, 233, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.wordmark { font: 800 22px var(--display); letter-spacing: -1.4px; text-decoration: none; color: inherit; }
.wordmark span:first-child { font-weight: 500; }
.wordmark-dot { color: var(--blue); }
.top-home { font: 700 14px var(--display); color: inherit; text-decoration: none; padding: 6px 10px; border-radius: 8px; background: var(--lime); }
.privacy, .eyebrow { margin: 0; font: 500 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.top .privacy { margin-left: auto; }
.back { font-size: 13px; font-weight: 600; color: inherit; }

#app { max-width: 1180px; margin: 0 auto; padding: 28px 24px 100px; }
body[data-view="tool"] #app { max-width: 1400px; }
.loading { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 120px 0; color: var(--muted); }

h1 { margin: 8px 0 12px; font: 800 clamp(36px, 5.6vw, 68px)/0.98 var(--display); letter-spacing: -0.045em; }
h1 em { font-style: normal; color: var(--blue); }
h2 { margin: 0 0 10px; font: 800 24px/1.1 var(--display); letter-spacing: -0.03em; }
.lede { max-width: 620px; color: var(--muted); font-size: 18px; line-height: 1.55; margin: 0 0 18px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  min-height: 38px; padding: 8px 14px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--card); color: var(--ink);
  font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn .ico { width: 17px; height: 17px; }
.btn-quiet { background: transparent; }
.btn-quiet:hover { background: rgba(255,255,255,.7); }
.btn-dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-dark:hover { background: #2a3633; }
.btn-lime { background: var(--lime); border-color: var(--lime); color: var(--ink); }
.btn.wide { width: 100%; }
.btn-link { background: none; border: 0; padding: 0; color: var(--blue); font-weight: 600; font-size: 13px; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); }
.icon-btn:hover { border-color: var(--ink); }
.icon-btn.flip .ico { transform: rotate(180deg); }
.btn-go {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  min-height: 54px; padding: 12px 20px; border: 0; border-radius: 12px;
  background: var(--blue); color: #fff; font: 800 17px var(--display); letter-spacing: -0.01em;
  box-shadow: 0 6px 18px rgba(41, 75, 224, .28);
  transition: transform .1s, box-shadow .15s, background .15s;
}
.btn-go:hover { background: #1f3ec7; }
.btn-go:active { transform: translateY(1px); }
.btn-go:disabled { background: #a9b2c9; box-shadow: none; cursor: not-allowed; }
.btn-go.big { width: auto; min-width: 300px; min-height: 62px; font-size: 19px; padding: 14px 34px; }

/* Home */
.hero { padding: 26px 0 10px; text-align: center; }
.hero .lede { margin: 0 auto 22px; }
.search { position: relative; max-width: 560px; margin: 0 auto 16px; }
.search .ico { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { width: 100%; height: 54px; padding: 0 18px 0 48px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--card); font-size: 16px; box-shadow: var(--shadow); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 18px; }
.pill { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; font-weight: 600; font-size: 14px; }
.pill[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.tool-group { margin-top: 30px; }
.tool-group h2 { font: 500 12px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tool {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto 1fr; column-gap: 14px; row-gap: 3px;
  padding: 18px; border-radius: var(--radius); background: var(--card);
  border: 1px solid var(--line); color: inherit; text-decoration: none; box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.tool:hover { transform: translateY(-2px); border-color: var(--ink); box-shadow: 0 12px 30px rgba(23,33,31,.1); }
.tool strong { font: 800 17px var(--display); letter-spacing: -0.02em; align-self: center; }
.tool > span:last-child { grid-column: 2; color: var(--muted); font-size: 14px; line-height: 1.4; }
.tool-ico { grid-row: 1 / 3; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; }
.tool-ico .ico { width: 24px; height: 24px; }
.g-organize { background: #e3e9ff; color: #2443c9; }
.g-optimize { background: #dcf4e7; color: #157a52; }
.g-to { background: #ffe7d9; color: #b84a12; }
.g-from { background: #f1e3ff; color: #7a32c2; }
.g-edit { background: #ffe1ea; color: #c02a59; }
.g-security { background: #e6ead8; color: #3d4a1f; }
.empty-search { text-align: center; color: var(--muted); padding: 30px 0; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 46px; }
.facts div { padding: 18px; border-radius: var(--radius); background: rgba(255,255,255,.6); border: 1px solid var(--line); }
.facts strong { display: block; font: 800 16px var(--display); margin-bottom: 4px; }
.facts span { color: var(--muted); font-size: 14px; }
.source {
  display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap;
  margin-top: 30px; padding: 30px; border-radius: 20px; background: var(--ink); color: #fff;
}
.source h2 { font-size: 34px; }
.source p { color: rgba(255,255,255,.72); max-width: 520px; margin: 0; }
.source .eyebrow { color: var(--lime); margin-bottom: 6px; }
.source-actions { display: grid; gap: 10px; justify-items: start; }
.source code { font: 13px var(--mono); color: var(--lime); background: rgba(255,255,255,.08); padding: 6px 10px; border-radius: 8px; }
.gap { margin-top: 28px; padding: 22px; border-radius: var(--radius); border: 1px dashed var(--line-strong); }
.gap h2 { font-size: 18px; }
.gap p { margin: 0; color: var(--muted); }

/* Landing */
.landing { display: grid; justify-items: center; text-align: center; padding: 20px 0 40px; }
.crumb { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: none; }
.crumb:hover { color: var(--ink); }
.crumb .ico { width: 16px; height: 16px; }
.landing .crumb { justify-self: start; margin-bottom: 18px; }
.landing-ico { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 20px; margin-bottom: 6px; }
.landing-ico .ico { width: 36px; height: 36px; }
.landing .lede { margin: 0 auto 26px; }
.pick {
  position: relative; display: inline-flex; align-items: center; gap: 12px;
  padding: 20px 40px; border-radius: 16px; background: var(--blue); color: #fff;
  font: 800 21px var(--display); cursor: pointer; box-shadow: 0 10px 28px rgba(41, 75, 224, .3);
  transition: transform .12s, background .15s;
}
.pick:hover { background: #1f3ec7; transform: translateY(-1px); }
.pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.pick .ico { width: 24px; height: 24px; }
.pick.small { padding: 10px 16px; font-size: 14px; border-radius: 10px; box-shadow: none; }
.drop-hint { color: var(--muted); margin: 14px 0 0; }
.howto { display: flex; flex-wrap: wrap; gap: 10px 28px; justify-content: center; list-style: none; counter-reset: s; padding: 0; margin: 34px 0 0; color: var(--muted); font-size: 14px; }
.howto li { counter-increment: s; display: flex; align-items: center; gap: 8px; }
.howto li::before { content: counter(s); display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; font: 600 12px var(--mono); }
.landing .privacy { display: inline-flex; gap: 6px; align-items: center; margin-top: 30px; }
.landing .privacy .ico { width: 14px; height: 14px; }

/* Work layout */
.work { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.work-main { min-width: 0; }
.work-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 14px; }
.work-head h1 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 26px; letter-spacing: -0.03em; }
.work-head h1 .ico { width: 24px; height: 24px; color: var(--blue); }
.work-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; align-items: center; }
.area { min-height: 320px; padding: 18px; border-radius: 18px; background: var(--paper-deep); border: 1px solid var(--line); }
.area-hint { margin: 14px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.area-sub { font: 700 14px var(--display); margin: 14px 0 8px; }
.area-sub:first-child { margin-top: 0; }
.side {
  position: sticky; top: 80px; display: flex; flex-direction: column;
  max-height: calc(100svh - 96px); border-radius: 18px; background: var(--card);
  border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden;
}
.side-scroll { overflow: auto; padding: 20px; }
.side h2 { font-size: 20px; }
.side-help { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.side-foot { padding: 14px 20px 18px; border-top: 1px solid var(--line); background: #fbfaf6; }
.summary { margin: 0 0 10px; font-size: 13px; color: var(--muted); min-height: 1.2em; }
.summary.warn { color: #9a5a00; }
.panel { display: grid; gap: 16px; }
.side-note { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.side-note .ico { width: 16px; height: 16px; vertical-align: -3px; }
.side-warn { margin: 0; padding: 10px 12px; border-radius: 10px; background: #fff3d6; color: #7a4a00; font-size: 13px; }
.err { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: #fde8e6; color: #8d1f16; display: grid; gap: 6px; font-size: 14px; }
.err .btn { justify-self: start; }

/* Form controls */
.field { display: grid; gap: 6px; }
.field-label { font: 500 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0; }
.field-hint { font-size: 12px; color: var(--muted); }
.field input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), .field select, .inline-input input, .pw-field input {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff;
}
.field input:focus, .field select:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(41,75,224,.15); }
.field input[type=range] { width: 100%; accent-color: var(--blue); }
.field input[type=color] { width: 100%; height: 40px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; }
.field output { font-size: 12px; color: var(--muted); }
.suffix { display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; overflow: hidden; }
.suffix input { border: 0 !important; box-shadow: none !important; min-width: 0; }
.suffix span { padding: 0 12px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.margins { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline-input { display: flex; gap: 8px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sub-panel { display: grid; gap: 14px; padding: 14px; border-radius: 12px; background: #f6f4ee; }
.sub-panel:empty { display: none; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--blue); flex: none; }
.check span { display: grid; gap: 2px; }
.check strong { font-weight: 600; }
.check small { color: var(--muted); font-size: 12px; }
.check.inline { display: inline-flex; align-items: center; }
.seg { display: flex; padding: 3px; gap: 3px; border-radius: 11px; background: #eeebe2; }
.seg-opt { flex: 1; position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; }
.seg-opt span { display: grid; place-items: center; text-align: center; padding: 7px 6px; border-radius: 9px; cursor: pointer; font-size: 13px; }
.seg-opt strong { font-weight: 600; }
.seg-opt small { font-size: 11px; color: var(--muted); }
.seg-opt input:checked + span { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--blue); }
.cards { display: grid; gap: 8px; }
.card-opt { position: relative; }
.card-opt input { position: absolute; opacity: 0; }
.card-body { display: grid; gap: 2px; padding: 12px 14px 12px 42px; border-radius: 12px; border: 1px solid var(--line-strong); cursor: pointer; position: relative; transition: border-color .15s, background .15s, box-shadow .15s; }
.card-body::before { content: ""; position: absolute; left: 14px; top: 14px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); }
.card-body strong { font-weight: 700; font-size: 15px; }
.card-body small { color: var(--muted); font-size: 12.5px; }
.card-opt input:checked + .card-body { border-color: var(--blue); background: #f2f5ff; box-shadow: 0 0 0 1px var(--blue); }
.card-opt input:checked + .card-body::before { border-color: var(--blue); background: radial-gradient(circle, var(--blue) 45%, transparent 50%); }
.card-opt input:focus-visible + .card-body { outline: 2px solid var(--blue); outline-offset: 2px; }
.pos-row { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.pos-row .check { flex: 1; min-width: 140px; margin-top: 20px; }
.pos-grid { display: grid; grid-template-columns: repeat(3, 30px); gap: 4px; padding: 6px; border-radius: 10px; background: #eeebe2; width: max-content; }
.pos-cell { position: relative; width: 30px; height: 30px; }
.pos-cell input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pos-cell span { display: block; width: 100%; height: 100%; border-radius: 6px; background: #fff; border: 1px solid var(--line); }
.pos-cell input:checked + span { background: var(--blue); border-color: var(--blue); }
.pos-cell.off { background: transparent; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { position: relative; width: 30px; height: 30px; }
.sw input[type=radio] { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.sw span { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.sw input:checked + span { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--blue); }
.sw-custom input { width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); cursor: pointer; }
.pw-field { display: flex; gap: 6px; }
.meter { height: 5px; border-radius: 3px; background: #e5e2d8; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }
.meter[data-s="1"] i { width: 25%; background: #d23a2f; }
.meter[data-s="2"] i { width: 50%; background: #e0912f; }
.meter[data-s="3"] i { width: 75%; background: #9bbf2a; }
.meter[data-s="4"] i { width: 100%; background: #1f9d6b; }
.order-list ol { margin: 6px 0; padding-left: 22px; display: grid; gap: 4px; font-size: 14px; }
.order-list li span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.order-list li small { color: var(--muted); font-size: 12px; }
.legend { display: grid; gap: 6px; font-size: 13px; }
.legend span { display: flex; gap: 8px; align-items: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.legend b { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--c); color: #fff; font-size: 12px; flex: none; }
.ranges { display: grid; gap: 8px; }
.range { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; border-radius: 10px; background: #fff; border: 1px solid var(--line); font-size: 13px; }
.range-tag { display: flex; align-items: center; gap: 6px; font-weight: 700; width: 100%; }
.range-tag::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.range label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.range input { width: 64px; height: 34px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 8px; }
.range .icon-btn { margin-left: auto; width: 30px; height: 30px; }

/* File cards */
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.files.single { grid-template-columns: minmax(0, 240px); justify-content: center; }
.file {
  position: relative; display: grid; gap: 4px; padding: 12px; border-radius: 14px; background: var(--card);
  border: 1px solid var(--line); box-shadow: var(--shadow); user-select: none; touch-action: manipulation;
}
.files.multi .file[data-sort] { cursor: grab; }
.file.sorting { cursor: grabbing; box-shadow: 0 18px 40px rgba(0,0,0,.2); transform: rotate(-2deg); }
.file-thumb { display: grid; place-items: center; aspect-ratio: 1; border-radius: 8px; background: #f4f2ec; overflow: hidden; }
.file-thumb img { max-width: 92%; max-height: 92%; box-shadow: 0 1px 4px rgba(0,0,0,.18); transform: rotate(var(--rot, 0deg)); transition: transform .25s; background: #fff; }
.file strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file small { font-size: 12px; color: var(--muted); }
.file-num { position: absolute; top: 18px; left: 18px; display: grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 8px; background: var(--ink); color: #fff; font: 600 12px var(--mono); }
.file-actions { position: absolute; top: 18px; right: 18px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.file:hover .file-actions, .file:focus-within .file-actions { opacity: 1; }
.file-actions button, .pg-actions button { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; border: 0; background: rgba(23,33,31,.85); color: #fff; }
.file-actions button:hover, .pg-actions button:hover { background: var(--blue); }
.file-actions .ico, .pg-actions .ico { width: 16px; height: 16px; }
.file-kind { font: 700 18px var(--mono); color: var(--muted); }
.file-add { place-items: center; align-content: center; min-height: 200px; border: 2px dashed var(--line-strong); background: transparent; box-shadow: none; color: var(--muted); font-weight: 600; }
.file-add:hover { border-color: var(--blue); color: var(--blue); }
.file-add .ico { width: 30px; height: 30px; }
.sort-placeholder { border: 2px dashed var(--blue); border-radius: 14px; background: rgba(41,75,224,.06); }
.thumb-fail { background: repeating-linear-gradient(45deg, #eee, #eee 6px, #f7f7f7 6px, #f7f7f7 12px); }

/* Page grid */
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 12px; }
.pg { position: relative; display: grid; gap: 5px; padding: 8px; border-radius: 12px; background: var(--card); box-shadow: 0 0 0 1px var(--line); user-select: none; touch-action: manipulation; transition: box-shadow .12s, opacity .12s; }
.pages.clickable .pg { cursor: pointer; }
.pages.sortable .pg { cursor: grab; }
.pg.sorting { cursor: grabbing; box-shadow: 0 18px 40px rgba(0,0,0,.2); }
.pg-thumb { position: relative; display: grid; place-items: center; aspect-ratio: 1; border-radius: 6px; background: #f4f2ec; overflow: hidden; }
.pg-thumb img { max-width: 94%; max-height: 94%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transform: rotate(var(--rot, 0deg)); transition: transform .25s; }
.pg-blank { display: grid; place-items: center; width: 70%; aspect-ratio: .707; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); font-size: 11px; color: var(--muted); }
.pg-label { text-align: center; font: 500 12px var(--mono); color: var(--muted); }
.pg-actions { position: absolute; top: 12px; right: 12px; display: flex; gap: 3px; opacity: 0; transition: opacity .15s; }
.pg:hover .pg-actions, .pg:focus-within .pg-actions { opacity: 1; }
.pg.grouped { box-shadow: 0 0 0 2px var(--c); }
.pg.grouped::after { content: attr(data-group); position: absolute; left: 12px; top: 12px; padding: 2px 7px; border-radius: 6px; background: var(--c); color: #fff; font: 600 11px var(--mono); }
.pg.muted { opacity: .4; }
.pg.selected { box-shadow: 0 0 0 2px var(--blue); background: #f2f5ff; }
.pg.selected::after { content: "✓"; position: absolute; left: 12px; top: 12px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 13px; font-weight: 700; }
.pg.doomed { box-shadow: 0 0 0 2px var(--red); }
.pg.doomed .pg-thumb::after { content: ""; position: absolute; inset: 0; background: rgba(210,58,47,.18) linear-gradient(45deg, transparent 48%, var(--red) 48%, var(--red) 52%, transparent 52%); }
.pg.changed { box-shadow: 0 0 0 2px var(--blue); }

/* Viewer */
.viewer { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px; }
.viewer.no-strip { grid-template-columns: minmax(0, 1fr); }
.v-strip { display: grid; gap: 8px; align-content: start; max-height: calc(100svh - 200px); overflow: auto; padding-right: 4px; position: sticky; top: 80px; }
.v-thumb { display: grid; gap: 3px; padding: 4px; border-radius: 8px; border: 0; box-shadow: 0 0 0 2px transparent; background: transparent; }
.v-thumb.on { box-shadow: 0 0 0 2px var(--blue); background: #fff; }
.v-thumb-img { display: grid; place-items: center; aspect-ratio: .75; background: #f4f2ec; border-radius: 4px; overflow: hidden; }
.v-thumb-img img { max-width: 100%; max-height: 100%; }
.v-thumb small { font: 500 11px var(--mono); color: var(--muted); }
.v-main { min-width: 0; }
.v-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 14px; }
.v-nav input { width: 56px; height: 34px; text-align: center; border: 1px solid var(--line-strong); border-radius: 8px; }
.v-zoom { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; }
.v-zoom b { font: 500 12px var(--mono); min-width: 40px; text-align: center; }
.v-extra { margin-left: auto; }
.live-tag { padding: 4px 9px; border-radius: 6px; background: var(--lime); font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .05em; }
.v-stage { display: grid; justify-items: center; overflow: auto; padding: 4px; }
.v-page { position: relative; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.18); }
.v-canvas canvas { display: block; }
.v-overlay { position: absolute; inset: 0; touch-action: none; }
.v-overlay[data-mode="text"] { cursor: text; }
.v-overlay[data-mode="highlight"], .v-overlay[data-mode="rect"], .v-overlay[data-mode="whiteout"], .v-overlay[data-mode="redact"], .v-overlay[data-mode="draw"] { cursor: crosshair; }

/* Marks */
.mk { position: absolute; box-sizing: border-box; }
.mk.sel { outline: 2px dashed var(--blue); outline-offset: 2px; }
.mk-text { white-space: pre; line-height: 1.2; padding: 0; outline: none; min-width: 1ch; cursor: move; }
.mk.sel .mk-text { cursor: text; }
.mk-highlight { opacity: .4; mix-blend-mode: multiply; }
.mk-whiteout { background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
.mk-redact { background: #000; }
.mk-draw svg, .mk-image img { position: absolute; inset: 0; width: 100%; height: 100%; }
.mk-image img { object-fit: fill; pointer-events: none; }
.mk:not(.drawing) { cursor: move; }
.mk-del { position: absolute; top: -14px; right: -14px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--red); color: #fff; z-index: 2; }
.mk-del .ico { width: 14px; height: 14px; }
.mk-resize { position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px; border-radius: 4px; background: var(--blue); cursor: nwse-resize; box-shadow: 0 0 0 2px #fff; }
.mk-grip { position: absolute; left: -26px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--blue); color: #fff; cursor: move; }
.mk-grip .ico { width: 13px; height: 13px; }
.modes { display: flex; flex-wrap: wrap; gap: 3px; padding: 3px; border-radius: 11px; background: #fff; border: 1px solid var(--line); }
.mode { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; font-size: 13px; font-weight: 600; }
.mode .ico { width: 17px; height: 17px; }
.mode.on { background: var(--ink); color: #fff; }
.mode:not(.on):hover { background: #f0eee7; }

/* Crop */
.crop-box { position: absolute; outline: 2px solid var(--blue); box-shadow: 0 0 0 9999px rgba(23,33,31,.45); cursor: move; }
.ch { position: absolute; width: 16px; height: 16px; background: #fff; box-shadow: 0 0 0 2px var(--blue); border-radius: 4px; }
.ch-nw { left: -8px; top: -8px; cursor: nwse-resize; } .ch-se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.ch-ne { right: -8px; top: -8px; cursor: nesw-resize; } .ch-sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.ch-n { left: calc(50% - 8px); top: -8px; cursor: ns-resize; } .ch-s { left: calc(50% - 8px); bottom: -8px; cursor: ns-resize; }
.ch-e { right: -8px; top: calc(50% - 8px); cursor: ew-resize; } .ch-w { left: -8px; top: calc(50% - 8px); cursor: ew-resize; }

/* Forms */
.ff { position: absolute; box-sizing: border-box; border: 1px solid rgba(41,75,224,.5); background: rgba(225,233,255,.75); border-radius: 2px; padding: 0 3px; margin: 0; font-family: Helvetica, Arial, sans-serif; resize: none; }
.ff:focus { outline: 2px solid var(--blue); background: #fff; }
.ff-check { accent-color: var(--blue); }

/* Sign */
.sig-card { display: grid; gap: 10px; padding: 14px; border-radius: 12px; background: #f6f4ee; }
.sig-card-head { display: flex; justify-content: space-between; align-items: center; }
.sig-preview { position: relative; display: grid; place-items: center; padding: 12px; min-height: 80px; border-radius: 10px; border: 1px dashed var(--line-strong); background: #fff; }
.sig-preview img { max-width: 100%; max-height: 70px; }
.sig-preview span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 6px; background: rgba(41,75,224,.88); color: #fff; font-weight: 700; border-radius: 10px; opacity: 0; transition: opacity .15s; }
.sig-preview:hover span, .sig-preview:focus-visible span { opacity: 1; }
.sel-card { background: #eef2ff; }
.sig-dialog { width: min(640px, 94vw); border: 0; border-radius: 18px; padding: 0; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.sig-dialog::backdrop, #pw::backdrop { background: rgba(23,33,31,.5); }
.sig-form { display: grid; gap: 16px; padding: 22px; }
.sig-form header, .sig-form footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sig-form footer { justify-content: flex-end; }
.sig-form header h2 { margin: 0; }
.sig-name { width: 100%; height: 46px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 10px; font-size: 17px; }
.sig-fonts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.sig-font { position: relative; }
.sig-font input { position: absolute; opacity: 0; }
.sig-font span { display: grid; place-items: center; height: 76px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); font-size: 30px; overflow: hidden; white-space: nowrap; cursor: pointer; }
.sig-font input:checked + span { border-color: var(--blue); background: #f2f5ff; box-shadow: 0 0 0 1px var(--blue); }
.sig-pad { width: 100%; height: auto; aspect-ratio: 3; border-radius: 12px; border: 1px dashed var(--line-strong); background: #fff; touch-action: none; cursor: crosshair; }
.sig-up-preview { margin: 10px 0; max-height: 200px; overflow: hidden; }
.sig-colors { display: flex; align-items: center; gap: 8px; }

/* Compare */
.compare { display: grid; gap: 14px; }
.cmp-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.cmp-nav .check { margin-left: auto; }
.cmp-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cmp-sides figure { margin: 0; display: grid; gap: 6px; }
.cmp-sides figcaption { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-img { position: relative; display: grid; place-items: center; min-height: 200px; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.15); }
.cmp-img canvas { display: block; width: 100%; height: auto; }
.cmp-overlay { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity .15s; }
.cmp-img.hl .cmp-overlay { opacity: 1; }
.cmp-missing { color: var(--muted); padding: 40px; }
.cmp-text { padding: 14px; border-radius: 12px; background: #fff; }
.diff { margin: 6px 0 0; line-height: 1.7; font-size: 14px; }
.diff del { background: #fdd; color: #a01b12; }
.diff ins { background: #d9f6e5; color: #11663f; text-decoration: none; }
.page-status { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 50vh; overflow: auto; }
.page-status button { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 13px; text-align: left; }
.page-status button span { display: flex; align-items: center; gap: 8px; }
.page-status button span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--green)); }
.page-status small { color: var(--muted); }
.page-status .on button { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.ps-changed { --dot: #e0912f; }
.ps-added, .ps-removed { --dot: var(--red); }
.mark-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.mark-list li { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.mark-list button { background: none; border: 0; padding: 0; color: var(--blue); font-weight: 600; }

/* Text, table */
.editor { width: 100%; min-height: 60svh; padding: 28px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font: 15px/1.6 var(--sans); resize: vertical; box-shadow: var(--shadow); }
.table-scroll { max-height: 62svh; overflow: auto; border-radius: 10px; background: #fff; border: 1px solid var(--line); }
.table-preview table { border-collapse: collapse; font-size: 12.5px; width: 100%; }
.table-preview th, .table-preview td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.table-preview th { position: sticky; top: 0; background: #eef2ff; }
.table-preview .area-hint { margin: 0 0 10px; text-align: left; }
.empty-state { display: grid; justify-items: center; gap: 12px; padding: 60px 20px; text-align: center; color: var(--muted); }
.doc-info { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; font-size: 14px; }
.doc-info dt { color: var(--muted); }
.doc-info dd { margin: 0; overflow-wrap: anywhere; }

/* Busy */
#busy { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(245,242,233,.82); backdrop-filter: blur(4px); }
.busy-box { display: grid; justify-items: center; gap: 14px; width: min(380px, 88vw); padding: 30px; border-radius: 20px; background: #fff; box-shadow: 0 20px 60px rgba(0,0,0,.18); text-align: center; }
.busy-box p { margin: 0; font-weight: 600; }
.bar { width: 100%; height: 8px; border-radius: 4px; background: #ebe8df; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--blue); transition: width .2s; }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(41,75,224,.2); border-top-color: var(--blue); animation: spin .8s linear infinite; }
.spin.big { width: 38px; height: 38px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Done */
.done { display: grid; justify-items: center; text-align: center; padding: 10px 0 40px; }
.done .crumb { justify-self: start; }
.done-check { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--green); color: #fff; margin: 10px 0 4px; }
.done-check .ico { width: 34px; height: 34px; stroke-width: 2.6; }
.done h1 { font-size: clamp(32px, 4.4vw, 52px); }
.done-meta { margin: 0; color: var(--muted); font: 500 14px var(--mono); }
.done-note { max-width: 560px; margin: 12px 0 0; padding: 12px 16px; border-radius: 12px; background: #fff; color: var(--muted); font-size: 14px; }
.done-preview { margin: 22px 0 6px; max-width: 260px; }
.done-preview img { max-width: 100%; max-height: 320px; box-shadow: 0 6px 22px rgba(0,0,0,.18); background: #fff; }
.done-actions { display: grid; justify-items: center; gap: 12px; margin-top: 22px; }
.done-sub { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.done-list { margin-top: 20px; width: min(560px, 100%); text-align: left; }
.done-list summary { cursor: pointer; font-weight: 600; color: var(--blue); text-align: center; }
.done-list ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; max-height: 300px; overflow: auto; }
.done-list li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 10px; background: #fff; font-size: 14px; }
.done-list li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.done-list li small { color: var(--muted); }
.done-text { width: min(760px, 100%); margin-top: 26px; text-align: left; }
.done-text-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.done-text pre { max-height: 340px; overflow: auto; margin: 0; padding: 18px; border-radius: 12px; background: #fff; border: 1px solid var(--line); font: 13px/1.55 var(--mono); white-space: pre-wrap; }
.next { margin-top: 34px; width: min(760px, 100%); }
.next p { font: 500 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.next > div { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip-tool { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: 14px; }
.chip-tool:hover { border-color: var(--ink); }
.chip-tool .tool-ico { width: 30px; height: 30px; border-radius: 8px; }
.chip-tool .tool-ico .ico { width: 17px; height: 17px; }

/* Drop veil, toast, dialogs */
.drop-veil { position: fixed; inset: 0; z-index: 70; display: none; place-items: center; background: rgba(41,75,224,.88); color: #fff; pointer-events: none; }
.drop-veil div { display: grid; gap: 6px; padding: 40px 60px; border: 2px dashed rgba(255,255,255,.7); border-radius: 24px; text-align: center; }
.drop-veil strong { font: 800 30px var(--display); }
body.dropping[data-view="tool"] .drop-veil { display: grid; }
#toast { position: fixed; left: 50%; bottom: 24px; z-index: 80; transform: translate(-50%, 30px); max-width: min(520px, 92vw); padding: 12px 18px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.warn { background: #7a4a00; }
#pw { width: min(440px, 92vw); border: 0; border-radius: 18px; padding: 24px; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
#pw h2 { margin: 6px 0 8px; }
#pw p { color: var(--muted); font-size: 14px; }
#pw input { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; margin: 6px 0 14px; }
#pw .row { display: flex; justify-content: flex-end; gap: 8px; }
.print-frame { position: fixed; width: 1px; height: 1px; opacity: 0; border: 0; right: 0; bottom: 0; }

/* Mobile */
@media (max-width: 960px) {
  .work { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
  .side-foot { position: sticky; bottom: 0; z-index: 10; box-shadow: 0 -6px 20px rgba(0,0,0,.08); }
  .work-tools { margin-left: 0; width: 100%; }
}
@media (max-width: 800px) {
  .top { padding: 0 14px; gap: 10px; height: 56px; }
  .top .privacy { display: none; }
  .back { margin-left: auto; }
  #app { padding: 18px 14px 120px; }
  .facts { grid-template-columns: 1fr; }
  .source { padding: 22px; }
  .area { padding: 10px; border-radius: 14px; }
  .viewer { grid-template-columns: 1fr; }
  .v-strip { display: flex; position: static; max-height: none; overflow-x: auto; order: 2; }
  .v-thumb { width: 64px; flex: none; }
  .files { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .pages { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .file-actions, .pg-actions { opacity: 1; }
  .cmp-sides { grid-template-columns: 1fr; }
  .pick { padding: 18px 26px; font-size: 18px; }
  .btn-go.big { min-width: 0; width: 100%; }
  .side-foot { position: fixed; left: 0; right: 0; bottom: 0; border-radius: 16px 16px 0 0; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
}

/* Crawlable SEO landing copy (cleared once the app boots) */
.seo-copy { max-width: 640px; margin: 36px auto 0; text-align: left; color: var(--muted); font-size: 14px; line-height: 1.55; }
.seo-copy h2 { font: 700 18px/1.2 var(--display); color: var(--ink); letter-spacing: -0.02em; margin: 22px 0 8px; }
.seo-copy h3 { font: 700 15px/1.3 var(--display); color: var(--ink); margin: 14px 0 4px; }
.seo-copy ol, .seo-copy ul { margin: 0; padding-left: 1.2em; }
.seo-copy li { margin: 4px 0; }
.seo-copy a { color: var(--blue); font-weight: 600; }
.seo-faq { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
