:root {
    --primary: #2563eb;
    --primary-600: #1d4ed8;
    --primary-400: #3b82f6;
    --accent: #06b6d4;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --background: linear-gradient(180deg, #f3f6fb 0%, #eef4fb 100%);
    --text: #0f1724;
    --muted: #6b7280;
    --border: #e6eef8;
    --danger: #dc2626;
    --success: #10b981;
    --shadow: 0 10px 30px rgba(16, 24, 40, 0.06);
    --radius: 14px;
    --radius-sm: 8px;
}

/* Compatibility aliases for older styles */
:root {
    --surface-alt: var(--surface-2);
    --text-primary: var(--text);
    --text-secondary: var(--muted);
    --text-muted: var(--muted);
    --radius-lg: var(--radius);
    --shadow-sm: rgba(15, 24, 40, 0.06);
    --primary-dark: var(--primary-600);
    --primary-light: var(--primary-400);
}

[data-theme="dark"] {
    --surface: #0f1724;
    --surface-2: #111827;
    --background: linear-gradient(180deg, #071027 0%, #081028 100%);
    --text: #e6eef8;
    --muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.06);
    --shadow: 0 10px 30px rgba(2, 6, 23, 0.6);
}

* {
    box-sizing: border-box
}

html,
body {
    height: 100%;
    margin: 0;
    font-family: Inter, -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    line-height: 1.35;
    background: var(--background);
    color: var(--text);
    -webkit-font-smoothing: antialiased
}

#app {
    width: 100%;
    max-width: 720px;
    margin: 28px auto;
    min-height: 84vh;
    background: var(--surface);
    border-radius: 26px;
    overflow: hidden;
    box-shadow: 0 30px 70px rgba(15, 23, 42, 0.12);
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    padding: 20px 22px;
    background: linear-gradient(90deg, var(--primary), var(--primary-600));
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px
}

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

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 999px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--primary)
}

.header-title h1 {
    font-size: 18px;
    margin: 0;
    font-weight: 700
}

.header-title p {
    font-size: 13px;
    margin: 0;
    opacity: 0.95
}

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

.lang-select {
    appearance: none;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #fff;
    padding: 8px 12px;
    border-radius: 999px;
    font-weight: 600
}

.header-btn {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    padding: 8px 10px;
    border-radius: 10px;
    color: #fff;
    cursor: pointer
}

.progress-row {
    display: flex;
    align-items: center;
    gap: 12px
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    overflow: hidden
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-400), var(--accent));
    width: 0%;
    transition: width .4s ease
}

.progress-text {
    min-width: 64px;
    text-align: right;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.95)
}

/* Main */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Chat Messages */
.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    display: flex;
    width: 100%;
    flex-direction: row;
    max-width: 100%;
    margin: 10px 0;
}

.message.bot {
    justify-content: flex-start;
    align-items: flex-start;
}

.message.user {
    justify-content: flex-end;
    align-items: flex-end;
}

.message-bubble {
    padding: 16px 18px;
    border-radius: 24px;
    font-size: 15px;
    line-height: 1.7;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    background: var(--surface-alt);
    border: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: 0 18px 35px rgba(15, 23, 42, 0.08);
    max-width: 74%;
    min-width: 120px;
}

.message.bot .message-bubble {
    background: var(--surface-alt);
    color: var(--text);
    border-radius: 24px 24px 24px 8px;
}

.message.user .message-bubble {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    border-radius: 24px 24px 8px 24px;
}

.message-text {
    margin: 0;
}

.typing-bubble {
    padding: 14px 18px;
    background: rgba(37, 99, 235, 0.14);
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.typing-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    animation: blink 1.2s infinite ease-in-out;
}

.typing-indicator .dot:nth-child(2) {
    animation-delay: 0.18s;
}

.typing-indicator .dot:nth-child(3) {
    animation-delay: 0.36s;
}

@keyframes blink {

    0%,
    80%,
    100% {
        opacity: 0.35;
    }

    40% {
        opacity: 1;
    }
}

