:root {
  --bg: #f3efe6;
  --paper: rgba(255, 252, 245, 0.92);
  --paper-strong: #fffaf1;
  --ink: #1b2b2a;
  --muted: #655f78;
  --line: rgba(27, 43, 42, 0.12);
  --accent: #31157a;
  --accent-deep: #240f5b;
  --warn: #7c2d12;
  --warn-bg: #fff0eb;
  --shadow: 0 18px 50px rgba(35, 48, 45, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Manrope", sans-serif;
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero {
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.8fr);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
}

.hero-copy,
.hero-card,
.panel {
  background: var(--paper);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 32px;
}

.hero-card {
  padding: 24px;
  align-self: stretch;
}

.eyebrow,
.card-label,
.toolbar-label {
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

h1,
h2,
h3 {
  font-family: "Manrope", sans-serif;
  margin: 0;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2.1rem, 4.6vw, 3.7rem);
  line-height: 1.08;
  font-weight: 800;
  max-width: 15ch;
}

h2 {
  font-size: clamp(1.45rem, 2.4vw, 2rem);
  line-height: 1.2;
  font-weight: 800;
}

h3 {
  font-size: clamp(1.02rem, 1.5vw, 1.24rem);
  line-height: 1.3;
  font-weight: 700;
}

.hero-text,
.panel-heading p,
.consent-box p,
.support-text,
.mode-copy,
.toolbar-value {
  color: var(--muted);
}

.hero-text {
  margin: 18px 0 0;
  max-width: 60ch;
  font-size: 1.05rem;
  line-height: 1.65;
}

.plain-list {
  margin: 0;
  padding-left: 18px;
  line-height: 1.7;
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(0, 1.3fr);
  gap: 24px;
}

.panel {
  padding: 24px;
}

.panel-heading p {
  margin: 8px 0 0;
  line-height: 1.6;
}

.consent-box {
  margin-top: 20px;
  padding: 18px;
  border-radius: 22px;
  background: var(--paper-strong);
  border: 1px solid var(--line);
}

.check-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 14px;
  line-height: 1.5;
}

.check-row input {
  margin-top: 4px;
}

.mode-grid {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.mode-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  border-radius: 20px;
  padding: 16px;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.mode-card:hover,
.mode-card:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(49, 21, 122, 0.4);
}

.mode-card.is-selected {
  background: rgba(49, 21, 122, 0.12);
  border-color: rgba(49, 21, 122, 0.42);
}

.mode-title {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}

.actions-row {
  margin-top: 20px;
}

.primary-button,
.ghost-button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.ghost-button {
  background: rgba(49, 21, 122, 0.08);
  color: var(--accent-deep);
}

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

.support-text {
  margin: 12px 0 0;
  font-size: 0.94rem;
}

.chat-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.voice-select-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.voice-select {
  max-width: 320px;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 7px 10px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
}

.alert-banner {
  margin-top: 18px;
  border-radius: 18px;
  padding: 14px 16px;
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid rgba(124, 45, 18, 0.16);
  line-height: 1.5;
}

.transcript-window {
  margin-top: 18px;
  min-height: 420px;
  max-height: 60vh;
  overflow: auto;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: rgba(255, 251, 244, 0.85);
  padding: 18px;
}

.thinking-row {
  margin-top: 10px;
  min-height: 42px;
}

.thinking-bubble {
  display: inline-block;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 18px;
  border-top-left-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 8px 22px rgba(27, 43, 42, 0.06);
}

.thinking-content {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
}

.thinking-dots {
  display: inline-flex;
  gap: 4px;
}

.thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.3;
  animation: thinking-bounce 1.1s infinite ease-in-out;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

.bubble {
  max-width: min(80%, 620px);
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: 22px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.bubble.doctor {
  background: #ffffff;
  border-top-left-radius: 8px;
}

.bubble.patient {
  background: rgba(49, 21, 122, 0.12);
  margin-left: auto;
  border-top-right-radius: 8px;
}

.bubble-meta {
  display: block;
  margin-bottom: 5px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-deep);
}

.feedback-card {
  margin-top: 18px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(49, 21, 122, 0.16);
  background: rgba(49, 21, 122, 0.08);
}

.composer {
  margin-top: 18px;
}

.composer-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

textarea {
  width: 100%;
  resize: vertical;
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 14px 16px;
  font: inherit;
  min-height: 112px;
  background: rgba(255, 255, 255, 0.8);
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.voice-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 250px;
}

#voiceToggleButton {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.voice-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(49, 21, 122, 0.5);
}

#voiceToggleButton.is-listening {
  background: rgba(49, 21, 122, 0.2);
  color: var(--accent-deep);
  animation: pulse-listen 1.2s ease-in-out infinite;
}

#voiceToggleButton.is-listening .voice-dot {
  background: var(--accent);
  animation: blink-listen 0.9s ease-in-out infinite;
}

.voice-meter {
  width: 110px;
  height: 10px;
  border-radius: 999px;
  background: rgba(49, 21, 122, 0.14);
  overflow: hidden;
}

.voice-meter-fill {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #4c1d95 0%, #7c3aed 60%, #a78bfa 100%);
  transition: width 80ms linear;
}

@keyframes pulse-listen {
  0% {
    box-shadow: 0 0 0 0 rgba(49, 21, 122, 0.28);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(49, 21, 122, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(49, 21, 122, 0);
  }
}

@keyframes blink-listen {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@keyframes thinking-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.3;
  }
  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

@media (max-width: 920px) {
  .hero,
  .app-grid {
    grid-template-columns: 1fr;
  }

  .chat-toolbar,
  .composer-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .voice-select-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .voice-select {
    width: 100%;
    max-width: 100%;
  }

  .voice-tools {
    min-width: 0;
  }

  .bubble {
    max-width: 92%;
  }
}
