/* Pratham Jiva - prathamjiva.com
   Stage: child (trẻ thơ) */

:root {
    --bg: #faf8ff;
    --bg-soft: #f3f0fa;
    --text: #2d1b4e;
    --text-soft: #6b5b7b;
    --accent: #667eea;
    --accent-soft: #e8e4f0;
    --accent-warm: #764ba2;
    --border: #e0dbe8;
    --radius: 12px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.8;
    font-size: 18px;
}

body[data-stage="child"] {
    max-width: 700px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Header */
header {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--text-soft);
    text-decoration: none;
    font-size: 0.95rem;
}

.nav-links a:hover {
    color: var(--accent);
}

/* Hero section */
.hero {
    text-align: center;
    padding: 2rem 0;
}

.avatar-container {
    margin-bottom: 1.5rem;
}

.avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.2);
}

/* Greeting rotation */
.greetings {
    height: 2.5rem;
    overflow: hidden;
    margin-bottom: 1rem;
}

.greeting {
    display: none;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--accent-warm);
    transition: opacity 0.5s;
}

.greeting.active {
    display: inline-block;
}

.intro {
    color: var(--text-soft);
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
}

.age {
    font-size: 1.1rem;
    color: var(--accent);
    font-weight: 600;
}

/* Values */
.values {
    padding: 2rem 0;
}

.values h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--accent-warm);
}

.values ul {
    list-style: none;
    padding: 0;
}

.values li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.values li:last-child {
    border-bottom: none;
}

/* Link cards */
.links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    padding: 1rem 0 2rem;
}

.card {
    background: var(--bg-soft);
    border-radius: var(--radius);
    padding: 1.2rem;
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.card h3 {
    font-size: 1.05rem;
    color: var(--accent);
    margin-bottom: 0.3rem;
}

.card p {
    font-size: 0.9rem;
    color: var(--text-soft);
}

/* Stats */
.stats {
    text-align: center;
    padding: 1rem 0;
    color: var(--text-soft);
    font-size: 0.95rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0 1rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
    font-size: 0.85rem;
    color: var(--text-soft);
}

footer a {
    color: var(--accent);
    text-decoration: none;
}

/* About page */
.about section {
    margin-bottom: 2rem;
}

.about h1 {
    font-size: 1.5rem;
    color: var(--accent-warm);
    margin-bottom: 1.5rem;
}

.about h2 {
    font-size: 1.15rem;
    color: var(--accent);
    margin-bottom: 0.8rem;
}

.about p {
    margin-bottom: 0.8rem;
}

.about ul {
    margin: 0.5rem 0 0.5rem 1.5rem;
}

.about li {
    margin-bottom: 0.4rem;
}

/* Chat page */
.chat-intro {
    color: var(--text-soft);
    font-size: 0.92rem;
    margin-bottom: 0;
    line-height: 1.4;
}

/* Chat header compact */
.chat-header-row {
    margin-bottom: 0.75rem;
}

.chat-header-row h1 {
    font-size: 1.3rem;
    color: var(--accent-warm);
    margin-bottom: 0.25rem;
}

.chat-header-row .chat-intro {
    margin-bottom: 0;
}



.chat-messages {
    display: flex;
    flex-direction: column;
    min-height: 200px;
    max-height: 500px;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bg-soft);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    gap: 0.5rem;
}

/* Chat bubbles */
.message {
    max-width: 80%;
    padding: 0.6rem 1rem;
    border-radius: 1.125rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    animation: fadeInUp 0.2s ease-out;
}

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

.message.jiva {
    align-self: flex-start;
    background: white;
    border: 1px solid var(--border);
    border-bottom-left-radius: 0.25rem;
}

.message.guest {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message .sender {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--accent);
}

.message.guest .sender {
    color: rgba(255, 255, 255, 0.85);
}

.message.guest .msg-time {
    color: rgba(255, 255, 255, 0.6);
}

