:root {
  --base-900: #0a2647;
  --base-700: #2c3e50;
  --accent-500: #2aa9b4;
  --accent-600: #6c5b7b;
  --bg: #f8fafc;
  --surface: rgba(255, 255, 255, 0.92);
  --text: #12263a;
  --muted: #5f6b7a;
  --border: rgba(44, 62, 80, 0.16);
  --ok: #18a058;
  --error: #d64545;
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow-lg: 0 22px 55px rgba(12, 25, 39, 0.12);
  --shadow-sm: 0 6px 16px rgba(12, 25, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Manrope, Inter, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 10% 5%, rgba(42, 169, 180, 0.12), transparent 40%),
    radial-gradient(circle at 88% 12%, rgba(108, 91, 123, 0.12), transparent 35%), var(--bg);
}

.ambient-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(140deg, rgba(10, 38, 71, 0.04), rgba(255, 255, 255, 0));
}

.page {
  position: relative;
  max-width: 1040px;
  margin: 0 auto;
  padding: 26px 18px 72px;
}

.topbar {
  margin-bottom: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--base-700);
  box-shadow: none;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: conic-gradient(from 80deg, #2aa9b4, #6c5b7b, #2aa9b4);
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: rgba(10, 38, 71, 0.9);
}

.brand-name {
  margin: 0;
  font-weight: 700;
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 0.84rem;
  opacity: 0.86;
}

.topbar .brand-subtitle {
  display: none;
}

.hero,
.dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 30px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3.8vw, 2.45rem);
  line-height: 1.12;
}

.subhead {
  margin: 12px 0 26px;
  color: var(--muted);
  line-height: 1.6;
  max-width: 760px;
}

.hero {
  padding-bottom: 40px;
}

.disclaimer {
  margin: 18px 0 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.role-segment {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  background: transparent;
  padding: 0;
  border-radius: 0;
}

.role-option {
  border: 1px solid rgba(74, 144, 226, 0.35);
  border-radius: 999px;
  background: linear-gradient(180deg, #eff8ff, #e0f0ff);
  cursor: pointer;
  padding: 14px 22px;
  min-height: 62px;
  flex: 1 1 320px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  color: #124265;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.role-option strong {
  display: block;
  margin-bottom: 4px;
}

.role-option small {
  color: #35658a;
}

.role-option:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: rgba(74, 144, 226, 0.55);
}

.role-option.active {
  border-color: rgba(36, 123, 198, 0.8);
  background: linear-gradient(180deg, #d6ecff, #c6e2ff);
  box-shadow: 0 10px 20px rgba(36, 123, 198, 0.2);
}

.doctor-gate {
  margin-top: 14px;
  border: 1px solid rgba(10, 38, 71, 0.16);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.82);
  padding: 14px;
}

.doctor-gate-title {
  margin: 0 0 10px;
  font-weight: 700;
}

.doctor-gate-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.doctor-gate-row input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.doctor-gate-confirm,
.doctor-gate-cancel {
  border: none;
  border-radius: 999px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

.doctor-gate-confirm {
  color: #fff;
  background: linear-gradient(120deg, var(--base-900), var(--accent-600));
}

.doctor-gate-cancel {
  color: var(--text);
  background: rgba(10, 38, 71, 0.08);
}

.doctor-gate-error {
  margin: 8px 0 0;
  color: var(--error);
  font-size: 0.9rem;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.ghost {
  border: none;
  border-radius: 999px;
  background: rgba(10, 38, 71, 0.08);
  padding: 8px 14px;
  cursor: pointer;
  color: var(--text);
  transition: background 160ms ease;
}

.ghost:hover {
  background: rgba(10, 38, 71, 0.14);
}

.role-badge {
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(42, 169, 180, 0.16);
  color: var(--base-900);
  font-size: 0.84rem;
  font-weight: 700;
}

.wizard-head {
  margin: 10px 0 16px;
}

.wizard-head h2 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
}

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

.step-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
  padding: 16px;
}

.step-title {
  margin: 0 0 12px;
  font-weight: 700;
}

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

.request-tile {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.request-tile strong {
  display: block;
  margin-bottom: 5px;
}

.request-tile small {
  color: var(--muted);
}

.request-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(42, 169, 180, 0.55);
}

.request-tile.active {
  border-color: rgba(24, 160, 88, 0.7);
  background: linear-gradient(160deg, rgba(24, 160, 88, 0.18), rgba(56, 189, 120, 0.12));
  box-shadow: var(--shadow-sm);
}

.upload-block {
  display: grid;
  gap: 9px;
  margin-bottom: 12px;
}

.upload-meta p {
  margin: 0;
}

.upload-heading {
  font-weight: 700;
}

.upload-subtext {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.upload-dropzone {
  border: 1px dashed rgba(44, 62, 80, 0.45);
  border-radius: var(--radius-md);
  padding: 18px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.85), rgba(255, 255, 255, 0.95));
  display: grid;
  gap: 6px;
  cursor: pointer;
  position: relative;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.upload-dropzone:hover,
.upload-dropzone.drag-over {
  border-color: var(--accent-500);
  box-shadow: 0 0 0 4px rgba(42, 169, 180, 0.12);
  background: linear-gradient(180deg, rgba(240, 252, 252, 0.95), rgba(255, 255, 255, 1));
}

.upload-dropzone input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

.upload-dropzone input::file-selector-button {
  display: none;
}

.upload-dropzone input::-webkit-file-upload-button {
  display: none;
}

.dropzone-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(10, 38, 71, 0.08);
}

