:root {
  --purple-900: #38234f;
  --purple-800: #42265b;
  --purple-700: #56326f;
  --purple-100: #ece8ef;
  --ink: #25212a;
  --muted: #68636d;
  --line: #d9dce1;
  --paper: #f6f7f9;
  --surface: #ffffff;
  --critical: #7a3038;
  --critical-soft: #f2e6e7;
  --success-soft: #e9f0ec;
  --success: #315d47;
  --shadow: 0 10px 30px rgba(32, 36, 49, .09);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.app-shell { width: min(100%, 760px); min-height: 100vh; margin: 0 auto; background: var(--surface); padding-bottom: 84px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; color: #fff; background: var(--purple-800); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 48px; height: 48px; object-fit: contain; border-radius: 50%; background: #fff; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 19px; font-weight: 700; }
.brand span { margin-top: 2px; font-size: 12px; opacity: .82; }
.icon-button { width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%; background: rgba(255,255,255,.13); color: inherit; font-size: 24px; cursor: pointer; }
main { padding: 18px; }
section + section { margin-top: 27px; }
.eyebrow { margin: 0 0 4px; color: var(--purple-700); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 20px; }
h2 { font-size: 19px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.text-button { padding: 7px 0; border: 0; background: transparent; color: var(--purple-700); font-size: 13px; font-weight: 700; cursor: pointer; }
.patient-panel { padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: #fbfbfc; }
.patient-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.patient-fields label { color: var(--ink); font-size: 12px; font-weight: 700; }
.patient-fields label span { display: block; min-height: 17px; margin-top: 1px; color: var(--muted); font-size: 10px; font-weight: 500; }
.patient-fields input { width: 100%; margin-top: 5px; padding: 10px 5px; border: 1px solid #cfd2d8; border-radius: 6px; background: #fff; color: var(--purple-800); font-size: 17px; font-weight: 700; text-align: center; }
.patient-note { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.context-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.context-card { min-height: 136px; padding: 16px; border: 1px solid #c9c2cf; border-radius: 8px; background: var(--purple-100); text-align: left; cursor: pointer; }
.context-card.critical { color: #4b292d; border-color: #d7c1c3; background: var(--critical-soft); }
.context-icon { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 7px; color: #fff; background: var(--purple-800); font-size: 18px; }
.critical .context-icon { background: var(--critical); }
.context-card strong, .context-card > span:last-child { display: block; }
.context-card strong { margin-top: 14px; font-size: 16px; }
.context-card > span:last-child { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.action-list { border-top: 1px solid var(--line); }
.action-row { display: grid; width: 100%; grid-template-columns: 36px 1fr auto; gap: 11px; align-items: center; padding: 13px 2px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.action-symbol { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 7px; color: var(--purple-800); background: var(--purple-100); font-weight: 800; }
.action-row strong, .action-row small { display: block; }
.action-row strong { font-size: 14px; }
.action-row small { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.3; }
.action-row b { color: #918a96; font-size: 25px; font-weight: 400; }
.protocol-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.protocol-button { min-height: 76px; padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: #fff; text-align: left; cursor: pointer; }
.protocol-button strong { display: block; font-size: 14px; }
.protocol-button span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.bottom-nav { position: fixed; z-index: 20; bottom: 0; left: 50%; display: grid; width: min(100%, 760px); grid-template-columns: repeat(5, 1fr); transform: translateX(-50%); border-top: 1px solid var(--line); padding: 7px 4px calc(7px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.97); box-shadow: 0 -8px 24px rgba(20,20,25,.06); }
.bottom-nav button, .bottom-nav a { display: flex; min-height: 47px; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: transparent; color: var(--muted); font-size: 10px; text-decoration: none; cursor: pointer; }
.bottom-nav span { font-size: 18px; font-weight: 700; }
.bottom-nav .active { color: var(--purple-800); }
dialog { width: min(calc(100% - 24px), 720px); max-height: 84vh; margin: auto auto 76px; padding: 18px; border: 0; border-radius: 12px; color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(25,20,30,.43); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.dialog-head .icon-button { flex: 0 0 auto; color: var(--ink); background: #eef0f3; }
.dialog-list { display: grid; gap: 8px; }
.dialog-item { padding: 12px; border-left: 3px solid var(--purple-700); background: #f4f3f6; }
.dialog-item.critical { border-left-color: var(--critical); background: var(--critical-soft); }
.dialog-item strong, .dialog-item span { display: block; }
.dialog-item span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.dialog-item.actionable { position: relative; width: 100%; padding-right: 38px; border-top: 0; border-right: 0; border-bottom: 0; color: inherit; font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.dialog-item.actionable b { position: absolute; top: 50%; right: 13px; transform: translateY(-50%); color: #8d8791; font-size: 22px; font-weight: 400; }
.tool-note { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.score-grid, .calc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.score-grid label, .calc-grid label { display: grid; gap: 5px; align-content: start; color: var(--ink); font-size: 12px; font-weight: 700; }
.score-grid select, .calc-grid input { width: 100%; min-height: 42px; padding: 8px; border: 1px solid #cbd0d7; border-radius: 6px; background: #fff; color: var(--purple-800); font-size: 16px; font-weight: 700; }
.calc-grid label span { color: var(--muted); font-size: 10px; font-weight: 500; }
.choice-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.choice-grid button { min-height: 43px; border: 1px solid #c9cdd3; border-radius: 6px; background: #fff; font-weight: 800; cursor: pointer; }
.choice-grid button.selected { border-color: var(--purple-800); color: #fff; background: var(--purple-800); }
.result-box { margin-top: 15px; padding: 14px; border-left: 4px solid var(--purple-700); background: var(--purple-100); }
.result-box span, .result-box strong, .result-box small { display: block; }
.result-box span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.result-box strong { margin-top: 4px; color: var(--purple-900); font-size: 19px; }
.result-box small { margin-top: 5px; color: var(--muted); line-height: 1.4; }
.search-field input { width: 100%; padding: 13px; border: 1px solid #c7cbd2; border-radius: 7px; font-size: 16px; }
.search-results { margin-top: 14px; }
.empty { padding: 26px 8px; color: var(--muted); text-align: center; }

@media (max-width: 480px) {
  main { padding: 15px; }
  .patient-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .context-card { min-height: 144px; padding: 14px; }
  .score-grid, .calc-grid { grid-template-columns: 1fr; }
}

@media (min-width: 761px) {
  body { padding: 18px 0; }
  .app-shell { min-height: calc(100vh - 36px); border: 1px solid var(--line); box-shadow: var(--shadow); }
}
