:root {
  color-scheme: light;
  --canvas: #eaf2ff;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --ink: #24372f;
  --muted: #687b71;
  --quiet: #6f83a3;
  --line: #d8e4f3;
  --blue: #285fe8;
  --blue-hover: #174bd1;
  --blue-soft: #edf3ff;
  --green: #4c9673;
  --ok: #28734e;
  --err: #b3402f;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #141d2b;
  --surface: #1d293a;
  --surface-soft: #233247;
  --ink: #e6edf8;
  --muted: #a0b0c5;
  --quiet: #8da2c2;
  --line: #34465f;
  --blue: #6f9bff;
  --blue-hover: #8bafff;
  --blue-soft: #263a5f;
  --green: #7cb99a;
  --ok: #7fd1a1;
  --err: #f0a597;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100vh;
  padding: 6px 20px 28px;
  color: var(--ink);
  background-color: var(--canvas);
  background-image: linear-gradient(rgba(64, 112, 184, .055) 1px, transparent 1px), linear-gradient(90deg, rgba(64, 112, 184, .055) 1px, transparent 1px);
  background-size: 25px 25px;
  font: 12px/1.45 var(--mono);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
h1, h2, h3, p { margin: 0; }
.window { max-width: 1480px; margin: 0 auto; }
.topbar {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 12px;
  border: 1px solid #d9e4f3;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 3px 12px rgba(42, 76, 128, .1);
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; color: inherit; text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; flex: 0 0 32px;
  display: grid; place-items: center;
  border-radius: 8px; background: var(--blue); color: #fff;
  font-size: 12px; font-weight: 800;
}
.brand-copy { display: grid; gap: 1px; min-width: 0; }
.brand-copy h1 { font-size: 14px; font-weight: 750; line-height: 1.2; }
.brand-copy > span { color: var(--quiet); font-size: 10px; white-space: nowrap; }
.toolbar-actions { display: flex; align-items: center; gap: 10px; }
.status-pill, .ready-indicator { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; font-weight: 700; white-space: nowrap; }
.status-pill { padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; }
.status-pill i, .ready-indicator i { width: 8px; height: 8px; border: 2px solid #cbe6d5; border-radius: 50%; background: var(--green); }
.theme-toggle { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.theme-toggle button { border: 0; border-radius: 5px; padding: 4px 10px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 650; }
.theme-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--blue); box-shadow: 0 1px 3px rgba(20, 45, 90, .12); }
.module-nav { min-height: 40px; display: flex; align-items: stretch; justify-content: space-between; border-bottom: 1px solid var(--line); }
.nav-context { display: flex; align-items: center; color: var(--quiet); font-size: 10px; font-weight: 700; }
.active-tab { display: flex; align-items: center; padding: 0 12px; border-bottom: 2px solid var(--blue); color: var(--blue); font-size: 12px; font-weight: 750; }
.page-heading { padding: 12px 2px 8px; }
.eyebrow { margin-bottom: 2px; color: var(--blue); font-size: 9px; font-weight: 750; }
.page-heading h2 { font-size: 17px; line-height: 1.25; font-weight: 750; }
.workspace { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 6px 18px rgba(33, 62, 110, .06); }
.capture-form { display: grid; }
.form-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); padding: 16px; }
.form-section { min-width: 0; }
.source-section { padding-right: 20px; }
.settings-section { padding-left: 20px; border-left: 1px solid var(--line); }
.section-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.step-number { width: 26px; height: 26px; flex: 0 0 26px; display: grid; place-items: center; border-radius: 7px; background: var(--blue); color: #fff; font-size: 10px; font-weight: 800; }
.section-heading h3 { font-size: 15px; font-weight: 750; line-height: 1.2; }
.section-heading small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.input-mode-options, .device-options { min-width: 0; margin: 0; padding: 0; border: 0; }
.input-mode-options { display: flex; align-items: center; gap: 7px; margin-bottom: 12px; }
.input-mode-options legend, .device-options legend { width: 100%; margin-bottom: 7px; color: var(--ink); font-size: 11px; font-weight: 700; }
.input-mode-options label { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--muted); cursor: pointer; }
.input-mode-options label:has(input:checked) { border-color: #a9c1ff; background: var(--blue-soft); color: #2447a8; }
.input-mode-options input { accent-color: var(--blue); }
.field-label { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 6px; color: var(--ink); font-size: 11px; font-weight: 700; }
.optional { color: var(--muted); font-size: 9px; font-weight: 500; }
textarea, input[type="text"] { width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid #c9d9ed; border-radius: 6px; outline: 0; background: var(--surface); color: var(--ink); }
textarea { min-height: 148px; resize: vertical; line-height: 1.55; }
textarea::placeholder, input[type="text"]::placeholder { color: #91a0a0; }
textarea:focus, input[type="text"]:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(40, 95, 232, .12); }
.device-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.device-options legend { grid-column: 1 / -1; }
.device-options label { display: flex; align-items: center; gap: 7px; min-height: 34px; padding: 6px 9px; border: 1px solid #b7cbff; border-radius: 6px; background: var(--blue-soft); color: #2447a8; cursor: pointer; }
.device-options input, .popup-option input { width: 15px; height: 15px; margin: 0; accent-color: var(--blue); }
.popup-option { display: inline-flex; align-items: center; gap: 8px; margin-top: 18px; color: var(--ink); font-weight: 650; cursor: pointer; }
.settings-note { margin: 6px 0 0 23px; color: var(--muted); font-size: 10px; }
.form-footer { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--surface); }
.form-actions { display: flex; gap: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 12px; min-height: 36px; padding: 8px 13px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); cursor: pointer; font-weight: 700; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-soft); }
.btn.primary { border-color: var(--blue); background: var(--blue); color: #fff; box-shadow: 0 5px 12px rgba(40, 95, 232, .2); }
.btn.primary:hover { border-color: var(--blue-hover); background: var(--blue-hover); }
.btn:disabled, .btn.disabled { opacity: .5; pointer-events: none; }
.progress { margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.bar { height: 5px; overflow: hidden; border-radius: 99px; background: var(--surface-soft); }
.fill { width: 0; height: 100%; border-radius: inherit; background: var(--blue); transition: width .25s ease; }
.fill.error { background: var(--err); }
.meta { display: flex; justify-content: space-between; margin-top: 8px; color: var(--muted); font-size: 10px; }
.stages { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.stages li { padding: 3px 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-soft); color: var(--muted); font-size: 9px; }
.stages li.done { border-color: #c8e4d3; background: #eff8f2; color: #366e4d; }
.stages li.active { border-color: #a9c1ff; background: var(--blue-soft); color: var(--blue); }
.notice { margin-top: 12px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.notice.success { border-color: #bcd9c7; background: #eef6f1; color: var(--ok); }
.notice.error { border-color: #e6c3bc; background: #fbeeeb; color: var(--err); }
.results { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.results-toolbar { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.capture-result { padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.capture-result h2 { margin: 0 0 8px; color: var(--ink); font-size: 12px; font-weight: 700; overflow-wrap: anywhere; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.folder { color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.preview { width: 100%; aspect-ratio: 5 / 3; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.preview img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; }
[hidden] { display: none !important; }
@media (max-width: 1000px) { .results { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  body { padding: 8px 10px 20px; }
  .form-grid { grid-template-columns: 1fr; gap: 18px; }
  .source-section { padding-right: 0; }
  .settings-section { padding: 16px 0 0; border-top: 1px solid var(--line); border-left: 0; }
}
@media (max-width: 520px) {
  .results { grid-template-columns: 1fr; }
  body { padding: 6px 8px 16px; }
  .topbar { align-items: flex-start; }
  .brand-copy h1 { font-size: 12px; }
  .brand-copy > span { max-width: 190px; white-space: normal; overflow: visible; text-overflow: clip; }
  .toolbar-actions { flex-direction: column-reverse; align-items: flex-end; gap: 5px; }
  .status-pill { display: none; }
  .nav-context { font-size: 8px; }
  .form-grid { padding: 13px; }
  .form-footer { align-items: flex-start; flex-direction: column; padding: 12px 13px; }
  .form-actions { width: 100%; }
  .form-actions .btn { flex: 1; white-space: normal; }
  .device-options { grid-template-columns: 1fr; }
  .device-options legend { grid-column: auto; }
  .actions .btn { flex: 1; }
}
