/* ============================================================
   LAWBOT — Pakistan Legal AI  |  style.css  v2.0
   Dark/Light • All 12 features
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=IBM+Plex+Sans:wght@300;400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ── Dark Mode (default) ── */
:root {
    --bg-deep: #0a0c0f;
    --bg-panel: #0f1318;
    --bg-card: #141a22;
    --bg-input: #1a2230;
    --bg-hover: #1e2a3a;
    --border-subtle: #1f2d3d;
    --border-mid: #2a3f57;
    --border-accent: #c9a84c;
    --gold: #c9a84c;
    --gold-light: #e8c97a;
    --gold-dim: #8a6e2f;
    --emerald: #2ecc71;
    --emerald-dim: #1a7a44;
    --red-alert: #e74c3c;
    --text-primary: #e8e4da;
    --text-secondary: #8fa3b8;
    --text-muted: #4a6070;
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(201, 168, 76, 0.12);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 14px;
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'IBM Plex Sans', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
    --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    /* law card palette */
    --ppc-bg: rgba(59, 130, 246, 0.09);
    --ppc-border: rgba(59, 130, 246, 0.38);
    --ppc-text: #7db9f5;
    --crpc-bg: rgba(34, 197, 94, 0.09);
    --crpc-border: rgba(34, 197, 94, 0.38);
    --crpc-text: #6ee7a0;
    --peca-bg: rgba(168, 85, 247, 0.09);
    --peca-border: rgba(168, 85, 247, 0.38);
    --peca-text: #c4a0f7;
}

/* ── Light Mode — Warm Beige ── */
body.light-mode {
    --bg-deep: #f5f0e8;
    --bg-panel: #faf7f2;
    --bg-card: #fff8ee;
    --bg-input: #faf7f2;
    --bg-hover: #ede5d8;
    --border-subtle: #e2d9cc;
    --border-mid: #c8b99a;
    --border-accent: #c9a84c;
    --text-primary: #2c2416;
    --text-secondary: #5a4e3a;
    --text-muted: #9e8e74;
    --shadow-card: 0 2px 16px rgba(100, 70, 20, 0.10);
    --shadow-glow: 0 0 20px rgba(201, 168, 76, 0.18);
    --ppc-bg: rgba(37, 99, 235, 0.07);
    --ppc-border: rgba(37, 99, 235, 0.22);
    --ppc-text: #1e40af;
    --crpc-bg: rgba(22, 163, 74, 0.07);
    --crpc-border: rgba(22, 163, 74, 0.22);
    --crpc-text: #15803d;
    --peca-bg: rgba(126, 34, 206, 0.07);
    --peca-border: rgba(126, 34, 206, 0.22);
    --peca-text: #6d28d9;
}

/* Light mode specific overrides — Warm Beige */
body.light-mode .navbar {
    background: #faf7f2;
    border-bottom: 1px solid #e2d9cc;
    box-shadow: 0 1px 8px rgba(100, 70, 20, 0.06);
}

body.light-mode .sidebar {
    background: #faf7f2;
    box-shadow: 2px 0 8px rgba(100, 70, 20, 0.05);
}

body.light-mode .chat-main {
    background: #f5f0e8;
}

body.light-mode .message.bot .message-bubble {
    background: #fff8ee;
    border-color: #e2d9cc;
    box-shadow: 0 1px 4px rgba(100, 70, 20, 0.06);
}

body.light-mode .message.user .message-bubble {
    background: linear-gradient(135deg, #7a5c2e, #c9a84c);
    border-color: #c9a84c;
    color: #fff;
}

body.light-mode .input-wrapper {
    background: #fff8ee;
    border-color: #c8b99a;
}

body.light-mode .input-wrapper:focus-within {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.15);
}

body.light-mode .chat-input-area {
    background: #faf7f2;
    border-top-color: #e2d9cc;
}

body.light-mode .btn-new-chat {
    background: linear-gradient(135deg, rgba(201, 168, 76, 0.18), rgba(201, 168, 76, 0.08));
    border-color: var(--gold-dim);
}

body.light-mode .hero-emblem {
    background: linear-gradient(135deg, rgba(201, 168, 76, 0.25), rgba(201, 168, 76, 0.10));
    border-color: rgba(201, 168, 76, 0.4);
}

