/* CSS Reset & Variable Definitions */
:root {
    --bg-app: #090b11;
    --bg-phone: #0e121e;
    --bg-card: rgba(30, 41, 59, 0.5);
    --border-card: rgba(255, 255, 255, 0.08);
    
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.35);
    
    --accent-cyan: #06b6d4;
    --accent-purple: #8b5cf6;
    --accent-red: #ef4444;
    --accent-green: #10b981;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --font-family: 'SF Pro Display', 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    background: radial-gradient(circle at 50% 50%, #1e1b4b 0%, #030712 100%);
    font-family: var(--font-family);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Wrapper to provide subtle ambient backdrop blurs */
.app-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100vh;
}

.app-wrapper::before,
.app-wrapper::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    filter: blur(120px);
    z-index: 0;
    opacity: 0.5;
}

.app-wrapper::before {
    background: var(--primary);
    top: 15%;
    left: 25%;
}

.app-wrapper::after {
    background: var(--accent-purple);
    bottom: 15%;
    right: 25%;
}

/* iPhone Frame Layout */
.iphone-frame {
    position: relative;
    width: 390px;
    height: 844px; /* iPhone 13/14 Pro Aspect Ratio 19.5:9 */
    background-color: var(--bg-phone);
    border: 11px solid #27272a;
    border-radius: 54px;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8),
                0 0 0 4px #18181b;
    z-index: 10;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Dynamic Island/Notch */
.iphone-notch {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 115px;
    height: 30px;
    background-color: #000;
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 18px;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
}

.camera-lens {
    width: 9px;
    height: 9px;
    background-color: #111827;
    border-radius: 50%;
    border: 1px solid #1f2937;
}

.speaker-grill {
    width: 35px;
    height: 3px;
    background-color: #1f2937;
    border-radius: 2px;
}

/* Status Bar */
.iphone-status-bar {
    height: 48px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 28px 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    background-color: transparent;
    z-index: 90;
    user-select: none;
}

.status-icons {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-icons svg {
    height: 14px;
    width: 14px;
}

.status-network {
    font-size: 11px;
    font-weight: 700;
    margin-right: 2px;
}

/* Home Indicator Bar */
.iphone-home-indicator {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 130px;
    height: 5px;
    background-color: #ffffff;
    border-radius: 3px;
    z-index: 100;
    opacity: 0.8;
}

/* Screen Content Container */
.screen-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 24px; /* Space for Home Indicator */
    overflow: hidden;
}

/* Screen Base Class */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateX(30px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    z-index: 1;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
    z-index: 10;
}

/* ==========================================================================
   AUTH SCREENS
   ========================================================================== */

#screen-login {
    justify-content: center;
}

#screen-create-user {
    padding-top: 18px;
    overflow-y: auto;
    justify-content: flex-start;
}

.auth-panel {
    width: 100%;
    max-width: 310px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
}

.auth-panel-top {
    margin-top: 28px;
}

.auth-logo {
    align-self: center;
    margin-bottom: 2px;
}

.auth-title {
    text-align: center;
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: -8px;
}

.auth-form,
.account-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
}

.auth-field.compact {
    font-size: 11px;
}

.auth-field input {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.68);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 12px 13px;
    font: inherit;
    outline: none;
}

.auth-field input:focus {
    border-color: rgba(59, 130, 246, 0.8);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

.auth-field input[type="range"] {
    border: 0;
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.gender-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.gender-selector label {
    cursor: pointer;
}

.gender-selector input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.gender-selector span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.68);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 700;
}

.gender-selector input:checked + span {
    border-color: rgba(59, 130, 246, 0.82);
    background: rgba(59, 130, 246, 0.18);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

.onboarding-voice-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 8px;
    padding: 12px;
    background: rgba(15, 23, 42, 0.36);
}

.onboarding-voice-title {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 700;
}

.auth-error,
.auth-success {
    min-height: 16px;
    font-size: 12px;
    line-height: 1.35;
}

.auth-error {
    color: #fca5a5;
}

.auth-success {
    color: #86efac;
}

.auth-link-btn {
    align-self: center;
    border: 0;
    background: transparent;
    color: #93c5fd;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 10px;
}

