/* =========================================================================
   Guide Capture — screen styles.
   Mobile-first. Built for one-handed use, gloves, and bad light:
   large targets (56px min), high contrast, no thin greys on white.
   Print styles live in css/print.css.
   ========================================================================= */

:root {
  --ink:        #0f1719;
  --ink-2:      #3d4c50;
  --ink-3:      #63757a;
  --line:       #d4dcde;
  --line-2:     #e8edee;
  --paper:      #ffffff;
  --surface:    #f2f5f6;
  --brand:      #12343f;
  --brand-ink:  #ffffff;
  --brand-soft: #e4edef;
  --danger:     #a5251c;
  --danger-soft:#fbe9e7;
  --warn:       #8a5000;
  --warn-soft:  #fdf0dc;
  --ok:         #1c6b4a;
  --ok-soft:    #e3f1eb;
  --focus:      #1668b8;

  --radius:     12px;
  --tap:        56px;
  --pad:        16px;
  --shadow:     0 1px 2px rgba(15,23,25,.08), 0 4px 16px rgba(15,23,25,.06);
  --shadow-up:  0 -2px 12px rgba(15,23,25,.10);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Class-level `display` beats the UA [hidden] rule; make hidden mean hidden. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body { padding-bottom: env(safe-area-inset-bottom); }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0 0 .6em; }
a { color: var(--focus); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ------------------------------------------------------------- app bar -- */

.appbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) var(--pad) 10px;
  background: var(--brand); color: var(--brand-ink);
  min-height: 56px;
}
.appbar h1 { font-size: 19px; line-height: 1.2; }
.appbar-sub { margin: 1px 0 0; font-size: 12.5px; opacity: .78; line-height: 1.25; }
.appbar-title { flex: 1; min-width: 0; }
.appbar-title h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar-actions { display: flex; gap: 6px; flex-shrink: 0; }
.appbar-back, .appbar-btn {
  appearance: none; border: 0; background: rgba(255,255,255,.12);
  color: inherit; width: 44px; height: 44px; border-radius: 10px;
  display: grid; place-items: center; cursor: pointer; flex-shrink: 0;
}
.appbar-btn { width: auto; padding: 0 14px; font: inherit; font-size: 15px; font-weight: 600; }
.appbar-back:active, .appbar-btn:active { background: rgba(255,255,255,.24); }
.appbar-back svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* --------------------------------------------------------------- netbar -- */

.netbar {
  position: sticky; top: 0; z-index: 45;
  padding: 7px var(--pad); font-size: 13.5px; font-weight: 600;
  background: var(--ink); color: #fff; text-align: center;
}
.netbar.offline { background: #3b2f00; color: #ffe9a8; }

/* ----------------------------------------------------------------- view -- */

.view { padding: var(--pad); max-width: 720px; margin: 0 auto; outline: none; }
.view.no-pad { padding: 0; }
@media (min-width: 760px) { .view { padding: 24px; } }

.stack > * + * { margin-top: 12px; }
.muted { color: var(--ink-3); }
.small { font-size: 14px; }
.tiny  { font-size: 12.5px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- cards -- */

.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--pad);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
.card-tight { padding: 12px; }

.section-title {
  font-size: 12.5px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-3);
  margin: 22px 0 10px;
}

/* -------------------------------------------------------------- buttons -- */

.btn {
  appearance: none; font: inherit; font-weight: 650;
  min-height: var(--tap); padding: 0 20px;
  border-radius: var(--radius); border: 1.5px solid transparent;
  background: var(--paper); color: var(--ink); border-color: var(--line);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  gap: 10px; text-decoration: none; text-align: center;
  -webkit-tap-highlight-color: transparent;
  transition: transform .06s ease;
}
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-block { display: flex; width: 100%; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-danger  { background: var(--paper); color: var(--danger); border-color: #e6c3bf; }
.btn-ghost   { background: transparent; border-color: transparent; color: var(--brand); }
.btn-sm { min-height: 42px; padding: 0 14px; font-size: 15px; border-radius: 10px; }
.btn-xl { min-height: 68px; font-size: 19px; }
.btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }

/* --------------------------------------------------------------- fields -- */

.field { display: block; margin-bottom: 14px; }
.field > .label {
  display: block; font-size: 14px; font-weight: 650; margin-bottom: 6px; color: var(--ink-2);
}
.field .hint { font-size: 13px; color: var(--ink-3); margin-top: 5px; }
input[type=text], input[type=date], input[type=url], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 14px; min-height: var(--tap);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px rgba(22,104,184,.18); }