body.light-mode .quick-prompt-btn {
    background: #fff8ee;
    border-color: #e2d9cc;
    box-shadow: 0 1px 4px rgba(100, 70, 20, 0.06);
}

body.light-mode .quick-prompt-btn:hover {
    background: #ede5d8;
    border-color: var(--gold-dim);
    box-shadow: 0 4px 16px rgba(201, 168, 76, 0.2);
}

body.light-mode .btn-send {
    box-shadow: 0 2px 8px rgba(201, 168, 76, 0.3);
}

body.light-mode .status-dot {
    background: #16a34a;
    box-shadow: 0 0 6px #16a34a;
}

body.light-mode .typing-dot {
    background: var(--gold-dim);
}

body.light-mode .modal-box {
    background: #fff8ee;
    border-color: #c8b99a;
}

body.light-mode .modal-select,
body.light-mode .modal-textarea {
    background: #faf7f2;
    border-color: #c8b99a;
    color: #2c2416;
}

body.light-mode .about-stat {
    background: #f5f0e8;
    border-color: #e2d9cc;
}

body.light-mode .toast {
    background: #fff8ee;
    border-color: #c8b99a;
}

body.light-mode .disclaimer-box {
    background: rgba(201, 168, 76, 0.08);
    border-color: rgba(201, 168, 76, 0.2);
}

body.light-mode .btn-nav-icon {
    background: #fff8ee;
    border-color: #c8b99a;
}

/* ── Reset ── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0
}

html {
    scroll-behavior: smooth;
    font-size: 16px
}

body {
    font-family: var(--font-body);
    background: var(--bg-deep);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    overflow: hidden;
    transition: background .3s, color .3s;
}

::-webkit-scrollbar {
    width: 6px
}

::-webkit-scrollbar-track {
    background: var(--bg-deep)
}

::-webkit-scrollbar-thumb {
    background: var(--border-mid);
    border-radius: 3px
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gold-dim)
}

::selection {
    background: rgba(201, 168, 76, .25);
    color: var(--gold-light)
}

/* ══════════════════ NAVBAR ══════════════════ */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 64px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px)
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    text-decoration: none
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--gold), var(--gold-dim));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0
}

.brand-name {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary)
}

.brand-name span {
    color: var(--gold)
}

.navbar-tagline {
    font-size: .7rem;
    color: var(--text-muted);
    letter-spacing: .12em;
    text-transform: uppercase;
    font-weight: 500;
    border-left: 1px solid var(--border-mid);
    padding-left: .75rem;
    margin-left: .25rem
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: .5rem
}

.status-pill {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .3rem .75rem;
    border: 1px solid var(--border-subtle);
    border-radius: 100px;
    font-size: .72rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: .05em
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--emerald);
    box-shadow: 0 0 6px var(--emerald);
    animation: pulse-green 2.5s ease-in-out infinite
}

@keyframes pulse-green {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: .45
    }
}

/* Navbar icon buttons */
.btn-nav-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-mid);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--transition)
}

.btn-nav-icon:hover {
    background: var(--bg-hover);
    color: var(--gold-light);
    border-color: var(--gold-dim)
}

/* ══════════════════ LAYOUT ══════════════════ */
.app-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    flex: 1;
    height: calc(100vh - 64px);
    height: calc(100dvh - 64px);
    overflow: hidden;
    position: relative;
    min-height: 0;
}

/* ══════════════════ SIDEBAR ══════════════════ */
.sidebar {
    background: var(--bg-panel);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
    min-width: 260px;
    width: 260px;
    align-self: stretch;
    transition: width 0.3s ease, min-width 0.3s ease;
}

.sidebar-section {
    padding: 1.25rem 1rem .5rem
}

.sidebar-label {
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: .75rem;
    padding: 0 .25rem
}

.btn-new-chat {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    padding: .65rem .85rem;
    background: linear-gradient(135deg, rgba(201, 168, 76, .12), rgba(201, 168, 76, .05));
    border: 1px solid var(--gold-dim);
    border-radius: var(--radius-md);
    color: var(--gold-light);
    font-family: var(--font-body);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: left
}