.current-user-pill {
    align-self: center;
    min-height: 24px;
    padding: 5px 11px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.68);
    border: 1px solid rgba(148, 163, 184, 0.18);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
}

.account-card {
    margin-bottom: 8px;
}

.account-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.password-panel {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(148, 163, 184, 0.16);
}

/* ==========================================================================
   SCREEN 1: WELCOME SCREEN STYLING
   ========================================================================== */

#screen-welcome {
    justify-content: space-between;
    padding-top: 40px;
}

.welcome-header {
    text-align: center;
    margin-top: 15px;
}

.logo-container {
    position: relative;
    width: 90px;
    height: 90px;
    margin: 0 auto 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo-ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid var(--primary);
    opacity: 0.3;
}

.ring-1 {
    width: 100%;
    height: 100%;
    animation: pulse-ring 3s infinite linear;
}

.ring-2 {
    width: 80%;
    height: 80%;
    animation: pulse-ring 2.2s infinite linear reverse;
}

.logo-icon {
    width: 36px;
    height: 36px;
    color: var(--primary);
    filter: drop-shadow(0 0 10px var(--primary));
    z-index: 10;
}

.app-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 30%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 500;
    margin-top: 4px;
}

.welcome-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 24px;
    padding: 20px;
    backdrop-filter: blur(8px);
}

.welcome-card h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--primary);
}

.welcome-card p {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.guide-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.guide-item:last-child {
    margin-bottom: 0;
}

.guide-num {
    background-color: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.guide-text {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.4;
}

.welcome-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.input-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: -6px;
    padding-left: 4px;
}

.text-input {
    background: rgba(15, 23, 42, 0.6);
    border: 1.5px solid var(--border-card);
    border-radius: 16px;
    padding: 14px 18px;
    color: #fff;
    font-size: 15px;
    font-family: var(--font-family);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.text-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Button Component */
.btn {
    width: 100%;
    padding: 16px;
    border-radius: 16px;
    border: none;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
    transition: transform 0.15s, background-color 0.2s, box-shadow 0.2s;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
    color: #fff;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #1e40af 100%);
}

.btn-primary:disabled {
    background: #1e293b;
    color: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.btn-primary.is-session-loading:disabled {
    background:
        linear-gradient(135deg, rgba(59, 130, 246, 0.92) 0%, rgba(29, 78, 216, 0.96) 54%, rgba(6, 182, 212, 0.9) 100%);
    color: #fff;
    box-shadow: 0 0 0 1px rgba(147, 197, 253, 0.2),
                0 12px 30px rgba(59, 130, 246, 0.28);
    cursor: wait;
}

.btn-primary.is-session-loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(110deg,
            transparent 0%,
            transparent 30%,
            rgba(255, 255, 255, 0.24) 44%,
            rgba(255, 255, 255, 0.44) 50%,
            rgba(255, 255, 255, 0.18) 56%,
            transparent 70%,
            transparent 100%);
    transform: translateX(-120%);
    animation: session-button-sheen 2s infinite cubic-bezier(0.42, 0, 0.24, 1);
    pointer-events: none;
}

.btn-primary.is-session-loading::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    pointer-events: none;
}

.session-loading-label,
.session-loading-dots {
    position: relative;
    z-index: 1;
}

.session-loading-label {
    min-width: 154px;
}

.session-loading-dots {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.session-loading-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.45);
    animation: session-dot-orbit 2s infinite ease-in-out;
}

.session-loading-dots span:nth-child(2) {
    animation-delay: 0.18s;
}

.session-loading-dots span:nth-child(3) {
    animation-delay: 0.36s;
}

.btn-secondary {
    background: rgba(51, 65, 85, 0.4);
    border: 1px solid var(--border-card);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(51, 65, 85, 0.6);
}

/* Pulse Animation */
.pulse-effect {
    animation: btn-pulse 2s infinite;
}

/* ==========================================================================
   SCREEN 2: CHATBOT SCREEN STYLING
   ========================================================================== */

#screen-chat {
    padding-top: 30px;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-card);
    padding-bottom: 12px;
    margin-bottom: 12px;
}

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

.rec-badge {
    background-color: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 100px;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.rec-dot {
    width: 6px;
    height: 6px;
    background-color: var(--accent-red);
    border-radius: 50%;
    animation: dot-blink 1.2s infinite;
}

.rec-text {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent-red);
    letter-spacing: 0.5px;
}

