@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    /* Color Palette - HSL (Light Clinical Theme) */
    --bg-dark: hsl(210, 36%, 96%);
    --bg-panel: #ffffff;
    --bg-card: hsl(210, 30%, 98%);
    --border-color: hsl(214, 30%, 88%);
    --border-color-active: hsla(217, 91%, 50%, 0.4);
    
    /* Medical Cobalt Blue Colors */
    --med-blue: hsl(217, 91%, 50%);
    --med-blue-glow: hsla(217, 91%, 50%, 0.08);
    --med-blue-dark: hsl(217, 85%, 40%);
    
    /* State Colors */
    --color-correct: hsl(142, 72%, 29%);
    --color-correct-bg: hsl(142, 70%, 95%);
    --color-incorrect: hsl(346, 84%, 61%);
    --color-incorrect-bg: hsl(346, 100%, 97%);
    --color-warning: hsl(36, 100%, 45%);
    --color-warning-bg: hsl(36, 100%, 96%);
    
    /* Text Colors */
    --text-primary: hsl(222, 47%, 15%);
    --text-secondary: hsl(215, 20%, 40%);
    --text-muted: hsl(215, 16%, 60%);
    
    /* Fonts */
    --font-sans: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    /* UI Sizing */
    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-sm: 4px;
    --transition-smooth: all 0.2s ease-in-out;
}

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

body {
    background-color: var(--bg-dark);
    background-image: radial-gradient(at 50% 0%, hsl(210, 40%, 94%) 0, transparent 75%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-heartbeat {
    width: 28px;
    height: 28px;
    background: var(--med-blue);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3C/svg%3E") no-repeat center;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3C/svg%3E") no-repeat center;
}

.logo-heartbeat.pulse-active {
    animation: pulse-rapid 0.4s ease-out;
}

@keyframes pulse-rapid {
    0% { transform: scale(1); }
    30% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.mode-badge {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--med-blue);
    text-transform: uppercase;
}

.stats-container {
    display: flex;
    gap: 1.5rem;
    font-size: 0.9rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.stat-label {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
}

.stat-value {
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

/* Dashboard Layout */
.dashboard {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 1.5rem;
    padding: 1.5rem 2rem;
    height: calc(100vh - 63px);
    max-height: calc(100vh - 63px);
    overflow: hidden;
}

@media (max-width: 1200px) {
    .dashboard {
        grid-template-columns: 1fr;
        height: auto;
        max-height: none;
        overflow: visible;
    }
}

/* Left Panel: ECG Display */
.ecg-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    padding: 1.25rem;
    overflow: hidden;
    height: 100%;
}

.ecg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.ecg-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.telemetry-tag {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-card);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-weight: 500;
}

.ecg-controls {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: var(--transition-smooth);
}

.btn-icon:hover {
    background: var(--bg-card);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.btn-icon.active {
    background: var(--med-blue-glow);
    border-color: var(--med-blue);
    color: var(--med-blue-dark);
}

.ecg-viewport {
    flex-grow: 1;
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    min-height: 400px;
}

canvas#ecgCanvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: zoom-in;
}

/* Right Panel: Case and Diagnosis Options */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
    overflow-y: auto;
    padding-right: 4px;
}

/* Scrollbar styling */
.control-panel::-webkit-scrollbar {
    width: 6px;
}
.control-panel::-webkit-scrollbar-track {
    background: transparent;
}
.control-panel::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    padding: 1.25rem;
}

/* Vignette Section */
.vignette-section h2 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    font-weight: 700;
}

.vignette-text {
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

/* Tabs for RAHIM Navigation */
.rahim-nav {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    background: hsl(210, 24%, 93%);
    border-radius: var(--radius-md);
    padding: 3px;
    margin-bottom: 1rem;
}

.rahim-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.45rem 0;
    text-align: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.rahim-tab:hover {
    color: var(--text-primary);
}

.rahim-tab.active {
    background: #ffffff;
    color: var(--med-blue);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.rahim-tab.checked {
    position: relative;
}

.rahim-tab.checked::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: 3px;
    background: var(--med-blue);
    border-radius: 50%;
}

.rahim-content {
    display: none;
    flex-direction: column;
    gap: 0.6rem;
    min-height: 230px;
}

.rahim-content.active {
    display: flex;
}

.rahim-content-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rahim-content-title span {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: normal;
}

/* Radio Option Cards */
.options-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition-smooth);
}

