:root {
  --primary: #2b6cb0;
  --primary-dark: #1e5a96;
  --primary-bg: #ebf4ff;
  --primary-50: #d0e4f7;
  --accent-blue: #4a9bd9;
  --accent-blue-bg: #eaf2fb;
  --accent-orange: #f0a050;
  --accent-orange-bg: #fef3e6;
  --danger: #e74c6f;
  --danger-bg: #fdeef2;
  --success: #38a169;
  --success-bg: #ecfdf5;
  --bg: #f0f5fb;
  --surface: #ffffff;
  --text: #1a365d;
  --text-secondary: #4a6fa5;
  --text-muted: #a0b4cc;
  --border: #dce6f0;
  --border-light: #edf2f7;
  --radius: 20px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.07);
  --tab-height: 72px;
  --header-height: 72px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: linear-gradient(135deg, #1e5a96 0%, #2b6cb0 40%, #4a9bd9 100%);
  display: flex;
  align-items: center;
  z-index: 100;
}

.header-inner {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.4);
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.header-greeting {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
  line-height: 1;
}

.header-name {
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
  margin-top: 3px;
  letter-spacing: -0.2px;
}

.header-right {
  display: flex;
  align-items: center;
}

.notification-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.notification-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #2b6cb0;
}

/* ===== Main content ===== */
.app-content {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--tab-height);
}

.tab-panel {
  display: none;
  min-height: 100%;
}

.tab-panel.active {
  display: block;
}

.panel-inner {
  padding: 20px 16px 100px;
  max-width: 600px;
  margin: 0 auto;
}

/* ===== Section titles ===== */
.section-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  margin-bottom: 20px;
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ===== Floating Tab bar ===== */
.tab-bar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  height: 56px;
  background: var(--surface);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  border-radius: 34px;
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.tab-btn span {
  display: none;
}

.tab-btn.active {
  color: #ffffff;
  background: linear-gradient(145deg, #3b82c4 0%, #1e5a96 100%);
  box-shadow: 0 4px 14px rgba(43, 108, 176, 0.3);
}

.tab-btn svg {
  width: 22px;
  height: 22px;
}

/* ===== Recording Panel ===== */
.recording-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding-top: 32px;
  padding-bottom: 100px;
}

.template-selector-row {
  width: 100%;
  margin-bottom: 40px;
}

.template-selector-row select {
  width: 100%;
  padding: 14px 40px 14px 16px;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23b2bec3' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  box-shadow: var(--shadow);
  transition: border-color 0.2s;
}

.template-selector-row select:focus {
  outline: none;
  border-color: var(--primary);
}

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

.card-label svg {
  color: var(--primary);
}