.message-text {
    margin-bottom: 6px;
}

/* Choice Buttons */
.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.choice-btn {
    padding: 12px 18px;
    min-width: 120px;
    border-radius: 999px;
    border: 1px solid var(--primary);
    background: var(--surface);
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.24s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.choice-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
}

.choice-btn[disabled],
.choice-btn.disabled {
    opacity: 0.65;
    pointer-events: none;
    transform: none;
    cursor: default;
}

/* Disabled choice buttons */
.choice-btn[disabled],
.choice-btn.disabled {
    opacity: 0.65;
    pointer-events: none;
    transform: none;
    cursor: default;
}

/* Mobile friendliness tweaks */
@media (max-width: 520px) {
    body {
        background: #eef4fb;
    }

    #app {
        max-width: 100%;
        min-height: 100vh;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }

    header {
        padding: 14px 16px;
        position: sticky;
        top: 0;
        z-index: 20;
    }

    .header-top {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .header-actions {
        justify-content: space-between;
    }

    .header-title h1 {
        font-size: 17px;
    }

    .progress-text {
        display: none;
    }

    main {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 12px;
        scroll-behavior: smooth;
        overflow: hidden;
    }

    .chat-area {
        padding: 18px;
        background: var(--surface-alt);
        border-radius: 0 0 20px 20px;
        min-height: 0;
        overflow-y: auto;
    }

    .message {
        width: 100%;
    }

    .button-row {
        flex-direction: column;
    }

    .choice-btn {
        width: 100%;
        box-sizing: border-box;
    }

    footer {
        display: none;
    }

    nav {
        position: sticky;
        bottom: 0;
        background: var(--surface);
        z-index: 20;
    }

    .chart-card canvas {
        min-height: 200px;
    }

    .timeline {
        padding-left: 0;
    }

    .timeline-item {
        margin-bottom: 18px;
    }

    .timeline-content {
        padding: 14px;
    }

    .timeline-header {
        gap: 8px;
    }

    .timeline-date,
    .timeline-time,
    .timeline-severity {
        font-size: 12px;
    }
}


/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--surface-alt);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: fit-content;
}

.typing-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: bounce 1.4s infinite;
}

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

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

@keyframes bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-6px);
    }
}

/* Results */
.result-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    max-width: 95%;
}

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

.severity-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
}

.severity-badge.urgent {
    background: #fef2f2;
    color: #dc2626;
}

.severity-badge.severe {
    background: #fff7ed;
    color: #ea580c;
}

.severity-badge.moderate {
    background: #fefce8;
    color: #ca8a04;
}

.severity-badge.mild {
    background: #f0fdf4;
    color: #16a34a;
}

[data-theme="dark"] .severity-badge.urgent {
    background: #450a0a;
    color: #fca5a5;
}

[data-theme="dark"] .severity-badge.severe {
    background: #431407;
    color: #fdba74;
}

[data-theme="dark"] .severity-badge.moderate {
    background: #422006;
    color: #fde047;
}

[data-theme="dark"] .severity-badge.mild {
    background: #052e16;
    color: #86efac;
}

.result-condition {
    background: var(--surface-alt);
    border-radius: 8px;
    padding: 12px 14px;
    margin: 10px 0;
    border-left: 3px solid var(--primary);
}

.result-condition h4 {
    font-size: 14px;
    color: var(--primary);
    margin-bottom: 4px;
    font-weight: 600;
}

.result-condition p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.severity-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
}

.severity-badge.urgent {
    background: #fef2f2;
    color: #dc2626;
}

.severity-badge.severe {
    background: #fff7ed;
    color: #ea580c;
}

.severity-badge.moderate {
    background: #fefce8;
    color: #ca8a04;
}

.severity-badge.mild {
    background: #f0fdf4;
    color: #16a34a;
}

[data-theme="dark"] .severity-badge.urgent {
    background: #450a0a;
    color: #fca5a5;
}

[data-theme="dark"] .severity-badge.severe {
    background: #431407;
    color: #fdba74;
}

