:root {
    --border: #e2e8f0;
    --text-muted: #64748b;
    --bg-light: #f1f5f9;
    --blue: #3b82f6;
    --orange: #f59e0b;
    --black: #0f172a;
    --white: #ffffff;

    /* Legacy aliases keep every existing template inside the four-color system. */
    --sky: var(--white);
    --ocean: var(--blue);
    --space: var(--black);
    --amber: var(--orange);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #ffffff;
    color: #334155;
    line-height: 1.5;
}
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(var(--blue) 1px, transparent 1px),
        linear-gradient(90deg, var(--blue) 1px, transparent 1px);
    background-size: 48px 48px;
    opacity: .015;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
::selection { background: var(--orange); color: #334155; }

.site-shell { min-height: 100vh; display: flex; flex-direction: column; }
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
}
.nav-wrap {
    width: min(1180px, calc(100% - 32px));
    min-height: 56px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    letter-spacing: -.03em;
    font-size: 1.15rem;
}
.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--blue);
    color: var(--white);
    border: 1px solid var(--border);
    box-shadow: none;
}
.brand-accent { color: var(--blue); }
.nav-links { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav-link {
    padding: 8px 12px;
    border: none;
    font-weight: 500;
    font-size: .88rem;
}
.nav-link:hover, .nav-link.active { border-color: #334155; background: var(--orange); }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.mobile-menu { display: none !important; }

.main-content { flex: 1; width: 100%; }
.container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.narrow { width: min(760px, calc(100% - 32px)); margin: 0 auto; }
.section { padding: 36px 0; }
.section-tight { padding: 20px 0; }

.hero {
    display: grid;
    grid-template-columns: 1.18fr .82fr;
    gap: 24px;
    align-items: stretch;
    padding: 56px 0 30px;
}
.hero-copy, .hero-panel, .panel, .card, .auth-card, .table-panel, .chart-panel {
    border: 1px solid var(--border);
    box-shadow: none;
    border-radius: 12px;
}
.hero-copy {
    position: relative;
    overflow: hidden;
    background: #ffffff;
    padding: clamp(30px, 5vw, 66px);
    border-radius: 14px;
}
.hero-copy::after { display: none; }
.hero-panel {
    background: var(--blue);
    color: var(--white);
    padding: 28px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: none;
    border-radius: 14px;
}
.hero-panel .card { color: #334155; box-shadow: none; border-radius: 12px; }
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--bg-light);
    color: var(--blue);
    border: none;
    padding: 4px 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-size: .75rem;
    border-radius: 9999px;
}
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.6rem, 4vw, 2.6rem); font-weight: 600; line-height: 1.1; letter-spacing: -.03em; margin-bottom: 10px; }
h2 { font-size: clamp(1.2rem, 2.5vw, 1.6rem); font-weight: 600; line-height: 1.15; letter-spacing: -.02em; margin-bottom: 8px; }
h3 { font-size: 0.97rem; font-weight: 600; line-height: 1.25; margin-bottom: 6px; }
.lead { font-size: clamp(0.95rem, 1.8vw, 1.1rem); max-width: 680px; font-weight: 400; color: #475569; }
.muted { color: #64748b; }
.small { font-size: .84rem; }
.micro { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 9px 16px;
    border: 1px solid var(--border);
    background: #ffffff;
    color: #334155;
    font-weight: 500;
    box-shadow: none;
    transition: background-color .12s ease, border-color .12s ease;
    border-radius: 8px;
}
.btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn:active { background: #f1f5f9; }
.btn-dark, .btn-ocean { background: var(--blue); color: #ffffff; border-color: var(--blue); }
.btn-dark:hover, .btn-ocean:hover { background: #2563eb; border-color: #2563eb; }
.btn-orange, .btn-ghost { background: #ffffff; color: #475569; border-color: var(--border); }
.btn-orange:hover, .btn-ghost:hover { background: #f8fafc; color: #0f172a; border-color: #cbd5e1; }
.btn-danger { background: #ffffff; color: #dc2626; border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; color: #991b1b; border-color: #fca5a5; }
.btn-sky { background: #ffffff; }
.btn-small { min-height: 34px; padding: 6px 11px; font-size: .82rem; box-shadow: none; }
.btn-block { width: 100%; }
.btn[disabled], button[disabled] { cursor: not-allowed; box-shadow: none; transform: none; background: #f1f5f9; color: #94a3b8; opacity: .7; border-color: var(--border); }
.google-button { min-height: 48px; font-size: .95rem; background: var(--blue); color: #ffffff; box-shadow: none; }
.google-button i { font-size: 1.2rem; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { position: relative; background: #ffffff; padding: 16px; border-radius: 10px; box-shadow: none; }
.card-amber { border-top: 3px solid var(--blue); }
.card-ocean { border-top: 3px solid var(--orange); }
.card-orange { border-top: 3px solid var(--black); }
.card-dark { background: #0f172a; color: #ffffff; box-shadow: none; }
.card-link { transition: border-color .12s ease; }
.card-link:hover { border-color: var(--blue); }
.icon-box {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    background: var(--bg-light);
    color: var(--blue);
    box-shadow: none;
    font-size: 1.25rem;
    border-radius: 10px;
}
.card-top, .page-header, .split-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.card-meta { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 10px; margin-top: 10px; border-top: 1px solid var(--border); font-size: .75rem; font-weight: 500; }
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    background: #ffffff;
    color: #334155;
    font-size: .7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-radius: 9999px;
}
.badge-private { background: #0f172a; color: #ffffff; border-color: #0f172a; }
.badge-public { background: var(--blue); color: #ffffff; border-color: var(--blue); }
.badge-alert { background: var(--orange); color: #334155; }

.page-title { padding: 22px 0 14px; }
.page-title h1 { font-size: clamp(1.5rem, 4vw, 2.2rem); margin-bottom: 6px; }
.panel { background: #ffffff; padding: clamp(14px, 3vw, 26px); border-radius: 10px; box-shadow: none; }
.panel-amber { border-top: 3px solid var(--orange); }
.panel-ocean { border-top: 3px solid var(--blue); }
.panel-orange { border-top: 3px solid var(--orange); }
.panel-dark { background: #0f172a; color: #ffffff; box-shadow: none; }
.stack { display: grid; gap: 14px; }
.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.space-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 22px 0; }

.field { display: grid; gap: 6px; }
.field label { font-size: .75rem; font-weight: 600; color: #475569; text-transform: uppercase; letter-spacing: .04em; }
.field-input, input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="search"], textarea, select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--border);
    background: #ffffff;
    color: #334155;
    padding: 9px 12px;
    outline: none;
    border-radius: 8px;
    box-shadow: none;
}
textarea { min-height: 110px; resize: vertical; }
.field-input:focus, input:focus, textarea:focus, select:focus { border-color: var(--blue); outline: none; }
::placeholder { color: #94a3b8; opacity: 1; }
.help { font-size: .78rem; font-weight: 400; color: #64748b; }
.error-list, .error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 10px 12px; font-weight: 500; border-radius: 8px; }
.checkbox-line { display: flex; align-items: flex-start; gap: 10px; border: 1px solid var(--border); padding: 14px; background: #ffffff; box-shadow: none; border-radius: 8px; }
.checkbox-line input { width: 20px; height: 20px; accent-color: var(--blue); flex: 0 0 auto; }

/* Custom Modern File Upload */
.custom-avatar-upload {
    position: relative;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    background: #f8fafc;
    transition: border-color 0.15s ease, background 0.15s ease;
    cursor: pointer;
}
.custom-avatar-upload:hover {
    border-color: var(--blue);
    background: #f0f7ff;
}
.avatar-file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    z-index: 2;
}
.avatar-preview-container {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    overflow: hidden;
    flex-shrink: 0;
}
.avatar-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.avatar-icon-placeholder {
    font-size: 1.25rem;
    color: var(--blue);
    display: grid;
    place-items: center;
}
.avatar-upload-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.avatar-upload-text strong {
    font-size: 0.86rem;
    font-weight: 500;
    color: #1e293b;
}

.messages { width: min(1180px, calc(100% - 32px)); margin: 18px auto 0; display: grid; gap: 8px; }
.message { padding: 12px 14px; border: 1px solid var(--border); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05); background: #ffffff; font-weight: 600;  border-radius: 8px; }
.message.error, .message.warning { background: var(--orange); }
.message.success { background: var(--blue); color: #ffffff; }

.auth-shell { min-height: calc(100vh - 57px); display: grid; grid-template-columns: .85fr 1.15fr; }
.auth-intro {
    position: relative;
    overflow: hidden;
    background: var(--blue);
    color: var(--white);
    padding: clamp(30px, 5vw, 64px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-right: 1px solid var(--border);
}
.auth-intro::after { display: none; }
.auth-intro > * { position: relative; z-index: 1; }
.auth-intro h1 { color: var(--white); font-size: clamp(1.8rem, 4vw, 2.8rem); margin-bottom: 12px; }
.auth-form-wrap { display: grid; place-items: center; padding: 28px 20px; background: #ffffff; }
.auth-card { width: min(460px, 100%); background: #ffffff; padding: clamp(20px, 4vw, 36px); border-radius: 12px; }
.auth-card h1 { font-size: clamp(1.4rem, 3vw, 2rem); margin-bottom: 4px; }
.auth-primary { padding: 16px; border: 1px solid var(--border); background: #ffffff; box-shadow: none; border-radius: 10px; }
.auth-primary p { margin-bottom: 14px; }
.auth-separator { display: flex; align-items: center; gap: 12px; font-weight: 600; text-transform: uppercase; font-size: .72rem; letter-spacing: .06em; color: var(--text-muted); }
.auth-separator::before, .auth-separator::after { content: ""; height: 1px; background: var(--border); flex: 1; }
.auth-config-note { margin: 10px 0 0; padding: 9px 10px; border: 1px dashed var(--border); background: var(--bg-light); font-size: .76rem; font-weight: 600; }

.stat-card { display: flex; flex-direction: column; justify-content: space-between; gap: 10px; }
.stat-value { font-size: clamp(1.6rem, 4vw, 2.4rem); line-height: 1; font-weight: 700; letter-spacing: -.04em; }
.stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; color: var(--text-muted); }

.profile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 18px 22px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #ffffff;
    margin-bottom: 18px;
}
.profile-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #0f172a;
    color: #ffffff;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    font-weight: 700;
    flex-shrink: 0;
}
.profile-identity {
    display: flex;
    align-items: center;
    gap: 14px;
}
.profile-info { display: flex; flex-direction: column; gap: 2px; }
.profile-name { font-size: 1rem; font-weight: 700; color: #0f172a; }
.profile-email { font-size: 0.8rem; color: var(--text-muted); font-weight: 400; }
.profile-quick-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #ffffff;
    transition: border-color .12s ease;
    text-decoration: none;
    color: inherit;
}
.profile-quick-card:hover { border-color: var(--blue); }
.profile-quick-card .icon-box { width: 32px; height: 32px; font-size: 0.9rem; border-radius: 7px; }
.profile-quick-card h3 { font-size: 0.9rem; margin-bottom: 0; }
.profile-quick-card p { font-size: 0.8rem; color: var(--text-muted); margin: 0; }

.table-panel { overflow: hidden; background: #ffffff;  border-radius: 12px; }
.table-heading { padding: 18px 20px; background: #f8fafc; border-bottom: 1px solid var(--border); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg-light); color: var(--text-muted); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: var(--orange); }

.dashboard-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 22px; align-items: start; }
.dashboard-sidebar { display: grid; gap: 22px; position: sticky; top: 98px; }
.chart-panel { background: #ffffff; padding: 20px; min-height: 330px;  border-radius: 12px; }
.chart-wrap { position: relative; height: 250px; }

/* --- Minimalist Professional Chat Shell & UI --- */
.chat-shell {
    height: calc(100vh - 95px);
    max-height: 920px;
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    gap: 12px;
}

/* --- Astroweb Rishi Style Layout --- */
.chat-shell-astroweb {
    height: calc(100vh - 73px);
    width: 100%;
    display: grid;
    grid-template-columns: 260px 1fr;
    background: #ffffff;
    overflow: hidden;
}

.astroweb-sidebar {
    background: #ffffff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px;
    height: 100%;
    overflow-y: auto;
    min-width: 0;
}

.account-card, .sidebar-user-card {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px 4px 4px 5px;
    border: 1px solid var(--border);
    border-radius: 9999px;
    background: #ffffff;
    max-width: 100%;
}

.account-avatar, .sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #0f172a;
    color: #ffffff;
    display: grid;
    place-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    overflow: hidden;
    flex-shrink: 0;
}
.account-avatar img, .sidebar-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.account-name, .sidebar-user-name {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 6px;
}

.account-signout-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #f1f5f9;
    border: 1px solid var(--border);
    color: #475569;
    display: grid;
    place-items: center;
    font-size: 0.9rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
    padding: 0;
}
.account-signout-btn:hover {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.btn-new-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 9px 14px;
    margin-top: 14px;
    border: 1px dashed #cbd5e1;
    border-radius: 20px;
    background: #ffffff;
    color: #1e293b;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    text-decoration: none;
}
.btn-new-chat:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.sidebar-chat-list {
    flex: 1;
    overflow-y: auto;
    margin: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-chat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    color: #475569;
    font-size: 0.86rem;
    font-weight: 400;
    transition: background 0.12s ease;
    text-decoration: none;
}
.sidebar-chat-item:hover {
    background: #f8fafc;
    color: #0f172a;
}
.sidebar-chat-item.active {
    background: #f1f5f9;
    color: #0f172a;
    font-weight: 600;
}
.sidebar-chat-item i {
    font-size: 1rem;
    color: #64748b;
}

.sidebar-bottom {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.usage-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.usage-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    color: #475569;
    font-weight: 600;
}
.usage-bar-track {
    height: 4px;
    width: 100%;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}
.usage-bar-fill {
    height: 100%;
    background: #0f172a;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.sidebar-action-link {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: #475569;
    font-weight: 500;
    background: none;
    border: none;
    padding: 4px 0;
    cursor: pointer;
    text-decoration: none;
    width: 100%;
}
.sidebar-action-link:hover {
    color: #0f172a;
}

/* Main Panel Right */
.astroweb-main {
    display: flex;
    flex-direction: column;
    background: #fafafa;
    position: relative;
    height: 100%;
    min-width: 0;
    overflow: hidden;
}

.astroweb-topbar {
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}

.astroweb-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.astroweb-agent-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #0f172a;
    margin: 0;
}

.astroweb-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 24px;
    margin: auto;
    max-width: 620px;
}

.astroweb-empty-title {
    font-size: clamp(1.6rem, 3.5vw, 2.3rem);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #0f172a;
    line-height: 1.15;
    margin-bottom: 12px;
}

.astroweb-empty-subtitle {
    font-size: 0.92rem;
    color: #64748b;
    line-height: 1.5;
    margin: 0;
}

.astroweb-input-container {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 6px 8px 6px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(840px, calc(100% - 32px));
    margin: 14px auto;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    flex-shrink: 0;
}

.astroweb-input-container textarea {
    border: none;
    background: transparent;
    padding: 6px 0;
    outline: none;
    box-shadow: none;
    font-size: 0.92rem;
    resize: none;
    min-height: 38px;
    max-height: 140px;
    flex: 1;
}

.astroweb-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #ffffff;
    display: grid;
    place-items: center;
    border: none;
    font-size: 1.05rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
}
.astroweb-send-btn.active, .astroweb-send-btn:not([disabled]) {
    background: #0f172a;
    color: #ffffff;
}

@media (max-width: 820px) {
    .chat-shell-astroweb {
        grid-template-columns: 1fr;
    }
    .astroweb-sidebar {
        display: none;
    }
}

.chat-header {
    padding: 14px 18px;
    border: 1px solid var(--border);
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-radius: 12px;
    box-shadow: none;
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.chat-agent-avatar {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: #f1f5f9;
    color: var(--blue);
    display: grid;
    place-items: center;
    font-size: 1.25rem;
    border: 1px solid var(--border);
    flex-shrink: 0;
    overflow: hidden;
}

.agent-avatar-img, .avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.chat-agent-details h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-agent-prompt-toggle {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.78rem;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 3px;
    font-weight: 500;
}
.chat-agent-prompt-toggle:hover {
    color: var(--blue);
}

.chat-prompt-collapse {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.82rem;
    color: #475569;
    margin-top: 4px;
    display: none;
    line-height: 1.45;
}
.chat-prompt-collapse.show {
    display: block;
}

.chat-history {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    border: 1px solid var(--border);
    background: #ffffff;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-radius: 12px;
    box-shadow: none;
}

.chat-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    max-width: 88%;
}

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

.chat-row.assistant {
    align-self: flex-start;
}

.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    font-size: 0.95rem;
    flex-shrink: 0;
    margin-top: 2px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.chat-row.assistant .chat-avatar {
    background: #f8fafc;
    color: var(--blue);
}

.chat-row.user .chat-avatar {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
}

.chat-bubble-container {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-width: 100%;
}

.chat-author-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 2px;
}

.chat-author {
    font-size: 0.7rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.chat-action-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.chat-action-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 500;
    color: #475569;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.chat-action-btn:hover {
    background: #f8fafc;
    color: #0f172a;
    border-color: #cbd5e1;
}

.chat-action-btn.playing {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.tts-word-highlight {
    background: #fef08a;
    color: #0f172a;
    border-radius: 3px;
    padding: 0 2px;
    box-shadow: 0 0 0 1px #fde047;
    transition: background 0.1s ease;
}

.chat-row.user .chat-author {
    text-align: right;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.92rem;
    line-height: 1.5;
    box-shadow: none;
    word-break: break-word;
}

.chat-row.assistant .chat-bubble {
    background: #f8fafc;
    border: 1px solid var(--border);
    color: #1e293b;
    border-top-left-radius: 2px;
}

.chat-row.user .chat-bubble {
    background: var(--blue);
    color: #ffffff;
    border: 1px solid var(--blue);
    border-top-right-radius: 2px;
}

/* Dynamic Textarea & Input Form */
.chat-input-wrapper {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    box-shadow: none;
    flex-shrink: 0;
}

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

.chat-input-form textarea {
    flex: 1;
    min-height: 40px;
    max-height: 160px;
    border: none;
    box-shadow: none;
    padding: 6px 4px;
    resize: none;
    font-size: 0.92rem;
    line-height: 1.45;
    background: transparent;
}
.chat-input-form textarea:focus {
    outline: none;
}

.chat-send-btn {
    width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    border-radius: 8px;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    box-shadow: none;
    flex-shrink: 0;
}

/* Markdown formatting inside chat bubbles */
.markdown-body {
    font-size: 0.95rem;
    line-height: 1.6;
}

.markdown-body p {
    margin: 0 0 0.6em 0;
}
.markdown-body p:last-child {
    margin-bottom: 0;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
    font-weight: 750;
    margin: 0.8em 0 0.4em 0;
    line-height: 1.3;
}
.markdown-body h1 { font-size: 1.3rem; }
.markdown-body h2 { font-size: 1.15rem; }
.markdown-body h3 { font-size: 1.05rem; }
.markdown-body h4 { font-size: 0.95rem; }

.markdown-body ul, .markdown-body ol {
    margin: 0.4em 0 0.6em 1.2em;
    padding: 0;
}
.markdown-body li {
    margin-bottom: 0.25em;
}

.markdown-body blockquote {
    margin: 0.6em 0;
    padding: 6px 12px;
    border-left: 3px solid var(--blue);
    background: rgba(59, 130, 246, 0.05);
    border-radius: 0 6px 6px 0;
    color: #475569;
    font-style: italic;
}

.chat-row.user .markdown-body blockquote {
    border-left-color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
    color: #f1f5f9;
}

/* Code styling */
.markdown-body code {
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.86em;
    padding: 2px 6px;
    border-radius: 5px;
}

.chat-row.assistant .markdown-body code:not(pre code) {
    background: #f1f5f9;
    color: #0f172a;
    border: 1px solid #e2e8f0;
}

.chat-row.user .markdown-body code:not(pre code) {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.markdown-body pre {
    position: relative;
    margin: 0.6em 0;
    padding: 12px 14px;
    background: #0f172a;
    color: #f8fafc;
    border-radius: 10px;
    overflow-x: auto;
    font-size: 0.86em;
    line-height: 1.45;
}

.markdown-body pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    border: none;
    display: block;
}

.code-block-wrapper {
    margin: 0.8em 0;
    border-radius: 10px;
    overflow: hidden;
    background: #0f172a;
    border: 1px solid #1e293b;
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1e293b;
    color: #94a3b8;
    font-size: 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    padding: 6px 12px;
}

.code-copy-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #cbd5e1;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.15s ease;
}
.code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.6em 0;
    font-size: 0.88rem;
}
.markdown-body th, .markdown-body td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    text-align: left;
}
.markdown-body th {
    background: #f8fafc;
    font-weight: 700;
}
.chat-row.user .markdown-body th {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}
.chat-row.user .markdown-body td, .chat-row.user .markdown-body th {
    border-color: rgba(255, 255, 255, 0.25);
}

.markdown-body a {
    color: var(--blue);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.chat-row.user .markdown-body a {
    color: #93c5fd;
}

/* Thinking Dots Animation */
.thinking-bubble {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 18px;
}
.thinking-dots {
    display: flex;
    align-items: center;
    gap: 5px;
}
.thinking-dots span {
    width: 7px;
    height: 7px;
    background: var(--blue);
    border-radius: 50%;
    animation: thinking-bounce 1.4s infinite ease-in-out both;
}
.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }

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

.market-filter { display: grid; grid-template-columns: 1fr auto auto auto; gap: 12px; align-items: end; }
.rating-stars { display: flex; gap: 5px; }
.star-button { background: #ffffff; border: 1px solid var(--border); min-width: 38px; min-height: 38px; font-weight: 700; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);  border-radius: 8px; }
.star-button.active, .star-button:hover { background: var(--orange); }

.profile-banner { background: #0f172a; color: #ffffff; padding: 30px; border: 1px solid var(--border); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);  border-radius: 16px; }
.avatar { width: 76px; height: 76px; display: grid; place-items: center; background: var(--blue); color: #ffffff; border: 1px solid var(--white); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05); font-size: 2rem; font-weight: 700;  border-radius: 50%; }

.site-footer { margin-top: 60px; background: #0f172a; color: #ffffff; border-top: 2px solid var(--blue); }
.footer-wrap { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 30px 0; display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; }

.empty { text-align: center; padding: 54px 24px; border: 1px dashed var(--border); background: #ffffff; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05); }
.code-like { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hidden { display: none !important; }

#mobile-nav {
    background: #ffffff;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
}
#mobile-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 500;
    color: #334155;
}
#mobile-nav .nav-link:hover {
    background: #f8fafc;
    color: #0f172a;
}

@media (max-width: 980px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hero, .dashboard-grid, .auth-shell { grid-template-columns: 1fr; }
    .auth-intro { border-right: 0; border-bottom: 1px solid var(--border); min-height: 380px; }
    .dashboard-sidebar { position: static; }
    .nav-links { display: none !important; }
    .mobile-menu { display: inline-flex !important; }
    .market-filter { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .nav-wrap { min-height: 64px; }
    .nav-actions .btn:not(.mobile-menu) { display: none; }
    .hero { padding: 28px 0; }
    .hero-copy::after { display: none; }
    .section { padding: 38px 0; }
    .page-header, .split-header, .space-between { align-items: stretch; flex-direction: column; }
    .market-filter { grid-template-columns: 1fr; }
    .chat-shell { height: calc(100vh - 90px); padding: 14px 0; }
    .chat-header { align-items: flex-start;  border-radius: 12px; }
    .chat-input { flex-direction: column;  border-radius: 12px; }
    .auth-form-wrap { padding: 22px 16px 40px; }
    .auth-intro { min-height: 320px; }
}

/* Material 3 style toggle switch */
.m3-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}
.m3-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.m3-switch .m3-track {
    position: relative;
    width: 52px;
    height: 32px;
    border-radius: 999px;
    background: #e2e8f0;
    border: 2px solid #94a3b8;
    box-sizing: border-box;
    flex-shrink: 0;
    transition: background 0.18s ease-out, border-color 0.18s ease-out;
}
.m3-switch .m3-track::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 2px;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid #94a3b8;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    box-sizing: border-box;
    transition: left 0.18s ease-out, background 0.18s ease-out, border-color 0.18s ease-out;
}
.m3-switch input:checked + .m3-track {
    background: #155eef;
    border-color: #155eef;
}
.m3-switch input:checked + .m3-track::after {
    left: 24px;
    background: #ffffff;
    border-color: #ffffff;
}
.m3-switch input:focus-visible + .m3-track {
    outline: 3px solid rgba(21, 94, 239, 0.35);
    outline-offset: 2px;
}
.m3-switch .m3-switch-text strong {
    font-weight: 600;
}

/* Minimal steps for getting a free API key */
.key-howto {
    margin-top: 10px;
    font-size: 0.85rem;
}
.key-howto summary {
    cursor: pointer;
    color: #155eef;
    font-weight: 600;
    font-size: 0.82rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.key-howto ol {
    margin: 10px 0 0 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--text-secondary, #475569);
}
.key-howto code {
    font-family: var(--font-mono, monospace);
    background: rgba(21, 94, 239, 0.08);
    padding: 1px 6px;
    border-radius: 6px;
    font-size: 0.8em;
}