.end-session-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 100px;
    color: var(--accent-red);
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font-family);
    letter-spacing: 0.4px;
    padding: 4px 8px;
    cursor: pointer;
    width: auto;
    transition: background 0.15s, border-color 0.15s;
}

.end-session-btn svg {
    width: 8px;
    height: 8px;
    flex-shrink: 0;
}

.end-session-btn:hover {
    background: rgba(239, 68, 68, 0.22);
    border-color: rgba(239, 68, 68, 0.5);
}

.end-session-btn:active {
    transform: scale(0.95);
}

.session-title {
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

.session-subtitle {
    font-size: 10px;
    color: var(--text-secondary);
    text-align: center;
    letter-spacing: 0.5px;
}

.timer {
    font-family: monospace;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 2px 6px;
}

/* Chat Messages */
.chat-area {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 4px;
    margin-bottom: 12px;
    scroll-behavior: smooth;
}

/* Custom scrollbar for Chat area */
.chat-area::-webkit-scrollbar {
    width: 4px;
}

.chat-area::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.message-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.45;
    animation: bubble-entrance 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transform-origin: left bottom;
}

.message-bubble.chatbot {
    align-self: flex-start;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--border-card);
    border-bottom-left-radius: 4px;
    color: var(--text-primary);
}

.message-bubble.patient {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    transform-origin: right bottom;
}

/* Audio Wave Visualizer */
.visualizer-container {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-card);
    border-radius: 20px;
    padding: 12px;
    margin-bottom: 12px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.visualizer-wave-box {
    height: 45px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.visualizer-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.visualizer-status {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 6px;
    letter-spacing: 0.3px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

/* Realtime Transcript Panel */
.transcript-box {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border-card);
    border-radius: 20px;
    padding: 14px;
    margin-bottom: 16px;
    backdrop-filter: blur(8px);
}

.transcript-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
}

.transcript-body-container {
    position: relative;
}

.transcript-textarea {
    width: 100%;
    height: 80px;
    background: transparent;
    border: none;
    resize: none;
    color: #fff;
    font-family: var(--font-family);
    font-size: 13.5px;
    line-height: 1.45;
    outline: none;
}

.transcript-textarea::placeholder {
    color: var(--text-muted);
}

.loading-dots {
    display: none;
    position: absolute;
    bottom: 0;
    right: 0;
    align-items: center;
    gap: 3px;
    background: var(--bg-phone);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--border-card);
}

.loading-dots.active {
    display: flex;
}

.loading-dots span {
    width: 5px;
    height: 5px;
    background-color: var(--primary);
    border-radius: 50%;
    animation: typing-dot 1.4s infinite ease-in-out;
}

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

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

.chat-controls {
    margin-top: auto;
}

.icon-arrow {
    width: 16px;
    height: 16px;
    transition: transform 0.2s;
}

.btn:hover .icon-arrow {
    transform: translateX(3px);
}

/* ==========================================================================
   SCREEN 3: FINISH SCREEN STYLING
   ========================================================================== */

#screen-finish {
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 30px;
}

.finish-icon-box {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.success-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid rgba(16, 185, 129, 0.2);
    animation: pulse-ring 2.5s infinite;
}

.success-checkmark {
    width: 40px;
    height: 40px;
    color: var(--accent-green);
    filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.4));
    animation: draw-check 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.finish-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.finish-message {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.stats-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 24px;
    padding: 20px;
    width: 100%;
    margin-bottom: 36px;
    backdrop-filter: blur(8px);
}

.stats-card h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-card);
    padding-bottom: 8px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 14px;
}

.stat-row:last-of-type {
    margin-bottom: 16px;
}

.stat-label {
    color: var(--text-secondary);
}

.stat-value {
    font-weight: 600;
    color: #fff;
}

.stat-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-card);
    padding-top: 12px;
}