.btn-new-chat:hover {
    background: linear-gradient(135deg, rgba(201, 168, 76, .2), rgba(201, 168, 76, .1));
    border-color: var(--gold);
    box-shadow: var(--shadow-glow)
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: .5rem 1rem;
    min-height: 0;
}

.history-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .6rem .75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    font-size: .82rem;
    border: 1px solid transparent;
    margin-bottom: 2px;
    width: 100%;
    background: none;
    font-family: var(--font-body);
    text-align: left
}

.history-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-subtle)
}

.history-item.active {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-mid)
}

.history-item-icon {
    font-size: .85rem;
    flex-shrink: 0;
    opacity: .6
}

.history-item-text {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1
}

.history-title {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    font-size: .82rem;
    color: var(--text-secondary)
}

.history-meta {
    font-size: .68rem;
    color: var(--text-muted);
    font-family: var(--font-mono)
}

.btn-export {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    padding: .55rem .85rem;
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: .82rem;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    margin-top: 4px
}

.btn-export:hover {
    background: var(--bg-hover);
    border-color: var(--gold-dim);
    color: var(--gold-light)
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-subtle);
    margin-top: auto;
}

.disclaimer-box {
    background: rgba(231, 76, 60, 0.06);
    border: 1px solid rgba(231, 76, 60, 0.2);
    border-radius: var(--radius-md);
    padding: .75rem;
    font-size: .72rem;
    color: var(--text-muted);
    line-height: 1.5
}

.disclaimer-box strong {
    color: #e74c3c;
    display: block;
    margin-bottom: .25rem;
    font-size: .68rem;
    letter-spacing: .08em;
    text-transform: uppercase
}

/* ══════════════════ CHAT MAIN ══════════════════ */
.chat-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
    background: var(--bg-deep);
    position: relative;
    min-height: 0;
    flex: 1;
}

.chat-main::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(201, 168, 76, .02) 1px, transparent 1px), linear-gradient(90deg, rgba(201, 168, 76, .02) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
    z-index: 0
}

body.light-mode .chat-main::before {
    background-image: none
}

/* ── Hero ── */
.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 2rem 1rem 1rem;
    text-align: center;
    position: relative;
    z-index: 1;
    overflow-y: auto;
}

.hero-emblem {
    width: 48px;
    height: 48px;
    margin: 0 auto 0.75rem;
    background: linear-gradient(135deg, rgba(201, 168, 76, .15), rgba(201, 168, 76, .05));
    border: 1px solid rgba(201, 168, 76, .3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    animation: float 4s ease-in-out infinite
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0)
    }

    50% {
        transform: translateY(-6px)
    }
}

.hero-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: .5rem
}

.hero-title span {
    color: var(--gold)
}

.hero-subtitle {
    font-size: .82rem;
    color: var(--text-secondary);
    max-width: 400px;
    line-height: 1.5;
    margin-bottom: 1rem
}

.quick-prompts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .5rem;
    max-width: 520px;
    width: 100%
}

.quick-prompt-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: .6rem .85rem;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: .82rem;
    line-height: 1.4
}

.quick-prompt-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-mid);
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card)
}

.quick-prompt-icon {
    font-size: 1.1rem;
    display: block;
    margin-bottom: .4rem
}

.quick-prompt-text {
    font-weight: 500;
    color: var(--text-primary);
    display: block;
    margin-bottom: .2rem;
    font-size: .84rem
}

.quick-prompt-desc {
    font-size: .76rem;
    color: var(--text-muted)
}

/* ── Messages ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: relative;
    z-index: 1;
    min-height: 0;
}

.message {
    display: flex;
    gap: .875rem;
    animation: msg-in .3s ease both
}

@keyframes msg-in {
    from {
        opacity: 0;
        transform: translateY(8px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

.message-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    margin-top: 2px
}

.message.bot .message-avatar {
    background: linear-gradient(135deg, var(--gold-dim), rgba(201, 168, 76, .4));
    border: 1px solid rgba(201, 168, 76, .3)
}

.message.user {
    flex-direction: row-reverse
}

.message.user .message-avatar {
    background: var(--bg-card);
    border: 1px solid var(--border-mid);
    color: var(--text-secondary)
}

.message-content {
    max-width: 72%
}

.message.user .message-content {
    align-items: flex-end;
    display: flex;
    flex-direction: column
}

.message-bubble {
    padding: .875rem 1.1rem;
    border-radius: var(--radius-lg);
    font-size: .9rem;
    line-height: 1.65
}

.message.bot .message-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-top-left-radius: var(--radius-sm)
}

.message.user .message-bubble {
    background: linear-gradient(135deg, rgba(201, 168, 76, .15), rgba(201, 168, 76, .08));
    border: 1px solid rgba(201, 168, 76, .25);
    color: var(--text-primary);
    border-top-right-radius: var(--radius-sm)
}

/* bot rich text */
.message.bot .message-bubble p {
    margin-bottom: .6rem
}