.recorder-center {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.recorder-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.recorder-visual {
  margin-bottom: 24px;
}

/* Outer ring — contains ripples */
.record-ring-outer {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.4s ease;
}

/* Ripple rings — hidden by default, visible when recording */
.ring-ripple {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid var(--primary);
  opacity: 0;
  pointer-events: none;
  width: 110px;
  height: 110px;
}

.record-ring-outer.recording .ring-ripple {
  border-color: var(--danger);
  animation: ripple 2.4s ease-out infinite;
}

.record-ring-outer.recording .ring-ripple-2 {
  animation-delay: 0.8s;
}

.record-ring-outer.recording .ring-ripple-3 {
  animation-delay: 1.6s;
}

@keyframes ripple {
  0% {
    width: 110px;
    height: 110px;
    opacity: 0.5;
  }
  100% {
    width: 180px;
    height: 180px;
    opacity: 0;
  }
}

/* Inner ring */
.record-ring-inner {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 4px 24px rgba(43, 108, 176, 0.12), 0 0 0 6px var(--primary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s ease;
  position: relative;
  z-index: 1;
}

.record-ring-inner.recording {
  box-shadow: 0 4px 24px rgba(231, 76, 111, 0.15), 0 0 0 6px var(--danger-bg);
}

/* Record button */
.btn-record {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, #3b82c4 0%, #1e5a96 100%);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 6px 24px rgba(43, 108, 176, 0.35), inset 0 1px 0 rgba(255,255,255,0.15);
  animation: breathe 3s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.btn-record:active {
  transform: scale(0.92) !important;
  animation: none;
}

.btn-record.recording {
  background: linear-gradient(145deg, #f43f6e 0%, #c81e50 100%);
  box-shadow: 0 6px 24px rgba(231, 76, 111, 0.4), inset 0 1px 0 rgba(255,255,255,0.15);
  animation: none;
}

/* Record icon — mic + wave bars */
.record-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  background: none;
  border-radius: 0;
}

.mic-icon {
  display: block;
  transition: opacity 0.3s, transform 0.3s;
}

.btn-record.recording .mic-icon {
  display: none;
}

/* Wave bars — only visible when recording */
.wave-bars {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 28px;
}

.btn-record.recording .wave-bars {
  display: flex;
}

.wave-bar {
  display: block;
  width: 4px;
  height: 8px;
  background: #ffffff;
  border-radius: 2px;
  animation: wave 1s ease-in-out infinite;
}

.wave-bar:nth-child(1) { animation-delay: 0s; height: 10px; }
.wave-bar:nth-child(2) { animation-delay: 0.15s; height: 16px; }
.wave-bar:nth-child(3) { animation-delay: 0.3s; height: 22px; }
.wave-bar:nth-child(4) { animation-delay: 0.15s; height: 16px; }
.wave-bar:nth-child(5) { animation-delay: 0s; height: 10px; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1); }
}

.record-timer {
  font-size: 38px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: 2px;
  margin-bottom: 6px;
}

.record-status {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ===== Results ===== */
.results-area {
  margin-top: 0;
}

.hidden {
  display: none !important;
}

.spinner-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  margin-bottom: 12px;
  background: var(--accent-blue-bg);
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(91, 155, 213, 0.2);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

.spinner-info { flex: 1; }

.spinner-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.spinner-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.result-section {
  margin-bottom: 16px;
}

.result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 0 4px;
}

.result-header svg { color: var(--primary); }

.result-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.transcript-content {
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
  color: var(--text-secondary);
}

.transcript-content .speaker {
  font-weight: 700;
  color: var(--primary-dark);
  font-size: 13px;
}

.transcript-content .speaker-patient {
  color: var(--accent-blue);
}

.extraction-content {
  padding: 4px 0;
  overflow: hidden;
}

.extraction-row {
  display: flex;
  flex-direction: column;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  gap: 4px;
}

.extraction-row:last-child { border-bottom: none; }

.extraction-label {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.extraction-value {
  font-size: 15px;
  color: var(--text);
  line-height: 1.5;
}

/* ===== History ===== */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.history-item:active { transform: scale(0.98); }

.history-item-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--primary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.history-item-icon svg { color: var(--primary); }

.history-item-info {
  flex: 1;
  min-width: 0;
}

.history-item-date {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.history-item-template {
  font-size: 16px;
  font-weight: 600;
  margin-top: 2px;
  color: var(--text);
}

.history-item-status {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--success-bg);
  color: var(--success);
}

.history-item-status.error {
  background: var(--danger-bg);
  color: var(--danger);
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: 16px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 56px 0;
  gap: 10px;
}

.empty-state svg { color: var(--text-muted); margin-bottom: 4px; }

.empty-state p {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 500;
}

.empty-hint {
  font-size: 13px !important;
  font-weight: 400 !important;
}

/* ===== History Detail ===== */
.detail-header-card {
  padding: 20px;
  margin-bottom: 16px;
}

.detail-header-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.detail-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.detail-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.detail-date {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.detail-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--border-light);
  color: var(--text-muted);
}

.detail-status.success {
  background: var(--success-bg);
  color: var(--success);
}

.detail-status.error {
  background: var(--danger-bg);
  color: var(--danger);
}

.detail-section {
  margin-bottom: 16px;
}

.detail-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  margin-bottom: 10px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
}

.detail-section-header span {
  color: var(--text);
}

/* Chat bubbles for transcript */
.detail-transcript {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  max-width: 88%;
}

.chat-bubble.doctor {
  background: var(--primary-bg);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-bubble.patient {
  background: var(--border-light);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-bubble.neutral {
  background: var(--border-light);
  align-self: center;
  max-width: 95%;
}

.chat-speaker {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.chat-bubble.doctor .chat-speaker {
  color: var(--primary);
}

.chat-bubble.patient .chat-speaker {
  color: var(--accent-blue);
}

.chat-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

/* Extraction fields in detail */
.detail-extraction {
  padding: 8px 0;
}

.detail-field {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
}

.detail-field:last-child {
  border-bottom: none;
}

.detail-field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-field-value {
  font-size: 15px;
  color: var(--text);
  line-height: 1.5;
}

/* Delete button */
.detail-delete-wrap {
  padding-top: 8px;
  text-align: center;
}

.btn-delete-recording {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.btn-delete-recording:active {
  background: var(--danger-bg);
}

/* ===== Templates ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.templates-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.template-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}

.template-item-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.template-item-fields {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

.template-item-actions {
  display: flex;
  gap: 6px;
}

.template-form { margin-top: 20px; }

.template-form h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

/* ===== Forms ===== */
.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 14px 16px;
  font-size: 15px;
  font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.1);
}

.form-group textarea {
  resize: vertical;
  line-height: 1.5;
}

.input-with-icon { position: relative; }

.input-with-icon svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.input-with-icon input { padding-left: 42px; }

.tpl-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

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

.tpl-field-row input {
  flex: 1;
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s;
}

.tpl-field-row input:focus {
  outline: none;
  border-color: var(--primary);
}

.tpl-field-row select {
  width: 100px;
  padding: 12px 8px;
  font-size: 14px;
  font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg);
  color: var(--text);
}

.btn-remove-field {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 18px;
  cursor: pointer;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ===== Buttons ===== */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 15px 24px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 100%;
  transition: opacity 0.2s, transform 0.15s;
  box-shadow: 0 4px 14px rgba(43, 108, 176, 0.25);
}

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

.btn-secondary {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  padding: 15px 24px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 100%;
}

.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-bg);
  color: var(--primary);
  border: none;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 24px;
  cursor: pointer;
}