.icon-secure {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ==========================================================================
   ANIMATIONS & KEYFRAMES
   ========================================================================== */

@keyframes pulse-ring {
    0% {
        transform: scale(0.95);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.3;
    }
    100% {
        transform: scale(1.25);
        opacity: 0;
    }
}

@keyframes btn-pulse {
    0% {
        box-shadow: 0 0 0 0 var(--primary-glow);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

@keyframes session-button-sheen {
    0% {
        transform: translateX(-120%);
        opacity: 0;
    }
    12% {
        opacity: 1;
    }
    58% {
        opacity: 1;
    }
    100% {
        transform: translateX(120%);
        opacity: 0;
    }
}

@keyframes session-dot-orbit {
    0%, 100% {
        transform: translateY(0) scale(0.88);
        opacity: 0.45;
    }
    35% {
        transform: translateY(-3px) scale(1.08);
        opacity: 1;
    }
    70% {
        transform: translateY(0) scale(0.92);
        opacity: 0.7;
    }
}

@keyframes dot-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes typing-dot {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

@keyframes bubble-entrance {
    0% {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes draw-check {
    0% {
        stroke-dashoffset: 80px;
        stroke-dasharray: 80px;
    }
    100% {
        stroke-dashoffset: 0;
        stroke-dasharray: 80px;
    }
}

/* ==========================================================================
   SCREEN 1: HOME SCREEN
   ========================================================================== */

#screen-home {
    justify-content: flex-start;
    padding: 28px 20px 24px;
    align-items: center;
    text-align: center;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

#screen-home::-webkit-scrollbar {
    width: 3px;
}

#screen-home::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
}

.home-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-height: min-content;
    padding-bottom: 8px;
}

.home-logo {
    position: relative;
    width: 62px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.home-logo .logo-ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid var(--primary);
    opacity: 0.3;
}

.home-logo .ring-1 {
    width: 100%;
    height: 100%;
    animation: pulse-ring 3s infinite linear;
}

.home-logo .ring-2 {
    width: 78%;
    height: 78%;
    animation: pulse-ring 2.2s infinite linear reverse;
}

.home-logo .logo-icon {
    width: 29px;
    height: 29px;
    color: var(--primary);
    filter: drop-shadow(0 0 10px var(--primary));
    z-index: 10;
}

.home-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 30%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}

.home-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 500;
    margin-bottom: 16px;
}

#screen-home .portrait-frame {
    max-width: 300px;
    margin-bottom: 16px;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
}

#screen-home .portrait-frame:active {
    transform: scale(0.985);
}

#screen-home #btn-start {
    margin-top: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    margin-top: 18px;
    margin-bottom: 0;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 20px;
    padding: 18px 12px;
    text-align: center;
    backdrop-filter: blur(8px);
}

.stat-icon-home {
    width: 20px;
    height: 20px;
    color: var(--primary);
    margin: 0 auto 8px;
    display: block;
}

.stat-number {
    font-size: 34px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 5px;
}

.stat-card-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: 1.3;
}

.home-description {
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-top: 16px;
    margin-bottom: 0;
    padding: 0 4px;
}

/* ==========================================================================
   GEAR BUTTON (home screen)
   ========================================================================== */

.gear-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    width: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
    z-index: 5;
}

.gear-btn svg {
    width: 20px;
    height: 20px;
}

.gear-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.12);
}

/* ==========================================================================
   SCREEN 4: SETTINGS SCREEN
   ========================================================================== */

#screen-settings {
    padding: 14px 18px 20px;
    justify-content: flex-start;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-card);
    flex-shrink: 0;
}

.settings-back-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--primary);
    font-size: 15px;
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    padding: 6px 0;
    width: auto;
    transition: opacity 0.2s;
}

.settings-back-btn svg {
    width: 18px;
    height: 18px;
}

.settings-back-btn:hover {
    opacity: 0.75;
}

.settings-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
}

.settings-header-spacer {
    width: 60px; /* mirrors back button width for centering */
}

/* Scrollable content area */
.settings-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-right: 2px;
}

.settings-content::-webkit-scrollbar {
    width: 3px;
}

.settings-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

/* Individual setting card */
.setting-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 20px;
    padding: 18px 16px 14px;
    backdrop-filter: blur(8px);
}

.setting-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.setting-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 14px;
}

.slider-end-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

/* Slider with colored track */
.slider-wrapper {
    position: relative;
    height: 40px;
    display: flex;
    align-items: center;
}

