:root {
  color-scheme: light;
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-subtle: #fbfcfb;
  --surface-tint: #e5f2f1;
  --surface-muted: var(--surface-subtle);
  --surface-blue: var(--surface-tint);
  --line: #dce4e8;
  --line-strong: #b9c8cf;
  --border: var(--line);
  --border-strong: var(--line-strong);
  --ink: #14324b;
  --text: #1e3447;
  --muted: #687989;
  --muted-strong: #4f5e6c;
  --faint: #95a4ae;
  --primary: #14324b;
  --primary-hover: #0e273d;
  --primary-strong: var(--primary-hover);
  --accent: #0b7c82;
  --accent-soft: #e5f2f1;
  --primary-soft: var(--accent-soft);
  --success: #16834a;
  --warning: #b7791f;
  --warning-bg: #fff7ed;
  --danger: #b74b4b;
  --danger-bg: #fff3f1;
  --focus: #0b7c82;
  --sidebar: var(--bg);
  --radius-sm: 6px;
  --radius-md: 8px;
  --shadow-raised: 0 10px 28px rgb(20 50 75 / 8%);
  --shadow: var(--shadow-raised);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Aptos, "SF Pro Text", "Helvetica Neue", ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
  padding: 6px 10px;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
}

button:hover {
  border-color: var(--border-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.primary-button,
.button--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.primary-button:hover,
.button--primary:hover:not(:disabled) {
  background: var(--primary-strong);
}

.button--secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}

/* File actions need a clear, consistent visual family across Vault, Workups,
   Checklist, and the local model library. Keep them compact and calm so the
   icon and verb read as one intentional control instead of a default button. */
.transfer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.button--transfer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 13px;
  border-color: #b9cfd2;
  border-radius: var(--radius-md);
  background: #f7fbfb;
  color: var(--ink);
  white-space: nowrap;
}

.button--transfer .icon {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.button--transfer:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--primary);
}

.button--quiet {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.button--quiet:hover:not(:disabled) {
  background: var(--surface-subtle);
  border-color: var(--border);
  color: var(--ink);
}

.button--icon {
  inline-size: 30px;
  min-width: 30px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

input,
select,
textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 6px 8px;
}

textarea {
  resize: vertical;
  min-height: 88px;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
  outline: 2px solid color-mix(in srgb, var(--focus), transparent 68%);
  outline-offset: 1px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  color: var(--text);
  font-weight: 650;
  line-height: 1.22;
  letter-spacing: -0.012em;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

h4 {
  font-size: 13px;
}

p {
  margin: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr);
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
}

.side-nav {
  display: grid;
  grid-template-rows: 56px minmax(0, 1fr) auto;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
  min-height: 0;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 14px 14px 12px;
}

.brand-lockup strong,
.brand-lockup span {
  display: block;
}

.brand-lockup span,
.side-footer,
.subtle,
.muted {
  color: var(--muted);
}

.brand-lockup span,
.side-footer {
  font-size: 11px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.primary-nav {
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 10px 8px;
  overflow-y: auto;
}

.nav-group {
  display: grid;
  align-content: start;
  gap: 4px;
}

.nav-group-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 10px 8px 2px;
}

.nav-group:first-child .nav-group-label {
  margin-top: 2px;
}

.primary-nav button {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #435465;
  font-size: 12px;
  font-weight: 550;
  padding: 7px 8px;
  text-align: left;
}

.primary-nav button.active {
  border: 0;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: #0b686d;
  padding-left: 5px;
}

.primary-nav .nav-note {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.3;
}

/* Keep navigation labels visible and avoid moving the workspace on hover. */
@media (min-width: 1041px) {
  .app-shell { grid-template-columns: 178px minmax(0, 1fr); }
  .side-nav { overflow: hidden; }
  .primary-nav button { min-height: 40px; }
}

.side-footer {
  display: grid;
  gap: 5px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}

.app-main {
  display: grid;
  grid-template-rows: 56px minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  min-height: 56px;
  height: 56px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.workspace-heading {
  min-width: 0;
  display: none;
}

.workspace-heading h1 {
  margin: 0;
  color: #14213a;
}

.page-context {
  margin-top: 1px;
  color: #345061;
  font-size: 12px;
  font-weight: 600;
}

.top-controls {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  width: 100%;
}

.patient-switcher {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 7px;
  width: 310px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.patient-switcher select { min-height: 34px; }

.status-pill {
  display: none;
}

.workspace {
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.view {
  display: none;
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding: 16px 20px 20px;
  overscroll-behavior: contain;
}

.view.active {
  display: block;
  height: 100%;
  min-height: 0;
}

#checklistView.active {
  overflow: hidden;
}

#checklistContent {
  height: 100%;
  min-height: 0;
}

#dailyContent,
#workupsContent,
#promptsContent,
#quickDeidContent {
  height: 100%;
  min-height: 0;
}

.page-grid {
  display: grid;
  gap: 12px;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.three-column {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.surface-panel,
.panel,
.table-panel,
.prompt-panel,
.utility-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.panel,
.table-panel,
.prompt-panel,
.utility-panel {
  padding: 13px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.section-heading.tight {
  align-items: center;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.topbar-trust {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

/* Offline-mode header pill. Reuses the topbar-trust slot; the is-offline
   state gets a distinct, restrained treatment (no alarm colors). */
.offline-pill {
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--muted);
  cursor: default;
  background: transparent;
}
.offline-pill.is-offline {
  color: #0f766e;
  border-color: #0f766e;
  background: #f0fdfa;
}
@media (prefers-color-scheme: dark) {
  .offline-pill.is-offline {
    color: #5eead4;
    border-color: #2dd4bf;
    background: rgba(45, 212, 191, 0.12);
  }
}

/* Settings > "Where does my data go?" disclosure list. */
.data-flow-list {
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.data-flow-list > div {
  display: grid;
  gap: 2px;
}
.data-flow-list dt {
  font-weight: 600;
  font-size: 13px;
}
.data-flow-list dd {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.notice,
.empty-state {
  border: 0;
  border-left: 3px solid #a6d5d6;
  border-radius: 4px;
  background: var(--surface-tint);
  color: #4b6572;
  padding: 9px 10px;
}

.warning-box {
  border: 0;
  border-left: 3px solid var(--danger);
  border-radius: 4px;
  background: var(--danger-bg);
  color: #81433e;
}

.next-step {
  display: grid;
  gap: 3px;
  border-left: 3px solid var(--accent);
  background: var(--surface-tint);
  color: #45616d;
  padding: 10px 11px;
}

.next-step strong { color: var(--ink); }

.next-step span { font-size: 12px; }

.compact-next-step {
  margin-bottom: 12px;
  font-size: 12px;
}

.vault-recovery {
  display: grid;
  gap: 4px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding-top: 12px;
}

.vault-recovery strong { color: var(--ink); }

.vault-recovery .button--quiet {
  justify-self: start;
  color: var(--danger);
  padding-inline: 0;
}

.vault-recovery .button--quiet:hover:not(:disabled) {
  border-color: transparent;
  background: transparent;
  color: #8f3434;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}

.form-grid.compact,
.stack {
  display: grid;
  gap: 10px;
}

.patient-list,
.section-list,
.workup-list,
.day-list,
.list-stack {
  display: grid;
  gap: 8px;
}

.list-row,
.check-row,
.day-row,
.compact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  padding: 8px 9px;
  text-align: left;
}

.list-row.selected,
.day-row.selected,
.check-row:has(input:checked) {
  border-color: #91cacc;
  background: var(--primary-soft);
}

.check-row {
  justify-content: flex-start;
}

.check-row input {
  width: auto;
}

.check-row span {
  display: grid;
}

.section-editor {
  padding: 6px 9px;
}

.section-toolbar {
  display: grid;
  grid-template-columns: 16px minmax(180px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.section-grip {
  color: var(--faint);
}

.section-meta {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.section-editor:not(.is-expanded) .section-label {
  border-color: transparent;
  background: transparent;
  padding: 3px 0;
}

.section-editor:not(.is-expanded) .section-role-control {
  display: none;
}

.section-editor:not(.is-expanded) .section-text {
  display: none;
}

.section-editor.is-expanded {
  padding: 9px;
}

.section-editor.is-expanded .section-toolbar {
  margin-bottom: 8px;
}

.section-editor.is-expanded .section-text {
  min-height: 118px;
}

.section-role-control {
  display: grid;
  grid-template-columns: minmax(190px, 320px) 1fr;
  gap: 4px 10px;
  align-items: center;
  margin: 0 0 8px 24px;
  color: var(--muted);
  font-size: 12px;
}

.section-role-control select {
  grid-column: 1;
  min-width: 0;
}

.section-role-control .muted {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.notice,
.empty-state {
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-muted);
  color: var(--muted);
  padding: 9px;
}

.warning-box {
  border: 1px solid #f3c383;
  border-radius: 7px;
  background: var(--warning-bg);
  color: #7c3f08;
  padding: 10px;
}

.residual-review {
  display: grid;
  gap: 8px;
}

.residual-warning-list {
  display: grid;
  gap: 6px;
}

.residual-warning {
  display: grid;
  grid-template-columns: minmax(76px, auto) minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  min-height: 0;
  width: 100%;
  border-color: #f3c383;
  background: rgba(255, 255, 255, 0.62);
  color: #7c3f08;
  padding: 7px 8px;
  text-align: left;
}

.residual-warning:hover,
.residual-warning:focus-visible {
  border-color: #b7791f;
  background: #ffffff;
}

.residual-warning span {
  color: #9a5b15;
  font-size: 11px;
  font-weight: 700;
}

.residual-warning strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.warning-box ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.deid-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #c8e4e5;
  border-radius: 5px;
  background: #f7fcfc;
  padding: 8px 9px;
  color: #24585a;
}

.deid-strip-compact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  min-height: 0;
  padding: 7px 10px;
}

.deid-inline-status {
  min-width: 0;
  align-self: center;
  font-size: 12px;
}

.deid-inline-status .muted {
  overflow-wrap: anywhere;
}

.deid-strip-compact select {
  width: min(320px, 100%);
  min-width: 220px;
  flex: 1 1 220px;
}

.deid-strip-compact .button-row {
  display: flex;
  min-width: 0;
  justify-content: flex-start;
}

.deid-admission-date-inline {
  flex: 0 0 auto;
}

.deid-admission-date-inline input {
  min-height: 34px;
}

.model-help {
  margin-top: 4px;
  max-width: 760px;
}

.model-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.model-status-card {
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  padding: 7px 8px;
  min-width: 0;
}

.model-library {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
  padding: 10px;
}

.model-pack-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 9px;
}

.model-pack-card {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  padding: 9px;
}

.model-pack-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
}

.model-pack-card-header > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.model-pack-card p {
  color: var(--text);
  font-size: 11px;
}

.model-pack-card p.muted {
  color: var(--muted);
}

.model-pack-progress {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
}

.model-pack-progress progress {
  width: 100%;
  height: 5px;
  accent-color: var(--accent);
}

.model-pack-state,
.model-pack-bundled {
  width: max-content;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 5px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
}

.model-pack-state.state-ready,
.model-pack-state.state-bundled,
.model-pack-state.state-self-hosted,
.model-pack-bundled {
  border-color: #9ed5b4;
  background: #f0faf3;
  color: #17683d;
}

.model-pack-state.state-invalid,
.model-pack-state.state-unsupported,
.model-pack-state.state-partial {
  border-color: #f3c383;
  background: var(--warning-bg);
  color: #7c3f08;
}

.model-pack-card .button-row {
  margin-top: 2px;
}

.model-status-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.model-status-card strong {
  display: block;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.timeline-layout {
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.stay-layout {
  display: grid;
  grid-template-columns: 218px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.stay-content {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.stay-layout .form-grid.compact {
  grid-template-columns: 1fr;
}

.admission-packet .deid-strip {
  margin-bottom: 10px;
}

.timeline-rail {
  display: grid;
  gap: 8px;
  max-height: min(580px, calc(100vh - 245px));
  overflow: auto;
  padding-right: 2px;
}

.day-row {
  position: relative;
  min-height: 54px;
}

.workup-editor-layout {
  display: grid;
  grid-template-columns: minmax(210px, 286px) minmax(0, 1fr);
  gap: 12px;
}

.workflow-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-muted);
  padding: 8px;
  margin: 10px 0;
}

.workflow-step {
  display: grid;
  gap: 2px;
}

.workflow-step strong {
  color: var(--text);
}

.workup-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr;
  gap: 10px;
}

.workup-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.workup-column {
  display: grid;
  align-content: start;
  gap: 8px;
}

.workup-editor-card {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) minmax(96px, 0.35fr) 78px auto;
  gap: 7px;
  align-items: center;
  padding: 8px;
}

.workup-editor-card .icon-button {
  min-width: 28px;
}

.workup-editor-card input,
.workup-editor-card select {
  min-width: 0;
}

.workup-editor-card [data-field="item-text"] {
  grid-column: 2 / 6;
  grid-row: 1;
}

.workup-editor-card [data-field="item-select"] {
  grid-column: 4;
  grid-row: 2;
}

.workup-editor-card .button-row {
  grid-column: 5;
  grid-row: 2;
  flex-wrap: nowrap;
}

.workup-editor-card [data-field="item-id"] {
  grid-column: 2;
  grid-row: 2;
}

.workup-editor-card [data-field="item-system"] {
  grid-column: 3;
  grid-row: 2;
}

.workup-editor-card [data-field="item-choices"] {
  grid-column: 2 / 6;
  grid-row: 3;
}

.json-import {
  min-height: 92px;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.checklist-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 286px;
  gap: 12px;
  height: 100%;
  min-height: 0;
}

.checklist-panel {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
  margin: 0;
  overflow: hidden;
}

.checklist-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.checklist-toolbar-row .notice {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.checklist-search-field {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 200px;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
}

.checklist-search-field input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 32px;
}

.checklist-scroll {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 12px;
  padding-right: 4px;
}

.checklist-section {
  display: grid;
  gap: 10px;
}

.checklist-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 8px 0 4px;
}

.checklist-system {
  display: grid;
  gap: 6px;
}

.checklist-system-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-bottom: 0;
  background: var(--surface-muted);
}

.checklist-system-header h4 {
  margin: 0;
  font-size: 12px;
}

.checklist-table {
  display: grid;
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
}

.checklist-item {
  display: grid;
  grid-template-columns: minmax(180px, 1.35fr) minmax(200px, 1.4fr) minmax(150px, 0.8fr) 74px;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.checklist-item:last-child {
  border-bottom: 0;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.choice-row label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: auto;
  min-height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 7px;
  color: var(--text);
}

.choice-row label.baseline-choice {
  border-color: #9dd0d2;
  background: #f2fbfb;
  color: #075d61;
}

.choice-row label.baseline-choice:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.choice-row input,
.workup-checkbox {
  width: auto;
}

.prompt-variable {
  display: grid;
  grid-template-columns: minmax(118px, 0.75fr) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 32px;
  text-align: left;
}

.prompt-variable strong {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 12px;
}

.prompt-variable span {
  color: var(--muted);
}

.confirm-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 18px;
  box-shadow: 0 8px 24px rgba(16, 32, 43, 0.14);
}

.confirm-dialog::backdrop {
  background: rgba(16, 32, 43, 0.28);
}

.confirm-dialog form {
  display: grid;
  gap: 14px;
}

.confirm-dialog h2 {
  margin: 0;
}

.danger-subtle {
  border-color: #efc1be;
  background: #fff7f6;
  color: #a22920;
}

.danger-subtle:hover {
  border-color: var(--danger);
  background: #fff1f0;
}

.danger-button {
  border-color: var(--danger);
  background: var(--danger);
  color: #ffffff;
}

.item-note-input {
  min-height: 34px;
}

/* The note field stays always-visible at desktop widths (unchanged today);
   the tap-to-reveal toggle only takes over once a narrower layout hides it
   (see the phone-mode and max-width:680px overrides below). */
.checklist-item .note-toggle {
  display: none;
  color: var(--muted);
}

.checklist-item.has-note .note-toggle {
  border-color: var(--primary);
  color: var(--primary);
}

.status-dot {
  color: var(--success);
  font-weight: 700;
}

/* Lives outside .checklist-scroll (its own grid row on .checklist-panel) so
   it stays reachable without scrolling through the question list. */
.quick-notes-panel {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 4px;
}

.quick-notes-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.quick-notes-header h4 {
  margin: 0;
  font-size: 13px;
}

.quick-notes-header .muted {
  font-size: 11px;
}

.quick-notes-empty {
  margin: 0;
  font-size: 12px;
}

.quick-notes-list {
  display: grid;
  gap: 6px;
  max-height: 160px;
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.quick-notes-list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
  padding: 6px 8px;
  font-size: 12px;
}

.quick-note-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}

.quick-note-meta .muted {
  font-size: 10px;
  white-space: nowrap;
}

.quick-note-compose {
  display: flex;
  gap: 6px;
}

.quick-note-compose input {
  flex: 1 1 auto;
  min-height: 40px;
}

.phone-resume-notice {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.phone-transfer {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
}

.phone-preview {
  border: 5px solid #172224;
  border-radius: 28px;
  background: #ffffff;
  padding: 13px 10px;
  min-height: 360px;
  box-shadow: 0 8px 24px rgba(16, 32, 43, 0.14);
}

.phone-preview .checklist-item {
  grid-template-columns: 1fr;
  gap: 5px;
  padding: 8px 0;
  border-width: 0 0 1px;
  border-radius: 0;
}

.prompt-layout {
  display: grid;
}

.prompt-template-wrap {
  position: relative;
}

.smart-variable-menu {
  position: absolute;
  z-index: 5;
  display: none;
  min-width: 260px;
  max-width: min(360px, 100%);
  max-height: 230px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.smart-variable-menu.open {
  display: grid;
}

.smart-variable-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
}

.token-color-swatch {
  width: 16px;
  height: 16px;
  min-height: 0; /* the global `button { min-height: 34px; }` reset otherwise
    stretches this into a 16x34 pill instead of a 16x16 circle */
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 50%;
  cursor: pointer;
  flex: none;
  justify-self: center;
  /* the global `button` rule animates background-color over 140ms - with
     paintPreview() repainting this on every pointermove during a drag, each
     new target retargets the transition before the last one finishes, so the
     swatch visibly lagged behind the drag instead of tracking it live */
  transition: none;
}

/* Positioned via JS (position: fixed, top/left set to sit under whichever
   swatch is active) - deliberately a single global element (see index.html),
   not nested inside either the Prompts or Settings markup, so re-rendering
   either page can't reset its position or interrupt an open pick, and it's
   never clipped by an ancestor's overflow: auto (the smart-variable menu
   scrolls; anything nested inside it that renders past its edge used to be
   clipped, both visually and for hit-testing). */
.token-color-picker {
  position: fixed;
  width: 220px;
  padding: 10px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 50;
}

.token-color-picker[hidden] {
  display: none;
}

.token-color-picker-field {
  display: grid;
  grid-template-columns: 1fr 44px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.token-color-picker-field input[type="color"] {
  width: 44px;
  height: 30px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.token-color-picker-value {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.token-color-picker-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
}

.token-color-picker-accept {
  background: #e6f4ea;
  border-color: #2e7d32;
  color: #2e7d32;
}

.token-color-picker-cancel:hover {
  background: #fdecea;
  border-color: #c62828;
  color: #c62828;
}

.smart-variable-row:last-child {
  border-bottom: 0;
}

.smart-variable-row[hidden] {
  display: none;
}

.smart-variable-insert {
  display: grid;
  grid-template-columns: minmax(150px, 0.9fr) minmax(0, 1.1fr);
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
  min-height: 30px;
  padding: 0;
}

.smart-variable-identity {
  display: grid;
  gap: 2px;
}

.smart-variable-identity code {
  color: var(--muted);
  font-size: 11px;
}

.prompt-preview,
.prompt-output-highlighted {
  min-height: 430px;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.prompt-template-backdrop {
  position: absolute;
  inset: 0;
  overflow: auto;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  pointer-events: none;
}

#promptPreview {
  position: absolute;
  inset: 0;
  background: transparent;
  color: transparent;
  caret-color: var(--text);
}

.prompt-output-highlighted {
  display: block;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #f7fafb;
  color: #284151;
  line-height: 1.5;
}

button.var-fill {
  appearance: none;
  border: 0;
  color: inherit;
  cursor: pointer;
}

.var-fill {
  border-radius: 3px;
  padding: 0 1px;
}

button.var-fill:hover,
button.var-fill:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 1px;
}

.prompt-output-plain {
  margin-top: 8px;
}

.prompt-output-plain summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

#promptOutput {
  min-height: 0;
  height: 120px;
}

.quick-deid-grid {
  display: grid;
  grid-template-columns: minmax(250px, 1.08fr) 220px minmax(240px, 0.9fr) minmax(260px, 1.08fr);
  gap: 12px;
  align-items: stretch;
}

.quick-deid-grid textarea {
  min-height: 180px;
}

.workup-import {
  padding: 0;
}

.workup-import summary {
  display: grid;
  gap: 2px;
  cursor: pointer;
  list-style: none;
  padding: 9px 10px;
}

.workup-import summary::-webkit-details-marker {
  display: none;
}

.workup-import summary::before {
  content: "+";
  float: right;
  color: var(--muted);
  font-weight: 700;
}

.workup-import[open] summary::before {
  content: "-";
}

.workup-import-body {
  display: grid;
  gap: 9px;
  padding: 0 10px 10px;
}

.oe-import {
  gap: 14px;
}

.oe-step {
  display: grid;
  gap: 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  padding: 12px;
}

.oe-step-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.oe-step-badge {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.oe-step-head h3 {
  margin: 0 0 2px;
  font-size: 14px;
}

.oe-step-head p {
  margin: 0;
}

.oe-destination-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.oe-destination-card {
  display: grid;
  align-content: start;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 10px;
}

.oe-destination-card h4 {
  margin: 0;
  font-size: 13px;
}

.oe-destination-card p {
  margin: 0;
}

.oe-saved-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--success);
  font-weight: 600;
}

.oe-saved-line .button--quiet {
  font-weight: 400;
  color: var(--muted);
}

.icon {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -3px;
}

#statusLine {
  display: flex;
  align-items: center;
  gap: 6px;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  opacity: 0.65;
  flex: none;
  vertical-align: -2px;
  animation: spinner-rotate 0.7s linear infinite;
}

@keyframes spinner-rotate {
  to { transform: rotate(360deg); }
}

#statusLine .icon {
  flex: none;
  width: 14px;
  height: 14px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  min-height: 30px;
  padding: 4px;
}

/* iOS HIG's ~44px minimum tap target - a live conversation leaves no room
   for mis-taps on a note toggle or a quick-note delete button. */
.phone-mode .icon-button,
.phone-mode .choice-row label,
.phone-mode .checklist-answer-select {
  min-height: 40px;
}

.phone-mode .side-nav,
.phone-mode .top-bar {
  display: none;
}

.phone-mode .app-shell {
  grid-template-columns: minmax(0, 1fr);
}

.phone-mode .app-main,
.phone-mode .workspace,
.phone-mode .view.active {
  height: 100vh;
}

.phone-mode .view.active {
  padding: 0;
}

.phone-mode .checklist-shell {
  grid-template-columns: minmax(0, 1fr);
}

.phone-mode .phone-transfer {
  padding: 12px;
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-nav {
    grid-template-rows: auto auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .brand-lockup,
  .side-footer {
    display: none;
  }

  .primary-nav {
    display: flex;
    overflow-x: auto;
    padding: 8px 10px;
    /* U8: keep the mobile nav usable at 390px — full-bleed scroll with a
       stable scrollbar gutter and visible scroll affordance. */
    max-width: 100vw;
    overscroll-behavior-inline: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
  }

  .primary-nav button {
    flex: 0 0 auto;
    width: max-content;
    min-width: max-content;
    white-space: nowrap;
  }

  .top-bar,
  .top-controls,
  .section-heading,
  .form-grid {
    flex-direction: column;
    align-items: stretch;
  }

  .patient-switcher {
    width: 100%;
  }

  .two-column,
  .timeline-layout,
  .stay-layout,
  .workup-editor-layout,
  .checklist-shell,
  .model-status-grid,
  .model-pack-grid,
  .prompt-layout,
  .quick-deid-grid,
  .three-column {
    grid-template-columns: 1fr;
  }

  .workup-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .app-shell,
  .app-main,
  .top-bar,
  .top-controls,
  .patient-switcher,
  .workspace,
  .view,
  .vault-screen,
  .vault-access,
  .roster-surface {
    min-width: 0;
    max-width: 100%;
  }

  .top-bar,
  .top-controls {
    display: block;
    width: 100%;
  }

  .patient-switcher {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .patient-switcher select {
    width: 100%;
    min-width: 0;
  }

  body {
    font-size: 13px;
  }

  .view {
    padding: 10px;
  }

  #checklistView.active {
    overflow: auto;
  }

  #checklistContent,
  .checklist-shell {
    height: auto;
  }

  .checklist-panel {
    height: auto;
    min-height: 520px;
  }

  .checklist-scroll {
    min-height: 340px;
    max-height: calc(100vh - 260px);
    overflow: auto;
  }

  .workup-form-grid,
  .workup-editor-card,
  .checklist-item {
    grid-template-columns: 1fr;
  }

  .deid-strip,
  .deid-strip-compact {
    align-items: stretch;
    flex-direction: column;
  }

  .deid-strip-compact select {
    width: 100%;
    min-width: 0;
  }

  .workflow-strip {
    grid-template-columns: 1fr;
  }

  .workflow-strip .muted[aria-hidden="true"] {
    display: none;
  }
}

/* Review Data / Draft Note */
.structured-primary-note,
.structured-result-fields {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 94%, var(--accent) 6%);
  padding: 18px;
}

.structured-primary-note {
  display: grid;
  gap: 16px;
}

.structured-note-heading { margin: 0; }
.structured-note-heading h3 { margin-bottom: 3px; }
.structured-note-heading p { max-width: 82ch; margin: 0; }

.structured-note-mode-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 215px));
  width: fit-content;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.structured-note-mode-toggle button {
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--border);
  background: var(--surface-subtle);
  padding: 8px 18px;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.structured-note-mode-toggle button:last-child { border-right: 0; }
.structured-note-mode-toggle button.selected {
  background: color-mix(in srgb, var(--surface) 90%, var(--accent) 10%);
  box-shadow: inset 0 0 0 1px var(--accent);
  color: var(--ink);
}

.structured-note-paste-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 290px);
  align-items: stretch;
  gap: 16px;
  min-width: 0;
}

.structured-note-paste-label {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.structured-note-paste-label textarea {
  min-height: 360px;
  resize: vertical;
  background: var(--surface);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  tab-size: 4;
}

.structured-note-detected {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 360px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}

.structured-note-detected h4 {
  margin: 0;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
}

.structured-note-detected > div {
  display: grid;
  align-content: start;
  min-height: 0;
  overflow: auto;
}

.structured-note-detected-list {
  display: grid;
  margin: 0;
  padding: 0 16px;
  list-style: none;
}

.structured-note-detected-list li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 44px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.structured-note-detected-list li span,
.structured-note-section-status.complete {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 20%, var(--surface));
  color: var(--accent-strong, var(--accent));
  font-size: 12px;
  font-weight: 800;
}

.structured-note-review-mapping { justify-self: start; margin: 12px 10px; }

.structured-note-detected-empty {
  padding: 20px 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.structured-note-detected-empty p { margin: 0 0 5px; color: var(--ink); font-weight: 700; }
.structured-note-paste-meta { margin-top: -9px; color: var(--muted); font-size: 11px; }

.structured-note-actions,
.structured-note-editor-actions,
.structured-note-privacy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.structured-note-actions--save { border-top: 1px solid var(--border); padding-top: 14px; }

.structured-note-privacy {
  justify-content: flex-start;
  border-top: 1px solid var(--border);
  padding-top: 13px;
  color: var(--muted);
  font-size: 12px;
}

.structured-note-privacy > span:first-child {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--muted);
  border-radius: 8px;
  color: var(--accent);
  font-weight: 800;
}

.structured-note-section-layout {
  display: grid;
  grid-template-columns: minmax(240px, 310px) minmax(0, 1fr);
  align-items: stretch;
  gap: 16px;
  min-width: 0;
}

.structured-note-section-nav,
.structured-note-section-editor {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}

.structured-note-section-nav {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 470px;
}

.structured-note-section-nav-heading,
.structured-note-section-editor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--border);
}

.structured-note-section-nav-heading span,
.structured-note-section-editor-heading > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.structured-note-section-list {
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
}

.structured-note-section-list > button {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  padding: 8px 12px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.structured-note-section-list > button:hover { background: var(--surface-subtle); }
.structured-note-section-list > button.selected {
  background: color-mix(in srgb, var(--surface) 84%, var(--accent) 16%);
  box-shadow: inset 3px 0 0 var(--accent);
}

.structured-note-section-list strong,
.structured-note-section-list small { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.structured-note-section-list strong { color: var(--ink); font-size: 12px; }
.structured-note-section-list small { margin-top: 2px; color: var(--muted); font-size: 10px; }

.structured-note-section-status {
  width: 20px;
  height: 20px;
  border: 1px solid var(--border-strong, var(--border));
  border-radius: 50%;
}

.structured-note-section-editor {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 470px;
  padding: 0 15px 14px;
}

.structured-note-section-editor-heading { margin-inline: -15px; }
.structured-note-section-editor-heading h4 { margin: 0 0 3px; color: var(--ink); }
.structured-note-section-editor-heading p { margin: 0; font-size: 11px; }

.structured-note-section-editor textarea {
  min-height: 320px;
  margin: 14px 0;
  resize: none;
  background: var(--surface);
  font-size: 13px;
  line-height: 1.55;
}

@media (max-width: 980px) {
  .structured-note-paste-layout,
  .structured-note-section-layout { grid-template-columns: 1fr; }
  .structured-note-detected { min-height: 0; }
  .structured-note-section-nav { height: 300px; }
}

@media (max-width: 680px) {
  .structured-primary-note { padding: 14px; }
  .structured-note-mode-toggle { grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .structured-note-mode-toggle button { padding-inline: 10px; }
  .structured-note-paste-label textarea { min-height: 280px; }
  .structured-note-actions,
  .structured-note-editor-actions { align-items: stretch; flex-direction: column; }
  .structured-note-actions button,
  .structured-note-editor-actions > button,
  .structured-note-editor-actions .button-row { width: 100%; }
  .structured-note-editor-actions .button-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.structured-note-grid,
.structured-result-fields,
.closing-section-grid,
.two-column-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.structured-note-one-liner {
  grid-column: 1 / -1;
}

.review-workspace {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.review-hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.review-hero h1 {
  margin: 4px 0 8px;
}

/* U6: the packet selector must never truncate its label. */
.review-packet-label {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.review-packet-label select {
  min-width: 200px;
  max-width: min(48vw, 360px);
}

@media (max-width: 640px) {
  /* U6: on narrow screens the packet selector gets the full row so its
     label never truncates. */
  .review-packet-label {
    width: 100%;
  }

  .review-packet-label select {
    flex: 1;
    min-width: 0;
    max-width: none;
  }
}

.review-one-liner {
  max-width: 920px;
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.5;
}

.review-one-liner.is-empty {
  color: var(--muted);
  font-style: italic;
}

.review-columns {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.4fr);
  align-items: start;
  gap: 16px;
  max-width: 100%;
  overflow: hidden;
}

.review-data-panel,
.note-draft-panel {
  min-width: 0;
}

.review-data-panel {
  position: sticky;
  top: 0;
  max-height: calc(100vh - 140px);
  overflow: auto;
  scrollbar-gutter: stable;
}

/* The draft note is one viewport-height editor: the toolbar stays pinned
   while the document scrolls internally, so the whole note fits on one page. */
.review-columns .note-draft-panel {
  position: sticky;
  top: 0;
  max-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.note-draft-panel .note-editor-toolbar {
  flex-shrink: 0;
}

/* Horizontal collapse for the clinical data panel: when collapsed it becomes
   a slim rail, giving the draft note the full horizontal width. */
.review-columns:has(.review-data-panel.is-collapsed) {
  grid-template-columns: 52px minmax(0, 1fr);
}

.review-data-panel.is-collapsed {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 6px;
  position: sticky;
  top: 0;
  max-height: calc(100vh - 140px);
}

.clinical-data-rail-toggle {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clinical-data-rail-toggle:hover {
  background: var(--surface-hover);
}

.clinical-data-rail-label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

/* Smart `$` lab autocomplete dropdown in the draft note editor. */
.lab-autocomplete-dropdown {
  position: absolute;
  z-index: 1000;
  min-width: 280px;
  max-width: 420px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #d0d7de);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  padding: 4px;
}

.lab-autocomplete-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.lab-autocomplete-item:hover,
.lab-autocomplete-item.is-selected {
  background: var(--surface-hover, #f0f4f8);
}

.lab-autocomplete-name {
  font-weight: 600;
  color: var(--ink, #1a1a1a);
  white-space: nowrap;
}

.lab-autocomplete-value {
  color: var(--muted, #666);
  font-size: 12px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.note-draft-panel .note-editor {
  flex: 1;
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
}

.review-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.45fr);
  gap: 12px;
}

.review-filter-summary {
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.review-data-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  margin-bottom: 0.7rem;
}

.review-data-pagination output {
  min-width: 6.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

.note-export-actions {
  margin: 0.8rem 0 0.35rem;
}

.review-data-list,
.note-section-stack,
.plan-problem-list,
.objective-linked-blocks {
  display: grid;
  gap: 12px;
}

.review-data-item,
.note-field-card,
.note-builder-section,
.plan-problem-card,
.differential-card,
.objective-linked-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  padding: 14px;
}

.review-data-item.is-selected,
.note-field-card--primary {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
  box-shadow: inset 3px 0 0 var(--accent);
}

.objective-choice,
.note-field-heading,
.plan-problem-heading,
.objective-linked-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.objective-choice {
  justify-content: flex-start;
  cursor: pointer;
}

.objective-choice input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.objective-choice span {
  display: grid;
  gap: 2px;
}

.objective-choice small,
.review-observation-list small {
  color: var(--muted);
}

.review-vital-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.review-vital-stats div {
  display: grid;
  gap: 3px;
  padding: 10px 14px;
}

/* ---- Single smart note editor ----
   One continuous document on the right: section labels live inside the
   editor flow and every editable region is an inline contenteditable area.
   Compact by design so a full note fits on roughly one page. */
.note-editor-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
}

.note-editor-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.note-editor-title h2 {
  margin: 0;
  font-size: 16px;
}

.note-type-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.note-type-control select {
  font-size: 12px;
  padding: 3px 6px;
}

/* Auto-save indicator (replaces the Save Draft button) */
.autosave-indicator {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: var(--muted, #6b7280);
  padding: 6px 10px;
  user-select: none;
}
.autosave-indicator[data-state="saving"] {
  color: var(--warning, #b45309);
}
.autosave-indicator[data-state="saving"]::before {
  content: "";
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: autosave-spin 0.8s linear infinite;
}
.autosave-indicator[data-state="saved"] {
  color: var(--success, #15803d);
}
@keyframes autosave-spin {
  to { transform: rotate(360deg); }
}

.note-editor-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.note-editor-actions .button--primary,
.note-editor-actions .button--secondary {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 8px;
}

/* Get AI feedback acts on the writing, so it carries the row's only primary
   styling and sits outside the exports group. */
.note-editor-actions .wf-open-btn {
  font-weight: 700;
}

/* Copy and download are outputs, grouped apart from the writing actions
   behind a divider. */
.note-editor-exports {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  border-left: 1px solid var(--border, #d8dee9);
  padding-left: 8px;
  margin-left: 2px;
}

.ed-toolbar-note {
  margin: 0;
  padding: 6px 14px;
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px dashed var(--border);
}

.note-editor {
  padding: 6px 16px 18px;
  font-size: 13px;
  line-height: 1.45;
}

.ed-section {
  padding: 7px 0 5px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}

.ed-section:last-child {
  border-bottom: 0;
}

.ed-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.ed-label-text {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.ed-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  background: color-mix(in srgb, var(--muted) 12%, transparent);
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}

.ed-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.ed-toggle input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  margin: 0;
}

.ed-body {
  min-height: 1.4em;
  padding: 1px 2px;
  margin: 0 -2px;
  border-radius: 4px;
  outline: none;
  overflow-wrap: anywhere;
}

.ed-body:hover {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

.ed-body:focus {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  box-shadow: 0 1px 0 var(--accent);
}

.ed-body:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  opacity: 0.65;
  pointer-events: none;
}

.ed-body--strong {
  font-weight: 600;
}

.ed-sub {
  margin: 3px 0;
}

.ed-sub-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 1px;
}

.ed-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ed-hint,
.ed-empty,
.ed-note {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0;
}

.ed-readonly {
  font-size: 13px;
}

.ed-checklist {
  margin: 2px 0 4px;
  padding-left: 18px;
}

.ed-checklist li {
  margin: 1px 0;
}

.ed-block {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 6px 8px;
  margin: 5px 0;
  background: color-mix(in srgb, var(--panel) 60%, var(--background, #fff));
}

/* Compact inline objective groups (Epic smart-phrase style): one line per
   category — "Vital signs: BP 120/80; HR 72" — with the text editable inline
   and no per-finding card chrome. */
.ed-group {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 4px 0;
  padding: 2px 0;
}

.ed-group-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  flex: 0 0 auto;
}

.ed-group-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 10px;
  color: var(--muted, #666);
  padding: 2px 4px;
  flex: 0 0 auto;
}

.ed-group-toggle:hover {
  color: var(--text);
}

.ed-group .ed-body--inline {
  flex: 1 1 auto;
  min-width: 0;
  padding: 2px 6px;
  border-radius: 4px;
}

.ed-group .ed-body--inline:hover {
  background: color-mix(in srgb, var(--panel) 50%, transparent);
}

.ed-group .ed-body--inline:focus {
  outline: 1px solid var(--accent);
  background: var(--background, #fff);
}

.ed-group .ed-mini-row {
  flex: 0 0 auto;
  opacity: 0.55;
}

.ed-group:hover .ed-mini-row {
  opacity: 1;
}

/* Vital signs: clean scannable list, one vital per line. */
.ed-vitals-list {
  flex: 1 1 auto;
  min-width: 0;
  padding: 2px 6px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ed-vitals-list:hover {
  background: color-mix(in srgb, var(--panel) 50%, transparent);
}

.ed-vitals-list:focus {
  outline: 1px solid var(--accent);
  background: var(--background, #fff);
}

.ed-vital-line {
  font-size: 13px;
  line-height: 1.5;
  padding: 1px 0;
  border-bottom: 1px dotted color-mix(in srgb, var(--text) 15%, transparent);
}

.ed-vital-line:last-child {
  border-bottom: none;
}

.ed-vital-secondary {
  font-size: 11px;
  color: var(--muted, #666);
  margin-left: 8px;
}

.ed-flag-inline {
  font-size: 11px;
  font-weight: 600;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 8px;
  white-space: nowrap;
}

.compact-flag {
  font-size: 10px;
  font-weight: 700;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 6px;
  white-space: nowrap;
}

.compact-row.needs-free-text {
  border-left: 3px solid #f59e0b;
  background: #fffbeb;
}

.review-flag-banner {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 0 12px 0;
  font-size: 13px;
  color: #92400e;
}

.review-flag-banner .muted {
  color: #b45309;
}

.ed-block-bar,
.ed-problem-bar,
.ed-diff-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.ed-block-state {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.ed-mini-row {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.ed-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  line-height: 1.2;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.ed-mini:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.ed-mini--danger:hover {
  border-color: var(--danger, #c0392b);
  color: var(--danger, #c0392b);
}

/* U11: text-insertion chips look like actions (dashed, with an affordance),
   never like clinical assertions. */
.ed-insert-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  line-height: 1.2;
  padding: 2px 8px;
  border: 1px dashed var(--accent, #2f6fed);
  border-radius: 999px;
  background: transparent;
  color: var(--accent, #2f6fed);
  cursor: pointer;
  white-space: nowrap;
}

.ed-insert-chip:hover {
  background: var(--accent-soft, rgba(47, 111, 237, 0.08));
}

.ed-insert-chip .icon {
  width: 12px;
  height: 12px;
}

/* U4: zero-parse guidance banner. */
.review-zero-yield-hint {
  margin: 8px 0 0;
  padding: 8px 12px;
  border: 1px solid var(--warning, #b7791f);
  border-left-width: 4px;
  border-radius: 6px;
  background: var(--warning-bg, #fef6e7);
  font-size: 12px;
  line-height: 1.45;
}

.review-zero-yield-hint code {
  font-size: 11px;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.06);
}

/* U17: warning marker for detected headings with zero parsed rows. */
.detected-warning {
  color: var(--warning, #b7791f);
  font-weight: 700;
  margin-right: 4px;
}

.detected-warning-text {
  color: var(--warning, #b7791f);
  font-style: italic;
}

/* Problem cards stay recognizable to existing tests but render compactly
   inside the single editor instead of as giant stacked cards. */
.plan-problem-card,
.differential-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  margin: 6px 0;
}

/* Clickable citation links in plan fields */
.plan-problem-card .ed-body a[href],
.note-draft-panel .ed-body a[href] {
  color: var(--primary, #0d6efd);
  text-decoration: underline;
  cursor: pointer;
}
.plan-problem-card .ed-body a[href]:hover,
.note-draft-panel .ed-body a[href]:hover {
  text-decoration-thickness: 2px;
}

.plan-problem-card {
  border-left: 3px solid var(--accent);
}

.differential-card {
  background: color-mix(in srgb, var(--muted) 5%, transparent);
}

.plan-problem-list {
  display: grid;
  gap: 2px;
}

.ed-problem-bar strong {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.ed-diff-bar strong {
  font-size: 12px;
  color: var(--muted);
}

.ed-decision1 {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}

.ed-diff-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0 2px;
}

.ed-etiology {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  flex-wrap: wrap;
}

.ed-etiology .segmented-options {
  margin: 0;
}

.ed-med-list {
  margin: 4px 0;
  padding-left: 18px;
}

.ed-med-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 2px 0;
}

@media (max-width: 720px) {
  .ed-two {
    grid-template-columns: 1fr;
  }

  .note-editor {
    padding: 4px 10px 14px;
  }
}

.review-vital-stats div + div {
  border-left: 1px solid var(--border);
}

.review-vital-stats dt {
  color: var(--muted);
  font-size: 11px;
}

.review-vital-stats dd {
  margin: 0;
  font-size: 13px;
}

.review-data-item--medication {
  display: grid;
  gap: 0;
  overflow: hidden;
  padding: 0;
}

.review-medication-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(112px, auto);
  align-items: center;
  gap: 14px;
  padding: 18px;
}

.review-medication-selection {
  display: flex;
}

.review-medication-selection input {
  width: 20px;
  height: 20px;
  margin: 0;
}

.review-medication-identity {
  min-width: 0;
}

.review-medication-title-line {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.review-medication-title-line h3 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.3;
}

.review-medication-type {
  flex: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--muted);
  padding: 2px 7px;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.review-medication-type[data-medication-type="prn"] {
  border-color: color-mix(in srgb, var(--warning) 38%, var(--border));
  background: var(--warning-bg);
  color: var(--warning-ink, #7a4b00);
}

.review-medication-type[data-medication-type="continuous"] {
  border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
  background: color-mix(in srgb, var(--accent) 9%, var(--panel));
  color: var(--accent-ink, var(--accent));
}

.review-medication-regimen,
.review-medication-rate {
  margin: 3px 0 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
}

.review-medication-rate {
  color: var(--muted);
  font-size: 10px;
}

.review-medication-latest {
  display: grid;
  justify-items: end;
  gap: 2px;
  border-left: 2px solid var(--border);
  padding-left: 14px;
  text-align: right;
}

.review-medication-latest span,
.review-medication-prn span {
  color: var(--muted);
  font-size: 10px;
}

.review-medication-latest strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}

.review-medication-details {
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-subtle) 52%, var(--panel));
}

.review-medication-details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  padding: 9px 16px;
  cursor: pointer;
  list-style: none;
}

.review-medication-details > summary::-webkit-details-marker { display: none; }

.review-medication-activity-label,
.review-medication-disclosure {
  display: flex;
  align-items: center;
  gap: 7px;
}

.review-medication-activity-label strong {
  color: var(--ink);
  font-size: 13px;
}

.review-medication-activity-label small,
.review-medication-disclosure {
  color: var(--muted);
  font-size: 10px;
}

.review-medication-list-icon {
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.review-medication-disclosure {
  color: var(--accent);
  font-weight: 700;
}

.review-medication-chevron {
  display: inline-flex;
  transform: rotate(90deg);
  transition: transform 150ms ease;
}

.review-medication-chevron .icon {
  width: 12px;
  height: 12px;
}

.review-medication-details[open] .review-medication-chevron {
  transform: rotate(-90deg);
}

.review-medication-history {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding: 14px 16px 16px;
}

.review-medication-history section {
  display: grid;
  grid-template-columns: minmax(112px, 0.3fr) minmax(0, 1fr);
  align-items: start;
  gap: 14px;
}

.review-medication-history section + section {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.review-medication-history section > header {
  display: grid;
  gap: 2px;
}

.review-medication-history section > header strong {
  color: var(--ink);
  font-size: 12px;
}

.review-medication-history section > header small {
  color: var(--muted);
  font-size: 9px;
}

.review-medication-administration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-medication-administration-grid li {
  display: grid;
  align-content: center;
  gap: 1px;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-subtle);
  padding: 5px 7px;
}

.review-medication-administration-grid strong {
  color: var(--ink);
  font-size: 11px;
  font-weight: 650;
}

.review-medication-administration-grid small {
  color: var(--danger);
  font-size: 8px;
}

.review-medication-administration-grid li[data-administration-status="cancelled"] {
  border-color: color-mix(in srgb, var(--danger) 28%, var(--border));
  background: color-mix(in srgb, var(--danger) 5%, var(--panel));
}

.review-medication-prn {
  border-left: 2px solid var(--warning);
  padding: 2px 0 2px 9px;
}

.review-medication-prn p {
  margin: 2px 0 0;
  font-size: 11px;
  line-height: 1.45;
}

.review-medication-note-preview {
  border-top: 1px solid var(--border);
  padding: 9px 16px 11px;
}

.review-medication-note-preview summary {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.review-data-item--vital {
  overflow: hidden;
  padding: 0;
}

.review-vital-heading {
  padding: 13px 14px;
}

.review-vital-trend {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 12px 14px 9px;
}

.review-vital-trend figcaption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.review-vital-trend figcaption strong {
  color: var(--ink);
  font-size: 12px;
}

.review-vital-trend figcaption span,
.review-trend-boundaries {
  color: var(--muted);
  font-size: 10px;
}

.review-trend-plot {
  position: relative;
  width: 100%;
  height: clamp(132px, 18vw, 172px);
}

.review-trend-plot svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.review-trend-plot line {
  stroke: color-mix(in srgb, var(--border) 78%, transparent);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.review-trend-plot polyline {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
}

.review-trend-point {
  position: absolute;
  left: var(--point-x);
  top: var(--point-y);
  width: 13px;
  min-width: 13px;
  height: 13px;
  min-height: 13px;
  margin: 0;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: var(--panel);
  padding: 0;
  transform: translate(-50%, -50%);
  transition: background 120ms ease, border-color 120ms ease;
  z-index: 1;
}

.review-trend-point:hover,
.review-trend-point:focus {
  border-color: var(--ink);
  background: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  outline-offset: 3px;
  z-index: 3;
}

.review-trend-point[data-clinical-emphasis="high"],
.review-trend-point[data-clinical-emphasis="low"],
.review-trend-point[data-clinical-emphasis="abnormal"],
.review-trend-point[data-clinical-emphasis="critical"] {
  border-color: var(--danger);
}

.review-trend-tooltip {
  position: absolute;
  left: 50%;
  bottom: 18px;
  display: grid;
  width: max-content;
  max-width: 210px;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--ink);
  color: var(--surface);
  opacity: 0;
  padding: 7px 9px;
  pointer-events: none;
  text-align: left;
  transform: translateX(-50%);
  transition: opacity 120ms ease;
}

.review-trend-tooltip strong {
  color: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.review-trend-tooltip span {
  color: inherit;
  font-size: 9px;
  line-height: 1.35;
  opacity: 0.82;
}

.review-trend-point:hover .review-trend-tooltip,
.review-trend-point:focus .review-trend-tooltip {
  opacity: 1;
}

.review-trend-point[data-edge="start"] .review-trend-tooltip {
  left: -4px;
  transform: none;
}

.review-trend-point[data-edge="end"] .review-trend-tooltip {
  right: -4px;
  left: auto;
  transform: none;
}

.review-trend-point[data-tooltip-side="below"] .review-trend-tooltip {
  top: 18px;
  bottom: auto;
}

.review-trend-boundaries {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  line-height: 1.35;
}

.review-trend-boundaries span:last-child {
  text-align: right;
}

.review-trend-empty {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px 8px;
  margin: 0;
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  color: var(--muted);
  font-size: 11px;
}

.review-trend-empty strong {
  color: var(--ink);
}

.review-vital-note-preview {
  border-top: 1px solid var(--border);
  padding: 9px 14px 11px;
}

.review-vital-note-preview summary {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.review-data-item--lab {
  overflow: hidden;
  border-radius: 12px;
  padding: 0;
}

.review-data-item--lab.is-selected {
  box-shadow: inset 4px 0 0 var(--accent);
}

.review-lab-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 13px 15px;
}

.review-lab-panel-heading {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 11px;
}

.review-lab-selection {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.review-lab-selection input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
}

.review-lab-panel-identity {
  min-width: 0;
}

.review-lab-title-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.review-lab-title-line h3,
.review-lab-trend-heading h4 {
  margin: 0;
  color: var(--ink);
}

.review-lab-title-line h3 {
  font-size: 0.96rem;
  line-height: 1.25;
}

.review-lab-panel-identity p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.review-lab-abnormal-count {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--danger, #a33) 9%, var(--panel));
  color: var(--danger, #a33);
  padding: 1px 7px;
  font-size: 0.66rem;
  font-weight: 700;
  white-space: nowrap;
}

.review-lab-panel-navigation {
  display: grid;
  grid-template-columns: auto minmax(4.8rem, auto) auto;
  align-items: center;
  gap: 7px;
}

.review-lab-panel-navigation output {
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
  white-space: nowrap;
}

.review-lab-panel-navigation .icon-button {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
}

.review-lab-results-header {
  display: grid;
  grid-template-columns: 26px minmax(0, 1.35fr) minmax(100px, 0.72fr) minmax(120px, 0.9fr);
  align-items: center;
  gap: 14px;
}

.review-lab-result > summary {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(100px, 0.72fr) minmax(120px, 0.9fr);
  align-items: center;
  gap: 14px;
}

.review-lab-results-header {
  background: color-mix(in srgb, var(--subtle-panel, #f4f3ef) 72%, var(--panel));
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 8px 15px;
  text-transform: uppercase;
}

.review-lab-result-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: stretch;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  padding-left: 15px;
}

.review-lab-result-row:last-child {
  border-bottom: 0;
}

.review-lab-result-row.is-selected {
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
}

.review-lab-result-selection {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.review-lab-result-selection input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.review-lab-result {
  min-width: 0;
}

.review-lab-result > summary {
  min-height: 58px;
  cursor: pointer;
  padding: 8px 15px 8px 0;
  list-style: none;
}

.review-lab-result > summary::-webkit-details-marker {
  display: none;
}

.review-lab-result > summary:hover,
.review-lab-result[open] > summary {
  background: color-mix(in srgb, var(--accent) 5%, var(--panel));
}

.review-lab-result-name {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  align-items: center;
  column-gap: 6px;
  min-width: 0;
}

.review-lab-result-name strong {
  min-width: 0;
  color: var(--ink);
  font-size: 0.84rem;
  line-height: 1.25;
}

.review-lab-result-name small {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 600;
}

.review-lab-result[data-has-trend="true"] .review-lab-result-name small {
  color: var(--accent);
}

.review-lab-chevron {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  transition: transform 140ms ease;
}

.review-lab-result[open] .review-lab-chevron {
  color: var(--accent);
  transform: rotate(90deg);
}

.review-lab-result-value {
  color: var(--ink);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.review-lab-reference {
  color: var(--muted);
  font-size: 0.78rem;
}

.review-lab-flag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-left: 4px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--danger, #a33) 10%, var(--panel));
  color: inherit;
  font-size: 0.66rem;
  font-weight: 800;
  padding: 1px 5px;
}

.review-lab-result[data-clinical-emphasis="high"] .review-lab-result-value,
.review-lab-result[data-clinical-emphasis="low"] .review-lab-result-value,
.review-lab-result[data-clinical-emphasis="abnormal"] .review-lab-result-value {
  color: var(--danger, #a33);
}

.review-lab-trend-drawer {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--accent) 4%, var(--panel));
  padding: 14px 15px 16px 35px;
}

.review-lab-trend-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.review-lab-trend-heading .eyebrow {
  font-size: 0.64rem;
}

.review-lab-trend-heading h4 {
  margin-top: 2px;
  font-size: 0.9rem;
}

.review-lab-trend-heading > span {
  color: var(--muted);
  font-size: 0.7rem;
}

.review-lab-trend-chart {
  width: 100%;
  height: 112px;
  overflow: visible;
}

.review-lab-trend-chart line {
  stroke: color-mix(in srgb, var(--border) 72%, transparent);
  stroke-width: 1;
}

.review-lab-trend-chart polyline {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.review-lab-trend-chart circle {
  fill: var(--panel);
  stroke: var(--accent);
  stroke-width: 3;
}

.review-lab-trend-message {
  margin: 0;
  font-size: 0.78rem;
}

.review-lab-trend-values {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-lab-trend-values li {
  display: grid;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 8px 10px;
}

.review-lab-trend-values strong {
  color: var(--ink);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.review-lab-trend-values span {
  color: var(--muted);
  font-size: 0.68rem;
}

.review-lab-trend-values li[data-clinical-emphasis="high"] strong,
.review-lab-trend-values li[data-clinical-emphasis="low"] strong,
.review-lab-trend-values li[data-clinical-emphasis="abnormal"] strong {
  color: var(--danger, #a33);
}

.review-lab-note-preview {
  border-top: 1px solid var(--border);
  padding: 11px 16px 13px;
}

.review-lab-note-preview summary {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.review-lab-note-preview pre {
  margin: 10px 0 0;
}

@media (max-width: 680px) {
  .review-lab-panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .review-lab-panel-navigation {
    justify-content: center;
    border-top: 1px solid var(--border);
    padding-top: 10px;
  }

  .review-lab-results-header {
    display: none;
  }

  .review-lab-result > summary {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px 12px;
    min-height: 64px;
    padding: 9px 12px;
  }

  .review-lab-reference {
    grid-column: 1 / -1;
    margin-left: 20px;
    font-size: 0.7rem;
  }

  .review-lab-reference::before {
    content: "Reference: ";
    font-weight: 650;
  }

  .review-lab-trend-drawer {
    padding: 13px 12px 15px;
  }
}

.review-result-text {
  white-space: pre-wrap;
}

.note-draft-panel,
.note-builder-section {
  display: grid;
  gap: 14px;
}

.note-draft-panel {
  gap: 18px;
}

.note-draft-panel > .note-builder-section {
  margin: 0;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  padding: 18px 0 0;
}

.note-draft-header {
  align-items: start;
}

.note-title-row,
.note-type-control,
.note-label-row,
.auto-checklist-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.note-title-row {
  flex-wrap: wrap;
}

.note-title-row h2 {
  margin: 0;
}

.note-type-control {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.note-type-control select {
  width: auto;
  min-width: 138px;
  padding-block: 7px;
}

.note-section-stack {
  display: grid;
  gap: 10px;
}

.note-field-card {
  border: 0;
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 11px 12px;
}

.note-field-card--primary {
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: none;
}

.auto-checklist-findings {
  display: grid;
  gap: 8px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 5%, var(--surface-muted));
  padding: 11px 12px;
}

.auto-checklist-heading {
  justify-content: space-between;
}

.auto-checklist-heading span {
  color: var(--muted);
  font-size: 12px;
}

.auto-checklist-findings ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 20px;
}

.auto-checklist-findings li {
  line-height: 1.4;
}

.closing-field {
  display: grid;
  gap: 6px;
}

.note-label-row {
  justify-content: space-between;
}

.note-field-heading h3,
.note-builder-section h3 {
  margin: 0;
}

.note-help-button {
  position: relative;
  display: inline-grid;
  width: 22px;
  height: 22px;
  min-height: 22px;
  flex: 0 0 22px;
  padding: 0;
  border-color: var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}

/* Pull-from-primary-note button: sits next to the help (?) icon. */
.note-pull-button {
  position: relative;
  display: inline-grid;
  width: 22px;
  height: 22px;
  min-height: 22px;
  flex: 0 0 22px;
  padding: 0;
  margin-left: 4px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.note-pull-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.note-pull-button::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  min-width: 140px;
  max-width: 220px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  text-align: center;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 50;
}

.note-pull-button:hover::after,
.note-pull-button:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Compact exam template picker in the Physical Exam section. */
.exam-template-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}

.exam-template-picker label {
  font-weight: 600;
}

.exam-template-picker select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}

.note-help-button::after {
  position: absolute;
  z-index: 40;
  left: -4px;
  bottom: calc(100% + 8px);
  width: var(--help-tip-width, max-content);
  max-width: var(--help-tip-width, min(300px, calc(100vw - 32px)));
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--ink);
  box-shadow: 0 8px 24px rgba(15, 37, 56, 0.18);
  color: var(--surface);
  content: attr(data-tooltip);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  opacity: 0;
  padding: 8px 10px;
  pointer-events: none;
  text-align: left;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
  visibility: hidden;
  white-space: normal;
}

.note-help-button:hover::after,
.note-help-button:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

/* Flipped by positionHelpTooltip() when the popup would overflow the note
   editor: grow leftward instead of rightward, or drop below the button. */
.note-help-button.note-help-flip::after {
  left: auto;
  right: -4px;
}

.note-help-button.note-help-below::after {
  bottom: auto;
  top: calc(100% + 8px);
  transform: translateY(-4px);
}

.note-help-button.note-help-below:hover::after,
.note-help-button.note-help-below:focus-visible::after {
  transform: translateY(0);
}

.etiology-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  margin: 0;
  border: 0;
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 8px 10px;
}

.etiology-control legend {
  display: flex;
  align-items: center;
  gap: 6px;
  float: left;
  width: auto;
  margin: 0;
  padding: 0;
  font-weight: 700;
}

.segmented-options {
  display: inline-flex;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
  padding: 3px;
}

.segmented-options label {
  position: relative;
  display: block;
  cursor: pointer;
}

.segmented-options input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.segmented-options span {
  display: block;
  border-radius: 5px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.segmented-options input:checked + span {
  background: var(--accent);
  color: white;
}

.segmented-options input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.plan-problem-card,
.differential-builder {
  display: grid;
  gap: 12px;
}

.differential-card {
  display: grid;
  gap: 10px;
  background: color-mix(in srgb, var(--panel) 94%, var(--accent) 6%);
}

.objective-linked-block[data-objective-state="stale"] {
  border-color: var(--warning, #9a6700);
  background: color-mix(in srgb, #f0b429 8%, var(--panel));
}

.objective-diff {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.objective-diff pre,
.review-data-item pre,
.final-note-preview pre {
  margin: 8px 0 0;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Compact clinical-data sheet (2026-09-24): dense one-page review layout.
   Vitals strip, pending/report rows, and panel-family lab grids replace the
   old giant per-vital/per-panel cards. No pagination. */
.compact-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 10px 12px;
}

.compact-section + .compact-section {
  margin-top: 10px;
}

.compact-section-heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-bottom: 8px;
}

.compact-section-heading h3 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

.compact-section-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.compact-section-meta strong {
  color: var(--danger);
  font-weight: 700;
}

.compact-section-note {
  margin: -4px 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.compact-panel-selects {
  margin-left: auto;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.compact-panel-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--teal-strong, #0f766e);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--surface);
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.compact-panel-select:hover {
  border-color: var(--accent);
}

.compact-panel-select input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.compact-panel-select .compact-panel-select-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 4px;
  border: 1.5px solid var(--muted);
  background: transparent;
  flex: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.compact-panel-select .compact-panel-select-box svg {
  width: 9px;
  height: 9px;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.compact-panel-select:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong, #0f766e);
}

.compact-panel-select:has(input:checked) .compact-panel-select-box {
  background: var(--accent);
  border-color: var(--accent);
}

.compact-panel-select:has(input:checked) .compact-panel-select-box svg {
  opacity: 1;
}

.compact-panel-select:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Narrative fallback card: a saved source the parsers could not structure.
   Dashed border distinguishes "kept as written" from parsed data. */
.narrative-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1.5px dashed var(--border-strong, #cbd5e1);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 10px 12px;
  margin-top: 8px;
}

.narrative-card.is-selected {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.narrative-card-body {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 4px;
}

.narrative-card-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.narrative-card-note {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted-strong);
}

.narrative-card-details summary {
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--teal-strong, #0f766e);
}

.narrative-card-details pre {
  margin: 6px 0 0;
  padding: 8px 10px;
  background: #f7fafb;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #284151;
  max-height: 220px;
  overflow: auto;
}

/* Vitals strip: one horizontal row of compact selectable chips. */
.vital-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.vital-chip {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 12px;
  border-right: 1px solid var(--border);
  cursor: pointer;
  min-width: 0;
}

.vital-chip:last-child {
  border-right: 0;
}

.vital-chip input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.vital-chip.is-selected {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.vital-chip.is-unit-unmarked {
  background: #fffbeb;
  box-shadow: inset 0 0 0 1.5px #d97706;
  cursor: default;
}

.unit-unmarked-flag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: middle;
}

.vital-chip-confirm-hint {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #92400e;
}

/* Temperature unit confirmation banner: an unmarked temperature never enters
   the note until the student explicitly confirms °F or °C. */
.unit-confirm-banner {
  border: 1px solid #fcd34d;
  background: #fffbeb;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 8px 0;
  display: grid;
  gap: 8px;
  font-size: 0.82rem;
  color: #78350f;
}

.unit-confirm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: #ffffff;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 7px 10px;
}

.unit-confirm-row .button-row {
  display: inline-flex;
  gap: 6px;
}

.unit-confirm-row .button--primary {
  min-height: 30px;
  padding: 4px 14px;
  font-size: 0.85rem;
}

.vital-chip:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.vital-chip-name {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted-strong);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.vital-chip-value {
  font-size: 1.02rem;
  line-height: 1.25;
  white-space: nowrap;
}

.vital-chip-value strong {
  font-weight: 750;
}

.vital-chip[data-clinical-emphasis="high"] .vital-chip-value strong,
.vital-chip[data-clinical-emphasis="low"] .vital-chip-value strong,
.vital-chip[data-clinical-emphasis="abnormal"] .vital-chip-value strong,
.vital-chip[data-clinical-emphasis="critical"] .vital-chip-value strong {
  color: var(--danger);
}

.vital-chip-when,
.vital-chip-trend,
.vital-chip-stats {
  color: var(--faint);
  font-size: 0.72rem;
  white-space: nowrap;
}

.vital-chip-trend {
  color: var(--muted-strong);
}

/* Small abnormal flag pills used across the compact sheet. */
.flag-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.05em;
  height: 1.05em;
  padding: 0 0.25em;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
}

.flag-high,
.flag-abnormal {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.flag-low {
  background: var(--surface-blue);
  color: var(--primary);
  border: 1px solid var(--primary);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.status-pending {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning);
}

.status-report {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
}

/* Dense one-line rows for pending, reports, medications, diagnostics. */
.compact-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.compact-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.compact-row:nth-child(odd) {
  background: var(--surface-subtle);
}

.compact-row.is-selected {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.compact-row-check {
  display: inline-flex;
  margin: 0;
}

.compact-row-check input {
  margin: 0;
}

.compact-row-name {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 8px;
  min-width: 0;
  font-size: 0.86rem;
}

.compact-row-name strong {
  font-weight: 650;
}

.compact-row-name small {
  color: var(--muted);
  font-size: 0.75rem;
}

.compact-row-excerpt {
  flex-basis: 100%;
  color: var(--faint);
  font-size: 0.75rem;
}

.compact-row-meta {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.compact-row .status-pill {
  margin-left: auto;
}

.compact-row .status-pill + .status-pill {
  margin-left: 0;
}

.compact-row-name + .compact-row-meta {
  margin-left: auto;
}

/* Laboratory family grids: dense multi-column analyte cells. */
.lab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 2px 10px;
}

.lab-cell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "check name"
    "check value"
    "check sub";
  column-gap: 7px;
  align-items: baseline;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.lab-cell:nth-child(odd) {
  background: var(--surface-subtle);
}

.lab-cell.is-selected {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.lab-cell-check {
  grid-area: check;
  display: inline-flex;
  margin: 0;
}

.lab-cell-check input {
  margin: 0;
}

.lab-cell-name {
  grid-area: name;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--muted-strong);
  min-width: 0;
}

.lab-cell-value {
  grid-area: value;
  font-size: 0.92rem;
  white-space: nowrap;
}

.lab-cell-value strong {
  font-weight: 750;
}

.lab-cell[data-clinical-emphasis="high"] .lab-cell-value strong,
.lab-cell[data-clinical-emphasis="low"] .lab-cell-value strong,
.lab-cell[data-clinical-emphasis="abnormal"] .lab-cell-value strong,
.lab-cell[data-clinical-emphasis="critical"] .lab-cell-value strong {
  color: var(--danger);
}

.lab-cell-flag {
  color: var(--muted);
  font-size: 0.72rem;
}

.lab-cell-sub {
  grid-area: sub;
  color: var(--faint);
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Patient-entered lab baselines: one toggle per row, inline editor. */
.lab-cell-baseline-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
.lab-cell-baseline {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lab-baseline-toggle {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent, #2563eb);
  font-size: 0.72rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}
.lab-baseline-toggle:hover {
  color: var(--accent-strong, #1d4ed8);
}
/* Baseline-priority labs (creatinine, troponin, hemoglobin, ...) with no
   baseline recorded: the "!" badge and the warning button prompt the
   student to enter a baseline, since interpretation depends on change from
   the patient's own steady state. */
.lab-baseline-needed {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.05em;
  height: 1.05em;
  margin-left: 4px;
  padding: 0 2px;
  border-radius: 999px;
  background: #b45309;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: 1px;
}
.lab-baseline-toggle.lab-baseline-warning {
  color: #b45309;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid #b45309;
  border-radius: 6px;
  padding: 2px 7px;
  background: #fffbeb;
}
.lab-baseline-toggle.lab-baseline-warning:hover {
  color: #92400e;
  background: #fef3c7;
}
.lab-baseline-warning-icon {
  margin-right: 3px;
}
.lab-row-needs-baseline.is-selected {
  background: #fffbeb;
}
.lab-baseline-editor {
  grid-column: 1 / -1;
  border-top: 1px dashed var(--border);
  margin-top: 6px;
  padding-top: 8px;
}
.lab-baseline-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 8px;
}
.lab-baseline-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.72rem;
  color: var(--muted);
}
.lab-baseline-field input {
  font-size: 0.8rem;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--background, #fff);
  color: inherit;
  width: 100%;
}
.lab-baseline-actions {
  margin-top: 8px;
  gap: 6px;
}
.lab-baseline-actions .button--primary {
  padding: 4px 10px;
  font-size: 0.78rem;
}
.lab-baseline-actions button:not(.button--primary) {
  padding: 4px 10px;
  font-size: 0.78rem;
}

@media (max-width: 680px) {
  .lab-grid {
    grid-template-columns: 1fr 1fr;
  }

  .vital-strip {
    flex-direction: column;
  }

  .vital-chip {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .vital-chip:last-child {
    border-bottom: 0;
  }
}
.final-note-preview {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

/* Rich final-note preview: real headings, tables, and lists instead of a
   plain-text <pre> dump. */
.rich-note-preview {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 14px 16px;
  max-height: 70vh;
  overflow: auto;
}
.rich-note .note-section + .note-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.rich-note h2 {
  font-size: 1.02rem;
  margin: 0 0 8px;
  letter-spacing: 0.01em;
}
.rich-note h3 {
  font-size: 0.92rem;
  margin: 12px 0 6px;
  color: var(--text-strong, inherit);
}
.rich-note p {
  margin: 6px 0;
  line-height: 1.45;
}
.rich-note ul {
  margin: 6px 0;
  padding-left: 1.25rem;
}
.rich-note li {
  margin: 3px 0;
  line-height: 1.4;
}
.rich-note table {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0 10px;
  font-size: 0.92rem;
}
.rich-note th,
.rich-note td {
  border: 1px solid var(--border);
  padding: 5px 8px;
  text-align: left;
  vertical-align: top;
}
.rich-note thead th {
  background: var(--surface-strong, rgba(0, 0, 0, 0.04));
}
.rich-note .note-vitals th,
.rich-note .note-labs th {
  width: 34%;
}

@media (max-width: 1100px) {
  .review-columns {
    grid-template-columns: 1fr;
  }

  .review-data-panel {
    position: static;
    max-height: none;
  }

  .review-columns .note-draft-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .note-draft-panel .note-editor {
    overflow: visible;
  }
}

@media (max-width: 680px) {
  .review-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .review-filter-row,
  .structured-note-grid,
  .structured-result-fields,
  .closing-section-grid,
  .two-column-form,
  .objective-diff,
  .review-data-item,
  .note-field-card,
  .note-builder-section,
  .plan-problem-card,
  .differential-card,
  .objective-linked-block {
    padding: 12px;
  }

  .review-data-item--medication { padding: 0; }
  .review-data-item--vital { padding: 0; }

  .review-vital-stats div {
    padding: 9px 10px;
  }

  .review-vital-trend figcaption {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .review-medication-header {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    padding: 13px;
  }

  .review-medication-title-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .review-medication-latest {
    grid-column: 2;
    justify-items: start;
    border-left: 0;
    padding-left: 0;
    text-align: left;
  }

  .review-medication-details > summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    padding-inline: 13px;
  }

  .review-medication-history {
    padding-inline: 13px;
  }

  .review-medication-history section {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .plan-problem-heading,
  .objective-linked-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .note-draft-header {
    align-items: stretch;
    flex-direction: column;
  }

  .etiology-control {
    align-items: stretch;
    flex-direction: column;
  }

  .etiology-control legend {
    float: none;
  }
}

.brand-lockup span,
.side-footer {
  font-size: 11px;
}

.stay-layout,
.workup-editor-layout,
.prompt-layout,
.quick-deid-shell {
  height: 100%;
  min-height: 0;
}

.stay-layout {
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  overflow: hidden;
}

.stay-layout > aside.panel,
.stay-layout .stay-content {
  min-height: 0;
  border: 0;
  border-radius: 0;
}

.stay-layout > aside.panel {
  overflow: auto;
  padding: 12px;
  border-right: 1px solid var(--border);
  background: #fcfdff;
}

.stay-content {
  overflow: auto;
  padding: 10px;
}

.stay-content .panel {
  box-shadow: none;
}

.timeline-rail {
  max-height: none;
  padding-right: 0;
}

.day-row {
  min-height: 46px;
  padding: 7px;
}

.day-row > span:first-child {
  display: grid;
  gap: 1px;
}

.day-row .muted {
  font-size: 10px;
}

.workup-editor-layout {
  grid-template-columns: minmax(180px, 214px) minmax(0, 1fr);
  gap: 8px;
  overflow: hidden;
}

.workup-editor-layout > .panel {
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.workup-list {
  max-height: calc(100% - 104px);
  overflow: auto;
}

.workup-editor-layout > section.panel {
  display: block;
}

.workup-editor-layout > section.panel > .button-row:last-of-type {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 10px -2px 0;
  padding: 8px 2px 0;
  background: var(--surface);
}

.workflow-strip {
  margin: 8px 0;
  padding: 7px 9px;
}

.workflow-step strong {
  font-size: 12px;
}

.workflow-step span {
  font-size: 11px;
}

.workup-form-grid {
  grid-template-columns: minmax(180px, 1fr) minmax(150px, 0.85fr) minmax(220px, 1.25fr);
  gap: 8px;
}

.workup-columns {
  align-items: start;
  gap: 10px;
  margin-top: 10px;
}

.workup-column {
  min-width: 0;
}

.workup-column .list-stack {
  gap: 5px;
  min-height: 36px;
}

.workup-column .list-stack.is-drop-target {
  border-radius: 4px;
  outline: 1px dashed #75bfc4;
  outline-offset: 3px;
}

.workup-editor-card {
  grid-template-columns: 28px 18px minmax(120px, 1fr) minmax(96px, 0.66fr) 64px auto;
  gap: 5px;
  min-width: 0;
  padding: 5px;
}

.workup-editor-card.is-dragging {
  opacity: 0.45;
}

.workup-drag-handle {
  grid-column: 1;
  grid-row: 1;
  cursor: grab;
  color: var(--faint);
}

.workup-drag-handle:active {
  cursor: grabbing;
}

.workup-row-number {
  grid-column: 2;
  grid-row: 1;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.workup-editor-card [data-field="item-text"] {
  grid-column: 3;
  grid-row: 1;
}

.workup-editor-card [data-field="item-choices"] {
  grid-column: 4;
  grid-row: 1;
}

.workup-editor-card [data-field="item-select"] {
  grid-column: 5;
  grid-row: 1;
}

.workup-editor-card .button-row {
  grid-column: 6;
  grid-row: 1;
  gap: 3px;
}

.workup-editor-card .icon-button {
  min-width: 24px;
  min-height: 26px;
  padding: 4px;
}

.workup-item-details {
  grid-column: 3 / 7;
  grid-row: 2;
  color: var(--muted);
  font-size: 11px;
}

.workup-item-details summary {
  cursor: pointer;
  width: max-content;
}

.workup-item-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
}

.workup-item-details input {
  min-height: 28px;
}

.checklist-shell {
  gap: 10px;
}

.checklist-panel,
.phone-transfer {
  border-radius: 5px;
}

.checklist-section-header {
  padding: 6px 0;
}

.checklist-system {
  gap: 0;
}

.checklist-system-header {
  min-height: 34px;
  padding: 5px 8px;
  background: #fbfcfe;
}

.checklist-item {
  grid-template-columns: minmax(180px, 1.3fr) minmax(190px, 1.35fr) minmax(110px, 0.75fr) 16px;
  gap: 8px;
  min-height: 46px;
  padding: 7px 9px;
}

.checklist-item > div:first-child strong {
  font-size: 12px;
}

.checklist-item > div:first-child .muted {
  font-size: 10px;
}

.choice-row {
  gap: 4px;
}

.choice-row label {
  min-height: 24px;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 11px;
}

.item-note-input {
  min-height: 28px;
  padding: 4px 6px;
  font-size: 11px;
}


.quick-deid-grid {
  grid-template-columns: minmax(220px, 1.1fr) 250px minmax(250px, 0.92fr) minmax(220px, 1.05fr);
  gap: 0;
}

.quick-deid-grid > * {
  min-width: 0;
  padding: 0 14px;
  border-right: 1px solid var(--border);
}

.quick-deid-grid > *:first-child {
  padding-left: 0;
}

.quick-deid-grid > *:last-child {
  padding-right: 0;
  border-right: 0;
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
  }

  .workspace,
  .view:not(#checklistView) {
    overflow: visible;
  }

  .top-bar {
    height: auto;
    min-height: 50px;
  }

  .view.active,
  .stay-layout,
  .workup-editor-layout,
  .prompt-layout,
  .quick-deid-shell {
    height: auto;
  }

  .stay-layout,
  .workup-editor-layout,
  .prompt-layout,
  .quick-deid-grid {
    overflow: visible;
  }

  .quick-deid-grid {
    grid-template-columns: 1fr;
  }

  .quick-deid-grid > * {
    padding: 0;
    border-right: 0;
  }
}

@media (max-width: 680px) {
  .top-bar {
    padding: 7px 10px;
  }

  .patient-switcher {
    width: 100%;
  }

  .stay-layout {
    border: 0;
  }

  .stay-layout > aside.panel {
    border: 1px solid var(--border);
  }

  .workup-editor-card {
    grid-template-columns: 26px 18px minmax(0, 1fr) 62px;
  }

  .workup-editor-card [data-field="item-text"] {
    grid-column: 3 / 5;
  }

  .workup-editor-card [data-field="item-choices"] {
    grid-column: 3 / 5;
    grid-row: 2;
  }

  .workup-editor-card [data-field="item-select"] {
    grid-column: 3;
    grid-row: 3;
  }

  .workup-editor-card .button-row {
    grid-column: 4;
    grid-row: 3;
  }

  .workup-item-details {
    grid-column: 3 / 5;
    grid-row: 4;
  }

  .workup-item-detail-grid {
    grid-template-columns: 1fr;
  }
}

/* Prompt screen: the reference uses one editable surface beside one generated surface. */
.prompt-layout {
  grid-template-columns: minmax(0, 1.12fr) minmax(320px, 0.88fr);
  grid-template-rows: minmax(0, 1fr);
}

.prompt-layout .prompt-template-panel,
.prompt-layout .prompt-output-panel {
  grid-column: auto;
  grid-row: auto;
  min-height: 0;
  overflow: hidden;
}

.prompt-layout .prompt-template-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 9px;
}

.prompt-panel-header,
.prompt-template-footer {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.prompt-panel-header {
  flex-wrap: nowrap;
}

.prompt-panel-header > div:first-child {
  flex: 1 1 200px;
  min-width: 0;
}

.prompt-panel-header > select,
.prompt-panel-header > .prompt-day-select {
  flex: 1 1 200px;
  max-width: 260px;
  min-width: 0;
}

.prompt-day-select {
  white-space: nowrap;
}

.prompt-template-wrap {
  min-height: 280px;
}

.prompt-template-panel .prompt-preview {
  height: 100%;
  min-height: 280px;
  max-height: none;
}

.prompt-template-footer {
  align-items: center;
}

.prompt-template-footer .notice {
  flex: 1 1 260px;
}

.prompt-output-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 9px;
}

.prompt-output-panel .prompt-output-highlighted {
  height: 100%;
  min-height: 280px;
  max-height: none;
}

.prompt-output-panel label {
  gap: 5px;
}

.prompt-output-panel #openEvidenceOutput {
  min-height: 96px;
}

@media (max-width: 1040px) {
  .prompt-layout .prompt-template-panel,
  .prompt-layout .prompt-output-panel {
    overflow: visible;
  }

  .prompt-template-panel .prompt-preview,
  .prompt-output-panel .prompt-output-highlighted {
    height: 360px;
  }
}

@media (max-width: 680px) {
  .prompt-panel-header,
  .prompt-template-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .prompt-panel-header > select,
  .prompt-panel-header > .prompt-day-select {
    max-width: none;
  }
}

/* Workup reference screen: one editor surface with the catalog in a compact menu. */
.workup-editor-surface {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto auto;
  gap: 9px;
  height: 100%;
  min-height: 0;
  overflow: auto;
}

.workup-topline {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 30px minmax(210px, 0.52fr) 30px;
  align-items: center;
  gap: 8px;
}

.workup-title-input {
  border-color: transparent;
  background: transparent;
  color: var(--text);
  font-size: 17px;
  font-weight: 650;
  padding: 2px 0;
}

.workup-title-input:hover,
.workup-title-input:focus {
  border-color: var(--border);
  background: #ffffff;
  padding-inline: 6px;
}

.workup-alias-control {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
}

.workup-catalog-menu {
  position: relative;
}

.workup-catalog-menu summary {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  list-style: none;
}

.workup-catalog-menu summary::-webkit-details-marker {
  display: none;
}

.workup-catalog-popover {
  position: absolute;
  z-index: 8;
  top: calc(100% + 6px);
  right: 0;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 230px));
  max-height: min(520px, calc(100dvh - 100px));
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(20, 33, 58, 0.14);
  padding: 10px;
}

.workup-catalog-popover .workup-list {
  max-height: 300px;
  overflow: auto;
}

.workup-catalog-popover .check-row {
  min-height: 42px;
}

.workup-subtitle {
  color: var(--muted);
  font-size: 11px;
}

.workup-editor-surface .workup-columns {
  min-height: 0;
}

.workup-footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.workup-footer-actions button:last-child {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.text-button {
  width: max-content;
  min-height: 24px;
  border-color: transparent;
  color: var(--muted);
  padding: 2px 0;
}

.text-button:hover {
  border-color: transparent;
  color: var(--danger);
  text-decoration: underline;
}

/* Override legacy three-panel selector specificity. */
.prompt-layout .prompt-panel.prompt-template-panel {
  display: grid;
  grid-column: 1;
  grid-row: 1;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

/* The presentation editor adds a dedicated panel above the template. Give it
   a named grid row so the template never falls into an implicit row. The
   combined input and template can be taller than the fixed desktop route, so
   this panel also owns vertical scrolling instead of clipping its lower rows. */
.prompt-layout .prompt-panel.prompt-template-panel--presentation-editor {
  grid-template-rows: auto auto auto minmax(280px, 1fr) auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.prompt-layout .prompt-panel.prompt-output-panel {
  display: grid;
  grid-column: 2;
  grid-row: 1;
}

@media (max-width: 1040px) {
  .workup-editor-surface {
    height: auto;
    overflow: visible;
  }

  .prompt-layout .prompt-panel.prompt-template-panel,
  .prompt-layout .prompt-panel.prompt-output-panel {
    grid-column: auto;
    grid-row: auto;
  }
}

@media (max-width: 680px) {
  .workup-topline {
    grid-template-columns: minmax(0, 1fr) 30px 30px;
  }

  .workup-alias-control {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .workup-catalog-popover {
    width: min(340px, calc(100vw - 36px));
  }
}

/* Hospital Stay reference screen keeps the selected day prominent. */
.new-day-control {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.new-day-control summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 30px;
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  color: var(--text);
  font-size: 12px;
  list-style: none;
}

.new-day-control summary::-webkit-details-marker {
  display: none;
}

.new-day-control .form-grid {
  align-items: stretch;
}

.admission-packet {
  padding: 0;
}

.admission-packet-details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  cursor: pointer;
  list-style: none;
  padding: 10px 12px;
}

.admission-packet-details > summary::-webkit-details-marker {
  display: none;
}

.admission-packet-details > summary > span:first-child {
  display: grid;
  gap: 1px;
}

.admission-packet-details > summary > span:first-child .muted {
  font-size: 11px;
}

.admission-packet-details[open] > summary {
  border-bottom: 1px solid var(--border);
}

.admission-packet-body {
  display: grid;
  gap: 10px;
  padding: 12px;
}

/* Quick De-ID reference screen is a compact four-step utility surface. */
.quick-deid-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 10px;
  height: 100%;
  min-height: 0;
  overflow: auto;
}

.quick-deid-panel > * {
  min-width: 0;
}

.quick-deid-heading {
  margin-bottom: 0;
}

.quick-deid-grid {
  align-items: start;
}

.quick-deid-grid label {
  color: var(--text);
  font-weight: 650;
}

.quick-deid-grid label textarea,
.quick-deid-grid label select {
  margin-top: 6px;
  font-weight: 400;
}

.quick-model-status {
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-muted);
  color: var(--muted);
  padding: 8px;
  font-size: 11px;
}

.quick-deid-grid .warning-box,
.quick-deid-grid .notice {
  min-height: 0;
}

/* Checklist tables follow the compact question/answer/notes/status reference. */
.checklist-column-head {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) minmax(190px, 1.35fr) minmax(110px, 0.75fr) 16px;
  gap: 8px;
  padding: 0 9px 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.checklist-answer-select {
  min-height: 26px;
  border-radius: 4px;
  padding: 3px 22px 3px 6px;
  font-size: 11px;
}

.checklist-item:has(.checklist-answer-select) .choice-row {
  display: block;
}

.checklist-item:has(.checklist-answer-select) .choice-row select {
  width: 100%;
}

.phone-mode .checklist-column-head {
  display: none;
}

.phone-mode .checklist-item {
  grid-template-columns: minmax(0, 1.15fr) minmax(106px, 0.85fr) 30px 16px;
  gap: 7px;
  padding: 8px 10px;
}

.phone-mode .checklist-item .note-toggle {
  display: inline-grid;
}

.phone-mode .checklist-item .item-note-input {
  display: none;
}

.phone-mode .checklist-item.note-open .item-note-input {
  display: block;
  grid-column: 1 / -1;
}

.phone-mode .checklist-item:has(.checklist-answer-select) .choice-row select {
  border-color: transparent;
  background: transparent;
  padding-left: 0;
}

@media (max-width: 680px) {
  .checklist-column-head {
    display: none;
  }

  .checklist-item {
    grid-template-columns: minmax(0, 1.15fr) minmax(106px, 0.85fr) 30px 16px;
    gap: 7px;
  }

  .checklist-item .note-toggle {
    display: inline-grid;
  }

  .checklist-item .item-note-input {
    display: none;
  }

  .checklist-item.note-open .item-note-input {
    display: block;
    grid-column: 1 / -1;
  }
}

@media (max-width: 1040px) {
  .quick-deid-panel {
    height: auto;
    overflow: visible;
  }
}

/* Vault / roster */
.vault-screen {
  display: grid;
  grid-template-columns: minmax(300px, 0.58fr) minmax(0, 1.42fr);
  gap: 16px;
  align-items: start;
  max-width: 1320px;
}

.vault-access,
.roster-surface,
.vault-pitch {
  padding: 18px;
}

.vault-access { display: grid; gap: 18px; }

.vault-pitch { display: grid; gap: 14px; }

.vault-pitch-title { margin: 0; font-size: 22px; color: var(--ink); }

.vault-pitch-lede {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  max-width: 62ch;
}

.vault-edu-disclaimer {
  align-items: flex-start;
  background: var(--surface-tint);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text);
  display: flex;
  font-size: 13px;
  gap: 10px;
  line-height: 1.5;
  padding: 12px 14px;
}

.vault-edu-disclaimer .icon {
  color: var(--accent);
  flex: 0 0 auto;
  height: 18px;
  margin-top: 1px;
  width: 18px;
}

.vault-edu-disclaimer strong { color: var(--ink); }

.vault-demo-cta { display: grid; gap: 6px; }

.vault-demo-cta > .muted { color: var(--muted-strong); font-size: 12px; }

.vault-trust-footer {
  align-items: center;
  color: var(--muted-strong);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 6px 16px;
  padding: 2px 4px 0;
}

.vault-trust-links { display: flex; flex-wrap: wrap; gap: 6px 16px; }

.vault-trust-links a {
  align-items: center;
  color: var(--accent);
  display: inline-flex;
  font-weight: 600;
  gap: 5px;
  text-decoration: none;
}

.vault-trust-links a:hover,
.vault-trust-links a:focus-visible { text-decoration: underline; }

.vault-trust-links .icon { height: 13px; width: 13px; }

.vault-access-heading { margin: 0; align-items: center; }

.vault-onboarding-kicker {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.vault-onboarding-kicker span {
  color: var(--muted);
  padding: 0 3px;
}

.vault-onboarding-steps {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.vault-onboarding-steps li {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 10px;
  padding: 3px 0;
}

.vault-onboarding-steps li.is-current { color: var(--ink); }

.vault-step-number {
  align-items: center;
  background: var(--surface-tint);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  display: inline-flex;
  flex: 0 0 25px;
  font-size: 12px;
  font-weight: 800;
  height: 25px;
  justify-content: center;
  width: 25px;
}

.is-current .vault-step-number {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.vault-onboarding-steps li > span:last-child {
  display: grid;
  gap: 1px;
}

.vault-onboarding-steps small {
  color: var(--muted);
  font-size: 12px;
}

.vault-primary-action {
  box-shadow: 0 5px 14px rgb(16 105 109 / 16%);
  font-weight: 800;
}

.vault-access-heading .transfer-actions {
  justify-content: flex-end;
}

@media (min-width: 681px) {
  .vault-access-heading .transfer-actions {
    flex-direction: column;
    align-items: stretch;
    min-width: 158px;
  }
}

@media (max-width: 680px) {
  .vault-access-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .vault-access-heading .button-row {
    justify-content: flex-start;
  }

  .vault-access-heading .transfer-actions {
    justify-content: flex-start;
  }
}

.vault-access-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: end;
}

.vault-access-controls.vault-setup-controls {
  grid-template-columns: minmax(0, 640px);
  gap: 14px;
  align-items: start;
}

.vault-setup-controls .button--primary {
  justify-self: start;
  min-width: 210px;
}

.vault-passphrase-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.vault-setup-controls .vault-passphrase-field { gap: 10px; }

.vault-passphrase-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.vault-passphrase-visibility {
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  display: inline-flex;
  height: 44px;
  justify-content: center;
  padding: 0;
  width: 44px;
}

.vault-passphrase-visibility:hover,
.vault-passphrase-visibility:focus-visible {
  border-color: var(--accent);
  color: var(--primary);
}

.vault-passphrase-visibility .icon {
  height: 18px;
  width: 18px;
}

.vault-passphrase-strength {
  color: var(--muted-strong);
  display: grid;
  font-size: 12px;
  gap: 6px;
  line-height: 1.35;
}

.vault-passphrase-meter {
  background: var(--border);
  border-radius: 999px;
  height: 4px;
  overflow: hidden;
}

.vault-passphrase-meter span {
  background: var(--muted);
  border-radius: inherit;
  display: block;
  height: 100%;
  transition: background-color 160ms ease, width 160ms ease;
  width: 0;
}

.vault-passphrase-strength.is-weak { color: var(--danger); }
.vault-passphrase-strength.is-weak .vault-passphrase-meter span { background: var(--danger); width: 33%; }
.vault-passphrase-strength.is-fair { color: #9a6200; }
.vault-passphrase-strength.is-fair .vault-passphrase-meter span { background: #d18c00; width: 66%; }
.vault-passphrase-strength.is-strong { color: #16734a; }
.vault-passphrase-strength.is-strong .vault-passphrase-meter span { background: #218455; width: 100%; }

.vault-no-recovery-warning {
  background: #fffaf1;
  border: 1px solid #efd7ad;
  border-left: 3px solid #cf810d;
  border-radius: 6px;
  color: #68430a;
  display: grid;
  font-size: 12px;
  gap: 4px;
  line-height: 1.45;
  padding: 11px 13px;
}

.vault-no-recovery-warning strong {
  color: #704606;
  font-size: 13px;
}

.vault-unlock-error {
  color: var(--danger);
  font-size: 12px;
  margin: 0;
}

.vault-session-state {
  align-items: center;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding-top: 12px;
}

.vault-session-state > div {
  display: grid;
  gap: 2px;
}

.vault-session-state strong { color: var(--ink); }

.vault-session-state span {
  color: var(--muted);
  font-size: 12px;
}

.vault-lock-button {
  align-items: center;
  display: inline-flex;
  flex: 0 0 auto;
  gap: 7px;
  min-height: 36px;
  padding: 7px 11px;
  white-space: nowrap;
}

.vault-lock-button .icon {
  color: var(--accent);
  height: 16px;
  width: 16px;
}

.vault-lock-button:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--primary);
}

.roster-surface { min-width: 0; }

.roster-heading {
  align-items: end;
  margin-bottom: 12px;
}

.roster-add-patient {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.vault-optional-patient {
  display: grid;
  gap: 2px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  margin: 2px 0 12px;
  padding-top: 12px;
}

.vault-optional-patient strong { color: var(--ink); }

.roster-column-head,
.roster-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 120px 92px auto;
  gap: 12px;
  align-items: center;
}

.roster-column-head {
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  padding: 0 8px 7px;
}

.patient-list { gap: 0; }

.roster-row {
  min-height: 58px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  padding: 8px;
}

.roster-row:hover { background: #fbfcfc; }

.roster-row.selected { border-color: var(--border); background: var(--surface-tint); }

.roster-patient-name { min-width: 0; }

.roster-patient-name .muted { display: none; }

.roster-status { color: #16737a; font-size: 12px; font-weight: 600; }

.roster-status.is-archived { color: var(--muted); }

.roster-actions { justify-content: flex-end; }

.local-vault-note {
  display: grid;
  gap: 2px;
  margin-top: 16px;
  border-left: 3px solid #8ecacc;
  background: var(--surface-tint);
  color: #526b76;
  padding: 10px 11px;
  font-size: 12px;
}

.local-vault-note strong { color: #0b686d; }

/* Hospital stay */
.stay-layout {
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 0;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.stay-layout > .stay-rail {
  min-height: 0;
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  background: #fcfdfd;
  box-shadow: none;
  overflow: auto;
  padding: 16px 14px;
}

.stay-rail .section-heading { margin-bottom: 12px; }

.timeline-rail {
  gap: 0;
  max-height: none;
  overflow: visible;
  padding: 0;
}

.day-row {
  min-height: 58px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  padding: 9px 8px;
}

.day-row:hover { background: #f7faf9; }

.day-row.selected {
  border-color: var(--border);
  border-left-color: var(--accent);
  background: var(--surface-tint);
}

.day-row > span:first-child strong { color: var(--ink); }

.admission-day-row {
  min-height: 66px;
  border-top: 1px solid var(--border);
}

.admission-day-row > span:first-child {
  display: grid;
  gap: 2px;
}

.admission-day-row > span:first-child .muted {
  line-height: 1.3;
  white-space: normal;
}

.new-day-control { margin-top: 14px; }

.new-day-control summary {
  border-color: var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
}

.stay-content {
  gap: 0;
  min-height: 0;
  overflow: auto;
  padding: 0;
}

.packet-surface,
.stay-content .panel {
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
}

.hospital-day-packet { padding: 18px 20px; }

.admission-packet-details > summary {
  min-height: 58px;
  padding: 13px 20px;
}

.admission-packet-details[open] > summary { border-bottom-color: var(--border); }

.admission-packet-body { gap: 12px; padding: 18px 20px; }

.packet-action-footer {
  position: sticky;
  bottom: -18px;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  margin: 2px -20px -18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 20px;
}

.deid-strip {
  min-height: 50px;
  border-color: #c7e0df;
  border-radius: 6px;
  background: #f2f9f8;
  color: #276267;
  padding: 8px 10px;
}

.deid-strip-compact { min-height: 0; }
.deid-strip-compact select { min-height: 34px; }

.deid-operation {
  display: none;
  grid-column: 1 / -1;
  flex-basis: 100%;
  grid-template-columns: minmax(80px, 180px) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
}

.deid-operation.is-active { display: grid; }
.deid-operation progress { width: 100%; height: 8px; }

.deid-readiness-note {
  grid-column: 1 / -1;
  flex-basis: 100%;
  color: var(--muted);
  font-size: 11px;
}

.deid-download-progress {
  display: grid;
  grid-column: 1 / -1;
  flex-basis: 100%;
  grid-template-columns: minmax(100px, 180px) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
}

.deid-download-progress progress { width: 100%; height: 8px; }

.section-list { gap: 0; }

.section-editor {
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  padding: 7px 8px;
}

.section-editor:first-child { border-top: 1px solid var(--border); }

.section-editor:hover { background: #fbfcfc; }

.section-editor.is-expanded { border: 1px solid #cbdedf; border-radius: 6px; background: #ffffff; margin: 6px 0; padding: 10px; }

.section-editor.is-expanded + .section-editor { border-top: 1px solid var(--border); }

.section-toolbar { grid-template-columns: 16px minmax(160px, 1fr) auto auto; }

.section-editor:not(.is-expanded) .section-label { color: var(--ink); font-weight: 600; }

.section-meta { font-size: 11px; }

.section-editor .icon-button {
  min-width: 28px;
  min-height: 28px;
  border-color: transparent;
  color: var(--muted);
}

.section-editor .icon-button:hover { border-color: var(--border); background: var(--surface-muted); color: var(--ink); }

/* Workups: maintain the existing markup but make its catalog a persistent rail. */
.workup-editor-surface {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto auto;
  column-gap: 0;
  row-gap: 10px;
  height: 100%;
  overflow: auto;
  padding: 0;
}

.workup-topline { display: contents; }

.workup-title-input {
  grid-column: 2;
  grid-row: 1;
  width: calc(100% - 42px);
  min-height: 36px;
  color: var(--ink);
  font-size: 19px;
  font-weight: 650;
  margin: 16px 20px 0;
  padding: 2px 0;
}

.workup-title-input:hover,
.workup-title-input:focus { border-color: var(--border); background: var(--surface); padding-inline: 7px; }

.workup-topline > .icon-button {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  margin: 18px 20px 0 0;
}

.workup-alias-control {
  grid-column: 2;
  grid-row: 2;
  grid-template-columns: 70px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin: 0 20px;
}

.workup-catalog-menu {
  grid-column: 1;
  grid-row: 1 / span 8;
  min-width: 0;
  border-right: 1px solid var(--border);
  background: #fcfdfd;
  padding: 14px;
}

.workup-catalog-menu summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: auto;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  color: var(--ink);
  padding: 0 0 12px;
}

.workup-catalog-menu summary > span {
  display: grid;
  gap: 2px;
  text-align: left;
}

.workup-catalog-menu summary .muted { font-size: 11px; font-weight: 400; }

.workup-catalog-menu summary::-webkit-details-marker { display: none; }

.workup-catalog-popover,
.workup-catalog-menu:not([open]) > .workup-catalog-popover {
  position: static;
  display: grid;
  gap: 10px;
  width: auto;
  max-height: none;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 14px 0 0;
}

.workup-catalog-popover .section-heading { margin-bottom: 0; }

.workup-catalog-popover .workup-list { max-height: 320px; overflow: auto; }

.workup-list { gap: 0; align-content: start; }

.check-row {
  min-height: 50px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  padding: 8px 2px;
}

.check-row:has(input:checked) { border-color: var(--border); background: var(--surface-tint); }

.check-row > button { margin-left: auto; }

.workup-subtitle {
  grid-column: 2;
  grid-row: 3;
  margin: 0 20px;
  color: var(--muted);
  font-size: 12px;
}

.workflow-strip { display: none; }

.workup-columns {
  grid-column: 2;
  grid-row: 4;
  gap: 0;
  margin: 0 20px;
  border-top: 1px solid var(--border);
}

.workup-column { padding: 14px 14px 0; }

.workup-column + .workup-column { border-left: 1px solid var(--border); }

.workup-column .section-heading { margin-bottom: 8px; }

.workup-editor-card {
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  padding: 7px 3px;
  grid-template-columns: 28px 18px minmax(0, 1fr) auto;
  grid-template-rows: auto auto auto auto;
  align-items: start;
}

.workup-editor-card:hover { background: #fbfcfc; }

.workup-editor-card input,
.workup-editor-card textarea,
.workup-editor-card select {
  min-height: 30px;
  border-color: transparent;
  background: transparent;
}

.workup-editor-card input:hover,
.workup-editor-card input:focus,
.workup-editor-card textarea:hover,
.workup-editor-card textarea:focus,
.workup-editor-card select:hover,
.workup-editor-card select:focus { border-color: var(--border); background: var(--surface); }

.workup-editor-card .icon-button { border-color: transparent; color: var(--muted); }

.workup-editor-card .icon-button:hover { border-color: var(--border); color: var(--ink); }

.workup-footer-actions {
  grid-column: 2;
  grid-row: 5;
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 20px;
}

.workup-import,
.workup-editor-surface > .text-button {
  grid-column: 2;
  margin-inline: 20px;
}

.workup-import { grid-row: 6; }

.workup-editor-surface > .text-button { grid-row: 7; justify-self: start; margin-bottom: 16px; }

/* Checklist */
.checklist-shell {
  grid-template-columns: minmax(0, 1fr) 270px;
  gap: 16px;
}

.checklist-panel,
.phone-transfer {
  border-color: var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.checklist-panel { padding: 18px 20px; }

.checklist-panel > .section-heading { align-items: center; }

/* Explicit row assignment (rather than relying on document-order
   auto-placement) so the layout holds even when the toolbar row is omitted
   entirely (no checklist built yet, nothing to search or import). */
.checklist-panel > .section-heading { grid-row: 1; }
.checklist-panel > p.muted { grid-row: 2; }
.checklist-panel > .openevidence-import {
  grid-row: 3;
  max-height: 40vh;
  overflow: auto;
}
.checklist-panel > .checklist-toolbar-row { grid-row: 4; }
.checklist-panel > .checklist-scroll,
.checklist-panel > .empty-state.next-step { grid-row: 5; }
.checklist-panel > .quick-notes-panel { grid-row: 6; }

.checklist-scroll { gap: 14px; padding-right: 0; }

.checklist-section { gap: 0; }

.checklist-section-header {
  border-bottom: 1px solid var(--border);
  padding: 10px 0 8px;
}

.checklist-system { gap: 0; }

.checklist-system-header {
  min-height: 36px;
  background: var(--surface-muted);
  padding: 7px 9px;
}

.checklist-table {
  border: 0;
  border-radius: 0;
}

.checklist-column-head,
.checklist-item {
  grid-template-columns: minmax(180px, 1.3fr) minmax(190px, 1.2fr) minmax(120px, 0.72fr) 20px;
}

.checklist-column-head { color: var(--muted); padding: 10px 9px 5px; }

.checklist-item {
  min-height: 54px;
  border-color: var(--border);
  background: transparent;
  padding: 9px;
}

.checklist-item:hover { background: #fbfcfc; }

.choice-row label {
  min-height: 26px;
  border-radius: 5px;
  background: var(--surface-muted);
  color: var(--text);
  padding: 3px 6px;
}

.choice-row label:has(input:checked),
.choice-row label.baseline-choice:has(input:checked) {
  border-color: #99cfce;
  background: var(--surface-tint);
  color: #0a686d;
}

.checklist-answer-select {
  min-height: 32px;
  border-color: var(--border);
  border-radius: 5px;
  background: var(--surface);
  font-size: 12px;
  position: static;
  transform: none;
  appearance: auto;
}

.item-note-input {
  min-height: 32px;
  border-color: transparent;
  background: transparent;
  font-size: 12px;
}

.item-note-input:hover,
.item-note-input:focus { border-color: var(--border); background: var(--surface); }

.status-dot { color: #9aacb4; font-size: 16px; }

.checklist-item:has(.checklist-answer:checked) .status-dot,
.checklist-item:has(.checklist-answer-select:not([value=""])) .status-dot { color: var(--accent); }

.phone-transfer {
  align-content: start;
  gap: 12px;
  padding: 16px;
}

.phone-transfer > * + * { border-top: 1px solid var(--border); padding-top: 12px; }

.phone-transfer .button-row { gap: 6px; }

/* OpenEvidence prompt builder */
.prompt-layout {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.96fr);
  gap: 16px;
}

.prompt-panel {
  border-color: var(--border);
  border-radius: 8px;
  padding: 18px;
}

.prompt-panel-header { padding-bottom: 4px; }

.prompt-panel-header select { min-height: 34px; }

.prompt-template-panel .prompt-preview {
  border-color: var(--border);
  background: var(--surface);
  font-size: 13px;
}

.prompt-output-panel #promptOutput {
  border-color: var(--border);
  background: #f7fafb;
  color: #284151;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.smart-variable-menu {
  border-color: var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.smart-variable-insert { min-height: 30px; border-radius: 0; font-size: 12px; }

.prompt-template-footer .notice { background: var(--surface-muted); border-left-color: #c6d4da; }

/* Quick De-ID */
.quick-deid-panel {
  border-color: var(--border);
  border-radius: 8px;
  padding: 18px 20px;
}

.model-library {
  border-color: var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
  padding: 12px;
}

.model-pack-grid { gap: 0; margin-top: 10px; }

.model-pack-card {
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  padding: 10px 12px;
}

.model-pack-card:last-child { border-right: 0; }

.quick-deid-grid {
  gap: 0;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.quick-deid-grid > * {
  border-right-color: var(--border);
  padding: 0 16px;
}

.quick-deid-grid > *:first-child { padding-left: 0; }

.quick-deid-grid > *:last-child { padding-right: 0; }

.quick-deid-grid label { color: var(--ink); font-size: 12px; }

.quick-deid-step {
  display: grid;
  align-content: start;
  gap: 8px;
}

.quick-deid-step-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

.quick-deid-step-label > span {
  display: inline-grid;
  inline-size: 20px;
  block-size: 20px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.quick-deid-step-helper {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.quick-model-status {
  display: grid;
  gap: 3px;
  border: 0;
  border-left: 3px solid #80c6c6;
  border-radius: 4px;
  background: var(--surface-tint);
  color: #276267;
}

.quick-model-status strong {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #0b686d;
  font-size: 12px;
}

.quick-model-status span { font-size: 11px; }

.quick-deid-grid .warning-box,
.quick-deid-grid .notice {
  border-left-width: 3px;
  border-radius: 4px;
}

.quick-deid-grid textarea { min-height: 210px; }

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
  }

  .side-nav {
    display: block;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .brand-lockup,
  .side-footer { display: none; }

  .primary-nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 7px 10px;
  }

  .primary-nav button {
    flex: 0 0 auto;
    width: max-content;
    min-width: max-content;
  }

  .top-bar { height: auto; min-height: 56px; }

  .view { padding: 14px; }

  .vault-screen,
  .checklist-shell,
  .prompt-layout { grid-template-columns: 1fr; }

  .stay-layout { height: auto; grid-template-columns: 208px minmax(0, 1fr); }

  .workup-editor-surface {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
    padding: 0;
  }

  .workup-catalog-menu,
  .workup-title-input,
  .workup-topline > .icon-button,
  .workup-alias-control,
  .workup-subtitle,
  .workup-columns,
  .workup-footer-actions,
  .workup-import,
  .workup-editor-surface > .text-button {
    grid-column: 1;
    grid-row: auto;
  }

  .workup-catalog-menu { border-right: 0; border-bottom: 1px solid var(--border); }

  .workup-title-input { width: calc(100% - 58px); }

  .workup-columns { margin: 0 14px; }

  .workup-footer-actions { position: static; padding-inline: 14px; }

  .model-pack-grid { grid-template-columns: 1fr; }

  .model-pack-card { border-right: 0; border-bottom: 1px solid var(--border); }

  .model-pack-card:last-child { border-bottom: 0; }
}

@media (max-width: 680px) {
  body { font-size: 14px; }

  .top-bar { padding: 10px 12px; }

  .patient-switcher { width: 100%; }

  .topbar-trust { display: none; }

  .view { padding: 10px; }

  .vault-access-controls,
  .roster-add-patient { grid-template-columns: 1fr; }

  .vault-session-state { align-items: stretch; flex-direction: column; }

  .vault-session-state .vault-lock-button { align-self: flex-start; }

  .roster-column-head { display: none; }

  .roster-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .roster-status,
  .roster-day-count { display: none; }

  .roster-actions { grid-column: 1 / -1; justify-content: flex-start; }

  .stay-layout { grid-template-columns: 1fr; border-radius: 0; border-inline: 0; }

  .stay-layout > .stay-rail { border-right: 0; border-bottom: 1px solid var(--border); }

  .timeline-rail { display: flex; overflow-x: auto; }

  .day-row { flex: 0 0 164px; border-bottom: 0; border-right: 1px solid var(--border); }

  .deid-strip,
  .deid-strip-compact { align-items: stretch; flex-direction: column; }

  .deid-strip-compact .button-row { flex: 1 1 auto; }

  .deid-strip-compact select { width: 100%; min-width: 0; }

  .workup-columns { grid-template-columns: 1fr; margin: 0 10px; }

  .workup-column { padding: 12px 0 0; }

  .workup-column + .workup-column { border-left: 0; border-top: 1px solid var(--border); margin-top: 12px; }

  .workup-title-input,
  .workup-alias-control,
  .workup-subtitle { margin-inline: 14px; }

  .workup-footer-actions { padding-inline: 14px; }

  .checklist-panel { padding: 14px; }

  .checklist-item,
  .phone-mode .checklist-item { grid-template-columns: minmax(0, 1.1fr) minmax(108px, 0.9fr) 30px 18px; }

  .checklist-item .note-toggle { display: inline-grid; }

  .checklist-item .item-note-input { display: none; }

  .checklist-item.note-open .item-note-input { display: block; grid-column: 1 / -1; }

  .icon-button,
  .choice-row label,
  .checklist-answer-select { min-height: 40px; }

  .quick-deid-panel { padding: 14px; }

  .quick-deid-grid { grid-template-columns: 1fr; gap: 14px; }

  .quick-deid-grid > * { border-right: 0; border-bottom: 1px solid var(--border); padding: 0 0 14px; }

  .quick-deid-grid > *:last-child { border-bottom: 0; padding-bottom: 0; }
}

/* Dense workup rows need a second line for answer choices at desktop widths.
   This keeps the editor inside its two-column workspace without horizontal scroll. */
.workup-catalog-menu > .workup-catalog-popover,
.workup-catalog-menu:not([open]) > .workup-catalog-popover {
  display: grid !important;
}

.workup-editor-card {
  grid-template-columns: 18px 16px minmax(0, 1fr) 56px auto;
  gap: 4px;
}

.workup-editor-card [data-field="item-text"] {
  grid-column: 3;
  grid-row: 1;
}

.workup-editor-card [data-field="item-select"] {
  grid-column: 4;
  grid-row: 1;
}

.workup-editor-card .button-row {
  grid-column: 5;
  grid-row: 1;
}

.workup-editor-card [data-field="item-choices"] {
  grid-column: 3 / 6;
  grid-row: 2;
}

.workup-item-details {
  grid-column: 3 / 6;
  grid-row: 3;
}

@media (max-width: 680px) {
  .workup-editor-card {
    grid-template-columns: 18px 16px minmax(0, 1fr) auto;
  }

  .workup-editor-card [data-field="item-text"] { grid-column: 3 / 5; }
  .workup-editor-card [data-field="item-select"] { grid-column: 3; grid-row: 2; }
  .workup-editor-card .button-row { grid-column: 4; grid-row: 2; }
  .workup-editor-card [data-field="item-choices"] { grid-column: 3 / 5; grid-row: 3; }
  .workup-item-details { grid-column: 3 / 5; grid-row: 4; }
}

.model-library {
  margin: 0;
}

.model-library summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  cursor: pointer;
  list-style: none;
  color: var(--ink);
  padding: 0;
}

.model-library summary::-webkit-details-marker { display: none; }

.model-library summary > span:first-child {
  display: grid;
  gap: 1px;
}

.model-library summary .section-meta { text-align: right; }

.model-library-body {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 10px;
}

/* The desktop shell is defined above the concept overrides.  Keep the compact
   shell last so its single-column layout wins at tablet and phone widths. */
@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    max-height: none;
  }

  .side-nav {
    display: block;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .brand-lockup,
  .side-footer { display: none; }

  .primary-nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 7px 10px;
  }

  .primary-nav button {
    flex: 0 0 auto;
    width: max-content;
    min-width: max-content;
  }
}

.guided-demo-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  padding: 7px 10px;
  border: 1px solid #b9cfd2;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 96%, #e7f6f6);
}

.guided-demo-heading {
  display: grid;
  gap: 2px;
  min-width: max-content;
}

.guided-demo-kicker {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.guided-demo-step {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.guided-demo-copy {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 1px 8px;
  min-width: 0;
}

.guided-demo-copy strong {
  color: var(--ink);
  font-size: 14px;
}

.guided-demo-copy span,
.guided-demo-badge {
  color: var(--muted);
  font-size: 13px;
}

.guided-demo-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: max-content;
}

.guided-demo-badge {
  white-space: nowrap;
}

/* Batch E (F16): the bar's instruction text must always wrap and the
   bar must always grow to fit it. Flex items default to min-width:
   auto, which can hold the copy on one clipped line instead of
   wrapping; pin every text-bearing flex item in the bar to
   min-width: 0 so wrapping is structural, not incidental. */
.guided-demo-copy > strong,
.guided-demo-instructions,
.guided-demo-action,
.guided-demo-note,
.guided-demo-sample {
  min-width: 0;
}

.guided-demo-action,
.guided-demo-note {
  overflow-wrap: break-word;
}

.guided-demo-sample {
  max-width: 100%;
}

.guided-demo-exit {
  border-color: var(--border);
  color: var(--ink);
  white-space: nowrap;
}

.guided-demo-exit:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface);
  color: var(--ink);
}

@media (max-width: 680px) {
  .guided-demo-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 8px 12px;
  }

  .guided-demo-heading {
    grid-column: 1;
    grid-row: 1;
  }

  .guided-demo-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .guided-demo-copy {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

/* Give the workup tools a clear hierarchy: prompts, file transfer, then the
   one action that saves the edited workup. */
.workup-footer-actions {
  position: static;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding: 10px 20px;
}

.workup-action-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.workup-file-actions {
  border-left: 1px solid var(--border);
  padding-left: 10px;
}

.workup-save-button {
  justify-self: end;
  white-space: nowrap;
}

.workup-workspace-mirror {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px 16px;
  padding: 12px 14px;
}

.workup-workspace-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.workup-workspace-copy p,
.workup-workspace-copy small {
  grid-column: auto;
  margin: 0;
}

.workup-workspace-copy small {
  color: var(--muted);
  font-size: 11px;
}

.workup-workspace-actions {
  align-self: center;
  justify-content: flex-end;
}

.workup-import summary {
  grid-template-columns: minmax(0, 1fr) 24px;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}

.workup-import summary::before {
  content: none;
}

.workup-import[open] summary::before {
  content: none;
}

.workup-import-summary-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.workup-import-summary-marker {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--accent);
}

.workup-import-summary-marker::before {
  content: "+";
  font-size: 17px;
  line-height: 1;
}

.workup-import[open] .workup-import-summary-marker::before {
  content: "−";
}

.workup-import-body {
  gap: 14px;
  padding: 0 14px 14px;
}

.workup-import-body > .section-heading {
  align-items: start;
  margin: 0;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.workup-import-body > .section-heading > div:first-child {
  min-width: 0;
}

.workup-import-body > .section-heading .button-row {
  justify-content: flex-end;
}

.workup-api-formatting {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  padding: 10px;
}

.workup-editor-surface > .text-button {
  width: auto;
  justify-self: stretch;
  margin: 0 20px 16px;
  border-top: 1px solid var(--border);
  padding: 10px 0 0;
  text-align: left;
  color: var(--danger);
  font-size: 12px;
}

@media (max-width: 1400px) {
  .workup-footer-actions {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .workup-file-actions {
    border-top: 1px solid var(--border);
    border-left: 0;
    padding-top: 10px;
    padding-left: 0;
  }

  .workup-save-button {
    width: 100%;
    justify-self: stretch;
  }

  .workup-workspace-mirror {
    grid-template-columns: 1fr;
  }

  .workup-workspace-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .workup-import-body > .section-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .workup-import-body > .section-heading .button-row {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .app-shell,
  .app-main,
  .top-bar,
  .top-controls,
  .patient-switcher,
  .workspace,
  .view,
  .vault-screen,
  .vault-access,
  .roster-surface {
    min-width: 0;
    max-width: 100%;
  }

  .top-bar,
  .top-controls {
    display: block;
    width: 100%;
  }

  .patient-switcher {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .patient-switcher select {
    width: 100%;
    min-width: 0;
  }
}

/* Interaction repairs: keep review work visible, contained, and local. */
.section-drag-handle {
  cursor: grab;
  touch-action: none;
}

.section-drag-handle:active,
.section-editor.is-dragging .section-drag-handle { cursor: grabbing; }

.section-editor.is-dragging { opacity: 0.56; }

.section-list.is-drop-target { outline: 1px dashed #75bfc4; outline-offset: 3px; }

.section-review-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 8px;
}

.section-review-tools .muted { font-size: 11px; }

.section-editor:not(.is-expanded) .section-review-tools,
.section-editor:not(.is-expanded) .redaction-review,
.section-editor:not(.is-expanded) .redaction-document { display: none; }

.redaction-review {
  display: grid;
  gap: 8px;
  border-left: 3px solid #c7902f;
  background: #fffaf0;
  margin-top: 10px;
  padding: 10px 12px;
}

.redaction-review-heading > div,
.redaction-inspector > div:first-child {
  display: grid;
  gap: 2px;
}

.review-next-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #b9cfd2;
  border-radius: 6px;
  background: #f7fbfb;
  padding: 10px 12px;
}

.review-next-step > div {
  display: grid;
  gap: 2px;
}

.review-next-step .muted { font-size: 11px; }

@media (max-width: 680px) {
  .review-next-step {
    align-items: stretch;
    flex-direction: column;
  }
}

.redaction-review .muted,
.redaction-inspector span,
.redaction-inspector small { font-size: 11px; }

.redaction-preview {
  max-height: 128px;
  overflow: auto;
  border: 1px solid #e2d3ad;
  background: #ffffff;
  color: var(--ink);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  padding: 9px;
  white-space: pre-wrap;
}

.redacted-token {
  position: relative;
  display: inline;
  border: 1px solid #c7902f;
  border-radius: 3px;
  background: #fff0c9;
  color: #6c4308;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 0 2px;
}

.redacted-token--static { cursor: default; }

.redacted-token[data-original]::after {
  content: "";
  opacity: 0;
  pointer-events: none;
}

.redacted-token[data-original]:hover::after,
.redacted-token[data-original]:focus-visible::after {
  content: attr(data-original);
  position: absolute;
  z-index: 20;
  bottom: calc(100% + 6px);
  left: 0;
  width: max-content;
  max-width: min(360px, 76vw);
  border: 1px solid #c7902f;
  border-radius: 4px;
  background: #fffdf8;
  box-shadow: 0 5px 14px rgb(33 50 66 / 18%);
  color: #563605;
  font: 500 12px/1.4 "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  opacity: 1;
  padding: 7px 8px;
  white-space: normal;
}

.redaction-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.redaction-chip {
  display: grid;
  gap: 1px;
  border: 1px solid #e2d3ad;
  border-radius: 4px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font-size: 11px;
  padding: 5px 7px;
  text-align: left;
}

.redaction-chip span { color: var(--muted); font-size: 10px; }

.redaction-chip.selected,
.redaction-chip:hover,
.redaction-chip:focus-visible { border-color: #c7902f; background: #fff7e3; }

.redaction-inspector {
  display: grid;
  gap: 8px;
  border-top: 1px solid #e2d3ad;
  padding-top: 8px;
}

.redaction-original {
  display: block;
  overflow-wrap: anywhere;
  border: 1px solid #d8c08c;
  background: #ffffff;
  color: #563605;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  padding: 8px;
}

.residual-warning-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.residual-warning-entry .button-row { gap: 4px; }

/* Reserve a stable, independent scroll surface for each workup kind. */
.workup-editor-surface {
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto auto auto;
  overflow: hidden;
}

.workup-catalog-menu { grid-row: 1 / span 9; }

.workup-scope-control {
  display: grid;
  grid-column: 2;
  grid-row: 4;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 0 20px;
  color: var(--ink);
  font-size: 12px;
}

.workup-scope-control label {
  display: grid;
  grid-template-columns: max-content 132px;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.workup-scope-control select { min-height: 30px; }

.workup-scope-control .muted { font-size: 11px; }

.workup-columns {
  grid-row: 5;
  min-height: 0;
  overflow: hidden;
}

.workup-column {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.workup-item-scroll {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 12px 88px;
  padding-right: 6px;
}

/* The editor has its own scroll surfaces; a sticky footer would otherwise sit
   over a dragged row and make its pointer target unreachable. */
.workup-footer-actions { position: static; }

.workup-system-group + .workup-system-group { margin-top: 12px; }

.workup-system-group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  padding: 8px 3px 6px;
}

.workup-system-group-header h4 { font-size: 12px; margin: 0; }
.workup-system-group-header .muted { font-size: 10px; }

.workup-footer-actions { grid-row: 6; }
.workup-import { grid-row: 7; }
.workup-editor-surface > .text-button { grid-row: 8; }

/* A return bundle is the final phone step, never a side effect of filling. */
.phone-mode .checklist-shell { grid-template-columns: minmax(0, 1fr); }

.phone-completion-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 1 1 100%;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  margin: 4px 0 12px;
  padding: 9px 10px;
}

.phone-completion-bar > div { display: grid; gap: 2px; }
.phone-completion-bar span { color: var(--muted); font-size: 11px; }
.phone-completion-bar.ready { border-color: #96c8c7; background: var(--surface-tint); }
.phone-return-ready { max-width: 480px; }

@media (max-width: 1040px) {
  .workup-editor-surface { overflow: visible; }

  .workup-scope-control,
  .workup-columns,
  .workup-footer-actions,
  .workup-import,
  .workup-editor-surface > .text-button {
    grid-column: 1;
    grid-row: auto;
  }

  .workup-item-scroll { max-height: 56dvh; }
}

@media (max-width: 680px) {
  .section-review-tools,
  .phone-completion-bar { align-items: stretch; flex-direction: column; }

  .residual-warning-entry { grid-template-columns: 1fr; }

  .workup-scope-control { grid-template-columns: 1fr; margin-inline: 14px; }
  .workup-scope-control label { grid-template-columns: 1fr; white-space: normal; }
  .workup-scope-control select { width: 100%; }
}

.demo-shell {
  display: grid;
  gap: 14px;
  width: min(100%, 920px);
  margin: 0 auto;
}

.demo-guide {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border: 1px solid #b9cfd2;
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  background: #f7fbfb;
  padding: 12px 14px;
}

.demo-guide-progress {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.demo-guide-copy {
  display: grid;
  gap: 2px;
}

.demo-guide-copy strong {
  color: var(--ink);
}

.demo-guide-copy p {
  color: var(--muted);
  font-size: 13px;
}

.demo-case {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.demo-case-header,
.demo-panel-heading,
.demo-checklist-preview,
.demo-complete,
.demo-checklist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.demo-case-header {
  align-items: flex-start;
}

.demo-case-header h2 {
  margin-top: 2px;
}

.demo-case-label,
.demo-only-label,
.demo-answer {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.demo-only-label {
  border: 1px solid #b9cfd2;
  border-radius: var(--radius-sm);
  padding: 4px 7px;
  white-space: nowrap;
}

.demo-workflow {
  display: grid;
  gap: 14px;
}

.demo-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  padding: 14px;
}

.demo-panel-heading {
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.demo-note,
.demo-prompt {
  color: var(--text);
  line-height: 1.65;
}

.demo-note del {
  color: var(--danger);
  text-decoration-thickness: 2px;
}

.demo-note mark {
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--ink);
  padding: 1px 3px;
}

.demo-review-explanation,
.demo-privacy-note,
.demo-checklist-preview,
.demo-complete {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  padding: 10px 12px;
}

.demo-review-explanation,
.demo-privacy-note {
  color: var(--muted);
  font-size: 13px;
}

.demo-privacy-note,
.demo-complete {
  display: grid;
  gap: 3px;
}

.demo-privacy-note strong,
.demo-complete strong {
  color: var(--ink);
}

.demo-privacy-note span,
.demo-complete span {
  color: var(--muted);
}

.demo-intro-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.demo-list {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.demo-checklist-panel {
  background: #ffffff;
}

.demo-checklist-item {
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
  padding: 4px 0 12px;
}

.demo-checklist-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.demo-checklist-item > div:first-child {
  display: grid;
  gap: 3px;
}

.demo-checklist-item > div:first-child span {
  color: var(--muted);
}

.demo-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: none;
}

.demo-next-action {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.demo-complete {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  border-color: #abd4bf;
  background: #f4fbf6;
}

.demo-complete .icon {
  width: 20px;
  height: 20px;
  color: var(--success);
}

@media (max-width: 680px) {
  .demo-guide,
  .demo-intro-grid {
    grid-template-columns: 1fr;
  }

  .demo-case {
    padding: 14px;
  }

  .demo-guide {
    align-items: flex-start;
  }

  .demo-case-header,
  .demo-panel-heading,
  .demo-checklist-preview,
  .demo-checklist-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .demo-choice-row {
    width: 100%;
  }
}
/* Keep the fail-closed vault shell last so responsive workspace rules cannot
   reveal navigation or override the locked layout. */
body.vault-locked .app-shell {
  grid-template-columns: minmax(0, 1fr);
}

body.vault-locked .side-nav,
body.vault-locked .top-bar {
  display: none;
}

body.vault-locked .workspace {
  display: grid;
  min-height: 100dvh;
  overflow: auto;
  padding: 28px;
  place-items: center;
}

body.vault-locked .view {
  display: none;
}

body.vault-locked #vaultView.active {
  display: block;
  width: min(100%, 660px);
}

.locked-vault-shell {
  display: grid;
  gap: 16px;
  width: 100%;
}

body.vault-locked .vault-access {
  margin: 0;
}

.demo-shell {
  display: grid;
  gap: 14px;
  width: min(100%, 920px);
  margin: 0 auto;
}

.demo-guide {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border: 1px solid #b9cfd2;
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  background: #f7fbfb;
  padding: 12px 14px;
}

.demo-guide-progress {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.demo-guide-copy {
  display: grid;
  gap: 2px;
}

.demo-guide-copy strong {
  color: var(--ink);
}

.demo-guide-copy p {
  color: var(--muted);
  font-size: 13px;
}

.demo-case {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.demo-case-header,
.demo-panel-heading,
.demo-checklist-preview,
.demo-complete,
.demo-checklist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.demo-case-header {
  align-items: flex-start;
}

.demo-case-header h2 {
  margin-top: 2px;
}

.demo-case-label,
.demo-only-label,
.demo-answer {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.demo-only-label {
  border: 1px solid #b9cfd2;
  border-radius: var(--radius-sm);
  padding: 4px 7px;
  white-space: nowrap;
}

.demo-workflow {
  display: grid;
  gap: 14px;
}

.demo-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  padding: 14px;
}

.demo-panel-heading {
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.demo-note,
.demo-prompt {
  color: var(--text);
  line-height: 1.65;
}

.demo-note del {
  color: var(--danger);
  text-decoration-thickness: 2px;
}

.demo-note mark {
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--ink);
  padding: 1px 3px;
}

.demo-review-explanation,
.demo-privacy-note,
.demo-checklist-preview,
.demo-complete {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  padding: 10px 12px;
}

.demo-review-explanation,
.demo-privacy-note {
  color: var(--muted);
  font-size: 13px;
}

.demo-privacy-note,
.demo-complete {
  display: grid;
  gap: 3px;
}

.demo-privacy-note strong,
.demo-complete strong {
  color: var(--ink);
}

.demo-privacy-note span,
.demo-complete span {
  color: var(--muted);
}

.demo-intro-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.demo-list {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.demo-checklist-panel {
  background: #ffffff;
}

.demo-checklist-item {
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
  padding: 4px 0 12px;
}

.demo-checklist-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.demo-checklist-item > div:first-child {
  display: grid;
  gap: 3px;
}

.demo-checklist-item > div:first-child span {
  color: var(--muted);
}

.demo-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: none;
}

.demo-next-action {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.demo-complete {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  border-color: #abd4bf;
  background: #f4fbf6;
}

.demo-complete .icon {
  width: 20px;
  height: 20px;
  color: var(--success);
}

@media (max-width: 680px) {
  .demo-guide,
  .demo-intro-grid {
    grid-template-columns: 1fr;
  }

  .demo-case {
    padding: 14px;
  }

  .demo-guide {
    align-items: flex-start;
  }

  .demo-case-header,
  .demo-panel-heading,
  .demo-checklist-preview,
  .demo-checklist-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .demo-choice-row {
    width: 100%;
  }
}

@media (max-width: 680px) {
  body.vault-locked .workspace {
    align-items: start;
    padding: 18px 14px;
  }
}

/* Quick De-ID and Hospital Stay use one annotated review document. The raw
   fragment is visible only in memory, struck through beside its replacement. */
.quick-redaction-review {
  margin: 0;
}

.quick-deid-coverage-note {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-block: 2px 14px;
}

.quick-deid-coverage-note summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.quick-deid-coverage-note p {
  margin: 8px 0 0;
  font-size: 12px;
}

.quick-deid-coverage-note a {
  color: inherit;
}

.quick-model-control {
  display: grid;
  gap: 8px;
  border-block: 1px solid var(--border);
  margin-block: 2px 14px;
  padding-block: 12px;
}

.quick-model-control > label,
.quick-deid-start > label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.quick-model-control-row,
.quick-deid-start-footer,
.quick-copy-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.quick-model-control-row select {
  flex: 1 1 300px;
  min-width: 0;
}

.quick-model-control p { margin: 0; font-size: 12px; }

.model-selection-message {
  color: var(--muted);
  font-size: 12px;
}

.model-selection-message--ready { color: #17716b; font-weight: 650; }
.model-selection-message--error { color: #9d3c2d; font-weight: 650; }

.model-selection-progress {
  display: grid;
  gap: 4px;
  font-size: 12px;
}

.model-selection-progress progress { inline-size: 100%; }

.quick-deid-start,
.quick-review-workspace {
  display: grid;
  gap: 12px;
  min-height: 0;
}

/* "Verify with local AI" option: a proper labeled row instead of a bare
   browser checkbox floating on its own line. */
.quick-deid-verify {
  display: grid;
  gap: 4px;
}
.quick-deid-verify-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  width: fit-content;
}
.quick-deid-verify-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
}
.quick-deid-verify-label input[type="checkbox"]:disabled {
  cursor: not-allowed;
}
.quick-deid-verify-label:has(input[type="checkbox"]:disabled) {
  color: var(--muted);
  font-weight: 400;
  cursor: not-allowed;
}
.quick-deid-verify > p {
  margin: 0;
}

.quick-deid-start textarea {
  box-sizing: border-box;
  min-height: min(54dvh, 460px);
  resize: vertical;
}

.quick-deid-start-footer,
.quick-copy-footer {
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.quick-copy-footer {
  padding-inline: 14px;
  padding-bottom: 14px;
}

.quick-copy-footer .muted { font-size: 12px; }

.redaction-document {
  box-sizing: border-box;
  max-height: min(58dvh, 560px);
  overflow: auto;
  border: 1px solid var(--border-strong);
  background: #fffefa;
  color: var(--ink);
  font: 14px/1.7 "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  padding: 14px;
  white-space: pre-wrap;
}

.section-editor .redaction-document { min-height: 190px; max-height: 340px; }

.redaction-document:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.redaction-document-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.redaction-change {
  display: inline;
  min-height: 0;
  line-height: inherit;
  vertical-align: baseline;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-align: inherit;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.redaction-change del,
.redaction-change ins,
.redaction-change mark {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.redaction-change del {
  border-bottom: 1px solid #b3503c;
  color: #7f3c2d;
  text-decoration-color: #b3503c;
  text-decoration-thickness: 2px;
}

.redaction-change-arrow { color: var(--muted); padding-inline: 3px; }

.redaction-change ins {
  background: #fff0c9;
  color: #67420b;
  font-weight: 750;
  text-decoration: none;
}

.redaction-change:hover ins,
.redaction-change:focus-visible ins,
.redaction-change.is-inspected ins {
  background: #f5da95;
  outline: 1px solid #b98424;
}

.redaction-change--confirmed mark {
  background: #e5f2e8;
  color: #205e43;
  font-weight: 750;
  text-decoration: none;
}

.redaction-change--confirmed:hover mark,
.redaction-change--confirmed:focus-visible mark,
.redaction-change--confirmed.is-inspected mark {
  background: #cfe5d4;
  outline: 1px solid #5c9472;
}

.redaction-change-wrap { display: inline; }

.redaction-reject {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5em;
  height: 1.5em;
  margin-left: 3px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8em;
  line-height: 1;
  vertical-align: 0.1em;
}

.redaction-reject:hover,
.redaction-reject:focus-visible {
  color: #b3503c;
  border-color: #d8a08f;
  background: #fdf0ec;
  outline: none;
}

.quick-review-instruction { margin: 0; font-size: 12px; }

.redaction-inline-actions { border-top: 1px solid #e2d3ad; padding-top: 8px; }

.quick-installer-feedback {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid #b9dfe1;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: #f0fbfb;
}

.quick-installer-feedback > div {
  display: grid;
  gap: 2px;
}

.quick-installer-feedback span {
  color: var(--muted);
  font-size: 12px;
}

.quick-installer-feedback progress {
  grid-column: 1 / -1;
  width: 100%;
}

.quick-installer-feedback--error {
  border-color: #e1b9ac;
  border-left-color: #b64b39;
  background: #fff5f1;
}

.quick-installer-feedback--error strong,
.quick-installer-feedback--error span {
  color: #7c3024;
}

.quick-installer-feedback--ready {
  border-color: #b9dfe1;
  border-left-color: #18857e;
  background: #f1fbf7;
}

.quick-redaction-review .redaction-preview {
  max-height: 104px;
}

.quick-review-current {
  border-top: 1px solid #e2d3ad;
  padding-top: 8px;
}

.quick-review-complete {
  margin: 0;
}

.quick-correction-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.quick-correction-layout > label,
.quick-correction-output {
  display: grid;
  gap: 5px;
}

.quick-correction-layout span,
.quick-correction-layout > label > span,
.quick-correction-output > label {
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.quick-correction-layout em {
  color: #8b621f;
  font-style: normal;
  font-weight: 600;
}

.quick-correction-layout textarea {
  min-height: 210px;
  max-height: 280px;
  resize: vertical;
}

.quick-correction-output .redaction-preview {
  max-height: 110px;
}

.quick-correction-output .muted {
  font-size: 11px;
}

.quick-residual-review {
  display: grid;
  gap: 7px;
  border-top: 1px solid #e2d3ad;
  padding-top: 8px;
}

.quick-output-tools {
  display: grid;
  gap: 5px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.quick-output-tools .muted {
  font-size: 11px;
}

@media (min-width: 1041px) {
  .quick-deid-grid {
    grid-template-columns: minmax(220px, 1fr) 190px minmax(280px, 1.24fr) minmax(220px, 1fr);
  }
}

@media (max-width: 1040px) {
  .quick-correction-layout > label,
  .quick-correction-output {
    min-width: 0;
  }
}

@media (max-width: 680px) {
  .quick-correction-layout { grid-template-columns: 1fr; }
}

/* Settings and the explicit BYOK workup-formatting handoff. */
.settings-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.settings-page-heading {
  margin-bottom: 18px;
}

.settings-page-heading h1 {
  margin: 0;
  color: var(--text);
  font-size: 28px;
  line-height: 1.15;
}

.settings-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  min-width: 0;
}

.settings-main {
  min-width: 0;
}

.settings-top-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.settings-page.has-guideline-editor {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 390px);
}

.settings-page.has-guideline-editor > .guideline-editor {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: 18px;
  align-self: start;
  min-height: calc(100dvh - 112px);
  max-height: calc(100dvh - 112px);
  overflow: auto;
  padding: 0 0 18px 18px;
  border-left: 1px solid var(--border);
}

.guideline-editor-heading h2 {
  margin: 0;
  font-size: 20px;
}

.settings-panel {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding: 20px;
}

.settings-panel--guidelines {
  grid-column: 1 / -1;
  min-width: 0;
  width: 100%;
}

.settings-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-field-wide {
  grid-column: 1 / -1;
}

.settings-fields textarea {
  resize: vertical;
}

.settings-security-note {
  display: grid;
  gap: 4px;
}

.settings-helper {
  margin: 0;
  font-size: 12px;
}

.guideline-set-manage {
  display: flex;
  gap: 8px;
  align-items: center;
}

.guideline-library-toolbar {
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--border);
}

.guideline-search {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.guideline-search input {
  width: 100%;
  min-height: 34px;
  padding-left: 30px;
  background-image: radial-gradient(circle at 13px 13px, transparent 0 5px, var(--muted) 5.5px 6.5px, transparent 7px), linear-gradient(45deg, transparent 46%, var(--muted) 47% 53%, transparent 54%);
  background-size: 18px 18px, 8px 8px;
  background-position: 4px 8px, 17px 21px;
  background-repeat: no-repeat;
}

.guideline-bulk-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}

.guideline-select-all {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
}

.guideline-selection-count {
  flex: 1 1 auto;
  color: var(--muted);
  font-size: 12px;
}

.guideline-selection-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.guideline-set-summary-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.guideline-set-summary-text code {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guideline-open-hint {
  color: var(--muted);
  font-size: 12px;
}

.guideline-set-card:has(.guideline-select:focus-visible),
.guideline-set-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.guideline-empty {
  display: grid;
  gap: 4px;
  border: 1px dashed var(--border);
  padding: 24px;
  color: var(--muted);
}

.guideline-set-manage input {
  flex: 1 1 auto;
  min-width: 0;
}

.guideline-set-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 4px 10px;
}

.guideline-set-card-header > .guideline-select {
  flex: 0 0 auto;
  margin: 0 10px 0 4px;
}

.guideline-set-card-header {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
  min-height: 36px;
}

.guideline-set-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  width: auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 8px 0;
  text-align: left;
}

.guideline-set-card summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  padding: 8px 0;
}

.guideline-set-card summary::-webkit-details-marker {
  display: none;
}

.guideline-set-card summary code {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.guideline-set-body {
  display: grid;
  gap: 10px;
  padding: 2px 0 12px;
}

.guideline-set-body[hidden] {
  display: none;
}

.guideline-set-body textarea {
  resize: vertical;
}

/* Compact guideline library: rows stay scannable while one editor opens beside them. */
.settings-panel--guidelines {
  grid-column: 1 / -1;
  min-width: 0;
}

.guideline-library-heading {
  margin-bottom: 4px;
}

.guideline-refresh-note {
  margin: 0 0 10px;
}

.guideline-library-toolbar {
  grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
}

.guideline-search {
  min-width: 0;
}

.guideline-set-manage {
  display: flex;
  justify-content: flex-end;
}

.guideline-bulk-toolbar {
  min-height: 44px;
}

.guideline-selection-count {
  min-width: 1px;
}

.guideline-library-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  border-top: 1px solid var(--border);
}

.guideline-library-body.has-editor {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.52fr);
  gap: 18px;
  padding-top: 14px;
}

.guideline-list {
  min-width: 0;
}

.guideline-list-header,
.guideline-row {
  display: grid;
  grid-template-columns: 16px 18px minmax(130px, 0.7fr) minmax(150px, 0.85fr) minmax(170px, 1fr) minmax(42px, auto);
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding-left: 12px;
}

.guideline-list-header {
  min-height: 38px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.guideline-row {
  min-height: 46px;
  border-bottom: 1px solid var(--border);
}

.guideline-row:hover,
.guideline-row.is-active {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

.guideline-row > .guideline-select {
  margin: 0;
}

.guideline-row > .guideline-select,
.guideline-select-all input {
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  margin: 0;
  border-radius: 4px;
}

.guideline-row > .token-color-swatch {
  justify-self: center;
}

.guideline-row-open {
  display: grid;
  grid-template-columns: minmax(100px, 0.55fr) minmax(150px, 0.8fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
  width: 100%;
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  grid-column: 3 / 6;
}

.guideline-row-open strong,
.guideline-row-open code,
.guideline-row-preview {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guideline-row-open code,
.guideline-row-preview {
  color: var(--muted);
  font-size: 12px;
}

.guideline-row-edit {
  justify-self: end;
  min-height: 30px;
  padding-inline: 8px;
  grid-column: 6;
}

.guideline-list-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.guideline-pagination {
  display: flex;
  align-items: center;
  gap: 8px;
}

.guideline-pagination .button--quiet {
  min-height: 30px;
  padding: 4px 8px;
}

.guideline-editor {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
  padding-left: 18px;
  border-left: 1px solid var(--border);
}

.guideline-editor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  border-bottom: 1px solid var(--border);
}

.guideline-editor-heading h3 {
  margin: 0;
  font-size: 18px;
}

.guideline-editor label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.guideline-editor label > span {
  font-size: 11px;
}

.guideline-editor textarea {
  min-height: 260px;
  resize: vertical;
}

.guideline-editor-footer {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

@media (max-width: 900px) {
  .guideline-library-body.has-editor {
    grid-template-columns: 1fr;
  }

  .guideline-editor {
    padding: 18px 0 0;
    border-top: 1px solid var(--border);
    border-left: 0;
  }
}

@media (max-width: 700px) {
  .guideline-library-toolbar {
    grid-template-columns: 1fr;
  }

.guideline-selection-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .guideline-list-header {
    display: none;
  }

  .guideline-row {
    grid-template-columns: 16px 18px minmax(0, 1fr) auto;
    padding: 8px 0 8px 10px;
  }

  .guideline-row-open {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    grid-column: 3;
  }

  .guideline-row-edit { grid-column: 4; }

  .guideline-row-preview {
    grid-column: 1 / -1;
  }

  .guideline-list-footer {
    align-items: flex-start;
    flex-direction: column;
    padding: 8px 0;
  }
}

@media (max-width: 900px) {
  .settings-page.has-guideline-editor {
    grid-template-columns: 1fr;
  }

  .settings-page.has-guideline-editor > .guideline-editor {
    grid-column: 1;
    grid-row: auto;
    position: static;
    min-height: 0;
    padding: 18px 0 0;
    border-top: 1px solid var(--border);
    border-left: 0;
  }
}

@media (max-width: 700px) {
  .settings-top-grid {
    grid-template-columns: 1fr;
  }
}

.workup-api-formatting {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.workup-api-formatting .check-row {
  align-items: start;
}

.workup-api-formatting .check-row input {
  margin-top: 3px;
}

.workup-workspace-mirror {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 14px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
  padding: 10px 12px;
}

.workup-workspace-mirror p,
.workup-workspace-mirror small {
  margin: 3px 0 0;
}

/* Give every direct workup surface child a stable grid slot.  This prevents a
   newly added helper panel from creating an implicit row that collapses the
   independently scrollable history/exam editor behind other controls. */
@media (min-width: 1041px) {
  .workup-editor-surface {
    grid-template-rows: auto auto auto auto minmax(480px, 1fr) auto auto auto auto auto;
  }

  .workup-catalog-menu { grid-row: 1 / span 10; }
  .workup-columns { grid-row: 5; }
  .workup-footer-actions { grid-row: 6; }
  .workup-editor-surface > p.muted { grid-column: 2; grid-row: 7; margin: 0 20px; }
  .workup-workspace-mirror { grid-column: 2; grid-row: 8; margin: 0 20px; }
  .workup-import { grid-column: 2; grid-row: 9; }
  .workup-editor-surface > .text-button { grid-column: 2; grid-row: 10; }
}

.workup-workspace-mirror small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.prompt-day-select {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.prompt-day-select select {
  min-width: 0;
  flex: 1;
}

@media (max-width: 680px) {
  .workup-workspace-mirror {
    grid-template-columns: 1fr;
  }

  .prompt-day-select { flex-direction: column; align-items: stretch; }
}

/* The sidebar and view padding leave the prompt builder substantially less
   room than the viewport width suggests.  Stack its two working surfaces
   before either panel reaches its minimum usable width, then let the header
   controls wrap instead of forcing the task and hospital-day selects into a
   single crowded row. */
@media (max-width: 1300px) {
  .prompt-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    height: auto;
    overflow: visible;
  }

  .prompt-layout .prompt-panel.prompt-template-panel,
  .prompt-layout .prompt-panel.prompt-output-panel {
    grid-column: auto;
    grid-row: auto;
    overflow: visible;
  }

  .prompt-template-panel .prompt-preview,
  .prompt-output-panel .prompt-output-highlighted {
    height: 360px;
  }

  .prompt-template-wrap {
    min-height: 360px;
  }
}

@media (max-width: 900px) {
  .prompt-panel-header {
    flex-wrap: wrap;
  }

  .prompt-panel-header > div:first-child {
    flex-basis: 100%;
  }

  .prompt-panel-header > select,
  .prompt-panel-header > .prompt-day-select {
    flex: 1 1 260px;
    max-width: none;
  }
}

@media (max-width: 880px) {
  .settings-layout {
    grid-template-columns: 1fr;
  }

  .guideline-library-toolbar {
    grid-template-columns: 1fr;
  }

  .guideline-set-manage {
    justify-content: stretch;
  }

  .guideline-set-manage button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .settings-fields {
    grid-template-columns: 1fr;
  }

  .settings-field-wide {
    grid-column: auto;
  }
}

/* Checklist surface: keep the entry controls compact, labeled, and easy to
   scan before the user reaches the answer grid. */
.checklist-heading {
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 8px;
}

.checklist-heading > div:first-child {
  min-width: 0;
}

.checklist-heading h2 {
  margin: 0;
  line-height: 1.2;
}

.checklist-heading p {
  margin: 3px 0 0;
  font-size: 13px;
}

.checklist-heading-actions {
  justify-content: flex-end;
}

.checklist-guidance {
  margin: 0 0 2px;
  max-width: 1100px;
  border-left: 2px solid var(--accent);
  padding-left: 10px;
  font-size: 13px;
  line-height: 1.4;
}

.openevidence-import {
  margin: 0;
  border-color: #c9d8dc;
  background: var(--surface-subtle);
}

.openevidence-import > summary {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}

.openevidence-import > summary::-webkit-details-marker {
  display: none;
}

.checklist-import-summary-marker {
  display: grid;
  place-items: center;
  color: var(--accent);
}

.checklist-import-summary-marker .icon {
  width: 17px;
  height: 17px;
  transition: transform 140ms ease;
}

.openevidence-import[open] .checklist-import-summary-marker .icon {
  transform: rotate(90deg);
}

.checklist-import-summary-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.checklist-import-summary-copy strong {
  font-size: 14px;
}

.checklist-import-summary-copy .muted {
  font-size: 12px;
}

.checklist-import-summary-action {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.checklist-toolbar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end;
  gap: 8px 12px;
  padding: 2px 0;
}

.checklist-search-field {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.checklist-search-field > span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.checklist-search-field input {
  min-height: 36px;
}

.checklist-search-count {
  align-self: center;
  font-size: 12px;
  white-space: nowrap;
}

.checklist-search-clear {
  align-self: center;
  padding-inline: 6px;
}

.checklist-section-header h3 {
  margin: 0;
  font-size: 16px;
}

.checklist-section-header .button-row {
  gap: 10px;
}

@media (max-width: 1040px) {
  .checklist-heading-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .checklist-heading {
    gap: 8px;
  }

  .checklist-heading-actions {
    width: 100%;
  }

  .checklist-heading-actions button {
    flex: 1 1 auto;
  }

  .checklist-toolbar-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .checklist-search-field {
    grid-column: 1 / -1;
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .openevidence-import > summary {
    grid-template-columns: 22px minmax(0, 1fr);
  }

  .checklist-import-summary-action {
    grid-column: 2;
  }
}

/* Hospital Stay review and the workup editor are each an independent working
   surface.  These final rules intentionally replace earlier transitional
   layout variants so a nested scroll area never hides its own actions. */
.section-review-surface { min-width: 0; }

.section-review-surface > .section-text {
  box-sizing: border-box;
  min-height: 220px;
  width: 100%;
}

.workup-editor-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 320px) auto;
  align-items: center;
  gap: 14px;
}

.workup-editor-select {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.workup-editor-select select { min-width: 0; }

.workup-editor-header-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.workup-catalog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.workup-catalog-actions .muted { font-size: 11px; }

.workup-catalog-search {
  display: grid;
  gap: 5px;
  min-width: 0;
  border-bottom: 1px solid var(--border);
  padding: 9px 0 10px;
}

.workup-catalog-search label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.workup-search-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
}

.workup-search-control input {
  min-width: 0;
  width: 100%;
  min-height: 32px;
}

.workup-search-control button {
  min-height: 32px;
  white-space: nowrap;
}

.workup-search-control button[hidden] { display: none; }

.workup-catalog-search > .muted { font-size: 10px; }

.workup-catalog-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
  border-bottom: 1px solid var(--border);
}

.workup-catalog-row[hidden] { display: none; }

.workup-catalog-row .check-row {
  min-width: 0;
  min-height: 50px;
  border: 0;
  border-radius: 0;
  padding: 8px 2px;
}

.workup-catalog-row.is-selected {
  background: var(--surface-tint);
}

.workup-catalog-row > button {
  margin: 0;
  white-space: nowrap;
}

.workup-row-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 4px;
}

.workup-row-actions .icon-button {
  flex: 0 0 30px;
  min-height: 30px;
  min-width: 30px;
  padding: 4px;
}

.workup-row-actions .workup-edit-button {
  color: var(--muted);
}

.workup-row-actions .workup-edit-button:hover:not(:disabled) {
  background: var(--surface-subtle);
  border-color: var(--border);
  color: var(--ink);
}

.workup-row-actions > button {
  margin: 0;
}

.workup-hidden-list {
  margin-top: 8px;
}

.workup-hidden-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--border);
}

.workup-catalog-row .check-row > span {
  display: grid;
  min-width: 0;
  overflow-wrap: break-word;
}

.workup-catalog-row .check-row > span > strong {
  line-height: 1.3;
}

.workup-catalog-row .check-row > span > .muted {
  white-space: nowrap;
}

@media (min-width: 1041px) {
  .workup-editor-surface {
    grid-template-rows: auto auto auto auto minmax(460px, 62dvh) auto auto auto auto auto;
    height: auto;
    min-height: 100%;
    overflow: visible;
  }

  .workup-editor-heading {
    grid-column: 2;
    grid-row: 1;
    margin: 16px 20px 0;
  }

  .workup-title-input {
    width: 100%;
    margin: 0;
    min-width: 0;
  }

  .workup-editor-select { justify-self: stretch; }

  .workup-catalog-menu {
    align-self: start;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
    height: min(760px, calc(100dvh - 116px));
    max-height: calc(100dvh - 116px);
    overflow: hidden;
  }

  .workup-catalog-popover,
  .workup-catalog-menu:not([open]) > .workup-catalog-popover {
    display: grid !important;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .workup-catalog-popover .workup-list {
    max-height: none;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .workup-columns {
    min-height: 0;
    height: min(760px, 62dvh);
    overflow: hidden;
    align-items: stretch;
  }

  .workup-column,
  .workup-item-scroll { min-height: 0; }

  .workup-column { height: 100%; }

  .workup-item-scroll {
    max-height: none;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .workup-footer-actions { position: static; }
}

@media (max-width: 1040px) {
  .workup-editor-heading {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .workup-editor-header-actions { justify-content: stretch; }

  .workup-editor-header-actions button { width: 100%; }

  .workup-title-input { width: 100%; margin: 0; }

  .workup-editor-select { grid-template-columns: auto minmax(0, 1fr); }
}

/* Each editable workup item gets a readable question row, an answer-choice
   row, and a compact action row. Textarea questions wrap instead of being
   clipped into a single narrow input beside the controls. */
.workup-editor-card [data-field="item-text"] {
  grid-column: 3 / -1;
  grid-row: 1;
  min-height: 48px;
  resize: vertical;
}

.workup-editor-card [data-field="item-choices"] {
  grid-column: 3;
  grid-row: 2;
}

.workup-editor-card [data-field="item-select"] {
  grid-column: 4;
  grid-row: 2;
  width: 82px;
}

.workup-editor-card .button-row {
  grid-column: 3 / -1;
  grid-row: 3;
  justify-content: flex-end;
}

.workup-editor-card .workup-item-details {
  grid-column: 3 / -1;
  grid-row: 4;
}

/* Keep each workup item readable at a glance: prompt first, answer
   configuration second, and row actions last. The older dense grid made
   unrelated fields compete for the same horizontal space. */
.workup-editor-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 12px;
}

.workup-editor-card:hover {
  background: var(--surface-subtle);
}

.workup-item-main {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
}

.workup-item-rail {
  display: grid;
  grid-template-columns: 24px 12px;
  align-items: start;
  gap: 0;
  padding-top: 18px;
}

.workup-item-rail .workup-drag-handle {
  grid-column: 1;
  grid-row: 1;
}

.workup-item-rail .workup-row-number {
  grid-column: 2;
  grid-row: 1;
  padding-top: 7px;
}

.workup-item-question,
.workup-item-choices,
.workup-item-select {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.workup-field-label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.workup-field-label .muted {
  font-size: 10px;
  font-weight: 400;
}

.workup-editor-card [data-field="item-text"] {
  grid-column: auto;
  grid-row: auto;
  min-height: 64px;
  line-height: 1.4;
  resize: vertical;
}

.workup-item-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  align-items: end;
  gap: 10px;
  min-width: 0;
  border-top: 1px solid var(--border);
  padding: 10px 0 0 44px;
}

.workup-editor-card [data-field="item-choices"],
.workup-editor-card [data-field="item-select"] {
  grid-column: auto;
  grid-row: auto;
  min-width: 0;
  min-height: 34px;
}

.workup-editor-card [data-field="item-select"] {
  width: 100%;
}

.workup-item-actions {
  display: flex;
  align-items: center;
  grid-column: 1 / -1;
  justify-content: flex-start;
  min-height: 34px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.workup-item-actions .button-row {
  flex-wrap: nowrap;
  gap: 2px;
}

.workup-item-actions .icon-button {
  min-width: 30px;
  min-height: 30px;
  padding: 4px;
}

.workup-editor-card .workup-item-details {
  grid-column: auto;
  grid-row: auto;
  margin-left: 44px;
}

@media (max-width: 680px) {
  .workup-editor-card {
    padding: 10px;
  }

  .workup-item-main {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 6px;
  }

  .workup-item-rail {
    grid-template-columns: 20px 10px;
    padding-top: 18px;
  }

  .workup-item-options {
    grid-template-columns: minmax(0, 1fr) 82px;
    gap: 8px;
    padding-left: 36px;
  }

  .workup-item-actions {
    grid-column: 1 / -1;
  }

  .workup-editor-card .workup-item-details {
    margin-left: 36px;
  }
}

/* Workup import flow: reduce repeated framing and make the safety gate the
   visual midpoint between paste and format/import actions. */
.workup-library-note {
  margin: 0 20px;
  font-size: 12px;
  line-height: 1.35;
}

.workup-workspace-mirror {
  align-items: start;
  gap: 6px 16px;
  padding: 10px 14px;
}

.workup-workspace-copy {
  gap: 2px;
}

.workup-workspace-copy > strong {
  font-size: 14px;
}

.workup-workspace-copy p {
  font-size: 13px;
  line-height: 1.35;
}

.workup-workspace-copy small {
  font-size: 11px;
  line-height: 1.3;
}

.workup-workspace-actions {
  padding-top: 1px;
}

.workup-import > summary {
  grid-template-columns: 24px minmax(0, 1fr) auto;
  min-height: 54px;
  padding: 11px 14px;
}

.workup-import-summary-marker {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 0;
  color: var(--accent);
}

.workup-import-summary-marker::before {
  content: none;
}

.workup-import[open] .workup-import-summary-marker::before {
  content: none;
}

.workup-import-summary-marker .icon {
  width: 17px;
  height: 17px;
  transition: transform 140ms ease;
}

.workup-import[open] .workup-import-summary-marker .icon {
  transform: rotate(90deg);
}

.workup-import-summary-copy {
  gap: 2px;
}

.workup-import-summary-copy strong {
  font-size: 14px;
}

.workup-import-summary-copy .muted {
  font-size: 12px;
}

.workup-import-summary-action {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.workup-import-body {
  gap: 0;
  padding: 0 14px 14px;
}

.workup-import-heading {
  align-items: start;
  gap: 12px;
  margin: 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 12px 0 11px;
}

.workup-import-heading h3 {
  margin: 0;
  font-size: 15px;
}

.workup-import-heading p {
  margin: 3px 0 0;
  font-size: 12px;
  line-height: 1.35;
}

.workup-import-heading .button-row {
  flex: none;
  gap: 8px;
}

.workup-import-heading button {
  white-space: nowrap;
}

.workup-import-body > #workupJsonImport {
  min-height: 108px;
  margin: 12px 0 0;
}

.workup-api-formatting {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-inline: 0;
  border-radius: 0;
  background: transparent;
  padding: 12px 0;
}

.workup-api-formatting .workup-deid-confirmation {
  min-height: 0;
  align-items: center;
  border: 0;
  background: transparent;
  padding: 0;
}

.workup-api-formatting .workup-deid-confirmation input {
  margin: 0;
}

.workup-api-action {
  align-items: center;
  gap: 10px;
}

.workup-api-action .muted {
  font-size: 12px;
}

.workup-api-guidance {
  margin-top: 12px;
}

.workup-json-note {
  margin-top: 12px;
  padding: 8px 10px;
  font-size: 12px;
}

.workup-reset-override {
  width: auto;
  justify-self: start;
  margin: 0 20px 16px;
  border-top: 1px solid var(--border);
  padding: 10px 0 0;
  color: var(--danger);
  font-weight: 600;
  text-align: left;
}

@media (max-width: 680px) {
  .workup-library-note,
  .workup-reset-override {
    margin-inline: 14px;
  }

  .workup-import > summary {
    grid-template-columns: 22px minmax(0, 1fr);
  }

  .workup-import-summary-action {
    grid-column: 2;
  }

  .workup-import-heading .button-row,
  .workup-api-action {
    align-items: stretch;
    justify-content: flex-start;
  }

  .workup-import-heading .button-row {
    flex-direction: column;
  }

  .workup-api-action button {
    width: 100%;
  }
}

/* Source-first Hospital Stay capture */
.source-first-stay .stay-content { background: #f8faf9; }

.source-first-stay .hospital-day-packet {
  display: grid;
  gap: 18px;
  background: var(--surface);
}

.source-day-heading {
  align-items: start;
  margin: 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.source-day-heading h2 { margin-bottom: 3px; }

.source-capture-composer {
  display: grid;
  gap: 12px;
  border: 1px solid #cbdedf;
  border-radius: 7px;
  background: #fbfdfd;
  padding: 16px;
}

.source-capture-composer .section-heading,
.saved-source-list .section-heading,
.packet-check .section-heading { margin: 0; }

.source-kind-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.source-kind-button {
  display: grid;
  gap: 2px;
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  color: var(--muted);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 650;
  text-align: left;
}

.source-kind-label { color: inherit; }

.source-kind-requirement {
  color: var(--muted);
  font-size: 10px;
  font-weight: 550;
}

.source-kind-button[data-review-requirement="required"] .source-kind-requirement {
  color: #865516;
}

.source-kind-button:nth-child(3n) { border-right: 0; }
.source-kind-button:nth-last-child(-n + 3) { border-bottom: 0; }
.source-kind-button:hover { background: #f1f7f6; color: var(--ink); }

.source-kind-button.selected {
  background: #e8f4f2;
  color: #075f64;
  box-shadow: inset 3px 0 0 var(--accent);
}

.source-draft-label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
}

.source-draft-label textarea {
  min-height: 188px;
  resize: vertical;
  background: var(--surface);
  font: inherit;
  font-weight: 400;
  line-height: 1.5;
}

[data-source-parse-preview]:empty { display: none; }

.source-parse-status {
  display: grid;
  grid-template-columns: minmax(150px, auto) minmax(0, 1fr);
  gap: 12px;
  border-top: 1px solid var(--border);
  padding-top: 11px;
  font-size: 12px;
}

.source-parse-status strong { color: var(--ink); }

.source-parse-review {
  display: grid;
  gap: 10px;
  margin-inline: -16px;
  border-block: 1px solid #cbdedf;
  background: #f3f8f7;
  padding: 13px 16px;
}

.source-parse-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.source-parse-heading p { margin: 3px 0 0; font-size: 11px; }

.source-parse-local {
  flex: none;
  color: #256a68;
  font-size: 11px;
  font-weight: 700;
}

.source-parse-help {
  max-width: 78ch;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.source-parse-review textarea {
  min-height: 220px;
  background: var(--surface);
}

.source-parse-sections {
  border-top: 1px solid #cbdedf;
}

.source-parse-section {
  display: grid;
  gap: 8px;
  padding-block: 12px;
  border-bottom: 1px solid #cbdedf;
}

.source-parse-section-heading {
  display: grid;
  gap: 2px;
}

.source-parse-section-heading .muted {
  font-size: 11px;
}

.source-parse-section textarea {
  min-height: 140px;
}

/* Free-text report placeholders: study name header + always-visible paste
   box. Sleek and scannable — no disclosure to open. */
.source-parse-section--needs-report {
  background: #fffdf5;
  border: 1px solid #e8dcc0;
  border-radius: 8px;
  padding: 12px;
  margin-block: 8px;
}

.source-parse-section--needs-report .source-parse-section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.source-parse-section--needs-report .source-parse-section-heading strong {
  font-size: 14px;
}

.needs-report-pill {
  font-size: 11px;
  font-weight: 600;
  color: #8a6d1b;
  background: #fef3d6;
  border: 1px solid #e8dcc0;
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

.source-parse-section--needs-report .muted {
  font-size: 12px;
  margin: 0;
}

.source-parse-section--needs-report textarea {
  min-height: 90px;
  font-size: 13px;
}

.clinical-data-view {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.saved-clinical-display {
  margin: 2px 0 8px;
}

.saved-clinical-display .clinical-data-view {
  border-color: var(--border-strong, var(--border));
}

.clinical-data-view__heading,
.clinical-data-group__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
}

.clinical-data-view__heading {
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}

.clinical-data-view__heading strong,
.clinical-data-group__heading strong { color: var(--ink); font-size: 12px; }
.clinical-data-view__heading span,
.clinical-data-group__heading span { color: var(--muted); font-size: 10px; }

.clinical-data-group {
  display: grid;
  min-width: 0;
}

.clinical-data-group + .clinical-data-group { border-top: 1px solid var(--border); }
.clinical-data-view [hidden] { display: none !important; }
.clinical-data-table-wrap { min-width: 0; overflow-x: auto; }

.clinical-data-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text);
  font-size: 11px;
}

.clinical-data-table th,
.clinical-data-table td {
  padding: 7px 10px;
  border-top: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.clinical-data-table thead th {
  color: var(--muted);
  background: var(--surface-subtle);
  font-size: 10px;
  font-weight: 650;
}

.clinical-data-table tbody th { color: var(--ink); font-weight: 650; }

.clinical-lab-navigation,
.clinical-medication-controls,
.clinical-medication-controls nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.clinical-lab-navigation {
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding: 6px 10px;
  color: var(--muted);
  font-size: 11px;
}

.clinical-medication-controls {
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
}

.clinical-medication-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: min(100%, 420px);
  color: var(--muted);
  font-size: 11px;
}

.clinical-medication-controls input { min-width: 0; flex: 1; }
.clinical-medication-controls nav { color: var(--muted); font-size: 11px; white-space: nowrap; }

[data-clinical-view="medications"] .clinical-data-table th,
[data-clinical-view="medications"] .clinical-data-table td {
  max-width: 320px;
  white-space: normal;
}

.clinical-vital-summary {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding: 10px;
}

.clinical-vital-summary__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
}

.clinical-vital-summary__heading span { color: var(--muted); font-size: 10px; }
.clinical-vital-summary__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 7px; }

.clinical-vital-stat {
  display: grid;
  gap: 2px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  padding: 7px 8px;
  /* U1: equal card heights in the summary grid. */
  height: 100%;
  align-content: start;
}

.clinical-vital-stat strong { color: var(--ink); font-size: 10px; }
.clinical-vital-stat span { color: var(--text); font-size: 12px; }
.clinical-vital-stat small { color: var(--muted); font-size: 9px; }

.clinical-data-table tr[data-clinical-emphasis="high"],
.clinical-data-table tr[data-clinical-emphasis="low"],
.clinical-data-table tr[data-clinical-emphasis="abnormal"] {
  border-left: 3px solid var(--warning);
  background: var(--warning-bg);
}

.clinical-data-table tr[data-clinical-emphasis="high"] td:last-child,
.clinical-data-table tr[data-clinical-emphasis="low"] td:last-child,
.clinical-data-table tr[data-clinical-emphasis="abnormal"] td:last-child {
  color: #865516;
  font-weight: 750;
}

.clinical-trends {
  display: grid;
  gap: 7px;
  border-top: 1px solid var(--border);
  padding: 10px;
}

.clinical-trends > strong { color: var(--ink); font-size: 11px; }
.clinical-trends > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }

.clinical-trend {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(100px, 160px) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 5px;
  font-size: 10px;
}

.clinical-trend__label { overflow: hidden; color: var(--ink); font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.clinical-trend__range { color: var(--muted); white-space: nowrap; }
.clinical-trend svg { width: 100%; height: 32px; overflow: visible; }
.clinical-trend polyline { fill: none; stroke: var(--accent); stroke-width: 1.8; vector-effect: non-scaling-stroke; }
.clinical-trend circle { fill: var(--surface); stroke: var(--accent); stroke-width: 1.4; vector-effect: non-scaling-stroke; }

.clinical-prompt-details {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.clinical-prompt-details summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.clinical-prompt-details summary span { color: var(--muted); font-weight: 500; }
.clinical-prompt-details[open] { display: grid; gap: 8px; }
.clinical-prompt-details[open] summary { margin-bottom: 2px; }

.source-draft-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.source-draft-footer .muted { max-width: 64ch; font-size: 11px; }

.saved-source-list { display: grid; gap: 10px; }
.source-capture-list { display: grid; gap: 0; }

.source-capture-editor {
  min-height: 58px;
  padding: 10px 8px;
}

.source-capture-editor .source-capture-toolbar {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.source-capture-identity { display: grid; min-width: 0; gap: 2px; }
.source-capture-identity strong { color: var(--ink); font-size: 13px; }
.source-capture-editor:not(.is-expanded) .source-kind-control { display: none; }

.primary-note-source-summary {
  min-height: 58px;
  padding: 10px 8px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.primary-note-source-summary:first-child { border-top: none; }
.primary-note-source-summary .source-capture-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.source-kind-control {
  display: grid;
  grid-template-columns: auto minmax(180px, 280px);
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 12px;
}

.packet-check {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

/* Batch C (audit F11): the completeness panel is a collapsed disclosure.
   Its summary keeps the heading and the at-a-glance count banner visible;
   the full checklist sits in the body, hidden until expanded. */
.packet-check > summary.packet-check-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.packet-check > summary.packet-check-summary::-webkit-details-marker { display: none; }

.packet-check > summary.packet-check-summary::after {
  content: "▾";
  color: var(--muted);
  font-size: 12px;
  transition: transform 120ms ease;
}

.packet-check[open] > summary.packet-check-summary::after { transform: rotate(180deg); }

.packet-check-summary__heading {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

.packet-check-summary .packet-review-summary {
  flex: 1 1 auto;
  min-width: 0;
}

/* The display rule is scoped to [open]: an author display value on a direct
   child of a closed <details> overrides the user-agent rule that hides it. */
.packet-check[open] > .packet-check-body {
  display: grid;
  gap: 10px;
}

.packet-review-summary {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--surface-subtle);
  padding: 10px 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.packet-review-summary[data-packet-review-state="attention"] {
  border-left-color: var(--warning);
  background: var(--warning-bg);
}

.packet-review-summary__indicator {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid currentColor;
  border-radius: 50%;
  color: var(--accent);
  font-size: 13px;
  line-height: 1;
}

[data-packet-review-state="attention"] .packet-review-summary__indicator {
  color: #865516;
}

.packet-review-list {
  display: grid;
  margin: 0;
  padding: 0;
  border-block: 1px solid var(--border);
  list-style: none;
}

.packet-review-item {
  display: grid;
  grid-template-columns: 22px minmax(150px, 1fr) 82px 90px;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 7px 2px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.packet-review-item:last-child { border-bottom: 0; }
.packet-review-item__label { color: var(--ink); }
.packet-review-item__requirement { font-size: 11px; }
.packet-review-item__status { text-align: right; }

.packet-review-item__indicator {
  color: var(--accent);
  font-weight: 800;
  text-align: center;
}

.packet-review-item--missing[data-review-requirement="required"] {
  border-left: 2px solid var(--warning);
  background: var(--warning-bg);
}

.packet-review-item--missing[data-review-requirement="required"] .packet-review-item__indicator,
.packet-review-item--missing[data-review-requirement="required"] .packet-review-item__status,
.packet-review-item--missing[data-review-requirement="required"] .packet-review-item__requirement {
  color: #865516;
  font-weight: 700;
}

.day-row-meta {
  display: grid;
  justify-items: end;
  gap: 2px;
}

.day-row-review {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.35;
  max-width: 100%;
}

.day-row-review--attention { color: #865516; }

.packet-check-list { display: grid; margin: 0; border-block: 1px solid var(--border); }

.packet-check-list > div {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 14px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--border);
}

.packet-check-list > div:last-child { border-bottom: 0; }
.packet-check-list dt { color: var(--ink); font-size: 12px; font-weight: 700; }
.packet-check-list dd { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.packet-check-missing dt { color: #8a5a12; }
.packet-check-review dt { color: #8b3d3d; }

@media (max-width: 680px) {
  .hospital-day-packet { padding: 14px; }
  .source-day-heading { gap: 10px; }
  .source-day-heading,
  .source-draft-footer { align-items: stretch; flex-direction: column; }
  .source-parse-heading { align-items: start; flex-direction: column; gap: 5px; }
  .source-parse-status { grid-template-columns: 1fr; gap: 3px; }
  .source-day-heading .button-row,
  .source-draft-footer .button--primary { width: 100%; }
  .source-kind-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .source-kind-button:nth-child(3n) { border-right: 1px solid var(--border); }
  .source-kind-button:nth-child(2n) { border-right: 0; }
  .source-kind-button:nth-last-child(-n + 3) { border-bottom: 1px solid var(--border); }
  .source-kind-button:nth-last-child(-n + 2) { border-bottom: 0; }
  .source-capture-editor .source-capture-toolbar { align-items: flex-start; }
  .source-capture-editor .button-row { flex: none; }
  .packet-check-list > div { grid-template-columns: 1fr; gap: 3px; }
  .packet-review-item { grid-template-columns: 22px minmax(0, 1fr) auto; }
  .packet-review-item__status { grid-column: 2 / -1; text-align: left; }
  .clinical-data-view__heading,
  .clinical-data-group__heading { align-items: flex-start; flex-direction: column; gap: 2px; }
  .clinical-medication-controls,
  .clinical-vital-summary__heading { align-items: stretch; flex-direction: column; }
  .clinical-medication-controls label { min-width: 100%; }
  .clinical-medication-controls nav { justify-content: space-between; }
  .clinical-trends > div { grid-template-columns: 1fr; }
  .clinical-trend { grid-template-columns: minmax(84px, 1fr) minmax(90px, 140px) auto; }
}

/* Guided-demo targets need to be unmistakable without relying on motion. */
.guided-demo-instructions {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  margin-top: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.guided-demo-action {
  color: var(--ink);
  font-weight: 600;
}

.guided-demo-note {
  color: var(--muted);
}

.guided-demo-callout {
  position: fixed;
  z-index: 100;
  width: min(320px, calc(100vw - 32px));
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 14px 15px;
  border: 1px solid color-mix(in srgb, var(--accent) 36%, var(--border));
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 14px 34px rgb(28 52 68 / 18%);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.42;
  pointer-events: none;
}

.guided-demo-callout strong { font-size: 13px; }
.guided-demo-callout p { margin: 0; color: var(--muted); }

.guided-demo-callout::before,
.guided-demo-callout::after {
  position: absolute;
  width: 0;
  height: 0;
  content: "";
  border: 8px solid transparent;
}

.guided-demo-callout[data-placement="right"]::before {
  top: var(--demo-arrow-y, 50%);
  left: -16px;
  margin-top: -8px;
  border-right-color: color-mix(in srgb, var(--accent) 36%, var(--border));
}
.guided-demo-callout[data-placement="right"]::after {
  top: var(--demo-arrow-y, 50%);
  left: -14px;
  margin-top: -8px;
  border-right-color: var(--surface);
}
.guided-demo-callout[data-placement="left"]::before {
  top: var(--demo-arrow-y, 50%);
  right: -16px;
  margin-top: -8px;
  border-left-color: color-mix(in srgb, var(--accent) 36%, var(--border));
}
.guided-demo-callout[data-placement="left"]::after {
  top: var(--demo-arrow-y, 50%);
  right: -14px;
  margin-top: -8px;
  border-left-color: var(--surface);
}
.guided-demo-callout[data-placement="bottom"]::before {
  top: -16px;
  left: var(--demo-arrow-x, 50%);
  margin-left: -8px;
  border-bottom-color: color-mix(in srgb, var(--accent) 36%, var(--border));
}
.guided-demo-callout[data-placement="bottom"]::after {
  top: -14px;
  left: var(--demo-arrow-x, 50%);
  margin-left: -8px;
  border-bottom-color: var(--surface);
}
.guided-demo-callout[data-placement="top"]::before {
  bottom: -16px;
  left: var(--demo-arrow-x, 50%);
  margin-left: -8px;
  border-top-color: color-mix(in srgb, var(--accent) 36%, var(--border));
}
.guided-demo-callout[data-placement="top"]::after {
  bottom: -14px;
  left: var(--demo-arrow-x, 50%);
  margin-left: -8px;
  border-top-color: var(--surface);
}

.presentation-editor-input {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.presentation-editor-input h3 { margin: 0; font-size: 14px; }
.presentation-editor-input p { margin: 3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.presentation-specialty-input { display: grid; gap: 5px; font-size: 12px; font-weight: 700; }
.presentation-specialty-input input { width: 100%; background: var(--surface); }
.presentation-editor-input textarea { min-height: 150px; max-height: 320px; resize: vertical; background: var(--surface); }
.presentation-editor-input__heading { display: grid; gap: 2px; }
.presentation-editor-input__optional {
  display: inline-flex;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  vertical-align: 1px;
}

.guided-demo-bar {
  border-width: 1px;
  border-left-width: 4px;
}

.demo-next-action {
  position: relative;
  z-index: 2;
  border-color: var(--accent) !important;
  outline: 3px solid var(--warning);
  outline-offset: 4px;
  box-shadow: 0 0 0 7px var(--surface);
  scroll-margin-block: 160px;
}

.demo-next-action[data-demo-target="true"]:not(.primary-button):not(.button--primary):not(.aic-send) {
  background-color: #fffdf2;
}

/* Final workup utility layout.  The editor reserves row 5 for the two
   independently scrollable item columns; the utility surface must begin only
   after that row.  Older direct-child grid assignments remain elsewhere in
   this stylesheet, so reset them inside the new wrapper explicitly. */
.workup-editor-surface > .workup-utilities {
  grid-column: 1 / -1;
  grid-row: 6 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-rows: auto;
  gap: 10px;
  align-content: start;
  margin: 0 20px 16px;
  min-width: 0;
}

.workup-editor-surface > .workup-catalog-menu {
  grid-row: 1 / 6;
}

.workup-utilities > .workup-footer-actions,
.workup-utilities > .workup-library-note,
.workup-utilities > .workup-workspace-mirror,
.workup-utilities > .workup-import,
.workup-utilities > .workup-reset-override {
  grid-column: auto;
  grid-row: auto;
}

.workup-utilities > .workup-footer-actions {
  position: static;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 3px 12px rgb(27 55 75 / 4%);
  padding: 9px 10px;
}

.workup-utilities > .workup-footer-actions .workup-action-group {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
}

.workup-utilities > .workup-footer-actions .workup-prompt-actions {
  border: 0;
  border-right: 1px solid var(--border);
  padding: 0 12px 0 0;
}

.workup-utilities > .workup-footer-actions .workup-file-actions {
  flex: 1 1 auto;
  justify-content: flex-end;
  border: 0;
  padding: 0;
}

.workup-utilities > .workup-footer-actions button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.workup-utilities > .workup-footer-actions .workup-save-button {
  width: auto;
  justify-self: auto;
}

.workup-utilities > .workup-library-note {
  width: auto;
  margin: 0;
  font-size: 11px;
}

.workup-utilities > .workup-workspace-mirror {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 11px 14px;
}

.workup-utilities > .workup-workspace-mirror small {
  grid-column: auto;
}

.workup-utility-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: var(--accent);
}

.workup-utility-icon .icon {
  width: 24px;
  height: 24px;
}

.workup-utilities > .workup-import {
  width: 100%;
  margin: 0;
}

.workup-utilities > .workup-reset-override {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-self: stretch;
  gap: 10px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 10px 14px;
}

.workup-utilities > .workup-reset-override .icon {
  width: 20px;
  height: 20px;
}

.workup-utilities > .workup-import {
  border-radius: 10px;
  padding: 0;
}

.workup-utilities > .workup-import > summary {
  min-height: 54px;
  padding: 9px 14px;
}

.workup-utilities .workup-import-summary-marker .icon {
  width: 23px;
  height: 23px;
  transform: none;
}

.workup-utilities .workup-import-summary-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.workup-utilities .workup-import-summary-action .icon {
  width: 15px;
  height: 15px;
  transition: transform 140ms ease;
}

.workup-utilities .workup-import[open] .workup-import-summary-action .icon {
  transform: rotate(90deg);
}

@media (max-width: 1100px) {
  .workup-utilities > .workup-footer-actions {
    flex-wrap: wrap;
  }

  .workup-utilities > .workup-footer-actions .workup-file-actions {
    flex: 1 1 100%;
    justify-content: flex-start;
    border-top: 1px solid var(--border);
    padding-top: 10px;
  }
}

@media (max-width: 1040px) {
  .workup-editor-surface > .workup-utilities {
    grid-column: 1;
    grid-row: auto;
    margin-inline: 14px;
  }
}

@media (max-width: 680px) {
  .workup-utilities > .workup-footer-actions,
  .workup-utilities > .workup-footer-actions .workup-file-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .workup-utilities > .workup-footer-actions .workup-action-group {
    width: 100%;
    flex: 1 1 auto;
    align-items: stretch;
    flex-direction: column;
  }

  .workup-utilities > .workup-footer-actions .workup-prompt-actions {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 0 0 10px;
  }

  .workup-utilities > .workup-footer-actions button {
    width: 100%;
  }

  .workup-utilities > .workup-workspace-mirror {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .workup-utilities > .workup-workspace-mirror > .workup-utility-icon {
    display: none;
  }
}

@media (max-width: 680px) {
  .guided-demo-instructions {
    font-size: 12px;
  }

  .demo-next-action {
    outline-width: 2px;
    outline-offset: 3px;
    box-shadow: 0 0 0 5px var(--surface);
  }
}

/* Checklist start state: this route has one clear next step until a workup
   has been selected and explicitly built into a checklist. */
.checklist-start-state {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 14px;
  row-gap: 18px;
  width: min(100%, 860px);
  min-height: 260px;
  margin: 28px auto;
  border-color: var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 28px 30px;
}

.checklist-start-icon {
  display: grid;
  grid-column: 1;
  grid-row: 1;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-tint);
  color: var(--accent);
}

.checklist-start-icon .icon {
  width: 22px;
  height: 22px;
}

.checklist-start-copy {
  grid-column: 2;
}

.checklist-start-copy h2 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
}

.checklist-start-copy p {
  max-width: 560px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.checklist-start-action {
  grid-column: 3;
  grid-row: 1;
  white-space: nowrap;
}

.checklist-start-steps {
  display: flex;
  grid-column: 2 / -1;
  align-items: center;
  gap: 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding-top: 16px;
}

.checklist-start-steps span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 18px;
  border-right: 1px solid var(--border);
}

.checklist-start-steps span:first-child { padding-left: 0; }
.checklist-start-steps span:last-child { border-right: 0; }

.checklist-start-steps b {
  color: var(--accent);
  font-size: 11px;
}

@media (max-width: 680px) {
  .checklist-start-state {
    grid-template-columns: 44px minmax(0, 1fr);
    margin: 14px 0;
    padding: 22px 18px;
  }

  .checklist-start-action {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  .checklist-start-steps {
    grid-column: 1 / -1;
    grid-row: 3;
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .checklist-start-steps span {
    padding: 0;
    border-right: 0;
  }
}

/* Compact review UI v2 (2026-09-24): dense lab rows, scaffold editor,
   collapsible lab families, optional-section toggles. */

/* Dense single-line lab rows replacing the old lab cells. */
.lab-rows {
  display: grid;
  gap: 2px;
}

.lab-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
}

.lab-row:nth-child(odd) {
  background: var(--surface-subtle);
}

.lab-row.is-selected {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

/* A temperature whose unit was never stated cannot be checked into the note
   until the student confirms °F/°C in the banner above. */
.lab-row.is-unit-unmarked {
  background: #fffbeb;
  box-shadow: inset 0 0 0 1.5px #d97706;
}

.lab-row-check {
  display: inline-flex;
  margin: 0;
}

.lab-row-check input {
  margin: 0;
}

.lab-row-name {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  min-width: 0;
}

.lab-row-flag {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
}

.lab-row-value {
  white-space: nowrap;
}

.lab-row-value strong {
  font-weight: 750;
}

.lab-row[data-clinical-emphasis="high"] .lab-row-value strong,
.lab-row[data-clinical-emphasis="low"] .lab-row-value strong,
.lab-row[data-clinical-emphasis="abnormal"] .lab-row-value strong,
.lab-row[data-clinical-emphasis="critical"] .lab-row-value strong {
  color: var(--danger);
}

.lab-row-meta {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.74rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46%;
}

.lab-row .lab-baseline-editor {
  flex-basis: 100%;
  border-top: 1px dashed var(--border);
  margin-top: 4px;
  padding-top: 8px;
}

/* Collapsible lab-family / flagged-section headings. */
.lab-family-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.lab-family-toggle:hover .lab-family-caret {
  color: var(--accent);
}

.lab-family-caret {
  color: var(--muted);
  font-size: 0.8rem;
  width: 1em;
  text-align: center;
}

.lab-family-toggle h3 {
  margin: 0;
}

/* Note-draft scaffolds: one compact card per core section, always included. */
.note-scaffold {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 10px 12px;
}

.note-scaffold + .note-scaffold {
  margin-top: 10px;
}

.note-scaffold-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-bottom: 8px;
}

.note-scaffold-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.note-scaffold-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.note-preview-scaffold {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

/* Optional-section on/off toggle (closing sections only). */
.scaffold-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  color: var(--muted-strong);
  cursor: pointer;
  white-space: nowrap;
}

.scaffold-toggle input {
  margin: 0;
}

.closing-field-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Medication list in the draft editor's Medications scaffold. */
.scaffold-med-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: grid;
  gap: 4px;
}

.scaffold-med-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
}

.scaffold-med-list li:nth-child(odd) {
  background: var(--surface-subtle);
}

@media (max-width: 1100px) {
  .review-columns {
    grid-template-columns: 1fr;
  }

  .review-data-panel {
    position: static;
    max-height: none;
  }

  .review-columns .note-draft-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .note-draft-panel .note-editor {
    overflow: visible;
  }
}

/* Auto-dismissing toast notifications (pull-from-primary feedback, etc.).
   Fixed to the bottom-right corner so a toast never covers the
   navigation (audit F10); slides up, then out. */
#toastContainer {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
  max-width: min(92vw, 560px);
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 100%;
}
.toast--visible {
  opacity: 1;
  transform: translateY(0);
}
.toast--warning {
  background: #fff7e6;
  border: 1px solid #e8a13d;
  color: #7a4a00;
}
.toast--success {
  background: #eefbf1;
  border: 1px solid #3da35d;
  color: #14532d;
}
.toast--error {
  background: #fdeeee;
  border: 1px solid #d64545;
  color: #7a1f1f;
}
.toast-dismiss {
  flex: none;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  color: inherit;
  opacity: 0.6;
  padding: 2px 4px;
  border-radius: 4px;
}
.toast-dismiss:hover { opacity: 1; }

/* ─── Structured exam-findings picker ─────────────────────────────── */
.exam-findings-picker {
  margin: 8px 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px 10px;
  font-size: 12px;
}
.ef-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.ef-toolbar-label {
  font-weight: 700;
  color: var(--text);
}
.ef-all-normal {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.ef-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
}
/* ─── Smart physical-exam editor (inline smart variables) ────────── */
.smart-exam { display: flex; flex-direction: column; gap: 8px; }
.se-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.se-template-picker { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.se-template-picker select { font-size: 12px; padding: 2px 4px; }
.se-systems { display: flex; flex-direction: column; gap: 8px; }
.se-system { border: 1px solid var(--border, #e2e2e2); border-radius: 8px; padding: 8px 10px; }
.se-system-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.se-system-actions { display: inline-flex; gap: 4px; }
/* Epic-style free-text exam editor: the student types anywhere; smart
   variables are atomic inline placeholders. */
.se-editor {
  margin: 0; font-size: 13px; line-height: 1.65;
  border: 1px solid var(--border, #ddd); border-radius: 8px;
  padding: 8px 10px; min-height: 44px; background: var(--bg, #fff);
}
.se-editor:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.se-editor:empty:before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.se-var-wrap { position: relative; display: inline-block; white-space: nowrap; }
.se-pill {
  display: inline-block; border: 1px dashed var(--accent); border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: inherit; font-size: 12px; padding: 0 8px; cursor: pointer; line-height: 1.7;
  user-select: none;
}
.se-pill.is-filled {
  border-style: solid; background: color-mix(in srgb, var(--accent) 16%, transparent);
  font-weight: 600;
}
.se-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Compact smart-variable dropdown. */
.se-dropdown {
  position: absolute; z-index: 40; left: 0; top: calc(100% + 4px); min-width: 220px; max-width: 300px;
  background: var(--bg, #fff); border: 1px solid var(--border, #ddd); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.14); display: flex; flex-direction: column;
  font-size: 12px; user-select: none;
}
.se-dropdown-scroll { display: flex; flex-direction: column; max-height: 220px; overflow-y: auto; padding: 3px; }
.se-opt-group {
  font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 4px 6px 2px;
}
.se-opt {
  display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 6px;
  font-size: 12px; line-height: 1.35; cursor: pointer; white-space: normal;
}
.se-opt input[type="checkbox"] { width: 14px; height: 14px; margin: 0; flex: none; accent-color: var(--accent); cursor: pointer; }
.se-opt:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.se-opt.is-normal span { font-weight: 600; }
.se-custom-pick {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 3px 6px; border-radius: 6px; font-size: 12px; font-style: italic;
}
.se-custom-x {
  border: none; background: none; cursor: pointer; color: var(--muted);
  font-size: 14px; line-height: 1; padding: 0 2px;
}
.se-custom-x:hover { color: var(--danger, #c0392b); }
.se-custom-row {
  display: flex; gap: 4px; padding: 4px 6px; border-top: 1px solid var(--border, #eee); align-items: center;
}
.se-custom-input { flex: 1; min-width: 0; font-size: 12px; padding: 3px 6px; border: 1px solid var(--border, #ddd); border-radius: 6px; }
.se-notes-label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.se-notes {
  width: 100%; font-size: 13px; padding: 6px 8px; border: 1px solid var(--border, #ddd);
  border-radius: 8px; resize: vertical; font-family: inherit;
}

/* ─── Collapsible draft-note sections (I1) ─────────────────────────── */
/* A11y: section header uses grid — <summary> stays a direct child of
   <details> (required for native disclosure toggle). Interactive controls
   live in .ed-section-actions, a sibling of <summary>, never inside it. */
details.ed-section {
  position: relative;
  display: block;
}
details.ed-section > summary.ed-section-summary {
  display: block;
  padding-right: 80px;
  min-width: 0;
}
details.ed-section > .ed-section-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
details.ed-section > .ed-section-body {
  display: block;
  min-width: 0;
}
details.ed-section .ed-section-summary {
  cursor: pointer;
  list-style: none;
  display: block;
}
details.ed-section .ed-section-summary::-webkit-details-marker { display: none; }
details.ed-section .ed-section-summary::before {
  content: "▾";
  display: inline-block;
  width: 14px;
  color: var(--muted);
  font-size: 10px;
  margin-right: 2px;
}
details.ed-section:not([open]) .ed-section-summary::before { content: "▸"; }
details.ed-section .ed-section-summary .ed-label { display: inline-flex; }

/* ─── Batch D: compact empty sections, problem drag grip ─── */
/* F13: an empty optional section is one compact row (chevron, label, Add
   button, header actions) instead of the full section chrome plus an empty
   placeholder body. */
.ed-section-empty-add {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ed-section-empty-add .ed-label { display: inline-flex; margin-bottom: 0; }
.ed-section-empty-add .ed-section-chevron {
  width: 14px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
  flex: none;
}
.ed-section-empty-add .ed-section-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ed-section-empty-add .ed-toggle { margin-left: 0; }
.ed-empty-add {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: 0;
  min-height: 26px;
  padding: 2px 4px;
  cursor: pointer;
  white-space: nowrap;
}
.ed-empty-add:hover { text-decoration: underline; }

/* F8: drag grip on each problem card. The bar keeps its title left and its
   action row right; the dragged card is visibly marked while it moves. */
.plan-problem-card .ed-problem-bar { justify-content: flex-start; }
.plan-problem-card .ed-problem-bar .ed-mini-row { margin-left: auto; }
.ed-problem-drag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: grab;
  touch-action: none;
  flex: none;
}
.ed-problem-drag:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); }
.ed-problem-drag:active { cursor: grabbing; }
.ed-problem-drag .icon { width: 14px; height: 14px; }
.plan-problem-card.is-dragging {
  opacity: 0.55;
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

/* ─── Persistent patient identity bar (NIST S1) ────────────────────── */
/* Patient identifiers in a reserved area at the top, persisting regardless
   of scrolling or navigation — the passive wrong-patient safeguard. */
.patient-identity-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 12px;
  margin: 0 -12px 8px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 65%, transparent);
  font-size: 13px;
}
.patient-identity-bar-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- Per-problem AI Assessment & Plan generation ---- */
.ap-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 1rem;
}
.ap-confirm-modal {
  background: var(--panel, #fff);
  border-radius: 12px;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow: auto;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.ap-confirm-modal h3 {
  margin: 0 0 0.5rem;
}
.ap-confirm-context {
  background: var(--input-bg, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 0.75rem;
  margin: 0.75rem 0;
  max-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 0.85rem;
  font-family: ui-monospace, monospace;
}
.ap-confirm-note {
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
/* Editable AI prompt: the exact text that will be sent. */
/* Consult questions textbox in A&P generation modal */
.ap-consult-questions {
  margin: 12px 0;
}
.ap-consult-questions label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
}
.ap-consult-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border, #d1d5db);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
}
.ap-consult-input:focus {
  outline: 2px solid var(--primary, #0d6efd);
  outline-offset: -1px;
  border-color: var(--primary, #0d6efd);
}
.ap-consult-hint {
  margin-top: 4px;
  font-size: 12px;
}

.ap-prompt-editor {
  width: 100%;
  box-sizing: border-box;
  background: var(--input-bg, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 0.75rem;
  margin: 0.75rem 0;
  min-height: 280px;
  max-height: 46vh;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 0.85rem;
  font-family: ui-monospace, monospace;
  resize: vertical;
}
.ap-prompt-editor:focus {
  outline: 2px solid var(--accent, #2563eb);
  outline-offset: 1px;
}
/* Google-Docs-style suggestion list on a problem card. */
.ap-suggestions {
  border-top: 1px dashed var(--border, #e2e8f0);
  margin-top: 0.75rem;
  padding-top: 0.5rem;
}
.ap-suggestions-head {
  font-weight: 600;
  margin: 0 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.ap-suggestion {
  border: 1px solid var(--border, #e2e8f0);
  border-left: 4px solid var(--accent, #2563eb);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--panel-alt, #fbfdff);
}
.ap-suggestion-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
}
.ap-suggestion-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  color: #fff;
}
.ap-suggestion-badge--add { background: #15803d; }
.ap-suggestion-badge--revise { background: #b45309; }
.ap-suggestion-badge--remove { background: #b91c1c; }
.ap-suggestion-target {
  font-weight: 600;
  font-size: 0.85rem;
}
.ap-suggestion-actions {
  margin-left: auto;
  display: flex;
  gap: 0.35rem;
}
.ed-mini--approve {
  color: #15803d;
  border-color: #15803d;
}
.ap-suggestion-change {
  margin: 0.25rem 0;
  font-size: 0.9rem;
}
.ap-suggestion-change s {
  color: #b91c1c;
  text-decoration-thickness: 2px;
}
.ap-suggestion-new {
  color: #15803d;
  font-weight: 600;
  display: block;
  margin-top: 0.15rem;
}
.ap-suggestion-rationale {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--muted, #64748b);
}
.ap-suggestion-refs {
  margin-top: 0.5rem;
  font-size: 0.85rem;
}
/* AI-generated plan content inside the note editors */
.ap-plan-list {
  margin: 0.25rem 0 0.5rem;
  padding-left: 1.25rem;
}
.ap-plan-list li {
  margin-bottom: 0.3rem;
}
.ap-rationale {
  color: var(--muted);
}
.ap-cite sup, sup.ap-cite {
  font-size: 0.7em;
}
.ap-cite a {
  text-decoration: none;
}
.ap-refs-head {
  font-weight: 700;
  margin: 0.75rem 0 0.25rem;
  font-size: 0.9rem;
}
.ap-refs {
  margin: 0 0 0.5rem;
  padding-left: 1.5rem;
  font-size: 0.85rem;
}
.ap-refs li {
  margin-bottom: 0.2rem;
}

/* Local AI view (browser-local LLM: note parsing + chat) */
.local-ai-specs {
  display: grid;
  gap: 6px;
  margin: 0;
}
.local-ai-specs > div {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 12px;
}
.local-ai-specs dt {
  color: var(--muted, #6b7280);
  font-size: 13px;
}
.local-ai-specs dd {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}
.local-ai-models {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.local-ai-model-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.local-ai-model-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.local-ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: var(--text);
}
.local-ai-badge--ready {
  background: color-mix(in srgb, #16a34a 18%, var(--surface));
}
.local-ai-progress {
  display: grid;
  gap: 4px;
  flex: 1;
  min-width: 200px;
  font-size: 13px;
}
.local-ai-progress progress {
  width: 100%;
}
.local-ai-warning {
  color: var(--warning-text, #92400e);
  font-size: 13px;
}
.local-ai-error {
  color: var(--danger, #b3261e);
  font-size: 13px;
}
.local-ai-note {
  font-size: 12px;
}
.local-ai-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  margin-top: 8px;
}
.local-ai-chat-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.local-ai-messages {
  display: grid;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}
.local-ai-message {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface);
}
.local-ai-message--user {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}
.local-ai-message p {
  margin: 4px 0 0;
  white-space: pre-wrap;
  font-size: 14px;
}
.local-ai-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}
.local-ai-caret {
  animation: local-ai-blink 1s steps(2) infinite;
}
@keyframes local-ai-blink {
  50% { opacity: 0; }
}
/* Local-AI affordances inside the structured-note paste panel */
.structured-note-provenance {
  font-size: 13px;
  padding: 6px 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.structured-note-local-ai {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 13px;
}
.structured-note-local-ai-button {
  margin: 4px 16px 12px;
}

/* Models tab: clinical score calculators + AI models. */
.scores-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
}
.scores-page-heading {
  margin-bottom: 16px;
}
/* Calculators search — same treatment as the Cheat Sheets search bar:
   sticky at the top of the view, and typing filters the list live. */
.scores-searchbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; padding: 0 12px; margin: 8px 0; }
.scores-searchbar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.scores-search-icon { color: var(--muted); flex: none; display: inline-flex; width: 18px; height: 18px; }
.scores-search-icon svg { width: 100%; height: 100%; display: block; }
.scores-search { flex: 1; min-width: 0; min-height: 44px; border: 0; background: transparent; font-size: 1rem; color: var(--text); }
.scores-search:focus { outline: none; }
.scores-search-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.scores-count { color: var(--muted); font-size: 0.85rem; margin: 0 2px; }
.scores-empty { color: var(--muted); margin: 16px 2px; }
.scores-page-heading h2 {
  margin: 0 0 4px;
}
.scores-section-heading {
  margin: 24px 0 12px;
  font-size: 1.1rem;
}
.scores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.score-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s;
}
.score-card:hover {
  border-color: var(--primary);
}
.score-card h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}
.score-card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.score-back {
  margin-bottom: 12px;
}
.score-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.score-field {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 0;
}
.score-field-label {
  font-weight: 600;
  margin-bottom: 8px;
  display: block;
}
.score-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 4px;
}
.score-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.score-option {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: center;
}
.score-option.is-selected {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
}
.score-option input {
  accent-color: var(--primary);
}
.score-input {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.score-number-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}
.score-unit {
  color: var(--muted);
  font-size: 0.85rem;
}
.score-result {
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 16px;
  background: var(--surface);
}
.score-result-headline {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 8px;
}
.score-result-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.score-save {
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary);
  background: transparent;
  color: var(--primary);
  cursor: pointer;
}
.score-save:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
}
.score-save:disabled {
  opacity: 0.6;
}
.score-disclaimer,
.score-license,
.score-footnote,
.score-provenance {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 8px;
}
.score-binding-badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  color: var(--primary);
  margin-left: 8px;
}
.score-binding-badge--edited {
  background: color-mix(in srgb, var(--warning) 15%, var(--surface));
  color: var(--warning);
}
.score-repull {
  font-size: 0.8rem;
  margin-left: 8px;
}

/* Local AI — compact professional design. */
.aic { max-width: 880px; margin: 0 auto; padding: 16px 16px 28px; display: flex; flex-direction: column; gap: 12px; }
.aic-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.aic-head h2 { margin: 0; font-size: 1.4rem; letter-spacing: -0.01em; }
.aic-tagline { font-size: 0.82rem; }
.aic-muted { color: var(--muted); font-size: 0.82rem; }
.aic-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 0.78rem; font-weight: 600; padding: 4px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); }
.aic-pill svg { width: 13px; height: 13px; }
.aic-pill--ready { background: #e8f5e9; border-color: #a5d6a7; color: #2e7d32; }
.aic-pill--loading { border-color: var(--primary); color: var(--primary); }
.aic-pill--error { background: #fdecea; border-color: #f5c6cb; color: #c62828; }
.aic-models-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .aic-models-grid { grid-template-columns: 1fr; } }
.aic-model { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; background: var(--surface); cursor: pointer; display: flex; flex-direction: column; gap: 2px; transition: border-color .15s, box-shadow .15s; }
.aic-model:hover { border-color: var(--primary); }
.aic-model.is-sel { border: 2px solid var(--primary); padding: 9px 13px; background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.aic-model.is-off { opacity: .55; cursor: default; }
.aic-model-top { display: flex; align-items: center; gap: 7px; }
.aic-model-top strong { font-size: 0.95rem; }
.aic-tag { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--primary) 12%, var(--surface)); color: var(--primary); display: inline-flex; align-items: center; gap: 3px; }
.aic-tag svg { width: 11px; height: 11px; }
.aic-tag--sel { padding: 2px 6px; }
.aic-model-sub { font-size: 0.8rem; color: var(--muted); line-height: 1.35; }
.aic-model-act { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.aic-btn { display: inline-flex; align-items: center; gap: 5px; font-size: 0.82rem; font-weight: 600; padding: 5px 14px; border-radius: 8px; border: 1px solid var(--primary); background: transparent; color: var(--primary); cursor: pointer; }
.aic-btn:hover { background: var(--primary); color: #fff; }
.aic-btn svg { width: 13px; height: 13px; }
.aic-link { background: none; border: none; color: var(--muted); font-size: 0.78rem; cursor: pointer; text-decoration: underline; padding: 0; }
.aic-ok { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; color: #2e7d32; font-weight: 600; }
.aic-ok svg { width: 13px; height: 13px; }
.aic-progress { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--primary); }
.aic-progress progress { width: 90px; height: 6px; }
.aic-specs { text-align: center; font-size: 0.78rem; color: var(--muted); margin-top: 8px; }
.aic-warn { color: var(--warning, #b45309); font-size: 0.82rem; margin: 6px 0 0; text-align: center; }
.aic-disclaimer { display: flex; gap: 7px; align-items: flex-start; color: var(--warning, #b45309); font-size: 0.78rem; line-height: 1.45; margin: 0; padding: 8px 14px 10px; text-align: left; }
.aic-disclaimer svg { flex: none; width: 14px; height: 14px; margin-top: 2px; }
.aic-context { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 6px 14px 0; font-size: 0.72rem; color: var(--muted); }
.aic-context-bar { width: 90px; height: 4px; border-radius: 999px; background: color-mix(in srgb, var(--text) 12%, transparent); overflow: hidden; }
.aic-context-bar span { display: block; height: 100%; border-radius: 999px; background: var(--muted); }
.aic-context-label { white-space: nowrap; }
.aic-context-note { white-space: nowrap; }
.aic-m--a .aic-m-body { background: color-mix(in srgb, var(--text) 7%, var(--surface)); border-radius: 16px; border-bottom-left-radius: 5px; padding: 9px 14px; line-height: 1.45; font-size: 0.9rem; }
.aic-m--a .aic-m-body > :first-child { margin-top: 0; }
.aic-m--a .aic-m-body > :last-child { margin-bottom: 0; }
.aic-m--a .aic-m-body p { margin: 0 0 8px; padding: 0; background: none; border-radius: 0; white-space: pre-wrap; word-break: break-word; }
.aic-m--a .aic-m-body ul, .aic-m--a .aic-m-body ol { margin: 4px 0 8px; padding: 0 0 0 22px; background: none; border-radius: 0; }
.aic-m--a .aic-m-body .aic-think { margin: 0 0 8px; }
.aic-m--a li { margin: 2px 0; }
.aic-m--a li::marker { color: var(--muted); }
.aic-m--a code { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 0.82em; background: color-mix(in srgb, var(--text) 10%, transparent); padding: 1px 5px; border-radius: 5px; }
.aic-chat { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.aic-msgs { padding: 14px; display: flex; flex-direction: column; gap: 10px; min-height: 140px; max-height: 420px; overflow-y: auto; }
.aic-m { max-width: 88%; display: flex; flex-direction: column; gap: 3px; }
.aic-m p { margin: 0; padding: 9px 14px; border-radius: 16px; line-height: 1.45; font-size: 0.9rem; white-space: pre-wrap; word-break: break-word; }
.aic-m--u { align-self: flex-end; align-items: flex-end; }
.aic-m--u p { background: var(--primary); color: #fff; border-bottom-right-radius: 5px; }
.aic-m--a { align-self: flex-start; }
.aic-m-label { font-size: 0.7rem; color: var(--muted); padding: 0 4px; }
.aic-empty { text-align: center; padding: 20px 12px; }
.aic-empty p { margin: 0; font-size: 0.88rem; }
.aic-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); align-items: flex-end; }
/* Rich-text chat composer: a contenteditable box so formatted pastes keep
   their line breaks and structure. Plain text is extracted on send. */
.aic-input { flex: 1; border: 1px solid var(--border); border-radius: 18px; padding: 9px 16px; font-size: 0.9rem; line-height: 1.45; background: var(--background); color: var(--text); min-height: 22px; max-height: 140px; overflow-y: auto; word-break: break-word; }
.aic-input:focus { outline: none; border-color: var(--primary); }
.aic-input:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.aic-input[contenteditable="false"] { opacity: .55; }
.aic-input div, .aic-input p { margin: 0 0 4px; }
.aic-input div:last-child, .aic-input p:last-child { margin-bottom: 0; }
.aic-input ul, .aic-input ol { margin: 4px 0; padding-left: 22px; }
.aic-send { width: 38px; height: 38px; border-radius: 50%; border: none; background: var(--primary); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.aic-send:hover:not(:disabled) { filter: brightness(1.1); }
.aic-send:disabled { opacity: .35; cursor: default; }
.aic-send svg { width: 17px; height: 17px; }
.aic-caret { animation: lai-blink 1s steps(2) infinite; }
@keyframes lai-blink { 50% { opacity: 0; } }
/* Collapsed reasoning dropdown (ChatGPT-style): hidden by default, expands on tap. */
.aic-think { border: 1px solid var(--border); border-radius: 10px; background: color-mix(in srgb, var(--text) 4%, var(--surface)); overflow: hidden; }
.aic-think > summary { display: flex; align-items: center; gap: 6px; padding: 7px 12px; font-size: 0.78rem; font-weight: 600; color: var(--muted); cursor: pointer; list-style: none; }
.aic-think > summary::-webkit-details-marker { display: none; }
.aic-think > summary svg { width: 13px; height: 13px; transition: transform .15s; }
.aic-think[open] > summary svg { transform: rotate(90deg); }
.aic-think > summary:hover { color: var(--text); }
.aic-think-body { padding: 2px 12px 10px; font-size: 0.8rem; line-height: 1.5; color: var(--muted); white-space: pre-wrap; word-break: break-word; max-height: 240px; overflow-y: auto; }
/* "Thinking" indicator: shown in the assistant bubble between send and the first token. */
.aic-thinking { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.85rem; padding: 2px 0; }
.aic-dots { display: inline-flex; gap: 4px; }
.aic-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: lai-dot-bounce 1.2s infinite; }
.aic-dots span:nth-child(2) { animation-delay: .15s; }
.aic-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes lai-dot-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .35; } 30% { transform: translateY(-4px); opacity: 1; } }
/* "Downloaded" badge shown on model cards whose weights are in this browser's cache. */
.aic-tag--dl { background: #e8f5e9; color: #2e7d32; }
.aic-tag--dl svg { width: 11px; height: 11px; }
.aic-parse { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 10px 14px; }
.aic-parse-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; margin: 0; }
.aic-parse-txt { display: flex; flex-direction: column; gap: 1px; }
.aic-parse-txt strong { font-size: 0.88rem; }
.aic-sw { position: relative; flex-shrink: 0; width: 44px; height: 25px; }
.aic-sw input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.aic-sw-t { position: absolute; inset: 0; border-radius: 999px; background: color-mix(in srgb, var(--text) 14%, var(--surface)); transition: background .2s; pointer-events: none; }
.aic-sw-t::after { content: ""; position: absolute; top: 2.5px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.aic-sw input:checked + .aic-sw-t { background: var(--primary); }
.aic-sw input:checked + .aic-sw-t::after { transform: translateX(19px); }
.aic-sw input:disabled + .aic-sw-t { opacity: .45; }
/* Chat header bar: message count + "New chat" (clears the conversation and
   the model's context). */
.aic-chatbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--border); }
.aic-newchat { display: inline-flex; align-items: center; gap: 5px; font-size: 0.78rem; font-weight: 600; color: var(--primary); background: none; border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.aic-newchat:hover:not(:disabled) { border-color: var(--primary); }
.aic-newchat:disabled { opacity: .4; cursor: default; }
.aic-newchat svg { width: 13px; height: 13px; }
.aic-chatbar-actions { display: inline-flex; align-items: center; gap: 8px; }
.aic-compress { display: inline-flex; align-items: center; gap: 5px; font-size: 0.78rem; font-weight: 600; color: var(--muted); background: none; border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.aic-compress:hover:not(:disabled) { border-color: var(--muted); color: var(--text); }
.aic-compress:disabled { opacity: .4; cursor: default; }
.aic-compress.is-armed { color: var(--warning); border-color: var(--warning); }
.aic-compress.is-armed:hover { background: var(--warning-bg); }
.aic-cost { display: flex; align-items: center; justify-content: flex-end; padding: 6px 14px 0; font-size: 0.72rem; color: var(--muted); }
.aic-cost-label { white-space: nowrap; }
/* Per-message "revert" control: removes the message and everything after it
   from the conversation (the model's context on the next send). Absolutely
   positioned so showing it never shifts the layout; revealed on hover, and
   always faintly visible on touch devices. */
.aic-m { position: relative; }
/* Revert sits in the normal flow BELOW the message content (never overlaid
   on top of it) and appears on hover. The flex column keeps it under the
   text, tool records, and citations alike. */
.aic-m-revert { display: none; align-items: center; gap: 3px; font-size: 0.68rem; font-weight: 600; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; cursor: pointer; white-space: nowrap; margin-top: 4px; align-self: flex-start; }
.aic-m--u .aic-m-revert { align-self: flex-end; }
.aic-m:hover .aic-m-revert, .aic-m-revert:focus-visible { display: inline-flex; }
.aic-m-revert:hover { color: var(--text); border-color: var(--muted); }
.aic-m-revert svg { width: 11px; height: 11px; }
@media (hover: none) { .aic-m-revert { display: inline-flex; } }
/* "Context" inspector: exactly what will be loaded into the model's context
   on the next send, with per-piece include/exclude checkboxes. */
.aic-ctx { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); overflow: hidden; }
.aic-ctx-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 14px; background: none; border: none; cursor: pointer; color: var(--text); text-align: left; }
.aic-ctx-head strong { font-size: 0.88rem; }
.aic-ctx-chev { display: inline-flex; }
.aic-ctx-chev svg { width: 14px; height: 14px; color: var(--muted); transition: transform .15s; }
.aic-ctx-chev.is-open svg { transform: rotate(90deg); }
.aic-ctx-body { padding: 2px 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.aic-ctx-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 0.84rem; }
.aic-ctx-grouphead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 0.84rem; }
.aic-ctx-sub { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-top: 6px; }
.aic-ctx-piece { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 0.84rem; cursor: pointer; }
.aic-ctx-piece input { accent-color: var(--primary); width: 15px; height: 15px; flex-shrink: 0; margin: 0; }
.aic-ctx-piece-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aic-ctx-piece.is-off .aic-ctx-piece-label { color: var(--muted); }
.aic-ctx-tok { white-space: nowrap; }
.aic-ctx-empty { margin: 4px 0; }
.aic-ctx-foot { margin: 2px 0 0; font-size: 0.74rem; color: var(--muted); line-height: 1.45; }

/* MDCalc-style calculator views (Models tab). Uses the app theme:
   teal accent headers, navy primary selections, Aptos/system font. */
.mdc { display: flex; flex-direction: column; min-height: 100%; }
.mdc-header {
  display: flex; align-items: center; gap: 8px;
  background: var(--accent); color: #fff;
  padding: 10px 12px;
  position: sticky; top: 0; z-index: 5;
}
.mdc-title {
  margin: 0; flex: 1; text-align: center;
  font-size: 1.05rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mdc-iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: none; background: transparent;
  color: #fff; cursor: pointer; border-radius: 8px; flex-shrink: 0;
}
.mdc-iconbtn:hover { background: rgb(255 255 255 / 12%); }
.mdc-iconbtn svg { width: 22px; height: 22px; }
.mdc-iconbtn.is-favorite { color: #ffd97a; }
.mdc-tabs {
  display: flex; background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 56px; z-index: 4;
}
.mdc-tab {
  flex: 1; border: none; background: transparent; cursor: pointer;
  padding: 12px 4px 10px; font-size: 0.78rem; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.mdc-tab.is-active { color: var(--text); border-bottom-color: var(--warning); }
.mdc-body { padding: 16px 16px 24px; max-width: 760px; width: 100%; margin: 0 auto; }
/* Mode-gated fields and inactive tab panes stay in the DOM with `hidden` so
   toggling them never rebuilds the calculator form (no scroll jump). */
.mdc-pane[hidden], .mdc-field[hidden] { display: none; }
.mdc-pane-title { font-size: 1.05rem; margin: 0 0 10px; }
.mdc-desc { color: var(--muted-strong); font-size: 0.95rem; line-height: 1.5; margin: 0 0 14px; }
.mdc-patientline { font-size: 0.82rem; color: var(--muted); margin: 0 0 12px; }
.mdc-footnote { font-size: 0.8rem; color: var(--muted); margin: 18px 0 0; }
/* Accordions */
.mdc-accwrap { margin-bottom: 10px; }
.mdc-acc {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  padding: 12px 14px; cursor: pointer; font-size: 0.92rem; font-weight: 600; color: var(--text);
}
.mdc-acc--tinted { background: var(--accent-soft); border-color: transparent; }
.mdc-acc-title { display: inline-flex; align-items: center; gap: 10px; }
.mdc-acc-icon { display: inline-flex; color: var(--accent); }
.mdc-acc-icon svg { width: 22px; height: 22px; }
.mdc-acc-chev { display: inline-flex; color: var(--muted); transition: transform 0.15s; }
.mdc-acc-chev svg { width: 20px; height: 20px; }
.mdc-acc[aria-expanded="true"] .mdc-acc-chev { transform: rotate(180deg); }
.mdc-acc-body { padding: 12px 4px 4px; font-size: 0.9rem; line-height: 1.55; color: var(--text); }
.mdc-acc-body p { margin: 0 0 8px; }
.mdc-bullets { margin: 0 0 8px; padding-left: 20px; }
.mdc-bullets li { margin-bottom: 6px; }
.mdc-trio { display: flex; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); margin-bottom: 10px; }
.mdc-acc--trio { border: none; border-radius: 0; flex: 1; padding: 12px 8px; font-size: 0.82rem; }
.mdc-acc--trio + .mdc-acc--trio { border-left: 1px solid var(--border); }
.mdc-acc--trio:first-child { border-radius: 10px 0 0 10px; }
.mdc-acc--trio:last-child { border-radius: 0 10px 10px 0; }
.mdc-acc--trio .mdc-acc-title { justify-content: center; width: 100%; text-align: center; }
.mdc-acc--trio .mdc-acc-chev svg { width: 16px; height: 16px; }
.mdc-trio-panel { border: 1px solid var(--border); border-radius: 10px; margin: 0 0 10px; padding: 12px 14px; background: var(--surface); font-size: 0.9rem; line-height: 1.55; }
.mdc-trio-panel p { margin: 0 0 8px; }
/* Input fields: label left, options right (MDCalc mobile pattern) */
.mdc-form { display: flex; flex-direction: column; }
.mdc-field {
  display: grid; grid-template-columns: minmax(110px, 1fr) minmax(150px, 1.1fr);
  gap: 12px; align-items: start;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.mdc-field--stacked { grid-template-columns: 1fr; gap: 8px; }
.mdc-field-name { font-weight: 700; font-size: 0.95rem; display: block; }
.mdc-field-hint { display: block; font-size: 0.8rem; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.mdc-opts { display: flex; flex-direction: column; gap: 8px; }
.mdc-opt {
  position: relative;
  display: flex; align-items: center; justify-content: center; text-align: center;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface);
  padding: 10px 12px; cursor: pointer; font-size: 0.9rem; font-weight: 500; color: var(--text);
  transition: background 0.12s, border-color 0.12s;
}
.mdc-opt:hover { border-color: var(--primary); }
.mdc-opt.is-selected { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.mdc-opt input { position: absolute; opacity: 0; pointer-events: none; }
.mdc-opt:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.mdc-select, .mdc-date, .mdc-number {
  width: 100%; padding: 12px; font-size: 1rem;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text);
}
.mdc-select:focus, .mdc-date:focus, .mdc-number:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 25%, transparent); }
.mdc-numberwrap { display: flex; gap: 8px; align-items: center; }
.mdc-numberwrap .mdc-number { flex: 1; min-width: 0; }
.mdc-numberwrap .mdc-unitsel { flex: 0 0 auto; width: auto; }
.mdc-unit { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.mdc-unitsel { padding: 12px 8px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); font-size: 0.9rem; }
/* Sticky result bar */
.mdc-resultbar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  background: var(--accent); color: #fff;
  padding: 14px 16px; margin-top: auto;
  border-radius: 14px 14px 0 0;
}
.mdc-resultbar-label { font-size: 1.3rem; font-weight: 800; flex-shrink: 0; }
.mdc-resultbar-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mdc-resultbar-pending { font-size: 0.95rem; opacity: 0.92; }
.mdc-resultbar-missing { font-size: 0.8rem; opacity: 0.8; }
.mdc-resultbar-headline { font-size: 1.15rem; font-weight: 800; }
.mdc-resultbar-detail { font-size: 0.82rem; opacity: 0.92; line-height: 1.4; }
.mdc-save {
  flex-shrink: 0; border: 2px solid #fff; background: transparent; color: #fff;
  border-radius: 10px; padding: 8px 14px; font-size: 0.85rem; font-weight: 700; cursor: pointer;
}
.mdc-save:hover:not(:disabled) { background: rgb(255 255 255 / 15%); }
.mdc-save:disabled { opacity: 0.7; cursor: default; }
/* Next steps / evidence / creator panes */
.mdc-nextband {
  border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 10px; background: var(--surface); padding: 14px; margin-bottom: 14px;
}
.mdc-nextband-head { display: block; font-size: 1rem; margin-bottom: 6px; }
.mdc-nextgeneral p { line-height: 1.55; }
.mdc-verified { font-size: 0.85rem; color: var(--muted-strong); line-height: 1.5; }
.mdc-verified a { color: var(--accent); }
.mdc-refs { margin: 12px 0; padding-left: 20px; font-size: 0.9rem; }
.mdc-refs li { margin-bottom: 6px; }
.mdc-refs a { color: var(--accent); }
.mdc-refprimary { font-size: 0.85rem; color: var(--muted-strong); line-height: 1.5; }
@media (max-width: 420px) {
  .mdc-field { grid-template-columns: minmax(96px, 0.9fr) minmax(140px, 1.1fr); gap: 8px; }
  .mdc-tab { font-size: 0.68rem; padding: 12px 2px 10px; }
  .mdc-resultbar-label { font-size: 1.1rem; }
}

/* A&P inline suggestions — track-changes style, rendered directly in the plan */
.ap-loading-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--border, #e2e8f0);
  border-left: 4px solid var(--accent, #2563eb);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
  background: var(--panel-alt, #fbfdff);
}
.ap-loading-banner p { margin: 0.15rem 0; }
.ap-spinner {
  width: 1.5rem;
  height: 1.5rem;
  flex: 0 0 auto;
  border: 3px solid var(--border, #e2e8f0);
  border-top-color: var(--accent, #2563eb);
  border-radius: 50%;
  animation: ap-spin 0.9s linear infinite;
}
@keyframes ap-spin { to { transform: rotate(360deg); } }
.ap-inline-del {
  color: #b91c1c;
  text-decoration-thickness: 2px;
  background: #fef2f2;
  border-radius: 3px;
  padding: 0 2px;
}
.ap-inline-ins {
  color: #15803d;
  font-weight: 600;
  text-decoration: none;
  background: #f0fdf4;
  border-radius: 3px;
  padding: 0 2px;
}
.ap-inline-change { display: inline; }
div.ap-inline-change { display: block; margin: 0.3rem 0; }
.ap-inline-actions {
  display: inline-flex;
  gap: 0.25rem;
  margin-left: 0.35rem;
  vertical-align: middle;
}
.ap-inline-btn {
  font-size: 0.8rem;
  line-height: 1;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--border, #e2e8f0);
  background: #fff;
  cursor: pointer;
}
.ap-inline-approve { color: #15803d; border-color: #15803d; }
.ap-inline-approve:hover { background: #f0fdf4; }
.ap-inline-reject { color: #b91c1c; border-color: #b91c1c; }
.ap-inline-reject:hover { background: #fef2f2; }
.ap-inline-rationale {
  margin: 0.25rem 0 0.35rem;
  font-size: 0.85rem;
  color: var(--muted, #64748b);
}
.ap-inline-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  color: #fff;
}
.ap-inline-badge--add { background: #15803d; }
.ap-inline-badge--revise { background: #b45309; }
.ap-inline-badge--remove { background: #b91c1c; }
.ap-inline-diff {
  border-left: 4px solid #b45309;
}
.ap-review-note {
  font-size: 0.8rem;
  color: var(--muted, #64748b);
  margin: 0.25rem 0 0;
  font-style: italic;
}
.ap-inline-unmatched {
  border: 1px dashed #b45309;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  background: #fffbeb;
}
.ap-inline-unmatched-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #b45309;
}
.ed-body[data-ap-reviewing="true"] {
  background: var(--panel-alt, #fbfdff);
}

/* ============================================================
   AI Chat — remote (ChatGPT) mode + HIPAA review modal
   ============================================================ */
.aic-mode {
  display: inline-flex;
  background: var(--surface-2, #f1f5f9);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.aic-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted, #64748b);
  cursor: pointer;
}
.aic-mode-btn svg { width: 15px; height: 15px; }
.aic-mode-btn.is-on {
  background: var(--surface, #fff);
  color: var(--ink, #0f172a);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}
.aic-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.aic-service {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted, #64748b);
}
.aic-service select {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface, #fff);
  color: var(--ink, #0f172a);
  max-width: 260px;
}
.aic-remote-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.aic-tool {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted, #64748b);
  cursor: pointer;
  user-select: none;
}
.aic-tool input { accent-color: var(--accent, #2563eb); }
.aic-keywarn {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 10px;
}
.aic-keywarn a { color: #92400e; font-weight: 700; }
.aic-keywarn svg { width: 15px; height: 15px; flex: none; }
.aic-m--r .aic-m-body { white-space: normal; }
.aic-m-sources { margin-top: 8px; font-size: 12px; color: var(--muted, #64748b); }
.aic-m-sources ul { margin: 4px 0 0; padding-left: 18px; }
.aic-m-sources a { color: var(--accent, #2563eb); }
.aic-m-warn {
  margin-top: 8px;
  font-size: 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 8px;
  padding: 6px 10px;
}
.aic-remote-note {
  font-size: 12px;
  color: var(--muted, #64748b);
  margin-top: 8px;
}

/* HIPAA review modal — pre-send gate for ChatGPT mode */
.aic-hipaa-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
/* Review controls stay pinned; the body and bounded document panes scroll independently. */
.aic-hipaa-modal {
  background: var(--surface, #fff);
  color: var(--ink, #0f172a);
  border-radius: 14px;
  width: 100%;
  max-width: 1080px;
  max-height: 94dvh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.4);
  overflow: hidden;
}
.aic-hipaa-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 16px 0;
  flex: none;
}
.aic-hipaa-shield {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #dbeafe;
  color: #1d4ed8;
  display: flex;
  align-items: center;
  justify-content: center;
}
.aic-hipaa-shield svg { width: 20px; height: 20px; }
.aic-hipaa-head h2 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.aic-hipaa-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted, #64748b); }
.aic-hipaa-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 16px 0;
  flex: none;
}
.aic-hipaa-stat {
  display: flex;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--surface-2, #f8fafc);
}
.aic-hipaa-stat-ic {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e0e7ff;
  color: #4338ca;
  display: flex;
  align-items: center;
  justify-content: center;
}
.aic-hipaa-stat-ic svg { width: 16px; height: 16px; }
.aic-hipaa-stat--warn .aic-hipaa-stat-ic { background: #fef3c7; color: #b45309; }
.aic-hipaa-stat--ok .aic-hipaa-stat-ic { background: #dcfce7; color: #15803d; }
.aic-hipaa-stat-tx { display: flex; flex-direction: column; line-height: 1.25; }
.aic-hipaa-stat-tx span { font-size: 12px; color: var(--muted, #64748b); }
.aic-hipaa-stat-tx strong { font-size: 14.5px; }
.aic-hipaa-body {
  padding: 10px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
}
.aic-hipaa-sec-title {
  margin: 4px 0 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted, #64748b);
}
.aic-hipaa-msg {
  font-size: 13px;
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 9px 12px;
  white-space: pre-wrap;
  word-break: break-word;
  flex: none;
}
.aic-hipaa-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12.5px;
  color: #92400e;
  margin: 6px 0 0;
}
.aic-hipaa-note svg { flex: none; width: 15px; height: 15px; margin-top: 1px; }
.aic-hipaa-piece {
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  background: var(--surface, #fff);
  overflow: hidden;
  /* Never let flex layout crush review cards to a sliver: the modal body
     scrolls instead. (overflow:hidden zeroes the automatic minimum size,
     so without this the cards collapse to their 2px borders.) */
  flex-shrink: 0;
}
.aic-hipaa-piece-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface-2, #f8fafc);
  border: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
}
.aic-hipaa-piece-head:hover { background: #eef2f7; }
.aic-hipaa-chev { flex: none; color: var(--muted, #64748b); display: flex; }
.aic-hipaa-chev svg { width: 16px; height: 16px; transition: transform 0.15s ease; }
.aic-hipaa-piece.is-open .aic-hipaa-chev svg { transform: rotate(90deg); }
.aic-hipaa-piece-title { font-weight: 650; font-size: 13.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aic-hipaa-chips { display: flex; gap: 6px; flex: none; }
.aic-hipaa-chip {
  font-size: 11.5px;
  font-weight: 600;
  background: #e2e8f0;
  color: #475569;
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}
.aic-hipaa-chip--red { background: #fde68a; color: #92400e; }
.aic-hipaa-piece-body {
  font-size: 12.5px;
  line-height: 1.55;
  padding: 8px 12px;
  /* Normal whitespace: the presentation's indented template literals leave
     whitespace-only text nodes between elements, and pre-wrap rendered those
     as blank lines (36px and 17px gaps in Chromium). Actual preformatted text
     keeps pre-wrap via .aic-hipaa-preview below. */
  white-space: normal;
  word-break: break-word;
  /* No nested scroller: the modal body owns the single scrollbar, so long
     documents never hide inside a 260px viewport. */
  border-top: 1px solid var(--border, #e2e8f0);
  color: #334155;
}
.aic-hipaa-mark {
  background: #fde68a;
  color: #78350f;
  border-radius: 5px;
  padding: 0 5px;
  font-weight: 700;
  font-size: 0.92em;
  white-space: nowrap;
}
.aic-hipaa-mark--date { background: #dbeafe; color: #1e40af; }
.aic-hipaa-flags {
  border: 1px solid #fcd34d;
  background: #fffbeb;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12.5px;
  color: #78350f;
  flex: none;
}
.aic-hipaa-flags > strong { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin-bottom: 6px; }
.aic-hipaa-flags > strong svg { width: 16px; height: 16px; }
.aic-hipaa-flags ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.aic-hipaa-flags--ok { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
.aic-hipaa-flags p { margin: 0; }
.aic-hipaa-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--border, #e2e8f0);
  background: var(--surface, #fff);
  flex: none;
}
.aic-hipaa-ack {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  user-select: none;
}
.aic-hipaa-ack input { width: 17px; height: 17px; accent-color: #1d4ed8; cursor: pointer; }
.aic-btn:disabled { opacity: 0.45; cursor: not-allowed; }
@media (max-width: 640px) {
  .aic-hipaa-stats { grid-template-columns: repeat(2, 1fr); }
  .aic-hipaa-foot { flex-wrap: wrap; }
  .aic-hipaa-ack { flex: 1 1 100%; order: -1; }
}

/* ==========================================================================
   AI Chat v3 — full-screen layout + delta review
   Appended 2026-09-29. Existing rules above are untouched; everything below
   is new classes for the ChatGPT-style full-screen chat shell, the sidebar,
   the Model menu, the de-identification gate, and the delta-review modal.
   ========================================================================== */

/* The aiChat view becomes a flex column with hidden overflow so the
   conversation scroller owns the scrolling, ChatGPT-style. Scoped to this
   view only; other views keep their existing behavior. */
#aiChatView.active { display: flex; flex-direction: column; overflow: hidden; padding: 0; }
#aiChatContent { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.aic-shell { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--background, #fff); }

/* ── Topbar ── */
.aic-topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border, #e2e8f0); flex: none; background: var(--surface, #fff); }
.aic-topbar-spacer { flex: 1; }
.aic-modeseg { display: inline-flex; background: color-mix(in srgb, var(--text, #0f172a) 7%, transparent); border-radius: 999px; padding: 3px; gap: 2px; }
.aic-modeseg-btn { border: none; background: transparent; color: var(--muted, #64748b); font: inherit; font-size: 0.82rem; font-weight: 650; padding: 6px 14px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.aic-modeseg-btn svg { width: 14px; height: 14px; }
.aic-modeseg-btn.is-on { background: var(--surface, #fff); color: var(--text, #0f172a); box-shadow: 0 1px 3px rgba(0,0,0,.14); }
.aic-modesub { margin: 0; padding: 8px 16px 0; font-size: 0.78rem; }

/* Model menu: a native <details> popover so no extra data-action is needed. */
.aic-modelwrap { position: relative; }
.aic-modelwrap > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; font-weight: 650; padding: 7px 12px; border: 1px solid var(--border, #e2e8f0); border-radius: 999px; background: var(--surface, #fff); color: var(--text, #0f172a); user-select: none; }
.aic-modelwrap > summary::-webkit-details-marker { display: none; }
.aic-modelwrap > summary::marker { content: none; }
.aic-modelwrap > summary svg { width: 13px; height: 13px; color: var(--muted, #64748b); }
.aic-modelwrap > summary strong { font-weight: 700; }
.aic-model-menu { position: absolute; right: 0; top: calc(100% + 8px); width: min(400px, 92vw); max-height: min(72vh, 600px); overflow-y: auto; background: var(--surface, #fff); border: 1px solid var(--border, #e2e8f0); border-radius: 14px; box-shadow: 0 12px 32px rgba(0,0,0,.16); padding: 14px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.aic-menu-title { margin: 6px 0 2px; font-size: 0.7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted, #64748b); font-weight: 700; }
.aic-modelrow { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--border, #e2e8f0); border-radius: 10px; }
.aic-modelrow.is-sel { border-color: var(--primary, #1d4ed8); }
.aic-modelrow.is-off { opacity: .55; }
.aic-modelrow-info { flex: 1; min-width: 0; }
.aic-modelrow-info strong { font-size: 0.85rem; display: block; }
.aic-modelrow-info > span { font-size: 0.75rem; color: var(--muted, #64748b); display: block; margin-top: 2px; }
.aic-modelrow-act { flex: none; display: flex; align-items: center; gap: 8px; }
.aic-warnline { display: flex; gap: 6px; align-items: flex-start; font-size: 0.78rem; color: var(--warning, #b45309); margin: 0; }
.aic-warnline svg { flex: none; width: 14px; height: 14px; margin-top: 1px; }

/* Narrow-screen button that opens the sidebar drawer (hidden on desktop). */
.aic-sidebtn { display: none; align-items: center; gap: 6px; font: inherit; font-size: 0.82rem; font-weight: 650; padding: 7px 12px; border: 1px solid var(--border, #e2e8f0); border-radius: 999px; background: var(--surface, #fff); color: var(--text, #0f172a); cursor: pointer; }
.aic-sidebtn svg { width: 13px; height: 13px; color: var(--muted, #64748b); }

/* ── Body: conversation column + sidebar ── */
.aic-body { flex: 1; min-height: 0; display: flex; }
.aic-main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.aic-chatbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; flex: none; }
.aic-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.aic-composer { flex: none; border-top: 1px solid var(--border, #e2e8f0); background: var(--surface, #fff); padding: 10px 16px 4px; }
.aic-composer .aic-form { border-top: none; padding: 0; }
.aic-composer .aic-disclaimer { padding-left: 2px; padding-right: 2px; }

/* De-identification gate banner (ChatGPT mode). */
.aic-deid-banner { flex: none; display: flex; align-items: center; gap: 12px; margin: 10px 16px 0; padding: 12px 14px; border: 1px solid #fcd34d; background: #fffbeb; border-radius: 12px; color: #92400e; }
.aic-deid-ic { flex: none; display: flex; }
.aic-deid-ic svg { width: 20px; height: 20px; }
.aic-deid-tx { flex: 1; min-width: 0; }
.aic-deid-tx strong { display: block; font-size: 0.85rem; }
.aic-deid-tx p { margin: 2px 0 0; font-size: 0.8rem; }

/* ── Sidebar ── */
.aic-sidebar { width: 320px; flex: none; border-left: 1px solid var(--border, #e2e8f0); background: var(--surface, #fff); overflow-y: auto; padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 18px; }
.aic-side-head { display: flex; align-items: center; justify-content: space-between; }
.aic-side-head strong { font-size: 0.9rem; }
.aic-side-close { display: none; align-items: center; gap: 4px; background: none; border: none; font: inherit; font-size: 0.8rem; font-weight: 600; color: var(--muted, #64748b); cursor: pointer; padding: 4px; }
.aic-side-close svg { width: 13px; height: 13px; }
.aic-side-backdrop { display: none; }
.aic-side-sec { display: flex; flex-direction: column; gap: 6px; }
.aic-side-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted, #64748b); font-weight: 700; margin: 0 0 2px; }
.aic-side-sub { font-size: 0.8rem; margin: 0; }
.aic-side-hint { font-size: 0.75rem; margin: 4px 0 0; font-style: italic; }
.aic-side-patient { font-size: 0.85rem; font-weight: 650; margin: 0; }
.aic-side-group { font-size: 0.75rem; font-weight: 700; color: var(--muted, #64748b); margin: 8px 0 2px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.aic-side-group-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.aic-side-group-actions { display: flex; gap: 8px; flex: none; }
.aic-side-group-actions .aic-link:disabled { opacity: 0.4; cursor: default; text-decoration: none; }
.aic-side-kv { display: flex; flex-direction: column; gap: 1px; font-size: 0.82rem; margin: 0; }
.aic-side-kv .aic-muted { font-size: 0.72rem; }
.aic-side-svc { font-size: 0.85rem; margin: 0; }

/* Context budget meter. */
.aic-meter { display: flex; flex-direction: column; gap: 5px; }
.aic-meter-bar { display: block; height: 8px; border-radius: 999px; background: color-mix(in srgb, var(--text, #0f172a) 9%, transparent); overflow: hidden; }
.aic-meter-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--primary, #1d4ed8); }
.aic-meter-label { font-size: 0.8rem; font-weight: 650; }

/* Editable custom guidelines textarea. */
.aic-guide { width: 100%; box-sizing: border-box; border: 1px solid var(--border, #e2e8f0); border-radius: 10px; padding: 9px 11px; font: inherit; font-size: 0.82rem; line-height: 1.5; background: var(--background, #fff); color: var(--text, #0f172a); resize: vertical; min-height: 110px; }
.aic-guide:focus { outline: none; border-color: var(--primary, #1d4ed8); }

/* ── HIPAA delta-review additions ── */
.aic-hipaa-badge { flex: none; font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 999px; }
.aic-hipaa-badge--new { background: #dbeafe; color: #1d4ed8; }
.aic-hipaa-badge--changed { background: #fef3c7; color: #b45309; }
.aic-hipaa-badge--reviewed { background: #dcfce7; color: #15803d; }
.aic-hipaa-sughead { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 4px; }
.aic-hipaa-sughead strong { font-size: 0.85rem; }
.aic-hipaa-sug-all { display: inline-flex; align-items: center; gap: 4px; font-size: 0.78rem; }
.aic-hipaa-sug { border: 1px solid var(--border, #e2e8f0); border-radius: 8px; padding: 6px 10px; margin-bottom: 4px; display: flex; flex-direction: column; gap: 4px; background: var(--surface, #fff); }
.aic-hipaa-sug.is-reviewed { background: color-mix(in srgb, var(--text, #0f172a) 3%, var(--surface, #fff)); }
.aic-hipaa-sug-text { display: flex; align-items: baseline; gap: 8px; font-size: 0.83rem; flex-wrap: wrap; }
.aic-hipaa-sug-orig { text-decoration: line-through; color: var(--muted, #64748b); word-break: break-word; }
.aic-hipaa-sug-arrow { color: var(--muted, #64748b); flex: none; }
.aic-hipaa-sug-repl { font-weight: 650; word-break: break-word; }
.aic-hipaa-sug-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.aic-hipaa-sug-act { margin-left: auto; display: inline-flex; gap: 6px; }
.aic-hipaa-reviewed-head { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: none; font: inherit; cursor: pointer; padding: 8px 0; color: var(--text, #0f172a); text-align: left; }
.aic-hipaa-reviewed-head strong { font-size: 0.85rem; }
.aic-hipaa-reviewed { display: flex; flex-direction: column; }
.aic-hipaa-preview { border: 1px dashed var(--border, #e2e8f0); border-radius: 10px; padding: 10px 12px; font-size: 0.83rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word; margin: 10px 0 8px; user-select: text; }
.aic-hipaa-preview-act { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.aic-hipaa-preview-act .aic-muted { font-size: 0.76rem; }
.aic-hipaa-transmit { background: color-mix(in srgb, var(--text, #0f172a) 4%, var(--surface, #fff)); border: 1px solid var(--border, #e2e8f0); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 0.8rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow-y: auto; margin: 0; }
.aic-hipaa-details { margin-top: 10px; }
.aic-hipaa-details > summary { cursor: pointer; font-weight: 650; font-size: 0.85rem; padding: 6px 0; }
.aic-hipaa-history { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.aic-hipaa-hist { border: 1px solid var(--border, #e2e8f0); border-radius: 10px; padding: 8px 10px; }
.aic-hipaa-hist strong { font-size: 0.78rem; display: block; margin-bottom: 3px; }
.aic-hipaa-hist p { margin: 0; font-size: 0.82rem; white-space: pre-wrap; word-break: break-word; }
.aic-hipaa-msgflags { margin: 8px 0 0; padding-left: 18px; font-size: 0.82rem; display: flex; flex-direction: column; gap: 3px; }
.aic-hipaa-progress { text-align: center; padding: 28px 12px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.aic-hipaa-progress strong { font-size: 0.95rem; }
.aic-hipaa-progress p { margin: 0; }
.aic-hipaa-progressbar { width: 100%; max-width: 340px; height: 8px; border-radius: 999px; background: color-mix(in srgb, var(--text, #0f172a) 10%, transparent); overflow: hidden; }
.aic-hipaa-progressbar > span { display: block; height: 100%; background: var(--primary, #1d4ed8); border-radius: 999px; transition: width .2s ease; }

/* Small button variant used for suggestion rows. */
.aic-btn--sm { padding: 4px 10px; font-size: 0.78rem; }

/* Review action bar: the one-click review controls live here, always visible
   between the stats and the scrollable body — no hunting through cards for
   the decision buttons. */
.aic-hipaa-actionbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 7px 12px;
  margin: 8px 16px 0;
  flex: none;
}
.aic-hipaa-actionbar-tx { font-size: 13px; }
.aic-hipaa-actionbar-tx strong { font-weight: 750; }
.aic-hipaa-actionbar-btns { display: inline-flex; gap: 8px; }
.aic-hipaa-actionbar-hint { margin-left: auto; font-size: 12px; color: var(--muted, #64748b); }
/* Floating highlight-to-redact pill: summoned next to any text selection in
   the review modal. position:fixed so it tracks the viewport rather than the
   modal's internal scroll; z-index sits above the modal backdrop. */
.aic-hipaa-redact-float {
  position: fixed;
  z-index: 300;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #1d4ed8;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(29, 78, 216, 0.45);
  white-space: nowrap;
}
.aic-hipaa-redact-float[hidden] { display: none; }
.aic-hipaa-redact-float:hover { background: #1e40af; }
.aic-hipaa-redact-float svg { width: 14px; height: 14px; }

/* ── Mobile: sidebar becomes a drawer ── */
@media (max-width: 1023px) {
  .aic-topbar { padding: 8px 12px; gap: 8px; }
  .aic-modesub { padding: 6px 12px 0; }
  .aic-messages { padding: 12px; }
  .aic-composer { padding: 8px 12px 2px; }
  .aic-chatbar { padding: 6px 12px; }
  .aic-sidebtn { display: inline-flex; }
  /* The fixed drawer spans the full screen height and would otherwise
     cover its own Context toggle in the top bar, leaving the toggle
     unclickable while the drawer is open. Keep the toggle above it. */
  .aic-sidebtn { position: relative; z-index: 71; }
  .aic-sidebar { position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 88vw); z-index: 70; transform: translateX(105%); transition: transform .22s ease; box-shadow: -8px 0 24px rgba(0,0,0,.14); }
  .aic-sidebar.is-open { transform: none; }
  .aic-side-backdrop { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(15,23,42,.38); border: none; padding: 0; cursor: pointer; }
  .aic-side-close { display: inline-flex; }
  .aic-deid-banner { margin: 8px 12px 0; flex-wrap: wrap; }
}

@media (max-width: 640px) {
  .aic-topbar { flex-wrap: wrap; }
  .aic-modesub { display: none; }
  .aic-model-menu { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; max-height: 70vh; }
  .aic-hipaa-sug-act { margin-left: 0; }
}

/* ── Desktop: collapsible sidebar column ── */
/* The topbar Context button is hidden on desktop by default; showing it
   gives a collapse/expand toggle for the persistent sidebar column.
   Narrow screens keep the drawer behavior (max-width: 1023px above). */
@media (min-width: 1024px) {
  .aic-sidebtn { display: inline-flex; }
  .aic-sidebtn[aria-pressed="true"] { background: color-mix(in srgb, var(--primary, #1d4ed8) 10%, var(--surface, #fff)); border-color: color-mix(in srgb, var(--primary, #1d4ed8) 45%, var(--border, #e2e8f0)); }
  .aic-sidebar.is-collapsed { display: none; }
}

/* Drug Lookup view styles */
.drug-lookup .card { margin-bottom: 1rem; }
.drug-add-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.75rem 0; }
.drug-add-row input { flex: 1 1 12rem; }
.drug-chip-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.drug-chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.6rem; border: 1px solid var(--border, #ccc); border-radius: 999px; }
.drug-chip-flag { font-size: 0.75em; color: var(--warning, #a60); }
.interaction-list { list-style: none; padding: 0; display: grid; gap: 0.75rem; }
.interaction-card { border: 1px solid var(--border, #ccc); border-left-width: 4px; border-radius: 6px; padding: 0.75rem; }
.interaction-card--major { border-left-color: #c0392b; }
.interaction-card--moderate { border-left-color: #e67e22; }
.interaction-card--minor { border-left-color: #f1c40f; }
.interaction-card-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.4rem; }
.severity-badge { font-size: 0.75em; font-weight: 700; text-transform: uppercase; padding: 0.15em 0.6em; border-radius: 999px; }
.severity-badge--major { background: #c0392b; color: #fff; }
.severity-badge--moderate { background: #e67e22; color: #fff; }
.severity-badge--minor { background: #f1c40f; color: #333; }
.indication-text { white-space: pre-wrap; }
.drug-lookup-privacy { display: flex; gap: 0.6rem; align-items: flex-start; }


/* Smart `@` drug autocomplete dropdown */
.drug-autocomplete-dropdown {
  position: absolute;
  z-index: 1000;
  min-width: 280px;
  max-width: 420px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  padding: 4px;
}

.drug-autocomplete-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.drug-autocomplete-item:hover,
.drug-autocomplete-item.is-selected {
  background: var(--surface-hover, #f0f4f8);
}

.drug-autocomplete-name {
  font-weight: 600;
  color: var(--ink, #1a1a1a);
  white-space: nowrap;
}

.drug-autocomplete-brand {
  color: var(--muted, #666);
  font-size: 12px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.drug-autocomplete-loading {
  padding: 12px;
  text-align: center;
  color: var(--muted, #666);
  font-size: 13px;
  font-style: italic;
}

/* Drug detail modal */
.drug-detail-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.drug-detail-modal-backdrop[hidden] {
  display: none;
}

.drug-detail-modal {
  background: var(--surface, #ffffff);
  border-radius: 12px;
  max-width: 640px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.drug-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border, #e0e0e0);
}

.drug-detail-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink, #1a1a1a);
}

.drug-detail-brand {
  font-weight: 400;
  font-size: 14px;
  color: var(--muted, #666);
}

.drug-detail-close {
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted, #666);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.drug-detail-close:hover {
  background: var(--surface-hover, #f0f4f8);
  color: var(--ink, #1a1a1a);
}

.drug-detail-body {
  padding: 20px;
  overflow-y: auto;
}

.drug-detail-section {
  margin-bottom: 24px;
}

.drug-detail-section h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted, #666);
}

.drug-detail-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.drug-detail-list li {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light, #f0f0f0);
}

.drug-detail-list li:last-child {
  border-bottom: none;
}

.drug-detail-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink, #1a1a1a);
}

.drug-insert-btn {
  flex-shrink: 0;
  background: var(--primary, #0066cc);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.drug-insert-btn:hover {
  background: var(--primary-dark, #0052a3);
}

.drug-insert-name {
  background: var(--surface-hover, #f0f4f8);
  color: var(--ink, #1a1a1a);
  border: 1px solid var(--border, #e0e0e0);
}

.drug-insert-name:hover {
  background: var(--border, #e0e0e0);
}

.drug-detail-footer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border, #e0e0e0);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drug-detail-source {
  margin: 0;
  font-size: 12px;
  color: var(--muted, #666);
  font-style: italic;
}

.drug-detail-empty {
  color: var(--muted, #666);
  font-style: italic;
  font-size: 14px;
}
/* Cheat Sheets — mobile-first read-only pocket reference (2026-09-29) */
.cs-list { display: flex; flex-direction: column; gap: 12px; max-width: 720px; margin: 0 auto; padding: 12px 12px 32px; }
.cs-title { margin: 4px 2px 0; font-size: 1.25rem; }
.cs-count { color: var(--muted); font-size: 0.85rem; margin: 0 2px; }
.cs-searchbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; padding: 0 12px; margin: 8px 0; }
.cs-searchbar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.cs-search-icon { color: var(--muted); flex: none; display: inline-flex; width: 18px; height: 18px; }
.cs-search-icon svg { width: 100%; height: 100%; display: block; }
.cs-search { flex: 1; min-width: 0; min-height: 44px; border: 0; background: transparent; font-size: 1rem; color: var(--text); }
.cs-search:focus { outline: none; }
.cs-search-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.cs-cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cs-card { width: 100%; display: flex; align-items: center; gap: 10px; min-height: 52px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.cs-card:active { background: var(--surface-subtle); }
.cs-card-icon { color: var(--accent); flex: none; display: inline-flex; }
.cs-card-body { flex: 1; min-width: 0; }
.cs-card-title { font-weight: 600; color: var(--text); }
.cs-card-aliases, .cs-aliases { color: var(--muted); font-size: 0.8rem; }
.cs-card-meta { color: var(--faint); font-size: 0.75rem; margin-top: 2px; }
.cs-card-chev { color: var(--faint); flex: none; }
.cs-empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.cs-empty-title { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.cs-empty-hint { font-size: 0.85rem; }
.cs-detail { display: flex; flex-direction: column; gap: 14px; max-width: 720px; margin: 0 auto; padding: 12px 12px 40px; }
.cs-back { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; background: none; border: 0; color: var(--accent); font-size: 0.95rem; cursor: pointer; padding: 4px 8px 4px 0; }
.cs-detail-header h2 { margin: 0 0 4px; font-size: 1.3rem; }
.cs-review-banner { background: var(--warning-bg); border: 1px solid var(--warning); border-radius: 10px; padding: 10px 12px; font-size: 0.85rem; color: var(--text); }
.cs-section { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.cs-section-title { margin: 0 0 10px; font-size: 1.05rem; }
.cs-group { margin-bottom: 12px; }
.cs-group:last-child { margin-bottom: 0; }
.cs-group-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-strong); margin: 0 0 6px; }
.cs-qlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.cs-q, .cs-exam { border-top: 1px solid var(--line); padding-top: 10px; }
.cs-q:first-child, .cs-exam:first-child { border-top: 0; padding-top: 0; }
.cs-q-text, .cs-exam-name { font-weight: 500; color: var(--text); margin-bottom: 6px; }
.cs-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.cs-chip { background: var(--surface-tint); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 0.78rem; color: var(--muted-strong); }
.cs-pearl { background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; padding: 8px 10px; margin: 8px 0 2px; font-size: 0.87rem; }
.cs-pearl-label { font-weight: 700; color: var(--accent); display: block; margin-bottom: 2px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
.cs-pearl-source { display: block; margin-top: 4px; font-size: 0.75rem; color: var(--muted); }
.cs-pending { font-size: 0.8rem; color: var(--muted); font-style: italic; margin: 6px 0 2px; }
.cs-how { font-size: 0.87rem; margin: 6px 0; }
.cs-how-label { font-weight: 600; }
.cs-footnote { color: var(--faint); font-size: 0.78rem; margin: 0 2px; }
@media (min-width: 720px) {
  .cs-list, .cs-detail { padding-left: 20px; padding-right: 20px; }
}

/* Cheat Sheets — fillable worksheet (MSE sheet only, session-only answers) */
.cs-worksheet-open { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 52px; text-align: left; background: var(--text); color: var(--surface); border: 1px solid var(--text); border-radius: 12px; padding: 10px 14px; cursor: pointer; }
.cs-worksheet-open-title { font-weight: 700; font-size: 1rem; }
.cs-worksheet-open-sub { font-size: 0.82rem; opacity: 0.85; }
.cs-worksheet { display: flex; flex-direction: column; gap: 12px; max-width: 720px; margin: 0 auto; padding: 12px 12px 40px; }
.cs-worksheet-header { display: flex; flex-direction: column; gap: 2px; }
.cs-worksheet-progress { color: var(--muted); font-size: 0.85rem; margin: 0 2px; }
.cs-worksheet-privacy { background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; padding: 8px 10px; font-size: 0.87rem; margin: 0; }
.cs-worksheet-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.cs-worksheet-phase { display: flex; flex-direction: column; gap: 12px; }
.cs-worksheet-phase-head { margin: 6px 2px 0; padding-top: 10px; border-top: 2px solid var(--line-strong); }
.cs-worksheet-phase-title { margin: 0 0 2px; font-size: 1.15rem; }
.cs-worksheet-phase-sub { color: var(--muted); font-size: 0.87rem; margin: 0; }
.cs-worksheet-domain { margin: 0 0 4px; font-size: 1rem; }
label.cs-worksheet-domain { display: block; font-weight: 600; }
.cs-worksheet-maneuver { color: var(--muted); font-size: 0.82rem; margin: 0 0 8px; }
.cs-worksheet-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.cs-worksheet-chip { min-height: 44px; display: inline-flex; align-items: center; background: var(--surface-tint); border: 1px solid var(--line-strong); border-radius: 999px; padding: 8px 14px; font-size: 0.9rem; color: var(--text); cursor: pointer; }
.cs-worksheet-chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); font-weight: 700; }
.cs-worksheet-field { margin-top: 12px; }
.cs-worksheet-field-label { font-weight: 600; font-size: 0.9rem; margin: 0 0 2px; }
.cs-worksheet-item { margin-top: 12px; }
.cs-worksheet-prompt { font-weight: 500; font-size: 0.95rem; margin: 0 0 2px; }
.cs-worksheet-detail { width: 100%; min-height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 1rem; padding: 10px 12px; margin-top: 8px; }
.cs-worksheet-note-label { display: block; font-weight: 600; font-size: 0.85rem; margin: 0 0 4px; }
.cs-worksheet-note { width: 100%; min-height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 1rem; padding: 10px 12px; resize: vertical; }
.cs-worksheet-output { width: 100%; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-subtle); color: var(--text); font: inherit; font-size: 0.92rem; line-height: 1.45; padding: 10px 12px; resize: vertical; }
.cs-worksheet-actions { display: flex; gap: 8px; margin-top: 10px; }
.cs-worksheet-copy { min-height: 44px; background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: 10px; padding: 10px 18px; font-weight: 700; font-size: 0.95rem; cursor: pointer; }
.cs-worksheet-copy:disabled { opacity: 0.45; cursor: default; }
.cs-worksheet-clear { min-height: 44px; background: none; border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 16px; font-size: 0.95rem; color: var(--text); cursor: pointer; }
.cs-worksheet-copy-hint { font-size: 0.85rem; color: var(--muted-strong); margin: 8px 0 0; }

/* Sample Notes — synthetic fixture library for end to end testing (2026-10-01) */
.sample-notes-panel { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.sample-notes-banner p { margin: 4px 0 0; font-size: 0.87rem; }
.sample-notes-list { display: flex; flex-direction: column; gap: 12px; }
.sample-note-card { display: flex; flex-direction: column; gap: 10px; }
.sample-note-heading { align-items: flex-start; }
.sample-note-heading h3 { margin: 0 0 4px; font-size: 1.05rem; }
.sample-note-heading .muted { margin: 0; font-size: 0.87rem; }
.sample-note-type-badge { flex: none; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 3px 10px; font-size: 0.75rem; font-weight: 600; }
.sample-note-preview { background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 0.82rem; line-height: 1.5; white-space: pre-wrap; max-height: 420px; overflow: auto; margin: 0; }
.sample-note-actions { flex-wrap: wrap; }
@media (max-width: 560px) {
  .sample-note-heading { flex-direction: column; }
  .sample-note-type-badge { align-self: flex-start; }
}


/* ── AI Chat clinical-tool records ────────────────────────────────────
   Collapsed per-tool-call audit rows under a tool-mode assistant reply:
   which tool ran, with what inputs, and the deterministic result it
   returned. Styled after .aic-think disclosures. */
.aic-toolrecs { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 2px; }
.aic-toolrec { border: 1px solid var(--border); border-radius: 10px; background: color-mix(in srgb, var(--text) 4%, var(--surface)); overflow: hidden; }
.aic-toolrec > summary { display: flex; align-items: center; gap: 8px; padding: 7px 12px; font-size: 0.78rem; font-weight: 600; color: var(--muted); cursor: pointer; list-style: none; }
.aic-toolrec > summary::-webkit-details-marker { display: none; }
.aic-toolrec > summary svg { width: 13px; height: 13px; flex-shrink: 0; }
.aic-toolrec > summary code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.75rem; color: var(--text); background: color-mix(in srgb, var(--text) 8%, transparent); border-radius: 6px; padding: 1px 6px; }
.aic-toolrec > summary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aic-toolrec > summary:hover { color: var(--text); }
.aic-toolrec-body { padding: 2px 12px 10px; font-size: 0.78rem; line-height: 1.5; color: var(--muted); }
.aic-toolrec-body p { margin: 8px 0 4px; }
.aic-toolrec-query { font-size: 0.85rem; color: var(--text); font-style: italic; }
.aic-toolrec-meta { font-size: 0.72rem; }
.aic-toolrec-meta code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.72rem; color: var(--text); background: color-mix(in srgb, var(--text) 8%, transparent); border-radius: 6px; padding: 1px 6px; }
.aic-toolrec-body pre { margin: 0; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--text) 5%, transparent); white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow-y: auto; font-size: 0.74rem; }

/* ── Chart-grounded RAG (Phase 2): citation chips, disclosure panel, model notice ── */
.rag-cite-chip {
  display: inline-block;
  margin: 0 2px;
  padding: 1px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent, #4da3ff) 12%, transparent);
  color: var(--text);
  font-size: 0.75em;
  font-weight: 600;
  cursor: pointer;
  vertical-align: baseline;
}
.rag-cite-chip:hover {
  background: color-mix(in srgb, var(--accent, #4da3ff) 22%, transparent);
}
/* Section-grounded citation quote: the model's verbatim quote stays
   visible next to the chip. <q> adds quotation marks; keep it inline so
   it flows with the surrounding sentence. */
.aic-cite-quote {
  font-style: italic;
  color: var(--muted);
  quotes: "“" "”" "‘" "’";
}
/* Citation navigation target flash: the chart section briefly highlights
   when a citation chip is clicked. */
.aic-flash-section {
  animation: aic-flash-section 1.6s ease-out;
  border-radius: 8px;
}
@keyframes aic-flash-section {
  0%, 30% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #4da3ff) 65%, transparent); background: color-mix(in srgb, var(--accent, #4da3ff) 10%, transparent); }
  100% { box-shadow: none; background: transparent; }
}
.rag-notice {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
  font-size: 0.78rem;
  color: var(--muted, #6b7280);
}
.rag-status--busy { color: var(--text, #111827); }

/* Sample Notes chart sections: tabs, tables, imaging reports (2026-10-01) */
.sample-note-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.sample-note-tab { border: 1px solid var(--line); background: var(--surface-subtle); border-radius: 999px; padding: 4px 12px; font-size: 0.8rem; cursor: pointer; }
.sample-note-tab--active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }
.sample-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 2px 0 0; }
.sample-section-head h4 { margin: 0; font-size: 0.95rem; }
.sample-section-subhead { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.sample-section-subhead h4 { margin: 0; font-size: 0.9rem; }
.sample-lab-panel { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.sample-table-wrap { overflow-x: auto; }
.sample-chart-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.sample-chart-table th, .sample-chart-table td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.sample-chart-table th { background: var(--surface-subtle); font-weight: 600; }
.sample-flag { font-weight: 700; color: var(--danger); }
.sample-imaging-report { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
/* Guided demo: locked tour layer (appended 2026-09-30). */
.demo-dim {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgb(15 18 25 / 55%);
  cursor: not-allowed;
}
.guided-demo-bar {
  z-index: 96;
}
.demo-next-action {
  position: relative;
  z-index: 91;
}
@keyframes demo-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgb(20 120 140 / 55%); }
  50% { box-shadow: 0 0 0 8px rgb(20 120 140 / 0%); }
}
.demo-next-action.demo-pulse {
  animation: demo-pulse 0.9s ease-in-out 2;
  border-radius: 6px;
}
.guided-demo-hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--warning-strong, #9a5b00);
}
.guided-demo-continue {
  margin-left: 8px;
}

/* Drug interaction checker (dc-). Base buttons reuse .button--primary/--quiet. */
.dc-wrap { max-width: 720px; margin: 0 auto; padding: 16px; display: grid; gap: 12px; }
.dc-head h2 { margin: 0; font-size: 20px; }
.dc-privacy { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.dc-label { font-weight: 600; font-size: 14px; }
.dc-input { width: 100%; min-height: 120px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); padding: 8px 10px; resize: vertical; }
.dc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dc-status { min-height: 1.4em; font-size: 14px; color: var(--muted-strong); margin: 0; }
.dc-alert { border: 1px solid var(--danger); border-radius: var(--radius-md); background: var(--danger-bg); padding: 12px 14px; display: grid; gap: 6px; }
.dc-alert p { margin: 0; }
.dc-sec-title { font-size: 15px; margin: 16px 0 8px; }
.dc-resolve { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dc-res-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-subtle); }
.dc-res-src { font-weight: 600; }
.dc-res-arrow { color: var(--muted); }
.dc-res-target { font-size: 14px; }
.dc-rxcui { color: var(--muted); font-size: 12px; }
.dc-res-line.is-unrec { border-style: dashed; }
.dc-unrec { color: var(--warning); font-size: 13px; font-style: italic; }
.dc-summary { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.dc-card { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); padding: 12px 14px; margin-bottom: 10px; display: grid; gap: 8px; }
.dc-card-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.dc-card-head h4 { margin: 0; font-size: 16px; }
.dc-badge { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.dc-sev-major { background: color-mix(in srgb, #b91c1c 16%, var(--surface)); color: #b91c1c; }
.dc-sev-moderate { background: color-mix(in srgb, #b45309 16%, var(--surface)); color: #b45309; }
.dc-sev-minor { background: color-mix(in srgb, #15803d 16%, var(--surface)); color: #15803d; }
.dc-sev-unknown { background: color-mix(in srgb, var(--muted) 16%, var(--surface)); color: var(--muted-strong); }
.dc-mech { margin: 0; padding-left: 18px; font-size: 14px; display: grid; gap: 4px; }
.dc-mech-none { margin: 0; color: var(--muted); font-size: 14px; }
.dc-mech-cats { margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.dc-mech-cat { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--accent-strong, var(--accent)); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.dc-caveat { margin: 0; font-size: 12px; color: var(--muted); }
.dc-none { font-size: 14px; }
.dc-foot { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 10px; font-size: 12px; color: var(--muted); display: grid; gap: 4px; }
.dc-foot p { margin: 0; }

/* Sample Notes "Try with this chart" coverage (2026-10-01) */
.sample-note-coverage { background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.sample-note-coverage-title { font-size: 0.8rem; font-weight: 700; color: var(--accent); }
.sample-note-coverage-group { display: flex; flex-direction: column; gap: 4px; }
.sample-note-coverage-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.sample-note-coverage-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.sample-note-tag { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 10px; font-size: 0.75rem; font-weight: 600; }
.sample-note-coverage-list { margin: 0; padding-left: 18px; font-size: 0.82rem; line-height: 1.5; }

/* "Verify with local AI" option: a proper labeled row instead of a bare
   browser checkbox floating on its own line. */
.quick-deid-verify {
  display: grid;
  gap: 4px;
}
.quick-deid-verify-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  width: fit-content;
}
.quick-deid-verify-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
}
.quick-deid-verify-label input[type="checkbox"]:disabled {
  cursor: not-allowed;
}
.quick-deid-verify-label:has(input[type="checkbox"]:disabled) {
  color: var(--muted);
  font-weight: 400;
  cursor: not-allowed;
}
.quick-deid-verify > p {
  margin: 0;
}

/* Suggested-rules panel (automatic rule proposer) */
.rule-proposals-panel { margin-top: 16px; }
.rule-list h3 { margin: 0 0 4px; font-size: 18px; }
.rule-intro { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.rule-card { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); padding: 12px 14px; margin-bottom: 10px; display: grid; gap: 8px; }
.rule-card-desc { margin: 0; font-size: 15px; }
.rule-card-examples { margin: 0; padding-left: 18px; font-size: 14px; color: var(--muted); display: grid; gap: 2px; }
.rule-card-examples q { quotes: "\201C" "\201D"; }
.rule-card-meta { margin: 0; font-size: 13px; color: var(--muted); }
.rule-card-actions { display: flex; gap: 8px; }
.rule-card--compact { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; }
.rule-card--compact span { font-size: 14px; }
.rule-empty { color: var(--muted); font-size: 14px; margin: 0; }

/* Rule-learner guided demo ("See how it learns") */
.demo-step-count { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 8px; }
.demo-step-body { display: grid; gap: 12px; margin: 12px 0 4px; }
.demo-step-body p { margin: 0; font-size: 14.5px; line-height: 1.55; }
.demo-note { background: var(--surface-2, #f8fafc); border: 1px solid var(--border, #e2e8f0); border-radius: 8px; padding: 12px 14px; font-size: 14.5px; line-height: 1.7; white-space: pre-wrap; }
.demo-note mark { border-radius: 3px; padding: 0 2px; }
.demo-miss { background: #fef3c7; border-bottom: 2px solid #d97706; }
.demo-caught { background: #d1fae5; border-bottom: 2px solid #059669; }
.demo-found { background: #e0e7ff; text-decoration: line-through; }
.demo-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; border-radius: 4px; padding: 1px 6px; margin-left: 6px; vertical-align: middle; white-space: nowrap; }
.demo-tag--miss { background: #fef3c7; color: #92400e; }
.demo-tag--caught { background: #d1fae5; color: #065f46; }
.demo-tag--found { background: #e0e7ff; color: #3730a3; }

/* Source-first writing workflow. Route elements remain the scroll owners. */
.import-review-guidance{display:flex;flex-direction:column;gap:4px;padding:14px 16px;border-left:3px solid var(--accent);background:var(--accent-soft);margin:12px 0}
.structured-note-section-layout.has-original{grid-template-columns:minmax(230px,1fr) minmax(155px,.65fr) minmax(290px,1.3fr);align-items:start}
.note-original-pane{display:flex;flex-direction:column;gap:10px;min-width:0}
.note-original-pane label{display:flex;justify-content:space-between;gap:8px;flex-wrap:wrap}
.note-original-pane textarea{font:14px/1.6 ui-monospace,monospace;min-height:380px;resize:vertical;background:var(--surface)}
.note-original-pane small{color:var(--muted)}
.note-mapping-tools{padding:12px 0;border-bottom:1px solid var(--border);display:grid;gap:10px}
.note-mapping-tools label{display:flex;align-items:center;gap:10px}
.note-mapping-tools select{min-width:0;flex:1}
.writing-workflow-bar{display:flex;justify-content:space-between;align-items:center;gap:12px;margin:0 0 14px;flex-wrap:wrap}
.writing-workflow-bar [role=tablist]{display:flex;background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:4px;gap:4px}
.writing-workflow-bar [role=tab]{border:0;background:transparent;min-height:44px}
.writing-workflow-bar [aria-selected=true]{background:var(--accent-soft);color:var(--accent);font-weight:700}
.note-export-preview pre{white-space:pre-wrap;overflow-wrap:anywhere;font:16px/1.75 system-ui;padding:20px;max-width:85ch;margin:auto}
.review-columns[hidden],.note-export-preview[hidden]{display:none!important}
.review-hero{border-top:3px solid var(--accent)}
@media(min-width:1100px){.review-columns{grid-template-columns:minmax(270px,.7fr) minmax(0,1.65fr)}}
@media(max-width:1100px){.structured-note-section-layout.has-original{grid-template-columns:minmax(145px,.7fr) minmax(240px,1.3fr)}.note-original-pane{grid-column:1/-1}.note-original-pane textarea{min-height:140px;max-height:260px}}
@media(max-width:760px){.structured-note-section-layout.has-original{grid-template-columns:1fr}.note-original-pane{grid-column:auto}.structured-note-section-nav{max-height:170px;overflow:auto}.review-workspace[data-clinical-data-visible="false"] .review-data-panel{display:none}.review-workspace[data-clinical-data-visible="true"] .review-columns .note-draft-panel{display:none}.review-workspace .review-columns{display:block}.writing-workflow-bar{position:sticky;top:0;z-index:4;background:var(--background,var(--surface));padding:8px 0}.writing-workflow-bar [role=tablist]{flex:1}.writing-workflow-bar [role=tab]{flex:1}.note-mapping-tools .button-row{flex-wrap:wrap}.note-mapping-tools button{min-height:44px}}

.secondary-navigation > summary{cursor:pointer;padding:10px 8px;font-weight:650;min-height:44px}
@media(min-width:1041px){.secondary-navigation > summary{display:none}}
@media(max-width:1040px){
 .primary-nav{display:block;overflow:visible;max-width:none}
 .primary-nav > .nav-group{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px}
 .primary-nav > .nav-group > .nav-group-label{display:none}
 .primary-nav button{width:100%;min-width:0;min-height:44px;white-space:normal;font-size:12px}
 .secondary-navigation > summary{text-align:center;border-top:1px solid var(--border);margin-top:4px}
 .secondary-navigation[open]{display:block}
 .secondary-navigation .nav-group{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
 .secondary-navigation .nav-group-label{grid-column:1/-1}
}

/* Keep the patient boundary within the narrower route padding on phones. */
@media (max-width: 760px) {
  .patient-identity-bar { margin-inline: 0; min-width: 0; }
  .patient-identity-bar strong { min-width: 0; overflow-wrap: anywhere; }
}

/* Keep consult actions reachable while reviewing a long context on phones. */
.ap-confirm-modal { max-width: 760px; }
.ap-confirm-modal label { display: block; margin-block: .6rem; }
.ap-confirm-modal textarea, .ap-confirm-modal input:not([type="checkbox"]), .ap-confirm-modal select { width: 100%; }
.ap-advanced { padding: .75rem; border: 1px solid var(--border); border-radius: 8px; margin-block: .75rem; }
.ap-confirm-actions { position: sticky; bottom: -1.25rem; background: var(--panel, #fff); border-top: 1px solid var(--border); padding-block: .75rem; margin-top: 1rem; z-index: 1; }
.ap-confirm-actions [data-action="ap-confirm-generate"] { order: -2; }
.ap-confirm-actions [data-action="ap-confirm-cancel"] { order: -1; }
@media (max-width: 640px) {
  .ap-confirm-overlay { padding: .5rem; }
  .ap-confirm-modal { max-height: 95dvh; padding: 1rem; }
  .ap-confirm-actions { bottom: -1rem; gap: .4rem; }
  .ap-confirm-actions button { min-height: 44px; }
  .ap-loading-banner { flex-wrap: wrap; }
}

/* Native top-layer dialog keeps sticky patient/navigation bars behind review. */
.ap-confirm-modal { border: 0; color: var(--text); margin: auto; }
.ap-confirm-modal::backdrop { background: rgba(15,23,42,.55); }
.ap-confirm-overlay { background: transparent; }

.ap-request-error { flex-basis: 100%; color: var(--danger, #b42318); margin: 0; order: -3; }

/* Epic arrangement workspace: original and editable destination cards. */
.note-arrange-count{font-size:11px;white-space:nowrap;color:var(--muted)}
.note-transfer-toolbar{display:flex;align-items:center;gap:12px;min-height:36px;min-width:0}
.note-arrange-feedback{flex:1;min-width:0;color:var(--muted);font-size:12px}
.note-drag-handle{touch-action:none;user-select:none;cursor:grab;white-space:nowrap;padding:6px 10px;border:1px solid var(--border);border-radius:4px;background:var(--surface);font:600 12px var(--font-body,system-ui)}
.note-drag-handle:disabled{cursor:default}
.is-note-dragging,.is-note-dragging *{user-select:none!important;cursor:grabbing!important}
.has-note-selection .note-arrange-feedback{color:var(--accent)}
.note-arrange-workspace{display:grid;grid-template-columns:minmax(0,1fr);gap:12px;align-items:stretch;min-width:0}
.note-arrange-workspace.has-original{grid-template-columns:repeat(2,minmax(0,1fr))}
.note-source-sheet{display:flex;flex-direction:column;min-width:0;min-height:0;background:var(--surface);border:1px solid var(--border);border-radius:4px;overflow:hidden}
.note-sheet-heading{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:8px 10px;border-bottom:1px solid var(--border);font-size:13px}
.note-sheet-heading span{font-size:10px;color:var(--muted)}
.note-source-text{padding:10px;white-space:pre-wrap;overflow-wrap:anywhere;font:13px/1.55 ui-monospace,Consolas,monospace;min-height:0;flex:1;overflow:auto;user-select:text;cursor:text}
.note-source-text::selection{background:var(--accent-soft);color:var(--ink)}
@media(min-width:851px){.note-source-sheet{height:clamp(300px,calc(100dvh - 370px),440px)}}
.note-arrange-sections{display:grid;grid-auto-rows:max-content;align-content:start;gap:8px;min-width:0;min-height:0;height:clamp(300px,calc(100dvh - 370px),440px);overflow:auto;scrollbar-gutter:stable;border:1px solid var(--border);border-radius:4px;padding:0 8px 8px}
.note-arrange-sections>.note-sheet-heading{position:sticky;top:0;z-index:1;padding:8px 2px;background:var(--surface)}
.note-section-card{border:1px solid var(--border);border-radius:4px;overflow:hidden;background:var(--surface);transition:border-color .12s,box-shadow .12s}
.note-section-title{width:100%;display:flex;align-items:center;justify-content:space-between;gap:8px;text-align:left;background:transparent;border:0;border-radius:0;padding:6px 10px;color:var(--ink);min-height:32px}
.note-section-title strong{font-size:14px}.note-section-title span{font-size:10px;color:var(--muted);font-weight:400}
.note-section-card textarea{display:block;width:100%;margin:0;border:0;border-radius:0;border-top:1px solid var(--border);padding:8px 10px;resize:vertical;min-height:80px;max-height:320px;field-sizing:content;background:transparent;font:13px/1.5 ui-monospace,Consolas,monospace;box-sizing:border-box}
.note-section-card textarea:focus{outline:2px solid var(--accent);outline-offset:-2px;box-shadow:none}
.has-note-selection .note-section-title{background:var(--accent-soft);color:var(--accent);cursor:copy}
.note-section-card.is-note-drop-target{border:2px dashed var(--accent);box-shadow:0 0 0 4px var(--accent-soft);background:var(--accent-soft)}
.note-arrange-footer{display:flex;align-items:center;gap:12px;position:sticky;bottom:0;z-index:3;background:var(--surface);border-top:1px solid var(--border);padding:8px 0}
.note-arrange-footer>span{flex:1;font-size:11px;color:var(--muted)}
@media(max-width:850px){.note-arrange-workspace.has-original{grid-template-columns:1fr}.note-source-sheet{position:static}.note-source-text{max-height:280px;min-height:150px}.note-arrange-count{display:none}.note-arrange-footer{gap:6px;flex-wrap:wrap}.note-arrange-footer>span{display:none}.note-arrange-footer .button--primary{flex:1}.note-arrange-footer button{min-height:44px}.note-arrange-workspace{gap:18px}}
.note-drag-ghost{position:fixed;pointer-events:none;z-index:10000;padding:10px 14px;background:var(--accent);color:white;border-radius:7px;box-shadow:0 4px 16px #0002;font:600 12px system-ui}
.note-drag-grip{position:fixed;z-index:9999;width:26px;height:26px;min-height:26px;display:grid;place-items:center;padding:0;border:1px solid var(--accent);border-radius:6px;background:var(--accent);color:#fff;font-size:13px;line-height:1;cursor:grab;touch-action:none;user-select:none;box-shadow:0 2px 8px #0003}
.note-drag-grip:active{cursor:grabbing}
/* Epic import: keep source selection, text, and actions in one workspace.
   The day panel never moves to the top: it stays on the left as a slim
   strip and expands in place to the full panel (sidebar spec 2026-10-13). */
.source-first-stay.stay-layout { grid-template-columns:52px minmax(0,1fr); grid-template-rows:minmax(0,1fr); }
.source-first-stay.stay-layout.stay-rail-expanded { grid-template-columns:218px minmax(0,1fr); }
.source-first-stay.stay-layout > .stay-rail { display:flex; flex-direction:column; gap:8px; padding:8px 6px; border-right:1px solid var(--border); border-bottom:0; overflow-x:hidden; overflow-y:auto; }
.source-first-stay.stay-layout.stay-rail-expanded > .stay-rail { padding:16px 14px; }
.source-first-stay .stay-rail-toggle { display:flex; align-items:center; justify-content:center; min-height:32px; padding:4px; border:1px solid var(--border); border-radius:4px; background:var(--surface); color:var(--ink); cursor:pointer; }
.source-first-stay .stay-rail-toggle .icon { width:16px; height:16px; }
.source-first-stay.stay-rail-expanded .stay-rail-toggle { align-self:flex-end; min-width:32px; }
.source-first-stay.stay-rail-expanded .stay-rail-toggle .icon { transform:rotate(180deg); }
.source-first-stay .stay-rail .section-heading { display:none; }
.source-first-stay.stay-rail-expanded .stay-rail .section-heading { display:block; }
.source-first-stay .stay-rail .section-heading h2 { font-size:16px; margin:0; }
.source-first-stay .stay-rail .section-heading p { display:none; }
.source-first-stay.stay-rail-expanded .stay-rail .section-heading p { display:block; }
.source-first-stay .timeline-rail { display:flex; flex-direction:column; gap:6px; overflow:visible; align-items:stretch; }
.source-first-stay .timeline-rail .empty-state { display:none; }
.source-first-stay.stay-rail-expanded .timeline-rail .empty-state { display:block; }
.source-first-stay.stay-layout:not(.stay-rail-expanded) .day-row { flex:0 0 auto; min-width:0; width:100%; min-height:42px; border:1px solid var(--border); border-radius:4px; gap:0; padding:6px 2px; justify-content:center; }
.source-first-stay.stay-layout:not(.stay-rail-expanded) .day-row > span:not(.day-row-compact) { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
.source-first-stay .day-row-compact { display:none; font-weight:650; font-size:11px; line-height:1.2; text-align:center; }
.source-first-stay.stay-layout:not(.stay-rail-expanded) .day-row-compact { display:block; }
.source-first-stay.stay-rail-expanded .day-row { flex:0 1 auto; width:100%; border-right:0; }
.source-first-stay.stay-rail-expanded .day-row-meta { display:grid; justify-items:end; gap:2px; }
.source-first-stay.stay-rail-expanded .day-row-review { white-space:normal; }
.source-first-stay .admission-day-row > span:first-child > .muted { display:none; }
.source-first-stay.stay-rail-expanded .admission-day-row > span:first-child > .muted { display:block; }
.source-first-stay .day-row.selected { border-color:var(--accent); background:var(--accent-soft); }
.source-first-stay.stay-layout:not(.stay-rail-expanded) .new-day-control { display:block; margin:0; }
.source-first-stay.stay-layout:not(.stay-rail-expanded) .new-day-control summary { display:flex; align-items:center; justify-content:center; min-height:40px; padding:6px 2px; font-size:0; }
.source-first-stay.stay-rail-expanded .new-day-control { margin:14px 0 0; min-width:0; max-width:none; }
.source-first-stay.stay-rail-expanded .new-day-control .form-grid { grid-template-columns:1fr; align-items:stretch; max-width:none; }
.source-first-stay .hospital-day-packet { padding:12px; gap:12px; }
.source-first-stay .admission-packet-body { padding:0; gap:12px; min-width:0; }
.source-first-stay .source-day-heading { padding-bottom:8px; align-items:center; }
.source-first-stay .source-day-heading h2 { font-size:16px; }
/* Batch C (audit F4): the tab row wraps instead of scrolling sideways, so
   every source tab is fully visible at any width; nothing is silently
   clipped at the right edge. */
.source-first-stay .source-kind-picker { display:flex; flex-wrap:wrap; overflow-x:visible; gap:0; border:0; border-bottom:1px solid var(--border); background:transparent; padding:0; }
.source-first-stay .source-kind-button { display:flex; flex-shrink:0; flex-wrap:wrap; gap:2px 6px; align-items:center; border:0; border-bottom:2px solid transparent; border-radius:0; min-height:38px; font-weight:500; padding:8px 10px; background:transparent; }
.source-first-stay .source-kind-button.selected { border-bottom-color:var(--accent); background:var(--accent-soft); box-shadow:none; font-weight:650; }
.source-first-stay .source-kind-requirement { font-size:10px; }
/* Batch C (audit F11): each tracked tab also shows its packet-completeness
   state; the state stays visible at narrow widths where the requirement
   badge is hidden. */
.source-first-stay .source-kind-state { font-size:10px; color:var(--muted); }
.source-first-stay .source-kind-state--reviewed { color:var(--accent); }
.source-first-stay .source-kind-state--needs_review { color:#865516; font-weight:700; }
.source-first-stay .source-kind-button[data-review-requirement="required"] .source-kind-state--not_saved { color:#865516; font-weight:700; }
.source-first-stay .structured-primary-note { background:var(--surface); border:0; border-radius:0; padding:0; gap:8px; }
.source-first-stay .structured-note-heading h3 { font-size:15px; }
.source-first-stay .structured-note-mode-toggle { display:flex; width:100%; border:0; border-bottom:1px solid var(--border); border-radius:0; }
.source-first-stay .structured-note-mode-toggle button { min-height:36px; padding:6px 12px; border:0; border-bottom:2px solid transparent; background:transparent; font-size:12px; }
.source-first-stay .structured-note-mode-toggle button.selected { border-bottom-color:var(--accent); box-shadow:none; color:var(--accent); }
.source-first-stay .structured-note-paste-layout { gap:12px; }
.source-first-stay .structured-note-paste-label textarea { min-height:260px; height:clamp(260px,40vh,480px); border-radius:4px; }
.source-first-stay .structured-note-detected { min-height:0; max-height:calc(clamp(260px,40vh,480px) + 24px); border-radius:4px; }
.source-first-stay .structured-note-detected h4 { padding:8px 10px; }
.source-first-stay .structured-note-detected-list { padding:0 10px; }
.source-first-stay .structured-note-detected-list li { min-height:34px; gap:6px; }
.source-first-stay .structured-note-actions { justify-content:flex-end; gap:8px; }
.source-first-stay .structured-note-paste-meta { margin:0 auto 0 0; }
.source-first-stay .structured-note-privacy { padding:0; font-size:11px; }
.source-first-stay .note-arrange-footer { position:static; padding:8px 0 0; gap:8px; }
.source-first-stay .note-arrange-footer .button--primary { background:var(--accent); border-color:var(--accent); color:white; }
.source-first-stay .source-capture-composer { padding:0; border:0; border-radius:0; background:var(--surface); gap:8px; }
.source-first-stay .deid-strip { margin:0; }
/* Batch C (audit F11): the de-ID settings bar is one compact line. The
   resting strip holds only the mode select, its load control, the
   selected-state text, and the admission date; the operation progress,
   download progress, and readiness note take their own line only while
   they are actually present. */
.source-first-stay .deid-strip { flex-direction:row; flex-wrap:wrap; align-items:center; gap:6px 10px; padding:5px 8px; }
.source-first-stay .deid-strip > * { min-width:0; max-width:100%; overflow-wrap:anywhere; }
.source-first-stay .deid-strip-compact select { flex:0 1 300px; min-width:180px; }
.source-first-stay .deid-admission-date-inline { display:inline-flex; align-items:center; gap:6px; white-space:nowrap; }
.source-first-stay .deid-strip .deid-operation:not(.is-active) { display:none; }
.source-first-stay .deid-strip .deid-operation,
.source-first-stay .deid-strip .deid-download-progress,
.source-first-stay .deid-strip .deid-readiness-note { flex:1 1 100%; }
@media(max-width:850px) {
  .source-first-stay .new-day-control { min-width:0; }
  .source-first-stay .new-day-control .form-grid { grid-template-columns:1fr; }
  .source-first-stay .source-kind-button, .source-first-stay .structured-note-mode-toggle button, .note-section-title { min-height:44px; }
  .source-first-stay .source-kind-requirement { display:none; }
  .source-first-stay .structured-note-paste-layout { grid-template-columns:minmax(0,1fr); }
  .source-first-stay .structured-note-detected { max-height:200px; }
  .note-arrange-workspace.has-original { grid-template-columns:minmax(0,1fr); }
  .note-source-text { max-height:200px; min-height:120px; }
  .note-arrange-sections { height:360px; }
  .source-first-stay .structured-note-actions { flex-wrap:wrap; }
  .source-first-stay .structured-note-actions button { min-height:44px; }
  .source-first-stay .deid-strip { flex-wrap:wrap; }
  .source-first-stay .deid-readiness-note, .source-first-stay .deid-download-progress { flex-basis:auto; }
}

/* The Epic workspace follows the full-width reference layout. Other routes
   retain their navigation, and the locked-vault boundary remains unchanged. */
@media (min-width:1041px) {
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .app-shell { grid-template-columns:minmax(0,1fr); grid-template-rows:56px minmax(0,1fr); }
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .app-main { display:contents; }
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .side-nav { grid-area:1/1; display:flex; align-items:center; gap:16px; padding:0 20px; border:0; border-bottom:1px solid var(--border); background:var(--surface); overflow:visible; }
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .brand-lockup { padding:0; min-height:0; }
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .brand-lockup span,
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .brand-mark,
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .side-footer { display:none; }
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .primary-nav { display:flex; align-items:center; overflow:visible; padding:0; gap:16px; }
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .primary-nav > .nav-group { display:flex; gap:4px; margin:0; }
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .primary-nav > .nav-group > .nav-group-label { display:none; }
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .primary-nav > .nav-group > button { width:auto; flex:none; white-space:nowrap; min-height:56px; padding:0 12px; border:0; border-bottom:2px solid transparent; border-radius:0; background:transparent; box-shadow:none; }
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .primary-nav > .nav-group > button.active { border-bottom-color:var(--accent); color:var(--accent); }
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .secondary-navigation { position:relative; align-self:center; }
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .secondary-navigation > summary { display:block; padding:12px 8px; min-height:44px; }
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .secondary-navigation[open] > .secondary-navigation[open] > .secondary-navigation-panel { position:absolute; top:100%; left:0; width:240px; max-height:calc(100dvh - 64px); overflow:auto; z-index:20; padding:0 8px 8px; background:var(--surface); border:1px solid var(--border); border-radius:4px; box-shadow:0 2px 8px #0002; }
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .top-bar { grid-area:1/1; justify-self:end; align-self:center; width:auto; padding:0 20px; border:0; height:54px; min-height:0; }
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .patient-switcher { width:280px; }
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .workspace { grid-area:2/1; }
  body:not(.vault-locked) #dailyView.active { padding:0; }
  .source-first-stay.stay-layout { border:0; border-radius:0; }
  .source-first-stay .hospital-day-packet { padding:10px 20px; }
  .source-first-stay .day-row { width:auto; max-width:none; min-height:36px; }
  .source-first-stay .day-row-meta { display:flex; align-items:center; gap:8px; }
  .source-first-stay .day-row-review { white-space:nowrap; }
  .source-first-stay .structured-note-heading { min-height:22px; }
  .source-first-stay .structured-note-heading p { display:none; }
  .source-first-stay .structured-note-mode-toggle button { border-radius:0; }
  .source-first-stay .structured-note-privacy { font-size:11px; }
  .source-first-stay [data-note-entry-mode="sections"] { grid-template-columns:auto minmax(0,1fr); column-gap:20px; }
  .source-first-stay [data-note-entry-mode="sections"] > * { grid-column:1/-1; }
  .source-first-stay [data-note-entry-mode="sections"] > .structured-note-mode-toggle { grid-column:1; grid-row:2; }
  .source-first-stay [data-note-entry-mode="sections"] > .note-transfer-toolbar { grid-column:2; grid-row:2; border-bottom:1px solid var(--border); }
  .source-first-stay [data-note-entry-mode="sections"] .note-arrange-feedback { font-size:11px; }
}
@media (max-width:850px) {
  .note-transfer-toolbar { flex-wrap:wrap; gap:6px; }
  .note-drag-handle { min-height:44px; }
  .note-arrange-feedback { flex-basis:55%; }
}

.ap-reference-button{display:inline;padding:0 2px;border:0;border-radius:0;background:transparent;color:var(--accent);font:inherit;text-decoration:underline;text-underline-offset:2px;cursor:pointer}
.ap-reference-button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.ap-source-preview,.ap-source-dialog{color:var(--ink);background:var(--surface);border:1px solid var(--border);border-radius:6px;padding:16px;box-shadow:0 2px 8px #0002;font:14px/1.5 system-ui;overflow:auto;overflow-wrap:anywhere}
.ap-source-preview{position:fixed;z-index:10020;width:400px;max-width:calc(100vw - 16px);max-height:min(460px,calc(100dvh - 16px))}
.ap-source-dialog{width:640px;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);margin:auto}
.ap-source-dialog::backdrop{background:#0006}
.ap-source-preview p,.ap-source-dialog p{margin:8px 0}
.ap-source-preview blockquote,.ap-source-dialog blockquote{margin:10px 0;padding:8px 12px;border-left:3px solid var(--border);white-space:pre-wrap}
.ap-source-label{font-weight:600}.ap-source-note,.ap-source-url{font-size:12px;color:var(--muted)}
.ap-source-dialog>button{display:block;margin:16px 0 0 auto}
/* Compact clinical workspaces: stable navigation, bounded document scroll. */
#reviewView { padding:10px 16px; }
.review-workspace { display:grid; grid-template-columns:auto minmax(0,1fr); gap:8px 16px; }
.review-workspace > * { grid-column:1/-1; }
.review-workspace > .patient-identity-bar { display:none; }
.review-workspace > .review-hero { grid-column:1; display:flex; padding:0; margin:0; border:0; background:transparent; box-shadow:none; }
.review-hero > div { display:none; }
.review-packet-label { display:flex; align-items:center; gap:8px; font-size:12px; }
.review-packet-label select { width:200px; min-height:32px; padding:4px 8px; }
.review-workspace > .writing-workflow-bar { grid-column:2; margin:0; padding:0; min-height:34px; }
.writing-workflow-bar button { min-height:32px; padding:5px 10px; }
.review-workspace[data-clinical-data-visible="false"] .review-data-panel { display:none; }
.review-workspace[data-clinical-data-visible="false"] .review-columns { display:block; }
.review-workspace .review-columns .note-draft-panel { position:static; max-height:none; border:1px solid var(--border); border-radius:4px; padding:0; display:block; }
.note-draft-panel .note-editor-toolbar { padding:8px 12px; gap:8px; min-height:44px; }
.note-editor-title h2 { font-size:15px; }
.note-editor-actions { gap:6px; }
.note-editor-actions button { min-height:30px; padding:4px 8px; }
.note-draft-panel .ed-toolbar-note { display:none; }
.writer-layout { display:grid; grid-template-columns:170px minmax(0,1fr); height:clamp(360px,calc(100dvh - 170px),900px); min-height:0; }
.writer-outline { overflow:auto; min-height:0; padding:8px; border-right:1px solid var(--border); background:var(--surface); }
.writer-outline > strong { display:block; font-size:12px; padding:4px 6px 8px; }
.writer-outline button { display:block; width:100%; min-height:27px; border:0; border-radius:3px; padding:4px 6px; text-align:left; background:transparent; font-size:12px; line-height:1.35; overflow-wrap:anywhere; }
.writer-outline button:hover,.writer-outline button[aria-current] { background:var(--accent-soft); color:var(--accent); }
.writer-outline .writer-problem-link { padding-left:18px; font-size:11px; }
.note-draft-panel .note-editor { min-height:0; max-height:none; height:100%; overflow:auto; padding:8px 12px; border:0; border-radius:0; font-size:13px; line-height:1.45; }
.note-editor details.ed-section { padding:6px 0; margin:0; }
.note-editor details.ed-section > .ed-section-body { padding-top:4px; }
.note-editor .ed-body { min-height:26px; padding:3px 5px; margin:0; }
.note-editor .ed-label { font-size:12px; text-transform:none; letter-spacing:0; }
.note-editor .ed-sub { margin:2px 0; min-width:0; }
.note-editor .ed-mini { min-height:26px; padding:3px 6px; border-radius:3px; }
.note-editor .plan-problem-card { border:1px solid var(--border); border-radius:4px; padding:8px; margin:4px 0 10px; }
.plan-problem-card > .ed-sub { display:grid; grid-template-columns:110px minmax(0,1fr); gap:8px; align-items:baseline; }
.plan-problem-card .ed-problem-bar { margin:0 0 4px; }
.plan-problem-card .ed-etiology { margin:4px 0; gap:6px; }
.note-editor .differential-row { display:grid; grid-template-columns:30px minmax(110px,1fr) minmax(120px,1fr) minmax(120px,1fr) 88px; align-items:start; gap:6px; border:0; border-bottom:1px solid var(--border); border-radius:0; margin:0; padding:5px 0; background:transparent; }
.differential-row > .ed-diff-bar,.differential-row > .ed-two { display:contents; }
.differential-row .ed-diff-bar > strong { grid-column:1; grid-row:1; padding-top:20px; font-size:11px; }
.differential-row > .ed-sub { grid-column:2; grid-row:1; }
.differential-row > .ed-two > .ed-sub:first-child { grid-column:3; grid-row:1; }
.differential-row > .ed-two > .ed-sub:last-child { grid-column:4; grid-row:1; }
.differential-row .differential-row-actions { grid-column:5; grid-row:1; padding-top:16px; display:flex; gap:2px; }
.differential-row .ed-decision1 { grid-column:1; font-size:10px; padding:1px; border-radius:2px; }
.differential-row .ed-sub-label { font-size:10px; margin:0; }
.differential-row .ed-body { font-size:13px; min-height:28px; line-height:1.35; }
.review-workspace[data-clinical-data-visible="true"] .writer-layout { grid-template-columns:minmax(0,1fr); }
.review-workspace[data-clinical-data-visible="true"] .writer-outline { display:none; }
.review-workspace[data-clinical-data-visible="true"] .differential-row { grid-template-columns:24px minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) 80px; }
@media(max-width:1040px) {
 .writer-layout { height:clamp(350px,calc(100dvh - 290px),700px); }
 .review-workspace { grid-template-columns:minmax(0,1fr); }
 .review-workspace > .review-hero,.review-workspace > .writing-workflow-bar { grid-column:1; }
}
@media(max-width:760px) {
 #reviewView { padding:6px; }
 .note-editor-toolbar,.note-editor-title,.note-editor-actions { flex-wrap:wrap; }
 .writer-layout { grid-template-columns:minmax(0,1fr); grid-template-rows:auto minmax(0,1fr); height:600px; max-height:calc(100dvh - 240px); min-height:350px; }
 .writer-outline { display:flex; overflow-x:auto; align-items:center; gap:4px; padding:4px; border-right:0; border-bottom:1px solid var(--border); }
 .writer-outline > strong { display:none; }
 .writer-outline button,.writer-outline .writer-problem-link { flex-shrink:0; width:auto; white-space:nowrap; min-height:44px; padding:6px 10px; }
 .note-editor .differential-row { grid-template-columns:22px minmax(0,1fr) minmax(0,1fr); gap:4px; padding:6px 0; }
 .differential-row > .ed-sub { grid-column:2/4; }
 .differential-row > .ed-two > .ed-sub:first-child { grid-column:2; grid-row:2; }
 .differential-row > .ed-two > .ed-sub:last-child { grid-column:3; grid-row:2; }
 .differential-row .differential-row-actions { grid-column:2/4; grid-row:3; padding:0; justify-content:flex-end; }
 .note-editor .ed-mini { min-height:36px; }
 .plan-problem-card > .ed-sub { grid-template-columns:1fr; gap:2px; }
 .review-workspace[data-clinical-data-visible="true"] .writer-layout { display:none; }
}
/* Epic import keeps the source, section index and corrections in one fixed workspace. */
.note-arrange-workspace { grid-template-columns:160px minmax(0,1fr); }
.note-arrange-workspace.has-original { grid-template-columns:minmax(0,1fr) 160px minmax(0,1.15fr); }
.note-section-index { height:clamp(300px,calc(100dvh - 370px),440px); overflow:auto; border:1px solid var(--border); border-radius:4px; padding:6px; }
.note-section-index > strong { display:block; font-size:12px; padding:4px 6px; }
.note-section-index button { display:block; width:100%; min-height:26px; padding:4px 6px; font-size:12px; line-height:1.25; text-align:left; border:0; border-radius:3px; background:transparent; }
.note-section-index button:hover { background:var(--accent-soft); }
.note-section-index button.is-note-drop-available { background:var(--accent-soft); box-shadow:inset 0 0 0 1px var(--accent); }
.note-section-index button.is-note-drop-target { background:var(--accent); color:#fff; box-shadow:0 0 0 2px var(--accent-soft), inset 0 0 0 1px var(--accent); }
.note-arrange-sections .note-section-card { padding:6px 8px; margin:0; border:0; border-bottom:1px solid var(--border); border-radius:0; }
.note-section-card .note-section-title { min-height:28px; padding:3px 0; }
.note-section-card textarea { min-height:54px; height:64px; padding:6px 8px; font-size:13px; line-height:1.4; resize:vertical; }
.structured-note-heading { margin-bottom:6px; }
.structured-note-heading h3 { font-size:15px; }
.structured-note-heading p { font-size:12px; margin:3px 0; }
.structured-note-mode-toggle { margin:6px 0; }
.structured-note-mode-toggle button { min-height:32px; padding:5px 10px; }
.source-first-stay .structured-note-paste-label textarea { height:clamp(220px,calc(100dvh - 440px),360px); min-height:180px; }
@media(max-width:900px) {
 .note-arrange-workspace.has-original { grid-template-columns:minmax(0,1fr) minmax(0,1fr); }
 .note-section-index { display:none; }
 .note-arrange-workspace:not(.has-original) { grid-template-columns:minmax(0,1fr); }
}
@media(max-width:600px) {
 .note-arrange-workspace.has-original { grid-template-columns:minmax(0,1fr); }
 .note-section-card textarea { font-size:16px; }
}
.note-editor .plan-problem-card { gap:4px; }
.note-editor .differential-builder { gap:4px; }
.note-draft-panel .ed-toolbar-note { display:block; padding:3px 12px; margin:0; font-size:11px; border-bottom:1px solid var(--border); }
@media(min-width:1041px) { .writer-layout { height:clamp(360px,calc(100dvh - 210px),900px); } }

/* Pre-send review: bounded reading panes and controls that stay in reach. */
.aic-hipaa-modal { border-radius: 8px; height: min(820px, 94dvh); box-shadow: 0 2px 8px #0003; }
.aic-hipaa-body { overscroll-behavior: contain; overflow-anchor: none; }
.aic-hipaa-body > * { flex-shrink: 0; }
.aic-hipaa-preview, .aic-hipaa-msg { max-height: 220px; overflow: auto; overscroll-behavior: contain; }
.aic-hipaa-preview { border-style: solid; border-radius: 6px; margin: 8px 0; }
.aic-hipaa-sug { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 4px 12px; border-radius: 6px; }
.aic-hipaa-sug-text { flex: 1 1 240px; }
.aic-hipaa-sug-meta { margin-left: auto; }
.aic-hipaa-stats { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.aic-hipaa-stat { border: 0; padding: 0; background: none; }
.aic-hipaa-stat-ic { display: none; }
.aic-hipaa-stat-tx { flex-direction: row; gap: 6px; align-items: baseline; }
.aic-hipaa-stat-tx strong { font-size: 13px; }
.aic-hipaa-jump { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 13px; }
.aic-hipaa-jump select { width: 220px; max-width: 55vw; min-height: 32px; font: inherit; }
.aic-hipaa-sec-title { text-transform: none; letter-spacing: normal; font-size: 13px; }
.aic-hipaa-details { margin-top: 0; }
@media (max-width: 600px) {
  .aic-hipaa-backdrop { padding: 4px; }
  .aic-hipaa-modal { height: 98dvh; max-height: 98dvh; }
  .aic-hipaa-head, .aic-hipaa-body { padding: 8px 10px; }
  .aic-hipaa-stats { padding: 0 10px; }
  .aic-hipaa-shield { display: none; }
  .aic-hipaa-head h2 { font-size: 15px; }
  .aic-hipaa-jump { margin-left: 0; }
  .aic-hipaa-foot { padding: 8px 10px; gap: 6px; }
}

.aic-hipaa-piece-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.aic-hipaa-decisions { max-height: 286px; overflow: auto; overscroll-behavior: contain; overflow-anchor: none; }
.aic-hipaa-reading { min-width: 0; }
.aic-hipaa-preview-label { font-size: 13px; }
.aic-hipaa-piece-body > .aic-hipaa-note { grid-column: 1 / -1; }
@media (max-width: 700px) {
  .aic-hipaa-piece-body { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .aic-hipaa-decisions { max-height: 180px; }
  .aic-hipaa-preview { max-height: 180px; }
}

/* Citation markers leave the sentence readable; details appear on demand. */
.aic-citation-number {
  display: inline; vertical-align: super; padding: 0 3px; margin: 0 1px;
  min-width: 0; min-height: 0; border: 0; border-radius: 2px;
  background: transparent; color: var(--accent, #245e91);
  font-family: inherit; font-size: 11px; font-weight: 600; line-height: 1; cursor: pointer;
}
.aic-citation-number:hover, .aic-citation-number:focus-visible {
  background: var(--surface-2, #eef2f5); text-decoration: underline;
}

/* ── Batch A: one app frame everywhere (audit F1) ────────────────────
   The main navigation never becomes a strip across the top. In the
   work views (Hospital Stay, Write note) at desktop width, and in
   every view at narrow widths, the sidebar collapses to a slim icon
   rail on the LEFT, mirroring the hospital-day rail: destinations are
   icons with the full label as a tooltip. Patients and Tools keep the
   full labeled sidebar at desktop width. The locked-vault rules above
   stay dominant: every selector here excludes body.vault-locked.
   ── Batch A3: hover is the only expansion route ─────────────────────
   The chevron pin is gone. The rail sits out of the grid at 56px and,
   while hovered (.app-nav-hover from app.js), animates its width to
   178px over the workspace, which never moves. Nav geometry is
   IDENTICAL in both states: the group labels and button labels stay
   in flow at full size and only fade (opacity), so no nav button ever
   changes position between rest, mid-animation, and settled-open;
   that is what makes the first click on a rail destination land. */
.roster-current {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 0 8px;
  font-size: 13px; font-weight: 600; color: var(--accent);
}
.roster-current .icon { width: 15px; height: 15px; }

/* Slim rail in the work views (any width). */
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .app-shell {
  grid-template-columns: 56px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  position: relative;
}
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .app-main {
  display: grid; grid-area: auto; grid-column: 2; grid-template-rows: 56px minmax(0, 1fr);
}
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .side-nav {
  position: absolute; top: 0; bottom: 0; left: 0; width: 56px; z-index: 60;
  display: grid; grid-template-rows: 56px minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
  align-items: stretch; gap: 0;
  padding: 0; min-height: 0; overflow: hidden;
  border-right: 1px solid var(--border); border-bottom: 0; background: var(--sidebar);
  transition: width 0.2s ease, box-shadow 0.2s ease;
}
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .app-shell.app-nav-hover .side-nav {
  width: 178px; box-shadow: 12px 0 32px #0003;
}
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .top-bar {
  grid-area: auto; justify-self: auto; align-self: auto;
  width: auto; height: 56px; min-height: 56px; padding: 10px 20px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .workspace { grid-area: auto; }
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .patient-switcher { width: min(310px, 100%); }
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .brand-lockup {
  display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 14px 14px 12px;
}
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .brand-copy {
  display: block; flex: none; white-space: nowrap; opacity: 0; transition: opacity 0.18s ease 0.05s;
}
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .app-shell.app-nav-hover .brand-copy { opacity: 1; }
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .brand-mark { display: grid; }
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .primary-nav {
  display: grid; align-content: start; align-items: stretch; gap: 4px; padding: 10px 8px;
  grid-template-columns: minmax(0, 1fr);
  overflow-y: auto; overflow-x: hidden;
}
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .primary-nav > .nav-group {
  display: grid; align-content: start; gap: 4px; margin: 0; min-width: 0;
}
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .nav-group-label {
  display: block; margin: 10px 8px 2px; white-space: nowrap; overflow: hidden;
  opacity: 0; transition: opacity 0.18s ease 0.05s;
}
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .nav-group:first-child .nav-group-label {
  margin-top: 2px;
}
/* The retired top-strip block above hides the first group's label with
   a more specific selector; the rail shows every group label. */
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .primary-nav > .nav-group > .nav-group-label { display: block; }
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .app-shell.app-nav-hover .nav-group-label { opacity: 1; }
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .secondary-navigation { display: block; position: static; align-self: stretch; }
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .secondary-navigation > summary { display: none; }
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .secondary-navigation[open] > .secondary-navigation-panel {
  display: grid; gap: 4px; position: static; width: auto; max-height: none;
  grid-template-columns: minmax(0, 1fr);
  padding: 0; border: 0; box-shadow: none; background: transparent;
}
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .secondary-navigation .nav-group { min-width: 0; }
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .primary-nav .nav-group > button {
  display: grid; grid-template-columns: 16px minmax(0, 1fr); place-items: stretch; align-items: center;
  width: 100%; min-width: 0; min-height: 40px; padding: 7px 8px 7px 12px;
  border-bottom: 0; border-radius: 6px; text-align: left; white-space: normal;
}
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .primary-nav .nav-group > button.active {
  border-left: 3px solid var(--accent); padding-left: 9px;
}
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .primary-nav .nav-group > button > span {
  display: block; white-space: nowrap; overflow: hidden; opacity: 0; transition: opacity 0.18s ease 0.05s;
}
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .app-shell.app-nav-hover .primary-nav .nav-group > button > span { opacity: 1; }
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .side-footer { display: none; }
body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .app-shell.app-nav-hover .side-footer { display: grid; }

/* Slim rail at narrow widths (every view): the shell stays a fixed
   two-column frame and each view scrolls inside its own pane, exactly
   like the desktop layout. */
@media (max-width: 1040px) {
  body:not(.vault-locked) .app-shell {
    display: grid; grid-template-columns: 56px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr);
    height: 100dvh; max-height: 100dvh;
    position: relative;
  }
  body:not(.vault-locked) .app-main {
    display: grid; grid-area: auto; grid-column: 2; grid-template-rows: 56px minmax(0, 1fr); min-height: 0;
  }
  body:not(.vault-locked) .side-nav {
    position: absolute; top: 0; bottom: 0; left: 0; width: 56px; z-index: 60;
    display: grid; grid-template-rows: 56px minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
    align-items: stretch; gap: 0;
    padding: 0; min-height: 0; overflow: hidden;
    border-right: 1px solid var(--border); border-bottom: 0; background: var(--sidebar);
    transition: width 0.2s ease, box-shadow 0.2s ease;
  }
  body:not(.vault-locked) .app-shell.app-nav-hover .side-nav {
    width: 178px; box-shadow: 12px 0 32px #0003;
  }
  body:not(.vault-locked) .top-bar {
    grid-area: auto; justify-self: auto; align-self: auto;
    width: auto; height: 56px; min-height: 56px; padding: 8px 10px;
    border-bottom: 1px solid var(--border); background: var(--surface);
  }
  /* The frame stays fixed; the workspace is the single scrolling pane
     and each view keeps its natural height, exactly how the narrow
     layouts were designed to flow (a height:100% view makes
     height:100% content roots spill over following siblings). */
  body:not(.vault-locked) .workspace { grid-area: auto; min-height: 0; overflow-y: auto; overflow-x: hidden; }
  body:not(.vault-locked) .view { height: auto; overflow: visible; }
  body:not(.vault-locked) .patient-switcher { width: min(310px, 100%); }
  body:not(.vault-locked) .brand-lockup {
    display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 14px 14px 12px;
  }
  body:not(.vault-locked) .brand-copy {
    display: block; flex: none; white-space: nowrap; opacity: 0; transition: opacity 0.18s ease 0.05s;
  }
  body:not(.vault-locked) .app-shell.app-nav-hover .brand-copy { opacity: 1; }
  body:not(.vault-locked) .primary-nav {
    display: grid; align-content: start; align-items: stretch; gap: 4px; padding: 10px 8px;
    grid-template-columns: minmax(0, 1fr);
    overflow-y: auto; overflow-x: hidden;
  }
  body:not(.vault-locked) .primary-nav > .nav-group {
    display: grid; align-content: start; gap: 4px; margin: 0; min-width: 0;
    /* The older narrow layout put the group buttons in 3 columns; the
       rail stacks them in one column. */
    grid-template-columns: none;
  }
  body:not(.vault-locked) .secondary-navigation .nav-group {
    display: grid; align-content: start; gap: 4px; margin: 0; min-width: 0;
    grid-template-columns: none;
  }
  body:not(.vault-locked) .nav-group-label {
    display: block; margin: 10px 8px 2px; white-space: nowrap; overflow: hidden;
    opacity: 0; transition: opacity 0.18s ease 0.05s;
  }
  body:not(.vault-locked) .nav-group:first-child .nav-group-label { margin-top: 2px; }
  /* The older narrow block above hides the first group's label with a
     more specific selector; the rail shows every group label. */
  body:not(.vault-locked) .primary-nav > .nav-group > .nav-group-label { display: block; }
  body:not(.vault-locked) .app-shell.app-nav-hover .nav-group-label { opacity: 1; }
  body:not(.vault-locked) .secondary-navigation { display: block; position: static; align-self: stretch; }
  body:not(.vault-locked) .secondary-navigation > summary { display: none; }
  body:not(.vault-locked) .secondary-navigation[open] > .secondary-navigation-panel {
    display: grid; gap: 4px; position: static; width: auto; max-height: none;
    grid-template-columns: minmax(0, 1fr);
    padding: 0; border: 0; box-shadow: none; background: transparent;
  }
  body:not(.vault-locked) .primary-nav .nav-group > button {
    display: grid; grid-template-columns: 16px minmax(0, 1fr); place-items: stretch; align-items: center;
    width: 100%; min-width: 0; min-height: 40px; padding: 7px 8px 7px 12px;
    border-bottom: 0; border-radius: 6px; text-align: left; white-space: normal;
  }
  body:not(.vault-locked) .primary-nav .nav-group > button.active {
    border-left: 3px solid var(--accent); padding-left: 9px;
  }
  body:not(.vault-locked) .primary-nav .nav-group > button > span {
    display: block; white-space: nowrap; overflow: hidden; opacity: 0; transition: opacity 0.18s ease 0.05s;
  }
  body:not(.vault-locked) .app-shell.app-nav-hover .primary-nav .nav-group > button > span { opacity: 1; }
  body:not(.vault-locked) .side-footer { display: none; }
  body:not(.vault-locked) .app-shell.app-nav-hover .side-footer { display: grid; }
}

/* At phone widths the top bar keeps its single 56px row: the patient
   switcher takes the row as a full-width select (its label stays as the
   control's accessible name), instead of wrapping onto a second row. */
@media (max-width: 680px) {
  body:not(.vault-locked) .top-bar { display: flex; align-items: center; }
  body:not(.vault-locked) .top-controls { display: flex; width: 100%; }
  body:not(.vault-locked) .patient-switcher { display: block; width: 100%; font-size: 0; }
  body:not(.vault-locked) .patient-switcher select { width: 100%; font-size: 12px; }
}

/* ── Batch A3: reduced motion ────────────────────────────────────────
   The hover expansion still happens for reduced-motion users, but
   nothing animates: the width change and the label fades are instant.
   (The rail positioning itself lives in the Batch A rail blocks
   above: the side nav is out of the grid at 56px, z-index 60 keeps it
   above workspace content but below the AI Chat drawer (70) and the
   guided-demo layers (90+), and the grid column stays 56px so the
   workspace box never moves. Pointer-only: app.js ignores touch
   pointerenter, so a tap on a destination never triggers it.) */
@media (prefers-reduced-motion: reduce) {
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .side-nav,
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .brand-copy,
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .nav-group-label,
  body:not(.vault-locked):has(#dailyView.active, #reviewView.active) .primary-nav .nav-group > button > span { transition: none; }
}
@media (max-width: 1040px) and (prefers-reduced-motion: reduce) {
  body:not(.vault-locked) .side-nav,
  body:not(.vault-locked) .brand-copy,
  body:not(.vault-locked) .nav-group-label,
  body:not(.vault-locked) .primary-nav .nav-group > button > span { transition: none; }
}
/* Session-only AI review uses the same ordinary dialog and form controls. */
.external-ai-review { width: min(760px, calc(100vw - 32px)); max-height: 85vh; overflow: auto; padding: 20px; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.external-ai-review > label, .external-ai-review label { display: block; margin: 12px 0; }
.external-ai-review textarea { display: block; width: 100%; margin-top: 6px; resize: vertical; }
.external-ai-review pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 40vh; overflow: auto; }
.external-ai-review::backdrop { background: rgb(0 0 0 / 35%); }
.external-ai-review .external-ai-ack { display: flex; align-items: flex-start; gap: 8px; }
.external-ai-review input[type="checkbox"] { flex: 0 0 16px; width: 16px; height: 16px; min-height: 16px; margin: 2px 0 0; }
.ap-confirm-modal label:has(> input[type="checkbox"]) { display: flex; align-items: flex-start; gap: 8px; }
.ap-confirm-modal input[type="checkbox"] { flex: 0 0 16px; width: 16px; height: 16px; min-height: 16px; margin: 2px 0 0; }

/* Outgoing privacy review: readable question first; supporting text by disclosure. */
.external-ai-review { box-sizing: border-box; }
.external-ai-review h3 { margin: 0 0 8px; }
.external-ai-review h4 { margin: 16px 0 8px; font-size: 1rem; }
.external-ai-review .external-ai-destination { margin: 0 0 12px; color: var(--muted); overflow-wrap: anywhere; }
.external-ai-review [data-external-review-status] { padding: 8px 0; border-block: 1px solid var(--border); }
.external-ai-review details { padding: 10px 0; border-bottom: 1px solid var(--border); }
.external-ai-review summary { cursor: pointer; overflow-wrap: anywhere; }
.external-ai-review textarea { min-height: 96px; max-height: 35vh; font: inherit; line-height: 1.5; box-sizing: border-box; }
.external-ai-review section textarea { min-height: 144px; }
.external-ai-review .button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.aic-hipaa-summary { margin: 0; padding: 10px 20px; border-bottom: 1px solid var(--border); font-size: 14px; }

.local-model-controls { padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.local-model-controls select { width: 100%; min-width: 0; }
.local-model-controls p { margin: 8px 0; font-size: 0.9rem; line-height: 1.5; overflow-wrap: anywhere; }
.local-model-controls progress { width: 100%; }
.local-model-controls input[type="number"] { width: 100%; box-sizing: border-box; }

/* Modal layout rules must respect intentional presentation visibility. */
.external-ai-review [hidden] { display: none !important; }
.encounter-review { min-width:0; border:1px solid var(--border); border-radius:6px; margin-bottom:12px; background:var(--surface, var(--panel, transparent)); }
.source-first-stay .stay-content { grid-template-columns:minmax(0,1fr); }
.encounter-review > summary { padding:12px 16px; cursor:pointer; font-weight:600; }
.encounter-review > summary .muted { margin-left:8px; font-weight:400; }
.encounter-review-body { padding:0 16px 16px; }
.encounter-review-tabs { border-bottom:1px solid var(--border); padding-bottom:8px; }
.encounter-review-tabs [aria-pressed="true"] { font-weight:700; text-decoration:underline; text-underline-offset:5px; }
.encounter-feedback:empty { display:none; }
.encounter-items { display:grid; gap:0; }
.encounter-item { padding:12px 0; border-bottom:1px solid var(--border); min-width:0; }
.encounter-item:last-child { border-bottom:0; }
.encounter-item-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.encounter-item blockquote { white-space:pre-wrap; overflow-wrap:anywhere; margin:8px 0; padding:4px 12px; border-left:2px solid var(--border); max-height:180px; overflow:auto; }
.encounter-item > label { display:block; max-width:440px; margin-top:8px; }
.encounter-filter { display:block; max-width:320px; margin:12px 0; }
.encounter-history { margin-top:8px; }
.encounter-history ol { max-height:180px; overflow:auto; padding-left:24px; }
.encounter-source-link { text-align:left; white-space:normal; }
.encounter-source-controls { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,2fr); gap:12px; margin-bottom:12px; }
.encounter-source-browser textarea { width:100%; min-height:200px; max-height:420px; resize:vertical; white-space:pre-wrap; }
.encounter-warning { color:var(--danger, #a52e2e); font-weight:600; }
.encounter-comparison > label { display:block; max-width:440px; }
.encounter-compare-row { border-top:1px solid var(--border); padding:10px 0; }
.encounter-compare-row summary { cursor:pointer; }
.encounter-compare-row summary span { margin-left:8px; }
.encounter-compare-columns { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:16px; }
.encounter-compare-columns h3 { font-size:14px; margin:12px 0 8px; }
.encounter-compare-columns pre { white-space:pre-wrap; overflow-wrap:anywhere; font:inherit; max-height:380px; overflow:auto; }
.encounter-compare-columns mark { background:var(--surface-tint); color:inherit; border-bottom:1px solid var(--border); }
.encounter-plan-passages { margin:12px 0; }
.encounter-plan-passages > div { display:flex; justify-content:space-between; gap:12px; align-items:start; padding:8px 0; border-bottom:1px solid var(--border); }
.encounter-plan-passages > div > span { white-space:pre-wrap; overflow-wrap:anywhere; min-width:0; }
.encounter-plan-passages button { flex-shrink:0; }
@media(max-width:680px) {
  .encounter-review select { min-width:0; max-width:100%; }
  .encounter-review > summary .muted { display:block; margin:4px 0 0; }
  .encounter-source-controls, .encounter-compare-columns { grid-template-columns:minmax(0,1fr); }
  .encounter-review-body { padding:0 12px 12px; }
}

.encounter-item-details { margin-top: 8px; }
.encounter-item-details > summary { cursor: pointer; color: var(--muted); }

/* .aloop stuck fixes (2026-10-20) */
.deid-operation-detail { color: var(--muted); font-size: 12px; white-space: nowrap; }
.redaction-summary { margin: 10px 0; border: 1px solid var(--border, #d8dee9); border-radius: 8px; padding: 8px 10px; }
.redaction-summary > summary { cursor: pointer; font-weight: 600; }
.redaction-summary-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 260px; overflow: auto; display: grid; gap: 6px; }
.redaction-summary-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--border, #d8dee9); padding-top: 6px; }
.redaction-summary-change { overflow-wrap: anywhere; min-width: 0; }
.redaction-summary-change del { opacity: 0.75; }
.redaction-summary-change ins { text-decoration: none; font-weight: 600; }
.redaction-summary-state { color: var(--muted); font-size: 12px; }
.redaction-summary-actions { margin-left: auto; display: inline-flex; gap: 4px; }
.guided-demo-callout-dismiss { margin-top: 8px; }
.aic-get-model { display: flex; align-items: center; gap: 10px; padding: 6px 2px 2px; flex-wrap: wrap; }
.quick-deid-empty-hint { color: var(--muted); font-weight: 600; }
.scribe-download-total { font-size: 15px; }
#admissionDateDialog label { display: grid; gap: 4px; margin-top: 10px; }

/* Writer AI feedback panel (2026-10-21) */
.wf-panel { border: 1px solid var(--border, #d8dee9); border-radius: 8px; padding: 10px 12px; margin: 10px 0; display: grid; gap: 10px; }
.wf-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.wf-panel-head h3 { margin: 0; }
.wf-panel-head p { margin: 4px 0 0; }
.wf-controls { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.wf-control-group { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.wf-control-label { font-weight: 600; font-size: 13px; }
.wf-send-note { margin: 0; }
.wf-scope-note { margin: 0; }
.wf-status { margin: 0; font-weight: 600; }
.wf-error { margin: 0; color: #b91c1c; font-weight: 600; }
.wf-notice { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border: 1px solid var(--border, #d8dee9); border-radius: 8px; padding: 8px 10px; }
.wf-notice p { margin: 0; }
.wf-items { display: grid; gap: 8px; }
.wf-item { border-top: 1px solid var(--border, #d8dee9); padding-top: 8px; }
.wf-item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wf-kind { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 8px; background: #e2e8f0; color: #1e293b; }
.wf-kind--works { background: #dcfce7; color: #166534; }
.wf-kind--unclear { background: #fef3c7; color: #92400e; }
.wf-kind--missing { background: #fee2e2; color: #991b1b; }
.wf-comment { margin: 6px 0 0; }
.wf-rewrite { margin-top: 8px; display: grid; gap: 6px; }
.wf-rewrite-label { font-weight: 600; font-size: 13px; }
.wf-rewrite pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--border, #d8dee9); border-radius: 8px; padding: 8px 10px; }
.cs-worksheet-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.cs-worksheet-normal { flex: none; min-height: 36px; background: none; border: 1px solid var(--line-strong); border-radius: 999px; padding: 6px 12px; font-size: 0.82rem; font-weight: 600; color: var(--text); cursor: pointer; }
.cs-worksheet-normal-all { min-height: 44px; background: none; border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 16px; font-size: 0.95rem; color: var(--text); cursor: pointer; }
.cs-worksheet-add-detail { background: none; border: 0; padding: 6px 2px; margin-top: 4px; font-size: 0.85rem; font-weight: 600; color: var(--accent); cursor: pointer; }