/* Choice tiles (capture type, status) */
.choices { display: grid; gap: 10px; }
.choice {
  display: flex; align-items: flex-start; gap: 12px; text-align: left;
  padding: 14px; border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--paper); cursor: pointer; min-height: var(--tap); width: 100%;
  font: inherit;
}
.choice[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.choice .ttl { font-weight: 650; display: block; }
.choice .sub { font-size: 13.5px; color: var(--ink-3); }

/* --------------------------------------------------------------- badges -- */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .02em;
  padding: 4px 9px; border-radius: 999px; border: 1px solid;
  white-space: nowrap;
}
.st-draft     { background: var(--surface);   color: var(--ink-2); border-color: var(--line); }
.st-review    { background: var(--warn-soft); color: var(--warn);  border-color: #ecd3a6; }
.st-published { background: var(--ok-soft);   color: var(--ok);    border-color: #b6d9c8; }
.st-archived  { background: #eceff0;          color: var(--ink-3); border-color: var(--line); }
.badge-stale  { background: var(--danger-soft); color: var(--danger); border-color: #e6c3bf; }
.badge-machine{ background: var(--brand-soft); color: var(--brand); border-color: #c2d4d8; }

/* The classification marker. Must never be subtle. */
.classification {
  display: flex; gap: 10px; align-items: flex-start;
  background: #fff8e6; border: 1.5px solid #e3c98c; border-left-width: 5px;
  border-radius: 10px; padding: 12px 14px;
}
.classification strong { display: block; font-size: 14.5px; }
.classification p { margin: 3px 0 0; font-size: 13px; color: #5d4a1e; line-height: 1.4; }

/* -------------------------------------------------------------- library -- */

.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  font: inherit; font-size: 14.5px; font-weight: 600; white-space: nowrap;
  padding: 9px 14px; min-height: 42px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--paper); color: var(--ink-2); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }

.guide-row {
  display: flex; gap: 12px; align-items: stretch; width: 100%; text-align: left;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 10px; cursor: pointer; font: inherit; color: inherit;
  box-shadow: var(--shadow);
}
.guide-row:active { background: var(--surface); }
.guide-thumb {
  width: 76px; height: 76px; flex-shrink: 0; border-radius: 9px; object-fit: cover;
  background: var(--surface); border: 1px solid var(--line-2);
}
.guide-thumb.empty { display: grid; place-items: center; color: var(--ink-3); font-size: 11px; text-align: center; }
.guide-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.guide-title { font-weight: 650; line-height: 1.3; }
.guide-meta { font-size: 13px; color: var(--ink-3); }
.guide-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty-state h2 { font-size: 19px; color: var(--ink); margin-bottom: 8px; }

/* ------------------------------------------------------------ step list -- */

.step-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow);
}
.step-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--line-2); background: var(--paper);
}
.step-num {
  width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.step-body { display: flex; gap: 12px; padding: 12px; }
.step-photo {
  width: 96px; height: 96px; border-radius: 9px; object-fit: cover; flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--line-2);
}
.step-photo.missing {
  display: grid; place-items: center; text-align: center; font-size: 12px;
  color: var(--warn); background: var(--warn-soft); border-color: #ecd3a6; padding: 6px;
}
.step-text { flex: 1; min-width: 0; font-size: 15.5px; }
.step-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 12px 12px; }
.step-actions .btn { flex: none; }
.icon-btn {
  appearance: none; border: 1.5px solid var(--line); background: var(--paper);
  width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center;
  cursor: pointer; color: var(--ink-2); flex-shrink: 0;
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn[disabled] { opacity: .3; pointer-events: none; }
.icon-btn:active { background: var(--surface); }

.flag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 650;
  padding: 3px 8px; border-radius: 6px;
}
.flag-danger { background: var(--danger-soft); color: var(--danger); }
.flag-warning { background: var(--warn-soft); color: var(--warn); }
.flag-note { background: var(--brand-soft); color: var(--brand); }
.flag-todo { background: var(--warn-soft); color: var(--warn); }

/* -------------------------------------------------------------- sticky -- */

.sticky-bar {
  position: sticky; bottom: 0; z-index: 30;
  margin: 16px calc(var(--pad) * -1) 0;
  padding: 12px var(--pad) calc(12px + env(safe-area-inset-bottom));
  background: var(--paper); border-top: 1px solid var(--line);
  box-shadow: var(--shadow-up);
}
.sticky-bar .btn-row + .small { margin-top: 8px; }

/* ------------------------------------------------------------- overlay -- */

