:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #eef3f6;
  --ink: #18212b;
  --muted: #607080;
  --line: #d7e0e7;
  --teal: #007c89;
  --green: #26824a;
  --amber: #b56a00;
  --red: #ba3b32;
  --blue: #2867b2;
  --violet: #6c4ab6;
  --shadow: 0 18px 45px rgba(21, 32, 43, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body {
  overflow-x: hidden;
}

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

button {
  cursor: pointer;
}

.shell {
  width: min(1360px, calc(100% - 36px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.showcase-top {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(360px, 0.65fr);
  gap: 22px;
  align-items: start;
  padding: 18px 0 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.2rem, 4vw, 4.35rem);
  line-height: 1.04;
  font-weight: 850;
}

.showcase-copy {
  max-width: 740px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.55;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(78px, 1fr));
  gap: 10px;
  max-width: 520px;
  margin-top: 20px;
}

.summary-pill {
  padding: 14px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.summary-pill strong {
  display: block;
  font-size: 1.75rem;
  line-height: 1;
}

.summary-pill span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin: 10px 0 20px;
}

.live-wall {
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--teal) 32%, var(--line));
  border-radius: 8px;
  background: #102330;
  box-shadow: var(--shadow);
}

.live-wall canvas {
  display: block;
  width: 100%;
  height: 282px;
}

.live-wall-footer {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
}

.live-wall-footer span {
  min-width: 0;
  padding: 12px 6px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.72rem;
  font-weight: 850;
  text-align: center;
  text-transform: uppercase;
}

.filter-btn,
.back-btn,
.primary-btn,
.ghost-btn,
.mini-btn,
.app-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

.filter-btn,
.back-btn,
.primary-btn,
.ghost-btn,
.mini-btn {
  min-height: 38px;
  padding: 8px 12px;
  font-weight: 800;
}

.filter-btn.active,
.primary-btn {
  border-color: transparent;
  background: var(--ink);
  color: #fff;
}

.ghost-btn {
  background: #f9fbfc;
}

.mini-btn {
  min-width: 36px;
  min-height: 32px;
  padding: 5px 9px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 16px;
}

.app-card {
  position: relative;
  display: grid;
  min-height: 242px;
  padding: 17px;
  overflow: hidden;
  text-align: left;
  box-shadow: 0 8px 24px rgba(21, 32, 43, 0.05);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease;
}

.app-card:hover,
.app-card:focus-visible {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  box-shadow: var(--shadow);
  outline: none;
}

.card-visual {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  height: 60px;
  margin-bottom: 16px;
}

.card-visual::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 5px;
  height: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 60%, #ffffff);
}

.visual-cell {
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 22%, #ffffff);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
}

.visual-cell:nth-child(2n) {
  transform: translateY(8px);
}

.visual-cell:nth-child(3n) {
  background: color-mix(in srgb, var(--accent) 42%, #ffffff);
}

.visual-cell:nth-child(5n) {
  background: color-mix(in srgb, var(--accent) 55%, #ffffff);
}

.subject-chip,
.concept-chip,
.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, #ffffff);
  color: color-mix(in srgb, var(--accent) 82%, #111111);
  font-size: 0.74rem;
  font-weight: 850;
}

.app-card h2 {
  margin: 10px 0 8px;
  font-size: 1.17rem;
  line-height: 1.2;
}

.app-card p {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.91rem;
  line-height: 1.45;
}

.card-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-self: end;
}

.app-view {
  min-height: 100vh;
  background: var(--bg);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 246, 248, 0.95);
  backdrop-filter: blur(12px);
}

.app-header-inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: min(1360px, calc(100% - 36px));
  margin: 0 auto;
  padding: 12px 0;
}

.app-title-block h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.18;
}

.app-title-block p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.app-body {
  width: min(1360px, calc(100% - 36px));
  margin: 0 auto;
  padding: 20px 0 38px;
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}

.visual-panel,
.control-panel,
.metric-panel,
.wide-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(21, 32, 43, 0.05);
}

.visual-panel {
  overflow: hidden;
}