.option-card:hover {
    border-color: var(--text-muted);
    background: hsl(210, 24%, 95%);
}

.option-card.selected {
    border-color: var(--med-blue);
    background: var(--med-blue-glow);
}

.option-card.correct {
    border-color: var(--color-correct) !important;
    background: var(--color-correct-bg) !important;
    color: var(--color-correct) !important;
}

.option-card.incorrect {
    border-color: var(--color-incorrect) !important;
    background: var(--color-incorrect-bg) !important;
    color: var(--color-incorrect) !important;
}

.option-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: inherit;
}

.option-checkbox {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.option-card.selected .option-checkbox {
    border-color: var(--med-blue);
    background: var(--med-blue);
}

.option-card.selected .option-checkbox::after {
    content: '';
    width: 4px;
    height: 4px;
    background: #ffffff;
    border-radius: 50%;
}

/* Practice Mode Parameters Sliders */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.6rem;
}

.slider-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.slider-info span.value {
    font-family: var(--font-mono);
    color: var(--med-blue);
    font-weight: bold;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: hsl(210, 20%, 90%);
    height: 4px;
    border-radius: 2px;
    outline: none;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--med-blue);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    transition: var(--transition-smooth);
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

/* Action Buttons */
.action-container {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.btn {
    flex-grow: 1;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.btn-primary {
    background: var(--med-blue);
    color: #ffffff;
    box-shadow: 0 2px 8px hsla(217, 91%, 50%, 0.15);
}

.btn-primary:hover {
    background: var(--med-blue-dark);
    box-shadow: 0 4px 12px hsla(217, 91%, 50%, 0.25);
}

.btn-secondary {
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card);
    border-color: var(--text-muted);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Overlay and Explanations */
.overlay-explanation {
    margin-top: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    display: none;
    flex-direction: column;
    gap: 0.75rem;
}

.overlay-explanation.visible {
    display: flex;
    animation: fade-in 0.3s ease-out;
}

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

.explanation-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.explanation-text {
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

/* Study Guide Tips Box */
.educational-tips-box {
    background: var(--color-warning-bg);
    border: 1px solid hsla(36, 100%, 45%, 0.2);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.educational-tips-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-warning);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.educational-tip-item {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-primary);
    border-left: 2px solid hsla(36, 100%, 45%, 0.4);
    padding-left: 0.5rem;
}

.educational-tip-item strong {
    color: var(--med-blue-dark);
}

.explanation-metric {
    display: inline-block;
    padding: 0.15rem 0.35rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--med-blue);
    margin-right: 0.2rem;
    margin-bottom: 0.2rem;
}

/* Mode Selection Switches */
.toggle-switch {
    display: inline-flex;
    background: hsl(210, 24%, 92%);
    border-radius: 4px;
    padding: 2px;
}

.toggle-option {
    padding: 0.3rem 0.75rem;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-smooth);
    border: none;
    background: transparent;
}

.toggle-option.active {
    background: #ffffff;
    color: var(--med-blue-dark);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Notification Overlay (Toast) */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1.25rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 1000;
    transform: translateY(80px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.15);
    pointer-events: none;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-icon {
    font-size: 1rem;
    font-weight: bold;
}

.toast-message {
    font-size: 0.85rem;
    font-weight: 600;
}

.toast-success {
    border-left: 3px solid var(--color-correct);
}
.toast-success .toast-icon {
    color: var(--color-correct);
}

.toast-error {
    border-left: 3px solid var(--color-incorrect);
}
.toast-error .toast-icon {
    color: var(--color-incorrect);
}

/* Zoom Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fade-in-modal 0.2s ease-out;
}

.modal-content {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 950px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slide-up-modal 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fade-in-modal {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slide-up-modal {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.modal-close-btn {
    background: transparent;
    border: none;
    font-size: 1.85rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0.2rem;
    transition: var(--transition-smooth);
}

.modal-close-btn:hover {
    color: var(--color-incorrect);
}

.modal-body {
    padding: 1.25rem;
    background: #ffffff;
    height: 400px;
}

canvas#modalCanvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

/* 4-Chamber Heart Conduction Simulator Styles */
.conduction-svg {
    width: 140px;
    height: 140px;
    display: block;
    transform: scale(1);
    transform-origin: center;
}

.chamber-circle {
    fill: #ffffff;
    stroke: #94a3b8;
    stroke-width: 1.5px;
    transition: fill 0.1s ease, stroke 0.1s ease, r 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chamber-circle.active-atrium {
    fill: hsla(217, 91%, 50%, 0.12) !important;
    stroke: var(--med-blue) !important;
    stroke-width: 2.2px !important;
    transform: scale(1.08);
    transform-origin: 30px 32px; /* RA center */
}

#circLA.active-atrium {
    transform-origin: 70px 32px; /* LA center */
}

.chamber-circle.active-ventricle {
    fill: hsla(217, 91%, 50%, 0.18) !important;
    stroke: var(--med-blue) !important;
    stroke-width: 2.5px !important;
    transform: scale(1.1);
    transform-origin: 30px 72px; /* RV center */
}

#circLV.active-ventricle {
    transform-origin: 70px 72px; /* LV center */
}

