:root {
  --bg: #000000;
  --paper: #111111;
  --paper-soft: #1a1a1a;
  --ink: #ffffff;
  --muted: #a0a0a0;
  --border: #333333;
  --accent: #FF3366;
  --accent-dark: #cc2952;
  --teal: #00D3B6;
  --ok: #00D3B6;
  --warn: #ffb703;
  --danger: #FF3366;
  --shadow: 0 18px 34px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "SF Pro Display", "Avenir Next", sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

body.sheet-open {
  overflow: hidden;
}

.bg-aura {
  position: fixed;
  border-radius: 999px;
  filter: blur(80px);
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
}

.bg-aura-a {
  width: 360px;
  height: 360px;
  top: -120px;
  right: -120px;
  background: var(--accent);
}

.bg-aura-b {
  width: 360px;
  height: 360px;
  bottom: -120px;
  left: -120px;
  background: var(--teal);
}

.layout {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 12px 30px;
  display: grid;
  gap: 10px;
}

.hero,
.panel,
.subpanel {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.hero {
  padding: 16px 14px;
  background: linear-gradient(120deg, #181818 0%, #0d0d0d 100%);
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal);
  font-weight: 760;
}

h1 {
  margin: 8px 0 8px;
  font-size: 30px;
  line-height: 1.05;
}

.sub {
  margin: 0;
  color: var(--muted);
  max-width: 880px;
}

/* GPU inference note */
.gpu-note {
  margin: 10px 0 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 183, 3, 0.08);
  border: 1px solid rgba(255, 183, 3, 0.25);
  color: var(--warn);
  font-size: 12px;
  line-height: 1.45;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.gpu-note-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.gpu-note strong {
  color: #fff;
}

/* Inference loading overlay */
.inference-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.inference-loader[hidden] {
  display: none !important;
}

.loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.loader-spinner {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 4px solid rgba(255, 51, 102, 0.15);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
  box-shadow: 0 0 24px rgba(255, 51, 102, 0.2);
}

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

.loader-title {
  margin: 0;
  font-size: 18px;
  font-weight: 760;
  color: var(--ink);
  animation: pulse-text 2s ease-in-out infinite;
}

@keyframes pulse-text {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.loader-sub {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  max-width: 300px;
}

.loader-sub strong {
  color: var(--warn);
}

.loader-elapsed {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--teal);
  font-variant-numeric: tabular-nums;
}

.vitals-chip {
  border: 1px solid var(--border);
  background: var(--paper-soft);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 760;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.vitals-chip span {
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: rgba(255, 51, 102, 0.2);
  color: var(--accent);
  font-size: 12px;
}

.vitals-chip.ok {
  border-color: var(--teal);
  background: rgba(0, 211, 182, 0.1);
  color: var(--ink);
}

.vitals-chip.ok span {
  background: var(--teal);
  color: #000;
}

.vitals-chip.needs-input {
  border-color: var(--accent);
  background: rgba(255, 51, 102, 0.1);
  color: var(--ink);
}

.panel {
  padding: 12px;
}

.panel-compact {
  padding: 12px 14px;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 20px;
}

.panel h3 {
  margin: 0 0 9px;
  font-size: 16px;
}

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

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

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

.subpanel {
  padding: 12px;
  background: var(--paper-soft);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.required-hint {
  margin: 6px 0 12px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 650;
}

.required-hint.ok {
  color: var(--ok);
}

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

.diagnose-row {
  margin-top: 8px;
}

.mode-diagnose {
  width: 100%;
}

.mode-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--paper-soft);
  color: var(--ink);
  padding: 12px 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 118px;
  gap: 8px;
  text-align: center;
}

.mode-card.active {
  border-color: var(--teal);
  background: linear-gradient(135deg, rgba(0, 211, 182, 0.15) 0%, rgba(0, 211, 182, 0.05) 100%);
  box-shadow: 0 0 15px rgba(0, 211, 182, 0.2);
}

.mode-card.has-data {
  position: relative;
}

.mode-card.has-data::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--teal);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--teal);
}

