 
:root {
  --bg: #efeee9; --panel: #ffffff; --panel2: #f7f6f2; --ink: #1c2026; --muted: #5f6771; --line: #dcdad2;
  --accent: #0e7a83; --accent-ink: #ffffff; --amber: #e39a12; --good: #1d8a4e; --bad: #c0392b; --crit: #a3121a; --info: #2f63b8;
  --good-bg: #e7f4ec; --bad-bg: #fbece9; --crit-bg: #fde3e3; --info-bg: #e8effb;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05); --r: 12px; --screen: #0b0f14;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1115; --panel: #161a20; --panel2: #1c2129; --ink: #e6e8eb; --muted: #9aa3ad; --line: #2a3039;
    --accent: #2bb3bd; --accent-ink: #061216; --amber: #f2ae2e; --good: #3fbf78; --bad: #ef6b5b; --crit: #ff7a7a; --info: #7da7f0;
    --good-bg: #13291d; --bad-bg: #2d1916; --crit-bg: #3a1414; --info-bg: #16213a;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1115; --panel: #161a20; --panel2: #1c2129; --ink: #e6e8eb; --muted: #9aa3ad; --line: #2a3039;
  --accent: #2bb3bd; --accent-ink: #061216; --amber: #f2ae2e; --good: #3fbf78; --bad: #ef6b5b; --crit: #ff7a7a; --info: #7da7f0;
  --good-bg: #13291d; --bad-bg: #2d1916; --crit-bg: #3a1414; --info-bg: #16213a;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.row { display: flex; gap: 8px; align-items: center; } .row.wrap { flex-wrap: wrap; } .row.end { justify-content: flex-end; }

 
.topbar { display: flex; align-items: center; gap: 12px 16px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; border: 0; background: none; cursor: pointer; padding: 0; text-align: left; }
.brand > span { display: flex; flex-direction: column; min-width: 0; }
.logo { width: 30px; height: 30px; flex: none; } .logo-a { fill: var(--ink); } .logo-b { stroke: var(--amber); stroke-width: 3.2; stroke-linecap: round; } .logo-c { stroke: var(--panel); stroke-width: 2.2; stroke-linecap: round; }
.brand .h1 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.brand .sub { font-size: 12px; color: var(--muted); }
.modes { display: flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; margin-left: auto; }
.modes button { border: 0; background: none; padding: 6px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 600; }
.modes button[aria-selected="true"] { background: var(--ink); color: var(--panel); }
.modes button:disabled { opacity: .45; cursor: not-allowed; }
.top-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.modes:not([hidden]) + .top-right { margin-left: 0; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel2); border-radius: 999px; padding: 5px 11px; cursor: pointer; max-width: 200px; }
.chip-btn span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.chip-btn.signed .dot { background: var(--good); }
.icon-btn { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel2); cursor: pointer; font-weight: 700; flex: none; }

 
.btn { border: 1px solid var(--line); background: var(--panel2); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 600; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ok { background: var(--good); color: #fff; border-color: var(--good); }
.btn.danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { background: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; font-weight: 600; padding: 2px 0; text-align: left; }
.toggle { border: 1px solid var(--line); background: var(--panel2); border-radius: 999px; padding: 4px 10px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--muted); }
.toggle[aria-pressed="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }

 
.home { max-width: 1100px; margin: 0 auto; padding: 24px 16px 8px; }
.hero h1 { font-size: 28px; letter-spacing: -.02em; }
.hero p { max-width: 720px; color: var(--muted); font-size: 15px; }
.cats { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0 12px; }
.cats button { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 7px 14px; cursor: pointer; font-weight: 600; color: var(--muted); }
.cats button[aria-selected="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card h3 { font-size: 17px; }
.card .sub { color: var(--muted); margin: 0; }
.card.soon { opacity: .62; }
.card .tag { align-self: flex-start; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.card .tag.live { color: var(--good); border-color: var(--good); }
.opt { display: flex; flex-direction: column; gap: 4px; }
.opt > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: var(--panel2); padding: 7px 6px; font-size: 13px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
.card .prog { font-size: 12.5px; color: var(--muted); margin: 0; }

 
.sim { display: grid; gap: 12px; padding: 12px 16px; grid-template-columns: minmax(0, 1fr) 380px; align-items: start; max-width: 1500px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 10px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.panel h2, .tray-head h2, h2.inline { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
h2.inline { display: inline; }
.side { display: grid; gap: 12px; min-width: 0; }

.field-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.step-pill { display: flex; align-items: baseline; gap: 4px; background: var(--ink); color: var(--panel); border-radius: 10px; padding: 4px 10px; font-weight: 700; }
.step-pill .of { font-weight: 500; font-size: 12px; opacity: .75; }
.field-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.field-tools { display: flex; gap: 6px; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.actions-row .btn { background: var(--crit); color: #fff; border-color: var(--crit); }
.actions-row .btn.done { background: var(--panel2); color: var(--muted); border-color: var(--line); }
.field-host { position: relative; touch-action: none; user-select: none; -webkit-user-select: none; background: #8fb4ae; border-radius: 10px; overflow: hidden; display: flex; justify-content: center; }
.field-svg { display: block; width: 100%; height: auto; max-height: min(74vh, 780px); cursor: crosshair; font: 600 13px system-ui, sans-serif; }
.field-svg .zone rect { fill: rgba(255,255,255,.22); stroke: rgba(255,255,255,.6); stroke-dasharray: 5 4; cursor: pointer; }
.field-svg .zone:hover rect { fill: rgba(255,255,255,.4); }
.field-svg .zone text { fill: #10262a; font-size: 12px; font-weight: 700; pointer-events: none; }
.field-svg .zone.chosen rect { fill: rgba(227,154,18,.5); stroke: #e39a12; stroke-dasharray: none; }
.field-svg .zone-tag { fill: #10262a; font-size: 12px; font-weight: 800; letter-spacing: .12em; opacity: .75; pointer-events: none; }
.field-svg .lbl-t { font-size: 13px; font-weight: 700; fill: #111a22; paint-order: stroke; stroke: rgba(255,255,255,.85); stroke-width: 3px; }
.field-svg .hint > * { fill: none; stroke: #ffd24a; stroke-width: 5; animation: pulse 1.2s ease-in-out infinite; pointer-events: none; }
@keyframes pulse { 0%, 100% { stroke-opacity: .25; } 50% { stroke-opacity: 1; } }
.field-svg .cut-preview { stroke: #a3121a; stroke-width: 3; stroke-dasharray: 6 5; fill: none; }
.field-svg .bougie-preview { stroke: #e9c769; stroke-width: 8; stroke-linecap: round; opacity: .8; fill: none; }
.field-svg .manip-preview { stroke: #e39a12; stroke-width: 3; stroke-dasharray: 4 4; fill: none; }
.field-svg .fingertip { fill: #c3bcf0; stroke: #7a70c2; stroke-width: 2; opacity: .85; pointer-events: none; }
.field-svg .fingertip-ring { fill: none; stroke: #fff; stroke-width: 2; opacity: .8; pointer-events: none; }
.field-svg .inst { cursor: pointer; }
.bubble { position: absolute; max-width: 220px; background: rgba(16,22,28,.92); color: #fff; font-size: 13px; padding: 7px 10px; border-radius: 8px; pointer-events: none; }
.bubble.felt { background: rgba(14,122,131,.95); }
.popover { position: absolute; display: flex; flex-direction: column; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.18); z-index: 5; }

.tray-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 10px 0 6px; }
.tray { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.tool { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; border: 1px solid var(--line); background: var(--panel2); border-radius: 10px; padding: 6px 4px 7px; cursor: pointer; font-size: 11.5px; font-weight: 600; line-height: 1.2; text-align: center; min-width: 0; }
.tool svg { width: 40px; height: 28px; }
.tool .k { position: absolute; top: 3px; left: 5px; font-size: 10px; color: var(--muted); font-weight: 700; }
.tool[aria-pressed="true"] { border-color: var(--amber); background: color-mix(in srgb, var(--amber) 18%, var(--panel2)); box-shadow: 0 0 0 2px var(--amber) inset; }
.tool.hint { animation: toolpulse 1.2s ease-in-out infinite; }
@keyframes toolpulse { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 50% { box-shadow: 0 0 0 3px #ffd24a; } }
.ico-stroke { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico-fill { fill: var(--ink); }
.ico-amber { fill: none; stroke: var(--amber); stroke-width: 2.4; stroke-linecap: round; }

 
.step-card { display: grid; gap: 8px; }
.kicker { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.step-head h2 { font-size: 18px; color: var(--ink); text-transform: none; letter-spacing: -.01em; margin-top: 2px; }
.prompt { margin: 0; font-size: 14.5px; }
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choices:empty { display: none; }
.result { border-radius: 10px; padding: 9px 11px; font-size: 13.5px; border: 1px solid transparent; }
.result.ok { background: var(--good-bg); border-color: var(--good); }
.result.error { background: var(--bad-bg); border-color: var(--bad); }
.result.critical { background: var(--crit-bg); border-color: var(--crit); }
.result.info { background: var(--panel2); border-color: var(--line); }
.result.recovery { background: var(--info-bg); border-color: var(--info); }
.result .tag { display: block; font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; margin-bottom: 2px; }
.result.ok .tag { color: var(--good); } .result.error .tag { color: var(--bad); } .result.critical .tag { color: var(--crit); } .result.recovery .tag { color: var(--info); }
.teach { background: var(--panel2); border-radius: 10px; padding: 6px 10px; }
.teach summary { cursor: pointer; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.teach p { margin: 6px 0 2px; }
.fb textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); padding: 8px; margin: 6px 0; resize: vertical; }

 
.depth-canvas { width: 100%; display: block; border-radius: 8px; background: #8fb4ae; }
.readout { margin: 6px 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.depth-ctrl .btn { flex: 1; }
.depth-panel.active { border-color: var(--amber); box-shadow: 0 0 0 2px color-mix(in srgb, var(--amber) 40%, transparent); }
.hold { touch-action: none; user-select: none; -webkit-user-select: none; }

 
.monitor { background: var(--screen); color: #e8f0f2; border-color: #222a33; }
.vitals { display: flex; gap: 16px; font-variant-numeric: tabular-nums; }
.vitals > div { display: flex; align-items: baseline; gap: 4px; }
.vitals .lab { font-size: 11px; color: #8fa0ab; font-weight: 700; }
.vitals b { font-size: 22px; }
.vitals div:nth-child(1) b { color: #69d2ff; } .vitals div:nth-child(2) b { color: #7cf29a; } .vitals div:nth-child(3) b { color: #ffd966; }
.capno { width: 100%; height: 56px; display: block; cursor: pointer; margin-top: 4px; }
.monitor .small { color: #8fa0ab; margin: 4px 0 0; }

.bodymap { display: flex; justify-content: center; }
.bodymap-svg { width: 100%; max-width: 240px; height: auto; }
.bm-skin { fill: #ecc3a8; stroke: #b07f65; stroke-width: 1.2; }
.bm-bone { fill: #f5f0e3; stroke: #ae9f84; }
.bm-clav { fill: none; stroke: #f5f0e3; stroke-width: 4; stroke-linecap: round; }
.bm-roll { fill: #8b6a4c; opacity: .8; }
.bm-field { fill: rgba(227,154,18,.12); stroke: #e39a12; stroke-width: 1.5; stroke-dasharray: 4 3; }
.bm-cut { stroke: #a3121a; stroke-width: 2.5; stroke-linecap: round; }
.bm-you { fill: var(--accent); } .bm-you-t { fill: var(--accent-ink); font: 700 8px system-ui, sans-serif; }
.bm-t { fill: var(--muted); font: 700 10px system-ui, sans-serif; }

.steps { margin: 8px 0 0; padding-left: 0; list-style: none; display: grid; gap: 2px; }
.steps li { display: flex; gap: 8px; padding: 4px 6px; border-radius: 6px; font-size: 13px; }
.steps li .n { width: 26px; flex: none; color: var(--muted); font-weight: 700; text-align: right; }
.steps li.done { color: var(--muted); } .steps li.done .n::after { content: ' ✓'; color: var(--good); }
.steps li.now { background: color-mix(in srgb, var(--amber) 16%, transparent); font-weight: 700; }
details > summary { cursor: pointer; }

 
.foot { max-width: 1500px; margin: 8px auto 20px; padding: 0 16px; color: var(--muted); font-size: 12.5px; }
.foot p { margin: 4px 0; }
.copyright { font-weight: 600; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal-card { background: var(--panel); border-radius: 14px; padding: 16px; width: min(560px, 100%); max-height: 90vh; overflow: auto; display: grid; gap: 10px; }
.modal-card.wide { width: min(960px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.modal-head h2 { font-size: 18px; }
input[type=email] { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--panel2); border-radius: 8px; padding: 7px 10px; }
.profile-list { display: flex; flex-wrap: wrap; gap: 6px; }
.progress-table table, table.keys { border-collapse: collapse; width: 100%; font-size: 13px; }
.progress-table td, .progress-table th, table.keys td { border-bottom: 1px solid var(--line); padding: 5px 6px; text-align: left; }
.danger-text { color: var(--bad); }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.help-grid h3 { font-size: 14px; margin: 4px 0; }
.help-grid ul { padding-left: 18px; margin: 4px 0 10px; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font: 600 12px ui-monospace, monospace; background: var(--panel2); }
.debrief { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; max-height: 40vh; overflow: auto; }
.debrief li { border-left: 3px solid var(--bad); padding: 3px 8px; font-size: 13px; background: var(--panel2); border-radius: 0 6px 6px 0; }
.debrief li.critical { border-color: var(--crit); }
.stat-row { display: flex; gap: 16px; flex-wrap: wrap; }
.stat { background: var(--panel2); border-radius: 10px; padding: 8px 12px; } .stat b { display: block; font-size: 20px; }

@media (max-width: 1000px) {
  .sim { grid-template-columns: minmax(0, 1fr); padding: 8px; }
  .side { order: 2; }
  .field-svg { max-height: none; }
}
@media (max-width: 520px) {
  .topbar { padding: 8px 10px; }
  .brand .sub { font-size: 11px; }
  .modes { order: 3; width: 100%; margin-left: 0; justify-content: center; }
  .hero h1 { font-size: 22px; }
  .tray { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
  .tool svg { width: 34px; height: 24px; }
  .field-head { gap: 6px; }
}
.pulse { animation: toolpulse 1.2s ease-in-out infinite; }

 
.work { display: grid; grid-template-columns: 184px minmax(0, 1fr); gap: 10px; align-items: start; }
.tray-col .tray-head { flex-direction: column; align-items: flex-start; gap: 2px; margin: 0 0 6px; }
.tray-col .tray { grid-template-columns: 1fr 1fr; }
.tray-col .tool { font-size: 11px; padding: 5px 3px 6px; }
.tray-col .tool svg { width: 34px; height: 24px; }
@media (max-width: 1000px) {
  .work { display: flex; flex-direction: column; }
  .tray-col { order: 2; width: 100%; }
  .tray-col .tray-head { flex-direction: row; align-items: baseline; justify-content: space-between; margin-top: 8px; }
  .tray-col .tray { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
  .side { display: contents; }
  .step-card { order: 1; } .field-panel { order: 2; } .depth-panel { order: 3; } .monitor { order: 4; } .side > .panel:not(.step-card):not(.depth-panel):not(.monitor) { order: 5; }
  .field-title { flex-basis: 100%; order: 3; }
}
.tool span { overflow-wrap: anywhere; }