[data-theme="dark"] .severity-badge.moderate {
    background: #422006;
    color: #fde047;
}

[data-theme="dark"] .severity-badge.mild {
    background: #052e16;
    color: #86efac;
}

.result-condition {
    background: var(--surface);
    border-radius: 8px;
    padding: 10px 12px;
    margin: 8px 0;
    border-left: 2px solid var(--primary);
}

.result-condition h4 {
    font-size: 13px;
    color: var(--primary);
    margin-bottom: 4px;
}

.result-condition p {
    font-size: 12px;
    color: var(--text-secondary);
}

.result-section {
    margin-top: 12px;
}

.result-section h4 {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.result-section ul {
    padding-left: 18px;
    font-size: 13px;
    color: var(--text-secondary);
}

.result-section ul li {
    margin: 4px 0;
}

.result-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* Modal for diary details */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px
}

.modal {
    background: var(--surface);
    border-radius: 12px;
    max-width: 720px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    padding: 18px;
    box-shadow: 0 30px 80px rgba(2, 6, 23, 0.5)
}

.modal-close {
    position: absolute;
    right: 18px;
    top: 12px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer
}

.modal-body h2 {
    margin-top: 0
}

.modal-section {
    margin-top: 12px
}

.modal-answer {
    margin-bottom: 8px
}

.action-btn {
    padding: 8px 16px;
    border-radius: var(--radius-full);
    border: none;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn.export-btn {
    background: var(--surface-alt);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.action-btn.export-btn:hover {
    background: var(--border);
}

.action-btn.diary-btn {
    background: var(--success);
    color: white;
}

.action-btn.diary-btn:hover {
    background: #059669;
}

.action-btn.restart-btn {
    background: var(--primary);
    color: white;
}

.action-btn.restart-btn:hover {
    background: var(--primary-dark);
}

/* Footer */
footer {
    background: var(--surface-alt);
    border-top: 1px solid rgba(226, 238, 248, 0.7);
    padding: 14px 20px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    flex-shrink: 0;
}

footer strong {
    color: var(--danger);
}

/* Navigation */
nav {
    display: flex;
    background: var(--surface);
    border-top: 1px solid rgba(226, 238, 248, 0.9);
    padding: 4px 8px;
    flex-shrink: 0;
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 6px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
    border-radius: 16px;
}

.nav-btn:hover {
    background: rgba(37, 99, 235, 0.06);
}

.nav-btn.active {
    color: var(--primary);
    font-weight: 700;
}

.nav-icon {
    font-size: 18px;
}

/* Pages */
.page {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.page.active {
    display: flex;
}

/* Diary Page */
.diary-page {
    padding: 20px;
    overflow-y: auto;
    background: transparent;
}

.diary-page h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 18px;
    color: var(--text);
    letter-spacing: 0.01em;
    text-rendering: optimizeLegibility;
}

.diary-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.diary-empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.diary-empty-state h2 {
    font-size: 20px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.diary-empty-state p {
    color: var(--text-muted);
    font-size: 14px;
}

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

.diary-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.diary-count {
    font-size: 13px;
    color: var(--text-muted);
    background: var(--surface-alt);
    padding: 4px 10px;
    border-radius: var(--radius-full);
}

.diary-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--surface);
    border-radius: 22px;
    padding: 18px;
    box-shadow: 0 18px 30px rgba(15, 23, 42, 0.06);
    border: 1px solid rgba(148, 163, 184, 0.14);
}

.chart-card h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 14px 0;
    text-rendering: optimizeLegibility;
}

.chart-card canvas {
    width: 100%;
    display: block;
    min-height: 240px;
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
}

.timeline-dot {
    position: absolute;
    left: -24px;
    top: 8px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 3px solid var(--surface);
    background: var(--border);
}

.timeline-dot.urgent {
    background: #dc2626;
}

.timeline-dot.severe {
    background: #ea580c;
}

.timeline-dot.moderate {
    background: #ca8a04;
}

.timeline-dot.mild {
    background: #16a34a;
}