/* VFib Quivering for all chambers */
.chamber-shiver {
    animation: chamber-shiver-anim 0.1s infinite linear;
}

#circRA.chamber-shiver { transform-origin: 30px 32px; }
#circLA.chamber-shiver { transform-origin: 70px 32px; }
#circRV.chamber-shiver { transform-origin: 30px 72px; }
#circLV.chamber-shiver { transform-origin: 70px 72px; }

@keyframes chamber-shiver-anim {
    0% { transform: translate(0.5px, 0.5px) rotate(0deg) scale(1.02); }
    25% { transform: translate(-0.5px, -1px) rotate(-0.5deg) scale(0.98); }
    50% { transform: translate(-1px, 0px) rotate(0.5deg) scale(1.03); }
    75% { transform: translate(0.5px, 1px) rotate(0deg) scale(0.97); }
    100% { transform: translate(0.5px, -0.5px) rotate(-0.5deg) scale(1.02); }
}

.chamber-shiver.chamber-circle {
    fill: hsl(346, 100%, 97%) !important;
    stroke: var(--color-incorrect) !important;
}

.chamber-label {
    font-family: var(--font-sans);
    font-size: 8px;
    font-weight: 700;
    fill: #475569;
    text-anchor: middle;
    pointer-events: none;
    user-select: none;
}

.conduction-path {
    fill: none;
    stroke: #e2e8f0;
    stroke-width: 1.8px;
    stroke-linecap: round;
    transition: stroke 0.08s ease, stroke-width 0.08s ease;
}

.conduction-path.active {
    stroke: #f59e0b !important;
    stroke-width: 2.8px !important;
}

.conduction-path.blocked {
    stroke: #ef4444 !important;
    stroke-width: 1.5px !important;
    stroke-dasharray: 2,2 !important;
}

.node-circle {
    fill: #10b981;
    stroke: #ffffff;
    stroke-width: 1px;
    transition: fill 0.08s ease, transform 0.08s ease;
    transform-origin: center;
}

.node-circle.active {
    fill: #f59e0b !important;
}

/* Infarct/STEMI Zones */
.infarct-zone {
    fill: none;
    stroke: transparent;
    stroke-width: 4px;
    stroke-linecap: round;
    opacity: 0;
    transition: var(--transition-smooth);
}

.infarct-zone.stemi-active {
    stroke: #ef4444 !important;
    opacity: 0.85;
    animation: stemi-pulse 1s infinite alternate;
}

.infarct-zone.ischemia-active {
    stroke: #6366f1 !important; /* purple/indigo for ischemia */
    opacity: 0.75;
    animation: ischemia-pulse 1.5s infinite alternate;
}

@keyframes stemi-pulse {
    0% { stroke-width: 3.5px; filter: drop-shadow(0 0 1px rgba(239, 68, 68, 0.4)); }
    100% { stroke-width: 5.5px; filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.9)); }
}

@keyframes ischemia-pulse {
    0% { stroke-width: 3.5px; filter: drop-shadow(0 0 1px rgba(99, 102, 241, 0.3)); }
    100% { stroke-width: 4.8px; filter: drop-shadow(0 0 3px rgba(99, 102, 241, 0.7)); }
}