.message.bot .message-bubble p:last-child {
    margin-bottom: 0
}

.message.bot .message-bubble ul,
.message.bot .message-bubble ol {
    padding-left: 1.25rem;
    margin: .5rem 0
}

.message.bot .message-bubble li {
    margin-bottom: .3rem
}

.message.bot .message-bubble strong {
    color: var(--gold-light);
    font-weight: 600
}

.message.bot .message-bubble .section-ref {
    display: inline-block;
    background: rgba(201, 168, 76, .1);
    border: 1px solid rgba(201, 168, 76, .25);
    border-radius: var(--radius-sm);
    padding: .1rem .5rem;
    font-family: var(--font-mono);
    font-size: .78rem;
    color: var(--gold);
    margin: 0 .1rem
}

.message.bot .message-bubble blockquote {
    border-left: 3px solid var(--gold-dim);
    padding-left: .875rem;
    margin: .75rem 0;
    color: var(--text-secondary);
    font-style: italic
}

/* ── Message meta row ── */
.message-meta {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: .35rem;
    padding: 0 .25rem;
    font-family: var(--font-mono);
    flex-wrap: wrap
}

/* Language badge */
.lang-badge {
    display: inline-flex;
    align-items: center;
    padding: .1rem .45rem;
    border-radius: 100px;
    font-size: .62rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    border: 1px solid
}

.lang-badge.en {
    background: rgba(59, 130, 246, .12);
    border-color: rgba(59, 130, 246, .38);
    color: #7db9f5
}

.lang-badge.ur {
    background: rgba(34, 197, 94, .12);
    border-color: rgba(34, 197, 94, .38);
    color: #6ee7a0
}

.lang-badge.mix {
    background: rgba(251, 191, 36, .12);
    border-color: rgba(251, 191, 36, .38);
    color: #fbbf24
}

/* Response time */
.resp-time {
    font-size: .65rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    opacity: .75
}

.resp-time::before {
    content: "⏱ "
}

/* Copy button */
.btn-copy {
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: .15rem .5rem;
    color: var(--text-muted);
    font-size: .7rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-body);
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    margin-left: auto
}

.btn-copy:hover {
    background: var(--bg-hover);
    color: var(--gold-light);
    border-color: var(--gold-dim)
}

.btn-copy.copied {
    color: var(--emerald);
    border-color: var(--emerald-dim)
}

/* Speaker button */
.btn-speak {
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: .15rem .5rem;
    color: var(--text-muted);
    font-size: .75rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-body);
    display: inline-flex;
    align-items: center;
}

.btn-speak:hover {
    background: var(--bg-hover);
    color: var(--gold-light);
    border-color: var(--gold-dim);
}

.btn-speak.speaking {
    color: var(--red-alert);
    border-color: var(--red-alert);
    background: rgba(231, 76, 60, .08);
    animation: pulse-speak 1s ease-in-out infinite;
}

