:root {
  --bg: #fbfcf8; --surface: #ffffff; --soft: #f1f4ec; --soft-2: #e6ecdf; --line: #e2e7dc;
  --ink: #1c2b24; --muted: #68756c; --green: #174f3d; --green-ink: #ffffff; --green-soft: #e3ecdb;
  --accent: #dff09c; --brand: #174f3d; --red: #b23b3b; --canvas: #e9ede4; --shadow: 0 10px 30px rgba(23, 50, 38, .08);
  --radius: 14px;
  color-scheme: light;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--bg);
}
:root[data-theme="dark"] {
  --bg: #0f1512; --surface: #171f1b; --soft: #1d2722; --soft-2: #26332c; --line: #2a3630;
  --ink: #e8eee9; --muted: #9aa79f; --green: #3b9a76; --green-ink: #06140e; --green-soft: #1f3329;
  --accent: #dff09c; --red: #e07a7a; --canvas: #0b100d; --shadow: 0 10px 30px rgba(0, 0, 0, .4);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1512; --surface: #171f1b; --soft: #1d2722; --soft-2: #26332c; --line: #2a3630;
    --ink: #e8eee9; --muted: #9aa79f; --green: #3b9a76; --green-ink: #06140e; --green-soft: #1f3329;
    --accent: #dff09c; --red: #e07a7a; --canvas: #0b100d; --shadow: 0 10px 30px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
/* Tema warna. Mode gelap memakai netral yang sama; hanya warna utama yang berganti. */
:root[data-accent="samudra"] { --bg: #f8fafd; --soft: #eef2f8; --soft-2: #e0e7f1; --line: #dde3ec; --canvas: #e6ebf2; --ink: #18243a; --muted: #617089; --green: #1b4f8f; --green-soft: #dde8f6; --accent: #bfe1ff; --brand: #153d70; }
:root[data-accent="senja"] { --bg: #fdfaf6; --soft: #f7efe6; --soft-2: #efe2d4; --line: #eadfd3; --canvas: #efe7dd; --ink: #33221a; --muted: #7d6a5f; --green: #a4471f; --green-soft: #f6e3d6; --accent: #ffd9a8; --brand: #7c3415; }
:root[data-accent="anggrek"] { --bg: #fbf9fd; --soft: #f3eef8; --soft-2: #e8e0f1; --line: #e5deed; --canvas: #ebe6f1; --ink: #281d38; --muted: #71667f; --green: #6a3fa0; --green-soft: #ebe2f6; --accent: #e6cdfc; --brand: #4f2d7c; }
:root[data-accent="arang"] { --bg: #fafafa; --soft: #f0f1f2; --soft-2: #e3e6e8; --line: #e1e4e6; --canvas: #e8eaec; --ink: #1d2327; --muted: #677278; --green: #2f3a40; --green-soft: #e2e6e9; --accent: #d7e0e4; --brand: #252e33; }
:root[data-accent="samudra"][data-theme="dark"] { --bg: #0e131a; --surface: #161d27; --soft: #1c2532; --soft-2: #263243; --line: #293546; --canvas: #0a0e14; --ink: #e7ecf3; --muted: #97a4b6; --green: #6ea8ee; --green-ink: #07111f; --green-soft: #1b2c44; }
:root[data-accent="senja"][data-theme="dark"] { --bg: #171210; --surface: #201a17; --soft: #29211d; --soft-2: #372c26; --line: #3a2f29; --canvas: #100c0a; --ink: #f1e9e4; --muted: #b0a199; --green: #e69461; --green-ink: #1f0f06; --green-soft: #3a261b; }
:root[data-accent="anggrek"][data-theme="dark"] { --bg: #131018; --surface: #1c1824; --soft: #241f2e; --soft-2: #30293d; --line: #332c40; --canvas: #0d0b11; --ink: #ece7f3; --muted: #a59bb4; --green: #b494e8; --green-ink: #150b24; --green-soft: #2d2340; }
:root[data-accent="arang"][data-theme="dark"] { --bg: #111314; --surface: #1a1d1f; --soft: #212527; --soft-2: #2c3134; --line: #2f3437; --canvas: #0b0d0e; --ink: #e9eced; --muted: #9ba4a9; --green: #a9b9c1; --green-ink: #0c1114; --green-soft: #262d31; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .45; cursor: not-allowed; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--green) 55%, #fff); outline-offset: 2px; }
[hidden] { display: none !important; }
svg { display: block; }
[data-icon] { display: inline-flex; flex: none; }
[data-icon] svg { width: 20px; height: 20px; }
h1, h2, h3, p { margin: 0; }
kbd { font: 600 11px ui-monospace, monospace; padding: 2px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--soft); }
code { font: 12px ui-monospace, monospace; background: var(--soft); padding: 1px 5px; border-radius: 4px; }

/* ---------- Tombol & kolom ---------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 10px; font-size: 14px; font-weight: 600; white-space: nowrap; transition: background .15s, transform .1s; }
.button:active:not(:disabled) { transform: scale(.98); }
.button.primary { background: var(--green); color: var(--green-ink); }
.button.primary:hover:not(:disabled) { filter: brightness(1.1); }
.button.light { background: var(--surface); border: 1px solid var(--line); }
.button.ghost { background: var(--soft); }
.button.ghost:hover:not(:disabled), .button.light:hover:not(:disabled) { background: var(--soft-2); }
.button.ghost.danger { color: var(--red); }
.button.ghost.active { background: var(--accent); color: #1c2b24; }
.button.destructive { background: var(--red); color: #fff; }
.button.big { min-height: 50px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.button.full { width: 100%; }
.icon-button { width: 38px; height: 38px; border-radius: 10px; display: inline-grid; place-items: center; color: var(--muted); flex: none; }
.icon-button:hover:not(:disabled) { background: var(--soft); color: var(--ink); }
.icon-button.danger:hover:not(:disabled) { color: var(--red); }
.icon-button.on { color: #c98a00; }
.icon-button.on svg { fill: currentColor; }
.link { font-size: 13px; font-weight: 650; color: var(--green); text-align: left; }
.link:hover { text-decoration: underline; }
select, input[type="text"], input[type="password"], input:not([type]), textarea { width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 14px; }
textarea { resize: vertical; line-height: 1.55; }
.field { display: grid; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; min-height: 30px; }
.check input { width: 17px; height: 17px; accent-color: var(--green); }
.hint { font-size: 12.5px; line-height: 1.55; color: var(--muted); }
.range { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.range output { color: var(--ink); font-variant-numeric: tabular-nums; }
.range input { grid-column: 1 / -1; width: 100%; accent-color: var(--green); height: 26px; margin: 0; }

/* ---------- Kerangka ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; padding: 26px 16px 18px; background: var(--soft); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.brand { display: flex; align-items: center; font-size: 23px; letter-spacing: -.6px; color: inherit; text-decoration: none; padding: 0 8px; font-weight: 500; }
.brand b { font-weight: 800; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: var(--brand); color: #fff; align-items: center; justify-content: center; margin-right: 10px; }
.brand-mark svg { width: 23px; height: 23px; }
.brand.compact { display: none; padding: 0; }
.brand.compact .brand-mark { margin: 0; }
.side-label { font-size: 10.5px; letter-spacing: 1.4px; text-transform: uppercase; font-weight: 700; color: var(--muted); margin: 26px 10px 8px; }
nav { display: grid; gap: 3px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px; border-radius: 9px; font-size: 13.5px; font-weight: 500; color: var(--muted); text-align: left; }
.nav-item:hover { background: var(--soft-2); color: var(--ink); }
.nav-item.active { background: var(--green-soft); color: var(--ink); font-weight: 650; }
.nav-item b { margin-left: auto; font-size: 11px; min-width: 22px; text-align: center; padding: 2px 5px; border-radius: 6px; background: var(--surface); font-weight: 650; }
.storage { margin: 18px 10px 0; font-size: 12px; color: var(--muted); }
.storage-row { display: flex; justify-content: space-between; margin-bottom: 6px; }
.storage-row b { color: var(--ink); }
.meter { height: 5px; border-radius: 5px; background: var(--soft-2); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--green); border-radius: 5px; }
.side-note { margin-top: auto; display: flex; gap: 10px; padding: 16px 10px 4px; border-top: 1px solid var(--line); color: var(--muted); }
.side-note strong { font-size: 13px; color: var(--ink); }
.side-note p { font-size: 12px; line-height: 1.6; margin: 5px 0 8px; }

.main { margin-left: 250px; min-height: 100dvh; }
.topbar { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 8px; padding: 12px clamp(16px, 4vw, 44px); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.search { flex: 1; min-width: 0; max-width: 520px; display: flex; align-items: center; gap: 9px; padding: 0 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--muted); margin-right: auto; }
.search input { min-width: 0; border: 0; padding: 0; min-height: 40px; background: none; color: var(--ink); outline: none; }
.search:focus-within { outline: 3px solid color-mix(in srgb, var(--green) 55%, #fff); outline-offset: 1px; }
.page { padding: 28px clamp(16px, 4vw, 44px) 40px; max-width: 1240px; }

/* ---------- Hero ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(250px, 1fr); gap: 20px; padding: clamp(22px, 3.5vw, 38px); border-radius: 22px; background: var(--brand); color: #fff; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -90px; top: -110px; width: 330px; height: 330px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 24%, transparent), transparent 68%); pointer-events: none; }
.hero.dragging { outline: 3px dashed var(--accent); outline-offset: -10px; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px 5px 8px; border-radius: 99px; background: rgba(255, 255, 255, .12); font-size: 11.5px; font-weight: 650; letter-spacing: .3px; }
.pill svg { width: 15px; height: 15px; }
.hero h1 { font-size: clamp(28px, 4.2vw, 44px); line-height: 1.08; letter-spacing: -1.2px; font-weight: 750; margin: 16px 0 12px; }
.hero-copy > p { font-size: 15px; line-height: 1.6; color: rgba(255, 255, 255, .8); max-width: 46ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 14px; }
.hero .button.primary { background: var(--accent); color: #17221c; }
.hero .button.light { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .28); color: #fff; }
.hero .button.light:hover { background: rgba(255, 255, 255, .2); }
.hero small { font-size: 12px; color: rgba(255, 255, 255, .62); line-height: 1.5; display: block; }
.steps { list-style: none; margin: 0; padding: 18px; border-radius: 16px; background: rgba(255, 255, 255, .08); display: grid; gap: 14px; align-content: center; position: relative; z-index: 1; }
.steps li { display: flex; gap: 12px; }
.steps b { width: 26px; height: 26px; flex: none; border-radius: 8px; background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); display: grid; place-items: center; font-size: 12px; }
.steps strong { display: block; font-size: 14px; }
.steps span { font-size: 12.5px; color: rgba(255, 255, 255, .7); line-height: 1.5; }
.steps .link { color: var(--accent) !important; }

/* ---------- Pustaka ---------- */
.library { margin-top: 34px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.section-head h2 { font-size: 21px; letter-spacing: -.4px; }
.section-head p { font-size: 13px; color: var(--muted); margin-top: 3px; }
.tools { display: flex; gap: 8px; align-items: center; }
.tools select { width: auto; }
.switch { display: flex; padding: 3px; border-radius: 10px; background: var(--soft); }
.switch button { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.switch button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.select-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 8px 8px 14px; margin-bottom: 14px; border-radius: 12px; background: var(--green-soft); font-size: 13.5px; }
.select-bar b { margin-right: auto; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.doc-card { position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; transition: box-shadow .15s, transform .15s; }
.doc-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.doc-card.selected { outline: 3px solid var(--green); outline-offset: -1px; }
.doc-open { display: block; width: 100%; text-align: left; }
.doc-thumb { display: block; aspect-ratio: 4 / 3.4; background: var(--canvas); position: relative; overflow: hidden; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.doc-thumb i { position: absolute; right: 8px; bottom: 8px; font-style: normal; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: rgba(0, 0, 0, .62); color: #fff; }
.doc-meta { display: grid; gap: 3px; padding: 11px 12px 44px; }
.doc-meta strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta small { font-size: 12px; color: var(--muted); }
.doc-meta em { font-style: normal; color: var(--green); font-weight: 650; }
.doc-meta .snippet { background: var(--soft); border-radius: 6px; padding: 4px 6px; line-height: 1.45; }
.doc-actions { position: absolute; left: 6px; right: 6px; bottom: 4px; display: flex; }
.doc-actions .icon-button { width: 34px; height: 34px; }
.doc-actions .danger { margin-left: auto; }
.doc-check { position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; border-radius: 7px; border: 2px solid #fff; background: rgba(0, 0, 0, .28); display: none; place-items: center; color: transparent; }
.doc-check svg { width: 16px; height: 16px; }
.selecting .doc-check { display: grid; }
.selecting .doc-actions { visibility: hidden; }
.doc-card.selected .doc-check { background: var(--green); color: #fff; }
.doc-grid.as-list { grid-template-columns: 1fr; gap: 8px; }
.as-list .doc-open { display: grid; grid-template-columns: 64px 1fr; align-items: center; }
.as-list .doc-thumb { aspect-ratio: 1; }
.as-list .doc-meta { padding: 8px 130px 8px 14px; }
.as-list .doc-actions { left: auto; right: 8px; top: 0; bottom: 0; align-items: center; }
.as-list .doc-check { top: 20px; left: 20px; }
.empty { text-align: center; padding: 50px 20px; border: 1.5px dashed var(--line); border-radius: 18px; color: var(--muted); display: grid; justify-items: center; gap: 8px; }
.empty [data-icon] svg { width: 34px; height: 34px; }
.empty h3 { color: var(--ink); font-size: 17px; margin-top: 6px; }
.empty p { font-size: 13.5px; }
.empty .link { margin-top: 6px; }
.foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 44px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.foot span { display: inline-flex; align-items: center; gap: 7px; }
.foot svg { width: 14px; height: 14px; }

/* ---------- Editor ---------- */
dialog { color: var(--ink); }
.editor { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--bg); }
.editor[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.editor-head { display: flex; align-items: center; gap: 6px; padding: 9px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.title-wrap { flex: 1; min-width: 0; display: grid; margin: 0 6px; }
.title-wrap input { border-color: transparent; background: none; font-size: 16px; font-weight: 700; padding: 3px 8px; min-height: 30px; margin-left: -8px; text-overflow: ellipsis; }
.title-wrap input:hover { border-color: var(--line); }
.title-wrap small { font-size: 11.5px; color: var(--muted); }
.editor-body { display: grid; grid-template-columns: 136px minmax(0, 1fr) 336px; min-height: 0; }
.pages-panel { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.panel-label { font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase; font-weight: 700; color: var(--muted); padding: 14px 14px 8px; }
#thumbnails { flex: 1; overflow-y: auto; padding: 4px 14px 12px; display: grid; gap: 10px; align-content: start; }
.thumb { position: relative; border-radius: 8px; border: 2px solid var(--line); background: var(--canvas); overflow: hidden; aspect-ratio: 3 / 4; }
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.thumb b { position: absolute; left: 5px; bottom: 5px; font-size: 10.5px; padding: 1px 6px; border-radius: 5px; background: rgba(0, 0, 0, .62); color: #fff; }
.thumb i { position: absolute; right: 5px; bottom: 5px; font: 700 10px/1 inherit; padding: 3px 5px; border-radius: 5px; background: var(--accent); color: #1c2b24; }
.thumb.active { border-color: var(--green); box-shadow: 0 0 0 2px var(--green-soft); }
.thumb.drop { border-style: dashed; border-color: var(--green); opacity: .6; }
.page-tools { display: flex; justify-content: space-between; padding: 6px; border-top: 1px solid var(--line); }
.page-tools .icon-button { width: 30px; height: 34px; }
.preview { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; min-height: 0; background: var(--canvas); }
.preview-bar { display: flex; align-items: center; gap: 10px; padding: 5px 8px 5px 16px; font-size: 12.5px; color: var(--muted); }
.preview-bar > div { margin-left: auto; display: flex; }
#crop-size { font-variant-numeric: tabular-nums; padding: 2px 8px; border-radius: 6px; background: var(--surface); color: var(--ink); }
.viewport { min-height: 0; display: grid; place-items: center; overflow: hidden; position: relative; }
.stage { position: relative; box-shadow: 0 6px 30px rgba(0, 0, 0, .22); background: #fff; touch-action: none; }
#preview-canvas { width: 100%; height: 100%; display: block; }
#crop-layer { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; touch-action: none; }
#crop-layer .shade { fill: rgba(8, 16, 12, .55); pointer-events: none; }
#crop-layer .outline { fill: transparent; stroke: #dff09c; stroke-width: 2; vector-effect: non-scaling-stroke; cursor: move; }
#crop-layer .outline.bad { stroke: #ff7b7b; }
#crop-layer .handle { cursor: grab; outline: none; }
#crop-layer .hit { fill: transparent; }
#crop-layer .dot { fill: #fff; stroke: var(--brand); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
#crop-layer .handle:focus-visible .dot { fill: #dff09c; stroke-width: 4; }
.loupe { position: absolute; left: 10px; top: 10px; width: 132px; height: 132px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 6px 20px rgba(0, 0, 0, .4); pointer-events: none; z-index: 2; }
.loupe.right { left: auto; right: 10px; }
.placer { position: absolute; border: 1.5px dashed #2563eb; background: rgba(37, 99, 235, .06); cursor: move; touch-action: none; }
.placer img { width: 100%; display: block; pointer-events: none; user-select: none; }
.placer .grip { position: absolute; right: -11px; bottom: -11px; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 3px solid #2563eb; cursor: nwse-resize; }
.placer .grip::after { content: ""; position: absolute; inset: -12px; }
.action-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; background: var(--surface); border-top: 1px solid var(--line); }
.modes { display: flex; padding: 3px; border-radius: 10px; background: var(--soft); overflow-x: auto; max-width: 100%; }
.modes button { padding: 7px 11px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.modes button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .14); }
.action-end { margin-left: auto; display: flex; gap: 8px; }
.tools-panel { border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; min-height: 0; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; position: sticky; top: 0; background: var(--surface); z-index: 1; border-bottom: 1px solid var(--line); }
.tabs button { padding: 14px 8px 12px; font-size: 13.5px; font-weight: 650; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--ink); border-color: var(--green); }
.tool-section { padding: 18px 16px; border-bottom: 1px solid var(--line); display: grid; gap: 12px; }
.tool-section h3 { font-size: 13.5px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.triple { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.triple .button { padding: 0 6px; }
.tile { display: grid; justify-items: center; gap: 6px; padding: 12px 6px; border-radius: 11px; background: var(--soft); font-size: 12.5px; font-weight: 600; }
.tile:hover { background: var(--soft-2); }
.tile.small { padding: 9px 2px; font-size: 11px; font-weight: 550; color: var(--muted); }
.tile.accent { background: var(--green); color: var(--green-ink); }
.tile.accent:hover { filter: brightness(1.1); background: var(--green); }
.tile.active { outline: 2px solid var(--green); }
.filters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.filters button { display: grid; gap: 5px; border-radius: 9px; padding: 3px 3px 5px; border: 2px solid transparent; }
.filters .sample { aspect-ratio: 3 / 4; border-radius: 6px; background: var(--canvas) center / cover; display: block; border: 1px solid var(--line); }
.filters small { font-size: 10.5px; line-height: 1.2; color: var(--muted); font-weight: 600; }
.filters button.active { border-color: var(--green); background: var(--green-soft); }
.filters button.active small { color: var(--ink); }
.signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.signatures:empty { display: none; }
.signature { position: relative; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.signature > button:first-child { width: 100%; height: 58px; padding: 6px; display: grid; place-items: center; }
.signature img { max-width: 100%; max-height: 46px; display: block; }
.signature .remove { position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: 14px; line-height: 1; }

/* ---------- Dialog ---------- */
.modal { border: 0; border-radius: 18px; padding: 22px; width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); background: var(--surface); box-shadow: 0 24px 70px rgba(0, 0, 0, .35); }
.modal[open] { display: grid; gap: 14px; }
.modal.wide { width: min(620px, calc(100vw - 24px)); }
.modal::backdrop, .busy::backdrop { background: rgba(8, 16, 12, .55); backdrop-filter: blur(2px); }
.modal header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal h2 { font-size: 18px; letter-spacing: -.3px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.modal-actions .button { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checks { display: grid; gap: 2px; }
.export-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.export-actions .primary { flex: 1 1 180px; min-height: 46px; }
.info { font-size: 14px; line-height: 1.65; overflow-y: auto; }
.info h3 { font-size: 14px; margin: 16px 0 4px; }
.info ol { padding-left: 20px; margin: 0; display: grid; gap: 8px; }
.info p { color: var(--muted); }
#confirm-text { font-size: 14px; line-height: 1.6; color: var(--muted); }
#signature-canvas { width: 100%; aspect-ratio: 900 / 340; border: 1.5px dashed #b9c4b4; border-radius: 12px; background: #fff; touch-action: none; cursor: crosshair; }
.ink-row { display: flex; align-items: center; gap: 10px; }
.ink { width: 28px; height: 28px; border-radius: 50%; background: var(--c); border: 3px solid var(--surface); box-shadow: 0 0 0 1.5px var(--line); }
.ink.active { box-shadow: 0 0 0 2.5px var(--green); }
.spacer { flex: 1; }
.modal.camera { width: min(720px, calc(100vw - 16px)); padding: 16px; }
.camera-stage { position: relative; border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; max-height: 58dvh; }
.camera-stage video, #camera-overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#camera-quad { fill: rgba(223, 240, 156, .18); stroke: #b8f26b; stroke-width: 3; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.on { animation: flash .35s ease-out; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }
.shots { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 2px; }
.shots:empty { display: none; }
.shot { position: relative; flex: none; }
.shot img { height: 62px; border-radius: 7px; display: block; border: 1px solid var(--line); }
.shot button { position: absolute; top: -6px; right: -6px; width: 21px; height: 21px; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: 13px; line-height: 1; }
.camera-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.camera-controls .button:first-child { justify-self: start; }
.camera-controls .button:last-child { justify-self: end; }
.shutter { width: 68px; height: 68px; border-radius: 50%; border: 4px solid var(--green); display: grid; place-items: center; }
.shutter i { width: 50px; height: 50px; border-radius: 50%; background: var(--green); transition: transform .1s; }
.shutter:active:not(:disabled) i { transform: scale(.86); }
.camera-extra { display: flex; gap: 8px; justify-content: center; }
.camera-extra:not(:has(button:not([hidden]))) { display: none; }
.busy { border: 0; border-radius: 16px; padding: 24px 30px; background: var(--surface); box-shadow: 0 24px 70px rgba(0, 0, 0, .35); }
.busy > div { display: grid; justify-items: center; gap: 8px; text-align: center; }
.busy small { color: var(--muted); font-size: 12.5px; }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--soft-2); border-top-color: var(--green); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#toast { position: fixed; inset: auto 0 calc(22px + env(safe-area-inset-bottom)) 0; margin: 0 auto; width: fit-content; max-width: min(520px, calc(100vw - 28px)); padding: 11px 16px; border: 0; border-radius: 12px; background: #16211b; color: #fff; font-size: 13.5px; line-height: 1.45; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none; z-index: 20; }
#toast.show { opacity: 1; transform: none; }
#toast:not(.show):not(:popover-open) { visibility: hidden; }

.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.swatches button { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 10px; border: 2px solid var(--line); font-size: 13px; font-weight: 600; color: var(--ink); }
.swatches i { width: 20px; height: 20px; border-radius: 50%; background: var(--c); flex: none; }
.swatches button[aria-pressed="true"] { border-color: var(--green); background: var(--green-soft); }
#theme-modes { width: fit-content; }
.certificate-box { display: grid; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--green-soft); }
.certificate-box .check { align-items: flex-start; font-size: 13.5px; line-height: 1.4; }
.certificate-box .check input { margin-top: 2px; flex: none; }
.certificate-box small { color: var(--muted); font-size: 12px; }
.thumb u { position: absolute; right: 5px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: #2563eb; border: 2px solid #fff; }
.verify-file { font-size: 12.5px; word-break: break-all; }
.verdict { display: grid; gap: 4px; padding: 14px 16px; border-radius: 12px; margin: 10px 0 14px; border-left: 5px solid; font-size: 13.5px; line-height: 1.5; }
.verdict strong { font-size: 16px; }
.verdict.good { background: color-mix(in srgb, #1f9d55 14%, var(--surface)); border-color: #1f9d55; }
.verdict.bad { background: color-mix(in srgb, #d64545 14%, var(--surface)); border-color: #d64545; }
.verdict.warn { background: color-mix(in srgb, #d99a1c 16%, var(--surface)); border-color: #d99a1c; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 12px; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; word-break: break-word; }

/* ---------- Responsif ---------- */
@media (max-width: 1100px) {
  .editor-body { grid-template-columns: 112px minmax(0, 1fr) 300px; }
  #thumbnails { padding: 4px 10px 12px; }
}
@media (max-width: 900px) {
  .sidebar { position: static; width: auto; flex-direction: row; align-items: center; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); gap: 4px; overflow-x: auto; scrollbar-width: none; }
  .sidebar .brand, .side-label, .side-note, .storage, #guide-nav { display: none; }
  .sidebar nav { display: flex; gap: 2px; flex: none; }
  .nav-item { padding: 8px 10px; font-size: 12.5px; gap: 7px; white-space: nowrap; }
  .nav-item svg { width: 17px; height: 17px; }
  .main { margin-left: 0; }
  .brand.compact { display: flex; }
  .hero { grid-template-columns: 1fr; }
  .editor-body { display: flex; flex-direction: column; overflow-y: auto; }
  .preview { order: 1; flex: none; height: 56dvh; position: sticky; top: 0; z-index: 2; }
  .pages-panel { order: 2; flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); flex: none; }
  .panel-label { display: none; }
  #thumbnails { display: flex; align-items: center; min-width: 0; overflow-x: auto; overflow-y: hidden; padding: 8px 10px; }
  .thumb { width: 54px; height: 72px; flex: none; }
  .page-tools { border-top: 0; border-left: 1px solid var(--line); padding: 4px; }
  .tools-panel { order: 3; border-left: 0; overflow: visible; flex: none; }
  .tabs { position: static; }
}
@media (max-width: 620px) {
  .hide-small { display: none; }
  .button { padding: 0 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; gap: 1px; }
  .facts dd { margin-bottom: 8px; }
  .editor-head { padding: 7px 8px; gap: 2px; }
  .icon-button { width: 36px; }
  .title-wrap input { font-size: 14.5px; }
  .title-wrap small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .preview-bar { font-size: 11.5px; padding-left: 10px; }
  .doc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .section-head { align-items: flex-start; }
  .tools select { max-width: 130px; }
  .action-end { width: 100%; }
  .action-end .button { flex: 1; }
  .loupe { width: 104px; height: 104px; }
  .modal { padding: 18px; }
  .page-tools { display: grid; grid-template-columns: 1fr 1fr; align-content: center; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
@media print { .sidebar, .topbar, .hero, .foot { display: none; } }