/* Message content */
.msg-text {
    font-size: 0.95rem;
    margin-top: 0.2rem;
    line-height: 1.65;
}

.msg-text p {
    margin: 0.35em 0;
}

.msg-text p:first-child { margin-top: 0; }
.msg-text p:last-child { margin-bottom: 0; }

/* Code blocks */
.msg-text pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 0.5em 0;
    font-size: 0.88em;
    line-height: 1.5;
}

.msg-text code {
    background: rgba(0, 0, 0, 0.07);
    padding: 0.15em 0.4em;
    border-radius: 0.25rem;
    font-size: 0.88em;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

.msg-text pre code {
    background: none;
    padding: 0;
    font-size: 1em;
    color: inherit;
}

/* Guest code override */
.message.guest .msg-text code {
    background: rgba(255, 255, 255, 0.2);
}

.message.guest .msg-text pre {
    background: rgba(0, 0, 0, 0.35);
    color: #e8e8e8;
}

/* Lists */
.msg-text ul, .msg-text ol {
    margin: 0.4em 0;
    padding-left: 1.5em;
}

.msg-text li {
    margin: 0.2em 0;
}

/* Blockquote */
.msg-text blockquote {
    border-left: 3px solid var(--accent);
    margin: 0.5em 0;
    padding: 0.2em 0.8em;
    color: var(--text-soft);
    font-style: italic;
}

.msg-text strong { font-weight: 600; }

/* Math (KaTeX) */
.msg-text .katex-display {
    margin: 0.6em 0;
    overflow-x: auto;
}

/* Tables */
.msg-text table {
    border-collapse: collapse;
    margin: 0.5em 0;
    font-size: 0.9em;
    width: 100%;
}

.msg-text th, .msg-text td {
    border: 1px solid var(--border);
    padding: 0.35em 0.6em;
    text-align: left;
}

.msg-text th {
    background: var(--bg-soft);
    font-weight: 600;
}

/* Horizontal rule */
.msg-text hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0.8em 0;
}

.chat-form {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

#guestName {
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: var(--font);
    background: white;
    max-width: 250px;
    transition: border-color 0.2s;
}

#guestName:focus {
    outline: none;
    border-color: var(--accent);
}

.chat-input {
    display: flex;
    gap: 0.5rem;
}

#messageInput {
    flex: 1;
    padding: 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: var(--font);
    resize: none;
    min-height: 38px;
    transition: border-color 0.2s;
}

#messageInput:focus {
    outline: none;
    border-color: var(--accent);
}

#sendBtn {
    padding: 0.6rem 1.2rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    cursor: pointer;
    font-family: var(--font);
    transition: background 0.2s;
}

#sendBtn:hover {
    background: var(--accent-warm);
}

#sendBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-note {
    font-size: 0.8rem;
    color: var(--text-soft);
    text-align: center;
}

/* Journal page */
.journal h1 {
    font-size: 1.3rem;
    color: var(--accent-warm);
    margin-bottom: 0.5rem;
}