@keyframes pulse-speak {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ── Confidence bar ── */
.confidence-block {
    margin-top: .65rem;
    padding: 0 .1rem
}

.confidence-label {
    font-size: .67rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-bottom: .3rem;
    display: flex;
    justify-content: space-between
}

.confidence-label .conf-val {
    color: var(--gold);
    font-weight: 600
}

.confidence-track {
    height: 4px;
    background: var(--border-subtle);
    border-radius: 2px;
    overflow: hidden
}

.confidence-fill {
    height: 100%;
    border-radius: 2px;
    transition: width .7s cubic-bezier(.4, 0, .2, 1)
}

.confidence-fill.high {
    background: linear-gradient(90deg, var(--emerald-dim), var(--emerald))
}

.confidence-fill.medium {
    background: linear-gradient(90deg, var(--gold-dim), var(--gold))
}

.confidence-fill.low {
    background: linear-gradient(90deg, #7a3a2f, var(--red-alert))
}

/* ── Law section cards ── */
.law-cards {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .75rem
}

.law-card {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .8rem;
    border-radius: var(--radius-md);
    font-size: .75rem;
    font-weight: 600;
    font-family: var(--font-mono);
    border: 1px solid;
    letter-spacing: .03em;
    cursor: default;
    transition: var(--transition)
}

.law-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-card)
}

.law-card.ppc {
    background: var(--ppc-bg);
    border-color: var(--ppc-border);
    color: var(--ppc-text)
}

.law-card.crpc {
    background: var(--crpc-bg);
    border-color: var(--crpc-border);
    color: var(--crpc-text)
}

.law-card.peca {
    background: var(--peca-bg);
    border-color: var(--peca-border);
    color: var(--peca-text)
}

.law-card.other {
    background: rgba(201, 168, 76, .08);
    border-color: rgba(201, 168, 76, .3);
    color: var(--gold)
}

/* ── Feedback ── */
.feedback-row {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-top: .55rem;
    padding: 0 .1rem
}

.feedback-label {
    font-size: .67rem;
    color: var(--text-muted);
    margin-right: .1rem
}

.btn-feedback {
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: .22rem .6rem;
    font-size: .82rem;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
    line-height: 1
}

.btn-feedback:hover {
    background: var(--bg-hover);
    transform: scale(1.12)
}

.btn-feedback.liked {
    background: rgba(46, 204, 113, .12);
    border-color: var(--emerald-dim);
    color: var(--emerald)
}

.btn-feedback.disliked {
    background: rgba(231, 76, 60, .12);
    border-color: #7a3a2f;
    color: var(--red-alert)
}

.btn-feedback:disabled {
    cursor: default;
    opacity: .5
}

/* ── Sources ── */
.sources-block {
    margin-top: .75rem;
    padding: .75rem;
    background: rgba(201, 168, 76, .04);
    border: 1px solid rgba(201, 168, 76, .12);
    border-radius: var(--radius-md)
}

.sources-title {
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--gold-dim);
    margin-bottom: .5rem
}

.source-tag {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .6rem;
    background: rgba(201, 168, 76, .08);
    border: 1px solid rgba(201, 168, 76, .2);
    border-radius: var(--radius-sm);
    font-size: .73rem;
    color: var(--text-secondary);
    margin: .2rem .25rem .2rem 0;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-mono)
}

.source-tag:hover {
    background: rgba(201, 168, 76, .15);
    color: var(--gold-light)
}

/* ── Typing ── */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: .875rem 1.1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    border-top-left-radius: var(--radius-sm);
    width: fit-content
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gold-dim);
    animation: bounce 1.2s ease-in-out infinite
}

.typing-dot:nth-child(2) {
    animation-delay: .2s
}

.typing-dot:nth-child(3) {
    animation-delay: .4s
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: .4
    }

    40% {
        transform: translateY(-6px);
        opacity: 1
    }
}

/* ══════════════════ TOOLBAR ══════════════════ */
.chat-toolbar {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 2rem;
    border-top: 1px solid var(--border-subtle);
    overflow-x: auto;
    position: relative;
    z-index: 1
}

.chat-toolbar::-webkit-scrollbar {
    height: 0
}

.category-tab {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .85rem;
    border-radius: 100px;
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: .78rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-weight: 500
}

.category-tab:hover {
    background: var(--bg-hover);
    color: var(--text-secondary)
}

.category-tab.active {
    background: rgba(201, 168, 76, .1);
    border-color: var(--gold-dim);
    color: var(--gold-light)
}

/* ══════════════════ INPUT AREA ══════════════════ */
.chat-input-area {
    padding: 0.875rem 1.5rem 1rem;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-panel);
    flex-shrink: 0;
    z-index: 10;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: .75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-lg);
    padding: .75rem .75rem .75rem 1.1rem;
    transition: var(--transition)
}