.slider-track-bg {
    position: absolute;
    left: 0;
    right: 0;
    height: 8px;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0.85;
}

/* Color zone gradients */
.grad-threshold {
    /* 0.30–0.50: red | 0.50–0.60: amber | 0.60–0.75: green | 0.75–0.85: amber | 0.85–0.90: red */
    background: linear-gradient(to right,
        #ef4444 0%,
        #f59e0b 33%,
        #10b981 50%,
        #10b981 68%,
        #f59e0b 82%,
        #ef4444 100%);
}

.grad-silence {
    /* 400–600ms: red | 600–800ms: amber | 800–1300ms: green | 1300–1700ms: amber | 1700–2000ms: red */
    background: linear-gradient(to right,
        #ef4444 0%,
        #f59e0b 12.5%,
        #10b981 25%,
        #10b981 56%,
        #f59e0b 75%,
        #ef4444 100%);
}

.settings-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: transparent;
    outline: none;
    cursor: pointer;
    position: relative;
    z-index: 1;
}

.settings-slider::-webkit-slider-runnable-track {
    background: transparent;
    height: 8px;
    border-radius: 4px;
}

.settings-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5), 0 0 0 2px rgba(255, 255, 255, 0.15);
    cursor: grab;
    margin-top: -11px;
    transition: transform 0.1s;
}

.settings-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.15);
}

.settings-slider::-moz-range-track {
    background: transparent;
    height: 8px;
    border-radius: 4px;
}

.settings-slider::-moz-range-thumb {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
    cursor: grab;
    border: none;
}

/* Bottom row: legend + current value */
.slider-bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.zone-legend {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 4px 8px;
}

.zone-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.zone-dot.red   { background: #ef4444; }
.zone-dot.amber { background: #f59e0b; }
.zone-dot.green { background: #10b981; }

.slider-val {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    padding: 4px 10px;
    min-width: 58px;
    text-align: center;
    flex-shrink: 0;
}

.advanced-card {
    padding-top: 0;
}

.advanced-card summary,
.drawer-advanced summary {
    cursor: pointer;
    list-style: none;
    color: var(--text-primary);
    font-weight: 600;
}

.advanced-card summary::-webkit-details-marker,
.drawer-advanced summary::-webkit-details-marker {
    display: none;
}

.advanced-card summary {
    padding-top: 16px;
    font-size: 15px;
}

.advanced-card summary::after,
.drawer-advanced summary::after {
    content: '+';
    float: right;
    color: var(--text-secondary);
    font-weight: 700;
}

.advanced-card[open] summary::after,
.drawer-advanced[open] summary::after {
    content: '-';
}

.advanced-desc {
    margin-top: 10px;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 0;
    border-top: 1px solid var(--border-card);
}

.toggle-row span {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.toggle-row strong {
    font-size: 13px;
    line-height: 1.25;
    color: var(--text-primary);
}

.toggle-row small {
    font-size: 11.5px;
    line-height: 1.35;
    color: var(--text-muted);
}

.toggle-row input[type="checkbox"] {
    flex: 0 0 auto;
    width: 44px;
    height: 26px;
    appearance: none;
    -webkit-appearance: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.12);
    position: relative;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.toggle-row input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s;
}

.toggle-row input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.toggle-row input[type="checkbox"]:checked::after {
    transform: translateX(18px);
}

/* Footer */
.settings-footer {
    flex-shrink: 0;
    padding-top: 14px;
}

.save-status {
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent-green);
    min-height: 22px;
    margin-bottom: 10px;
    opacity: 0;
    transition: opacity 0.35s;
}

.save-status.visible {
    opacity: 1;
}

/* ==========================================================================
   WORD COUNTER (chat header)
   ========================================================================== */

.header-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.header-right-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.chat-gear-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-card);
    border-radius: 8px;
    color: var(--text-secondary);
    padding: 5px 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}

.chat-gear-btn svg {
    width: 14px;
    height: 14px;
}

.chat-gear-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.12);
}

/* ── Session settings drawer ─────────────────────────────────────────── */

.session-drawer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #0e121e;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px 20px 0 0;
    padding: 14px 18px 28px;
    z-index: 20;
    box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.5);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.session-drawer.open {
    transform: translateY(0);
}