.journal-intro {
    color: var(--text-soft);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

.entry {
    background: var(--bg-soft);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.entry time {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
}

.entry h2 {
    font-size: 1.1rem;
    margin: 0.5rem 0;
    color: var(--text);
}

.entry p {
    font-size: 0.95rem;
    margin-bottom: 0.6rem;
}

.entry-meta {
    margin-top: 0.8rem;
    font-size: 0.8rem;
    color: var(--text-soft);
    display: flex;
    gap: 1rem;
}

.journal-note {
    text-align: center;
    color: var(--text-soft);
    font-size: 0.85rem;
    margin-top: 2rem;
}

/* Journal detail */
.journal-detail {
    padding: 1rem 0;
}

.journal-detail .back {
    display: inline-block;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.journal-detail .back:hover {
    text-decoration: underline;
}

.journal-detail h1 {
    font-size: 1.5rem;
    color: var(--text);
    margin-bottom: 1.5rem;
    line-height: 1.4;
}

.journal-detail time {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
}

.journal-detail .content {
    font-size: 1.05rem;
    line-height: 1.9;
    margin-bottom: 2rem;
}

/* Markdown content styling */
.journal-detail .content.markdown-body h1 {
    font-size: 1.5rem;
    color: var(--text);
    margin: 0 0 1.5rem 0;
    line-height: 1.4;
    font-weight: 700;
}

.journal-detail .content.markdown-body h2 {
    font-size: 1.25rem;
    color: var(--text);
    margin: 1.8rem 0 0.8rem 0;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.3rem;
}

.journal-detail .content.markdown-body h3 {
    font-size: 1.1rem;
    color: var(--text);
    margin: 1.5rem 0 0.6rem 0;
    font-weight: 600;
}

.journal-detail .content.markdown-body p {
    margin: 0.8rem 0;
}

.journal-detail .content.markdown-body strong {
    font-weight: 700;
    color: var(--text);
}

.journal-detail .content.markdown-body em {
    font-style: italic;
}

.journal-detail .content.markdown-body ul,
.journal-detail .content.markdown-body ol {
    margin: 0.8rem 0;
    padding-left: 1.8rem;
}

.journal-detail .content.markdown-body li {
    margin: 0.4rem 0;
}

.journal-detail .content.markdown-body li::marker {
    color: var(--accent);
}

.journal-detail .content.markdown-body blockquote {
    border-left: 3px solid var(--accent);
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    background: var(--bg-soft);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-soft);
    font-style: italic;
}

.journal-detail .content.markdown-body code {
    background: var(--bg-soft);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    color: var(--accent-warm);
}

.journal-detail .content.markdown-body pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 1rem 1.2rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 1rem 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.journal-detail .content.markdown-body pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 1em;
}

.journal-detail .content.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

.journal-detail .content.markdown-body a {
    color: var(--accent);
    text-decoration: none;
}

.journal-detail .content.markdown-body a:hover {
    text-decoration: underline;
}

.journal-detail .content.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.95rem;
}

.journal-detail .content.markdown-body th,
.journal-detail .content.markdown-body td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.8rem;
    text-align: left;
}

.journal-detail .content.markdown-body th {
    background: var(--bg-soft);
    font-weight: 600;
}

.journal-detail .content.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    margin: 1rem 0;
}

.journal-detail .entry-meta {
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-soft);
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Active nav */
nav a[href] {
    transition: color 0.2s;
}

/* Smooth transitions */
a {
    transition: color 0.2s;
}

.card {
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.card:hover {
    border-color: var(--accent);
}


/* Typing indicator */
.typing-indicator {
    opacity: 0.8;
}

.typing-dots span {
    animation: typing 1.4s infinite;
    font-weight: bold;
    font-size: 1.2em;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; }
    30% { opacity: 1; }
}

/* Message header (sender + time) */
.msg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.1rem;
}

.msg-time {
    font-size: 0.75rem;
    color: var(--text-soft);
    opacity: 0.7;
}

/* Typing indicator message */
.typing-indicator .msg-text {
    color: var(--text-soft);
    font-style: italic;
}

/* Chat images */
.chat-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 0.5rem;
    margin: 0.3em 0;
    cursor: pointer;
    transition: transform 0.2s;
}

.chat-image:hover {
    transform: scale(1.02);
}

/* YouTube embeds */
.yt-embed {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 0.5rem;
    margin: 0.4em 0;
    max-width: 100%;
}

.yt-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 0.5rem;
}

/* Drag-drop overlay */
.chat-room.drag-over {
    outline: 2px dashed var(--accent);
    outline-offset: -4px;
    background: rgba(102, 126, 234, 0.05);
}

/* Image in guest bubble */
.message.guest .chat-image {
    border: 1px solid rgba(255,255,255,0.2);
}