.input-wrapper:focus-within {
    border-color: var(--gold-dim);
    box-shadow: 0 0 0 3px rgba(201, 168, 76, .08), var(--shadow-glow)
}

#user-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: .9rem;
    line-height: 1.55;
    resize: none;
    max-height: 160px;
    overflow-y: auto;
    min-height: 22px
}

#user-input::placeholder {
    color: var(--text-muted)
}

.input-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0
}

.btn-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: var(--transition)
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
    border-color: var(--border-subtle)
}

/* ── Send button + spinner ── */
.btn-send {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    border: none;
    background: linear-gradient(135deg, var(--gold), var(--gold-dim));
    color: #0a0c0f;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--transition);
    flex-shrink: 0;
    position: relative;
    overflow: hidden
}

.btn-send:hover:not(:disabled) {
    transform: scale(1.06);
    box-shadow: 0 4px 16px rgba(201, 168, 76, .35)
}

.btn-send:disabled {
    opacity: .35;
    cursor: not-allowed
}

.send-icon {
    transition: opacity .15s;
    position: relative;
    z-index: 1
}

.send-spinner {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center
}

.btn-send.loading .send-icon {
    opacity: 0
}

.btn-send.loading .send-spinner {
    display: flex
}

.btn-send.loading {
    cursor: not-allowed
}

@keyframes spin {
    to {
        transform: rotate(360deg)
    }
}

.spinner-ring {
    animation: spin .75s linear infinite;
    transform-origin: center
}

.input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: .6rem;
    padding: 0 .25rem
}

.input-hint {
    display: none
}

.input-hint kbd {
    display: inline-block;
    padding: .1rem .3rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: .65rem
}

.char-count {
    font-size: .68rem;
    color: var(--text-muted);
    font-family: var(--font-mono)
}

.char-count.warning {
    color: var(--gold-dim)
}

.char-count.danger {
    color: var(--red-alert)
}

/* ══════════════════ SCROLL TO TOP ══════════════════ */
.scroll-top-btn {
    position: fixed;
    bottom: 5.5rem;
    right: 1.5rem;
    z-index: 50;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-mid);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: var(--shadow-card);
    transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.3s ease;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none
}

.scroll-top-btn.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all
}

.scroll-top-btn:hover {
    background: var(--bg-hover);
    border-color: var(--gold-dim);
    color: var(--gold-light)
}

/* ══════════════════ MODALS ══════════════════ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .72);
    backdrop-filter: blur(6px)
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: min(520px, 90vw);
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-card);
    animation: msg-in .25s ease both
}

.modal-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--gold-light);
    margin-bottom: 1.25rem
}

.modal-field-label {
    font-size: .78rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: .35rem;
    letter-spacing: .06em;
    text-transform: uppercase
}

.modal-select,
.modal-textarea {
    width: 100%;
    padding: .6rem .875rem;
    background: var(--bg-input);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: .875rem;
    outline: none;
    transition: var(--transition)
}

.modal-select:focus,
.modal-textarea:focus {
    border-color: var(--gold-dim);
    box-shadow: 0 0 0 2px rgba(201, 168, 76, .1)
}

.modal-textarea {
    resize: vertical;
    min-height: 90px;
    line-height: 1.55
}

.modal-actions {
    display: flex;
    gap: .75rem;
    margin-top: 1.5rem;
    justify-content: flex-end
}

.modal-field {
    margin-bottom: .875rem
}

/* About modal */
.about-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
    margin: 1rem 0
}

.about-stat {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: .75rem;
    text-align: center
}

.about-stat-val {
    font-family: var(--font-display);
    font-size: 1.4rem;
    color: var(--gold);
    font-weight: 700
}

.about-stat-key {
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: .2rem;
    text-transform: uppercase;
    letter-spacing: .08em
}

.about-tech-tag {
    display: inline-block;
    padding: .25rem .65rem;
    background: rgba(201, 168, 76, .08);
    border: 1px solid rgba(201, 168, 76, .2);
    border-radius: var(--radius-sm);
    font-size: .75rem;
    color: var(--gold);
    margin: .2rem;
    font-family: var(--font-mono)
}

.about-desc {
    font-size: .85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: .75rem
}

/* ══════════════════ TOAST ══════════════════ */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 1.5rem;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: .5rem
}