.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: #0b1214; color: #fff;
  display: flex; flex-direction: column;
}
.overlay-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) var(--pad) 12px;
  font-weight: 650;
}
.overlay-body { flex: 1; position: relative; overflow: hidden; display: flex; flex-direction: column; }
.overlay-foot {
  padding: 12px var(--pad) calc(16px + env(safe-area-inset-bottom));
  display: flex; gap: 10px; background: #0b1214;
}
.overlay-foot .btn { flex: 1; background: #1d282b; color: #fff; border-color: #2c3a3e; }
.overlay-foot .btn-primary { background: #fff; color: #0b1214; border-color: #fff; }
.overlay .muted { color: #9fb0b4; }

/* Cropper */
.crop-stage { flex: 1; position: relative; overflow: hidden; touch-action: none; background: #000; }
.crop-img { position: absolute; user-select: none; -webkit-user-drag: none; }
.crop-shade { position: absolute; inset: 0; pointer-events: none; }
.crop-box {
  position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.55);
  touch-action: none; cursor: move;
}
.crop-box::before, .crop-box::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  border-color: rgba(255,255,255,.35); border-style: solid;
}
.crop-box::before { border-width: 0 1px; left: 33.33%; right: 33.33%; }
.crop-box::after  { border-width: 1px 0; top: 33.33%; bottom: 33.33%; }
.crop-handle {
  position: absolute; width: 44px; height: 44px; touch-action: none;
}
.crop-handle::after {
  content: ''; position: absolute; width: 22px; height: 22px; border: 3px solid #fff;
}
.crop-handle.tl { top: -22px; left: -22px; } .crop-handle.tl::after { top: 20px; left: 20px; border-width: 3px 0 0 3px; }
.crop-handle.tr { top: -22px; right: -22px; } .crop-handle.tr::after { top: 20px; right: 20px; border-width: 3px 3px 0 0; }
.crop-handle.bl { bottom: -22px; left: -22px; } .crop-handle.bl::after { bottom: 20px; left: 20px; border-width: 0 0 3px 3px; }
.crop-handle.br { bottom: -22px; right: -22px; } .crop-handle.br::after { bottom: 20px; right: 20px; border-width: 0 3px 3px 0; }

.crop-tools { display: flex; gap: 8px; padding: 10px var(--pad); overflow-x: auto; }
.crop-tools .chip { background: #1d282b; border-color: #2c3a3e; color: #dbe5e7; }

/* Recorder */
.rec-stage { flex: 1; display: flex; flex-direction: column; padding: 0 var(--pad); overflow-y: auto; }
.rec-photo { width: 100%; max-height: 30vh; object-fit: contain; border-radius: 10px; background: #000; margin-bottom: 12px; }
.rec-status { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 14.5px; }
.rec-dot { width: 13px; height: 13px; border-radius: 50%; background: #ff4d3d; flex-shrink: 0; animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.82); } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 700; }
.rec-transcript {
  flex: 1; min-height: 120px; background: #131f22; border: 1.5px solid #2c3a3e; border-radius: 10px;
  padding: 14px; font-size: 17px; line-height: 1.5; overflow-y: auto; color: #fff;
}
.rec-transcript .interim { color: #8fa3a8; }
.rec-transcript .placeholder { color: #71858a; }
.rec-note {
  background: #2a2410; border: 1px solid #4d4118; color: #f0d795;
  border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 10px;
}
.overlay textarea {
  background: #131f22; border-color: #2c3a3e; color: #fff; font-size: 17px;
}
.overlay textarea::placeholder { color: #71858a; }

/* ---------------------------------------------------------------- toast -- */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 200;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px;
  font-size: 15px; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.28);
  max-width: 90vw; text-align: center;
}

/* --------------------------------------------------------------- review -- */

.editable {
  width: 100%; font: inherit; font-size: 15.5px; line-height: 1.5;
  border: 1.5px solid transparent; border-radius: 8px; padding: 8px;
  background: var(--surface); color: var(--ink); resize: none; overflow: hidden;
}
.editable:focus { background: var(--paper); border-color: var(--focus); }

.caution-item {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px;
  border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; background: var(--paper);
}
.caution-item.sev-danger  { border-left: 5px solid var(--danger); }
.caution-item.sev-warning { border-left: 5px solid var(--warn); }
.caution-item.sev-note    { border-left: 5px solid var(--brand); }

.changes-list { margin: 8px 0 0; padding-left: 20px; font-size: 14px; color: var(--ink-2); }
.changes-list li { margin-bottom: 2px; }

.detail-photo { width: 100%; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); }

.kv { display: grid; grid-template-columns: 1fr; gap: 2px; font-size: 14.5px; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--ink-3); font-size: 13px; }

/* The on-screen app is hidden entirely when printing — see print.css */
/* --------------------------------------------------------------- glasses -- */
/* Connection chip. Colour carries state so it reads at a glance in a plant
   room, but the label always says it in words too. */
.glasses-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  min-height: 52px;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
}
.glasses-chip svg { width: 24px; height: 24px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.6; }
.glasses-chip span:nth-of-type(1) { flex: 1; }
.glasses-action { font-weight: 700; color: var(--brand); }
.glasses-chip.g-on  { border-color: var(--ok, #1c6742); color: var(--ok, #1c6742); }
.glasses-chip.g-busy { border-color: var(--warn, #855408); color: var(--warn, #855408); }
.glasses-chip.g-off { color: var(--muted); }

.print-root { display: none; }
