/* ===================== OpLog — design system ===================== */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #fbfcfe;
  --ink: #0f1722;
  --ink-2: #5a6675;
  --ink-3: #8a94a3;
  --line: #e8ebf0;
  --line-2: #f0f2f5;
  --accent: #3667f0;
  --accent-ink: #ffffff;
  --accent-soft: #eef3ff;
  --ok: #12a67c; --ok-soft: #e7f7f1;
  --warn: #c77a17; --warn-soft: #fdf3e3;
  --info: #2f6bff; --info-soft: #e9f0ff;
  --danger: #e0484d;
  --r: 18px; --r-md: 13px; --r-sm: 10px; --pill: 999px;
  --sh-sm: 0 1px 2px rgba(15,23,34,.05);
  --sh: 0 1px 2px rgba(15,23,34,.04), 0 6px 16px rgba(15,23,34,.05);
  --sh-lg: 0 10px 40px rgba(15,23,34,.16);
  --nav-h: 62px;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
}
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
b { font-weight: 650; }

/* ===================== app bar ===================== */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(244,246,249,.82); backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  padding: max(14px, env(safe-area-inset-top)) 16px 12px;
}
.appbar h1 { margin: 0; font-size: 21px; font-weight: 750; letter-spacing: -.02em; }
.appbar h1 span { color: var(--accent); }
#stats { color: var(--ink-2); font-size: 12.5px; margin-top: 3px; }
#stats b { color: var(--ink); }
.appbar { --gear-right: 12px; }
.gear { position: absolute; top: max(14px, calc(env(safe-area-inset-top) + 0px)); right: var(--gear-right);
  background: none; border: none; color: var(--ink-3); cursor: pointer; line-height: 0;
  display: inline-flex; align-items: center; justify-content: center; padding: 5px; border-radius: 10px; }
.gear svg { width: 21px; height: 21px; }
.gear:hover { color: var(--ink); background: var(--line-2); }
#helpBtn { right: calc(var(--gear-right) + 37px); }  /* tracks the gear at every breakpoint */

/* Password show/hide toggle (injected by addPasswordToggles) */
.pw-wrap { position: relative; display: block; }
.pw-wrap > input { padding-right: 46px !important; }
.pw-eye { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); line-height: 0;
  background: none; border: none; padding: 8px; border-radius: 9px; cursor: pointer; color: var(--ink-3);
  display: inline-flex; align-items: center; justify-content: center; }
.pw-eye:hover { color: var(--ink); background: var(--line-2); }
.pw-eye:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pw-eye svg { width: 19px; height: 19px; }

.searchwrap { margin-top: 12px; }
#search {
  width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); font-size: 15px; color: var(--ink);
}
#search::placeholder { color: var(--ink-3); }
#search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* filters */
.filterbar { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; align-items: center; }
.fsel { padding: 7px 8px; border: 1px solid var(--line); border-radius: var(--pill); background: var(--surface);
  font-size: 12.5px; color: var(--ink); appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: right 10px top 14px, right 6px top 14px; background-size: 4px 4px, 4px 4px; background-repeat: no-repeat; padding-right: 22px; }
.fsel:focus { outline: none; border-color: var(--accent); }
.fclear, .fexport { padding: 7px 12px; font-size: 12.5px; border-radius: var(--pill); }
.btn.fexport { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 640;
  border-radius: var(--pill); padding: 8px 16px; }
.btn.fexport:hover { background: #2a55d4; border-color: #2a55d4; }

/* ===================== nav: top tabs (desktop) + bottom bar (mobile) ===================== */
/* Segmented control — light track, white active pill (iOS-style). */
.topnav { display: none; gap: 2px; margin-top: 14px; padding: 3px;
  background: #eaedf2; border-radius: 11px; }
.ttab { flex: 1; padding: 8px 12px; border: none; background: transparent;
  border-radius: 8px; font-size: 13.5px; font-weight: 640; color: var(--ink-2); cursor: pointer;
  transition: background .14s, color .14s, box-shadow .14s; }
.ttab:hover { color: var(--ink); }
.ttab.active { background: var(--surface); color: var(--ink); box-shadow: var(--sh-sm); }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: center; gap: 2px;
  background: rgba(255,255,255,.92); backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
}
.navbtn {
  flex: 1; max-width: 130px; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 3px 2px; color: var(--ink-3); font-size: 11px; font-weight: 620; border-radius: 12px;
}
.navbtn svg { width: 23px; height: 23px; }
.navbtn.active { color: var(--accent); }
.navbtn:active { background: var(--line-2); }

/* desktop: top tabs, no bottom bar, everything aligned to the 720px content column */
@media (min-width: 720px) {
  .topnav { display: flex; }
  .bottomnav { display: none; }
  body { padding-bottom: 28px; }
  .fab { bottom: 24px; }
  .fab-mic { bottom: 92px; }
  .appbar { padding-left: 24px; padding-right: 24px; }
  .appbar > h1, .appbar > #stats, .appbar > .topnav, .appbar > .searchwrap, .appbar > .filterbar {
    max-width: 692px; margin-left: auto; margin-right: auto; width: 100%; }
  .appbar { --gear-right: max(24px, calc(50% - 346px)); }  /* both header buttons follow this */
  .filterbar .btn.fexport { margin-left: auto; }
}

