/* =========================================================
   SOP Operator Viewer — remastered design system
   Calm, tablet-first, one obvious action per screen.
   ========================================================= */

:root {
  /* Surfaces */
  --bg: #f2f3f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-tint: rgba(255, 255, 255, 0.78);
  --border: rgba(50, 55, 70, 0.12);
  --border-strong: rgba(50, 55, 70, 0.22);

  /* Text */
  --text: #171a21;
  --text-2: #3a3f4b;
  --muted: #878d9b;
  --muted-2: #aab0bc;

  /* System colors */
  --primary: #0a6cff;
  --primary-dark: #0353cc;
  --primary-tint: rgba(10, 108, 255, 0.10);
  --success: #2fb344;
  --success-deep: #1e7e34;
  --success-tint: rgba(47, 179, 68, 0.13);
  --warn: #f59300;
  --warn-tint: rgba(245, 147, 0, 0.13);
  --danger: #e5372b;
  --danger-tint: rgba(229, 55, 43, 0.10);
  --info-tint: rgba(10, 108, 255, 0.09);

  /* Radius */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 999px;

  /* Shadows — soft, layered, never heavy */
  --shadow-1: 0 1px 2px rgba(20, 24, 33, 0.04);
  --shadow-2: 0 4px 16px rgba(20, 24, 33, 0.06);
  --shadow-lift: 0 12px 32px rgba(20, 24, 33, 0.12);

  /* Motion */
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --t-fast: 140ms;
  --t-med: 240ms;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
               "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: 1rem; }
::selection { background: var(--primary-tint); }
/* Kill the double-tap zoom delay on tablets — taps must feel instant. */
button, label, a { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* =========================================================
   TOPBAR
   ========================================================= */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface-tint);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--border);
}
.topbar-inner {
  max-width: 960px; margin: 0 auto;
  padding: 12px 20px;
  display: flex; align-items: center; gap: 12px;
}

.brand {
  display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1;
  text-align: left; padding: 4px 6px; border-radius: var(--r-sm);
  transition: background var(--t-fast) var(--ease);
}
.brand:hover { background: rgba(0, 0, 0, 0.03); }
/* The brand is the persistent "go up" anchor — chevron shows on every screen
   except the top-level Library. */
.brand::before {
  content: "‹";
  font-size: 1.45rem; line-height: 1; color: var(--muted);
  margin: -2px -2px 0 0; flex-shrink: 0;
  transition: color var(--t-fast) var(--ease);
}
body[data-view="library"] .brand::before { display: none; }
.brand:hover::before { color: var(--text-2); }
.brand-text { min-width: 0; }
.brand-title {
  font-weight: 600; font-size: 0.95rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -0.015em;
}
.brand-sub { font-size: 0.75rem; color: var(--muted); }