/* WPW Accessory Pathway */
.path-WPW {
    stroke-dasharray: 2, 2;
    display: none;
}

.path-WPW.visible {
    display: block;
    stroke: #cbd5e1;
}

.path-WPW.active {
    stroke: #f59e0b !important;
    stroke-width: 2.2px !important;
}

/* Axis Compass */
.axis-normal-zone {
    fill: hsla(142, 72%, 29%, 0.08);
    stroke: none;
    pointer-events: none;
}

.axis-ring {
    fill: none;
    stroke: #e2e8f0;
    stroke-width: 0.75px;
    stroke-dasharray: 1.5, 1.5;
    pointer-events: none;
}

.axis-arrow-line {
    stroke: var(--med-blue);
    stroke-width: 1.6px;
    stroke-linecap: round;
    transition: transform 0.3s ease, stroke 0.3s ease;
    transform-origin: 50px 62px;
}

.axis-arrow-line.normal {
    stroke: #10b981;
    color: #10b981;
}

.axis-arrow-line.lad {
    stroke: #f59e0b;
    color: #f59e0b;
}

.axis-arrow-line.rad {
    stroke: #ec4899;
    color: #ec4899;
}

.axis-arrow-line.extreme {
    stroke: #ef4444;
    color: #ef4444;
}

/* Shake Animation for Lives display */
.shake {
    animation: shake-anim 0.4s ease;
}

