:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #5d6b63;
  --line: #d9e0dc;
  --bg: #eef2ef;
  --card: #ffffff;
  --brand: #1f5a3c;
  --brand-2: #2e7d55;
  --accent: #1d4fa8;
  --accent-soft: #e8efff;
  --warn: #a8461d;
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-size: 14px; display: flex; flex-direction: column; }
button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 14px; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; width: 100%; padding: 12px; font-size: 15px; }
button.primary:hover { background: var(--brand-2); }
button.primary:disabled { opacity: .5; cursor: wait; }
button.ghost { background: transparent; }
button.ghost:hover { background: rgba(0,0,0,.05); }
button.small, .small { font-size: 12.5px; }
button.small { padding: 5px 10px; }
.muted { color: var(--muted); }
.error { color: var(--warn); font-weight: 600; }
.pill { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 99px; background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.3); }

/* header */
.bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; background: var(--brand); color: #fff; gap: 12px; }
.bar .ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.bar .ghost:hover { background: rgba(255,255,255,.12); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand small { display: block; opacity: .8; font-size: 12px; }
.mark { width: 34px; height: 34px; border-radius: 8px; background: #fff; color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.bar-actions { display: flex; gap: 8px; align-items: center; }

main { flex: 1; min-height: 0; display: flex; }

/* intake */
.intake { margin: auto; width: min(640px, 100% - 32px); padding: 32px 0; }
.intake h1 { font-size: 22px; margin: 0 0 16px; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.mode { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; }
.mode small { display: block; color: var(--muted); }
.mode:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,90,60,.12); }
.mode input { margin-top: 3px; accent-color: var(--brand); }
.drop { display: grid; gap: 10px; justify-items: center; text-align: center; padding: 44px 20px; background: var(--card); border: 2px dashed #a9b8b0; border-radius: var(--radius); cursor: pointer; transition: .15s; }
.drop:hover, .drop.over { border-color: var(--brand); background: #f6fbf8; }
.drop-icon { font-size: 34px; color: var(--brand); line-height: 1; }

/* review */
.review { flex: 1; display: grid; grid-template-columns: 1fr 340px; min-height: 0; }
.pages-wrap { overflow: auto; padding: 18px; }
.pages { display: grid; gap: 18px; justify-items: center; }
.page { position: relative; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.page canvas { display: block; }
.page-label { position: absolute; top: -1px; left: -1px; font-size: 11px; background: var(--ink); color: #fff; padding: 1px 6px; border-radius: 0 0 6px 0; }
.margin-strip { position: absolute; top: 0; right: 0; bottom: 0; width: 46px; background: linear-gradient(90deg, rgba(29,79,168,0), rgba(29,79,168,.07)); cursor: copy; }
.margin-strip:hover { background: linear-gradient(90deg, rgba(29,79,168,0), rgba(29,79,168,.16)); }

.stamp { position: absolute; cursor: grab; outline: 2px solid rgba(31,90,60,.85); outline-offset: 1px; touch-action: none; }
.stamp img { width: 100%; height: 100%; display: block; pointer-events: none; }
.stamp.dragging { cursor: grabbing; opacity: .9; }
.stamp::after { content: "drag"; position: absolute; top: -18px; left: -2px; font-size: 10px; background: var(--brand); color: #fff; padding: 1px 6px; border-radius: 4px 4px 0 0; }

.marker { position: absolute; display: flex; align-items: center; gap: 2px; transform: translateY(-50%); }
.marker select { font-size: 12px; padding: 0 2px; height: 20px; border: 1.5px solid var(--accent); background: var(--accent-soft); border-radius: 4px; font-weight: 700; }
.marker select.unset { border-color: var(--warn); background: #fff1ea; }
.marker .x { width: 16px; height: 16px; padding: 0; font-size: 11px; line-height: 1; border-radius: 50%; background: #fff; border-color: #bbb; }
.marker.hot select { box-shadow: 0 0 0 3px rgba(29,79,168,.3); }
.marker-guide { position: absolute; left: 0; height: 0; border-top: 1px dashed rgba(29,79,168,.45); pointer-events: none; }

/* panel */
.panel { background: var(--card); border-left: 1px solid var(--line); overflow: auto; display: flex; flex-direction: column; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); gap: 8px; }
.panel-head b { word-break: break-all; }
.block { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.block h3 { margin: 0 0 6px; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.block h3 .pill { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.block p { margin: 4px 0 8px; }
.row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.row input[type=range] { flex: 1; accent-color: var(--brand); }
.sticky { position: sticky; bottom: 0; background: var(--card); margin-top: auto; border-bottom: 0; border-top: 1px solid var(--line); }
.progress { display: flex; gap: 10px; align-items: center; padding: 10px 16px; background: #fffbea; border-bottom: 1px solid #f0e2a8; }
.spinner { width: 16px; height: 16px; border: 2px solid #d8c56a; border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.sl-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; max-height: 42vh; overflow: auto; }
.sl-list li { display: grid; grid-template-columns: 30px 1fr auto 46px; gap: 6px; align-items: center; padding: 5px 6px; border-radius: 6px; border: 1px solid transparent; font-size: 12.5px; }
.sl-list li:hover, .sl-list li.hot { background: var(--accent-soft); border-color: #c9d7f5; cursor: pointer; }
.sl-list .pg { color: var(--muted); font-size: 11px; }
.sl-list .desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-list .amt { font-variant-numeric: tabular-nums; }
.sl-list select { font-size: 12px; font-weight: 700; }
.conf-low { color: var(--warn); }
.totals { margin-top: 10px; display: grid; gap: 2px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.totals div { display: flex; justify-content: space-between; border-top: 1px dotted var(--line); padding-top: 2px; }

dialog { border: 0; border-radius: 12px; padding: 0; width: min(520px, 100% - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog form { padding: 20px; display: grid; gap: 12px; }
dialog h2 { margin: 0; font-size: 18px; }
dialog .stack { display: grid; gap: 4px; }
dialog input[type=password] { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 0; padding: 0; }
dialog menu .primary { width: auto; padding: 8px 18px; font-size: 14px; }
details ol { padding-left: 18px; }

@media (max-width: 860px) {
  .review { grid-template-columns: 1fr; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .modes { grid-template-columns: 1fr; }
}
