@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ================= THEME — Hài hòa, dễ dùng ================= */
:root {
    --bg: #0f1419;
    --bg-soft: #1a2332;
    --bg-strong: #243044;
    --card: #1e2a3a;

    --text: #e2e8f0;
    --text-muted: #94a3b8;

    --border: rgba(148,163,184,0.15);

    --primary: #6366f1;
    --primary-soft: rgba(99,102,241,0.15);
    --accent: #64748b;
    --danger: #f43f5e;
    --success: #22c55e;

    --radius: 12px;
    --radius-sm: 8px;

    --navbar-h: 56px;
    --tab-bar-h: 60px;

    --shadow: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-hover: 0 8px 24px rgba(0,0,0,0.2);
}

body.light {
    --bg: #f8fafc;
    --bg-soft: #ffffff;
    --bg-strong: #f1f5f9;
    --card: #ffffff;

    --text: #1e293b;
    --text-muted: #64748b;

    --border: rgba(100,116,139,0.2);

    --primary: #4f46e5;
    --primary-soft: rgba(79,70,229,0.12);
    --accent: #64748b;
    --danger: #e11d48;
    --success: #16a34a;

    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
}

/* Focus ring — accessibility */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button, input, textarea, select {
    font-family: inherit;
}

/* ================= NAVBAR ================= */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--navbar-h);

    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;

    padding: 0 1.25rem;
    background: rgba(15,20,25,0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

body.light .navbar {
    background: rgba(248,250,252,0.92);
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-decoration: none;
    color: var(--text);
}

.logo-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-btn.nav-active {
    color: var(--primary);
    background: var(--primary-soft);
    border-color: transparent;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: 1;
    justify-content: center;
}
.nav-right {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.nav-btn {
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid transparent;

    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;

    transition: all 0.2s ease;
    cursor: pointer;
}

.nav-btn:hover {
    background: var(--bg-strong);
    color: var(--text);
}

.history {
    background: var(--danger);
    color: #fff !important;
}

.theme-btn {
    font-size: 1rem;
}

/* ================= MAIN ================= */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ================= HERO ================= */
.hero-title {
    font-size: clamp(2.2rem, 5vw, 3.6rem);
    font-weight: 800;
    text-align: center;
    margin-top: 2.5rem;
    color: var(--text);
}

.hero-subtitle {
    text-align: center;
    margin-top: 0.8rem;
    font-size: 1.1rem;
    color: var(--text-muted);
}

/* ================= CARDS / CONTENT ================= */
.feature-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.5rem 1.75rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);

    transition: all 0.25s ease;
}

.feature-card:hover {
    border-color: rgba(99,102,241,0.3);
    box-shadow: var(--shadow-hover);
}

/* ================= BUTTON ================= */
.btn-large {
    display: inline-block;
    padding: 0.9rem 2rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    border: none;
    cursor: pointer;

    background: var(--primary);
    color: #fff;
    transition: all 0.2s ease;
}

.btn-large:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* ================= MOBILE HAMBURGER BUTTON ================= */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: background 0.15s;
}

.mobile-menu-btn:hover {
    background: var(--bg-strong);
}

/* ================= MOBILE SLIDE MENU ================= */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 3000;
    opacity: 0;
    transition: opacity 0.3s;
}

.mobile-menu-overlay.active {
    display: block;
    opacity: 1;
}

.mobile-menu {
    position: fixed;
    top: 0;
    right: -300px;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;

    background: var(--bg-soft);
    border-left: 1px solid var(--border);
    z-index: 3001;

    display: flex;
    flex-direction: column;

    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
}

.mobile-menu.open {
    right: 0;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border);
}

.mobile-menu-title {
    font-weight: 700;
    font-size: 1.05rem;
}

.mobile-menu-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: all 0.15s;
}

.mobile-menu-close:hover {
    background: var(--bg-strong);
    color: var(--text);
}

.mobile-menu-links {
    flex: 1;
    overflow-y: auto;
    padding: 0.6rem;
}

.mobile-link {
    display: flex;
    align-items: center;
    gap: 12px;

    padding: 12px 14px;
    border-radius: 10px;

    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;

    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;

    transition: background 0.15s;
}

.mobile-link:hover {
    background: var(--bg-strong);
}