@keyframes shake-anim {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* Hearts Display */
.hearts-display {
    display: inline-block;
    transition: transform 0.2s ease;
}

/* Spinner for simulated ad */
@keyframes ad-spin {
    to { transform: rotate(360deg); }
}

/* MedCredits Refill Button Styling */
.btn-add-credits {
    background: var(--color-warning-bg);
    border: 1px solid var(--color-warning);
    color: var(--color-warning);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: var(--transition-smooth);
    margin-left: 0.15rem;
}

.btn-add-credits:hover {
    background: var(--color-warning);
    color: #ffffff;
    transform: scale(1.12);
    box-shadow: 0 1px 4px rgba(217, 119, 6, 0.2);
}

.btn-add-credits:active {
    transform: scale(0.95);
}

/* ==========================================
   Layout Selection Modal & Simulator Layouts 
   ========================================== */

body.view-pc {
    background-color: var(--bg-dark);
}

body.view-pc #appWrapper {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

/* Tablet View Simulator */
body.view-tablet {
    background-color: #0b0f19;
    background-image: radial-gradient(at 50% 0%, #1e293b 0%, transparent 75%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1.5rem;
    box-sizing: border-box;
}

body.view-tablet #appWrapper {
    width: 768px;
    height: 1024px;
    max-height: 96vh;
    border: 12px solid #334155;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Allow entire screen inside tablet frame to scroll */
    position: relative;
    box-sizing: border-box;
}

body.view-tablet header {
    padding: 0.75rem 1.25rem;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

body.view-tablet .dashboard {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
    overflow-y: visible;
    padding: 1rem;
    gap: 1rem;
}

body.view-tablet .ecg-panel {
    height: auto;
}

body.view-tablet .ecg-viewport {
    min-height: 320px;
    height: 320px;
}

body.view-tablet .control-panel {
    overflow-y: visible;
    height: auto;
}

/* Mobile View Simulator */
body.view-mobile {
    background-color: #0b0f19;
    background-image: radial-gradient(at 50% 0%, #1e293b 0%, transparent 75%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
    box-sizing: border-box;
}

body.view-mobile #appWrapper {
    width: 390px;
    height: 844px;
    max-height: 96vh;
    border: 12px solid #1e293b;
    border-radius: 36px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Allow entire screen inside phone frame to scroll */
    position: relative;
    box-sizing: border-box;
}

/* Simulated Smartphone Notch */
body.view-mobile #appWrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 130px;
    height: 16px;
    background: #1e293b;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    z-index: 1001;
}

body.view-mobile header {
    padding: 1.25rem 0.75rem 0.6rem 0.75rem;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    height: auto;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

body.view-mobile .logo-container h1 {
    font-size: 1.05rem;
    text-align: center;
}

body.view-mobile .logo-container {
    flex-direction: column;
    gap: 0.25rem;
}

body.view-mobile .logo-heartbeat {
    display: none; /* Hide icon in tiny headers */
}

body.view-mobile .header-controls {
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

body.view-mobile .toggle-switch {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
}

body.view-mobile .toggle-option {
    padding: 0.4rem 0.2rem;
    font-size: 0.68rem;
    text-align: center;
}

body.view-mobile .stats-container {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
    font-size: 0.75rem;
}

body.view-mobile .stat-item {
    justify-content: center;
    background: var(--bg-panel);
    padding: 0.25rem 0.4rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

body.view-mobile .dashboard {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
    overflow-y: visible;
    padding: 0.75rem;
    gap: 0.75rem;
}

body.view-mobile .ecg-panel {
    padding: 0.75rem;
    height: auto;
}

body.view-mobile .ecg-header {
    flex-direction: column;
    gap: 0.4rem;
    align-items: flex-start;
}

body.view-mobile .ecg-controls {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 0.2rem;
    display: flex;
    flex-wrap: nowrap;
    gap: 0.3rem;
}

body.view-mobile .ecg-controls::-webkit-scrollbar {
    height: 3px;
}

body.view-mobile .ecg-controls::-webkit-scrollbar-thumb {
    background: var(--border-color);
}

body.view-mobile .ecg-controls .btn-icon {
    flex-shrink: 0;
    padding: 0.3rem 0.45rem;
    font-size: 0.7rem;
    gap: 0.2rem;
}

body.view-mobile .ecg-viewport {
    min-height: 240px;
    height: 240px;
}

body.view-mobile .control-panel {
    overflow-y: visible;
    height: auto;
    padding-right: 0;
}

body.view-mobile .rahim-nav {
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
}

body.view-mobile .rahim-tab {
    padding: 0.35rem 0;
    font-size: 0.7rem;
}

body.view-mobile .options-grid {
    gap: 0.4rem;
}

body.view-mobile .option-card {
    padding: 0.5rem 0.75rem;
}

body.view-mobile .option-label {
    font-size: 0.78rem;
}

body.view-mobile .btn {
    padding: 0.6rem 1rem;
    font-size: 0.82rem;
}

/* Ensure mobile scrollable overlays render appropriately */
body.view-mobile .modal-content {
    max-width: 90% !important;
    max-height: 90% !important;
}

body.view-mobile .modal-body {
    height: 260px;
}

/* Physical responsiveness override for small real devices */
@media (max-width: 900px) {
    body.view-tablet, body.view-mobile {
        display: block !important;
        padding: 0 !important;
        background-color: var(--bg-dark) !important;
        background-image: none !important;
    }
    body.view-tablet #appWrapper, body.view-mobile #appWrapper {
        width: 100% !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        padding-top: 0 !important;
    }
    body.view-mobile #appWrapper::before {
        display: none !important;
    }
}

/* Inline Consult Button (RAHIM panel bottom) */
.btn-consult-inline {
    margin-top: 0.85rem;
    width: 100%;
    border: 1px solid var(--color-warning);
    color: var(--color-warning);
    background: var(--color-warning-bg);
    font-weight: 700;
    font-size: 0.82rem;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-family: var(--font-sans);
    transition: var(--transition-smooth);
    box-shadow: 0 1px 3px rgba(217, 119, 6, 0.05);
}

.btn-consult-inline:hover {
    background: var(--color-warning);
    color: #ffffff;
    box-shadow: 0 4px 8px rgba(217, 119, 6, 0.15);
    transform: translateY(-1px);
}

.btn-consult-inline:active {
    transform: translateY(0);
}

/* Default hidden states (visible only on mobile) */
#btnToggleSoundHeaderContainer {
    display: none;
}
#btnOpenCreditsInline {
    display: none;
}

/* Hide top telemetry consult button in Mobile view to declutter header */
body.view-mobile #btnConsultAttending {
    display: none !important;
}

/* Relocate mute and credits buttons in Mobile view */
body.view-mobile #btnToggleSoundHeaderContainer {
    display: flex;
}
body.view-mobile #btnOpenCreditsInline {
    display: block;
}
body.view-mobile #btnOpenCredits {
    display: none !important;
}
body.view-mobile #btnToggleSound {
    display: none !important;
}

