/*
 * Bayaan: a police front-desk tool. One screen per stage.
 * body[data-screen] is start, statement or review; body[data-step] lights the progress bar.
 * Only system fonts are used, so the page never calls another server.
 */
:root {
  --navy: #0b2349;
  --navy-700: #173766;
  --khaki: #b59a5a;
  --khaki-tint: #f4eedc;
  --red: #a4161a;
  --paper: #ffffff;
  --ground: #eaedf3;
  --line: #d4dbe7;
  --ink: #121f38;
  --muted: #515d74;
  --ok: #146c43;
  --check: #8a5300;
  --stamp: #3d2f8f;
  --head: Bahnschrift, "DIN Alternate", "Roboto Condensed", "Noto Sans", "Nirmala UI", sans-serif;
  --text: "Nirmala UI", "Noto Sans", "Noto Sans Devanagari", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 16px/1.5 var(--text); }
h1, h2 { margin: 0; font-family: var(--head); font-weight: 600; }
p { margin: 0; }
.sr { position: absolute; left: -9999px; }

/* ---------- header ---------- */
.top {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px 24px; align-items: center;
  padding: 10px 24px; background: var(--navy); color: #fff; border-bottom: 6px solid var(--khaki);
}
.brand { display: flex; gap: 12px; align-items: center; }
.shield { color: var(--khaki); flex: none; }
h1 { font-size: 26px; line-height: 1.15; white-space: nowrap; }
.deva { font-family: var(--text); font-weight: 400; font-size: 20px; margin-left: 6px; color: #c5d1ea; }
.brand p { font-size: 13px; color: #c5d1ea; line-height: 1.2; }
.steps { display: flex; gap: 28px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { display: flex; gap: 8px; align-items: center; font-family: var(--head); font-size: 16px; color: #a9b8d8; }
.steps li::before {
  counter-increment: step; content: counter(step);
  display: grid; place-items: center; width: 26px; height: 26px; border: 2px solid currentColor; border-radius: 50%; font-size: 14px;
}
body[data-step="1"] .steps li[data-for="1"],
body[data-step="2"] .steps li[data-for="2"],
body[data-step="3"] .steps li[data-for="3"] { color: #fff; }
body[data-step="1"] .steps li[data-for="1"]::before,
body[data-step="2"] .steps li[data-for="2"]::before,
body[data-step="3"] .steps li[data-for="3"]::before { background: var(--khaki); border-color: var(--khaki); color: var(--navy); }
body[data-step="2"] .steps li[data-for="1"]::before,
body[data-step="3"] .steps li[data-for="1"]::before,
body[data-step="3"] .steps li[data-for="2"]::before { content: "✓"; }
.tools { display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: flex-end; align-items: center; }
.demo-tag { font-size: 12.5px; padding: 3px 10px; border: 1px solid var(--khaki); border-radius: 3px; color: #f1e6c4; }
#resetBtn { background: transparent; color: #fff; border-color: #7f93bd; }
body[data-screen="start"] #resetBtn { display: none; }

/* ---------- controls ---------- */
button, select, input[type=text] { font: inherit; border-radius: 4px; }
button { font-weight: 600; padding: 8px 16px; border: 1px solid #9aa8c2; background: #fff; color: var(--navy); cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--navy); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--navy-700); }
button.big { font-size: 18px; padding: 12px 26px; }
button.link { border-color: transparent; background: transparent; text-decoration: underline; }
select, input[type=text] { padding: 9px 12px; border: 1px solid #9aa8c2; background: #fff; color: var(--ink); }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid #e09200; outline-offset: 2px; }

/* ---------- layout ---------- */
.desk { display: grid; gap: 20px; max-width: 1240px; margin: 0 auto; padding: 22px 24px; align-items: start; }
.panel { min-width: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--navy); }
h2 { font-size: 20px; color: var(--navy); }
.panel-head p { font-size: 13.5px; color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }
.hint:empty { display: none; }

/* ---------- start screen ---------- */
body[data-screen="start"] .desk { grid-template-columns: minmax(0, 600px); justify-content: center; padding-top: 40px; }
body[data-screen="start"] .stage { padding: 32px 36px; border-top: 6px solid var(--navy); }
body[data-screen="start"] :is(.ask, .status, .live, .heard, .answers, .type, .history, #fieldsCard, #reportCard, #previewCard) { display: none; }
body:not([data-screen="start"]) :is(.intro, .settings, .begin, .privacy) { display: none; }
.intro h2 { font-size: 32px; }
.intro p { margin-top: 6px; color: var(--muted); }
.settings { display: grid; gap: 8px; margin-top: 26px; }
.settings-title { font-weight: 600; }
.langs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.langs button { font-size: 20px; padding: 12px; }
.langs button[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; box-shadow: inset 0 -4px 0 var(--khaki); }
.check { display: flex; gap: 8px; align-items: center; }
.begin { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; margin-top: 24px; }
.privacy { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

/* ---------- statement and check ---------- */
body[data-screen="statement"] .desk { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
body[data-screen="statement"][data-step="2"] .desk { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
body[data-screen="statement"] :is(#reportCard, #previewCard) { display: none; }
body[data-screen="statement"] .stage { display: flex; flex-direction: column; align-items: center; text-align: center; min-height: calc(100vh - 128px); padding: 28px 32px 18px; }
.ask { display: flex; flex-direction: column; align-items: center; width: 100%; }
.mic { display: grid; place-items: center; width: 104px; height: 104px; border-radius: 50%; background: var(--ground); color: var(--navy); border: 3px solid var(--navy); }
.stage.rec .mic { background: var(--red); border-color: var(--red); color: #fff; animation: listening 1.4s ease-out infinite; }
@keyframes listening {
  from { box-shadow: 0 0 0 0 rgba(164, 22, 26, .55); }
  to { box-shadow: 0 0 0 22px rgba(164, 22, 26, 0); }
}
.prompt { margin-top: 20px; max-width: 22em; font-family: var(--head); font-size: 32px; line-height: 1.25; color: var(--navy); }
.prompt.long { font-size: 20px; line-height: 1.45; }
.prompt-sub { margin-top: 8px; max-width: 40em; color: var(--muted); }
.prompt-sub:empty { display: none; }
.status { margin-top: 14px; font-size: 14px; color: var(--muted); }
.status.rec { color: var(--red); font-weight: 600; }
.live { min-height: 24px; margin-top: 4px; font-style: italic; }
.heard { max-width: 40em; padding: 6px 14px; background: var(--ground); border-radius: 4px; font-size: 14px; }
.answers { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 18px; }
#yesBtn, #changeBtn, #skipBtn { display: none; }
.stage[data-ask="confirm"] :is(#yesBtn, #changeBtn) { display: inline-block; }
.stage[data-ask="field"] #skipBtn { display: inline-block; }
body[data-mode="demo"] .stage .answers :is(#yesBtn, #changeBtn, #skipBtn) { display: none; }
button.yes { background: var(--ok); border-color: var(--ok); color: #fff; }
.type { display: flex; gap: 8px; width: 100%; max-width: 520px; margin-top: auto; padding-top: 20px; }
.type input { flex: 1; min-width: 0; }
.history { width: 100%; margin-top: 12px; text-align: left; font-size: 14px; }
.history summary { cursor: pointer; color: var(--muted); text-align: center; }
.log { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; padding-top: 10px; }
.bubble { max-width: 85%; padding: 6px 12px; border-radius: 6px; }
.bubble small { display: block; font-size: 12px; color: var(--muted); }
.bubble.app { align-self: flex-start; background: var(--ground); }
.bubble.you { align-self: flex-end; background: var(--khaki-tint); }

/* ---------- the details ---------- */
.register { padding: 16px 18px; }
.review-note:empty, body[data-screen="statement"] .review-note { display: none; }
.dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #aab4c8; display: grid; place-items: center; font-size: 11px; line-height: 1; color: #fff; }
.dot.ok { background: var(--ok); border-color: var(--ok); }
.dot.ok::after { content: "✓"; }
.dot.check { background: var(--check); border-color: var(--check); }
.dot.check::after { content: "?"; font-weight: 700; }
.dot.missing { border-color: var(--red); }
.field {
  display: grid; grid-template-columns: 18px minmax(0, 1fr) auto auto; column-gap: 10px; align-items: center;
  grid-template-areas: "dot name why play" "dot input input play"; padding: 7px 6px; border-bottom: 1px solid var(--line);
}
.field > .dot { grid-area: dot; }
.field .inner { display: contents; }
.field .name { grid-area: name; font-size: 12.5px; color: var(--muted); }
.field input { grid-area: input; width: 100%; padding: 0; border: 0; background: transparent; font-weight: 600; text-overflow: ellipsis; }
.field input::placeholder { color: #8a95aa; font-weight: 400; }
.field .why { grid-area: why; font-size: 12px; color: var(--muted); }
.field .play { grid-area: play; }
.field.ok .why { color: var(--ok); }
.field.check .why { color: var(--check); }
.field.missing .why { color: var(--red); }
.field.asking { background: var(--khaki-tint); box-shadow: inset 4px 0 0 var(--khaki); }
.play { padding: 2px 10px; font-size: 12px; }
.register > .hint { margin-top: 12px; }
/* while speaking: a quiet checklist */
body[data-screen="statement"] :is(.field.quiet, .field .why, .field .play, .register > .hint) { display: none; }
body[data-screen="statement"] .field input { pointer-events: none; }
body[data-screen="statement"] .field { padding-block: 3px; }
body[data-screen="statement"] .field input { line-height: 1.25; }

/* ---------- officer review: details and form on the left, the draft on the right ---------- */
body[data-screen="review"] .desk { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); max-width: 1440px; }
body[data-screen="review"] .stage { display: none; }
body[data-screen="review"] .review-note { margin-top: 12px; padding: 8px 12px; background: var(--khaki-tint); border-left: 4px solid var(--khaki); font-size: 14px; }
body[data-screen="review"] #fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
body[data-screen="review"] .field { border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; }
body[data-screen="review"] .field input { margin-top: 2px; padding: 4px 8px; border: 1px solid var(--line); background: #fff; }
body[data-screen="review"] :is(#fieldsCard, #reportCard) { grid-column: 1; }
body[data-screen="review"] #previewCard {
  grid-column: 2; grid-row: 1 / span 2; position: sticky; top: 12px;
  display: flex; flex-direction: column; max-height: calc(100vh - 24px);
}
.officer { padding: 16px 18px; }
details { border-bottom: 1px solid var(--line); }
#firForm summary { padding: 10px 0; font-family: var(--head); font-size: 17px; color: var(--navy); cursor: pointer; }
.inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; }
#firForm details > .inputs { padding-bottom: 14px; }
.inputs label { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; color: var(--muted); }
.inputs .wide, .acts { grid-column: 1 / -1; }
.inputs :is(input, select, textarea) { width: 100%; min-width: 0; font: inherit; font-size: 14.5px; padding: 5px 8px; border: 1px solid #9aa8c2; border-radius: 4px; color: var(--ink); background: #fff; }
.acts { display: grid; grid-template-columns: 1.6fr 1fr; gap: 6px 10px; }
.acts span { font-size: 12.5px; color: var(--muted); }
#propValues:empty { display: none; }
#suggestBtn { font-size: 14px; background: var(--khaki-tint); border-color: var(--khaki); }
#words ol { margin: 4px 0 14px; padding-left: 22px; }
#words li { margin-bottom: 6px; }
.blank { color: var(--muted); font-style: italic; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 2px solid var(--navy); }
.toolbar p { width: 100%; font-size: 13px; }
#missing { color: var(--check); }
#missing:empty { display: none; }
.paper-scroll { flex: 1; min-height: 0; overflow: auto; padding: 16px; background: #cfd6e3; }

/* ---------- the FIR draft ---------- */
.paper {
  position: relative; min-width: 440px; max-width: 800px; margin: 0 auto; padding: 28px 30px 36px; color: #000;
  font: 13.5px/1.4 "Times New Roman", Cambria, serif;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='300'%3E%3Ctext x='210' y='160' text-anchor='middle' transform='rotate(-28 210 150)' font-family='Arial' font-size='24' font-weight='700' fill='%23a4161a' fill-opacity='0.09'%3EDRAFT. NOT REGISTERED.%3C/text%3E%3C/svg%3E");
}
.watermark { display: none; }
.sheet { width: 100%; border-collapse: collapse; }
.sheet > :is(thead, tbody) > tr > td { padding: 0; vertical-align: top; }
.running { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 10px; padding-bottom: 4px; border-bottom: 1.5px solid #000; font-weight: 700; }
.running span:last-child { text-align: right; }
.draft-mark { color: var(--red); }
.paper h3 { margin: 4px 0 0; text-align: center; text-transform: uppercase; text-decoration: underline; font-size: 17px; }
.under { text-align: center; font-weight: 700; margin-bottom: 8px; }
.sheet .item > td { padding: 6px 0; }
.sheet .item > td.no { width: 30px; font-weight: 700; }
.paper p { margin: 3px 0; }
.pair { display: inline-block; margin-right: 20px; }
.gap { display: inline-block; min-width: 80px; border-bottom: 1px dotted #444; height: 1em; vertical-align: baseline; }
.later { font-style: italic; color: #555; }
.grid { width: 100%; margin: 4px 0; border-collapse: collapse; font-size: 12.5px; }
.grid :is(th, td) { border: 1px solid #555; padding: 3px 5px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.grid .gap { min-width: 0; border: 0; }
.flag { font-size: 11px; font-style: italic; color: var(--check); }
.said { white-space: pre-wrap; }
.box { display: inline-block; width: 20px; font-size: 15px; }
.signs { display: flex; justify-content: space-between; gap: 40px; }
.signs > div { flex: 1; }
.line { height: 38px; border-bottom: 1px solid #000; }
.stamp {
  width: fit-content; max-width: 100%; margin: 4px 0 6px auto; padding: 4px 16px;
  border: 4px double var(--stamp); border-radius: 6px; color: var(--stamp);
  font-family: var(--head); font-weight: 600; text-align: center; transform: rotate(-2deg);
}
.stamp span { display: block; font-size: 11px; font-weight: 400; }

/* ---------- smaller screens ---------- */
@media (max-width: 1000px) {
  .top { grid-template-columns: 1fr auto; }
  .steps { grid-column: 1 / -1; grid-row: 2; justify-content: center; gap: 18px; }
}
@media (max-width: 860px) {
  body[data-screen] .desk, body[data-screen="statement"][data-step="2"] .desk { grid-template-columns: minmax(0, 1fr); padding: 12px; }
  body[data-screen="statement"] .stage { min-height: 0; padding: 20px 16px 14px; }
  body[data-screen="review"] #fields, .inputs { grid-template-columns: minmax(0, 1fr); }
  body[data-screen="review"] :is(#fieldsCard, #reportCard, #previewCard) { grid-column: 1; }
  body[data-screen="review"] #previewCard { grid-row: auto; position: static; max-height: none; }
  .paper-scroll { padding: 8px; }
  .paper { min-width: 0; padding: 14px 12px 20px; font-size: 12.5px; }
  .pair { margin-right: 10px; }
  .prompt { font-size: 25px; }
}
@media (max-width: 560px) {
  .top { padding: 8px 12px; }
  .demo-tag { font-size: 11.5px; }
  .brand p { display: none; }
  .steps li { font-size: 14px; }
  body[data-screen="start"] .stage { padding: 22px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .stage.rec .mic { animation: none; box-shadow: 0 0 0 8px rgba(164, 22, 26, .3); }
}

/* ---------- print and Save as PDF: the draft only, on A4 ---------- */
@page {
  size: A4; margin: 14mm 14mm 18mm;
  @bottom-center { content: "Draft. Not registered. Page " counter(page) " of " counter(pages); font: 9pt "Times New Roman", serif; }
}
@media print {
  body { background: #fff; }
  .top, #talk, #fieldsCard, #reportCard, .toolbar { display: none !important; }
  body[data-screen] .desk { display: block; max-width: none; padding: 0; }
  body[data-screen] #previewCard { display: block; position: static; max-height: none; border: 0; }
  .paper-scroll { overflow: visible; padding: 0; background: #fff; }
  .paper { min-width: 0; max-width: none; padding: 0; font-size: 11.5pt; background: none; }
  /* a fixed box repeats on every printed page */
  .watermark {
    display: block; position: fixed; top: 34%; left: 0; right: 0; text-align: center; transform: rotate(-30deg);
    font: 700 60pt/1.15 Arial, sans-serif; text-transform: uppercase; color: rgba(164, 22, 26, .13); pointer-events: none;
  }
  .sheet thead { display: table-header-group; }
  .sheet .item { break-inside: avoid; }
  .sheet .item.long { break-inside: auto; }
  .sheet .annex { break-before: page; }
  .grid, .said, .signs { break-inside: avoid; }
}