.mobile-link.active {
    background: var(--primary-soft);
    font-weight: 600;
    color: var(--primary);
}

.mobile-link svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.mobile-link.active svg {
    opacity: 1;
    stroke: var(--primary);
}

.mobile-link-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 0;
}

/* Theme toggle icons in mobile menu */
.theme-icon-light {
    display: none;
}

body.light .theme-icon-dark {
    display: none;
}

body.light .theme-icon-light {
    display: block;
}

/* ================= MOBILE BOTTOM TAB BAR ================= */
.mobile-tab-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2000;

    height: var(--tab-bar-h);

    background: rgba(15,20,25,0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(16px);

    border-top: 1px solid var(--border);

    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

body.light .mobile-tab-bar {
    background: rgba(248,250,252,0.95);
    border-top-color: var(--border);
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;

    text-decoration: none;
    background: none;
    border: none;

    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 500;

    cursor: pointer;
    position: relative;
    padding: 6px 0;

    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.tab-item svg {
    transition: transform 0.2s;
}

.tab-item span {
    letter-spacing: 0.01em;
}

.tab-item.active {
    color: var(--primary);
    font-weight: 600;
}

.tab-item.active svg {
    stroke: var(--primary);
    transform: scale(1.05);
}

/* Active indicator dot */
.tab-item.active::before {
    content: "";
    position: absolute;
    top: 2px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--primary);
}

/* Tap feedback */
.tab-item:active {
    opacity: 0.7;
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .mobile-tab-bar {
        display: flex;
    }

    .logo-text {
        display: none;
    }

    main {
        padding: 1.2rem;
        padding-bottom: calc(var(--tab-bar-h) + 16px);
    }

    body {
        padding-bottom: 0;
    }
}

/* ================= HERO LANDING ================= */
.hero {
    text-align: center;
    padding: 4rem 1rem 3rem;
    position: relative;
}

.hero-badge {
    display: inline-block;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    background: rgba(79,209,197,0.15);
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 1.2rem;
}

.hero-gradient {
    background: linear-gradient(90deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-actions {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-primary {
    padding: 0.9rem 2rem;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
}

.btn-secondary {
    padding: 0.9rem 2rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
}

/* ================= FEATURES ================= */
.features {
    margin-top: 4rem;
    text-align: center;
}

.section-title {
    font-size: 2rem;
    font-weight: 700;
}

.section-desc {
    margin-top: 0.6rem;
    color: var(--text-muted);
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 0.6rem;
}

.feature-card h3 {
    margin-bottom: 0.4rem;
}

.feature-link {
    display: inline-block;
    margin-top: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
}

@media (max-width: 768px) {
    .hero {
        padding: 3rem 1rem 2rem;
    }
    .section-title {
        font-size: 1.6rem;
    }
}

.hero-theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.25s ease;
}

.hero-theme-toggle:hover {
    background: var(--bg-strong);
    transform: scale(1.05);
}

/* ======================================================
   CONFIG PAGE
   ====================================================== */

.config-page {
    max-width: 1100px;
    margin: 0 auto;
}

.config-page .page-title {
    margin-top: 1rem;
    font-size: 2.4rem;
    font-weight: 800;
}

.config-page .page-desc {
    max-width: 720px;
    margin: 0.6rem auto 2.5rem;
    font-size: 1rem;
}

.config-container {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 2rem;
    box-shadow:
        0 20px 50px rgba(0,0,0,0.35),
        inset 0 1px 0 rgba(255,255,255,0.02);
}

.info-box {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.4rem;
    margin-bottom: 2rem;
}

.info-box h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.8rem 1.2rem;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.config-page .form-group {
    margin-bottom: 1.8rem;
}

.config-page .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.config-page input[type="number"] {
    width: 100%;
    max-width: 260px;
    padding: 0.65rem 0.8rem;
    border-radius: 10px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    color: var(--text);
}

.config-page .form-group[style] {
    background: var(--bg-strong) !important;
    border-left: 4px solid var(--danger) !important;
    border-radius: 14px !important;
}

.editor-container {
    background: #0f1424;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.08);
}

body.light .editor-container {
    background: #f7f8fb;
}

#botRulesTextarea {
    color: #dfe6ff;
}

body.light #botRulesTextarea {
    color: var(--text);
}

.line-numbers {
    background: rgba(0,0,0,0.25);
}

body.light .line-numbers {
    background: #eef1f7;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 2.5rem;
}

.btn-save {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    padding: 0.8rem 2.2rem;
    border-radius: 999px;
}

.btn-reset {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.8rem 1.6rem;
    border-radius: 999px;
}

#status .info-box {
    margin-top: 2rem;
}

