/* ============================================================
   Mellow Web — Design tokens from iOS DS / DesignTokens.swift
   ============================================================ */

:root {
    --bg: #F6F1EA;
    --card: #FFFFFF;
    --accent: #F47D30;
    --accent-soft: rgba(244, 125, 48, 0.14);
    --ink: #403D3B;
    --ink-secondary: #8F877D;
    --shadow: rgba(115, 89, 51, 0.10);
    --danger: #C74740;
    --positive: #4D9959;
    --radius: 18px;
    --radius-sm: 14px;
    --font: "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

/* ---- Layout ---- */

#app {
    max-width: 768px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    flex-direction: column;
}

#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    flex-shrink: 0;
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

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

.logo-video { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.title { font-size: 20px; font-weight: 650; color: var(--ink); letter-spacing: -0.3px; }

.header-right { display: flex; gap: 6px; }

/* ---- Buttons ---- */

.btn-ghost {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    font-size: 16px;
    font-weight: 600;
    color: var(--ink-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.btn-ghost:hover { background: var(--accent-soft); color: var(--ink); }
.btn-ghost:active { opacity: 0.7; }

.btn-send {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s;
}
.btn-send:disabled { opacity: 0.35; cursor: default; }
.btn-send:not(:disabled):active { opacity: 0.7; }

/* ---- Chat area ---- */

#chatArea {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding-bottom: 40px;
}

.welcome-cat-video { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; }
.welcome-text {
    font-size: 17px;
    color: var(--ink-secondary);
    text-align: center;
    line-height: 1.6;
}

/* ---- Bubbles ---- */

.bubble {
    max-width: 82%;
    padding: 12px 17px;
    border-radius: var(--radius);
    font-size: 16px;
    line-height: 1.55;
    word-break: break-word;
    animation: bubbleIn 0.25s ease-out;
}

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

.bubble.assistant {
    align-self: flex-start;
    background: var(--card);
    color: var(--ink);
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 12px var(--shadow);
}

.bubble.user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 6px;
}

/* ---- Streaming cursor ---- */

.bubble.streaming::after {
    content: "|";
    animation: blink 0.8s infinite;
    font-weight: 100;
    margin-left: 1px;
    opacity: 0.7;
}

@keyframes blink {
    0%, 100% { opacity: 0.7; }
    50%      { opacity: 0; }
}

/* ---- Crisis hint ---- */

.crisis-hint {
    background: #FEF2F2;
    border: 1px solid #FECACA;
    color: var(--danger);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
}

/* ---- Input bar ---- */

#inputBar {
    flex-shrink: 0;
    padding: 10px 16px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: var(--bg);
    position: sticky;
    bottom: 0;
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--card);
    border-radius: 26px;
    padding: 6px 8px 6px 20px;
    box-shadow: 0 2px 14px var(--shadow);
}

#messageInput {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--font);
    font-size: 16px;
    color: var(--ink);
    padding: 8px 0;
    min-height: 24px;
    max-height: 120px;
}

#messageInput::placeholder { color: var(--ink-secondary); opacity: 0.6; }

/* ---- Scrollbar ---- */

#chatArea::-webkit-scrollbar { width: 4px; }
#chatArea::-webkit-scrollbar-track { background: transparent; }
#chatArea::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.10); border-radius: 4px; }

/* ---- Thinking dots ---- */

.thinking-dots {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 14px 18px;
}

.thinking-dots span {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--ink-secondary);
    animation: dotBounce 1.2s infinite ease-in-out;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}