.visual-panel-header,
.panel-pad {
  padding: 15px;
}

.visual-panel-header {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.visual-panel-header h2,
.control-panel h2,
.metric-panel h2,
.wide-panel h2 {
  margin: 0;
  font-size: 1rem;
}

.visual-panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.lab-canvas {
  display: block;
  width: 100%;
  height: 466px;
  background: #ffffff;
}

.control-stack {
  display: grid;
  gap: 12px;
  padding: 15px;
}

.control-row {
  display: grid;
  gap: 7px;
}

.control-row label,
.input-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.control-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.control-row select,
.control-row input[type="number"],
.control-row input[type="text"],
.control-row textarea,
.field {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfdfe;
  color: var(--ink);
}

.control-row textarea {
  min-height: 76px;
  resize: vertical;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 15px;
}

.metric-box {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.metric-box span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.metric-box strong {
  display: block;
  margin-top: 6px;
  font-size: 1.18rem;
  line-height: 1.15;
}

.side-stack {
  display: grid;
  gap: 16px;
}

.concept-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 15px 15px;
}

.concept-chip {
  --accent: var(--teal);
}

.split-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.9rem;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.punnett-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.punnett-cell {
  min-height: 74px;
  display: grid;
  place-items: center;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  font-weight: 850;
}

.punnett-cell:nth-child(3n) {
  border-right: none;
}

.punnett-cell:nth-last-child(-n + 3) {
  border-bottom: none;
}

.punnett-head {
  background: color-mix(in srgb, var(--accent) 12%, #ffffff);
  color: color-mix(in srgb, var(--accent) 70%, #111111);
}

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: var(--value);
  background: var(--accent);
}

.equation-grid {
  display: grid;
  gap: 10px;
}

.formula-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.coef-control {
  display: grid;
  grid-template-columns: 36px 42px 36px;
  gap: 4px;
  align-items: center;
}

.coef-value {
  display: grid;
  place-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-weight: 850;
}

.atom-ok {
  color: var(--green);
  font-weight: 850;
}

.atom-warn {
  color: var(--red);
  font-weight: 850;
}

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

.lock-tile {
  min-height: 118px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.lock-tile.done {
  border-color: color-mix(in srgb, var(--green) 50%, var(--line));
  background: color-mix(in srgb, var(--green) 10%, #ffffff);
}

.lock-tile strong {
  display: block;
  margin-bottom: 8px;
}

.lock-symbol {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-bottom: 10px;
  border: 2px solid currentColor;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 900;
}

.lock-tile.done .lock-symbol {
  color: var(--green);
}

.reflection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(236px, 1fr));
  gap: 12px;
}

.reflection-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.reflection-card h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.reflection-card p {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.42;
}

.medical-report {
  background: #f8fbfc;
}

.medical-header {
  background: #ffffff;
}

.medical-command {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: #102330;
  color: #ffffff;
}

.medical-command div {
  min-width: 0;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.05);
}

.medical-command span,
.clinical-kicker,
.clinical-card span,
.lab-table td span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.medical-command span {
  color: rgba(255, 255, 255, 0.64);
}

.medical-command strong {
  display: block;
  margin-top: 5px;
  font-size: 1rem;
}

.anatomy-stage {
  position: relative;
  min-height: 480px;
  overflow: hidden;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #0c1b27;
}

.anatomy-canvas {
  display: block;
  width: 100%;
  height: 480px;
}

.anatomy-overlay {
  position: absolute;
  left: 16px;
  top: 14px;
  width: min(260px, calc(100% - 32px));
  padding: 13px 14px;
  border: 1px solid rgba(130, 224, 233, 0.26);
  border-radius: 8px;
  background: rgba(8, 21, 30, 0.72);
  color: #ffffff;
  backdrop-filter: blur(8px);
}

.anatomy-overlay span,
.anatomy-readouts span {
  display: block;
  color: rgba(204, 241, 245, 0.72);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.anatomy-overlay strong {
  display: block;
  margin-top: 4px;
  font-size: 1.08rem;
}

.anatomy-overlay p {
  margin: 8px 0 0;
  color: rgba(235, 249, 250, 0.78);
  font-size: 0.82rem;
  line-height: 1.38;
}

.anatomy-readouts {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: calc(100% - 28px);
}

.anatomy-readouts span {
  min-height: 28px;
  padding: 7px 10px;
  border: 1px solid rgba(130, 224, 233, 0.24);
  border-radius: 999px;
  background: rgba(8, 21, 30, 0.68);
  color: rgba(235, 249, 250, 0.88);
  backdrop-filter: blur(8px);
}

.anatomy-readouts span[data-state="review"] {
  border-color: rgba(240, 178, 63, 0.72);
  color: #ffd58a;
}

.clinical-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: 8px;
  background: #ffffff;
}

.clinical-summary h2 {
  margin: 4px 0 8px;
  font-size: 1.28rem;
}

.clinical-summary p,
.medical-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.48;
  font-size: 0.9rem;
}