.info-box.success {
    background: linear-gradient(135deg, rgba(46,204,113,0.18), rgba(46,204,113,0.08));
    color: #2ecc71;
}

.nav-buttons {
    margin-top: 3rem;
}

.nav-buttons .btn-nav {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.8rem 1.8rem;
}

@media (max-width: 768px) {
    .config-container {
        padding: 1.4rem;
    }
    .config-page .page-title {
        font-size: 1.9rem;
    }
    .editor-container {
        font-size: 14px;
    }
}

/* ======================================================
   CHAT LAYOUT — GPT STYLE (FIXED)
   ====================================================== */

/* Override main constraints for chat page */
main:has(.chat-layout) {
    max-width: none;
    padding: 0;
    margin: 0;
}

.chat-layout {
    display: flex;
    height: calc(100vh - var(--navbar-h));
    height: calc(100dvh - var(--navbar-h));
    overflow: hidden;
    background: var(--bg);
    position: relative;
}

/* SIDEBAR */
.sessions-panel {
    width: 260px;
    min-width: 240px;
    max-width: 300px;

    background: var(--bg-soft);
    border-right: 1px solid var(--border);

    display: flex;
    flex-direction: column;
    padding: 0.6rem;

    overflow-y: auto;
    z-index: 10;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.menu-item {
    width: 100%;
    background: transparent;
    border: none;

    display: flex;
    align-items: center;
    gap: 8px;

    padding: 8px 10px;
    border-radius: 10px;

    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;

    transition: background 0.15s ease;
}

.menu-item:hover {
    background: var(--bg-strong);
}

.menu-item.primary {
    background: var(--primary-soft);
    font-weight: 600;
    color: var(--primary);
}

.menu-item.primary:hover {
    background: rgba(99,102,241,0.25);
}

.menu-item .icon {
    width: 20px;
    text-align: center;
    opacity: 0.9;
    background: none;
    border: none;
    font-size: 1rem;
}

.menu-item .label {
    flex: 1;
    text-align: left;
}

.menu-item .shortcut {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Search input */
.session-search {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    margin: 6px 0 8px;
    font-size: 0.85rem;
    color: var(--text);
}

.session-search:focus {
    border-color: var(--primary);
}

/* Session list */
.sessions-list {
    padding: 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.sessions-list li {
    list-style: none;
}

.session-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    position: relative;

    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s ease;
}

.session-row:hover {
    background: var(--bg-strong);
}

.session-row.active {
    background: var(--primary-soft);
    font-weight: 600;
    color: var(--primary);
}

.session-row .pin-icon {
    font-size: 0.7rem;
    flex-shrink: 0;
}

.session-row .title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-more {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    opacity: 0;
    transition: all 0.15s ease;
}

.session-row:hover .session-more {
    opacity: 1;
}

.session-more:hover {
    background: var(--bg-strong);
    color: var(--text);
}

.session-menu {
    position: absolute;
    right: 6px;
    top: calc(100% + 6px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    min-width: 140px;
    overflow: hidden;
    box-shadow: 0 12px 30px rgba(0,0,0,0.35);
    z-index: 999;
}

.session-menu button {
    width: 100%;
    background: transparent;
    border: none;
    text-align: left;
    padding: 10px 12px;
    font-size: 0.85rem;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s ease;
}

.session-menu button:hover {
    background: var(--bg-strong);
}

.session-menu button.danger {
    color: var(--danger);
}

/* CHAT HEADER — session toggle + new chat (visible on mobile) */
.chat-sidebar-btn,
.chat-new-btn {
    display: none; /* hidden on desktop */
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.chat-sidebar-btn:hover,
.chat-new-btn:hover {
    background: var(--bg-strong);
    color: var(--text);
}

/* Sidebar mobile header (with close button) */
.sidebar-header-mobile {
    display: none; /* hidden on desktop */
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-title {
    font-weight: 700;
    font-size: 1rem;
}

.sidebar-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.15s;
}

.sidebar-close-btn:hover {
    background: var(--bg-strong);
    color: var(--text);
}

/* Sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
}

.sidebar-overlay.active {
    display: block;
}

/* CHAT WRAPPER — GPT full-width */
.chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    background: var(--bg);
    position: relative;
    min-width: 0;
}

.bg-gradient {
    position: absolute;
    inset: 0;
    background: transparent;
    pointer-events: none;
    z-index: 0;
}

#chatForm {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-container {
    width: 100%;
    max-width: 56rem;
    height: 100%;
    margin: 0 auto;

    display: flex;
    flex-direction: column;

    background: var(--bg);
    overflow: hidden;

    position: relative;
    z-index: 1;
}

/* CHAT HEADER — GPT style */
.chat-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.ai-badge {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-text h2 {
    font-size: 1rem;
    font-weight: 700;
}

.status {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    display: inline-block;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
    70% { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
    100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* MESSAGES AREA — GPT style */
.messages-container {
    flex: 1;
    padding: 1rem 1rem 2rem;
    overflow-y: auto;
    background: var(--bg);
    position: relative;

    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

body.light .messages-container {
    scrollbar-color: rgba(0,0,0,0.12) transparent;
}

.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background-color: rgba(255,255,255,0.15);
    border-radius: 999px;
}

.messages-container:hover::-webkit-scrollbar-thumb {
    background-color: rgba(255,255,255,0.35);
}

body.light .messages-container::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.12);
}

body.light .messages-container:hover::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.25);
}

/* MESSAGES — GPT style */
.chat-layout .messages {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    max-height: none;
    overflow: visible;
}

.message {
    display: flex;
    gap: 0.75rem;
    padding: 1.25rem 0;
    max-width: 48rem;
    margin: 0 auto;
    width: 100%;
}

.message.bot {
    flex-direction: row;
    align-items: flex-start;
}

.message.user {
    flex-direction: row-reverse;
    align-items: flex-start;
}

/* Avatar — GPT style */
.msg-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.bot-avatar {
    background: var(--primary);
    color: #fff;
}

.user-avatar {
    background: var(--bg-strong);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

body.light .user-avatar {
    background: var(--bg-strong);
}

/* BUBBLE (Chat page) — GPT style */
.chat-layout .bubble {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    padding: 0.875rem 1.125rem;
    border-radius: 18px;
    font-size: 0.9375rem;
    line-height: 1.65;
    background: var(--bg-strong);
    color: var(--text);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

body.light .chat-layout .bubble {
    background: var(--bg-soft);
    color: var(--text);
    border: 1px solid var(--border);
}

.chat-layout .message.user .bubble {
    background: var(--primary);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
}

.chat-layout .message.bot .bubble {
    border-radius: 18px 18px 18px 4px;
}

/* Markdown inside bubble */
.chat-layout .bubble .content {
    line-height: 1.7;
}

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

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

.chat-layout .bubble .content ul,
.chat-layout .bubble .content ol {
    padding-left: 1.5em;
    margin-bottom: 0.5em;
}

.chat-layout .bubble .content code {
    background: rgba(255,255,255,0.1);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.88em;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

body.light .chat-layout .bubble .content code {
    background: rgba(0,0,0,0.06);
}

.chat-layout .bubble .content pre {
    background: var(--bg);
    color: var(--text);
    border-radius: 8px;
    padding: 0.8em 1em;
    overflow-x: auto;
    margin: 0.5em 0;
    font-size: 0.88em;
}

.chat-layout .bubble .content pre code {
    background: none;
    padding: 0;
    font-size: inherit;
    color: inherit;
}

.chat-layout .bubble .content blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 0.8em;
    margin: 0.5em 0;
    color: var(--text-muted);
}

.chat-layout .bubble .content table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5em 0;
    font-size: 0.9em;
}

.chat-layout .bubble .content th,
.chat-layout .bubble .content td {
    border: 1px solid var(--border);
    padding: 0.4em 0.6em;
    text-align: left;
}

.chat-layout .bubble .content th {
    background: var(--bg-soft);
    font-weight: 600;
}

/* MESSAGE ACTIONS (copy, feedback, timestamp) */
.msg-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}

.message.bot:hover .msg-actions,
.msg-actions:focus-within {
    opacity: 1;
}

.msg-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-right: auto;
}