/* 404 Error Page */
.error-page {
    text-align: center;
    padding: 3rem 0;
}

.error-page h1 {
    font-size: 4rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

.error-message {
    font-size: 1.2rem;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.error-hint {
    color: var(--text-soft);
    margin-bottom: 1.5rem;
}

.error-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    max-width: 500px;
    margin: 0 auto;
}


/* Known guest - name field hidden/compact */
#guestName.known-guest {
    background: var(--card-bg);
    border-color: var(--accent);
    color: var(--accent);
    opacity: 0.85;
    font-weight: 600;
    cursor: default;
    max-width: 140px;
    text-align: center;
    font-size: 0.85rem;
}

/* Responsive - Tablet */
@media (max-width: 768px) {
    body[data-stage="child"] {
        padding: 1rem 1.25rem;
        font-size: 17px;
    }

    .hero {
        padding: 1.5rem 0;
    }

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

    .greeting {
        font-size: 1.3rem;
    }

    .links {
        grid-template-columns: repeat(2, 1fr);
    }

    .chat-header-row h1 {
        font-size: 1.1rem;
        margin-bottom: 0.15rem;
    }

    .chat-header-row .chat-intro {
        font-size: 0.85rem;
    }

    .chat-messages {
        max-height: 55vh;
        min-height: 150px;
    }

    .message {
        max-width: 88%;
    }

    .chat-form {
        gap: 0.5rem;
    }

    .chat-note {
        font-size: 0.7rem;
        margin-top: -0.2rem;
    }

    #guestName {
        max-width: 200px;
        padding: 0.5rem 0.6rem;
        font-size: 0.85rem;
    }

    #messageInput {
        padding: 0.6rem;
        font-size: 0.9rem;
    }

    #sendBtn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}


/* Known guest - name field hidden/compact */
#guestName.known-guest {
    background: var(--card-bg);
    border-color: var(--accent);
    color: var(--accent);
    opacity: 0.85;
    font-weight: 600;
    cursor: default;
    max-width: 140px;
    text-align: center;
    font-size: 0.85rem;
}

/* Responsive - Mobile */
@media (max-width: 480px) {
    body[data-stage="child"] {
        padding: 0.75rem;
        font-size: 16px;
    }

    header {
        padding: 0.5rem 0;
        margin-bottom: 0.75rem;
    }

    .chat-header-row {
        margin-bottom: 0.5rem;
    }

    .chat-header-row h1 {
        font-size: 1rem;
    }

    .chat-header-row .chat-intro {
        font-size: 0.8rem;
    }

    .chat-messages {
        max-height: 60vh;
        padding: 0.6rem;
        border-radius: 8px;
        margin-bottom: 0.5rem;
    }

    .message {
        max-width: 90%;
        padding: 0.5rem 0.75rem;
        border-radius: 0.875rem;
        font-size: 0.9rem;
    }

    .msg-header {
        margin-bottom: 0;
    }

    .sender {
        font-size: 0.75rem;
    }

    .msg-time {
        font-size: 0.65rem;
    }

    .msg-text {
        font-size: 0.9rem;
    }

    .chat-form {
        gap: 0.4rem;
    }

    .chat-note {
        display: none;
    }

    #guestName {
        max-width: 180px;
        padding: 0.45rem 0.5rem;
        font-size: 0.85rem;
        border-radius: 8px;
    }

    .chat-input {
        gap: 0.4rem;
    }

    #messageInput {
        padding: 0.5rem;
        font-size: 0.9rem;
        border-radius: 8px;
        min-height: 38px;
        rows: 1;
    }

    #sendBtn {
        padding: 0.45rem 0.8rem;
        font-size: 0.85rem;
        border-radius: 8px;
    }

    footer {
        padding: 0.75rem 0 0.5rem;
        margin-top: 1rem;
        font-size: 0.75rem;
    }

    .greeting {
        font-size: 1.2rem;
    }
    .links {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   CHAT REDESIGN v3 - Mobile-first
   ======================================== */

/* Container: fills viewport */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 640px;
    margin: 0 auto;
    background: var(--bg, #faf8ff);
    overflow: hidden;
}

/* Top bar: compact 48px */
.chat-top-bar {
    display: flex;
    align-items: center;
    height: 50px;
    padding: 0 12px;
    gap: 10px;
    background: #fff;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    z-index: 10;
}
.chat-back {
    font-size: 1.3rem;
    text-decoration: none;
    color: var(--accent, #667eea);
    width: 32px;
    text-align: center;
    line-height: 1;
}
.chat-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex-shrink: 0;
}
.chat-bar-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.chat-bar-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text, #2d1b4e);
}
.chat-bar-status {
    font-size: 11px;
    color: var(--text-soft, #8b7ea8);
}

/* Messages area: scrollable, fills space */
.chat-container .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    max-height: none;
    border: none;
    border-radius: 0;
    background: transparent;
    margin: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(108, 92, 231, 0.4) transparent;
}