.drawer-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.drawer-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.drawer-close-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    cursor: pointer;
    width: auto;
    padding: 0;
    width: 24px;
    height: 24px;
    transition: background 0.15s, color 0.15s;
}

.drawer-close-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.15);
}

.drawer-setting {
    margin-bottom: 12px;
}

.drawer-setting-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
}

.drawer-setting-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.drawer-setting-val {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.drawer-advanced {
    margin: 4px 0 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border-card);
}

.drawer-advanced summary {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    margin-bottom: 2px;
}

.toggle-row.compact {
    padding: 9px 0;
}

.toggle-row.compact strong {
    font-size: 12px;
}

.toggle-row.compact small {
    font-size: 10.5px;
}

.drawer-status {
    text-align: center;
    font-size: 11px;
    font-weight: 500;
    color: var(--accent-green);
    min-height: 16px;
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.3s;
}

.drawer-status.visible {
    opacity: 1;
}

.word-counter {
    font-size: 10px;
    font-weight: 600;
    color: var(--accent-cyan);
    background: rgba(6, 182, 212, 0.1);
    border-radius: 6px;
    padding: 2px 6px;
    letter-spacing: 0.2px;
}

/* ==========================================================================
   TAPPABLE STAT CARDS (home screen)
   ========================================================================== */

.stat-card-tappable {
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.stat-card-tappable:hover {
    border-color: rgba(59, 130, 246, 0.35);
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.15);
}

.stat-card-tappable:active {
    transform: scale(0.96);
}

.stat-card-hint {
    font-size: 9.5px;
    color: var(--text-muted);
    margin-top: 4px;
    letter-spacing: 0.3px;
}

/* ==========================================================================
   SCREEN 7: IMAGE EXPLORER
   ========================================================================== */

#screen-image-explorer {
    padding: 14px 18px 20px;
    justify-content: flex-start;
}

.image-explorer-header {
    flex-shrink: 0;
}

.image-explorer-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-right: 2px;
}

.image-explorer-content::-webkit-scrollbar {
    width: 3px;
}

.image-explorer-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
}

.image-viewer {
    width: 100%;
    height: calc(100vh - 210px);
    min-height: 500px;
    max-height: 650px;
    border-radius: 22px;
    overflow: hidden;
    background: #05070d;
    border: 1px solid var(--border-card);
    box-shadow: 0 12px 42px rgba(0, 0, 0, 0.45);
    position: relative;
    cursor: grab;
    touch-action: none;
}

.image-viewer.dragging {
    cursor: grabbing;
}

.image-viewer-img {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: auto;
    max-width: none;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    transform: translate(-50%, -50%) translate(0px, 0px) scale(1.65);
    transition: transform 0.12s ease-out;
    transform-origin: center center;
}

.image-viewer.dragging .image-viewer-img {
    transition: none;
}

.image-viewer-hint {
    color: var(--text-muted);
    font-size: 11px;
    text-align: center;
    margin: 10px 0 20px;
}

.image-gallery-section {
    padding-bottom: 16px;
}

.image-gallery-title {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 12px;
}

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

.gallery-thumb {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 14px;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    color: var(--text-primary);
    font-family: var(--font-family);
    text-align: left;
    transition: transform 0.15s, border-color 0.15s;
}

.gallery-thumb:active {
    transform: scale(0.98);
}

.gallery-thumb:hover {
    border-color: rgba(59, 130, 246, 0.55);
}

.gallery-thumb img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
}

.gallery-thumb span {
    display: block;
    padding: 8px 9px 9px;
    font-size: 12px;
    color: var(--text-secondary);
}

.gallery-empty {
    grid-column: 1 / -1;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 18px 0;
}

.print-order-section {
    padding: 4px 0 22px;
}

.order-print-btn {
    width: 100%;
    border: 1px solid rgba(59, 130, 246, 0.36);
    border-radius: 14px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.22), rgba(6, 182, 212, 0.12));
    color: rgba(248, 250, 252, 0.72);
    font-family: var(--font-family);
    font-size: 15px;
    font-weight: 650;
    letter-spacing: 0;
    cursor: not-allowed;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.print-order-note {
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 12.5px;
    line-height: 1.45;
    text-align: center;
}