.msg-time.user-time {
    display: block;
    text-align: right;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
    margin-top: 4px;
}

body.light .msg-time.user-time {
    color: var(--text-muted);
}

.action-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 0.78rem;
    transition: all 0.15s;
    color: var(--text-muted);
    line-height: 1;
    display: flex;
    align-items: center;
}

.action-btn:hover:not(:disabled) {
    background: var(--bg-strong);
    border-color: var(--text-muted);
    color: var(--text);
}

.action-btn.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}

.action-btn:disabled {
    cursor: default;
}

/* THINKING INDICATOR — GPT style */
.thinking-indicator {
    display: none;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 1.25rem 0;
    max-width: 48rem;
    margin: 0 auto;
}

.thinking-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.thinking-dots span {
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.4s infinite both;
}

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

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

/* SUGGESTED QUESTIONS CHIPS — GPT style */
.suggestions-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.75rem 0;
    max-width: 48rem;
    margin: 0 auto;
    animation: fadeInUp 0.3s ease;
}

.suggestions-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.suggestion-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    color: var(--primary);
    background: var(--bg-strong);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-chip:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
    transform: translateY(-1px);
}

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

/* SCROLL TO BOTTOM BUTTON */
.scroll-btn {
    position: sticky;
    bottom: 16px;
    float: right;
    margin-right: 8px;
    margin-top: -52px;

    opacity: 0;
    pointer-events: none;

    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: all 0.25s ease;
    z-index: 5;
}