.timeline-content {
    background: var(--surface);
    border-radius: 20px;
    padding: 16px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    box-shadow: 0 18px 35px rgba(15, 23, 42, 0.05);
}

.timeline-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.timeline-date {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.timeline-time {
    font-size: 12px;
    color: var(--muted);
}

.timeline-severity {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    margin-left: auto;
}

.condition-pill {
    font-size: 12px;
    padding: 5px 10px;
    background: rgba(59, 130, 246, 0.12);
    color: var(--primary);
    border-radius: 999px;
}

.timeline-date {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.timeline-time {
    font-size: 12px;
    color: var(--text-muted);
}

.timeline-severity {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    margin-left: auto;
}

.timeline-severity.urgent {
    background: #fef2f2;
    color: #dc2626;
}

.timeline-severity.severe {
    background: #fff7ed;
    color: #ea580c;
}

.timeline-severity.moderate {
    background: #fefce8;
    color: #ca8a04;
}

.timeline-severity.mild {
    background: #f0fdf4;
    color: #16a34a;
}

[data-theme="dark"] .timeline-severity.urgent {
    background: #450a0a;
    color: #fca5a5;
}

[data-theme="dark"] .timeline-severity.severe {
    background: #431407;
    color: #fdba74;
}

[data-theme="dark"] .timeline-severity.moderate {
    background: #422006;
    color: #fde047;
}

[data-theme="dark"] .timeline-severity.mild {
    background: #052e16;
    color: #86efac;
}

.timeline-conditions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.condition-pill {
    font-size: 12px;
    padding: 4px 10px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-full);
}

.timeline-answers {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.answer-item {
    display: flex;
    gap: 6px;
    margin: 4px 0;
}

.answer-bullet {
    color: var(--primary);
    flex-shrink: 0;
}

.answer-text {
    line-height: 1.4;
}

.more-answers {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 4px;
}

.diary-entry {
    align-items: center;
    margin-bottom: 8px;
}

.diary-date {
    font-size: 12px;
    color: var(--text-muted);
}

.diary-severity {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.diary-conditions {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.condition-tag {
    background: var(--surface);
    padding: 2px 8px;
    border-radius: 4px;
}

.delete-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    padding: 6px 12px;
    border: none;
    background: var(--surface-alt);
    color: var(--text-muted);
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.delete-btn:hover {
    background: var(--danger);
    color: white;
}

/* Settings Page */
.settings-page {
    padding: 16px;
    overflow-y: auto;
}

.settings-page h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

.setting-item {
    background: var(--surface-alt);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
}

.setting-item label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.setting-item select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 14px;
}

.danger-btn {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--danger);
    background: var(--danger);
    color: white;
    font-size: 14px;
    cursor: pointer;
    margin-top: 8px;
}

.danger-btn:hover {
    background: #dc2626;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: var(--surface);
    padding: 10px 20px;
    border-radius: var(--radius-full);
    font-size: 13px;
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Welcome/Consent */
.consent-message {
    text-align: center;
    padding: 20px;
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.02));
}

.chat-area {
    flex: 1;
    min-height: 320px;
    overflow: auto;
    padding: 20px;
    background: var(--surface-alt);
}

/* Message content/layout helpers used by ChatView */
.message {
    margin: 12px 0;
    width: 100%;
}

.message-content {
    background: transparent;
    padding: 0;
}

.question-text {
    font-size: 16px;
    color: var(--text);
    margin-bottom: 12px;

}

/* Options grid: responsive columns */
.options-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.option-btn {
    padding: 12px 14px;
    border-radius: 999px;
    border: 2px solid var(--primary-400);
    background: transparent;
    color: var(--primary-600);
    cursor: pointer;
    text-align: center;
    font-weight: 600;
}

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

@media (max-width: 900px) {
    .options-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 520px) {
    .options-grid {
        grid-template-columns: 1fr;
    }
}

.consent-message {
    max-width: 720px;
    margin: 10px auto;
    padding: 20px;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04)
}

.consent-message h2 {
    margin: 0 0 8px 0;
    font-size: 20px;
    color: var(--primary)
}