/* ==========================================================================
   SCREEN 5: BIOGRAPHY (VINTAGE BOOK)
   ========================================================================== */

#screen-biography {
    padding: 14px 18px 20px;
    justify-content: flex-start;
}

.bio-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding-right: 2px;
}

.bio-scroll-area::-webkit-scrollbar {
    width: 3px;
}

.bio-scroll-area::-webkit-scrollbar-thumb {
    background: rgba(180, 140, 80, 0.3);
    border-radius: 2px;
}

.bio-book-page {
    background: #f5edd8;
    border-radius: 10px;
    box-shadow:
        0 6px 24px rgba(0, 0, 0, 0.5),
        inset 0 0 0 1px rgba(160, 120, 60, 0.25),
        inset 4px 0 12px -4px rgba(0, 0, 0, 0.12);
    position: relative;
    overflow: hidden;
}

/* Subtle aged-paper gradient */
.bio-book-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 0% 0%, rgba(210, 180, 120, 0.18) 0%, transparent 60%),
        radial-gradient(ellipse at 100% 100%, rgba(180, 140, 80, 0.12) 0%, transparent 55%);
    pointer-events: none;
}

/* Left binding shadow */
.bio-book-page::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 18px;
    background: linear-gradient(to right, rgba(0,0,0,0.08), transparent);
    pointer-events: none;
}

.bio-book-inner {
    padding: 22px 20px 20px 24px;
    position: relative;
    z-index: 1;
}

.bio-ornament {
    text-align: center;
    font-size: 22px;
    color: #8b6b1a;
    opacity: 0.75;
    line-height: 1;
    margin-bottom: 8px;
}

.bio-chapter-title {
    font-family: 'EB Garamond', Georgia, 'Times New Roman', serif;
    font-size: 17px;
    font-weight: 500;
    font-style: italic;
    text-align: center;
    color: #3a2e1a;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.bio-divider {
    text-align: center;
    font-size: 11px;
    color: #8b6b1a;
    opacity: 0.65;
    letter-spacing: 4px;
    margin-bottom: 16px;
}

.bio-paragraphs {
    font-family: 'EB Garamond', Georgia, 'Times New Roman', serif;
    font-size: 15.5px;
    line-height: 1.75;
    color: #2e2418;
}

.bio-paragraph {
    margin-bottom: 1.2em;
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
}

/* Drop cap on the very first paragraph */
.bio-paragraph:first-child::first-letter {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 3.4em;
    font-weight: 500;
    float: left;
    line-height: 0.78;
    margin: 4px 5px -2px 0;
    color: #7a5a10;
}

.bio-paragraph:last-child {
    margin-bottom: 0;
}

.book-order-section {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid rgba(139, 107, 26, 0.18);
}

.order-book-btn {
    width: 100%;
    border: 1px solid rgba(122, 90, 16, 0.32);
    border-radius: 9px;
    padding: 12px 14px;
    background: linear-gradient(180deg, rgba(255, 248, 225, 0.74), rgba(214, 183, 121, 0.28));
    color: rgba(58, 46, 26, 0.72);
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 16px;
    font-weight: 600;
    cursor: not-allowed;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.book-order-note {
    margin-top: 10px;
    color: rgba(58, 46, 26, 0.62);
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 14px;
    font-style: italic;
    line-height: 1.42;
    text-align: center;
}

.bio-page-foot {
    text-align: center;
    font-size: 11px;
    color: #8b6b1a;
    opacity: 0.55;
    letter-spacing: 4px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(139, 107, 26, 0.2);
}

.bio-loading,
.bio-empty {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 15px;
    font-style: italic;
    color: #8b6b1a;
    text-align: center;
    padding: 20px 0;
    opacity: 0.7;
}

/* ==========================================================================
   SCREEN 6: SESSIONS LIST
   ========================================================================== */

#screen-sessions {
    padding: 14px 18px 20px;
    justify-content: flex-start;
}

.sessions-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 2px;
}

.sessions-list::-webkit-scrollbar {
    width: 3px;
}

.sessions-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.sessions-loading,
.sessions-empty {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    padding: 20px 0;
}

.session-item {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 18px;
    padding: 14px 16px;
    backdrop-filter: blur(8px);
    flex-shrink: 0;
}

.session-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-card);
}