.clinical-alert {
  display: grid;
  place-items: center;
  min-width: 96px;
  min-height: 64px;
  padding: 12px;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 900;
  text-transform: uppercase;
}

.clinical-alert.clear {
  background: var(--green);
}

.clinical-alert.review {
  background: var(--amber);
}

.clinical-alert.priority {
  background: var(--red);
}

.clinical-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.clinical-card {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.clinical-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
}

.clinical-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.38;
}

.lab-table td:first-child {
  min-width: 150px;
}

.lab-table td:last-child {
  min-width: 230px;
  color: var(--muted);
}

.result-flag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 900;
}

.result-flag.normal {
  background: color-mix(in srgb, var(--green) 13%, #ffffff);
  color: var(--green);
}

.result-flag.low,
.result-flag.high {
  background: color-mix(in srgb, var(--amber) 15%, #ffffff);
  color: #8a5200;
}

.result-flag.critical {
  background: color-mix(in srgb, var(--red) 13%, #ffffff);
  color: var(--red);
}

.result-flag.missing {
  background: #eef3f6;
  color: var(--muted);
}

.medical-form-section {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

.medical-form-section + .medical-form-section {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.medical-form-section h3 {
  margin: 0;
  color: var(--ink);
  font-size: 0.9rem;
}

.status-line {
  min-height: 26px;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 980px) {
  .showcase-top,
  .app-layout,
  .split-two {
    grid-template-columns: 1fr;
  }

  .summary-strip {
    max-width: none;
  }

  .app-header-inner {
    grid-template-columns: 1fr;
  }

  .app-header-inner .subject-chip {
    width: fit-content;
  }

  .lab-canvas {
    height: 360px;
  }

  .live-wall canvas {
    height: 240px;
  }

  .medical-command,
  .clinical-grid {
    grid-template-columns: 1fr;
  }

  .bloodwork-layout .side-stack {
    order: -1;
  }

  .anatomy-canvas {
    height: 400px;
  }

  .anatomy-stage {
    min-height: 400px;
  }
}

@media (max-width: 620px) {
  .shell,
  .app-body,
  .app-header-inner {
    width: min(100% - 24px, 1360px);
  }

  h1 {
    font-size: 2rem;
  }

  .metric-grid,
  .room-grid {
    grid-template-columns: 1fr;
  }

  .summary-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 14px;
  }

  .summary-pill {
    padding: 10px 8px;
  }

  .summary-pill strong {
    font-size: 1.35rem;
  }

  .summary-pill span {
    font-size: 0.62rem;
  }

  .live-wall canvas {
    height: 162px;
  }

  .live-wall-footer {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .live-wall-footer span {
    padding: 8px 3px;
    font-size: 0.58rem;
  }

  .clinical-summary {
    grid-template-columns: 1fr;
  }

  .anatomy-overlay {
    position: static;
    width: auto;
    margin: 10px;
  }

  .anatomy-readouts {
    left: 10px;
    right: 10px;
    justify-content: flex-start;
  }

  .anatomy-canvas {
    height: 340px;
  }

  .anatomy-stage {
    min-height: 340px;
  }

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