:root {
  --bg-primary: #0a0c0f;
  --bg-secondary: #111318;
  --bg-card: #161b22;
  --bg-input: #1c2128;
  --border: #2a3040;
  --border-focus: #3b82f6;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #5a6475;
  --accent-blue: #3b82f6;
  --accent-blue-dark: #1d4ed8;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --accent-red-dark: #991b1b;
  --accent-amber: #f59e0b;
  --accent-teal: #14b8a6;
  --radius: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  overscroll-behavior: none;
}

/* Header */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-teal));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.header-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-top: 1px;
}

.protocol-badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.protocol-badge:hover {
  border-color: var(--accent-blue);
}

.protocol-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
}

.protocol-dot.offline {
  background: var(--accent-amber);
}

/* Main Layout */
.main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 100px;
}

/* Consult Input Area */
.consult-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.consult-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-blue);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.consult-label::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 12px;
  background: var(--accent-blue);
  border-radius: 2px;
}

.consult-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.5;
  padding: 12px 14px;
  resize: vertical;
  min-height: 100px;
  font-family: inherit;
  transition: border-color 0.2s;
  outline: none;
}

.consult-input:focus {
  border-color: var(--border-focus);
}

.consult-input::placeholder {
  color: var(--text-muted);
}

.consult-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn-consult {
  flex: 1;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-blue-dark));
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  padding: 14px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.2s, transform 0.1s;
  letter-spacing: 0.2px;
  touch-action: manipulation;
}

.btn-consult:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.btn-consult:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-voice {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  padding: 14px 16px;
  cursor: pointer;
  font-size: 20px;
  transition: border-color 0.2s, color 0.2s;
  touch-action: manipulation;
}

.btn-voice:hover, .btn-voice.recording {
  border-color: var(--accent-red);
  color: var(--accent-red);
}

.btn-clear {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  padding: 14px 16px;
  cursor: pointer;
  font-size: 16px;
  transition: border-color 0.2s;
  touch-action: manipulation;
}

/* Quick Scenarios */
.quick-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.quick-scenarios {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 6px 12px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  touch-action: manipulation;
  white-space: nowrap;
}

.chip:hover, .chip:active {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.08);
}

/* Loading State */
.loading-state {
  display: none;
  text-align: center;
  padding: 40px 20px;
}

.loading-state.visible {
  display: block;
}

.loading-pulse {
  display: inline-flex;
  gap: 6px;
  margin-bottom: 16px;
}

.loading-pulse span {
  width: 8px;
  height: 8px;
  background: var(--accent-blue);
  border-radius: 50%;
  animation: pulse 1.2s ease-in-out infinite;
}

.loading-pulse span:nth-child(2) { animation-delay: 0.2s; }
.loading-pulse span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.loading-text {
  color: var(--text-secondary);
  font-size: 14px;
}

.loading-subtext {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
}

/* Response Area */
.response-area {
  display: none;
}

.response-area.visible {
  display: block;
}

/* Patch Point Alert */
.patch-alert {
  background: rgba(239, 68, 68, 0.1);
  border: 2px solid var(--accent-red);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.patch-alert-icon {
  font-size: 22px;
  flex-shrink: 0;
  line-height: 1;
}

.patch-alert-content {}

.patch-alert-title {
  color: var(--accent-red);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 4px;
}

.patch-alert-text {
  color: #fca5a5;
  font-size: 14px;
  line-height: 1.5;
}

/* Clinical Sections */
/* Clinical Overview */
.overview-card {
  background: rgba(139, 92, 246, 0.05);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 10px;
  margin-bottom: 10px;
  overflow: hidden;
}

.overview-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(139, 92, 246, 0.15);
}

.overview-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.overview-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #a78bfa;
}

.overview-body {
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  overflow: hidden;
}

.section-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.section-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.section-icon.green { background: rgba(34, 197, 94, 0.15); }
.section-icon.red { background: rgba(239, 68, 68, 0.15); }
.section-icon.blue { background: rgba(59, 130, 246, 0.15); }
.section-icon.amber { background: rgba(245, 158, 11, 0.15); }

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.section-body {
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
}

/* Citations */
.citations-card {
  background: rgba(59, 130, 246, 0.04);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 10px;
}

.citations-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-blue);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.citation-item {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 3px 0;
  border-bottom: 1px solid rgba(59, 130, 246, 0.08);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.citation-item:last-child { border-bottom: none; }

.citation-item::before {
  content: '▸';
  color: var(--accent-blue);
  opacity: 0.6;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Cognitive Check */
.cognitive-card {
  background: rgba(20, 184, 166, 0.04);
  border: 1px solid rgba(20, 184, 166, 0.25);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
}

.cognitive-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-teal);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cognitive-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-style: italic;
}

.cognitive-dx {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: flex-start;
}

.cognitive-dx-badge {
  background: rgba(20, 184, 166, 0.15);
  color: var(--accent-teal);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

.cognitive-dx-text {
  font-size: 14px;
  color: var(--text-primary);
}

.cognitive-reasoning {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(20, 184, 166, 0.15);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  font-style: italic;
}

/* No Protocols Warning */
.no-protocols-banner {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.no-protocols-banner p {
  font-size: 13px;
  color: var(--accent-amber);
  line-height: 1.5;
}

.no-protocols-banner p span {
  font-weight: 700;
  display: block;
  margin-bottom: 3px;
}

/* Error State */
.error-card {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 14px;
}

.error-title {
  color: var(--accent-red);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}

.error-text {
  color: #fca5a5;
  font-size: 13px;
}

/* Timestamp */
.response-meta {
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-style: italic;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Upload Protocol Area */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
  margin-top: 8px;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.04);
}

.upload-zone p {
  color: var(--text-muted);
  font-size: 14px;
}

.upload-zone strong {
  color: var(--accent-blue);
}

/* Modal / Sheet */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.visible {
  display: flex;
}

.modal-sheet {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px 16px 40px;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.protocol-list {
  margin-bottom: 16px;
}

.protocol-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-secondary);
}

.protocol-item:last-child { border-bottom: none; }

.protocol-item-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.btn-close-modal {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  padding: 12px;
  cursor: pointer;
  font-size: 14px;
  margin-top: 12px;
}

/* Follow-up input */
.followup-wrap {
  margin-top: 14px;
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 10px;
  background: rgba(59, 130, 246, 0.04);
  padding: 12px 14px;
}

.followup-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--accent-blue);
  margin-bottom: 10px;
}

.followup-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.followup-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
}

.followup-input::placeholder { color: var(--text-muted); }
.followup-input:focus { border-color: var(--border-focus); }
.followup-input:disabled { opacity: 0.5; }

.followup-btn {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 18px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.followup-btn:hover { background: var(--accent-blue-dark); }
.followup-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Disclaimer Footer */
.disclaimer-footer {
  width: 100%;
  padding: 12px 20px;
  background: #0d0f12;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--text-muted);
  text-align: center;
}

/* Responsive */
@media (min-width: 480px) {
  .main { padding: 20px; }
  .consult-input { font-size: 15px; }
  .disclaimer-footer { padding: 14px 32px; font-size: 11px; }
}
