:root {
  color-scheme: dark;
  --bg: #020604;
  --panel: #07100d;
  --panel-2: #0b1712;
  --ink: #c9ffdc;
  --muted: #86a994;
  --green: #54ff9f;
  --cyan: #6be7ff;
  --yellow: #f4e76e;
  --red: #ff7b82;
  --line: rgba(84, 255, 159, 0.25);
  --glow: 0 0 18px rgba(84, 255, 159, 0.2);
  font-family: "Courier New", ui-monospace, SFMono-Regular, Consolas, monospace;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(40, 120, 78, 0.18), transparent 32rem),
    linear-gradient(180deg, #030806, #010302 72%);
}

button, input, select { font: inherit; }
button, select, input { color: var(--ink); }
button { cursor: pointer; }

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 100;
  padding: 0.8rem 1rem;
  color: #00150a;
  background: var(--green);
}
.skip-link:focus { top: 1rem; }

.shell {
  width: min(calc(100% - 2rem), 1180px);
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.2rem;
}

.kicker, .subtitle { margin: 0; color: var(--muted); }
.kicker { font-size: 0.78rem; letter-spacing: 0.18em; }

h1 {
  margin: 0.18rem 0 0.25rem;
  font-size: clamp(2rem, 7vw, 5.4rem);
  line-height: 0.9;
  letter-spacing: -0.08em;
  color: var(--green);
  text-shadow: 0 0 22px rgba(84, 255, 159, 0.32);
}
h1 span { color: var(--yellow); }

.status-panel {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 0 0 auto;
  padding: 0.72rem 0.9rem;
  border: 1px solid var(--line);
  background: rgba(7, 16, 13, 0.9);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}
.status-light {
  width: 0.68rem;
  height: 0.68rem;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 14px var(--green);
}

.display {
  position: relative;
  display: grid;
  grid-template-columns: minmax(280px, 0.7fr) minmax(0, 1.3fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(3, 10, 7, 0.92);
  box-shadow: var(--glow), 0 24px 80px rgba(0, 0, 0, 0.44);
}

.scanlines {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0.16;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(190, 255, 215, 0.08) 3px 4px);
}

.doctor-core {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 610px;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background:
    radial-gradient(circle, rgba(84, 255, 159, 0.15), transparent 54%),
    linear-gradient(135deg, rgba(4, 20, 12, 0.96), rgba(1, 5, 3, 0.96));
}

.halo {
  position: absolute;
  width: 75%;
  aspect-ratio: 1;
  border: 1px solid rgba(107, 231, 255, 0.28);
  border-radius: 50%;
  animation: rotate 18s linear infinite;
}
.halo::before, .halo::after {
  content: "";
  position: absolute;
  inset: 10%;
  border: 1px dashed rgba(84, 255, 159, 0.2);
  border-radius: inherit;
}
.halo::after { inset: 23%; border-style: solid; }
.halo-two { width: 96%; animation-direction: reverse; animation-duration: 26s; }

.faceplate {
  position: relative;
  z-index: 2;
  width: min(66%, 260px);
  aspect-ratio: 0.92;
  border: 2px solid rgba(84, 255, 159, 0.75);
  border-radius: 46% 46% 40% 40%;
  background: linear-gradient(180deg, rgba(10, 38, 24, 0.94), rgba(2, 12, 7, 0.98));
  box-shadow: inset 0 0 44px rgba(84, 255, 159, 0.12), 0 0 34px rgba(84, 255, 159, 0.18);
}

.eye {
  position: absolute;
  top: 37%;
  width: 18%;
  height: 5%;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 16px var(--green);
  animation: blink 7s infinite;
}
.eye-left { left: 22%; }
.eye-right { right: 22%; }

.mouth {
  position: absolute;
  left: 50%;
  bottom: 23%;
  width: 38%;
  height: 5%;
  transform: translateX(-50%);
  border: 2px solid var(--yellow);
  border-radius: 0 0 999px 999px;
  box-shadow: 0 0 12px rgba(244, 231, 110, 0.45);
}

.waveform {
  position: absolute;
  z-index: 3;
  bottom: 9%;
  display: flex;
  align-items: center;
  gap: 0.34rem;
  height: 44px;
}
.waveform i {
  display: block;
  width: 3px;
  height: 10px;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}