/* ===================== lists / cards ===================== */
main { max-width: 720px; margin: 0 auto; padding: 14px 14px 0; }
.group { margin-bottom: 6px; }
.group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3);
  margin: 18px 6px 10px; font-weight: 650; }
.group-title span { background: var(--line); color: var(--ink-2); border-radius: var(--pill); padding: 1px 8px; font-size: 11px; margin-left: 5px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--sh-sm); padding: 14px 16px; margin-bottom: 11px; cursor: pointer;
  transition: transform .08s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover { box-shadow: var(--sh); }
/* Confirmed but not yet in ACGME — a subtle blue tint + accent edge marks what's queued to sync. */
.card-queued { background: #f3f7ff; border-color: #d3e1ff; box-shadow: inset 3px 0 0 var(--accent), var(--sh-sm); }
@media (prefers-color-scheme: dark) { .card-queued { background: rgba(54,103,240,.10); border-color: rgba(54,103,240,.35); } }
.card:active { transform: scale(.992); }
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.proc { font-weight: 680; font-size: 16.5px; letter-spacing: -.01em; }
.date { color: var(--ink-3); font-size: 13px; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.meta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 9px; color: var(--ink-2); font-size: 12.5px; }
.pearls { margin-top: 10px; font-size: 13.5px; color: #43506a; background: var(--surface-2);
  border: 1px solid var(--line-2); padding: 8px 11px; border-radius: var(--r-md); }
.badges { margin-top: 11px; display: flex; gap: 6px; align-items: center; }
.card-del { margin-left: auto; background: none; border: none; cursor: pointer; color: var(--ink-3);
  padding: 5px 6px; border-radius: 8px; line-height: 0; display: inline-flex; transition: color .12s, background .12s; }
.card-del svg { width: 17px; height: 17px; }
.card-del:hover { color: var(--danger); background: #fdf0f0; }

/* undo snackbar */
.snackbar { position: fixed; left: 50%; transform: translateX(-50%) translateY(16px);
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); z-index: 70;
  background: #1c2735; color: #fff; border-radius: 12px; padding: 12px 16px;
  display: none; align-items: center; gap: 16px; box-shadow: var(--sh-lg); font-size: 14px;
  max-width: 90vw; opacity: 0; transition: opacity .2s, transform .2s; }
.snackbar.show { display: flex; opacity: 1; transform: translateX(-50%) translateY(0); }
.snackbar button { background: none; border: none; color: #86abff; font-weight: 750; font-size: 14px; cursor: pointer; padding: 2px 4px; }

/* chips + badges */
.chip { font-size: 12px; padding: 3px 10px; border-radius: var(--pill); font-weight: 600; white-space: nowrap; }
.chip.approach.a-robotic { background: #f3ecff; color: #7c4dd1; }
.chip.approach.a-lap { background: #e6f2fe; color: #1f74c4; }
.chip.approach.a-open { background: #e7f7ee; color: #1a9460; }
.chip.approach.a-endoscopic { background: #e2f6f3; color: #12897c; }
.chip.role { background: #eef7f2; color: #16875f; }
.chip.person { background: #eef1f6; color: #3d4a5c; }
.chip.rot { background: #fbf1e0; color: #a06a1a; }
.chip.cpt { background: #eef1ff; color: #3d55c9; font-variant-numeric: tabular-nums; }
.chip.cat { background: #eef1ff; color: #3d55c9; cursor: pointer; }
.badge { font-size: 11.5px; padding: 3px 10px; border-radius: var(--pill); font-weight: 650;
  display: inline-flex; align-items: center; gap: 4px; }
.badge svg { width: 13px; height: 13px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.muted { background: var(--line-2); color: var(--ink-2); }
.badge.acg-in { background: var(--ok-soft); color: var(--ok); }
.badge.acg-out { background: var(--warn-soft); color: var(--warn); }
.acg-toggle { cursor: pointer; }
.acg-toggle:hover { filter: brightness(.97); text-decoration: underline; text-underline-offset: 2px; }

/* list "show more" footer */
.list-more { text-align: center; padding: 8px 0 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.list-more .btn { min-width: 160px; }

/* empty state */
.empty { text-align: center; color: var(--ink-2); padding: 56px 18px; }
.empty p { font-size: 16px; margin-bottom: 18px; line-height: 1.5; }
.empty .btn { margin: 5px; }

/* ===================== buttons ===================== */
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 10px 15px; border-radius: var(--r-sm); font-size: 14px; font-weight: 620; cursor: pointer;
  transition: background .12s, border-color .12s, filter .12s; -webkit-appearance: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); padding-left: 6px; padding-right: 6px; }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { color: var(--danger); border-color: #f6d3d4; background: #fdf3f3; }

/* FABs */
.fab { position: fixed; right: 18px; z-index: 35; width: 58px; height: 58px; border-radius: 50%;
  border: none; cursor: pointer; color: #fff; font-size: 27px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  background: var(--accent); box-shadow: 0 8px 22px rgba(54,103,240,.42);
  transition: transform .08s; }
.fab:active { transform: scale(.94); }
.fab svg { width: 25px; height: 25px; }
.fab-mic svg { width: 23px; height: 23px; }
.fab-mic { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 84px); background: #0ea371;
  box-shadow: 0 8px 22px rgba(14,163,113,.42); font-size: 23px; }
.fab-mic.rec { animation: pulse 1.1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* ===================== sheets / overlays ===================== */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(15,23,34,.42);
  display: none; align-items: flex-end; justify-content: center; }
.overlay.open { display: flex; }
.sheet { background: var(--surface); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  border-radius: 22px 22px 0 0; box-shadow: var(--sh-lg); }
@media (min-width: 640px) { .overlay { align-items: center; } .sheet { border-radius: 22px; } }
/* Lock background scroll while any sheet/gate is open, so the page behind doesn't move under it. */
body:has(.overlay.open), body:has(.authgate.open) { overflow: hidden; }
.sheet-head { position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 16px; z-index: 2; }
.sheet-head h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.icon-btn { background: none; border: none; font-size: 19px; color: var(--ink-3); cursor: pointer; padding: 2px 6px; }
.icon-btn:hover { color: var(--ink); }
.sheet-actions { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line);
  display: flex; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); justify-content: flex-end; align-items: center; }
.sheet-actions .spacer { flex: 1; }

/* forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.span2 { grid-column: 1 / -1; }
.field > span { font-size: 12.5px; font-weight: 640; color: #3b4557; }
.field > span em { color: var(--ink-3); font-weight: 400; font-style: normal; }
.field input, .field select, .field textarea { max-width: 100%; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: var(--r-sm); font-size: 15px; background: var(--surface); color: var(--ink); font-family: inherit; -webkit-appearance: none; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.checkbox { flex-direction: row; align-items: center; gap: 9px; font-size: 14.5px; cursor: pointer; }
/* Restore the NATIVE checkbox — the .field input reset (appearance:none, padding, border) breaks it otherwise. */
.field.checkbox input[type="checkbox"] {
  -webkit-appearance: auto; appearance: auto;
  width: 18px; height: 18px; min-height: 0; flex: none;
  padding: 0; margin: 0; border: none; border-radius: 0; box-shadow: none;
  accent-color: var(--accent); cursor: pointer;
}
.hint { font-size: 12px; color: var(--ink-2); min-height: 16px; }
.hint a { color: var(--accent); font-weight: 600; text-decoration: none; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* cpt + category editors */
.cpt-add { display: flex; gap: 8px; }
.cpt-add input, .cpt-add select { flex: 1; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 15px; min-width: 0; }
.cpt-results { display: none; flex-direction: column; gap: 1px; margin-top: 6px; max-height: 260px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); box-shadow: 0 8px 24px rgba(15,23,34,.10); }
.cpt-results.open { display: flex; }
.cpt-opt { display: flex; gap: 8px; align-items: baseline; text-align: left; width: 100%; padding: 9px 11px;
  background: none; border: none; border-radius: 7px; cursor: pointer; font: inherit; color: var(--ink); }
.cpt-opt:hover, .cpt-opt:focus { background: var(--accent-soft); outline: none; }
.cpt-opt b { color: #3d55c9; font-variant-numeric: tabular-nums; flex: none; }
.cpt-opt span { color: var(--ink-2); font-size: 13px; }
.cat-suggest { display: none; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.cat-suggest-label { font-size: 12px; color: var(--ink-3); margin-right: 2px; }
.chip.cat-add { cursor: pointer; border: 1px dashed var(--accent); background: var(--accent-soft); color: #3d55c9;
  padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font: inherit; line-height: 1.4; }
.chip.cat-add:hover, .chip.cat-add:focus { background: #e2ebff; outline: none; }
.chip.sample { background: #fff4dc; color: #8a5a00; border: 1px solid #f0d089; font-weight: 600; }
.cpt-list { margin-top: 9px; display: flex; flex-direction: column; gap: 7px; }
.cpt-row { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: var(--r-sm); background: var(--surface-2); flex-wrap: wrap; }
.cpt-row.is-primary { border-color: #e2c98a; background: #fffdf5; }
.cpt-row .cpt-info { flex: 1; font-size: 13px; min-width: 120px; }
.cpt-row .cpt-info b { font-variant-numeric: tabular-nums; color: #3d55c9; }
.cpt-row .cpt-info span { color: var(--ink-2); }
.cpt-row .cpt-nocode { color: var(--ink-3); font-style: italic; }
.cpt-toggles { display: flex; align-items: center; gap: 6px; }
.cpt-tog { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer;
  font-size: 11.5px; font-weight: 640; padding: 5px 9px; border-radius: var(--pill); white-space: nowrap; transition: all .12s; }
.cpt-tog.prim.on { background: #fbf1d9; border-color: #eccf85; color: #9a6a12; }
.cpt-tog.robo.on { background: #f3ecff; border-color: #d9c6f5; color: #7c4dd1; }
.cpt-row .x { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 14px; padding: 2px 4px; }
.cat-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }

#opNoteOverlay textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 14px; line-height: 1.5; background: var(--surface); color: var(--ink); resize: vertical; font-family: inherit; }
#opNoteOverlay textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#opNoteOverlay .opnote-text { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
#opNoteCase b { color: var(--ink); }

.transcript-box { padding: 10px 12px; border: 1px dashed var(--line); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--ink-2); font-size: 13px; line-height: 1.5; white-space: pre-wrap; }

.low-banner { margin: 12px 16px 0; padding: 9px 13px; border-radius: var(--r-sm); background: var(--warn-soft); color: var(--warn); font-size: 12.5px; }
input.low, select.low, .cpt-list.low { border-color: #eaa23b !important; background: #fffdf7; box-shadow: 0 0 0 3px rgba(234,162,59,.16); }

/* settings */
.setgroup { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 700; margin-bottom: 9px; }

/* Settings sheet — clean, clearly-sectioned layout (replaces the flat, cramped look). */
.settings-body { padding: 6px 20px 12px; }
.settings-body .setgroup {
  margin: 22px -20px 12px; padding: 18px 20px 0;
  border-top: 1px solid var(--line);
  font-size: 13px; letter-spacing: 0; text-transform: none;
  color: var(--accent); font-weight: 700;
}
.settings-body .setgroup:first-child { margin-top: 4px; padding-top: 0; border-top: none; }
.settings-body .field { margin-top: 12px !important; }
.settings-body .setgroup + .field,
.settings-body .setgroup + .muted + .field,
.settings-body .setgroup + p + .field { margin-top: 2px !important; }
.settings-body .field input, .settings-body .field select, .settings-body .field textarea { padding: 12px 13px; border-radius: 12px; }
.settings-body .btn { border-radius: 12px; }

/* --- Settings: sectioned panes. Desktop gets a left nav (macOS/iOS Settings pattern, so it
   ports cleanly to native); mobile falls back to one scroll with every pane shown. --- */
.setpane .setgroup:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.set-nav { display: none; }
.acct-id { display: flex; align-items: center; gap: 12px; padding: 13px 15px; border-radius: 14px;
  background: var(--accent-soft); border: 1px solid #dfe6fb; }
.acct-id-name { font-size: 15px; font-weight: 700; color: var(--ink); }
.acct-id-sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; }

@media (min-width: 760px) {
  #settingsOverlay .sheet { max-width: 800px; }
  .settings-body { display: grid; grid-template-columns: 186px minmax(0, 1fr); gap: 26px;
    align-items: start; padding: 10px 22px 14px; }
  .set-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 6px; }
  .set-navbtn { text-align: left; border: none; background: none; cursor: pointer; font: inherit;
    padding: 9px 12px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
  .set-navbtn:hover { background: var(--line-2); color: var(--ink); }
  .set-navbtn.active { background: var(--accent-soft); color: #3d55c9; }
  .setpane { display: none; }
  .setpane.active { display: block; }
  .set-panes { min-width: 0; }
}
.settings-body #acct_out, .settings-body #acct_in { margin-top: 4px; }
.statlink { color: var(--accent); text-decoration: none; }
.statlink:hover { text-decoration: underline; }
.queue-banner { background: var(--accent-soft); color: #2748b8; border: 1px solid #d6e0ff; border-radius: var(--r-md);
  padding: 11px 13px; margin-bottom: 12px; font-size: 13px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.queue-banner a { color: var(--accent); }
.qexport { padding: 5px 11px; font-size: 12px; }

/* ===================== progress ===================== */
.progress { padding-bottom: 24px; }
.prog-head h2 { margin: 8px 4px 3px; font-size: 19px; font-weight: 720; letter-spacing: -.01em; }
.prog-head .muted { margin: 0 4px 14px; }
.prog-sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-sm); padding: 6px 16px 14px; margin-bottom: 12px; }
.prog-sec-title { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); margin: 13px 0 6px; font-weight: 700; }
.pgrow { padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.pgrow:last-child { border-bottom: none; }
.pgrow.sub { padding-left: 16px; }
.pgrow.sub .pglabel { color: var(--ink-2); font-size: 13px; font-weight: 600; }
.pglabel { font-weight: 640; font-size: 14.5px; margin-bottom: 6px; }
.pgbar { height: 8px; background: #edeff3; border-radius: var(--pill); overflow: hidden; }
.pgbar > span { display: block; height: 100%; background: var(--accent); border-radius: var(--pill); transition: width .35s ease; }
.pgbar > span.done { background: var(--ok); }
.pgnum { font-size: 12px; color: var(--ink-2); margin-top: 5px; font-variant-numeric: tabular-nums; }
.pgnum b { color: var(--ink); }

/* ===================== technique folders / view / editor ===================== */
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 11px; padding-top: 4px; }
.folder { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-sm);
  padding: 20px 14px; cursor: pointer; text-align: center; transition: transform .08s, box-shadow .18s; }
.folder:hover { box-shadow: var(--sh); }
.folder:active { transform: scale(.98); }
.folder-ico { font-size: 30px; line-height: 1; }
.folder-name { font-weight: 680; margin-top: 9px; font-size: 15px; }
.folder-count { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }

.tech-link { width: 100%; text-align: left; }
.tech-snippet { margin-top: 6px; font-size: 13px; color: var(--ink-2); }

.tech-sec { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px dashed var(--line); align-items: start; }
.tsec-title { grid-column: 1; font-weight: 650; padding: 10px 11px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 15px; min-width: 0; }
.tech-sec .x { grid-column: 2; grid-row: 1 / span 2; background: none; border: none; color: var(--danger); cursor: pointer; align-self: center; }
.tsec-body { grid-column: 1; min-height: 64px; padding: 10px 11px; border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: 14.5px; line-height: 1.5; resize: none; overflow: hidden; font-family: inherit; min-width: 0; }
.tsec-title:focus, .tsec-body:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.tview-sec { margin-bottom: 18px; }
.tview-sec h3 { margin: 0 0 5px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--accent); font-weight: 720; }
.tview-body { font-size: 14.5px; color: #1c2432; line-height: 1.55; }
.tview-body p { margin: 3px 0; }
.tview-body ol, .tview-body ul { margin: 5px 0; padding-left: 22px; }
.tview-body li { margin: 4px 0; }

/* attending prefs */
.apref-row { display: grid; grid-template-columns: 1fr auto; gap: 7px 8px; margin-bottom: 11px; padding-bottom: 11px; border-bottom: 1px dashed var(--line); align-items: start; }
.apref-row input.apref-name { grid-column: 1; font-weight: 640; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 14px; min-width: 0; }
.apref-row textarea.apref-note { grid-column: 1; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 14px; min-height: 54px; resize: vertical; font-family: inherit; min-width: 0; }
.apref-row .x { grid-column: 2; grid-row: 1 / span 2; background: none; border: none; color: var(--danger); cursor: pointer; align-self: center; }
.apref-view { padding: 7px 0; border-bottom: 1px solid var(--line-2); }
.apref-view:last-child { border-bottom: none; }
.apref-view b { color: #3b4557; }

/* attending detail */
.att-item { padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.att-item:last-child { border-bottom: none; }
.att-item > div { color: #3b4557; margin-top: 3px; white-space: pre-wrap; }
.att-item .chip { margin-left: 6px; }
#attBody textarea { width: 100%; padding: 11px; border: 1px solid var(--line); border-radius: var(--r-sm); font: inherit; font-size: 15px; resize: vertical; }
#attBody textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.att-caserow { padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; font-weight: 640; cursor: pointer; }
.att-caserow:last-child { border-bottom: none; }
.att-caserow:hover { color: var(--accent); }
.att-caserow .muted { font-weight: 400; }

/* capture sheet */
.sheet.capture #capText { width: 100%; padding: 13px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 15.5px; line-height: 1.45; resize: vertical; }
.sheet.capture #capText:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cap-controls { display: flex; align-items: center; gap: 10px; margin-top: 11px; }
#micBtn.rec { background: #fbe9e9; border-color: #f2b8b8; color: var(--danger); }

/* small button variant */
.btn.small { padding: 6px 11px; font-size: 12.5px; border-radius: var(--pill); }

/* merge / rename attending picker */
.merge-search { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 15px; -webkit-appearance: none; }
.merge-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.merge-sec { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 700; margin: 4px 2px 8px; }
.merge-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 13px;
  border: 1px solid var(--line); border-radius: var(--r-sm); margin-bottom: 8px; cursor: pointer; transition: background .12s, border-color .12s; }
.merge-row:hover { background: var(--accent-soft); border-color: #cdd9ff; }
.merge-name { font-weight: 650; }
.merge-count { color: var(--ink-3); font-size: 12.5px; white-space: nowrap; }
.merge-row.rename { color: var(--accent); font-weight: 600; }
.merge-row.rename b { font-weight: 750; }

/* list toolbar (sort / show-hidden) */
.listbar { display: flex; align-items: center; gap: 10px; margin: 2px 2px 4px; flex-wrap: wrap; }
.seg { display: inline-flex; background: #eaedf2; border-radius: 10px; padding: 3px; gap: 2px; }
.segbtn { border: none; background: transparent; padding: 6px 13px; border-radius: 7px; font-size: 12.5px;
  font-weight: 640; color: var(--ink-2); cursor: pointer; transition: background .14s, color .14s, box-shadow .14s; }
.segbtn.active { background: var(--surface); color: var(--ink); box-shadow: var(--sh-sm); }
.listbar .btn.small { margin-left: auto; }
/* Techniques: approach filter chips (colors mirror the approach chips on cards) */
.techfilters { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.fchip { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer;
  font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: var(--pill); }
.fchip:hover { border-color: var(--accent); }
.fchip .fchip-n { opacity: .5; margin-left: 3px; font-variant-numeric: tabular-nums; }
.fchip.active { border-color: transparent; }
.fchip.active.a-all { background: var(--accent-soft); color: #3d55c9; }
.fchip.active.a-lap { background: #e6f2fe; color: #1f74c4; }
.fchip.active.a-robotic { background: #f3ecff; color: #7c4dd1; }
.fchip.active.a-open { background: #e7f7ee; color: #1a9460; }
.fchip.active.a-endoscopic { background: #e2f6f3; color: #12897c; }
@media (max-width: 560px) { .techfilters { margin-left: 0; width: 100%; } }

/* attending cards + detail */
.muted-chip { background: var(--line-2); color: var(--ink-3); }
.att-card.is-hidden { opacity: .62; }
.att-hero { display: flex; gap: 10px; margin-bottom: 6px; }
.att-stat { flex: 1; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-md);
  padding: 12px 10px; text-align: center; min-width: 0; }
.att-stat b { display: block; font-size: 22px; font-weight: 740; letter-spacing: -.02em; }
.att-stat span { font-size: 11.5px; color: var(--ink-2); }

/* folder icon (svg) */
.folder-ico svg { width: 30px; height: 30px; color: var(--accent); }
.tech-hint { text-align: center; margin: 22px auto 0; max-width: 420px; }

/* progress baseline bar + editor */
.baseline-bar { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--sh-sm); padding: 11px 14px; margin: 4px 0 14px; font-size: 13px; color: var(--ink-2); }
.baseline-bar > div { flex: 1; min-width: 0; }
.baseline-bar b { color: var(--ink); }
.baseline-bar .btn { white-space: nowrap; }
.baseline-bar.stale { border-color: #f0d9a8; background: #fdf8ee; }
.baseline-stale { color: #9a6b12; font-weight: 600; }
.ti-drop { border: 2px dashed var(--line); border-radius: 12px; padding: 22px 18px; text-align: center; background: var(--surface-2); transition: border-color .15s, background .15s; }
.ti-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.ti-drop .link { color: var(--accent); font-weight: 600; cursor: pointer; }
.ti-drop-main { font-size: 14px; color: var(--ink); }
.ti-drop-sub { font-size: 12px; color: var(--ink-3); margin-top: 7px; }
.ti-or { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 12px; margin: 16px 0 10px; }
.ti-or::before, .ti-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.ti-skip { opacity: .5; }
.tech-foot { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 20px 12px 8px; }
.tech-foot p { margin: 0; max-width: 470px; }
.bl-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line-2); }
.bl-row.sub { padding-left: 16px; }
.bl-row.sub span { color: var(--ink-2); font-size: 13.5px; }
.bl-row span { font-size: 14.5px; font-weight: 600; }
.bl-row input { width: 88px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: 15px; text-align: right; font-variant-numeric: tabular-nums; -webkit-appearance: none; }
.bl-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* PIN lock */
.lockscreen { position: fixed; inset: 0; z-index: 2147483000; background: var(--bg); display: none; align-items: center; justify-content: center; }
.lockscreen.open { display: flex; }
.lockbox { text-align: center; width: 260px; }
.lock-logo { font-size: 32px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 6px; }
.lock-logo span { color: var(--accent); }
.lockbox input { width: 100%; padding: 13px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 22px; text-align: center; letter-spacing: 6px; }
.lockbox input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lock-err { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 16px; }

/* Account gate (front door) */
.authgate { position: fixed; inset: 0; z-index: 2147483000; background: var(--bg); display: none; align-items: center; justify-content: center; padding: 24px; overflow-y: auto; }
.authgate.open { display: flex; }
.authbox { width: 100%; max-width: 340px; text-align: center; }
.auth-logo { font-size: 34px; font-weight: 800; letter-spacing: -.02em; }
.auth-logo span { color: var(--accent); }
.auth-tag { color: var(--ink-3); font-size: 13.5px; margin: 2px 0 22px; }
.gate-view { text-align: left; }
.gstep { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); margin-bottom: 14px; text-align: center; }
.auth-note { font-size: 12.5px; color: var(--ink-2, #5a6678); line-height: 1.5; margin: 0 0 14px; }
.gfield { display: block; margin-bottom: 12px; }
.gfield > span { display: block; font-size: 12.5px; font-weight: 640; color: #3b4557; margin-bottom: 6px; }
.gfield > span em { color: var(--ink-3); font-weight: 400; font-style: normal; }
.gfield input, .gfield select { width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px; font-size: 15px; background: var(--surface); color: var(--ink); }
.gfield input:focus, .gfield select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.gbtn { width: 100%; justify-content: center; margin-top: 4px; padding: 13px; font-size: 15px; }
.gbtn + .gbtn { margin-top: 10px; }
.gmsg { font-size: 13px; margin-top: 10px; min-height: 18px; text-align: center; }
.gate-alt { text-align: center; font-size: 13.5px; color: var(--ink-3); margin-top: 14px; }
.gate-alt a { color: var(--accent); cursor: pointer; text-decoration: none; font-weight: 600; }
.gate-alt a.muted { color: var(--ink-3); font-weight: 400; }
.gate-alt a:hover { text-decoration: underline; }
.rec-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 21px; letter-spacing: 2px; text-align: center; padding: 16px; border: 1px dashed var(--line); border-radius: 12px; margin: 4px 0 12px; color: var(--ink); }

/* --- Sign-in: single centered form on phones; brand/value panel + form on desktop.
   The split maps to a native onboarding screen later (hero art left, form right). --- */
.authwrap { width: 100%; display: flex; justify-content: center; }
.auth-hero { display: none; }
@media (min-width: 900px) {
  .authgate { padding: 32px; }
  .authwrap { display: grid; grid-template-columns: 1.05fr .95fr; max-width: 880px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
    overflow: hidden; box-shadow: 0 18px 50px rgba(20, 28, 48, .13); }
  .auth-hero { display: flex; flex-direction: column; gap: 16px; padding: 46px 42px;
    background: linear-gradient(158deg, #4170f1, #2b4bc7); color: #fff; text-align: left; }
  .auth-hero .auth-logo { font-size: 30px; color: #fff; }
  .auth-hero .auth-logo span { color: #c9dbff; }
  .auth-hero .auth-tag { color: rgba(255, 255, 255, .82); margin: 0 0 4px; font-size: 14px; }
  .auth-points { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 13px; }
  .auth-points li { position: relative; padding-left: 26px; font-size: 13.6px; line-height: 1.5;
    color: rgba(255, 255, 255, .95); }
  .auth-points li::before { content: "✓"; position: absolute; left: 0; font-weight: 800; color: #b9d1ff; }
  .auth-hero-foot { margin-top: auto; padding-top: 26px; font-size: 12.5px; line-height: 1.55;
    color: rgba(255, 255, 255, .72); }
  .auth-hero-foot a { color: #fff; font-weight: 600; text-decoration: underline; white-space: nowrap; }
  .authgate .authbox { max-width: none; padding: 46px 42px; display: flex;
    flex-direction: column; justify-content: center; }
  .authbox .auth-logo, .authbox .auth-tag, .gate-privacy { display: none; } /* hero covers these */
}

/* Recently deleted (trash) rows */
.trash-row { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.trash-row:last-child { border-bottom: none; }
.trash-info { flex: 1; min-width: 0; }
.trash-title { font-weight: 640; font-size: 14px; }

/* Pull-to-refresh indicator */
html, body { overscroll-behavior-y: contain; }
#ptr { position: fixed; top: -46px; left: 50%; transform: translateX(-50%); z-index: 40; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--ink-3); box-shadow: 0 6px 18px rgba(20,30,50,.12); opacity: 0; transition: top .18s, opacity .18s; display: flex; align-items: center; gap: 5px; pointer-events: none; }
#ptr.spin span { display: inline-block; animation: ptrspin .8s linear infinite; }
@keyframes ptrspin { to { transform: rotate(360deg); } }

/* Onboarding / how it works */
.ob-body { padding: 20px 24px 6px; }
.ob-step { min-height: 232px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.ob-icon { width: 62px; height: 62px; border-radius: 18px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-size: 31px; line-height: 1; margin: 2px 0 18px; }
.ob-step h3 { margin: 0 0 10px; font-size: 20px; font-weight: 780; letter-spacing: -.015em; color: var(--ink); }
.ob-step p { margin: 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.6; max-width: 340px; }
.ob-step em { color: var(--ink); font-style: normal; font-weight: 640; }
.ob-count { font-size: 12px; font-weight: 640; color: var(--ink-3); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.ob-dots { display: flex; gap: 7px; justify-content: center; padding: 22px 0 4px; }
/* import guide */
.ig-lbl { font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 9px; }
.ig-steps { margin: 0; padding-left: 22px; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.ig-steps li { margin: 8px 0; padding-left: 3px; }
.ig-steps li::marker { color: var(--accent); font-weight: 700; }
.ig-steps b { color: var(--ink); font-weight: 640; }
.ig-help { display: inline-block; margin-top: 14px; font-size: 13.5px; font-weight: 640; color: var(--accent); text-decoration: none; }
.ig-help:hover { text-decoration: underline; }
.ob-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); transition: background .18s, width .18s; }
.ob-dot.on { background: var(--accent); width: 20px; border-radius: 4px; }

/* Pilot survey */
.survey-body { padding: 10px 20px 12px; max-height: 66vh; overflow: auto; }
.sv-q { margin: 0 0 18px; }
.sv-qt { font-weight: 640; font-size: 14px; margin-bottom: 9px; line-height: 1.4; }
.sv-likert { display: flex; gap: 6px; }
.sv-choices { display: flex; flex-direction: column; gap: 7px; }
.sv-opt { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 13px; background: var(--surface); transition: border-color .12s, background .12s; }
.sv-likert .sv-opt { flex: 1; flex-direction: column; text-align: center; gap: 7px; font-size: 11px; padding: 10px 4px; }
.sv-opt:hover { border-color: var(--accent); }
.sv-opt input { accent-color: var(--accent); margin: 0; }
.sv-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.sv-num, .sv-text { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; font-family: inherit; background: var(--surface); color: var(--ink); box-sizing: border-box; }
.sv-num:focus, .sv-text:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Clearer busy/disabled feedback — the Parse button shows a spinner while Claude works. */
.btn:disabled { opacity: .55; cursor: default; }
#parseBtn { position: relative; }
#parseBtn:disabled { opacity: 1; color: transparent; }
#parseBtn:disabled::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: parsespin .7s linear infinite;
}
@keyframes parsespin { to { transform: rotate(360deg); } }
#capStatus { color: var(--accent); font-weight: 600; }
