/* ==========================================================================
   VitalCheck Modern Clinical Design System & Multi-Palette Theme Engine
   Supported Palettes:
   - sapphire (Ocean Blue - default)
   - crimson  (Cardiology Heart Rose)
   - emerald  (Clinical Health Viridian)
   - midnight (Obsidian Electric Indigo)
   - mocha    (Warm Boutique Sand & Coffee)
   ========================================================================== */

:root {
    /* Base Palette: Sapphire Clinical (Default) */
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: rgba(2, 132, 199, 0.12);
    --primary-glow: rgba(2, 132, 199, 0.35);
    --accent: #0d9488;
    --accent-light: rgba(13, 148, 136, 0.12);
    --hero-gradient: linear-gradient(135deg, #0f172a 0%, #0284c7 100%);
    
    /* Clinical Severity Tokens */
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-light: #fee2e2;
    --warning: #ea580c;
    --warning-light: #ffedd5;
    --caution: #d97706;
    --caution-light: #fef3c7;
    --success: #16a34a;
    --success-light: #dcfce7;
    
    /* Light Surface System */
    --bg-base: #f8fafc;
    --bg-surface: #ffffff;
    --bg-elevated: #f1f5f9;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --ink: #0f172a;
    --ink-muted: #64748b;
    --ink-subtle: #94a3b8;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
    --shadow-lg: 0 12px 30px -4px rgba(15, 23, 42, 0.08), 0 4px 12px -2px rgba(15, 23, 42, 0.04);
    --shadow-glow: 0 0 20px var(--primary-glow);
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

/* ==========================================================================
   PALETTE VARIATIONS: Light Mode
   ========================================================================== */

[data-palette="crimson"] {
    --primary: #e11d48;
    --primary-hover: #be123c;
    --primary-light: rgba(225, 29, 72, 0.12);
    --primary-glow: rgba(225, 29, 72, 0.35);
    --accent: #f43f5e;
    --accent-light: rgba(244, 63, 94, 0.12);
    --hero-gradient: linear-gradient(135deg, #1f0409 0%, #be123c 100%);
}

[data-palette="emerald"] {
    --primary: #059669;
    --primary-hover: #047857;
    --primary-light: rgba(5, 150, 105, 0.12);
    --primary-glow: rgba(5, 150, 105, 0.35);
    --accent: #0d9488;
    --accent-light: rgba(13, 148, 136, 0.12);
    --hero-gradient: linear-gradient(135deg, #022217 0%, #059669 100%);
}

[data-palette="midnight"] {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.12);
    --primary-glow: rgba(99, 102, 241, 0.35);
    --accent: #06b6d4;
    --accent-light: rgba(6, 182, 212, 0.12);
    --hero-gradient: linear-gradient(135deg, #09090b 0%, #4338ca 100%);
}

[data-palette="mocha"] {
    --primary: #8b5432;
    --primary-hover: #6e3f22;
    --primary-light: rgba(139, 84, 50, 0.12);
    --primary-glow: rgba(139, 84, 50, 0.35);
    --accent: #b47b56;
    --accent-light: rgba(180, 123, 86, 0.12);
    --bg-base: #faf7f2;
    --bg-elevated: #f4eee6;
    --border: #e8ded2;
    --hero-gradient: linear-gradient(135deg, #27170f 0%, #784323 100%);
}

/* ==========================================================================
   DARK MODE SYSTEM
   ========================================================================== */

[data-theme="dark"] {
    --bg-base: #090d16;
    --bg-surface: #111827;
    --bg-elevated: #1a2234;
    --border: #1f293d;
    --border-strong: #334155;
    --ink: #f8fafc;
    --ink-muted: #94a3b8;
    --ink-subtle: #64748b;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.65);
    
    --danger-light: rgba(220, 38, 38, 0.2);
    --warning-light: rgba(234, 88, 12, 0.2);
    --caution-light: rgba(217, 119, 6, 0.2);
    --success-light: rgba(22, 163, 74, 0.2);
}

[data-theme="dark"][data-palette="sapphire"],
[data-theme="dark"]:not([data-palette]) {
    --primary: #38bdf8;
    --primary-hover: #0284c7;
    --primary-light: rgba(56, 189, 248, 0.15);
    --primary-glow: rgba(56, 189, 248, 0.4);
    --hero-gradient: linear-gradient(135deg, #081325 0%, #0369a1 100%);
}

[data-theme="dark"][data-palette="crimson"] {
    --primary: #fb7185;
    --primary-hover: #e11d48;
    --primary-light: rgba(251, 113, 133, 0.15);
    --primary-glow: rgba(251, 113, 133, 0.4);
    --hero-gradient: linear-gradient(135deg, #24050d 0%, #9f1239 100%);
}

[data-theme="dark"][data-palette="emerald"] {
    --primary: #34d399;
    --primary-hover: #059669;
    --primary-light: rgba(52, 211, 153, 0.15);
    --primary-glow: rgba(52, 211, 153, 0.4);
    --hero-gradient: linear-gradient(135deg, #022216 0%, #047857 100%);
}

[data-theme="dark"][data-palette="midnight"] {
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --primary-light: rgba(129, 140, 248, 0.15);
    --primary-glow: rgba(129, 140, 248, 0.4);
    --hero-gradient: linear-gradient(135deg, #09090f 0%, #3730a3 100%);
}

[data-theme="dark"][data-palette="mocha"] {
    --primary: #d4a373;
    --primary-hover: #bc6c25;
    --primary-light: rgba(212, 163, 115, 0.15);
    --primary-glow: rgba(212, 163, 115, 0.4);
    --bg-base: #140d09;
    --bg-surface: #1e1510;
    --bg-elevated: #291d16;
    --border: #38291f;
    --border-strong: #4f3b2e;
    --hero-gradient: linear-gradient(135deg, #1c0e07 0%, #5e3218 100%);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

html.text-lg {
    font-size: 19px;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-base);
    color: var(--ink);
    min-height: 100vh;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

/* Emergency Top Warning Banner */
.emergency-strip {
    background: linear-gradient(90deg, #991b1b, #dc2626);
    color: #ffffff;
    padding: 10px 16px;
    font-size: 0.92rem;
    font-weight: 600;
    text-align: center;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.emergency-strip a.quick-call-link {
    background: #ffffff;
    color: #dc2626;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    animation: pulse-border 1.8s infinite;
}

@keyframes pulse-border {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* App Header & Navigation */
.app-header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: relative;
    z-index: 40;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--ink);
}

.brand-icon-wrap {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 20px;
    box-shadow: 0 2px 10px rgba(2, 132, 199, 0.35);
}

.brand-title {
    font-size: 1.28rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-title span {
    color: #dc2626;
}

.brand-tagline {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-muted);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    color: var(--ink);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.header-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Theme & Palette Switcher Controls */
.theme-palette-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.theme-toggle-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--ink);
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
}

.palette-menu-container {
    position: relative;
}

.palette-toggle-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    position: relative;
    border-radius: var(--radius-sm);
    color: var(--ink);
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
}

.palette-active-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 2px var(--bg-surface);
}

.palette-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 210px;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 12px;
    display: none;
    z-index: 1000;
    animation: dropdownFade 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.palette-dropdown-menu.show {
    display: block;
}

.palette-dropdown-title {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-muted);
    margin-bottom: 8px;
    padding: 0 4px;
}

.palette-options-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.palette-option-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid transparent;
    color: var(--ink);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
}

.palette-option-btn:hover {
    background: var(--bg-elevated);
    color: var(--primary);
}

.palette-option-btn.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.palette-swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Profile Dropdown Navigation */
.profile-menu-container {
    position: relative;
}

.profile-pill-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    color: var(--ink);
    padding: 5px 12px 5px 6px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.profile-pill-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.user-avatar-initial {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0284c7, #0d9488);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.82rem;
}

.profile-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 250px;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 40px -10px rgba(15, 23, 42, 0.2), 0 4px 12px rgba(15, 23, 42, 0.08);
    padding: 10px;
    display: none;
    z-index: 1000;
    animation: dropdownFade 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.profile-dropdown-menu.show {
    display: block;
}

@keyframes dropdownFade {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-header {
    padding: 10px 12px 12px;
}

.dropdown-user-name {
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--ink);
}

.dropdown-user-email {
    font-size: 0.78rem;
    color: var(--ink-muted);
    margin-top: 2px;
    word-break: break-all;
}

.dropdown-user-badge {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 800;
    font-size: 0.68rem;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 6px;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--ink);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    transition: all 0.15s ease;
}

.dropdown-item:hover {
    background: var(--bg-base);
    color: var(--primary);
}

.dropdown-item.dropdown-logout {
    color: #dc2626;
}

.dropdown-item.dropdown-logout:hover {
    background: #fee2e2;
    color: #b91c1c;
}

/* Main Container Wrap */
.main-wrapper {
    max-width: 1140px;
    margin: 0 auto;
    padding: 24px 20px 80px;
}

/* Stepper Progress Bar */
.stepper-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    box-shadow: 0 4px 16px -2px rgba(15, 23, 42, 0.05);
    overflow-x: auto;
    border-radius: var(--radius-lg);
    padding: 16px 24px;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink-muted);
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.step-item.active {
    color: var(--primary);
    font-weight: 700;
}

.step-item.completed {
    color: var(--teal);
    font-weight: 600;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-base);
    border: 1.5px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.88rem;
    color: var(--ink-muted);
    transition: all 0.25s ease;
}

.step-item.active .step-number {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 0 0 4px var(--primary-light);
}

.step-item.completed .step-number {
    background: var(--teal);
    border-color: var(--teal);
    color: #ffffff;
}

.step-divider {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 16px;
    min-width: 24px;
    border-radius: 2px;
}

/* Screen Sections */
.triage-screen {
    display: none;
    animation: fadeIn 0.3s ease;
}

.triage-screen.active {
    display: block;
}

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

/* Virtual Doctor AI Persona Card */
.doctor-guide-card {
    background: linear-gradient(135deg, var(--bg-surface) 60%, var(--primary-light));
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 18px 22px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: var(--shadow-sm);
}

.doctor-avatar-wrap {
    position: relative;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
}

.doctor-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
    box-shadow: var(--shadow-md);
}

.doctor-online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid var(--bg-surface);
}

.doctor-info-wrap {
    flex: 1;
}

.doctor-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.doctor-name {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--ink);
}

.doctor-role-badge {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.doctor-speech-bubble {
    color: var(--ink-muted);
    font-size: 0.92rem;
    line-height: 1.45;
}

.tts-speech-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--ink);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
}