.btn-small {
  background: var(--primary-bg);
  color: var(--primary);
  border: none;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-xs);
  cursor: pointer;
}

.btn-small.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-small.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: none;
}

.btn-text-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 6px 0;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.form-actions .btn-primary,
.form-actions .btn-secondary { flex: 1; }

/* ===== Settings ===== */
.settings-card { padding: 24px 20px; }

.settings-section { margin-bottom: 20px; }

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

.settings-section-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.settings-status {
  margin-top: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--success);
  text-align: center;
}

/* ===== Processing Overlay ===== */
.processing-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 200;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: slideUp 0.3s ease;
}

.processing-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 52px 16px 40px;
}

.processing-header {
  margin-bottom: 16px;
}

.processing-steps {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.proc-step {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  margin-bottom: -1px;
  opacity: 0.5;
  transition: all 0.3s;
}

.proc-step:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}

.proc-step:last-child {
  border-radius: 0 0 var(--radius) var(--radius);
}

.proc-step.active {
  opacity: 1;
  background: var(--primary-bg);
  border-color: var(--primary-50);
}

.proc-step.done {
  opacity: 1;
}

.proc-step.error {
  opacity: 1;
}

.proc-step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.3s;
}

.proc-step.active .proc-step-circle {
  background: var(--primary);
  color: #fff;
}

.proc-step.done .proc-step-circle {
  background: var(--success);
}

.proc-step.error .proc-step-circle {
  background: var(--danger);
}

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

.proc-step-info {
  flex: 1;
}

.proc-step-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.proc-step-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.proc-step.active .proc-step-sub {
  color: var(--primary);
}

.proc-step.done .proc-step-sub {
  color: var(--success);
}

.proc-step.error .proc-step-sub {
  color: var(--danger);
}

.processing-content {
  animation: fadeIn 0.3s ease;
}

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

/* ===== Analyze button ===== */
.extraction-action {
  padding: 16px 20px 12px;
}

.btn-analyze {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
  background: linear-gradient(135deg, #1e5a96 0%, #4a9bd9 100%);
  color: #ffffff;
  border: none;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(43, 108, 176, 0.25);
  transition: opacity 0.2s, transform 0.15s;
}

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

.btn-analyze svg {
  flex-shrink: 0;
}

/* ===== Diagnosis Overlay ===== */
.diagnosis-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 200;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: slideUp 0.3s ease;
}

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

.diagnosis-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 52px 16px 40px;
}

.diagnosis-header {
  margin-bottom: 20px;
}

.diagnosis-header .btn-back {
  margin-bottom: 12px;
}

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

.diagnosis-symptoms-card {
  margin-bottom: 20px;
  background: var(--primary-bg);
}

.diagnosis-symptoms-card .card-label {
  color: var(--primary);
}

.diagnosis-symptoms-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.diagnosis-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 0;
}

.diagnosis-loading p {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

.diagnosis-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Diagnosis card */
.diagnosis-card {
  padding: 20px;
}

.diagnosis-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.diagnosis-card-info {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
}

.diagnosis-rank {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.diagnosis-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.diagnosis-prob {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 2px;
}

.diagnosis-pct {
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
  padding-left: 12px;
}

.diagnosis-pct.high { color: var(--danger); }
.diagnosis-pct.medium { color: var(--accent-orange); }
.diagnosis-pct.low { color: var(--success); }

/* Progress bar */
.diagnosis-bar-track {
  width: 100%;
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}

.diagnosis-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

.diagnosis-bar-fill.high { background: var(--danger); }
.diagnosis-bar-fill.medium { background: var(--accent-orange); }
.diagnosis-bar-fill.low { background: var(--success); }

.diagnosis-desc {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.diagnosis-tests {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius-xs);
}

.diagnosis-tests-label {
  font-weight: 600;
  color: var(--text-secondary);
}

.diagnosis-disclaimer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding: 20px 16px 0;
  line-height: 1.5;
}

/* ===== Error message ===== */
.error-message {
  background: var(--danger-bg);
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  margin-top: 16px;
}
