:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #5f6b7a;
  --border: #d8dee6;
  --border-strong: #b9c3cf;
  --accent: #0b6bcb;
  --accent-ink: #ffffff;
  --accent-soft: #e7f1fb;
  --ok: #1e7f4f;
  --ok-soft: #e6f4ec;
  --warn: #8a5a00;
  --warn-soft: #fff5dc;
  --error: #b42318;
  --error-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: "Lato", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1rem; }
code, kbd { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85em; background: #eef1f5; padding: .05em .35em; border-radius: 4px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .9rem 1.5rem; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: .75rem; }
.brand svg { width: 34px; height: 34px; flex: none; }
.brand svg rect { fill: var(--accent); }
.brand svg path { stroke: #fff; stroke-width: 3.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.brand h1 { font-size: 1.1rem; margin: 0; }
.brand p { margin: 0; font-size: .85rem; color: var(--muted); }

.steps { display: flex; gap: .25rem; list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.steps li { display: flex; align-items: center; gap: .4rem; padding: .35rem .7rem; border-radius: 999px; color: var(--muted); }
.steps li span { display: inline-grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: 50%; border: 1.5px solid currentColor; font-size: .78rem; font-weight: 700; }
.steps li.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.steps li.done { color: var(--ok); }

main { max-width: 980px; margin: 1.5rem auto 4rem; padding: 0 1rem; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.lead { color: var(--muted); margin: 0 0 1.25rem; max-width: 70ch; }

.dropzone { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: 2.25rem 1rem; border: 2px dashed var(--border-strong); border-radius: var(--radius); text-align: center; cursor: pointer; transition: background .15s, border-color .15s; }
.dropzone svg { width: 38px; height: 38px; stroke: var(--accent); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dropzone:hover, .dropzone:focus-visible, .dropzone.drag { background: var(--accent-soft); border-color: var(--accent); outline: none; }
.dropzone strong { font-size: 1.05rem; }
.dropzone u { color: var(--accent); }

.or { display: flex; align-items: center; gap: .75rem; margin: 1.25rem 0 .75rem; color: var(--muted); font-size: .85rem; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

textarea, input[type="text"], input[type="number"], select {
  font: inherit; color: inherit; background: #fff; border: 1px solid var(--border-strong); border-radius: 7px; padding: .5rem .65rem; width: 100%;
}
textarea { resize: vertical; }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
select { width: auto; padding-right: 1.8rem; }
input[type="number"] { width: 6.5rem; }

.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: .75rem; }
.row.between { justify-content: space-between; margin-top: 1.25rem; }
.grow { flex: 1; min-width: 220px; }
.inline { display: inline-flex; align-items: center; gap: .45rem; font-size: .9rem; color: var(--muted); }
.check { cursor: pointer; }

.btn { font: inherit; font-weight: 600; border: 1px solid var(--border-strong); background: #fff; color: var(--text); padding: .5rem .95rem; border-radius: 7px; cursor: pointer; }
.btn:hover { background: #f0f3f7; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(.94); }
.btn.big { padding: .75rem 1.4rem; font-size: 1.05rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { font: inherit; border: 1px solid transparent; background: none; color: var(--muted); border-radius: 6px; width: 2rem; height: 2rem; cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn:hover { background: #eef1f5; color: var(--text); }
.icon-btn.danger:hover { background: var(--error-soft); color: var(--error); }
.link-btn { font: inherit; font-size: .88rem; background: none; border: 0; color: var(--accent); cursor: pointer; padding: .25rem 0; }

.progress { margin-top: 1rem; display: grid; gap: .4rem; }
.progress .bar { height: 6px; background: #e4e9ef; border-radius: 99px; overflow: hidden; }
.progress .bar div { height: 100%; width: 30%; background: var(--accent); border-radius: 99px; transition: width .2s; }
.progress.indeterminate .bar div { animation: slide 1.1s infinite ease-in-out; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
.progress span { font-size: .88rem; color: var(--muted); }

.alert { border-radius: 8px; padding: .75rem 1rem; margin-top: 1rem; font-size: .92rem; }
.alert p { margin: 0 0 .5rem; }
.alert p:last-child { margin-bottom: 0; }
.alert.error { background: var(--error-soft); color: var(--error); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--accent-soft); color: #08427e; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }

.help { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.help summary { cursor: pointer; font-weight: 700; color: var(--accent); }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; margin-top: 1rem; font-size: .9rem; }
.help-grid ul { padding-left: 1.1rem; margin: .25rem 0 .75rem; }
.help-grid p { margin: .25rem 0 .75rem; }
.help-grid h3 { margin-top: .25rem; }

/* Review */
.review-head { display: flex; gap: 1rem; flex-wrap: wrap; align-items: end; margin-bottom: .75rem; }
.field-label { display: block; font-size: .82rem; font-weight: 700; color: var(--muted); margin-bottom: .25rem; text-transform: uppercase; letter-spacing: .03em; }
.title-input { font-size: 1.25rem !important; font-weight: 700; }
.summary-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin: 1.25rem 0 .75rem; padding: .75rem 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.summary { display: flex; gap: .5rem; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; font-weight: 600; padding: .2rem .65rem; border-radius: 999px; background: #eef1f5; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.error { background: var(--error-soft); color: var(--error); }

.question { border: 1px solid var(--border); border-left: 4px solid var(--ok); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: .9rem; background: #fff; }
.question.has-warn { border-left-color: #e0a100; }
.question.has-issue { border-left-color: var(--error); }
.q-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .6rem; }
.q-num { font-weight: 800; min-width: 2.2rem; }
.q-head .spacer { flex: 1; }
.q-head label { font-size: .85rem; color: var(--muted); display: inline-flex; align-items: center; gap: .35rem; }
.q-head input[type="number"] { width: 4.5rem; padding: .3rem .45rem; }
.q-head select { padding: .3rem 1.6rem .3rem .45rem; }
.q-text { min-height: 2.6rem; }
.q-body { margin-top: .6rem; display: grid; gap: .4rem; }
.opt { display: grid; grid-template-columns: auto 1fr auto; gap: .5rem; align-items: center; }
.opt input[type="radio"], .opt input[type="checkbox"] { width: 1.15rem; height: 1.15rem; accent-color: var(--ok); }
.opt.correct input[type="text"] { border-color: var(--ok); background: var(--ok-soft); }
.opt .tf-label { padding: .4rem .2rem; font-weight: 600; }
.pair { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: .5rem; align-items: center; }
.pair .arrow { color: var(--muted); }
.hint { font-size: .82rem; color: var(--muted); margin: 0; }
.notes { margin-top: .6rem; display: grid; gap: .3rem; }
.note { font-size: .85rem; padding: .35rem .6rem; border-radius: 6px; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.issue { background: var(--error-soft); color: var(--error); }
.feedback-box { margin-top: .5rem; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--panel) 30%); padding: 1rem 0 .25rem; }

/* Send */
.engine { border: 0; padding: 0; margin: 1.25rem 0; display: flex; gap: .75rem; flex-wrap: wrap; }
.engine legend { font-weight: 700; margin-bottom: .5rem; }
.choice-card { display: flex; gap: .6rem; align-items: flex-start; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: .8rem 1rem; cursor: pointer; min-width: 240px; flex: 1; }
.choice-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice-card small { display: block; color: var(--muted); }
.choice-card input { margin-top: .25rem; accent-color: var(--accent); }
.download-box { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.download-box p { max-width: 70ch; }

/* Google import */
.small { font-size: .85rem; }
.row.nowrap { flex-wrap: nowrap; }
.row.nowrap input { flex: 1; min-width: 0; }
.google-box { margin-top: 1rem; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; background: #fbfcfe; }
.google-box p { margin: .25rem 0 .75rem; }
.google-box .hint { margin: .35rem 0 .9rem; }
.google-head { display: flex; align-items: center; gap: .55rem; margin-bottom: .35rem; }
.google-head svg { width: 20px; height: 20px; flex: none; }
.google-head h3 { margin: 0; }
dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: 0 20px 50px rgba(16, 24, 40, .25); color: var(--text); }
dialog::backdrop { background: rgba(16, 24, 40, .45); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.dialog-head h2 { margin: 0; }
.drive-results { display: grid; gap: .35rem; margin-top: .5rem; max-height: 52vh; overflow: auto; }
.drive-file { display: grid; grid-template-columns: auto auto 1fr auto; gap: .75rem; align-items: center; text-align: left; font: inherit; color: inherit; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem; cursor: pointer; }
.drive-file input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.drive-file:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.drive-foot { margin-top: .75rem; }
.drive-file:hover, .drive-file:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.drive-file .name { font-weight: 600; overflow-wrap: anywhere; }
.drive-file .meta { font-size: .82rem; color: var(--muted); }
.drive-file .open { font-size: .85rem; color: var(--accent); font-weight: 600; white-space: nowrap; }
.kind { display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 7px; font-size: .7rem; font-weight: 800; letter-spacing: .02em; color: #fff; }
.kind.form { background: #7248b9; }
.kind.doc { background: #2a7ae2; }
.kind.docx { background: #1f4e9c; }
.kind.pdf { background: #c8372d; }
.empty { padding: 1.5rem; text-align: center; color: var(--muted); }

/* Checklist */
.btn.small { padding: .3rem .7rem; font-size: .88rem; }
.hint.center { text-align: center; margin-top: .5rem; }
.list-banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 0 0 1.25rem; }
.list-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; flex-wrap: wrap; }
.list-head .grow { min-width: 0; }
.list-head h2 { margin: 0; }
.list-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .75rem 0; border-bottom: 1px solid var(--border); margin-top: .75rem; }
.quiz-list { display: grid; gap: .5rem; margin: .75rem 0 1.25rem; }
.qrow { display: grid; grid-template-columns: auto 1fr auto auto; gap: .8rem; align-items: center; border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: var(--radius); padding: .7rem .9rem; background: #fff; }
.qrow input[type="checkbox"] { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
.qrow.ok { border-left-color: var(--ok); }
.qrow.warn { border-left-color: #e0a100; }
.qrow.error { border-left-color: var(--error); }
.qrow.busy { border-left-color: var(--accent); }
.qrow-title { font-weight: 700; overflow-wrap: anywhere; }
.qrow .meta { font-size: .84rem; color: var(--muted); overflow-wrap: anywhere; }
.qrow-line { font-size: .84rem; color: var(--muted); margin-top: .15rem; }
.qrow.error .qrow-line { color: var(--error); }
.qrow-line.ok { color: var(--ok); }
.qrow-actions { display: flex; gap: .35rem; align-items: center; }
.chip.busy { background: var(--accent-soft); color: var(--accent); }
.chip.busy::before { content: ""; width: .7rem; height: .7rem; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bulk { border-top: 1px solid var(--border); padding-top: 1rem; display: grid; gap: 1rem; }
.bulk-block .engine { margin: .25rem 0 1rem; }
.scoring { font-size: .85rem; }
.scoring select { padding: .25rem 1.6rem .25rem .45rem; font-size: .85rem; }

/* Side-by-side review */
main { transition: max-width .2s; }
body.wide main { max-width: 1480px; }
.review-split.with-orig { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 1.25rem; align-items: start; }
.review-head .btn { align-self: end; }
.orig-pane { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #f3f5f8; }
.orig-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: .5rem; padding: .6rem .8rem; background: #f3f5f8; border-bottom: 1px solid var(--border); }
.orig-head .small { overflow-wrap: anywhere; }
.orig-find { padding: .4rem .8rem; border-bottom: 1px solid var(--border); background: #fff; }
.orig-find.miss { color: var(--warn); background: var(--warn-soft); }
.orig-body { padding: .75rem; }
.orig-actions { font-size: .85rem; margin-bottom: .5rem; color: var(--muted); }
.orig-page { position: relative; margin-bottom: .9rem; background: #fff; border-radius: 4px; box-shadow: var(--shadow); transition: outline-color .2s; outline: 3px solid transparent; }
.orig-page.hit { outline-color: #e0a100; }
.orig-page-label { font-size: .75rem; color: var(--muted); padding: .25rem .5rem; border-bottom: 1px solid var(--border); }
.orig-page canvas, .orig-img { display: block; width: 100%; height: auto; }
.orig-img { border-radius: 4px; box-shadow: var(--shadow); background: #fff; }
.orig-text { white-space: pre-wrap; overflow-wrap: anywhere; font: .82rem/1.5 ui-monospace, Menlo, Consolas, monospace; background: #fff; padding: .75rem; border-radius: 6px; margin: 0; }
.orig-ocr { margin: .5rem; font-size: .85rem; }
.orig-ocr summary { cursor: pointer; color: var(--accent); font-weight: 600; margin-bottom: .35rem; }
.orig-doc { background: #fff; padding: 1rem 1.25rem; border-radius: 6px; box-shadow: var(--shadow); font-size: .92rem; }
.orig-doc img { max-width: 100%; height: auto; }
.orig-doc table, .orig-table table { border-collapse: collapse; }
.orig-doc td, .orig-doc th, .orig-table td, .orig-table th { border: 1px solid var(--border); padding: .25rem .45rem; vertical-align: top; }
.orig-table { overflow-x: auto; background: #fff; border-radius: 6px; font-size: .82rem; margin-bottom: 1rem; }
.orig-sheet { margin: .5rem 0 .35rem; }
mark.orig-hit { background: #ffe58a; color: inherit; padding: 0 2px; border-radius: 2px; box-shadow: 0 0 0 2px #ffe58a; }
.gf { background: #fff; padding: 1rem; border-radius: 6px; box-shadow: var(--shadow); font-size: .92rem; }
.gf-item { border-top: 1px solid var(--border); padding: .6rem 0; }
.gf-item h4 { margin: .15rem 0 .35rem; font-size: .95rem; }
.gf-item ul { margin: 0; padding-left: 1.2rem; }
.gf-item li.key { font-weight: 700; }
.gf-meta { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.gf-section h4 { color: var(--accent); }
.key-mark { font-size: .78rem; color: var(--ok); font-weight: 700; }
.question.current { box-shadow: 0 0 0 2px var(--accent); }
@media (max-width: 960px) {
  .review-split.with-orig { grid-template-columns: 1fr; }
  .orig-pane { position: static; max-height: 55vh; }
}

@media (max-width: 640px) {
  .qrow { grid-template-columns: auto 1fr; }
  .qrow .chip, .qrow-actions { grid-column: 2; justify-self: start; }
  .topbar { padding: .75rem 1rem; }
  .steps li { padding: .3rem .45rem; }
  .panel { padding: 1rem; }
  .pair { grid-template-columns: 1fr auto; }
  .pair .arrow { display: none; }
  .sticky-actions { position: static; }
}