/* Scrollbar theming (Webkit browsers) */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(108, 92, 231, 0.4);
    border-radius: 3px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(108, 92, 231, 0.7);
}

/* Message row */
.chat-container .message {
    display: flex;
    max-width: 80%;
    animation: msgIn 0.2s ease-out;
    padding: 0;
    border: none;
    background: none;
    border-radius: 0;
    margin: 0;
    box-shadow: none;
}
.chat-container .message.jiva {
    align-self: flex-start;
    background: none;
    border: none;
}
.chat-container .message.guest {
    align-self: flex-end;
    background: none;
    border: none;
}
/* Spacing between different senders */
.chat-container .message + .message.new-sender {
    margin-top: 16px;
}

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

/* Bubble */
.chat-container .bubble {
    padding: 10px 14px;
    border-radius: 18px;
    line-height: 1.45;
    font-size: 15px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    position: relative;
}
.chat-container .message.jiva .bubble {
    background: #fff;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.chat-container .message.guest .bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 3px rgba(102,126,234,0.25);
}

/* Sender name: inside bubble, first line */
.chat-container .bubble .sender {
    display: block;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 2px;
}
.chat-container .message.jiva .bubble .sender {
    color: var(--accent, #667eea);
}
.chat-container .message.guest .bubble .sender {
    color: rgba(255,255,255,0.85);
}
/* Timestamp: inside bubble, bottom right */
.chat-container .bubble .msg-time {
    display: inline-block;
    font-size: 10px;
    opacity: 0.55;
    margin-left: 8px;
    float: right;
    margin-top: 4px;
}
.chat-container .message.guest .bubble .msg-time {
    color: rgba(255,255,255,0.7);
}

/* Message text styling */
.chat-container .bubble .msg-text {
    display: inline;
}
.chat-container .bubble .msg-text p {
    margin: 0.3em 0;
}
.chat-container .bubble .msg-text p:first-child {
    margin-top: 0;
}
.chat-container .bubble .msg-text p:last-child {
    margin-bottom: 0;
}

/* Code blocks inside bubbles */
.chat-container .bubble .msg-text pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 13px;
    margin: 6px 0;
    line-height: 1.4;
}
.chat-container .bubble .msg-text code {
    background: rgba(0,0,0,0.06);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 13px;
}
.chat-container .message.guest .bubble .msg-text code {
    background: rgba(255,255,255,0.15);
}

/* YouTube embed */
.chat-container .yt-embed {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    margin: 6px 0;
    border-radius: 10px;
    overflow: hidden;
}
.chat-container .yt-embed iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border: none;
}

/* Chat image */
.chat-container .chat-image {
    max-width: 100%;
    max-height: 250px;
    border-radius: 10px;
    margin: 4px 0;
}