.dropzone-title {
  font-weight: 700;
}

.upload-dropzone small {
  color: var(--muted);
}

.required-block .upload-dropzone {
  border-color: rgba(214, 145, 18, 0.58);
}

.required-block.highlight {
  animation: attentionGlow 1.3s ease-in-out infinite;
}

.upload-dropzone.has-file {
  border-color: rgba(24, 160, 88, 0.6);
  box-shadow: inset 0 0 0 1px rgba(24, 160, 88, 0.22);
}

.upload-dropzone.has-file .dropzone-title::after {
  content: "  ✓";
  color: var(--ok);
}

.upload-dropzone.error-state {
  border-color: rgba(214, 69, 69, 0.8);
  box-shadow: 0 0 0 4px rgba(214, 69, 69, 0.14);
}

.file-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  border: 1px solid rgba(24, 160, 88, 0.28);
  background: rgba(24, 160, 88, 0.08);
  padding: 8px 10px;
}

.file-chip button {
  border: none;
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  background: rgba(18, 38, 58, 0.1);
}

.primary.launch-btn {
  border: none;
  border-radius: 16px;
  min-height: 52px;
  width: 100%;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(120deg, var(--base-900), var(--accent-600));
  box-shadow: 0 14px 26px rgba(12, 25, 39, 0.25);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.primary.launch-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 30px rgba(12, 25, 39, 0.28);
}

.primary.launch-btn:disabled {
  opacity: 0.85;
  cursor: wait;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  animation: spin 1s linear infinite;
}

.chat-shell {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.95);
  padding: 16px;
  display: grid;
  gap: 11px;
}

.result-toolbar {
  display: flex;
  justify-content: flex-start;
}

.result-toolbar .ghost {
  border: 1px solid var(--border);
  background: #fff;
}

.primary.export-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  background: linear-gradient(120deg, var(--base-900), var(--accent-600));
  box-shadow: 0 8px 20px rgba(12, 25, 39, 0.2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.primary.export-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(12, 25, 39, 0.25);
}

.follow-up {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  background: linear-gradient(160deg, rgba(42, 169, 180, 0.07), rgba(108, 91, 123, 0.05));
  border-top: 3px solid var(--accent-500);
  display: grid;
  gap: 10px;
}

.follow-up-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  background: linear-gradient(120deg, var(--base-900), var(--accent-500));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.01em;
}