.scroll-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

.scroll-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

/* SSE STREAMING CURSOR */
.streaming::after {
    content: "▊";
    display: inline-block;
    animation: blink-cursor 0.7s steps(2) infinite;
    color: var(--primary);
    margin-left: 2px;
}

@keyframes blink-cursor {
    0% { opacity: 1; }
    50% { opacity: 0; }
}

/* INPUT SECTION — GPT style */
.input-section {
    padding: 1rem 1rem 1.5rem;
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    background: var(--bg);
    flex-shrink: 0;
}

.input-container {
    max-width: 48rem;
    margin: 0 auto;
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.input-box {
    flex: 1;
    display: flex;
    background: var(--bg-soft);
    border-radius: 24px;
    padding: 12px 18px;
    border: 1px solid var(--border);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-soft);
}

#userInput {
    width: 100%;
    resize: none;
    overflow-y: hidden;
    line-height: 1.5;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.95rem;
    max-height: 160px;
    font-family: inherit;
}

#userInput::placeholder {
    color: var(--text-muted);
}

#userInput:focus {
    outline: none;
}

/* PLUS / ATTACH BUTTON — bên trái input */
.input-attach-wrap {
    position: relative;
}
.plus-btn {
    width: 42px;
    height: 42px;
    border: 1.5px solid var(--border);
    background: var(--bg-soft);
    color: var(--text-muted);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.attach-menu {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 8px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
    z-index: 100;
    min-width: 220px;
}
.attach-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.95rem;
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.15s, color 0.15s;
}
.attach-menu-item:hover {
    background: var(--primary-soft);
    color: var(--primary);
}
.attach-menu-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--bg-strong);
    color: var(--text-muted);
}
.attach-menu-item:hover .attach-menu-icon {
    background: var(--primary-soft);
    color: var(--primary);
}

/* MIC BUTTON — dùng chung với plus khi ghi âm */
.mic-btn {
    width: 42px;
    height: 42px;
    border: 1.5px solid var(--border);
    background: var(--bg-soft);
    color: var(--text-muted);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.mic-btn .mic-icon-recording {
    display: none;
}
.mic-btn .plus-icon { display: block; }
.mic-btn.recording .plus-icon { display: none !important; }

.mic-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-soft);
}

.mic-btn.recording {
    color: #fff;
    background: #e74c3c;
    border-color: #e74c3c;
    animation: mic-pulse 1.4s ease infinite;
}

.mic-btn.recording .mic-icon-default {
    display: none;
}

.mic-btn.recording .mic-icon-recording {
    display: block;
}

@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231,76,60,0.35); }
    50%      { box-shadow: 0 0 0 10px rgba(231,76,60,0); }
}

