:root {
    --bg: #F8FAFC;
    --surface: #FFFFFF;
    --border: #E2E8F0;
    --border-subtle: #F1F5F9;
    --text-main: #0F172A;
    --text-muted: #475569;
    --text-light: #64748B;
    
    /* Apple / Calm Navy & Slate Palette */
    --blue: #007AFF;
    --blue-hover: #0066D6;
    --blue-subtle: #F0F7FF;
    --green: #059669;
    --green-subtle: #ECFDF5;
    --green-text: #065F46;
    --amber: #D97706;
    --amber-subtle: #FFFBEB;

    --imessage-bubble-bot: #F1F5F9;
    --imessage-bubble-user: #007AFF;

    --header-height: 64px;
    --input-height: 60px;
    --nav-height: 56px;
}

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

html, body {
    height: 100dvh;
    width: 100%;
    overflow: hidden;
    position: fixed;
    background-color: var(--bg);
    color: var(--text-main);
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    position: relative;
    background-color: #FFFFFF;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.04);
}

/* Top Fixed Header */
.top-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.85rem;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    flex-shrink: 0;
    gap: 0.5rem;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text-main);
    min-width: 0;
    flex: 1;
}

.brand-avatar {
    width: 36px;
    height: 36px;
    background: #0F172A;
    color: #FFFFFF;
    font-weight: 800;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.brand-titles {
    min-width: 0;
}

.brand-titles h1 {
    font-size: 0.96rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.2;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-titles span {
    font-size: 0.72rem;
    color: var(--text-light);
    font-weight: 600;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.42rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.header-btn-call {
    background: #0F172A;
    color: #FFFFFF;
    border: 1px solid #0F172A;
}

.header-btn-text {
    background: #FFFFFF;
    color: var(--text-main);
    border: 1px solid var(--border);
}

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

/* Main Scrollable Stream */
.imessage-stream {
    flex: 1;
    min-height: 0;
    position: relative; /* offset parent for scroll anchoring (js/chat-engine.js) */
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    padding: 1rem 0.85rem 1.5rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: #FAFAFA;
}

.chat-bubble {
    max-width: 90%;
    padding: 0.85rem 1.05rem;
    font-size: 0.95rem;
    line-height: 1.48;
    animation: fadeIn 0.18s ease-out;
    word-wrap: break-word;
}

.chat-bubble.bot {
    align-self: flex-start;
    background: #FFFFFF;
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.chat-bubble.user {
    align-self: flex-end;
    background: #007AFF;
    color: #FFFFFF;
    border-radius: 18px;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.2);
}

/* Cards inside Stream */
.chat-card {
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.15rem;
    margin-top: 0.25rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
    width: 100%;
}

.card-category {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.35rem;
    display: block;
}

.chat-card-title {
    font-size: 1.12rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.25;
    margin-bottom: 0.25rem;
}

.chat-card-date {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.55rem;
    display: block;
}

.chat-card-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.48;
    margin-bottom: 0.85rem;
}

/* Action Buttons inside Cards */
.chat-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 46px;
    border-radius: 12px;
    font-size: 0.92rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform 0.12s ease;
}

.chat-action-btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: #007AFF;
    color: #FFFFFF;
}

.btn-secondary {
    background: #0F172A;
    color: #FFFFFF;
}

.btn-outline {
    background: #FFFFFF;
    border: 1px solid var(--border);
    color: var(--text-main);
}

/* Choice Chips inside Stream */
.choice-chips-container {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    width: 100%;
    max-width: 90%;
    align-self: flex-start;
    margin-top: 0.2rem;
}

.choice-chip {
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.15s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.choice-chip:hover, .choice-chip:active {
    background: var(--blue-subtle);
    border-color: var(--blue);
    color: var(--blue);
    transform: scale(0.99);
}

/* Callout Box inside Tips */
.prompt-callout {
    background: #F8FAFC;
    border: 1px solid var(--border);
    border-left: 3px solid #007AFF;
    padding: 0.85rem 0.95rem;
    border-radius: 0 10px 10px 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    color: #0F172A;
    line-height: 1.5;
    margin: 0.75rem 0;
}

/* Self-Check question card (was a wall of inline styles in js/app.js) */
.quiz-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.25rem;
    width: 100%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.quiz-kicker {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}

.quiz-question {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.3;
    margin-bottom: 0.85rem;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

/* Result payout blocks — shown free, before any contact is asked for */
.result-block {
    border-top: 1px solid var(--border-subtle);
    padding-top: 0.75rem;
    margin-top: 0.35rem;
}

.result-label {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--green-text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.3rem;
    display: block;
}

/* Typing Indicator */
.typing-bubble {
    align-self: flex-start;
    background: #FFFFFF;
    border: 1px solid var(--border);
    padding: 0.6rem 0.95rem;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 0.3rem;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #94A3B8;
    border-radius: 50%;
    animation: bounce 1.2s infinite ease-in-out;
}

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

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

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

/* Bottom Fixed Input Bar */
.imessage-input-bar {
    height: var(--input-height);
    padding: 0.4rem 0.75rem;
    background: #FFFFFF;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    z-index: 9998;
}

.imessage-text-input {
    flex: 1;
    height: 40px;
    background: #F8FAFC;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0 1rem;
    font-size: 0.92rem;
    font-family: inherit;
    color: var(--text-main);
}

.imessage-text-input:focus {
    outline: none;
    border-color: #007AFF;
    background: #FFFFFF;
}

.imessage-send-btn {
    width: 36px;
    height: 36px;
    background: #007AFF;
    color: #FFFFFF;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s ease;
    flex-shrink: 0;
}

.imessage-send-btn:active {
    transform: scale(0.92);
}

/* Anchored Bottom Navigation Glass Dock (Rule #12 Standard) */
.glass-dock-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    z-index: 9999;
    flex-shrink: 0;
}

.dock-container {
    display: flex;
    height: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 0 0.5rem;
    align-items: center;
    justify-content: space-around;
}

.dock-tab {
    flex: 1;
    height: 40px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
}

.dock-tab .dock-label {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1;
}

.dock-tab.active {
    background: var(--blue-subtle);
    color: var(--blue);
    border-color: rgba(0, 122, 255, 0.2);
}

/* Spacing for stream container above the fixed bottom navigation */
.stream-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
}
