:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #4d5a66;
  --paper: #f7f3ea;
  --panel: #fffdf7;
  --line: #c9c0ad;
  --green: #14532d;
  --green-dark: #0d3b20;
  --gold: #f2c14e;
  --danger: #8a1f1f;
  --focus: #005fcc;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; }
button, .file-btn, select, input[type="text"], textarea {
  border-radius: 14px;
}
button, .file-btn {
  min-height: 56px;
  border: 2px solid transparent;
  padding: 0.8rem 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 750;
  cursor: pointer;
  text-align: center;
  transition: background-color 120ms ease, border-color 120ms ease;
}
button:disabled { cursor: not-allowed; opacity: 0.48; }
button:focus-visible, .file-btn:focus-within, input:focus-visible, select:focus-visible, textarea:focus-visible, .corner-handle:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}
.primary { background: var(--green); color: #fff; }
.primary:hover:not(:disabled) { background: var(--green-dark); }
.primary.strong { background: var(--ink); }
.primary-alt { background: var(--gold); color: var(--ink); }
.secondary { background: #fff; color: var(--ink); border-color: var(--ink); }
.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem clamp(1rem, 4vw, 3rem);
  background: var(--ink);
  color: #fff;
}
.app-header h1 { margin: 0; font-size: clamp(2rem, 7vw, 4.5rem); line-height: 0.95; letter-spacing: -0.045em; }
.eyebrow { margin: 0 0 0.4rem; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 800; font-size: 0.78rem; color: var(--gold); }
.exp-tag { flex: 0 0 auto; border: 1px solid rgba(255,255,255,0.55); border-radius: 999px; padding: 0.35rem 0.65rem; font-weight: 800; }
main { width: min(1180px, 100%); margin: 0 auto; padding: 1rem clamp(0.75rem, 3vw, 2rem) 2rem; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: clamp(1rem, 3vw, 1.75rem);
  margin: 0 0 1rem;
  box-shadow: 0 12px 30px rgba(23,32,42,0.07);
}
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.section-head > div { display: flex; align-items: center; gap: 0.75rem; }
h2 { margin: 0; font-size: clamp(1.45rem, 4vw, 2.1rem); line-height: 1.1; }
h3 { margin-top: 0; }
.step { display: inline-grid; place-items: center; width: 2.3rem; height: 2.3rem; border-radius: 50%; background: var(--gold); font-weight: 900; }
.status-chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 0.35rem 0.65rem; font-size: 0.9rem; font-weight: 700; }
.lede { max-width: 68ch; font-size: 1.05rem; }
.hint { color: var(--muted); font-size: 0.94rem; }
.msg { min-height: 1.45em; font-weight: 700; }
.msg:empty { min-height: 0; }
.action-grid, .export-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0.75rem; align-items: stretch; }
.export-grid.compact { margin: 0.75rem 0; }
.camera-wrap { position: relative; overflow: hidden; border-radius: 20px; background: #05080a; aspect-ratio: 4 / 3; margin: 1rem 0; }
.camera-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-guide { position: absolute; inset: 8% 7%; border: 3px solid #fff; border-radius: 12px; display: flex; align-items: flex-start; justify-content: center; pointer-events: none; box-shadow: 0 0 0 999px rgba(0,0,0,0.22); }
.camera-guide span { background: #fff; color: var(--ink); padding: 0.3rem 0.6rem; border-radius: 0 0 10px 10px; font-weight: 800; }
.empty-state, .empty-copy { border: 2px dashed var(--line); border-radius: 18px; padding: 1rem; background: #fff; }
.editor-grid { display: grid; gap: 1.25rem; }
.corner-stage { position: relative; width: 100%; background: #20262c; border-radius: 18px; overflow: hidden; line-height: 0; }
.corner-stage canvas { display: block; width: 100%; height: auto; }
.corner-overlay { position: absolute; inset: 0; line-height: normal; }
.corner-outline { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.corner-outline polygon { fill: rgba(242,193,78,0.13); stroke: var(--gold); stroke-width: 3; vector-effect: non-scaling-stroke; }
.corner-handle {
  position: absolute;
  width: 48px; height: 48px;
  min-height: 48px;
  padding: 0;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: transparent;
  border-color: transparent;
  z-index: 2;
}
.corner-handle::after {
  content: "";
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #22c55e;
  border: 4px solid #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.45);
}
.tool-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; margin-top: 1rem; }
.tool-row label, .session-name { display: grid; gap: 0.3rem; font-weight: 750; }
select, input[type="text"] { min-height: 52px; border: 2px solid var(--ink); background: #fff; color: var(--ink); padding: 0.65rem 0.8rem; }
.preview-card { margin: 0; }
.preview-card figcaption { font-weight: 850; margin-bottom: 0.5rem; }
.preview-card canvas { width: 100%; height: auto; max-height: 72vh; object-fit: contain; background: #e8e2d4; border: 1px solid var(--line); border-radius: 12px; }
.page-list { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: 0.75rem; }
.page-card { display: grid; grid-template-columns: 76px 1fr; gap: 0.85rem; align-items: center; border: 1px solid var(--line); border-radius: 18px; padding: 0.7rem; background: #fff; }
.page-card.selected { border: 3px solid var(--green); }
.page-card img { width: 76px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: #eee; }
.page-card h3 { margin: 0 0 0.25rem; font-size: 1rem; }
.page-card p { margin: 0.15rem 0; color: var(--muted); }
.mini-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.55rem; }
.mini-actions button { min-height: 44px; padding: 0.45rem 0.7rem; border-radius: 999px; }
.ocr-box { border-top: 1px solid var(--line); margin-top: 1.5rem; padding-top: 1.25rem; }
.ocr-box label { display: grid; gap: 0.4rem; font-weight: 750; margin-top: 1rem; }
textarea { width: 100%; border: 2px solid var(--ink); padding: 0.8rem; background: #fff; color: var(--ink); resize: vertical; }
footer { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; padding: 1.25rem clamp(1rem, 4vw, 3rem); background: var(--ink); color: #fff; }
footer span:first-child { font-weight: 900; }
@media (min-width: 900px) {
  .editor-grid { grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr); }
  .page-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