/* MIC TOAST — thông báo lỗi mic */
.mic-toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30,30,40,0.92);
    color: #fff;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.85rem;
    z-index: 9999;
    animation: toastSlide 4s ease forwards;
    max-width: 90vw;
    text-align: center;
}

@keyframes toastSlide {
    0%   { opacity: 0; transform: translateX(-50%) translateY(10px); }
    10%  { opacity: 1; transform: translateX(-50%) translateY(0); }
    80%  { opacity: 1; }
    100% { opacity: 0; }
}

/* SEND BUTTON — bên phải */
.send-btn {
    width: 42px;
    height: 42px;
    border: none;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
    flex-shrink: 0;
}

.send-btn:hover {
    filter: brightness(1.1);
    transform: scale(1.06);
}

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

.input-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 6px;
    padding: 0 54px;
    opacity: 0.7;
}

#charCount.over-limit {
    color: var(--danger);
    font-weight: 600;
    opacity: 1;
}

/* LOADING SESSION STATE */
.loading-session {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* WELCOME — GPT style */
.welcome {
    margin: auto;
    max-width: 42rem;
    text-align: center;
    padding: 3rem 1.5rem 2rem;
}

.welcome-avatar {
    width: 68px;
    height: 68px;
    margin: 0 auto 1.25rem;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome h3 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.welcome-desc {
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1.75rem;
}

.quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.quick-buttons button {
    background: var(--bg-strong);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.6rem 1.1rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text);
    transition: all 0.18s ease;
}

.quick-buttons button:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

/* ================= RESPONSIVE CHAT ================= */
@media (max-width: 768px) {
    .chat-sidebar-btn,
    .chat-new-btn {
        display: flex;
    }
    .sidebar-header-mobile {
        display: flex;
    }
    .sessions-panel {
        position: fixed;
        top: 0;
        left: -280px;
        height: 100vh;
        height: 100dvh;
        width: 280px;
        max-width: 85vw;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 200;
        box-shadow: none;
    }
    .sessions-panel.open {
        left: 0;
        box-shadow: 4px 0 24px rgba(0,0,0,0.25);
    }
    .chat-container {
        max-width: none;
    }
    .message {
        padding: 1rem 1rem;
        max-width: none;
    }
    .chat-layout .bubble {
        max-width: 85%;
    }
    .quick-buttons {
        flex-direction: column;
    }
    .quick-buttons button {
        width: 100%;
        max-width: 280px;
        margin: 0 auto;
    }
    .chat-layout {
        height: calc(100vh - var(--navbar-h) - var(--tab-bar-h));
        height: calc(100dvh - var(--navbar-h) - var(--tab-bar-h));
    }
}

@media (max-width: 480px) {
    .sessions-panel.open {
        width: min(280px, 100vw - 16px);
    }
    .messages-container {
        padding: 0.75rem 0.75rem 1.5rem;
    }
    .message {
        padding: 0.875rem 0.75rem;
        gap: 0.5rem;
    }
    .msg-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.65rem;
    }
    .chat-layout .bubble {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    .chat-header {
        padding: 0.6rem 0.75rem;
    }
    .chat-header .ai-text h2 {
        font-size: 0.95rem;
    }
    .input-section {
        padding: 0.75rem 0.75rem 1.25rem;
        padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
    }
    .input-row {
        gap: 8px;
    }
    .input-box {
        padding: 10px 14px;
        border-radius: 22px;
    }
    .plus-btn {
        width: 40px;
        height: 40px;
    }
    .send-btn {
        width: 40px;
        height: 40px;
    }
    .welcome {
        padding: 2rem 1rem 1.5rem;
    }
    .welcome-avatar {
        width: 56px;
        height: 56px;
        font-size: 1.25rem;
    }
    .welcome h3 {
        font-size: 1.35rem;
    }
    .welcome-desc {
        font-size: 0.9rem;
    }
    .input-meta {
        padding: 0 44px;
        font-size: 0.65rem;
    }
    .scroll-btn {
        width: 36px;
        height: 36px;
        bottom: 12px;
    }
    .suggestions-row {
        padding: 0.5rem 0.75rem;
    }
    .suggestion-chip {
        font-size: 0.75rem;
        padding: 0.35rem 0.7rem;
    }
}

/* Tablet */
@media (min-width: 481px) and (max-width: 768px) {
    .message {
        padding: 1rem 1.25rem;
    }
    .welcome {
        padding: 2.5rem 1.25rem 1.75rem;
    }
}

/* ================= HISTORY PAGE ================= */

.history-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.4rem;
    color: var(--text);
}

