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

        :root {
            --primary: #4E93EE;
            --primary-dark: #3A7ED8;
            --primary-light: #EBF3FE;
            --color-orange: #FF9D47;
            --color-green: #52C87F;
            --color-pink: #F56098;
            --color-gray: #6B7280;
            --bg: #f1f5f9;
            --surface: #ffffff;
            --text: #1e293b;
            --text-muted: #64748b;
            --text-light: #94a3b8;
            --border: #e2e8f0;
            --border-light: #f1f5f9;
            --warning-bg: #fffbeb;
            --warning-border: #f59e0b;
            --warning-text: #92400e;
            --user-bubble: #4E93EE;
            --user-text: #ffffff;
            --assistant-bubble: #ffffff;
            --sidebar-w: 320px;
            --header-h: 56px;
            --input-h: 80px;
            --radius: 12px;
            --radius-sm: 8px;
        }

        body {
            font-family: 'Poppins', sans-serif;
            background: var(--bg);
            color: var(--text);
        }

        /* Lock viewport scroll only when the app shell is present */
        body:has(.app-layout) {
            height: 100vh;
            overflow: hidden;
        }

        /* ── Layout ── */
        .app-layout {
            display: flex;
            height: 100vh;
        }

        /* ── Sidebar ── */
        .sidebar {
            width: var(--sidebar-w);
            background: var(--surface);
            border-right: 1px solid var(--border);
            display: flex;
            flex-direction: column;
            flex-shrink: 0;
            overflow-y: auto;
        }

        .sidebar-header {
            padding: 1rem 1.25rem;
            border-bottom: 1px solid var(--border);
        }

        .sidebar-header h1 {
            font-size: 1.2rem;
            font-weight: 700;
            color: var(--primary);
        }

        .sidebar-logo {
            height: 28px;
            width: auto;
            display: block;
        }

        .sidebar-header .subtitle {
            font-size: 0.78rem;
            color: var(--text-muted);
            margin-top: 0.15rem;
        }

        .sidebar-section {
            padding: 1.25rem;
            border-bottom: 1px solid var(--border);
        }

        .sidebar-section h3 {
            font-size: 0.72rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.06em;
            color: var(--text-muted);
            margin-bottom: 0.75rem;
        }

        /* Role selector */
        .role-selector {
            display: flex;
            gap: 0.4rem;
            flex-wrap: wrap;
        }

        .role-selector label { cursor: pointer; }
        .role-selector input[type="radio"] { display: none; }

        .role-selector .chip {
            display: inline-block;
            padding: 0.35rem 0.75rem;
            border: 1.5px solid var(--border);
            border-radius: 999px;
            font-size: 0.78rem;
            font-weight: 500;
            color: var(--text-muted);
            transition: all 0.15s;
            user-select: none;
        }

        .role-selector input:checked + .chip {
            border-color: var(--primary);
            background: var(--primary-light);
            color: var(--primary);
        }

        /* Child profile form */
        .profile-form { display: flex; flex-direction: column; gap: 0.6rem; }

        .profile-form label {
            font-size: 0.8rem;
            font-weight: 500;
            color: var(--text);
        }

        .profile-form input,
        .profile-form select,
        .profile-form textarea {
            width: 100%;
            padding: 0.45rem 0.65rem;
            border: 1.5px solid var(--border);
            border-radius: var(--radius-sm);
            font-size: 0.85rem;
            font-family: inherit;
            outline: none;
            transition: border-color 0.15s;
            background: var(--surface);
        }

        .profile-form input:focus,
        .profile-form select:focus,
        .profile-form textarea:focus {
            border-color: var(--primary);
        }

        .profile-form input::placeholder,
        .profile-form textarea::placeholder { color: var(--text-light); }

        .profile-form textarea {
            resize: vertical;
            min-height: 38px;
            max-height: 100px;
            line-height: 1.4;
        }

        /* Checkbox group for communication modalities */
        .checkbox-group {
            display: flex;
            flex-wrap: wrap;
            gap: 0.3rem 0.6rem;
        }

        .checkbox-group label {
            display: flex;
            align-items: center;
            gap: 0.3rem;
            font-size: 0.78rem;
            font-weight: 400;
            color: var(--text);
            cursor: pointer;
        }

        .checkbox-group input[type="checkbox"] {
            width: auto;
            margin: 0;
            cursor: pointer;
        }

        /* Collapsible profile header */
        .profile-collapse-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            cursor: pointer;
            padding: 0.35rem 0;
            margin-bottom: 0.5rem;
            user-select: none;
        }

        .profile-collapse-header:hover { opacity: 0.8; }

        .profile-summary-line {
            font-size: 0.82rem;
            font-weight: 500;
            color: var(--text);
        }

        .profile-summary-line.empty {
            color: var(--text-light);
            font-weight: 400;
        }

        .collapse-arrow {
            font-size: 0.65rem;
            color: var(--text-muted);
            transition: transform 0.2s;
        }

        .collapse-arrow.open { transform: rotate(180deg); }

        .profile-form-body {
            display: none;
        }

        .profile-form-body.open {
            display: flex;
            flex-direction: column;
            gap: 0.6rem;
        }

        /* Profile completeness indicator */
        .profile-completeness {
            font-size: 0.73rem;
            color: var(--text-muted);
            margin-top: 0.15rem;
        }

        /* Save toast */
        .save-toast {
            font-size: 0.78rem;
            font-weight: 500;
            color: var(--color-green);
            opacity: 0;
            transition: opacity 0.3s;
            margin-top: 0.25rem;
        }

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

        /* Profile switcher (dropdown + delete) */
        .profile-switcher {
            display: flex;
            gap: 0.4rem;
            margin-bottom: 0.75rem;
        }

        .profile-switcher select {
            flex: 1;
            padding: 0.45rem 0.65rem;
            border: 1.5px solid var(--border);
            border-radius: var(--radius-sm);
            font-size: 0.82rem;
            font-family: inherit;
            outline: none;
            background: var(--surface);
            transition: border-color 0.15s;
            min-width: 0;
        }

        .profile-switcher select:focus { border-color: var(--primary); }

        .btn-icon {
            width: 34px;
            height: 34px;
            border: 1.5px solid var(--border);
            border-radius: var(--radius-sm);
            background: var(--surface);
            color: var(--text-light);
            font-size: 1.1rem;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            transition: all 0.15s;
        }

        .btn-icon:hover { border-color: #ef4444; color: #ef4444; }

        .profile-actions {
            display: flex;
            gap: 0.5rem;
            margin-top: 0.25rem;
        }

        .btn-sm {
            padding: 0.4rem 0.85rem;
            border: 1.5px solid var(--border);
            border-radius: var(--radius-sm);
            font-size: 0.78rem;
            font-weight: 500;
            cursor: pointer;
            background: var(--surface);
            color: var(--text-muted);
            transition: all 0.15s;
        }

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

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

        .profile-status {
            font-size: 0.75rem;
            color: var(--text-light);
            margin-top: 0.25rem;
        }

        .profile-status.set { color: var(--color-green); font-weight: 500; }

        .new-chat-btn {
            margin: 1.25rem;
            padding: 0.55rem 1rem;
            background: var(--bg);
            border: 1.5px solid var(--border);
            border-radius: var(--radius-sm);
            font-size: 0.85rem;
            font-weight: 500;
            cursor: pointer;
            color: var(--text-muted);
            transition: all 0.15s;
            text-align: center;
        }

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

        /* Sidebar footer */
        .sidebar-footer {
            margin-top: auto;
            padding: 1rem 1.25rem;
            font-size: 0.72rem;
            color: var(--text-light);
            text-align: center;
            line-height: 1.5;
        }

        /* Patent notice */
        .patent-notice {
            position: fixed;
            bottom: 6px;
            right: 12px;
            font-size: 0.6rem;
            color: var(--color-gray);
            opacity: 0.45;
            pointer-events: none;
            z-index: 1;
        }

        /* ── Chat area ── */
        .chat-area {
            flex: 1;
            display: flex;
            flex-direction: column;
            min-width: 0;
        }

        /* Chat header (mobile) */
        .chat-header {
            display: none;
            height: var(--header-h);
            background: var(--surface);
            border-bottom: 1px solid var(--border);
            padding: 0 1rem;
            align-items: center;
            gap: 0.75rem;
            flex-shrink: 0;
        }

        .chat-header h1 {
            font-size: 1.1rem;
            font-weight: 700;
            color: var(--primary);
        }

        .menu-btn {
            width: 36px;
            height: 36px;
            border: 1.5px solid var(--border);
            border-radius: var(--radius-sm);
            background: var(--surface);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-muted);
            font-size: 1.1rem;
            flex-shrink: 0;
        }

        /* Messages area */
        .messages {
            flex: 1;
            overflow-y: auto;
            padding: 1.5rem;
            display: flex;
            flex-direction: column;
            gap: 1rem;
        }

        .welcome-message {
            text-align: center;
            padding: 2rem 1.5rem;
            color: var(--text-muted);
            max-width: 560px;
            margin: auto;
        }

        .welcome-header h2 {
            font-size: 1.3rem;
            font-weight: 600;
            color: var(--text);
            margin-bottom: 0.4rem;
        }

        .welcome-header p {
            font-size: 0.88rem;
            line-height: 1.6;
            margin-bottom: 1.25rem;
        }

        /* Primary CTA — State 1 */
        .welcome-cta-btn {
            display: inline-block;
            background: var(--primary);
            color: #fff;
            border: none;
            border-radius: var(--radius-sm);
            padding: 0.75rem 1.75rem;
            font-size: 0.95rem;
            font-weight: 600;
            cursor: pointer;
            transition: background 0.15s;
            margin-bottom: 1.25rem;
        }

        .welcome-cta-btn:hover {
            background: var(--primary-dark);
        }

        /* Cards row — side by side on desktop, stacked on mobile */
        .welcome-cards-row {
            display: flex;
            gap: 0.75rem;
            justify-content: center;
        }

        .welcome-card {
            background: var(--surface);
            border: 1.5px solid var(--border);
            border-radius: var(--radius);
            padding: 1rem 1.1rem;
            flex: 1;
            max-width: 260px;
            cursor: pointer;
            transition: border-color 0.15s, box-shadow 0.15s;
            text-align: left;
        }

        .welcome-card:hover {
            border-color: var(--primary);
            box-shadow: 0 2px 8px rgba(78, 147, 238, 0.12);
        }

        .welcome-card-title {
            font-size: 0.85rem;
            font-weight: 600;
            color: var(--text);
            margin-bottom: 0.3rem;
        }

        .welcome-card-desc {
            font-size: 0.8rem;
            color: var(--text-muted);
            line-height: 1.4;
        }

        .welcome-card-body {
            font-size: 0.8rem;
            color: var(--text-muted);
            line-height: 1.5;
        }

        /* Insight card accent */
        .welcome-card.insight {
            border-left: 3px solid var(--color-orange);
            cursor: default;
        }

        .welcome-card.insight:hover {
            border-color: var(--border);
            border-left-color: var(--color-orange);
            box-shadow: none;
        }

        .welcome-card.insight .welcome-card-title::before {
            content: "\1F4A1";
            margin-right: 0.35rem;
        }

        /* Profile snapshot card — State 2 */
        .profile-snapshot-card {
            background: var(--surface);
            border: 1.5px solid var(--border);
            border-radius: var(--radius);
            padding: 1rem 1.25rem;
            margin-bottom: 0.75rem;
            text-align: left;
        }

        .snapshot-header {
            font-size: 0.95rem;
            font-weight: 600;
            color: var(--text);
            margin-bottom: 0.75rem;
        }

        .snapshot-stats {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 0.5rem;
            text-align: center;
        }

        .snapshot-stat-value {
            display: block;
            font-size: 1.1rem;
            font-weight: 700;
            color: var(--primary);
        }

        .snapshot-stat-label {
            display: block;
            font-size: 0.7rem;
            color: var(--text-muted);
            margin-top: 0.15rem;
        }

        /* Contextual nudge */
        .contextual-nudge {
            font-size: 0.88rem;
            color: var(--text-muted);
            margin: 0.75rem 0;
            font-style: italic;
        }

        /* Returning user insight card — standalone */
        #welcome-state-returning > .welcome-card.insight {
            max-width: 100%;
            margin-bottom: 0.75rem;
        }

        /* Quick-action buttons row */
        .quick-actions-row {
            display: flex;
            gap: 0.5rem;
            justify-content: center;
            margin-top: 0.5rem;
        }

        .quick-action-btn {
            background: transparent;
            border: 1.5px solid var(--primary);
            border-radius: var(--radius-sm);
            padding: 0.5rem 1rem;
            font-size: 0.82rem;
            font-weight: 500;
            color: var(--primary);
            cursor: pointer;
            transition: all 0.15s;
        }

        .quick-action-btn:hover {
            background: var(--primary);
            color: #fff;
        }

        /* Mobile responsive */
        @media (max-width: 600px) {
            .welcome-cards-row {
                flex-direction: column;
                align-items: center;
            }
            .welcome-card {
                max-width: 100%;
            }
            .snapshot-stats {
                grid-template-columns: repeat(2, 1fr);
            }
            .quick-actions-row {
                flex-direction: column;
                align-items: center;
            }
            .quick-action-btn {
                width: 100%;
                max-width: 280px;
            }
        }

        /* Message bubbles */
        .msg-row {
            display: flex;
            gap: 0.5rem;
            max-width: 85%;
        }

        .msg-row.user {
            align-self: flex-end;
            flex-direction: row-reverse;
        }

        .msg-row.assistant { align-self: flex-start; }

        .msg-bubble {
            padding: 0.75rem 1rem;
            border-radius: var(--radius);
            line-height: 1.65;
            font-size: 0.92rem;
            word-wrap: break-word;
            overflow-wrap: break-word;
        }

        .msg-row.user .msg-bubble {
            background: var(--user-bubble);
            color: var(--user-text);
            border-bottom-right-radius: 4px;
        }

        .msg-row.assistant .msg-bubble {
            background: var(--assistant-bubble);
            border: 1px solid var(--border);
            border-bottom-left-radius: 4px;
        }

        /* Markdown inside assistant bubbles */
        .msg-bubble h1, .msg-bubble h2, .msg-bubble h3 {
            margin-top: 0.85rem;
            margin-bottom: 0.35rem;
            font-size: 1rem;
        }
        .msg-bubble h1 { font-size: 1.1rem; }
        .msg-bubble ul, .msg-bubble ol { padding-left: 1.25rem; margin: 0.4rem 0; }
        .msg-bubble li { margin-bottom: 0.2rem; }
        .msg-bubble p { margin-bottom: 0.5rem; }
        .msg-bubble p:last-child { margin-bottom: 0; }
        .msg-bubble strong { color: inherit; }
        .msg-bubble code {
            background: rgba(0,0,0,0.06);
            padding: 0.15rem 0.35rem;
            border-radius: 4px;
            font-size: 0.85em;
        }

        /* Role badge on assistant messages */
        .msg-meta {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            margin-bottom: 0.35rem;
        }

        .role-badge {
            display: inline-block;
            padding: 0.15rem 0.55rem;
            border-radius: 999px;
            font-size: 0.68rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.04em;
        }

        .role-parent  { background: #FFF0E0; color: #C06800; }
        .role-rbt     { background: #E8F4FD; color: #3578CC; }
        .role-bcba    { background: #E5F7ED; color: #2E8B57; }
        .role-support { background: #F3F4F6; color: #6B7280; }

        /* Safety warning */
        .safety-warning {
            background: var(--warning-bg);
            border-left: 4px solid var(--warning-border);
            color: var(--warning-text);
            padding: 0.6rem 0.85rem;
            border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
            font-size: 0.82rem;
            font-weight: 500;
            margin-bottom: 0.5rem;
        }

        /* Sources collapsible */
        .sources-toggle {
            display: inline-flex;
            align-items: center;
            gap: 0.3rem;
            margin-top: 0.65rem;
            padding: 0.3rem 0.65rem;
            border: 1px solid var(--border);
            border-radius: 999px;
            font-size: 0.72rem;
            color: var(--text-muted);
            cursor: pointer;
            background: var(--bg);
            transition: all 0.15s;
        }

        .sources-toggle:hover { border-color: var(--primary); color: var(--primary); }

        .sources-toggle .arrow {
            transition: transform 0.2s;
            font-size: 0.65rem;
        }

        .sources-toggle.open .arrow { transform: rotate(180deg); }

        .sources-list {
            display: none;
            margin-top: 0.5rem;
            padding: 0.5rem 0.75rem;
            background: var(--bg);
            border-radius: var(--radius-sm);
            font-size: 0.78rem;
            color: var(--text-muted);
            line-height: 1.6;
        }

        .sources-list.open { display: block; }

        .sources-list li {
            list-style: none;
            padding: 0.2rem 0;
            padding-left: 0.85rem;
            position: relative;
        }

        .sources-list li::before {
            content: "\2022";
            position: absolute;
            left: 0;
            color: var(--primary);
        }

        /* Follow-up card */
        .followup-card {
            display: none;
            background: #EDFAF2;
            border: 1px solid #A8E5BF;
            border-radius: var(--radius);
            padding: 1rem 1.25rem;
            margin: 0 1.5rem 0.5rem 1.5rem;
            position: relative;
            flex-shrink: 0;
        }

        .followup-card.visible { display: block; }

        .followup-card .followup-text {
            font-size: 0.88rem;
            color: var(--text);
            line-height: 1.55;
            margin-bottom: 0.75rem;
            padding-right: 1.5rem;
        }

        .followup-card .followup-dismiss {
            position: absolute;
            top: 0.6rem;
            right: 0.75rem;
            background: none;
            border: none;
            font-size: 1.1rem;
            color: var(--text-light);
            cursor: pointer;
            padding: 0.15rem 0.35rem;
            line-height: 1;
            border-radius: 4px;
        }

        .followup-card .followup-dismiss:hover { color: var(--text-muted); background: rgba(0,0,0,0.04); }

        .followup-buttons {
            display: flex;
            flex-wrap: wrap;
            gap: 0.4rem;
        }

        .followup-btn {
            padding: 0.4rem 0.85rem;
            border: 1.5px solid #A8E5BF;
            border-radius: 999px;
            font-size: 0.78rem;
            font-weight: 500;
            cursor: pointer;
            background: #ffffff;
            color: #1B7A3D;
            transition: all 0.15s;
        }

        .followup-btn:hover {
            border-color: var(--color-green);
            background: #D4F3E0;
        }

        /* Follow-up notes input (shown after outcome click) */
        .followup-notes {
            display: none;
            margin-top: 0.75rem;
        }

        .followup-notes.visible { display: block; }

        .followup-notes textarea {
            width: 100%;
            padding: 0.5rem 0.7rem;
            border: 1.5px solid #A8E5BF;
            border-radius: var(--radius-sm);
            font-size: 0.85rem;
            font-family: inherit;
            resize: vertical;
            min-height: 40px;
            max-height: 100px;
            outline: none;
            margin-bottom: 0.5rem;
        }

        .followup-notes textarea:focus { border-color: var(--color-green); }

        .followup-notes-actions {
            display: flex;
            gap: 0.4rem;
        }

        .followup-notes-btn {
            padding: 0.35rem 0.75rem;
            border: 1.5px solid #A8E5BF;
            border-radius: var(--radius-sm);
            font-size: 0.76rem;
            font-weight: 500;
            cursor: pointer;
            background: #ffffff;
            color: #1B7A3D;
            transition: all 0.15s;
        }

        .followup-notes-btn:hover { border-color: var(--color-green); background: #D4F3E0; }

        .followup-notes-btn.primary {
            background: var(--color-green);
            color: #ffffff;
            border-color: var(--color-green);
        }

        .followup-notes-btn.primary:hover { background: #3DB56A; }

        /* Typing indicator */
        .typing-indicator {
            display: flex;
            gap: 0.3rem;
            padding: 0.75rem 1rem;
            align-items: center;
        }

        .typing-dot {
            width: 7px;
            height: 7px;
            background: var(--text-light);
            border-radius: 50%;
            animation: typing 1.2s infinite;
        }

        .typing-dot:nth-child(2) { animation-delay: 0.2s; }
        .typing-dot:nth-child(3) { animation-delay: 0.4s; }

        @keyframes typing {
            0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
            30% { opacity: 1; transform: scale(1); }
        }

        /* ── Input area ── */
        .input-area {
            background: var(--surface);
            border-top: 1px solid var(--border);
            padding: 0.75rem 1.5rem;
            flex-shrink: 0;
        }

        .input-row {
            display: flex;
            gap: 0.5rem;
            align-items: flex-end;
            max-width: 780px;
            margin: 0 auto;
        }

        .input-row textarea {
            flex: 1;
            padding: 0.65rem 0.85rem;
            border: 1.5px solid var(--border);
            border-radius: var(--radius);
            font-size: 0.92rem;
            font-family: inherit;
            resize: none;
            outline: none;
            transition: border-color 0.15s;
            min-height: 44px;
            max-height: 150px;
            line-height: 1.5;
        }

        .input-row textarea:focus { border-color: var(--primary); }

        .input-row textarea::placeholder { color: var(--text-light); }

        .send-btn {
            width: 44px;
            height: 44px;
            border: none;
            border-radius: var(--radius);
            background: var(--primary);
            color: #fff;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.15s;
            flex-shrink: 0;
        }

        .send-btn:hover { background: var(--primary-dark); }
        .send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

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

        .input-hint {
            text-align: center;
            font-size: 0.7rem;
            color: var(--text-light);
            margin-top: 0.4rem;
        }

        /* ── Mobile overlay ── */
        .sidebar-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.3);
            z-index: 90;
        }

        .sidebar-overlay.visible { display: block; }

        /* ── Onboarding overlay ── */
        /* ── Login screen ── */
        .login-overlay {
            position: fixed;
            inset: 0;
            z-index: 300;
            background: var(--bg);
            display: flex;
            align-items: center;
            justify-content: center;
            flex-direction: column;
        }
        .login-overlay.hidden { display: none; }

        .login-inner {
            text-align: center;
            max-width: 400px;
            padding: 2rem 1.5rem;
        }
        .login-inner h1 {
            font-size: 1.8rem;
            font-weight: 700;
            color: var(--primary);
            margin-bottom: 0.35rem;
        }

        .login-logo {
            max-width: 260px;
            width: 100%;
            height: auto;
            margin-bottom: 0.5rem;
        }
        .login-inner .tagline {
            font-size: 1rem;
            color: var(--text-muted);
            margin-bottom: 2.5rem;
        }
        .login-form {
            display: flex;
            flex-direction: column;
            gap: 0.75rem;
            text-align: left;
        }
        .login-form label {
            font-size: 0.9rem;
            font-weight: 600;
            color: var(--text);
        }
        .login-form input[type="email"] {
            width: 100%;
            padding: 0.7rem 0.9rem;
            border: 1.5px solid var(--border);
            border-radius: var(--radius-sm);
            font-size: 1rem;
            outline: none;
            transition: border-color 0.15s;
        }
        .login-form input[type="email"]:focus {
            border-color: var(--primary);
        }
        .login-btn {
            padding: 0.7rem;
            background: var(--primary);
            color: white;
            border: none;
            border-radius: var(--radius-sm);
            font-size: 1rem;
            font-weight: 600;
            cursor: pointer;
            transition: background 0.15s;
        }
        .login-btn:hover { background: var(--primary-dark); }
        .login-btn:disabled { opacity: 0.6; cursor: not-allowed; }
        .login-status {
            font-size: 0.85rem;
            color: var(--text-muted);
            min-height: 1.2rem;
        }
        .login-status.error { color: #dc2626; }
        .login-status.success { color: var(--color-green); }
        .login-footer {
            margin-top: 1.5rem;
            font-size: 0.82rem;
            color: var(--text-light);
        }

        .onboarding-overlay {
            position: fixed;
            inset: 0;
            z-index: 200;
            background: var(--bg);
            display: flex;
            align-items: center;
            justify-content: center;
            flex-direction: column;
        }

        .onboarding-overlay.hidden { display: none; }

        .onboarding-inner {
            text-align: center;
            max-width: 720px;
            padding: 2rem 1.5rem;
        }

        .onboarding-inner h1 {
            font-size: 1.8rem;
            font-weight: 700;
            color: var(--primary);
            margin-bottom: 0.35rem;
        }

        .onboarding-inner .tagline {
            font-size: 1rem;
            color: var(--text-muted);
            margin-bottom: 2.5rem;
        }

        .onboarding-inner h2 {
            font-size: 1rem;
            font-weight: 600;
            color: var(--text);
            margin-bottom: 1.25rem;
        }

        .role-cards {
            display: flex;
            gap: 1rem;
            justify-content: center;
            flex-wrap: wrap;
        }

        .role-card {
            background: var(--surface);
            border: 2px solid var(--border);
            border-radius: var(--radius);
            padding: 1.75rem 1.25rem;
            width: 200px;
            cursor: pointer;
            transition: all 0.2s;
            text-align: center;
        }

        .role-card:hover {
            border-color: var(--primary);
            box-shadow: 0 4px 16px rgba(78, 147, 238, 0.12);
            transform: translateY(-2px);
        }

        .role-card .role-icon {
            font-size: 2rem;
            margin-bottom: 0.75rem;
        }

        .role-card .role-title {
            font-size: 0.95rem;
            font-weight: 600;
            color: var(--text);
            margin-bottom: 0.4rem;
        }

        .role-card .role-desc {
            font-size: 0.78rem;
            color: var(--text-muted);
            line-height: 1.5;
        }

        .onboarding-footer {
            margin-top: 2.5rem;
            font-size: 0.72rem;
            color: var(--text-light);
            line-height: 1.5;
        }

        /* ── Calibration screen ── */
        .calibration-overlay {
            position: fixed;
            inset: 0;
            z-index: 200;
            background: var(--bg);
            display: flex;
            align-items: flex-start;
            justify-content: center;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
        }

        .calibration-overlay.hidden { display: none; }

        .calibration-inner {
            max-width: 680px;
            width: 100%;
            padding: 2rem 1.5rem;
            margin: auto 0;
        }

        .calibration-inner h1 {
            font-size: 1.5rem;
            font-weight: 700;
            color: var(--primary);
            margin-bottom: 0.3rem;
            text-align: center;
        }

        .calibration-inner .cal-subtitle {
            font-size: 0.9rem;
            color: var(--text-muted);
            text-align: center;
            margin-bottom: 2rem;
        }

        .cal-question {
            margin-bottom: 1.5rem;
        }

        .cal-question label {
            display: block;
            font-size: 0.88rem;
            font-weight: 600;
            color: var(--text);
            margin-bottom: 0.6rem;
        }

        .cal-chips {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 0.4rem;
        }

        .cal-chip {
            padding: 0.5rem 0.9rem;
            border: 1.5px solid var(--border);
            border-radius: var(--radius-sm);
            font-size: 0.8rem;
            font-weight: 500;
            color: var(--text-muted);
            cursor: pointer;
            background: var(--surface);
            transition: all 0.15s;
            font-family: inherit;
            text-align: center;
        }

        .cal-chip:hover {
            border-color: var(--primary);
            color: var(--primary);
        }

        .cal-chip.selected {
            border-color: var(--primary);
            background: var(--primary-light);
            color: var(--primary);
        }

        .cal-actions {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-top: 2rem;
        }

        .cal-skip {
            font-size: 0.78rem;
            color: var(--text-light);
            cursor: pointer;
            background: none;
            border: none;
            padding: 0;
            font-family: inherit;
        }

        .cal-skip:hover { color: var(--text-muted); text-decoration: underline; }

        .cal-continue {
            padding: 0.6rem 1.5rem;
            background: var(--primary);
            color: #fff;
            border: none;
            border-radius: var(--radius-sm);
            font-size: 0.88rem;
            font-weight: 600;
            cursor: pointer;
            font-family: inherit;
            transition: background 0.15s;
        }

        .cal-continue:hover { background: var(--primary-dark); }

        /* ── Edit your name modal ── */
        .display-name-overlay {
            position: fixed;
            inset: 0;
            z-index: 250;
            background: rgba(15, 23, 42, 0.45);
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 1rem;
        }

        .display-name-overlay.hidden { display: none; }

        .display-name-inner {
            background: var(--surface);
            border-radius: var(--radius-md, 10px);
            box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
            width: 100%;
            max-width: 420px;
            padding: 1.5rem 1.5rem 1.25rem;
        }

        .display-name-inner h2 {
            font-size: 1.15rem;
            font-weight: 600;
            color: var(--text);
            margin: 0 0 0.35rem;
        }

        .display-name-helper {
            font-size: 0.82rem;
            color: var(--text-muted);
            margin-bottom: 1rem;
        }

        #display-name-input {
            width: 100%;
            padding: 0.6rem 0.75rem;
            border: 1.5px solid var(--border);
            border-radius: var(--radius-sm);
            font-size: 0.95rem;
            font-family: inherit;
            background: var(--bg);
            color: var(--text);
            box-sizing: border-box;
        }

        #display-name-input:focus {
            outline: none;
            border-color: var(--primary);
        }

        .display-name-actions {
            display: flex;
            justify-content: flex-end;
            gap: 0.5rem;
            margin-top: 1.1rem;
        }

        .display-name-cancel {
            padding: 0.55rem 1.1rem;
            background: none;
            color: var(--text-muted);
            border: 1.5px solid var(--border);
            border-radius: var(--radius-sm);
            font-size: 0.85rem;
            font-weight: 500;
            cursor: pointer;
            font-family: inherit;
            transition: border-color 0.15s, color 0.15s;
        }

        .display-name-cancel:hover {
            border-color: var(--text-muted);
            color: var(--text);
        }

        .display-name-save {
            padding: 0.55rem 1.2rem;
            background: var(--primary);
            color: #fff;
            border: none;
            border-radius: var(--radius-sm);
            font-size: 0.85rem;
            font-weight: 600;
            cursor: pointer;
            font-family: inherit;
            transition: background 0.15s;
        }

        .display-name-save:hover { background: var(--primary-dark); }
        .display-name-save:disabled { opacity: 0.6; cursor: not-allowed; }

        .display-name-status {
            font-size: 0.78rem;
            color: var(--text-muted);
            margin-top: 0.6rem;
            min-height: 1em;
        }

        .display-name-status.error { color: #dc2626; }

        /* First-run mode (post-calibration prompt): hide Cancel, show Skip link below Save */
        .display-name-skip-row { display: none; }

        .display-name-overlay.first-run .display-name-cancel { display: none; }
        .display-name-overlay.first-run .display-name-actions { justify-content: center; }
        .display-name-overlay.first-run .display-name-skip-row {
            display: flex;
            justify-content: center;
            margin-top: 0.6rem;
        }

        .display-name-skip-link {
            background: none;
            border: none;
            padding: 0;
            font-size: 0.82rem;
            color: var(--text-muted);
            cursor: pointer;
            font-family: inherit;
            text-decoration: underline;
            text-underline-offset: 3px;
            transition: color 0.15s;
        }

        .display-name-skip-link:hover { color: var(--text); }
        .display-name-skip-link:disabled { opacity: 0.6; cursor: not-allowed; }

        /* ── Role reset link ── */
        .role-reset-link {
            display: inline-block;
            margin-top: 0.6rem;
            font-size: 0.7rem;
            color: var(--text-light);
            cursor: pointer;
            border: none;
            background: none;
            padding: 0;
            font-family: inherit;
            text-decoration: none;
        }

        .role-reset-link:hover {
            color: var(--text-muted);
            text-decoration: underline;
        }

        /* ── Sidebar role badge ── */
        .sidebar-role-badge {
            display: inline-block;
            padding: 0.15rem 0.55rem;
            border-radius: 999px;
            font-size: 0.68rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.04em;
            margin-top: 0.35rem;
        }

        /* ── Progress view ── */
        .progress-view {
            display: none;
            flex: 1;
            overflow-y: auto;
            padding: 1.5rem;
        }

        .progress-view.visible {
            display: block;
        }

        .progress-inner {
            max-width: 720px;
            margin: 0 auto;
        }

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

        .progress-header h2 {
            font-size: 1.2rem;
            font-weight: 700;
            color: var(--text);
        }

        .progress-back-btn {
            padding: 0.4rem 0.85rem;
            border: 1.5px solid var(--border);
            border-radius: var(--radius-sm);
            font-size: 0.78rem;
            font-weight: 500;
            cursor: pointer;
            background: var(--surface);
            color: var(--text-muted);
            transition: all 0.15s;
        }

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

        /* Stats cards */
        .progress-stats {
            display: flex;
            gap: 0.75rem;
            margin-bottom: 1.5rem;
            flex-wrap: wrap;
        }

        .stat-card {
            flex: 1;
            min-width: 120px;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 1rem;
            text-align: center;
        }

        .stat-card .stat-value {
            font-size: 1.6rem;
            font-weight: 700;
            color: var(--primary);
            line-height: 1.2;
        }

        .stat-card .stat-label {
            font-size: 0.72rem;
            font-weight: 500;
            text-transform: uppercase;
            letter-spacing: 0.04em;
            color: var(--text-muted);
            margin-top: 0.25rem;
        }

        /* RBT/BCBA note banner */
        .progress-role-note {
            display: none;
            background: var(--primary-light);
            border: 1px solid rgba(78, 147, 238, 0.3);
            border-radius: var(--radius-sm);
            padding: 0.65rem 1rem;
            font-size: 0.82rem;
            color: var(--primary-dark);
            margin-bottom: 1.25rem;
        }

        .progress-role-note.visible { display: block; }

        /* Weekly summary */
        .weekly-summary-section {
            margin-bottom: 1.5rem;
        }

        .generate-summary-btn {
            padding: 0.5rem 1rem;
            border: 1.5px solid var(--primary);
            border-radius: var(--radius-sm);
            font-size: 0.82rem;
            font-weight: 500;
            cursor: pointer;
            background: var(--primary);
            color: #fff;
            transition: all 0.15s;
        }

        .generate-summary-btn:hover { background: var(--primary-dark); }
        .generate-summary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

        .download-report-btn {
            padding: 0.5rem 1rem;
            border: 1.5px solid var(--primary);
            border-radius: var(--radius-sm);
            font-size: 0.82rem;
            font-weight: 500;
            cursor: pointer;
            background: #fff;
            color: var(--primary);
            transition: all 0.15s;
            margin-left: 0.5rem;
        }

        .download-report-btn:hover { background: var(--primary-light); }
        .download-report-btn:disabled { opacity: 0.5; cursor: not-allowed; }

        .weekly-summary-content {
            display: none;
            margin-top: 1rem;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 1.25rem;
            font-size: 0.9rem;
            line-height: 1.7;
            color: var(--text);
        }

        .weekly-summary-content.visible { display: block; }

        .weekly-summary-content p { margin-bottom: 0.75rem; }
        .weekly-summary-content p:last-child { margin-bottom: 0; }

        /* Intervention groups */
        .intervention-group {
            margin-bottom: 1.5rem;
        }

        .intervention-group-title {
            font-size: 0.75rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            color: var(--text-muted);
            margin-bottom: 0.6rem;
            padding-bottom: 0.35rem;
            border-bottom: 1px solid var(--border);
        }

        .intervention-entry {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            padding: 0.85rem 1rem;
            margin-bottom: 0.5rem;
        }

        .intervention-entry .iv-summary {
            font-size: 0.88rem;
            font-weight: 500;
            color: var(--text);
            margin-bottom: 0.25rem;
        }

        .intervention-entry .iv-context {
            font-size: 0.8rem;
            color: var(--text-muted);
            margin-bottom: 0.2rem;
        }

        .intervention-entry .iv-date {
            font-size: 0.72rem;
            color: var(--text-light);
        }

        .intervention-entry .iv-outcome {
            display: inline-block;
            padding: 0.15rem 0.5rem;
            border-radius: 999px;
            font-size: 0.7rem;
            font-weight: 600;
            margin-top: 0.35rem;
        }

        .iv-outcome.worked { background: #E5F7ED; color: #2E8B57; }
        .iv-outcome.partial { background: #FFF0E0; color: #C06800; }
        .iv-outcome.didnt_work { background: #fee2e2; color: #991b1b; }
        .iv-outcome.not_tried { background: #F3F4F6; color: var(--color-gray); }
        .iv-outcome.pending { background: #E8F4FD; color: #3578CC; }

        .intervention-entry .iv-notes {
            font-size: 0.8rem;
            color: var(--text-muted);
            margin-top: 0.35rem;
            padding-top: 0.35rem;
            border-top: 1px solid var(--border-light);
            font-style: italic;
        }

        /* Inline follow-up in progress view */
        .iv-howdiditgo-btn {
            display: inline-block;
            margin-top: 0.5rem;
            padding: 0.35rem 0.8rem;
            border: 1.5px solid #A8E5BF;
            border-radius: 999px;
            font-size: 0.76rem;
            font-weight: 500;
            cursor: pointer;
            background: #EDFAF2;
            color: #1B7A3D;
            transition: all 0.15s;
        }

        .iv-howdiditgo-btn:hover {
            border-color: var(--color-green);
            background: #D4F3E0;
        }

        .iv-inline-outcome {
            display: none;
            background: #EDFAF2;
            border: 1px solid #A8E5BF;
            border-radius: var(--radius-sm);
            padding: 0.85rem 1rem;
            margin-top: 0.6rem;
        }

        .iv-inline-outcome.visible { display: block; }

        .iv-inline-outcome .iv-inline-prompt {
            font-size: 0.84rem;
            color: var(--text);
            margin-bottom: 0.6rem;
        }

        .iv-inline-buttons {
            display: flex;
            flex-wrap: wrap;
            gap: 0.4rem;
        }

        .iv-inline-notes {
            display: none;
            margin-top: 0.65rem;
        }

        .iv-inline-notes.visible { display: block; }

        .iv-inline-notes textarea {
            width: 100%;
            padding: 0.5rem 0.7rem;
            border: 1.5px solid #A8E5BF;
            border-radius: var(--radius-sm);
            font-size: 0.85rem;
            font-family: inherit;
            resize: vertical;
            min-height: 40px;
            max-height: 100px;
            outline: none;
            margin-bottom: 0.5rem;
        }

        .iv-inline-notes textarea:focus { border-color: var(--color-green); }

        .iv-inline-notes-actions {
            display: flex;
            gap: 0.4rem;
        }

        .iv-inline-confirm {
            font-size: 0.84rem;
            font-weight: 500;
            color: var(--color-green);
            padding: 0.25rem 0;
        }

        .progress-empty {
            text-align: center;
            padding: 2rem 1rem;
            color: var(--text-muted);
            font-size: 0.9rem;
        }

        /* Progress sidebar button */
        .progress-tab-btn {
            margin: 0 1.25rem 0.75rem 1.25rem;
            padding: 0.55rem 1rem;
            background: var(--bg);
            border: 1.5px solid var(--border);
            border-radius: var(--radius-sm);
            font-size: 0.85rem;
            font-weight: 500;
            cursor: pointer;
            color: var(--text-muted);
            transition: all 0.15s;
            text-align: center;
        }

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

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

        /* ── Manage Team (invite system) ── */
        .slot-counts {
            display: flex;
            flex-wrap: wrap;
            gap: 0.35rem;
            margin-bottom: 0.75rem;
        }

        .slot-pill {
            font-size: 0.7rem;
            padding: 0.2rem 0.55rem;
            border-radius: 999px;
            background: var(--primary-light);
            color: var(--primary-dark);
            font-weight: 500;
            white-space: nowrap;
        }

        .team-list {
            margin-bottom: 0.75rem;
        }

        .team-empty {
            font-size: 0.8rem;
            color: var(--text-light);
            padding: 0.4rem 0;
        }

        .team-member-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.45rem 0;
            border-bottom: 1px solid var(--border-light);
            gap: 0.4rem;
        }

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

        .team-member-info {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 0.35rem;
            min-width: 0;
            flex: 1;
        }

        .team-member-email {
            font-size: 0.78rem;
            color: var(--text);
            word-break: break-all;
        }

        .team-role-badge {
            font-size: 0.65rem;
            font-weight: 600;
            padding: 0.12rem 0.4rem;
            border-radius: 999px;
            text-transform: uppercase;
            letter-spacing: 0.03em;
        }

        .team-role-parent { background: #FFF0E0; color: #C06800; }
        .team-role-rbt { background: #E8F4FD; color: #3578CC; }
        .team-role-bcba { background: #E5F7ED; color: #2E8B57; }
        .team-role-support { background: #F3F4F6; color: #6B7280; }
        .team-role-restricted { background: #F3F4F6; color: #6B7280; }

        .team-status {
            font-size: 0.65rem;
            padding: 0.1rem 0.35rem;
            border-radius: 999px;
            font-weight: 500;
        }

        .team-status-pending { background: #fef9c3; color: #854d0e; }
        .team-status-accepted { background: #D4F3E0; color: #1B7A3D; }
        .team-status-revoked { background: #fee2e2; color: #991b1b; }

        .revoke-btn {
            font-size: 0.7rem;
            padding: 0.2rem 0.5rem;
            border: 1px solid #fca5a5;
            border-radius: var(--radius-sm);
            background: #fff;
            color: #dc2626;
            cursor: pointer;
            white-space: nowrap;
            transition: all 0.15s;
            flex-shrink: 0;
        }

        .revoke-btn:hover {
            background: #fef2f2;
            border-color: #f87171;
        }

        .reactivate-btn {
            font-size: 0.7rem;
            padding: 0.2rem 0.5rem;
            border: 1px solid #A8E5BF;
            border-radius: var(--radius-sm);
            background: #fff;
            color: var(--color-green);
            cursor: pointer;
            white-space: nowrap;
            transition: all 0.15s;
            flex-shrink: 0;
        }

        .reactivate-btn:hover {
            background: #EDFAF2;
            border-color: var(--color-green);
        }

        .team-member-actions {
            display: flex;
            gap: 0.3rem;
            flex-shrink: 0;
        }

        .delete-btn {
            font-size: 0.7rem;
            padding: 0.2rem 0.5rem;
            border: 1px solid #fca5a5;
            border-radius: var(--radius-sm);
            background: #fff;
            color: #dc2626;
            cursor: pointer;
            white-space: nowrap;
            transition: all 0.15s;
            flex-shrink: 0;
        }

        .delete-btn:hover {
            background: #fef2f2;
        }

        .delete-btn.confirming {
            background: #dc2626;
            border-color: #dc2626;
            color: #fff;
        }

        .invite-form {
            padding-top: 0.5rem;
            border-top: 1px solid var(--border-light);
        }

        .invite-form-row {
            display: flex;
            gap: 0.35rem;
            margin-bottom: 0.4rem;
        }

        .invite-form-row input[type="email"] {
            flex: 1;
            min-width: 0;
            padding: 0.4rem 0.5rem;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            font-size: 0.8rem;
        }

        .invite-form-row select {
            padding: 0.4rem 0.3rem;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            font-size: 0.75rem;
            background: var(--surface);
            cursor: pointer;
        }

        .invite-send-btn {
            width: 100%;
        }

        .invite-status {
            font-size: 0.75rem;
            margin-top: 0.35rem;
            min-height: 1.1em;
        }

        .invite-status.success { color: var(--color-green); }
        .invite-status.error { color: #dc2626; }

        .profile-shared-option {
            color: var(--text-muted);
            font-style: italic;
        }

        /* ── Responsive ── */
        @media (max-width: 768px) {
            .sidebar {
                position: fixed;
                left: 0;
                top: 0;
                bottom: 0;
                z-index: 100;
                transform: translateX(-100%);
                transition: transform 0.25s ease;
                width: 300px;
            }

            .sidebar.open { transform: translateX(0); }

            .chat-header { display: flex; }
        }

        /* ── Splash Screen ── */
        .splash-overlay {
            position: fixed;
            inset: 0;
            z-index: 400;
            background: linear-gradient(135deg, #fefefe 0%, #fdf8f4 50%, #f8faff 100%);
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 1;
            transition: opacity 0.5s ease, transform 0.5s ease;
        }

        .splash-overlay.hidden {
            display: none;
        }

        .splash-overlay.fade-out {
            opacity: 0;
            transform: translateY(-20px);
        }

        .splash-inner {
            text-align: center;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .splash-brain-svg {
            width: 320px;
            height: auto;
            margin-bottom: 1.5rem;
        }

        /* Brain path animation — draw on via stroke-dashoffset */
        @media (prefers-reduced-motion: no-preference) {
            /* Each segment draws on in sequence, then switches to dashed */
            .splash-brain-seg {
                stroke-dasharray: 1200;
                stroke-dashoffset: 1200;
            }

            /* Orange: 0–0.55s draw, then dashed */
            #brain-seg-orange {
                animation: splash-draw-seg 0.55s cubic-bezier(0.4, 0, 0.2, 1) 0s forwards,
                           splash-seg-to-dashed 0.01s ease 0.55s forwards;
            }

            /* Pink: 0.5–0.95s draw */
            #brain-seg-pink {
                animation: splash-draw-seg 0.45s cubic-bezier(0.4, 0, 0.2, 1) 0.5s forwards,
                           splash-seg-to-dashed 0.01s ease 0.95s forwards;
            }

            /* Blue: 0.9–1.35s draw */
            #brain-seg-blue {
                animation: splash-draw-seg 0.45s cubic-bezier(0.4, 0, 0.2, 1) 0.9s forwards,
                           splash-seg-to-dashed 0.01s ease 1.35s forwards;
            }

            /* Green: 1.3–1.85s draw */
            #brain-seg-green {
                animation: splash-draw-seg 0.55s cubic-bezier(0.4, 0, 0.2, 1) 1.3s forwards,
                           splash-seg-to-dashed 0.01s ease 1.85s forwards;
            }

            /* Stems: solid, fade in after outline completes */
            .splash-brain-stem {
                stroke-dasharray: 800;
                stroke-dashoffset: 800;
            }

            #brain-stem-left {
                animation: splash-draw-seg 0.5s cubic-bezier(0.4, 0, 0.2, 1) 1.85s forwards;
            }

            #brain-stem-right {
                animation: splash-draw-seg 0.4s cubic-bezier(0.4, 0, 0.2, 1) 1.85s forwards;
            }

            .splash-glow-dot {
                opacity: 1;
            }

            .splash-wordmark {
                opacity: 0;
                transform: translateY(8px);
                animation: splash-fadein 0.5s ease 2.2s forwards;
            }

            .splash-tagline {
                opacity: 0;
                transform: translateY(8px);
                animation: splash-fadein 0.5s ease 2.5s forwards;
            }
        }

        /* Reduced motion — show everything immediately */
        @media (prefers-reduced-motion: reduce) {
            .splash-brain-seg {
                stroke-dasharray: 32 24;
                stroke-dashoffset: 0;
            }

            .splash-brain-stem {
                stroke-dashoffset: 0;
            }

            .splash-glow-dot {
                display: none;
            }

            .splash-wordmark,
            .splash-tagline {
                opacity: 1;
                transform: none;
            }
        }

        @keyframes splash-draw-seg {
            to { stroke-dashoffset: 0; }
        }

        /* After drawing, switch to dashed look matching the logo */
        @keyframes splash-seg-to-dashed {
            to { stroke-dasharray: 32 24; stroke-dashoffset: 0; }
        }

        @keyframes splash-fadein {
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        /* Wordmark styling */
        .splash-wordmark {
            font-family: 'Poppins', sans-serif;
            font-size: 2.2rem;
            font-weight: 600;
            letter-spacing: -0.02em;
            line-height: 1;
            margin-bottom: 0.4rem;
        }

        .splash-word-trace {
            color: var(--primary);
        }

        .splash-word-care {
            color: var(--color-orange);
        }

        .splash-tagline {
            font-family: 'Poppins', sans-serif;
            font-size: 0.95rem;
            font-weight: 400;
            color: var(--color-gray);
        }

        /* ══════════════════════════════════════════════════════
           PART 2: GLOBAL UI POLISH
           ══════════════════════════════════════════════════════ */

        /* ── Transitions & Micro-interactions ── */

        /* Buttons: smooth hover + active press */
        .login-btn,
        .welcome-cta-btn,
        .cal-continue,
        .send-btn,
        .new-chat-btn,
        .progress-tab-btn,
        .progress-back-btn,
        .generate-summary-btn,
        .download-report-btn,
        .btn-sm,
        .quick-action-btn,
        .followup-btn,
        .followup-notes-btn,
        .invite-send-btn {
            transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease,
                        transform 0.15s ease, box-shadow 0.2s ease;
        }

        .login-btn:active,
        .welcome-cta-btn:active,
        .cal-continue:active,
        .send-btn:active:not(:disabled),
        .new-chat-btn:active,
        .progress-tab-btn:active,
        .progress-back-btn:active,
        .generate-summary-btn:active:not(:disabled),
        .download-report-btn:active:not(:disabled),
        .btn-sm:active,
        .quick-action-btn:active,
        .followup-btn:active,
        .followup-notes-btn:active,
        .invite-send-btn:active {
            transform: scale(0.98);
        }

        /* Cards: hover lift */
        .welcome-card:not(.insight),
        .profile-snapshot-card,
        .stat-card,
        .intervention-entry {
            transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
        }

        .welcome-card:not(.insight):hover,
        .profile-snapshot-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
        }

        .stat-card:hover {
            transform: translateY(-1px);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
        }

        .intervention-entry:hover {
            border-color: var(--primary);
            box-shadow: 0 1px 6px rgba(78, 147, 238, 0.1);
        }

        /* Insight card: gentle hover glow */
        .welcome-card.insight {
            transition: box-shadow 0.2s ease;
        }

        .welcome-card.insight:hover {
            box-shadow: 0 2px 12px rgba(255, 157, 71, 0.1);
        }

        /* Form inputs: focus glow */
        .profile-form input:focus,
        .profile-form select:focus,
        .profile-form textarea:focus,
        .login-form input[type="email"]:focus,
        .invite-form-row input[type="email"]:focus,
        #user-input:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(78, 147, 238, 0.15);
        }

        /* Sidebar mobile slide — already has transition, enhance backdrop */
        .sidebar-overlay {
            transition: opacity 0.25s ease;
            opacity: 0;
        }

        .sidebar-overlay.visible {
            display: block;
            opacity: 1;
        }

        /* Follow-up card: fade + slide up on appear */
        .followup-card {
            animation: none;
        }

        .followup-card.visible {
            display: block;
            animation: polish-slide-up 0.35s ease forwards;
        }

        @keyframes polish-slide-up {
            from {
                opacity: 0;
                transform: translateY(12px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        /* Toast slide-in from top */
        .save-toast {
            position: relative;
        }

        .save-toast.visible {
            opacity: 1;
            animation: polish-toast-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
        }

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

        /* ── Visual Refinements ── */

        /* Chat bubbles: enhanced styling */
        .msg-bubble {
            border-radius: 20px;
            font-size: 15px;
        }

        .msg-row.user .msg-bubble {
            background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
            border-bottom-right-radius: 6px;
        }

        .msg-row.assistant .msg-bubble {
            border-left: 3px solid var(--primary);
            border-bottom-left-radius: 6px;
            background: var(--surface);
        }

        /* Role badges: subtle shadow for pop */
        .role-badge {
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
        }

        .sidebar-role-badge {
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
        }

        /* Quick-action buttons: icon-style hover lift */
        .quick-action-btn:hover {
            transform: translateY(-1px);
            box-shadow: 0 2px 8px rgba(78, 147, 238, 0.18);
        }

        /* Profile completeness: animated shimmer bar */
        .profile-completeness {
            position: relative;
            overflow: hidden;
        }

        .profile-completeness-bar {
            height: 4px;
            border-radius: 2px;
            background: linear-gradient(90deg, var(--color-orange), var(--color-pink), var(--primary), var(--color-green));
            background-size: 200% 100%;
            margin-top: 0.35rem;
            transition: width 0.5s ease;
            position: relative;
            overflow: hidden;
        }

        .profile-completeness-bar::after {
            content: '';
            position: absolute;
            inset: 0;
            background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.4) 50%, transparent 100%);
            animation: polish-shimmer 2s ease-in-out infinite;
        }

        @keyframes polish-shimmer {
            0% { transform: translateX(-100%); }
            100% { transform: translateX(100%); }
        }

        /* Role card hover — brand color accents */
        .role-card[data-role="parent"]:hover { border-color: var(--color-orange); }
        .role-card[data-role="rbt"]:hover { border-color: var(--primary); }
        .role-card[data-role="bcba"]:hover { border-color: var(--color-green); }

        .role-card[data-role="parent"]:hover {
            box-shadow: 0 4px 16px rgba(255, 157, 71, 0.15);
        }
        .role-card[data-role="rbt"]:hover {
            box-shadow: 0 4px 16px rgba(78, 147, 238, 0.15);
        }
        .role-card[data-role="bcba"]:hover {
            box-shadow: 0 4px 16px rgba(82, 200, 127, 0.15);
        }

        /* Calibration chips: smoother transitions */
        .cal-chip {
            transition: all 0.2s ease;
        }

        .cal-chip:active {
            transform: scale(0.97);
        }

        /* ── Typography Polish ── */
        .sidebar-section h3,
        .progress-header h2,
        .welcome-header h2,
        .calibration-inner h1,
        .onboarding-inner h2,
        .snapshot-header {
            letter-spacing: -0.01em;
        }

        .messages {
            scroll-behavior: smooth;
        }

        .msg-bubble {
            line-height: 1.6;
        }

        /* Secondary text color consistency */
        .welcome-card-desc,
        .welcome-card-body,
        .role-card .role-desc,
        .contextual-nudge {
            color: var(--color-gray);
        }

        /* ── Mobile Polish ── */
        @media (max-width: 768px) {
            /* Sticky bottom input */
            .input-area {
                position: sticky;
                bottom: 0;
                z-index: 10;
            }

            /* Comfortable chat padding on mobile */
            .messages {
                padding: 1rem;
                -webkit-overflow-scrolling: touch;
            }

            /* Prevent overscroll bounce on chat */
            .chat-area {
                overscroll-behavior: contain;
            }

            /* Touch targets: ensure minimum 44px */
            .menu-btn {
                min-width: 44px;
                min-height: 44px;
            }

            .btn-sm {
                min-height: 44px;
                padding: 0.5rem 0.85rem;
            }

            .cal-chip {
                min-height: 44px;
                display: inline-flex;
                align-items: center;
            }

            .followup-btn {
                min-height: 44px;
                display: inline-flex;
                align-items: center;
            }

            .quick-action-btn {
                min-height: 44px;
            }

            .role-card {
                min-height: 44px;
            }

            /* Splash screen: smaller on mobile */
            .splash-brain-svg {
                width: 240px;
            }

            .splash-wordmark {
                font-size: 1.8rem;
            }

            .splash-tagline {
                font-size: 0.85rem;
            }
        }

        /* ── Loading States ── */

        /* Skeleton pulse for thinking/loading */
        @keyframes polish-skeleton-pulse {
            0% { opacity: 0.6; }
            50% { opacity: 0.3; }
            100% { opacity: 0.6; }
        }

        .skeleton-line {
            height: 14px;
            border-radius: 7px;
            background: var(--border);
            animation: polish-skeleton-pulse 1.5s ease-in-out infinite;
            margin-bottom: 0.5rem;
        }

        .skeleton-line:nth-child(1) { width: 85%; }
        .skeleton-line:nth-child(2) { width: 70%; animation-delay: 0.15s; }
        .skeleton-line:nth-child(3) { width: 55%; animation-delay: 0.3s; }

        /* Send button loading spinner */
        .send-btn.loading svg {
            display: none;
        }

        .send-btn.loading::after {
            content: '';
            width: 18px;
            height: 18px;
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-top-color: #fff;
            border-radius: 50%;
            animation: polish-spin 0.6s linear infinite;
        }

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

        /* Message row entrance animation */
        @media (prefers-reduced-motion: no-preference) {
            .msg-row {
                animation: polish-msg-in 0.3s ease forwards;
            }

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

        /* ── Legal pages ────────────────────────────────────────────────── */

        .legal-page {
            max-width: 720px;
            margin: 0 auto;
            padding: 2rem 1.5rem;
            font-family: 'Poppins', sans-serif;
            color: #333;
            line-height: 1.7;
        }

        .legal-logo-link {
            display: inline-block;
            margin-bottom: 1.5rem;
        }

        .legal-logo {
            height: 40px;
            width: auto;
        }

        .legal-page h1 {
            color: var(--primary);
            font-size: 1.5rem;
            font-weight: 600;
            margin-top: 1rem;
            margin-bottom: 0.25rem;
        }

        .legal-effective {
            color: var(--color-gray);
            font-size: 0.85rem;
            margin-bottom: 1.5rem;
        }

        .legal-page h2 {
            color: #333;
            font-size: 1.2rem;
            font-weight: 500;
            margin-top: 2rem;
            margin-bottom: 0.75rem;
        }

        .legal-page h3 {
            color: #444;
            font-size: 1.05rem;
            font-weight: 500;
            margin-top: 1.25rem;
            margin-bottom: 0.5rem;
        }

        .legal-page p {
            margin-bottom: 0.75rem;
        }

        .legal-page ul {
            padding-left: 1.5rem;
            list-style: disc;
            margin-bottom: 0.75rem;
        }

        .legal-page ul li {
            margin-bottom: 0.4rem;
        }

        .legal-page a {
            color: var(--primary);
            text-decoration: none;
        }

        .legal-page a:hover {
            text-decoration: underline;
        }

        .legal-back {
            margin-top: 2.5rem;
            padding-top: 1.5rem;
            border-top: 1px solid var(--border);
        }

        .legal-back a {
            color: var(--primary);
            text-decoration: none;
            font-weight: 500;
            font-size: 0.9rem;
        }

        .legal-back a:hover {
            text-decoration: underline;
        }

        .legal-footer {
            text-align: center;
            padding: 2rem 1rem;
            color: var(--color-gray);
            font-family: 'Poppins', sans-serif;
            font-size: 0.75rem;
        }

        /* Legal links on login & onboarding screens */
        .login-legal-links {
            font-size: 0.8rem;
            color: var(--color-gray);
            margin-top: 1rem;
            text-align: center;
        }

        .login-legal-links a {
            color: var(--color-gray);
            text-decoration: underline;
        }

        .login-legal-links a:hover {
            color: var(--primary);
        }

        /* Legal links in sidebar footer */
        .sidebar-legal-links {
            font-size: 0.7rem;
            color: var(--color-gray);
            padding-top: 0.5rem;
            text-align: center;
        }

        .sidebar-legal-links a {
            color: var(--color-gray);
            text-decoration: none;
        }

        .sidebar-legal-links a:hover {
            text-decoration: underline;
            color: var(--primary);
        }
    