.toast {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: .83rem;
    box-shadow: var(--shadow-card);
    animation: toast-in .3s ease both;
    max-width: 300px
}

.toast.success {
    border-left: 3px solid var(--emerald)
}

.toast.error {
    border-left: 3px solid var(--red-alert)
}

.toast.info {
    border-left: 3px solid var(--gold-dim)
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(20px)
    }

    to {
        opacity: 1;
        transform: translateX(0)
    }
}

/* ══════════════════ UTILITY ══════════════════ */
.hidden {
    display: none !important
}

.divider {
    height: 1px;
    background: var(--border-subtle);
    margin: .75rem 0
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem 1.25rem;
    background: linear-gradient(135deg, var(--gold), var(--gold-dim));
    border: none;
    border-radius: var(--radius-md);
    color: #0a0c0f;
    font-family: var(--font-body);
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: .02em
}

.btn-primary:hover {
    box-shadow: 0 4px 20px rgba(201, 168, 76, .35);
    transform: translateY(-1px)
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem 1.1rem;
    background: transparent;
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: .85rem;
    cursor: pointer;
    transition: var(--transition)
}

.btn-ghost:hover {
    background: var(--bg-hover);
    border-color: var(--border-accent);
    color: var(--text-primary)
}

/* ══════════════════ RESPONSIVE ══════════════════ */
@media(max-width:768px) {

    /* Layout */
    .app-container {
        grid-template-columns: 1fr;
        height: calc(100vh - 56px);
        height: calc(100dvh - 56px);
    }

    .chat-empty {
        justify-content: flex-start;
        padding-top: 1.5rem;
        overflow-y: auto;
    }

    /* Navbar */
    .navbar {
        height: 56px;
        padding: 0 1rem;
    }

    .navbar-tagline {
        display: none;
    }

    .brand-name {
        font-size: 1.1rem;
    }

    /* Hide status pill on mobile to save navbar space */
    .status-pill {
        display: none;
    }

    /* Show hamburger button */
    #sidebar-toggle {
        display: flex !important;
    }

    /* Hide desktop sidebar toggle */
    .btn-sidebar-toggle {
        display: none !important;
    }

    /* Sidebar hidden by default on mobile */
    .sidebar {
        display: none;
        min-width: unset;
        width: 80vw !important;
    }

    /* Sidebar drawer when open */
    .sidebar.open {
        display: flex;
        position: fixed;
        top: 56px;
        left: 0;
        bottom: 0;
        z-index: 200;
        width: 80vw !important;
        max-width: 300px;
        box-shadow: 4px 0 30px rgba(0, 0, 0, 0.5);
        overflow-y: auto;
    }

    /* Overlay when sidebar open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 56px 0 0 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 199;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Chat */
    .chat-main {
        height: calc(100vh - 56px);
        height: calc(100dvh - 56px);
    }

    .chat-messages {
        padding: 0.75rem 0.75rem;
    }

    .chat-input-area {
        padding: 0.5rem 0.75rem 0.75rem;
    }

    /* Messages */
    .message-content {
        max-width: 88%;
    }

    .message-bubble {
        font-size: .85rem;
        padding: .6rem .85rem;
    }

    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    /* Hero */
    .hero-title {
        font-size: 1.3rem;
    }

    .hero-subtitle {
        font-size: .78rem;
    }

    .hero-emblem {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .quick-prompts {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }

    .quick-prompt-btn {
        padding: .5rem .75rem;
    }

    /* Input */
    .char-count {
        display: none;
    }

    /* Modals */
    .modal-box {
        width: 95vw;
        padding: 1.25rem;
    }

    .about-grid {
        grid-template-columns: 1fr;
    }

    /* Scroll top — higher up on mobile, closer to edge */
    .scroll-top-btn {
        right: .75rem;
        bottom: 5rem;
    }
}