.speaking .waveform i { animation: voice 0.55s ease-in-out infinite alternate; }
.speaking .waveform i:nth-child(2n) { animation-delay: -0.2s; }
.speaking .waveform i:nth-child(3n) { animation-delay: -0.4s; }
.speaking .mouth { animation: talk 0.18s steps(2) infinite; }

.terminal-wrap {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 610px;
  padding: 1rem;
}

.terminal-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.7rem 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}
.terminal-bar strong { color: var(--cyan); }

.transcript {
  flex: 1 1 auto;
  min-height: 340px;
  max-height: 450px;
  overflow: auto;
  padding: 1rem 0.4rem 1.4rem;
  scrollbar-color: var(--green) transparent;
}

.message {
  display: grid;
  grid-template-columns: 6rem minmax(0, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.message p { margin: 0; line-height: 1.48; overflow-wrap: anywhere; }
.speaker { color: var(--green); font-weight: 700; }
.message.user .speaker { color: var(--yellow); }
.message.system { color: var(--muted); font-size: 0.88rem; }
.message.system .speaker { color: var(--cyan); }

.input-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem;
  border: 1px solid rgba(84, 255, 159, 0.42);
  background: rgba(2, 8, 5, 0.96);
}
.prompt-mark { color: var(--yellow); font-weight: 700; }

input[type="text"], select {
  width: 100%;
  border: 1px solid var(--line);
  outline: none;
  background: #020604;
}
input[type="text"] { min-width: 0; padding: 0.68rem; border: 0; }
input[type="text"]:focus, select:focus, button:focus-visible, input[type="range"]:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}

button {
  border: 1px solid rgba(84, 255, 159, 0.42);
  padding: 0.66rem 0.82rem;
  background: #0a1811;
}
button:hover { border-color: var(--green); background: #10271a; }
button[aria-pressed="true"] { border-color: var(--yellow); color: var(--yellow); }
button:disabled { cursor: not-allowed; opacity: 0.45; }

.input-help, .privacy-note {
  margin: 0.72rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}
.privacy-note { padding-left: 0.7rem; border-left: 2px solid var(--yellow); }
.privacy-note strong { color: var(--yellow); }
code { color: var(--cyan); }

.controls {
  display: grid;
  grid-template-columns: minmax(170px, 1.4fr) repeat(2, minmax(130px, 1fr)) repeat(3, auto);
  gap: 0.7rem;
  margin-top: 0.9rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  background: rgba(7, 16, 13, 0.9);
}
.controls label { display: grid; gap: 0.35rem; color: var(--muted); font-size: 0.72rem; }
.controls select { padding: 0.5rem; }
.controls input[type="range"] { width: 100%; accent-color: var(--green); }

.mode-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.9rem;
}
.mode-card { min-height: 96px; text-align: left; }
.mode-card strong, .mode-card span { display: block; }
.mode-card strong { color: var(--green); }
.mode-card span { margin-top: 0.45rem; color: var(--muted); font-size: 0.78rem; }
.mode-card.active strong { color: var(--yellow); }

footer {
  padding: 1.4rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
  text-align: center;
}
footer p { margin: 0.25rem; }
a { color: var(--cyan); }

.grass-mode {
  --green: #9dff73;
  --cyan: #8ee6ff;
  background: radial-gradient(circle at 50% 100%, rgba(76, 150, 45, 0.24), transparent 45%), var(--bg);
}

@keyframes rotate { to { transform: rotate(1turn); } }
@keyframes blink { 0%, 46%, 50%, 100% { transform: scaleY(1); } 48% { transform: scaleY(0.08); } }
@keyframes voice { to { height: 42px; } }
@keyframes talk { to { height: 16%; width: 28%; border-radius: 999px; } }

@media (max-width: 900px) {
  .display { grid-template-columns: 1fr; }
  .doctor-core {
    min-height: 270px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .faceplate { width: min(32%, 170px); }
  .terminal-wrap { min-height: 520px; }
  .controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mode-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .shell {
    width: min(calc(100% - 1rem), 1180px);
    padding-top: 1rem;
  }
  .masthead { display: block; }
  .status-panel { width: fit-content; margin-top: 1rem; }
  .display { border-radius: 8px; }
  .terminal-wrap { padding: 0.55rem; }
  .terminal-bar { display: grid; }
  .message { grid-template-columns: 1fr; gap: 0.2rem; }
  .input-row { grid-template-columns: 1fr auto; }
  .prompt-mark { grid-column: 1 / -1; }
  .input-row input { grid-column: 1 / -1; border: 1px solid var(--line); }
  .controls, .mode-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}