.history-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.history-header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 0.4rem;
}

.history-header p {
    color: var(--text-muted);
    font-size: 1rem;
}

.history-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .history-layout {
        grid-template-columns: 1fr;
    }
}

.card {
    background: var(--card);
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.4rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 1.1rem;
}

.meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* History page messages (NOT chat page) */
.history-wrapper .messages {
    padding: 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 65vh;
    overflow-y: auto;
}

.msg {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
}

.msg.user {
    justify-content: flex-end;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}

/* History page bubble (NOT chat page) */
.history-wrapper .bubble {
    max-width: 72%;
    padding: 0.75rem 1rem;
    border-radius: 14px;
    background: var(--bg-soft);
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}

.msg.user .bubble {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #081018;
}

.bubble-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.bubble-body {
    font-size: 0.95rem;
    line-height: 1.6;
    word-wrap: break-word;
}

/* FILE PANEL */
.files-panel {
    padding-bottom: 0.8rem;
}

.file-list {
    list-style: none;
    padding: 0.8rem 1.2rem;
    margin: 0;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px dashed var(--border);
}

.file-item strong {
    font-size: 0.9rem;
}

.file-item span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* BUTTONS */
.btn {
    padding: 0.5rem 1.2rem;
    border-radius: 999px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #081018;
}

.btn.ghost {
    background: transparent;
    color: var(--text-muted);
}

.icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.icon.danger {
    color: var(--danger);
}

/* EMPTY STATE */
.empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
}

.empty a {
    margin-top: 0.8rem;
    display: inline-block;
}

/* FOOTER */
.footer-actions {
    margin-top: 2.5rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ================= LOADER PAGE ================= */

.loader-page {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1rem;
    text-align: center;
    color: var(--text);
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 20px;
    padding: 3rem;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--bg-soft);
    margin: 2rem 0;
    color: var(--text-muted);
}

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

.file-preview {
    margin: 2rem 0;
    text-align: left;
    background: var(--card);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.preview-header {
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 1rem;
}

.preview-item {
    padding: 0.5rem 0;
    color: var(--text);
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed var(--border);
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    max-width: 700px;
    margin: 3rem auto;
}

.setting-item label {
    display: block;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.setting-item input[type=range] {
    width: 100%;
}

.action-buttons {
    margin: 3rem 0;
    display: flex;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
}

.teal {
    background: var(--text);
    color: var(--bg);
}

.red {
    background: var(--danger);
    color: white;
}

.status-box {
    min-height: 60px;
    margin: 2rem 0;
}

.nav-buttons a {
    display: inline-block;
    margin: 1rem;
    padding: 0.8rem 2rem;
    background: var(--bg-soft);
    color: var(--text);
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    border: 1px solid var(--border);
}

.nav-buttons a.purple {
    background: var(--primary);
    color: #fff;
}

/* ================= CONFIG TABLE ================= */

.config-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.config-table th,
.config-table td {
    border: 1px solid var(--border);
    padding: 0.4rem 0.6rem;
    text-align: left;
    vertical-align: top;
}

.config-table th {
    background: var(--bg-strong);
    font-weight: 600;
    width: 35%;
}

/* ================= DEBUG PANEL ================= */

.debug-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--card);
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 999;
}

.debug-panel {
    position: fixed;
    bottom: 70px;
    right: 20px;
    width: 420px;
    height: 260px;
    background: #1e1e1e;
    color: #00ff9d;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999;
}

.debug-panel.hidden {
    display: none;
}

.debug-header {
    background: #111;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #ccc;
}

/* LOG PANEL */
.view-log-btn {
    margin-top: 6px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    padding: 4px 10px;
    cursor: pointer;
    color: var(--text);
}

.view-log-btn:hover {
    background: var(--bg-strong);
}