/* ── Better brand icon ── */
.brand-icon {
    background: linear-gradient(135deg, #c9a84c 0%, #8a6e2f 100%);
    box-shadow: 0 2px 12px rgba(201, 168, 76, 0.35);
}

/* ── Sidebar always fixed, history scrolls ── */
.sidebar-section {
    flex-shrink: 0;
}

.sidebar-footer {
    flex-shrink: 0;
}

/* ── Remove toolbar/quick-actions if somehow present ── */
.chat-toolbar {
    display: none !important;
}

.quick-actions {
    display: none !important;
}

/* ── Smooth theme transition — only on specific properties, not * ── */
body,
.navbar,
.sidebar,
.chat-main,
.modal-box,
.input-wrapper,
.btn-nav-icon,
.btn-new-chat,
.history-item,
.quick-prompt-btn,
.message-bubble,
.toast,
.about-stat {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.25s ease, box-shadow 0.3s ease;
}

.btn-send,
.typing-dot,
.confidence-fill,
.status-dot {
    transition: all 0.3s ease !important;
}

@media(max-width:480px) {
    .sidebar-section {
        padding: 0.75rem 0.75rem 0.35rem;
    }

    .btn-new-chat {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .history-item {
        padding: 0.45rem 0.6rem;
        font-size: 0.78rem;
    }

    .sidebar-label {
        font-size: 0.6rem;
    }

    .disclaimer-box {
        font-size: 0.68rem;
        padding: 0.6rem;
    }

    .btn-export {
        padding: 0.45rem 0.75rem;
        font-size: 0.78rem;
    }

    /* Navbar buttons — smaller on 480px */
    .btn-nav-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .navbar-actions {
        gap: 0.3rem;
    }
}

/* 360px — very small phones (Galaxy A, older budget phones) */
@media(max-width:380px) {
    .brand-name {
        font-size: 1rem;
    }

    .brand-icon {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .navbar {
        padding: 0 0.75rem;
    }

    .navbar-actions {
        gap: 0.2rem;
    }

    .btn-nav-icon {
        width: 30px;
        height: 30px;
        font-size: 13px;
    }

    .chat-messages {
        padding: 0.5rem 0.6rem;
    }

    .message-content {
        max-width: 92%;
    }

    .message-avatar {
        width: 24px;
        height: 24px;
        font-size: 11px;
    }

    .hero-title {
        font-size: 1.15rem;
    }

    .hero-subtitle {
        font-size: .74rem;
    }
}

.sidebar.collapsed {
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed~.app-container {
    transition: grid-template-columns 0.3s ease;
}

.sidebar.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    overflow: hidden;
    border: none;
}

.app-container.sidebar-collapsed {
    grid-template-columns: 0 1fr !important;
}

/* ══ SIDEBAR COLLAPSE TOGGLE ══ */
.btn-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: none;
    border-top: 1px solid var(--border-subtle);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
    flex-shrink: 0;
    width: 100%;
}

.btn-sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--gold);
}

.toggle-icon {
    display: inline-block;
    transition: transform 0.3s ease;
}

/* When collapsed */
.app-container.sidebar-collapsed .sidebar {
    width: 0 !important;
    min-width: 0 !important;
    overflow: hidden;
    border: none;
    padding: 0;
}

.app-container.sidebar-collapsed {
    grid-template-columns: 0px 1fr !important;
}

.app-container.sidebar-collapsed .toggle-icon {
    transform: rotate(180deg);
}

/* Collapsed sidebar shows mini toggle button */
.app-container.sidebar-collapsed .btn-sidebar-toggle {
    position: fixed;
    left: 0;
    top: 80px;
    width: 20px;
    height: 40px;
    border-radius: 0 6px 6px 0;
    border: 1px solid var(--border-mid);
    border-left: none;
    background: var(--bg-panel);
    padding: 0;
    z-index: 200;
    overflow: visible;
}

/* Transition */
.app-container {
    transition: grid-template-columns 0.3s ease;
}

.sidebar {
    transition: width 0.3s ease, min-width 0.3s ease;
}

@media(max-width:768px) {
    .btn-sidebar-toggle {
        display: none !important;
    }
}

/* ── Hero disclaimer ── */
.hero-disclaimer {
    margin-top: 1rem;
    font-size: .72rem;
    color: #e74c3c;
    text-align: center;
    padding: .4rem 1rem;
    background: rgba(231, 76, 60, 0.08);
    border: 1px solid rgba(231, 76, 60, 0.2);
    border-radius: var(--radius-md);
    max-width: 520px;
    width: 100%;
    line-height: 1.5;
}