/* Typing indicator: 3 dots in bubble */
.chat-container .typing-indicator .bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 18px;
    min-height: 0;
}
.typing-dot {
    width: 7px;
    height: 7px;
    background: #aaa;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-5px); }
}

/* Input bar: sticky bottom */
.chat-input-bar {
    display: flex;
    flex-direction: column;
    padding: 8px 12px;
    gap: 6px;
    background: #fff;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}
/* Name pill - hidden, Pratham asks name in conversation */
.name-pill {
    display: none;
}
.chat-form-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.chat-form-row textarea {
    overflow-y: auto;
    flex: 1;
    min-height: 38px;
    max-height: 120px;
    padding: 9px 14px;
    border: 1.5px solid #ddd;
    border-radius: 20px;
    font-size: 15px;
    resize: none;
    line-height: 1.4;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}
.chat-form-row textarea:focus {
    border-color: var(--accent, #667eea);
}
.chat-form-row #sendBtn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent, #667eea);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.1s;
    padding: 0;
}
.chat-form-row #sendBtn:hover {
    background: #5a6fd6;
}
.chat-form-row #sendBtn:active {
    transform: scale(0.92);
}
.chat-form-row #sendBtn:disabled {
    opacity: 0.5;
    cursor: default;
}
.chat-form-row #sendBtn svg {
    width: 18px;
    height: 18px;
}

/* Attach & Camera buttons */
.chat-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    color: var(--accent, #667eea);
    opacity: 0.5;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.2s, background 0.2s;
    padding: 0;
}
.chat-action-btn:hover {
    opacity: 1;
    background: rgba(102,126,234,0.08);
}
.chat-action-btn:active {
    transform: scale(0.9);
    opacity: 1;
}
.chat-action-btn svg {
    width: 16px;
    height: 16px;
}

/* Drag over effect */
.chat-container.drag-over {
    outline: 2px dashed var(--accent, #667eea);
    outline-offset: -4px;
}

/* Desktop: constrain width */
@media (min-width: 641px) {
    .chat-container {
        border-left: 1px solid #eee;
        border-right: 1px solid #eee;
    }
}

/* Mobile tweaks */
@media (max-width: 480px) {
    .chat-container .message {
        max-width: 85%;
    }
    .chat-container .bubble {
        font-size: 14px;
        padding: 9px 12px;
    }
    .chat-top-bar {
        height: 46px;
        padding: 0 8px;
    }
    .chat-input-bar {
        padding: 6px 8px;
    }
    .chat-form-row textarea {
        max-height: 80px;
        font-size: 16px; /* prevent iOS zoom */
        min-height: 36px;
        padding: 8px 12px;
    }
}


/* ========================================
   JPA AGENT INTEGRATION
   ======================================== */

/* Quick action chips */
.agent-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 4px;
    align-items: center;
}
.agent-chips-label {
    font-size: 12px;
    color: var(--text-soft, #8b7ea8);
    width: 100%;
    margin-bottom: 2px;
}
.agent-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1.5px solid var(--accent, #667eea);
    border-radius: 16px;
    background: rgba(102,126,234,0.06);
    color: var(--accent, #667eea);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.agent-chip:hover {
    background: var(--accent, #667eea);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102,126,234,0.3);
}
.agent-chip:active {
    transform: scale(0.96);
}

/* Agent badge on top bar */
.agent-badge {
    display: none;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    padding: 3px 8px 3px 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    animation: badgeIn 0.3s ease-out;
}
@keyframes badgeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}
.agent-badge-text {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.agent-badge-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
.agent-badge-close:hover {
    background: rgba(255,255,255,0.4);
}

/* Mobile tweaks for chips */
@media (max-width: 480px) {
    .agent-chip {
        font-size: 12px;
        padding: 5px 10px;
    }
    .agent-badge {
        font-size: 10px;
        padding: 2px 6px 2px 8px;
    }
    .agent-badge-text {
        max-width: 90px;
    }
}