.clear-mode-btn {
  font-size: 11px;
  padding: 4px 8px;
  background: rgba(255, 51, 102, 0.1);
  color: var(--danger);
  border-color: rgba(255, 51, 102, 0.2);
  margin-top: 4px;
}

.mode-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
  font-size: 18px;
  font-weight: 760;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
}

.mode-diagnose {
  border-color: var(--border);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
}

.mode-diagnose .mode-copy small {
  color: rgba(255, 255, 255, 0.7);
}

.diagnose-icon {
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
}

.mode-copy strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
}

.mode-copy small {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.mode-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.mode-panel {
  display: none;
}

.mode-panel.active {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 210px;
}

#textPanel.active {
  min-height: 230px;
}

#voicePanel .row-inline {
  flex-wrap: wrap;
}

#imagePanel .grid-two {
  grid-template-columns: 1fr;
}

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

.checks {
  display: grid;
  gap: 7px;
}

.checks-inline {
  margin-top: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 650;
}

label {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--muted);
  font-weight: 760;
}

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

input,
select,
textarea {
  width: 100%;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--ink);
  padding: 10px 11px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(0, 211, 182, 0.25);
  border-color: var(--teal);
}

textarea {
  resize: vertical;
}

.row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.row-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

button {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--paper-soft);
  color: var(--ink);
  padding: 9px 14px;
  font-weight: 760;
  cursor: pointer;
  transition: transform 80ms ease, box-shadow 80ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

button.primary {
  background: linear-gradient(130deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-color: var(--accent-dark);
  color: #fff;
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.actions button {
  width: 100%;
}

button.primary {
  font-size: 20px;
  padding: 12px 14px;
}

.status {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.validation {
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.health-line {
  font-size: 13px;
  color: var(--muted);
}

.health-line.ok {
  color: var(--ok);
  font-weight: 700;
}

.health-line.err {
  color: var(--danger);
  font-weight: 700;
}

.preview {
  display: none;
  width: 100%;
  max-height: 210px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--paper);
}

.summary-grid {
  display: grid;
  gap: 7px;
  grid-template-columns: 1fr;
  margin-bottom: 10px;
}

.summary-grid p {
  margin: 0;
  font-size: 13px;
}

#riskLevel.green {
  color: var(--ok);
  font-weight: 760;
}

#riskLevel.yellow {
  color: var(--warn);
  font-weight: 760;
}

#riskLevel.red {
  color: var(--danger);
  font-weight: 760;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

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

.carousel-nav button {
  padding: 6px 10px;
  font-size: 12px;
}

.carousel-bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  gap: 12px;
  margin-bottom: 8px;
}

.carousel-bottom-nav button {
  flex: 1;
  padding: 14px 10px;
  font-size: 16px;
  border-radius: 12px;
}

.nav-primary {
  background: linear-gradient(130deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  border-color: var(--accent-dark);
}

.nav-secondary {
  background: var(--paper-soft);
  color: var(--ink);
  border-color: var(--border);
}

#cardPosition {
  min-width: 48px;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
}

.result-card {
  display: none;
  border: none;
  background: transparent;
  padding: 0;
  min-height: auto;
  margin-top: 16px;
}

.result-card.is-active {
  display: block;
}

.watch-hero-metrics {
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-top: 20px;
}

