
:root {
  --bg: #0b0c10;
  --panel: #12141b;
  --panel-2: #171922;
  --panel-3: #1f2330;
  --line: #2a3142;
  --text: #eef2ff;
  --muted: #9aa6c2;
  --accent: #7c3aed;
  --accent-2: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0,0,0,.35);
  --font: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
#app { height: 100vh; display: grid; grid-template-rows: 64px 1fr; }
header { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: rgba(18,20,27,.92); backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg,var(--accent),#06b6d4); font-weight: 800; }
.brand h1 { font-size: 18px; margin: 0; }
.sub { color: var(--muted); font-size: 12px; }
.toolbar-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn, .icon-btn, .chip, select, .field, .range-wrap { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 12px; }
.btn, .icon-btn, .chip { padding: 10px 12px; min-height: 42px; }
.btn.primary { background: linear-gradient(135deg,var(--accent),#4f46e5); border-color: transparent; }
.btn.green { background: linear-gradient(135deg,#16a34a,var(--accent-2)); border-color: transparent; color: #08130c; font-weight: 700; }
.btn.warn { background: linear-gradient(135deg,#f59e0b,#f97316); border-color: transparent; color: #201300; font-weight: 700; }
.icon-btn.active, .chip.active { outline: 2px solid var(--accent); }
main { min-height: 0; display: grid; grid-template-columns: 260px 1fr 320px; }
aside, .rightbar { background: var(--panel); border-right: 1px solid var(--line); min-height: 0; overflow: auto; }
.rightbar { border-left: 1px solid var(--line); border-right: 0; padding: 14px; }
.sidebar-head, .panel-title { display: flex; justify-content: space-between; align-items: center; padding: 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 2; }
#thumbs { padding: 10px; display: grid; gap: 10px; }
.thumb { padding: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.thumb.active { outline: 2px solid var(--accent); }
.thumb canvas { width: 100%; display: block; border-radius: 8px; background: white; }
.thumb .meta { margin-top: 6px; display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.viewer-shell { min-height: 0; overflow: auto; padding: 20px; position: relative; }
#dropzone { border: 2px dashed var(--line); border-radius: 20px; padding: 28px; color: var(--muted); text-align: center; margin-bottom: 18px; }
#stage { position: relative; width: fit-content; margin: 0 auto; }
#pdfCanvas, #overlayCanvas, #textLayer { display: block; background: white; border-radius: 14px; box-shadow: var(--shadow); }
#overlayCanvas, #textLayer { position: absolute; left: 0; top: 0; }
#textLayer { opacity: .22; pointer-events: none; }
.panel { background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; padding: 12px; margin-bottom: 12px; }
.panel h3 { margin: 0 0 10px; font-size: 14px; }
.stack { display: grid; gap: 8px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.field, select { width: 100%; padding: 10px 12px; min-height: 42px; }
.range-wrap { padding: 8px 10px; }
input[type='range'] { width: 100%; }
.swatches { display: grid; grid-template-columns: repeat(6,1fr); gap: 8px; }
.swatch { width: 100%; aspect-ratio: 1; border-radius: 10px; border: 2px solid transparent; }
.swatch.active { outline: 2px solid white; }
#layersList, #docList { display: grid; gap: 8px; max-height: 240px; overflow: auto; }
.layer-item, .doc-item { background: var(--panel-3); border: 1px solid var(--line); border-radius: 12px; padding: 10px; font-size: 13px; }
.layer-item .row, .doc-item .row { margin-top: 8px; }
#toast { position: fixed; right: 18px; bottom: 18px; background: rgba(18,20,27,.96); color: var(--text); border: 1px solid var(--line); padding: 12px 14px; border-radius: 12px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); transition: .18s ease; z-index: 100; max-width: 360px; }
#toast.show { opacity: 1; transform: translateY(0); }
#toast.success { border-color: rgba(34,197,94,.6); }
#toast.error { border-color: rgba(239,68,68,.7); }
#signatureModal, #textModal, #splitModal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; place-items: center; z-index: 90; }
.modal-card { width: min(92vw, 620px); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 16px; box-shadow: var(--shadow); }
.modal-card h2 { margin: 0 0 8px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
#signaturePad { width: 100%; height: 220px; background: white; border-radius: 12px; touch-action: none; }
#statusbar { position: sticky; bottom: 0; display:flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top:1px solid var(--line); background: rgba(18,20,27,.96); color: var(--muted); font-size: 12px; }
.hidden { display: none !important; }
.text-token { position:absolute; white-space:pre; color: transparent; transform-origin: 0 0; }
@media (max-width: 1180px) { main { grid-template-columns: 220px 1fr; } .rightbar { display:none; } }
@media (max-width: 820px) { main { grid-template-columns: 1fr; } aside { display:none; } header { padding:10px; } }
