/* Cubby — Beat Reporter
   Color palette inspired by Lake Washington waterfront */

:root {
    --lake-blue: #1a6fb5;
    --lake-dark: #14537d;
    --lake-light: #e8f2fa;
    --lake-lighter: #f4f8fc;
    --evergreen: #2d7a4f;
    --warm-gray: #f7f6f4;
    --text: #1a1a2e;
    --text-secondary: #555;
    --border: #e0ddd8;
    --white: #ffffff;
    --error-bg: #fef2f2;
    --error-text: #991b1b;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont,
        "Segoe UI", Roboto, "Helvetica Neue", Arial,
        sans-serif;
    background: var(--warm-gray);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */

.header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-inner {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

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

.header-logo {
    width: 32px;
    height: 32px;
    background: var(--lake-blue);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
}

.header-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--lake-dark);
}

.header-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.header-live {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--evergreen);
}

.live-dot {
    width: 8px;
    height: 8px;
    background: var(--evergreen);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* --- Chat Container --- */

.chat-container {
    flex: 1;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding: 0 1rem;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* --- Messages --- */

.message {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
    animation: fadeIn 0.3s ease-out;
}

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

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

.message-cubby {
    align-self: flex-start;
}

.message-system {
    align-self: center;
    max-width: 90%;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.avatar-cubby {
    background: var(--lake-blue);
    color: white;
}

.avatar-user {
    background: var(--border);
    color: var(--text-secondary);
}

.bubble {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.bubble p {
    margin-bottom: 0.5em;
}

.bubble p:last-child {
    margin-bottom: 0;
}

.bubble-cubby {
    background: var(--white);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    color: var(--text);
}

.bubble-cubby h3, .bubble-cubby h4,
.bubble-cubby h5, .bubble-cubby h6 {
    margin: 0.6em 0 0.3em;
    color: var(--lake-dark);
}

.bubble-cubby h3:first-child,
.bubble-cubby h4:first-child {
    margin-top: 0;
}

.bubble-cubby ul, .bubble-cubby ol {
    margin: 0.3em 0 0.5em 1.2em;
    padding: 0;
}

.bubble-cubby li {
    margin-bottom: 0.2em;
}

.bubble-cubby strong {
    color: var(--lake-dark);
}

.bubble-cubby code {
    background: var(--lake-lighter);
    padding: 0.15em 0.35em;
    border-radius: 4px;
    font-size: 0.88em;
}

.bubble-cubby a {
    color: var(--lake-blue);
    text-decoration: underline;
}

.bubble-user {
    background: var(--lake-blue);
    color: white;
    border-bottom-right-radius: 4px;
}

.bubble-system {
    background: var(--lake-lighter);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
}

.bubble-error {
    background: var(--error-bg);
    border: 1px solid #fecaca;
    color: var(--error-text);
    font-size: 0.85rem;
}

/* --- Welcome Card --- */

.welcome-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin: 1rem 0;
    box-shadow: var(--shadow-md);
}

.welcome-card h2 {
    font-size: 1.1rem;
    color: var(--lake-dark);
    margin-bottom: 0.5rem;
}

.welcome-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.welcome-starters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.starter-btn {
    background: var(--lake-lighter);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.4rem 0.9rem;
    font-size: 0.82rem;
    color: var(--lake-dark);
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.starter-btn:hover {
    background: var(--lake-light);
    border-color: var(--lake-blue);
    color: var(--lake-blue);
}

/* --- Thinking Indicator --- */

.thinking {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-style: italic;
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dots span {
    width: 6px;
    height: 6px;
    background: var(--lake-blue);
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

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

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

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* --- Input Area --- */

.input-area {
    position: sticky;
    bottom: 0;
    background: var(--warm-gray);
    padding: 0.75rem 0 1.25rem;
    border-top: 1px solid var(--border);
}

.input-form {
    display: flex;
    gap: 0.5rem;
    max-width: 800px;
    margin: 0 auto;
}

.input-field {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--white);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s ease;
    box-shadow: var(--shadow);
}

.input-field:focus {
    border-color: var(--lake-blue);
    box-shadow: 0 0 0 3px rgba(26, 111, 181, 0.1);
}

.input-field:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.send-btn {
    padding: 0.75rem 1.25rem;
    background: var(--lake-blue);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
    box-shadow: var(--shadow);
    font-family: inherit;
}

.send-btn:hover {
    background: var(--lake-dark);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Live Data Sidebar --- */

.live-panel {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.live-panel summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--lake-dark);
    font-size: 0.82rem;
}

.live-panel-content {
    margin-top: 0.5rem;
    white-space: pre-line;
}

/* --- Community Picker --- */

.picker-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.picker-header {
    text-align: center;
    margin-bottom: 2rem;
}

.picker-header h1 {
    font-size: 1.8rem;
    color: var(--lake-dark);
    margin: 0.75rem 0 0.25rem;
}

.picker-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.picker-logo {
    width: 48px;
    height: 48px;
    font-size: 22px;
    margin: 0 auto;
}

.picker-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    max-width: 720px;
}

.picker-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 220px;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.picker-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--lake-blue);
}

.picker-card-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--lake-dark);
    margin-bottom: 0.4rem;
}

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

/* --- Header Right (switch + live) --- */

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-switch {
    font-size: 0.75rem;
    color: var(--lake-blue);
    text-decoration: none;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: background 0.15s ease;
}

.header-switch:hover {
    background: var(--lake-lighter);
}

.header-share {
    font-size: 0.75rem;
    color: var(--lake-blue);
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease;
}

.header-share:hover {
    background: var(--lake-lighter);
}

/* --- Footer --- */

.footer {
    text-align: center;
    padding: 0.75rem 1rem;
    font-size: 0.72rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    background: var(--white);
}

.footer a {
    color: var(--lake-blue);
    text-decoration: none;
}

/* --- Responsive --- */

@media (max-width: 640px) {
    .header-inner {
        height: 48px;
    }

    .header-subtitle {
        display: none;
    }

    .message {
        max-width: 92%;
    }

    .welcome-card {
        padding: 1rem;
    }

    .welcome-starters {
        flex-direction: column;
    }

    .starter-btn {
        text-align: left;
    }

    .avatar {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .picker-cards {
        flex-direction: column;
        align-items: center;
    }

    .picker-card {
        width: 100%;
        max-width: 320px;
    }
}