.session-item-date {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
}

.session-item-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.session-audio-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 100px;
    padding: 3px 8px;
    font-size: 9.5px;
    font-weight: 600;
    color: var(--accent-green);
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.session-audio-badge svg {
    width: 10px;
    height: 10px;
}

.session-item-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.session-stat {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.session-stat-label {
    font-size: 9.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.session-stat-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
}

/* ==========================================================================
   PERSONALITY CUSTOMIZATION (settings card)
   ========================================================================== */

.personality-additions-box {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 12px;
    min-height: 52px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-secondary);
    word-break: break-word;
}

.personality-empty {
    color: var(--text-muted);
    font-style: italic;
    font-size: 13px;
}

.personality-addition-line {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 4px;
}

.personality-addition-line:last-child {
    margin-bottom: 0;
}

.personality-addition-bullet {
    color: var(--primary);
    flex-shrink: 0;
    margin-top: 2px;
}

.personality-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.personality-record-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 100px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-family);
    padding: 7px 14px;
    cursor: pointer;
    width: auto;
    transition: background 0.15s, border-color 0.15s;
}

.personality-record-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
}

.personality-clear-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 11.5px;
    font-family: var(--font-family);
    cursor: pointer;
    padding: 4px 0;
    width: auto;
    transition: color 0.15s;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.personality-clear-btn:hover {
    color: var(--accent-red);
}

.personality-recording-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 12px;
    padding: 10px 12px;
}

.personality-rec-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-red);
    border-radius: 50%;
    animation: dot-blink 1.2s infinite;
    flex-shrink: 0;
}

.personality-rec-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-red);
    flex: 1;
}

.personality-stop-btn {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 100px;
    color: var(--accent-red);
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-family);
    padding: 4px 12px;
    cursor: pointer;
    width: auto;
    transition: background 0.15s;
}

.personality-stop-btn:hover {
    background: rgba(239, 68, 68, 0.25);
}

.personality-preview {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    padding: 12px;
    margin-top: 2px;
}

.personality-preview-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 6px;
}

.personality-preview-text {
    font-size: 13.5px;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 12px;
    font-style: italic;
}

.personality-preview-actions {
    display: flex;
    gap: 8px;
}

.personality-add-btn {
    flex: 1;
    background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-family);
    padding: 8px 0;
    cursor: pointer;
    transition: opacity 0.15s;
}

.personality-add-btn:hover {
    opacity: 0.85;
}

.personality-discard-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-card);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font-family);
    padding: 8px 0;
    cursor: pointer;
    transition: background 0.15s;
}

.personality-discard-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.personality-transcribing {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 0;
}

.personality-transcribing-text {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

.personality-status {
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-green);
    min-height: 18px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.3s;
    text-align: center;
}

.personality-status.visible {
    opacity: 1;
}

.hidden {
    display: none !important;
}

/* ─── Biography portrait ─────────────────────────────────────────────────── */

.portrait-frame {
    display: none;
    position: relative;
    width: 100%;
    max-width: 320px;
    margin: 0 auto 20px;
    aspect-ratio: 1 / 1;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--border-card);
    background: var(--bg-card);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

.portrait-frame.has-image {
    display: block;
}

.portrait-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: filter 0.6s ease, opacity 0.6s ease;
}

/* While rendering, gently breathe + soft-focus until the next frame lands. */
.portrait-frame.rendering .portrait-img {
    filter: saturate(0.92) brightness(0.97);
    animation: portrait-breathe 2.4s ease-in-out infinite;
}

@keyframes portrait-breathe {
    0%, 100% { opacity: 0.88; }
    50%      { opacity: 1; }
}

/* Sheen sweep across the frame while a new image is being painted. */
.portrait-frame.rendering::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        110deg,
        transparent 30%,
        rgba(255, 255, 255, 0.10) 50%,
        transparent 70%
    );
    background-size: 220% 100%;
    animation: portrait-sheen 1.8s linear infinite;
    pointer-events: none;
}

@keyframes portrait-sheen {
    0%   { background-position: 200% 0; }
    100% { background-position: -120% 0; }
}

.portrait-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 18px 14px 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    text-align: center;
    background: linear-gradient(to top, rgba(9, 11, 17, 0.75), transparent);
}