/* Mode switch (segmented control) */
.mode-switch {
  display: inline-flex;
  background: rgba(50,55,70,0.08);
  padding: 2px;
  border-radius: 9px;
  gap: 2px;
  flex-shrink: 0;
}
.mode-opt {
  padding: 6px 13px;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text-2);
  transition: all var(--t-fast) var(--ease);
  min-width: 64px;
  font-variant-numeric: tabular-nums;
}
.mode-opt:hover { color: var(--text); }
.mode-opt.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 1px rgba(0,0,0,0.04);
}
.mode-opt.active[data-mode="sme"] { color: #7c3aed; }
@media (max-width: 380px) {
  .mode-opt { padding: 5px 10px; font-size: 0.78rem; min-width: 0; }
}

/* Thin progress line at the bottom of the topbar */
.topbar-progress {
  height: 3px;
  background: rgba(50,55,70,0.08);
  position: relative;
  overflow: hidden;
}
.topbar-progress-fill {
  height: 100%; width: 0%;
  background: var(--success);
  transition: width 0.5s var(--ease);
}

/* =========================================================
   MAIN
   ========================================================= */
.main {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}
/* Leave room for the fixed bottom action bar when present. */
body.has-action-bar .main { padding-bottom: 150px; }
/* Re-triggered by navigate() only when the screen actually changes. */
.main.view-anim { animation: viewFade var(--t-med) var(--ease-out); }
@keyframes viewFade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* Direction-aware step transitions in run mode */
.anim-fwd { animation: slideFwd 220ms var(--ease-out); }
.anim-back { animation: slideBack 220ms var(--ease-out); }
@keyframes slideFwd {
  from { opacity: 0; transform: translateX(32px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideBack {
  from { opacity: 0; transform: translateX(-32px); }
  to   { opacity: 1; transform: translateX(0); }
}

.large-title {
  font-size: 2.1rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  margin: 4px 0 10px;
  line-height: 1.1;
}
.lead {
  font-size: 1rem;
  color: var(--muted);
  margin: 0 0 22px;
  max-width: 56ch;
  line-height: 1.5;
}

/* Contextual back link on leaf screens */
.back-link {
  display: inline-flex; align-items: center;
  font-size: 0.9rem; font-weight: 600;
  color: var(--primary);
  padding: 4px 8px 4px 2px; margin: -2px 0 6px -2px;
  border-radius: var(--r-sm);
  transition: background var(--t-fast) var(--ease);
}
.back-link:hover { background: var(--primary-tint); }

.screen-eyebrow {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em;
  font-weight: 700; color: var(--primary); margin-bottom: 6px;
}

/* Inline meta row (SME home) */
.inline-meta {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 0.88rem;
}
.inline-meta-item { display: inline-flex; align-items: center; gap: 6px; }
.inline-meta-sep { color: var(--muted-2); }
.inline-meta strong { color: var(--text); font-weight: 600; }

/* Hero chips (operator home) */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.chip {
  display: inline-flex; align-items: center;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: rgba(50,55,70,0.07);
  color: var(--text-2);
  font-size: 0.85rem; font-weight: 600;
  letter-spacing: -0.005em;
  font-variant-numeric: tabular-nums;
}
.chip-danger { background: var(--danger-tint); color: #b3271d; }
.chip-success { background: var(--success-tint); color: var(--success-deep); }
.chip-doc { background: var(--surface); border: 1px solid var(--border-strong); font-variant-numeric: tabular-nums; }
.chip-action { background: var(--surface); border: 1px dashed var(--border-strong); cursor: pointer; transition: all var(--t-fast) var(--ease); }
.chip-action:hover { border-color: var(--primary); color: var(--primary); }

/* Revision stamp — styled like a control number, not UI chrome, so it
   registers as a compliance fact rather than decoration. */
.rev-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border: 1.5px solid var(--text); border-radius: 6px;
  background: var(--surface); color: var(--text);
  font-size: 0.7rem; font-weight: 800;
  letter-spacing: 0.06em; text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rev-badge.lg { font-size: 0.8rem; padding: 4px 10px; }

/* Home section headers */
.home-h {
  margin: 28px 0 10px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  font-weight: 700;
}
.home-h-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.home-h-row .home-h { margin-bottom: 10px; }
.home-h-note { font-size: 0.78rem; color: var(--muted-2); font-weight: 500; }

.card-section-title {
  margin: 0 0 14px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

/* =========================================================
   PRE-START GATES (safety / equipment rows on home)
   ========================================================= */
.gate-list {
  background: var(--surface);
  border-radius: var(--r-md);
  overflow: hidden;
  border: 0.5px solid var(--border);
  box-shadow: var(--shadow-1), var(--shadow-2);
}
.gate-row {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  padding: 15px 18px;
  border-bottom: 0.5px solid var(--border);
  transition: background var(--t-fast) var(--ease);
}
.gate-row:last-child { border-bottom: none; }
.gate-row:hover { background: rgba(0,0,0,0.025); }
.gate-ico {
  width: 40px; height: 40px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
  background: var(--warn-tint); color: #b06a00;
}
.gate-row.done .gate-ico { background: var(--success-tint); color: var(--success-deep); }
.gate-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.gate-title { font-weight: 650; font-size: 1rem; letter-spacing: -0.01em; }
.gate-sub { font-size: 0.84rem; color: var(--muted); }
.gate-status { display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0; }
.gate-check {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--success); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
}
.gate-chevron { color: var(--muted-2); font-size: 1.1rem; }

/* =========================================================
   PROCEDURE TIMELINE (home — the whole job at a glance)
   ========================================================= */
.tl {
  background: var(--surface);
  border-radius: var(--r-md);
  overflow: hidden;
  border: 0.5px solid var(--border);
  box-shadow: var(--shadow-1), var(--shadow-2);
}
.tl-row {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  padding: 13px 18px;
  transition: background var(--t-fast) var(--ease);
}
.tl-row:hover { background: rgba(0,0,0,0.025); }
/* vertical connector through the nodes */
.tl-row::before {
  content: "";
  position: absolute; left: 32px; top: 0; bottom: 0;
  width: 2px; background: var(--border);
}
.tl-row:first-child::before { top: 50%; }
.tl-row:last-child::before { bottom: 50%; }
.tl-node {
  position: relative; z-index: 1;
  width: 30px; height: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.84rem;
  background: var(--surface);
  border: 2px solid var(--border-strong);
  color: var(--muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  transition: all var(--t-fast) var(--ease);
}
.tl-row.done .tl-node { background: var(--success); border-color: var(--success); color: #fff; }
.tl-row.current .tl-node {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 0 0 4px var(--primary-tint);
}
.tl-body { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tl-title { font-weight: 550; font-size: 0.96rem; letter-spacing: -0.01em; }
.tl-row.done .tl-title { color: var(--muted); }
.tl-row.current .tl-title { font-weight: 700; }
.tl-meta { display: inline-flex; align-items: center; gap: 8px; }
.tl-next {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--primary); background: var(--primary-tint);
  padding: 2px 8px; border-radius: var(--r-pill);
}
.tl-go { color: var(--muted-2); font-size: 1.1rem; flex-shrink: 0; }
.tl-locked .tl-row { opacity: 0.6; }
.tl-locked .tl-row.current { opacity: 0.6; }

/* =========================================================
   FIXED BOTTOM ACTION BAR — the one obvious next action
   ========================================================= */
.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: var(--surface-tint);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.action-bar-inner {
  max-width: 720px; margin: 0 auto;
  display: flex; gap: 10px; align-items: stretch;
}
.bar-main {
  flex: 1; min-height: 62px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 10px 20px;
  border-radius: 16px;
  color: #fff; text-align: left;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
}
.bar-main:hover:not(:disabled) { transform: translateY(-1px); }
.bar-main:active:not(:disabled) { transform: scale(0.99); }
.bar-main:disabled { opacity: 0.45; cursor: not-allowed; }
/* Gated but still tappable — the tap explains itself (shakes the gate) */
.bar-main.blocked { opacity: 0.55; box-shadow: none; }
.bar-main.blocked:hover { transform: none; }
.bar-blue {
  background: linear-gradient(135deg, #0a6cff 0%, #0353cc 100%);
  box-shadow: 0 6px 20px rgba(10, 108, 255, 0.30);
}
.bar-green {
  background: linear-gradient(135deg, #2fb344 0%, #1e7e34 100%);
  box-shadow: 0 6px 20px rgba(47, 179, 68, 0.30);
}
.bar-text { display: flex; flex-direction: column; min-width: 0; }
.bar-label {
  font-size: 0.7rem; font-weight: 650;
  text-transform: uppercase; letter-spacing: 0.07em;
  opacity: 0.88;
}
.bar-title {
  font-size: 1.1rem; font-weight: 700; letter-spacing: -0.015em;
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar-arrow { font-size: 1.35rem; opacity: 0.85; flex-shrink: 0; }
.bar-prev {
  width: 62px; min-height: 62px; flex-shrink: 0;
  border-radius: 16px;
  background: rgba(50,55,70,0.08);
  color: var(--text-2);
  font-size: 1.6rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
}
.bar-prev:hover:not(:disabled) { background: rgba(50,55,70,0.14); }
.bar-prev:disabled { opacity: 0.35; cursor: not-allowed; }
/* One-tap flag — same size as prev, always in the thumb zone */
.bar-flag {
  width: 62px; min-height: 62px; flex-shrink: 0;
  border-radius: 16px;
  background: rgba(50,55,70,0.08);
  color: var(--muted);
  font-size: 1.35rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.bar-flag:hover { background: rgba(50,55,70,0.14); color: var(--text-2); }
.bar-flag.flagged {
  background: var(--warn-tint);
  color: #b06a00;
  border-color: rgba(245,147,0,0.45);
}

/* =========================================================
   RUN MODE (step screens)
   ========================================================= */
.run-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px;
}
.run-back {
  display: flex; align-items: center; gap: 8px;
  min-width: 0; text-align: left;
  padding: 6px 10px 6px 4px; margin-left: -4px;
  border-radius: var(--r-sm);
  transition: background var(--t-fast) var(--ease);
}
.run-back:hover { background: rgba(0,0,0,0.04); }
.run-back-chev { font-size: 1.5rem; line-height: 1; color: var(--muted); }
.run-back-text { display: flex; flex-direction: column; min-width: 0; }
.run-eyebrow {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 700; color: var(--primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.run-count { font-size: 0.84rem; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.run-list-btn {
  flex-shrink: 0;
  padding: 9px 14px;
  border-radius: var(--r-pill);
  background: rgba(50,55,70,0.07);
  font-size: 0.85rem; font-weight: 600; color: var(--text-2);
  transition: background var(--t-fast) var(--ease);
}
.run-list-btn:hover { background: rgba(50,55,70,0.13); }

/* Segmented progress — one segment per step */
.seg-bar { display: flex; gap: 5px; margin-bottom: 18px; }
.seg {
  flex: 1; height: 8px; min-width: 0;
  padding: 0;
  border-radius: 999px;
  background: rgba(50,55,70,0.13);
  position: relative;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
/* enlarge the touch target without enlarging the visual */
.seg::after { content: ""; position: absolute; inset: -14px -2px; }
.seg:hover { transform: scaleY(1.4); }
.seg.done { background: var(--success); }
.seg.current { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }
.seg.current.done { background: var(--success); }

/* =========================================================
   STEP CARD — action-first
   ========================================================= */
.step-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  border: 0.5px solid var(--border);
  padding: 26px 24px 22px;
}
.step-eyebrow { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.step-count {
  font-size: 0.74rem; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}
.step-flag {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 3px 9px; border-radius: var(--r-pill);
}
.step-flag.crit { color: var(--danger); background: var(--danger-tint); }
.step-flag.done { color: var(--success-deep); background: var(--success-tint); }

/* HERO — biggest, darkest element on the screen */
.step-instruction {
  font-size: clamp(1.5rem, 5vw, 1.8rem);
  font-weight: 650; line-height: 1.28; letter-spacing: -0.022em;
  color: var(--text); margin: 0;
}
/* Individually confirmable sub-actions — record-bearing, all required */
.sub-list { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.sub-row {
  display: flex; gap: 13px; align-items: flex-start;
  width: 100%; text-align: left;
  padding: 13px 14px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface-2);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.sub-row:hover:not(:disabled) { border-color: var(--border-strong); }
.sub-row.checked { background: var(--success-tint); border-color: rgba(47,179,68,0.35); }
.sub-row:disabled { cursor: default; }
.sub-box {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: var(--surface); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
  transition: all var(--t-fast) var(--ease);
}
.sub-row.checked .sub-box { background: var(--success); border-color: var(--success); animation: checkPop 300ms var(--ease-out); }
.sub-text { font-size: 1.05rem; font-weight: 600; line-height: 1.4; letter-spacing: -0.01em; }
.sub-row.checked .sub-text { color: var(--success-deep); }
.sub-row.sub-attn { animation: gateShake 420ms var(--ease); }

/* photo — only rendered when the step actually has one */
.step-media { margin: 20px 0 0; }
.step-media-img {
  width: 100%; display: block; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface-2);
  aspect-ratio: 16 / 10; object-fit: cover;
}
.step-media-cap { font-size: 0.8rem; color: var(--muted); margin-top: 8px; }

/* non-blocking cautions — a single quiet amber note */
.step-caution {
  display: flex; gap: 11px; align-items: flex-start;
  margin-top: 20px; padding: 13px 15px;
  background: var(--warn-tint); border-radius: var(--r-md);
  font-size: 0.95rem; line-height: 1.45; color: #8a5200;
}
.step-caution-ico { color: var(--warn); font-weight: 700; flex-shrink: 0; }
.step-caution-body ul { margin: 0; padding-left: 18px; }
.step-caution-body li + li { margin-top: 4px; }

.step-record {
  margin-top: 16px; font-size: 0.9rem; color: var(--text-2);
  padding: 11px 14px; background: var(--surface-2);
  border-radius: var(--r-md); border: 0.5px solid var(--border);
}

/* critical gate — warning + confirm merged into one block */
.step-gate {
  display: flex; align-items: flex-start; gap: 13px;
  margin-top: 22px; padding: 16px;
  background: var(--danger-tint); border: 1px solid rgba(229,55,43,0.30);
  border-radius: var(--r-md); cursor: pointer; user-select: none;
  transition: background var(--t-fast) var(--ease);
}
.step-gate:hover { background: rgba(229,55,43,0.13); }
.step-gate input {
  width: 26px; height: 26px; margin: 1px 0 0;
  accent-color: var(--danger); flex-shrink: 0; cursor: pointer;
}
.step-gate-text { font-size: 0.96rem; line-height: 1.4; color: var(--text); }
.step-gate-text b { color: var(--danger); font-weight: 700; }
/* Tapping a blocked Mark-done shakes the gate to show what's missing */
.step-gate.gate-attn { animation: gateShake 420ms var(--ease); }
@keyframes gateShake {
  15%, 45%, 75% { transform: translateX(-6px); }
  30%, 60%, 90% { transform: translateX(6px); }
  100% { transform: translateX(0); }
}

/* quiet secondary actions — note · help · undo */
.step-quiet { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.step-quiet-btn {
  font-size: 0.86rem; font-weight: 550; color: var(--muted); padding: 8px 10px;
  border-radius: var(--r-sm);
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.step-quiet-btn:hover { color: var(--text-2); background: rgba(0,0,0,0.03); }
.step-quiet-btn.flag-quiet { color: #b06a00; font-weight: 600; }
.step-quiet-sep { color: var(--muted-2); }
.step-note-wrap { margin-top: 12px; }
.step-note-area {
  width: 100%; min-height: 72px; padding: 12px 14px;
  border-radius: var(--r-md); border: 0.5px solid var(--border);
  background: var(--surface-2); resize: vertical;
  font-size: 0.95rem; line-height: 1.5; color: var(--text);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.step-note-area::placeholder { color: var(--muted-2); }
.step-note-area:focus {
  outline: none; border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 4px var(--primary-tint);
}

/* =========================================================
   STEP SHEET (bottom sheet — all steps)
   ========================================================= */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,18,25,0.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: backdropIn var(--t-med) var(--ease-out);
}
.sheet {
  width: min(720px, 100%);
  max-height: 72vh;
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-lift);
  display: flex; flex-direction: column;
  animation: sheetIn 280ms var(--ease-out);
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes sheetIn {
  from { transform: translateY(40px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 0.5px solid var(--border);
}
.sheet-title { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.015em; }
.sheet-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(50,55,70,0.08); color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  transition: background var(--t-fast) var(--ease);
}
.sheet-close:hover { background: rgba(50,55,70,0.15); }
.sheet-body {
  overflow-y: auto;
  border: none; border-radius: 0; box-shadow: none;
}

/* =========================================================
   SAFETY BRIEFING
   ========================================================= */
.warn-list { display: flex; flex-direction: column; gap: 10px; }
.warn-card {
  display: flex; gap: 15px; align-items: flex-start;
  background: var(--surface);
  border: 0.5px solid rgba(245,147,0,0.35);
  border-left: 4px solid var(--warn);
  border-radius: var(--r-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-1);
}
.warn-num {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: var(--warn-tint); color: #b06a00;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 750; font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.warn-body { min-width: 0; }
.warn-text { font-size: 1.05rem; font-weight: 550; line-height: 1.45; letter-spacing: -0.01em; }

.undo-link {
  margin-top: 12px;
  font-size: 0.86rem; font-weight: 600; color: var(--muted);
  padding: 6px 8px; margin-left: -8px;
  border-radius: var(--r-sm);
  transition: color var(--t-fast) var(--ease);
}
.undo-link:hover { color: var(--danger); }

.action-card { padding: 18px 20px; }
.ack-state { display: flex; align-items: center; gap: 14px; padding: 4px 0; }
.ack-state-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.2rem;
  flex-shrink: 0;
}
.ack-state-title { font-weight: 650; letter-spacing: -0.01em; }
.ack-state-sub { font-size: 0.85rem; color: var(--muted); margin-top: 1px; }

/* =========================================================
   EQUIPMENT
   ========================================================= */
.stat-card { padding: 18px 22px; }
.stat-card-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.stat-card-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--muted);
}
.stat-card-value {
  font-size: 1.3rem;
  font-weight: 750;
  letter-spacing: -0.022em;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.stat-card-success { background: linear-gradient(180deg, var(--success-tint), var(--surface) 70%); }
.stat-card-success .stat-card-value { color: var(--success-deep); }

.list-card { padding: 18px 18px; }
.check-list { display: flex; flex-direction: column; }
.check-row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 13px 6px;
  border-top: 0.5px solid var(--border);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.check-row:first-child { border-top: none; }
.check-row:hover { background: rgba(0,0,0,0.025); border-radius: 8px; }
.check-row.checked .check-title { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(50,55,70,0.4); }
.check-box {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-weight: 700; font-size: 0.9rem;
  color: #fff;
  background: var(--surface);
  transition: all var(--t-fast) var(--ease);
}
.check-box.checked {
  background: var(--success);
  border-color: var(--success);
  animation: checkPop 300ms var(--ease-out);
}
.check-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.check-title { font-weight: 600; font-size: 0.98rem; letter-spacing: -0.01em; }
.check-detail { font-size: 0.85rem; color: var(--text-2); }
.check-source { font-size: 0.74rem; color: var(--muted); font-family: ui-monospace, "SF Mono", Menlo, monospace; margin-top: 2px; }

@keyframes checkPop {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* =========================================================
   LIBRARY (entry screen)
   ========================================================= */
.library-list { background: transparent; border: none; box-shadow: none; display: flex; flex-direction: column; gap: 12px; }
.library-tile {
  background: var(--surface);
  border-radius: var(--r-md);
  border: 0.5px solid var(--border);
  box-shadow: var(--shadow-1), var(--shadow-2);
  padding: 18px 20px;
  align-items: stretch;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.library-tile:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-2), 0 10px 28px rgba(0,0,0,0.07);
}
.library-tile:active { transform: translateY(0); }
.library-tile-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.library-tile .title { font-size: 1.08rem; }
.library-meta { display: flex; flex-wrap: wrap; gap: 4px 6px; font-size: 0.82rem; color: var(--muted); }
.library-meta strong { color: var(--text); font-weight: 600; }
.library-dot { color: var(--muted-2); }
.library-desc {
  font-size: 0.9rem;
  color: var(--text-2);
  margin-top: 4px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.library-progress { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.library-progress-bar {
  flex: 1; max-width: 220px;
  height: 4px; background: rgba(50,55,70,0.12); border-radius: 999px; overflow: hidden;
}
.library-progress-fill { height: 100%; background: var(--success); transition: width 0.5s var(--ease); }
.library-progress-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* Empty state */
.empty-card { text-align: center; padding: 40px 24px; }
.empty-icon { font-size: 2.6rem; opacity: 0.5; margin-bottom: 8px; }
.empty-title { margin: 0 0 6px; font-size: 1.1rem; font-weight: 700; letter-spacing: -0.015em; }
.empty-text { margin: 0; font-size: 0.9rem; color: var(--muted); }
.empty-text code {
  background: var(--surface-2);
  padding: 1px 6px; border-radius: 5px;
  font-size: 0.85rem;
}

/* =========================================================
   SME MODE
   ========================================================= */
.continue-cta {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: linear-gradient(135deg, #0a6cff 0%, #0353cc 100%);
  color: #fff; padding: 18px 22px;
  border-radius: var(--r-md);
  width: 100%; text-align: left;
  margin-bottom: 18px;
  box-shadow: 0 6px 20px rgba(10, 108, 255, 0.28);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.continue-cta:hover { transform: translateY(-1px); }
.continue-cta:active { transform: translateY(0) scale(0.99); }
.continue-cta.sme-cta {
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.28);
}
.continue-cta .cta-label {
  font-size: 0.72rem;
  opacity: 0.88;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.continue-cta .cta-title { font-size: 1.12rem; font-weight: 700; margin-top: 3px; letter-spacing: -0.015em; }
.continue-cta .cta-arrow { font-size: 1.4rem; opacity: 0.85; }

.dc-block { margin-top: 14px; }
.dc-block:first-child { margin-top: 4px; }
.dc-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

body[data-mode="sme"] .large-title::after {
  content: " · SME view";
  font-size: 0.85rem;
  color: #7c3aed;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

/* =========================================================
   PDF VIEWER
   ========================================================= */
.pdf-card { padding: 0; overflow: hidden; }
.pdf-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 0.5px solid var(--border);
  background: var(--surface-2);
}
.pdf-toolbar-meta { min-width: 0; }
.pdf-toolbar-title {
  font-size: 0.98rem; font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pdf-toolbar-sub {
  font-size: 0.78rem; color: var(--muted);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  margin-top: 1px;
}
.pdf-toolbar-actions { display: flex; gap: 8px; flex-shrink: 0; }
.pdf-action { padding: 9px 14px; min-height: 38px; font-size: 0.85rem; text-decoration: none; }
.pdf-frame-wrap {
  position: relative;
  background: #525659;
  height: calc(100vh - 280px);
  min-height: 480px;
}
.pdf-frame { width: 100%; height: 100%; border: none; display: block; }
@media (max-width: 600px) {
  .pdf-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .pdf-toolbar-actions { justify-content: stretch; }
  .pdf-action { flex: 1; justify-content: center; }
  .pdf-frame-wrap { height: calc(100vh - 320px); min-height: 420px; }
}

.source-line {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

/* =========================================================
   CARDS
   ========================================================= */
.card {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 22px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-1), var(--shadow-2);
  border: 0.5px solid var(--border);
}
.card h2 { margin: 0 0 4px; font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; }
.card h3 { margin: 0 0 8px; font-size: 1.05rem; font-weight: 600; letter-spacing: -0.015em; }
.card .meta { color: var(--muted); font-size: 0.9rem; }
.plain-list { margin: 0; padding-left: 20px; }
.plain-list li + li { margin-top: 6px; }

/* Key-value grid */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  margin-top: 18px;
  background: var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.kv { background: var(--surface-2); padding: 12px 14px; }
.kv-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.06em;
  font-weight: 600;
}
.kv-value {
  font-weight: 600;
  font-size: 0.98rem;
  margin-top: 3px;
  word-break: break-word;
  letter-spacing: -0.01em;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.5;
}
.badge-success { background: var(--success-tint); color: var(--success-deep); }
.badge-warn    { background: var(--warn-tint);    color: #b45309; }
.badge-danger  { background: var(--danger-tint);  color: #b91c1c; }
.badge-info    { background: var(--info-tint);    color: var(--primary-dark); }
.badge-muted   { background: rgba(50,55,70,0.1);  color: var(--text-2); }

/* =========================================================
   SECTION TILES (grouped list)
   ========================================================= */
.section-list {
  background: var(--surface);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-top: 8px;
  box-shadow: var(--shadow-1), var(--shadow-2);
  border: 0.5px solid var(--border);
}
.section-tile {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  text-align: left; width: 100%;
  border-bottom: 0.5px solid var(--border);
  transition: background var(--t-fast) var(--ease);
}
.section-tile:last-child { border-bottom: none; }
.section-tile:hover { background: rgba(0,0,0,0.025); }
.section-tile:active { background: rgba(0,0,0,0.05); }
.section-tile .tile-left { display: flex; gap: 14px; align-items: center; min-width: 0; }
.section-tile .tile-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  background: var(--primary-tint);
  color: var(--primary);
}
.section-tile .tile-icon.warn { background: var(--warn-tint); color: var(--warn); }
.section-tile .tile-icon.success { background: var(--success-tint); color: var(--success-deep); }
.section-tile .tile-icon.muted { background: rgba(50,55,70,0.08); color: var(--text-2); }
.section-tile .title { font-weight: 600; font-size: 1rem; letter-spacing: -0.01em; }
.section-tile .sub { color: var(--muted); font-size: 0.85rem; margin-top: 1px; }
.section-tile .tile-right { display: flex; align-items: center; gap: 10px; color: var(--muted-2); font-size: 1.1rem; }

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px;
  border-radius: var(--r-pill);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.005em;
  transition: transform var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease),
              opacity var(--t-fast) var(--ease);
  min-height: 44px;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { filter: brightness(1.04); }
.btn-outline { background: rgba(10,108,255,0.08); color: var(--primary); }
.btn-outline:hover:not(:disabled) { background: rgba(10,108,255,0.14); }
.btn-neutral { background: rgba(50,55,70,0.08); color: var(--text); }
.btn-neutral:hover:not(:disabled) { background: rgba(50,55,70,0.14); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); }

.btn-block { display: flex; width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* =========================================================
   MAINTENANCE CARD (home — separate track)
   ========================================================= */
.maint-card {
  display: block; width: 100%; text-align: left;
  margin-top: 16px; padding: 16px 18px;
  background: var(--surface); border-radius: var(--r-md);
  border: 0.5px solid var(--border); box-shadow: var(--shadow-1);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.maint-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); }
.maint-card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.maint-card-title { font-size: 1rem; font-weight: 650; letter-spacing: -0.01em; }
.maint-card-sub { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }
.maint-card-cta { font-size: 0.9rem; font-weight: 600; color: var(--primary); white-space: nowrap; }
.maint-progress { height: 5px; border-radius: 999px; background: rgba(50,55,70,0.12); overflow: hidden; margin-top: 12px; }
.maint-progress-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width 0.4s var(--ease); }
.maint-progress-fill.done { background: var(--success); }

/* =========================================================
   ALERTS
   ========================================================= */
.alert {
  padding: 13px 15px;
  border-radius: var(--r-md);
  margin: 12px 0;
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.alert-warn    { background: var(--warn-tint);    color: #8a5200; }
.alert-danger  { background: var(--danger-tint);  color: #8b1a14; font-weight: 500; }
.alert-info    { background: var(--info-tint);    color: var(--primary-dark); }
.alert-success { background: var(--success-tint); color: #14532d; }
.alert ul { margin: 4px 0 0; padding-left: 20px; }
.alert-title {
  font-weight: 700;
  display: flex; align-items: center; gap: 6px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.warn-list .alert { margin: 0; }

/* =========================================================
   NOTES / TEXTAREA
   ========================================================= */
.notes-area {
  width: 100%; min-height: 76px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 0.5px solid var(--border);
  background: var(--surface-2);
  resize: vertical;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.notes-area::placeholder { color: var(--muted-2); }
.notes-area:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--primary-tint);
}

/* =========================================================
   STEP LIST (sheet + summary)
   ========================================================= */
.steplist {
  background: var(--surface);
  border-radius: var(--r-md);
  overflow: hidden;
  border: 0.5px solid var(--border);
  box-shadow: var(--shadow-1);
}
.steplist-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  text-align: left; width: 100%;
  border-bottom: 0.5px solid var(--border);
  transition: background var(--t-fast) var(--ease);
}
.steplist-item:last-child { border-bottom: none; }
.steplist-item:hover { background: rgba(0,0,0,0.025); }
.steplist-item.completed { background: rgba(47, 179, 68, 0.06); }
.steplist-item.completed:hover { background: rgba(47, 179, 68, 0.1); }
.steplist-item.active { background: var(--primary-tint); }
.steplist-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(50,55,70,0.1); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.85rem; flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.steplist-item.completed .steplist-num { background: var(--success); color: #fff; }
.steplist-item.active .steplist-num { background: var(--primary); color: #fff; }
.steplist-title { flex: 1; font-size: 0.95rem; min-width: 0; font-weight: 500; letter-spacing: -0.01em; }
.steplist-title .sub { font-size: 0.78rem; color: var(--muted); margin-top: 2px; font-weight: 400; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.steplist-check { color: var(--success); font-weight: 700; font-size: 1.1rem; }

/* =========================================================
   LIST ROWS
   ========================================================= */
.list-rows {
  background: var(--surface);
  border-radius: var(--r-md);
  overflow: hidden;
  border: 0.5px solid var(--border);
  box-shadow: var(--shadow-1);
}
.list-row { padding: 14px 18px; border-bottom: 0.5px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.list-row .row-title { font-weight: 600; margin-bottom: 4px; letter-spacing: -0.01em; }
.list-row .row-meta { font-size: 0.78rem; color: var(--muted); font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* =========================================================
   SOURCE COVERAGE TABLE (SME)
   ========================================================= */
.coverage-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--r-md);
  overflow: hidden;
  border: 0.5px solid var(--border);
}
.coverage-table th, .coverage-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 0.5px solid var(--border);
  font-size: 0.88rem;
  vertical-align: top;
}
.coverage-table th {
  background: var(--surface-2);
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.06em;
  font-weight: 600;
}
.coverage-table tr:last-child td { border-bottom: none; }
.coverage-table code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.82rem;
  background: rgba(50,55,70,0.06);
  padding: 1px 6px;
  border-radius: 5px;
}

/* =========================================================
   MODAL
   ========================================================= */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,18,25,0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
  animation: backdropIn var(--t-med) var(--ease-out);
}
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 24px;
  width: 100%; max-width: 460px;
  box-shadow: var(--shadow-lift);
  animation: modalIn var(--t-med) var(--ease-out);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal h3 { margin: 0 0 8px; font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; }

/* Issue reason chips — one tap beats typing on a shop floor */
.issue-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.issue-chip-btn {
  padding: 9px 15px;
  border-radius: var(--r-pill);
  background: rgba(50,55,70,0.07);
  font-size: 0.88rem; font-weight: 600; color: var(--text-2);
  border: 1px solid transparent;
  transition: all var(--t-fast) var(--ease);
}
.issue-chip-btn:hover { background: rgba(50,55,70,0.12); }
.issue-chip-btn.selected {
  background: var(--primary-tint);
  color: var(--primary);
  border-color: rgba(10,108,255,0.4);
}
.remove-flag { color: var(--danger); }
.remove-flag:hover { background: var(--danger-tint); }
.modal-input {
  width: 100%;
  padding: 12px 14px; margin-top: 14px;
  border-radius: var(--r-md);
  border: 0.5px solid var(--border);
  background: var(--surface-2);
  font-size: 1rem; color: var(--text);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.modal-input:focus {
  outline: none; border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 4px var(--primary-tint);
}

/* =========================================================
   COMPLETION RECORDS (SME)
   ========================================================= */
.rec-card { padding: 18px 20px; }
.rec-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.rec-head-main { min-width: 0; }
.rec-title { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.015em; }
.rec-sub {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 0.84rem; color: var(--muted); margin-top: 4px;
}
.rec-sub strong { color: var(--text); font-weight: 600; }
.rec-badges { flex-shrink: 0; }
.rec-flags { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.rec-flag-row {
  font-size: 0.9rem; line-height: 1.45;
  background: var(--warn-tint); color: #8a5200;
  padding: 9px 12px; border-radius: var(--r-sm);
}
.rec-flag-row span { font-weight: 600; }
.rec-details { margin-top: 14px; }
.rec-details summary {
  cursor: pointer; user-select: none; list-style: none;
  font-size: 0.86rem; font-weight: 650; color: var(--primary);
  padding: 4px 0;
}
.rec-details summary::-webkit-details-marker { display: none; }
.rec-details summary::before { content: "▸ "; }
.rec-details[open] summary::before { content: "▾ "; }
.rec-details .list-rows { margin-top: 10px; }
.rec-step-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 14px; }
.rec-step-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.92rem; font-weight: 550; min-width: 0; }
.rec-step-n {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(50,55,70,0.08);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.74rem; font-weight: 700; flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.rec-step-flag { color: #b06a00; font-weight: 700; }
.rec-step-time { font-size: 0.8rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* =========================================================
   TOAST
   ========================================================= */
.toast-stack {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 90;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
  width: min(420px, calc(100% - 32px));
}
body.has-action-bar .toast-stack { bottom: 110px; }
.toast {
  background: rgba(25,28,35,0.95);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 0.92rem;
  font-weight: 500;
  box-shadow: var(--shadow-lift);
  backdrop-filter: blur(20px);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  pointer-events: auto;
  animation: toastIn 280ms var(--ease-out);
}
.toast.leaving { animation: toastOut 200ms var(--ease) forwards; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px); }
}
.toast-action {
  color: #5ba3ff;
  font-weight: 700;
  background: transparent;
  padding: 0;
  font-size: 0.92rem;
}
.toast-action:hover { color: #8ec0ff; }

/* =========================================================
   COMPLETION HERO (summary)
   ========================================================= */
.complete-hero {
  text-align: center;
  background: linear-gradient(180deg, var(--success-tint), var(--surface) 72%);
  border-color: rgba(47,179,68,0.3);
}
.complete-hero-icon {
  width: 58px; height: 58px; margin: 6px auto 12px;
  border-radius: 50%;
  background: var(--success); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; font-weight: 700;
  box-shadow: 0 6px 18px rgba(47,179,68,0.35);
  animation: checkPop 420ms var(--ease-out);
}
.complete-hero-title { font-size: 1.35rem; font-weight: 750; letter-spacing: -0.02em; }
.complete-hero-sub { font-size: 0.92rem; color: var(--text-2); margin-top: 6px; max-width: 46ch; margin-left: auto; margin-right: auto; }

/* =========================================================
   ERROR SCREEN
   ========================================================= */
.error-screen {
  max-width: 560px; margin: 60px auto;
  padding: 28px; background: var(--surface);
  border-radius: var(--r-lg);
  border: 0.5px solid var(--border);
  box-shadow: var(--shadow-2);
}
.error-screen h2 { color: var(--danger); margin: 0 0 12px; font-size: 1.4rem; letter-spacing: -0.02em; }
.error-screen pre {
  background: var(--surface-2); padding: 14px; border-radius: var(--r-md);
  font-size: 0.85rem; overflow: auto; white-space: pre-wrap;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

/* =========================================================
   RESPONSIVE — phone tightening, tablet scale-up
   ========================================================= */
@media (max-width: 719px) {
  .main { padding: 18px 16px 32px; }
  body.has-action-bar .main { padding-bottom: 140px; }
  .large-title { font-size: 1.8rem; }
}
/* Phone held in one hand (≈375px): instruction stays readable at arm's
   length, all three bar controls stay ≥54px in the thumb zone, decoration
   yields to tap area. */
@media (max-width: 480px) {
  .action-bar { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .action-bar-inner { gap: 8px; }
  .bar-arrow { display: none; }
  .bar-prev, .bar-flag { width: 54px; min-height: 58px; border-radius: 14px; }
  .bar-main { min-height: 58px; padding: 8px 14px; border-radius: 14px; }
  .bar-title { font-size: 1rem; }
  .bar-label { font-size: 0.64rem; }
  .step-card { padding: 22px 18px; }
  /* Never shrink the instruction below arm's-length readability */
  .step-instruction { font-size: 1.5rem; }
  .sub-text { font-size: 0.98rem; }
  .seg-bar { gap: 4px; }
  .run-list-btn { padding: 8px 12px; font-size: 0.82rem; }
  .kv-grid { grid-template-columns: repeat(2, 1fr); }
  .chip { font-size: 0.8rem; }
}
@media (max-width: 380px) {
  .topbar-inner { padding: 10px 14px; gap: 8px; }
  .card { padding: 18px 18px; }
}
/* Tablet and up: everything breathes a little more */
@media (min-width: 720px) {
  .large-title { font-size: 2.5rem; }
  .step-instruction { font-size: 2rem; }
  .step-card { padding: 34px 32px 26px; }
  .seg-bar { gap: 6px; }
  .seg { height: 9px; }
  .warn-text { font-size: 1.12rem; }
  .bar-main { min-height: 66px; }
  .bar-prev { width: 66px; min-height: 66px; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