.risk-center-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.muted-label {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.risk-pill-hero {
  font-size: 32px;
  font-weight: 900;
  padding: 16px 36px;
  border-radius: 999px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  display: inline-block;
  letter-spacing: 0.02em;
}

.risk-pill-hero.green,
.risk-pill-hero.low {
  background: rgba(30, 215, 96, 0.15);
  color: #1ed760;
  border: 2px solid #1ed760;
  box-shadow: 0 0 24px rgba(30, 215, 96, 0.3);
}

.risk-pill-hero.yellow,
.risk-pill-hero.mid {
  background: rgba(255, 204, 0, 0.15);
  color: #ffcc00;
  border: 2px solid #ffcc00;
  box-shadow: 0 0 24px rgba(255, 204, 0, 0.3);
}

.risk-pill-hero.red,
.risk-pill-hero.high,
.risk-pill-hero.critical {
  background: rgba(255, 51, 102, 0.15);
  color: #ff3366;
  border: 2px solid #ff3366;
  box-shadow: 0 0 24px rgba(255, 51, 102, 0.3);
}

.metric-compact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.metric-compact-box {
  background: var(--paper-soft);
  padding: 16px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.metric-compact-box .bold-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

.result-text {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.4;
  color: var(--muted);
  font-size: 14px;
}

.patient-guidance {
  display: grid;
  gap: 9px;
}

.guidance-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.guidance-title {
  font-weight: 760;
  color: var(--ink);
  font-size: 13px;
}

.risk-pill {
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 760;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.risk-pill.green {
  background: rgba(0, 211, 182, 0.15);
  color: var(--teal);
}

.risk-pill.yellow {
  background: rgba(255, 183, 3, 0.15);
  color: var(--warn);
}

.risk-pill.red {
  background: rgba(255, 51, 102, 0.15);
  color: var(--accent);
}

.guidance-card {
  background: var(--paper-soft);
  padding: 18px;
  border-radius: 24px;
}

.guidance-card.warning {
  background: rgba(255, 51, 102, 0.1);
}

.guidance-card h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--teal);
}

.guidance-card.warning h4 {
  color: #ff3366;
}

.guidance-card p {
  margin: 0;
  line-height: 1.4;
  color: var(--ink);
  font-size: 15px;
}

.guidance-list,
.visit-list {
  margin: 0;
  padding-left: 20px;
  font-size: 15px;
  color: var(--ink);
}

.guidance-list li,
.visit-list li {
  margin-bottom: 8px;
  line-height: 1.4;
}

.guidance-empty {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
}

.specialist-stack {
  display: grid;
  gap: 6px;
}

.specialist-chip {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--paper-soft);
  padding: 7px 9px;
  line-height: 1.35;
}

.bullet-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.timeline {
  margin: 0;
  padding-left: 18px;
  max-height: 360px;
  overflow: auto;
}

.timeline li {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--paper-soft);
  font-size: 12px;
  line-height: 1.34;
}

#finalJson {
  margin-top: 0;
  font-size: 12px;
  background: var(--paper);
}

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

.results-grid[hidden] {
  display: none !important;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 14;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
}

.sheet-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  z-index: 15;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 90vw;
  max-width: 440px;
  height: auto;
  max-height: 85vh;
  overflow: auto;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 24px;
  background: rgba(18, 18, 20, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
  opacity: 0;
  pointer-events: none;
  transition: all 250ms cubic-bezier(0.16, 1, 0.3, 1);
}

.sheet.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.sheet[hidden] {
  display: none !important;
  opacity: 0;
}

.sheet .grid,
.sheet .field-grid,
.sheet .checks-inline {
  grid-template-columns: 1fr;
}

.sheet .chip-row {
  display: grid;
  gap: 8px;
  width: 100%;
  grid-template-columns: 1fr;
}

.sheet .chip-row button {
  width: 100%;
  padding: 14px 12px;
  font-size: 16px;
}

.sheet .panel-head {
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  margin-bottom: 16px;
}

.sheet h2 {
  font-size: 22px;
  text-align: center;
}

.sheet input,
.sheet select,
.sheet textarea {
  padding: 14px 12px;
  font-size: 16px;
  border-radius: 12px;
}

.sheet label {
  font-size: 15px;
  margin-bottom: 8px;
}

.sheet .checks label {
  background: var(--paper);
  border: 1px solid var(--border);
  padding: 14px 12px;
  border-radius: 12px;
  font-size: 16px;
  margin-bottom: 0;
}

.sheet input[type="checkbox"] {
  width: 24px;
  height: 24px;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
}

@media (max-width: 980px) {

  .grid,
  .grid-two,
  .endpoint-grid,
  .field-grid,
  .checks-inline {
    grid-template-columns: 1fr;
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  h1 {
    font-size: 27px;
  }

  .mode-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sheet {
    width: 100vw;
    top: 0;
    left: 0;
    transform: none;
    max-width: 100vw;
    max-height: 100vh;
  }
}