.log-wrapper {
    margin-top: 10px;
    border-radius: 10px;
    background: #0f172a;
    color: #e5e7eb;
    font-size: 12px;
    line-height: 1.5;
    box-shadow: inset 0 0 0 1px #1e293b;
    max-height: 280px;
    overflow: hidden;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: #020617;
    border-bottom: 1px solid #1e293b;
    font-size: 11px;
    letter-spacing: 0.04em;
}

.log-title {
    color: #38bdf8;
    font-weight: 600;
}

.log-actions button {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 12px;
    margin-left: 6px;
}

.log-actions button:hover {
    color: #e5e7eb;
}

.log-view {
    padding: 10px;
    margin: 0;
    max-height: 240px;
    overflow: auto;
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.log-input {
    color: #22c55e;
}

.log-flow {
    color: #38bdf8;
}

.log-error {
    color: #f87171;
    font-weight: bold;
}

/* ================= LEGACY FEEDBACK (for backward compat) ================= */

.feedback-row {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}

.message.bot:hover .feedback-row,
.feedback-row:focus-within {
    opacity: 1;
}

.fb-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.15s;
    color: inherit;
}

.fb-btn:hover:not(:disabled) {
    background: var(--bg-strong);
}

.fb-btn.active {
    border-color: var(--primary);
    background: rgba(108,124,255,0.15);
}

.fb-btn:disabled {
    cursor: default;
}

/* FEEDBACK COMMENT BOX (hiện khi bấm 👎) */
.feedback-comment-box {
    margin-top: 8px;
    padding: 8px 10px;
    background: var(--msg-bot-bg, #f5f5f7);
    border: 1px solid var(--border);
    border-radius: 10px;
    animation: slideDown 0.2s ease;
}

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

.fb-comment-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.85rem;
    font-family: inherit;
    resize: vertical;
    background: var(--bg, #fff);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

.fb-comment-input:focus {
    border-color: var(--primary);
}

.fb-comment-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    justify-content: flex-end;
}

.fb-comment-submit,
.fb-comment-skip {
    padding: 4px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: 0.2s;
}

.fb-comment-submit {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.fb-comment-submit:hover {
    opacity: 0.85;
}

.fb-comment-skip {
    background: transparent;
    color: var(--text-muted);
}

.fb-comment-skip:hover {
    border-color: var(--text-muted);
}

/* FEEDBACK TOAST */
.fb-toast {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 10px;
    font-size: 0.75rem;
    color: var(--primary);
    background: rgba(108,124,255,0.1);
    border-radius: 8px;
    animation: fadeInOut 2.5s ease forwards;
}

@keyframes fadeInOut {
    0%   { opacity: 0; }
    15%  { opacity: 1; }
    75%  { opacity: 1; }
    100% { opacity: 0; }
}

/* CLEAR CHAT BUTTON */
.clear-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 10px;
    padding: 0.45rem;
    cursor: pointer;
    transition: 0.2s;
}

.clear-btn:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* EMOJI / SETTINGS */
.emoji-picker,
.settings-panel {
    background: var(--bg);
    border: 1px solid var(--border);
}

/* NOTIFY BUTTON — đối diện Hidemium */
.nav-notify-btn {
    color: var(--text-muted);
    padding: 8px 12px;
}
.nav-notify-btn:hover {
    color: #f39c12;
}
.mobile-notify-btn {
    width: 100%;
    text-align: left;
    border: none;
    background: none;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

/* NOTIFY MODAL */
.notify-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
}
.notify-modal-overlay:has(+ .notify-modal.open) {
    display: block;
}
.notify-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.notify-modal.open {
    display: flex;
}
.notify-modal-content {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 24px 64px rgba(0,0,0,0.45);
}
.notify-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.notify-modal-header h3 { font-size: 1.15rem; margin: 0; font-weight: 600; }
.notify-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}
.notify-modal-close:hover { color: var(--text); }
.notify-modal-body { padding: 1.5rem; }
.notify-modal-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
    line-height: 1.5;
}
.notify-form-group {
    margin-bottom: 1.25rem;
}
.notify-form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}
.notify-form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-soft);
    color: var(--text);
    font-size: 0.95rem;
}
.notify-time-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.notify-time-row input {
    width: 70px;
    text-align: center;
}
.notify-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}
.notify-save-btn {
    padding: 10px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}
.notify-save-btn:hover { opacity: 0.9; }
.notify-status {
    font-size: 0.9rem;
    color: var(--text-muted);
}