.follow-up-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.follow-up-thread {
  max-height: 280px;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 4px;
}

.follow-up-bubble {
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.follow-up-bubble.user {
  background: rgba(42, 169, 180, 0.1);
}

.follow-up-bubble.assistant {
  background: rgba(10, 38, 71, 0.06);
}

.follow-up-form {
  display: grid;
  gap: 8px;
}

.follow-up-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 90px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.follow-up-form .primary {
  border: none;
  border-radius: 12px;
  min-height: 42px;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(120deg, var(--base-900), var(--accent-600));
  cursor: pointer;
}

.bubble {
  border-radius: 14px;
  padding: 14px;
  line-height: 1.5;
  border: 1px solid transparent;
}

.bubble.markdown {
  background: #ffffff;
  border-color: rgba(44, 62, 80, 0.12);
  box-shadow: var(--shadow-sm);
  overflow-wrap: anywhere;
}

.bubble.markdown h1,
.bubble.markdown h2,
.bubble.markdown h3,
.bubble.markdown h4,
.bubble.markdown h5,
.bubble.markdown h6 {
  margin: 0.8em 0 0.35em;
  line-height: 1.2;
}

.bubble.markdown h1 { font-size: 1.3rem; }
.bubble.markdown h2 { font-size: 1.2rem; }
.bubble.markdown h3 { font-size: 1.1rem; }
.bubble.markdown h4 { font-size: 1.02rem; }
.bubble.markdown h5,
.bubble.markdown h6 { font-size: 0.96rem; }

.bubble.markdown p {
  margin: 0.5em 0;
}

.bubble.markdown ul,
.bubble.markdown ol {
  margin: 0.6em 0;
  padding-left: 1.25em;
}

.bubble.markdown li {
  margin: 0.25em 0;
}

.bubble.markdown code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.92em;
  background: rgba(10, 38, 71, 0.06);
  border: 1px solid rgba(10, 38, 71, 0.12);
  padding: 0.12em 0.35em;
  border-radius: 8px;
}

.bubble.markdown pre {
  margin: 0.7em 0;
  padding: 12px;
  background: rgba(10, 38, 71, 0.04);
  border: 1px solid rgba(10, 38, 71, 0.12);
  border-radius: 12px;
  overflow: auto;
}

.bubble.markdown pre code {
  background: transparent;
  border: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.9em;
}

.bubble.markdown a {
  color: var(--base-900);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.assistant {
  background: rgba(10, 38, 71, 0.08);
  position: relative;
}

.assistant.typing::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: 10px;
  width: 22px;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(42, 169, 180, 0.2), rgba(42, 169, 180, 0.8), rgba(42, 169, 180, 0.2));
  background-size: 220% 100%;
  animation: typingPulse 1.1s ease-in-out infinite;
}

.assistant.reveal {
  animation: bubbleReveal 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.error {
  background: rgba(214, 69, 69, 0.14);
  color: var(--error);
}

.result-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: #fff;
}

.result-card h3 {
  margin: 0 0 10px;
}

.result-card p {
  margin: 0 0 8px;
}

.result-card ul {
  margin: 6px 0 12px;
  padding-left: 18px;
}

.result-card a {
  color: var(--base-900);
}

.hidden {
  display: none;
}

@keyframes typingPulse {
  0% {
    background-position: 100% 50%;
    opacity: 0.3;
  }
  50% {
    background-position: 0% 50%;
    opacity: 1;
  }
  100% {
    background-position: -100% 50%;
    opacity: 0.3;
  }
}

@keyframes bubbleReveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes attentionGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(214, 145, 18, 0.2);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(214, 145, 18, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(214, 145, 18, 0);
  }
}

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

@media (max-width: 860px) {
  .hero,
  .dialog {
    padding: 20px;
  }

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

  .dialog-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .doctor-gate-row {
    grid-template-columns: 1fr;
  }

  .result-toolbar {
    justify-content: stretch;
  }

  .result-toolbar .ghost {
    width: 100%;
  }
}