.tts-speech-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Card layouts */
.content-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 26px 28px;
    box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
    margin-bottom: 24px;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card-heading-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.card-title {
    font-size: 1.32rem;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.015em;
}

.card-subtitle {
    color: var(--ink-muted);
    font-size: 0.92rem;
    margin-top: 4px;
    line-height: 1.5;
}

/* Form Inputs Grid */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.input-subtext {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--ink-muted);
}

.form-input, .form-select {
    width: 100%;
    min-height: 48px;
    padding: 11px 16px;
    border: 1.5px solid var(--border-strong);
    background: var(--bg-surface);
    color: var(--ink);
    border-radius: 10px;
    font-family: var(--font-sans);
    font-size: 0.96rem;
    font-weight: 500;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.form-select option,
select option {
    background-color: var(--bg-surface);
    color: var(--ink);
    padding: 10px 14px;
}

[data-theme="dark"] .form-select option,
[data-theme="dark"] select option,
.dark .form-select option,
.dark select option {
    background-color: #111827 !important;
    color: #f8fafc !important;
}

[data-theme="light"] .form-select option,
[data-theme="light"] select option {
    background-color: #ffffff !important;
    color: #0f172a !important;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
    background: var(--bg-surface);
}

/* Step Validation Error Banner & Required Badges */
.step-validation-banner {
    background: #fef2f2;
    border: 1.5px solid #f87171;
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    margin-bottom: 20px;
    color: #991b1b;
    font-size: 0.9rem;
    animation: bannerShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

[data-theme="dark"] .step-validation-banner {
    background: #450a0a;
    border-color: #ef4444;
    color: #fca5a5;
}

.step-validation-banner .banner-head {
    font-weight: 800;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.step-validation-banner ul {
    margin-left: 24px;
    line-height: 1.55;
}

.step-validation-banner li {
    margin-top: 3px;
    font-weight: 600;
}

@keyframes bannerShake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

.input-error {
    border-color: #dc2626 !important;
    background-color: rgba(220, 38, 38, 0.04) !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18) !important;
}

.req-tag {
    font-size: 0.72rem;
    font-weight: 700;
    color: #dc2626;
    background: #fee2e2;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-left: 6px;
}

[data-theme="dark"] .req-tag {
    background: #450a0a;
    color: #fca5a5;
}

.opt-tag {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ink-muted);
    background: var(--bg-elevated);
    padding: 2px 7px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid var(--border);
    margin-left: 6px;
    display: inline-block;
    vertical-align: middle;
}

[data-theme="dark"] .opt-tag {
    background: rgba(255, 255, 255, 0.06);
    color: #94a3b8;
    border-color: rgba(255, 255, 255, 0.12);
}

.custom-checkbox {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 2px solid var(--border-strong);
    background: var(--bg-surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.chip-select.selected .custom-checkbox {
    border-color: var(--primary);
    background: var(--primary);
}

.chip-select.danger-chip.selected .custom-checkbox {
    border-color: var(--danger);
    background: var(--danger);
}

.custom-checkbox::after {
    content: '';
    width: 4px;
    height: 8px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
    display: none;
}

.chip-select.selected .custom-checkbox::after {
    display: block;
}


/* Pulse Tap Tool */
.pulse-tapper-wrap {
    background: var(--bg-elevated);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.pulse-tap-btn {
    background: #dc2626;
    color: #ffffff;
    border: none;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.1s;
    user-select: none;
}

.pulse-tap-btn:active {
    transform: scale(0.94);
}

.pulse-display {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.15rem;
    color: #dc2626;
}

/* Checkbox and Risk Factor Pill Grids */
.chip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.chip-select {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    padding: 12px 16px;
    min-height: 60px;
    background: var(--bg-surface);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.90rem;
    color: var(--ink);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.chip-select.has-doc-badge {
    /* no extra padding needed — badge flows in flex layout */
}

.doc-risk-badge {
    display: inline-block;
    margin-left: auto;
    flex-shrink: 0;
    align-self: flex-start;
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: rgba(234, 88, 12, 0.16);
    color: #ea580c;
    border: 1px solid rgba(234, 88, 12, 0.35);
    padding: 2px 7px;
    border-radius: 99px;
    line-height: 1.4;
    white-space: nowrap;
    pointer-events: none;
}

/* Text label inside chips takes remaining space — pushes badge to far right */
.chip-select > span:not(.custom-checkbox):not(.doc-risk-badge) {
    flex: 1;
    min-width: 0;
}

.chip-select:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.08);
}

.chip-select.selected {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 700;
    box-shadow: 0 2px 10px var(--primary-light);
}

[data-theme="dark"] .chip-select.selected {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.chip-select.danger-chip.selected {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}

.chip-icon {
    font-size: 1.25rem;
    line-height: 1;
}

/* ==========================================================================
   Interactive Human Model Stage (Step 2)
   ========================================================================== */
.human-model-stage {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 860px) {
    .human-model-stage {
        grid-template-columns: 1fr;
    }
}

.model-viewport-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 20px 16px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 16px 36px -12px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(0, 0, 0, 0.03);
    position: relative;
    transition: all 0.3s ease;
}

.model-controls-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 14px;
}

.toggle-group {
    display: flex;
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 3px;
    gap: 2px;
}

[data-theme="dark"] .toggle-group {
    background: rgba(255, 255, 255, 0.06);
}

.toggle-opt-btn {
    background: none;
    border: none;
    color: var(--ink-muted);
    font-weight: 700;
    font-size: 0.8rem;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.toggle-opt-btn.active {
    background: var(--bg-surface);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.svg-model-container {
    width: 100%;
    max-width: 290px;
    height: auto;
    position: relative;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.svg-model-container svg {
    filter: drop-shadow(0 6px 14px rgba(15, 23, 42, 0.06));
}

/* Hotspot pulse radar animations */
.hotspot-beacon .ping-circle {
    transform-origin: center;
    animation: pingRadar 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes pingRadar {
    0% { r: 16px; opacity: 0.8; stroke-width: 3px; }
    75%, 100% { r: 36px; opacity: 0; stroke-width: 1px; }
}

.hotspot-beacon:hover .target-circle {
    fill: rgba(2, 132, 199, 0.45);
    stroke-width: 3.5px;
}

.hotspot-beacon.active .target-circle {
    fill: rgba(220, 38, 38, 0.5);
    stroke: #dc2626;
}

.heart-pulse-aura {
    animation: heartbeatSync 1.1s ease-in-out infinite;
    transform-origin: 158px 152px;
}

@keyframes heartbeatSync {
    0% { transform: scale(1); opacity: 0.5; }
    18% { transform: scale(1.18); opacity: 0.95; }
    30% { transform: scale(1.05); opacity: 0.7; }
    45% { transform: scale(1.22); opacity: 1; }
    70%, 100% { transform: scale(1); opacity: 0.5; }
}

/* Interactive Pain Intensity Slider */
.pain-scale-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin-bottom: 20px;
}

.pain-slider-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.pain-value-badge {
    font-size: 1.15rem;
    font-weight: 800;
    padding: 4px 14px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.pain-slider-input {
    width: 100%;
    -webkit-appearance: none;
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(90deg, #10b981 0%, #f59e0b 50%, #dc2626 100%);
    outline: none;
    cursor: pointer;
}

.pain-slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid var(--primary);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.1s;
}

.pain-slider-input::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

/* Radiation Pathways Selector */
.radiation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.radiation-badge {
    padding: 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    text-align: center;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.15s;
    user-select: none;
}

.radiation-badge.active {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}

/* Body Spot Symptom Accordion / Detail Cards */
.spot-detail-card {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    margin-bottom: 14px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.spot-detail-card.highlighted {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.spot-card-header {
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-elevated);
    cursor: pointer;
    user-select: none;
}

.spot-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1rem;
}

.spot-card-body {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.symptom-tag-btn {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
}

.symptom-tag-btn:hover {
    border-color: var(--primary);
}

.symptom-tag-btn.selected {
    background: var(--primary-light);
    border-color: var(--primary);
}

.symptom-tag-btn.sev-3.selected {
    background: var(--danger-light);
    border-color: var(--danger);
}

.tag-checkbox-box, .tag-radio-circle {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
    background: var(--bg-surface);
    transition: all 0.15s ease;
}

.symptom-tag-btn.selected .tag-checkbox-box,
.symptom-tag-btn.selected .tag-radio-circle {
    border-color: var(--primary);
    background: var(--primary);
}

.symptom-tag-btn.sev-3.selected .tag-checkbox-box,
.symptom-tag-btn.sev-3.selected .tag-radio-circle {
    border-color: var(--danger);
    background: var(--danger);
}

.tag-checkbox-box::after, .tag-radio-circle::after {
    content: '';
    width: 5px;
    height: 9px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
    display: none;
}

.symptom-tag-btn.selected .tag-checkbox-box::after,
.symptom-tag-btn.selected .tag-radio-circle::after {
    display: block;
}

/* ==========================================================================
   Results Screen (Step 3) - Outputs & Clinical Visualizers
   ========================================================================== */
.results-hero-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

@media (max-width: 800px) {
    .results-hero-grid {
        grid-template-columns: 1fr;
    }
}

.triage-verdict-card {
    border-radius: var(--radius-md);
    padding: 24px;
    color: #ffffff;
    box-shadow: var(--shadow-md);
}

.triage-verdict-card.triage-critical {
    background: linear-gradient(135deg, #991b1b, #dc2626);
    box-shadow: var(--shadow-glow-red);
}

.triage-verdict-card.triage-urgent {
    background: linear-gradient(135deg, #c2410c, #ea580c);
}

.triage-verdict-card.triage-moderate {
    background: linear-gradient(135deg, #b45309, #d97706);
}

.triage-verdict-card.triage-low {
    background: linear-gradient(135deg, #15803d, #16a34a);
}

.verdict-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.verdict-title {
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: 10px;
}

.verdict-desc {
    font-size: 0.96rem;
    opacity: 0.95;
    line-height: 1.5;
}

/* Cardiac Risk Gauge & Score Card */
.score-summary-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.gauge-wrap {
    display: flex;
    align-items: center;
    gap: 20px;
}

.gauge-circle {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.7rem;
    font-weight: 800;
    color: #ffffff;
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
}

/* Model Hint Pill */
.model-hint-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(2, 132, 199, 0.08);
    color: var(--primary);
    border: 1px solid rgba(2, 132, 199, 0.25);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 14px;
    width: fit-content;
}

/* Coronary Artery Blockage Visualization */
.artery-viz-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 22px;
    box-shadow: var(--shadow-sm);
}

.artery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 14px;
}

.artery-block-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}

.artery-name {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.artery-meter {
    height: 8px;
    border-radius: 4px;
    background: var(--border);
    overflow: hidden;
    margin-top: 6px;
}

.artery-meter-fill {
    height: 100%;
    transition: width 0.8s ease;
}

/* Differentials Progress Table */
.diff-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 14px;
}

.diff-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}

.diff-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.diff-name {
    font-weight: 700;
    font-size: 0.98rem;
}

.diff-pct {
    font-weight: 800;
    font-size: 1.1rem;
    font-family: var(--font-mono);
}

.diff-progress-bar {
    height: 7px;
    border-radius: 4px;
    background: var(--border);
    overflow: hidden;
    margin-bottom: 8px;
}

.diff-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s ease;
}

.diff-desc {
    font-size: 0.84rem;
    color: var(--ink-muted);
}

/* Action Buttons & Footers */
.stepper-actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 28px;
    flex-wrap: wrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.96rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 14px var(--primary-glow);
    text-decoration: none;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1.5px);
    box-shadow: 0 6px 20px var(--primary-glow);
    text-decoration: none;
    color: #ffffff;
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px var(--primary-glow);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--ink);
    border: 1.5px solid var(--border-strong);
    padding: 12px 22px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-1.5px);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
    padding: 12px 22px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-outline:hover {
    background: var(--primary-light);
    transform: translateY(-1.5px);
    text-decoration: none;
}

.btn-emergency-action {
    background: #dc2626;
    color: #ffffff;
    border: none;
    padding: 15px 28px;
    border-radius: var(--radius-sm);
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.4);
    text-decoration: none;
}

.btn-emergency-action:hover {
    background: #b91c1c;
}

/* ==========================================================================
   Comprehensive Multi-Device Responsiveness (Phone, Tablet, Laptop)
   ========================================================================== */

/* Tablet & Smaller Laptops (max-width: 1024px) */
@media (max-width: 1024px) {
    .main-wrapper {
        padding: 20px 16px 60px;
    }
    .human-model-stage {
        grid-template-columns: 310px 1fr;
        gap: 18px;
    }
}

/* Portrait Tablet & Mobile Breakdown (max-width: 860px) */
@media (max-width: 860px) {
    .human-model-stage {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .triage-left-stage-col {
        max-width: 480px;
        margin: 0 auto;
        width: 100%;
    }
    .model-viewport-card {
        padding: 16px 14px;
    }
}

/* Mobile Devices / Phones (max-width: 640px) */
@media (max-width: 640px) {
    .emergency-strip {
        font-size: 0.8rem;
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 6px;
    }
    .emergency-strip a.quick-call-link {
        font-size: 0.78rem;
        padding: 3px 10px;
    }

    .app-header {
        padding: 12px 14px;
        flex-wrap: wrap;
        gap: 10px;
    }
    .header-brand .brand-title {
        font-size: 1.15rem;
    }
    .header-brand .brand-tagline {
        display: none;
    }
    .header-controls {
        gap: 6px;
    }
    .header-btn {
        padding: 6px 10px;
        font-size: 0.78rem;
    }

    /* Stepper Navigation on mobile phones */
    .stepper-nav {
        padding: 10px 12px;
        margin-bottom: 20px;
        gap: 4px;
    }
    .step-item {
        font-size: 0.78rem;
        gap: 6px;
    }
    .step-number {
        width: 26px;
        height: 26px;
        font-size: 0.78rem;
    }
    .step-divider {
        margin: 0 4px;
        min-width: 10px;
    }

    /* Pain Slider Mobile Styling */
    .pain-scale-box {
        padding: 14px 14px;
    }
    .pain-slider-head {
        flex-wrap: wrap;
        gap: 8px;
        align-items: flex-start;
    }
    .pain-value-badge {
        font-size: 0.95rem;
        padding: 4px 10px;
        width: 100%;
        justify-content: center;
    }
    .pain-slider-input::-webkit-slider-thumb {
        width: 30px;
        height: 30px;
    }

    /* Chips & Badges Grid on Mobile */
    .chip-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .chip-select {
        min-height: 52px;
        padding: 10px 14px;
        font-size: 0.88rem;
    }
    .radiation-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .radiation-badge {
        padding: 10px 12px;
        font-size: 0.82rem;
        text-align: center;
    }

    /* Stepper Actions Buttons */
    .stepper-actions {
        flex-direction: column-reverse;
        gap: 10px;
    }
    .stepper-actions .btn-primary,
    .stepper-actions .btn-secondary,
    .stepper-actions .btn-emergency-action {
        width: 100%;
        justify-content: center;
        padding: 13px 18px;
        font-size: 0.95rem;
    }

    /* Model controls tap friendly */
    .model-controls-row {
        flex-direction: column;
        gap: 8px;
    }
    .toggle-group {
        width: 100%;
        justify-content: center;
    }
    .toggle-opt-btn {
        flex: 1;
        text-align: center;
        padding: 8px 12px;
        font-size: 0.82rem;
    }
}

/* Extra Small Phones (max-width: 380px) */
@media (max-width: 380px) {
    .step-item span {
        display: none; /* Show only step numbers for ultra-compact screens */
    }
    .radiation-grid {
        grid-template-columns: 1fr;
    }
}