.consent-message p {
    margin: 0 0 12px 0;
    color: var(--muted)
}

.warning-box {
    background: #fff5f5;
    border: 1px solid rgba(220, 38, 38, 0.12);
    padding: 8px 12px;
    border-radius: 10px;
    color: var(--danger);
    margin-bottom: 12px
}

.consent-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 6px
}

.consent-btn {
    padding: 14px 18px;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-weight: 700;
    cursor: pointer
}

.consent-btn.primary {
    background: linear-gradient(90deg, var(--primary-400), var(--primary));
    color: #fff;
    border: none
}

.consent-btn.secondary {
    background: transparent;
    color: var(--muted)
}

.consent-btn[disabled],
.consent-btn.disabled {
    opacity: 0.55;
    cursor: default;
    pointer-events: none;
}

/* Messages */
.message {
    display: flex;
    width: 100%;
    margin: 12px 0;
    align-items: flex-start;
}

.message.bot {
    justify-content: flex-start;
}

.message.user {
    justify-content: flex-end;
}

.message-bubble {
    padding: 16px 18px;
    border-radius: 24px;
    font-size: 15px;
    line-height: 1.7;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    background: var(--surface-alt);
    border: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: 0 18px 35px rgba(15, 23, 42, 0.08);
    max-width: 74%;
    min-width: 120px;
}

.message.bot .message-bubble {
    background: var(--surface-alt);
    color: var(--text);
    border-radius: 24px 24px 24px 8px;
}

.message.user .message-bubble {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    border-radius: 24px 24px 8px 24px;
}

.message-text {
    margin: 0;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 14px;
}

.choice-btn {
    padding: 12px 16px;
    border-radius: 999px;
    border: 1px solid var(--primary);
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    font-weight: 600
}

.choice-btn.primary {
    background: var(--primary);
    color: #fff;
    border: none
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--surface-2)
}

.typing-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--muted);
    animation: bounce 1.2s infinite
}

@keyframes bounce {

    0%,
    60%,
    100% {
        transform: translateY(0)
    }

    30% {
        transform: translateY(-6px)
    }
}

/* Results */
.result-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04)
}

.result-card h3 {
    color: var(--primary);
    margin: 0 0 10px 0
}

.result-section h4 {
    font-size: 12px;
    color: var(--muted);
    margin: 10px 0
}

.result-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.view-details-btn {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
}

.view-details-btn:hover {
    background: var(--primary-400);
    color: white;
    border-color: var(--primary-400);
}

.action-btn {
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    cursor: pointer
}

.action-btn.restart-btn {
    background: var(--primary);
    color: #fff;
    border: none
}

/* Footer & Nav */
footer {
    padding: 12px 18px;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--muted)
}

nav {
    display: flex;
    background: transparent;
    border-top: 1px solid var(--border)
}

.nav-btn {
    flex: 1;
    padding: 10px 8px;
    text-align: center;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer
}

.nav-btn.active {
    color: var(--primary);
    font-weight: 700
}

/* Diary & misc */
.diary-empty-state {
    padding: 40px;
    text-align: center;
    color: var(--muted)
}

/* Responsive tweaks */
@media (max-width:720px) {
    #app {
        margin: 12px;
        min-height: 88vh;
        border-radius: 12px
    }

    .header-top {
        gap: 8px
    }

    .avatar {
        width: 40px;
        height: 40px
    }

    .header-title h1 {
        font-size: 16px;
    }

    .header-title p {
        font-size: 13px;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .consent-buttons {
        flex-direction: column;
    }

    .choice-btn {
        flex: 1 1 100%;
        text-align: center;
    }

    .result-actions {
        flex-direction: column;
    }
}

@media (min-width:721px) {
    .consent-buttons {
        flex-direction: row
    }

    .choice-btn {
        min-width: 160px
    }
}

/* Accessibility */
.consent-btn:focus,
.choice-btn:focus,
.action-btn:focus {
    outline: 3px solid rgba(37, 99, 235, 0.18);
    outline-offset: 2px
}