/* Public + Member theme - ChatGPT-inspired dark mode: a near-black sidebar, a dark gray main
   content area, and one restrained white glow accent carried over from this app's earlier
   "black + neon white" identity. Every selector here is scoped under .theme-noir so it can't
   leak into the Material admin theme. */

.theme-noir {
    --bg: #212121;
    --sidebar-bg: #171717;
    --surface: #2a2a2a;
    --surface-alt: #2f2f2f;
    --surface-hover: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.22);
    --text: #ececec;
    --text-dim: #9b9b9b;
    --glow: rgba(255, 255, 255, 0.35);
    --danger: #f85149;
    --danger-glow: rgba(248, 81, 73, 0.35);
    /* Only exist so the Material-theme .md-switch component (used by ThemeSettingsPanel, shared
       across both themes) has something to resolve under .theme-noir too - not used anywhere
       else here. */
    --text-secondary: var(--text-dim);
    --accent: rgba(255, 255, 255, 0.6);
    --accent-strong: #ffffff;
    --accent-tint: rgba(255, 255, 255, 0.14);
    --font-display: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    height: 100vh;
    overflow: hidden;
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    display: flex;
}

/* Light-mode override - toggled from Settings (ThemeService), persisted in local storage. Every
   surface in this theme already routes through the custom properties above, so remapping just
   these is the whole light theme - no selector-by-selector rework needed. */
.theme-noir.light-mode {
    --bg: #ffffff;
    --sidebar-bg: #f7f7f8;
    --surface: #f0f0f1;
    --surface-alt: #ececed;
    --surface-hover: rgba(0, 0, 0, 0.05);
    --border: rgba(0, 0, 0, 0.1);
    --border-strong: rgba(0, 0, 0, 0.2);
    --text: #1a1a1a;
    --text-dim: #6e6e6e;
    --text-secondary: #6e6e6e;
    --glow: rgba(0, 0, 0, 0.2);
    --accent: rgba(0, 0, 0, 0.5);
    --accent-strong: #1a1a1a;
    --accent-tint: rgba(0, 0, 0, 0.08);
}

.theme-noir h1 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
}

.theme-noir h2, .theme-noir h3, .theme-noir h4, .theme-noir h5 {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--text);
}

.theme-noir a {
    color: var(--text);
}

/* --- Shell layout: sidebar + main --- */

.cg-shell {
    display: flex;
    width: 100%;
    height: 100%;
}

.cg-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.cg-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1rem 1rem 0.75rem;
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    flex-shrink: 0;
}

.cg-sidebar-brand .glow-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--text);
    box-shadow: 0 0 10px var(--glow), 0 0 20px var(--glow);
    flex-shrink: 0;
}

.cg-sidebar-logo {
    width: 22px;
    height: 22px;
    object-fit: contain;
    border-radius: 5px;
    flex-shrink: 0;
}

.cg-sidebar-nav a i {
    width: 1.1rem;
    text-align: center;
    flex-shrink: 0;
}

.cg-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.25rem 0.6rem;
    flex-shrink: 0;
}

.cg-sidebar-nav a, .cg-sidebar-nav button.cg-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    color: var(--text-dim);
    font-size: 0.875rem;
    font-weight: 500;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-family: var(--font-body);
    width: 100%;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.cg-sidebar-nav a:hover, .cg-sidebar-nav a.active, .cg-sidebar-nav button.cg-link:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.cg-sidebar-section-label {
    padding: 1rem 0.9rem 0.4rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    flex-shrink: 0;
}

.cg-sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.6rem;
    min-height: 0;
}

.cg-sidebar-footer {
    flex-shrink: 0;
    padding: 0.75rem 0.6rem;
    border-top: 1px solid var(--border);
}

.cg-sidebar-footer .cg-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.3rem 0.5rem 0.85rem;
    margin-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}

.cg-user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cg-sidebar-footer a, .cg-sidebar-footer button.cg-link {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.45rem 0.5rem;
    border-radius: 8px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: var(--font-body);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.cg-sidebar-footer a:hover, .cg-sidebar-footer a.active, .cg-sidebar-footer button.cg-link:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.cg-sidebar-footer a i, .cg-sidebar-footer button.cg-link i {
    width: 1.1rem;
    text-align: center;
    flex-shrink: 0;
    margin-right: 0.2rem;
}

.cg-copyright {
    margin: 0.5rem 0 0;
    padding: 0 0.5rem;
    font-size: 0.7rem;
    color: var(--text-dim);
    opacity: 0.7;
}

/* Mobile: off-canvas drawer */
.cg-sidebar-toggle {
    display: none;
}

.cg-backdrop {
    display: none;
}

.cg-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* Top-right "Log In / Signup" pill - visible at every viewport width (unlike .cg-topbar, which is
   mobile-only and holds the hamburger toggle instead), so it needs its own spot rather than
   living inside that bar. */
.cg-topright {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    z-index: 5;
}

.cg-topright a {
    display: inline-block;
    padding: 0.45rem 1rem;
    border-radius: 999px;
    background: var(--surface-alt);
    border: 1px solid var(--border-strong);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}

.cg-topright a:hover {
    background: var(--surface-hover);
    border-color: rgba(255, 255, 255, 0.4);
}

.cg-link-inline {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: inherit;
    font-family: var(--font-body);
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
}

.cg-link-inline:hover {
    color: var(--text);
}

.cg-topbar {
    display: none;
    flex-shrink: 0;
}

/* Full-width on purpose: this is what owns overflow-y, so its scrollbar sits flush at .cg-main's
   true right edge. The width-constrained, centered look lives on .cp-content-inner instead -
   splitting the two was a deliberate fix: when this element used to carry BOTH the scroll AND the
   max-width/margin:auto centering, its own scrollbar rendered at the edge of the centered 860px
   column (wherever that landed on a wide viewport), not the window's real edge - a vertical
   scrollbar floating mid-page with a blank strip of background past it, easy to mistake for a
   second, broken sidebar. Noticeable mainly on tall/scrollable pages (Features) since most other
   pages fit one viewport and never actually needed to scroll. */
.cp-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.cp-content-inner {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 2.5rem 2rem;
    max-width: 860px;
    width: 100%;
    margin: 0 auto;
}

/* --- History list (chat sessions, rendered into the sidebar via SectionOutlet) --- */

.cg-history-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-bottom: 0.5rem;
}

.cg-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.7rem;
    border-radius: 8px;
    color: var(--text-dim);
    font-size: 0.82rem;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-family: var(--font-body);
    transition: background-color 0.12s ease, color 0.12s ease;
}

.cg-history-item:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.cg-history-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
    font-weight: 600;
}

.cg-history-item .count {
    font-size: 0.72rem;
    color: var(--text-dim);
    opacity: 0.8;
}

/* --- Components --- */

.theme-noir .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.theme-noir .btn {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.85rem;
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text);
    padding: 0.55rem 1.1rem;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.theme-noir .btn:hover:not(:disabled) {
    background: var(--surface-hover);
}

.theme-noir .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.theme-noir .btn-primary {
    background: var(--text);
    color: #171717;
    font-weight: 700;
    border-color: var(--text);
}

.theme-noir .btn-primary:hover:not(:disabled) {
    box-shadow: 0 0 16px var(--glow);
}

.theme-noir .btn-danger {
    border-color: var(--danger);
    color: var(--danger);
}

.theme-noir .btn-danger:hover:not(:disabled) {
    background: rgba(248, 81, 73, 0.12);
}

.theme-noir .btn-ghost {
    border-color: var(--border);
    color: var(--text-dim);
}

.theme-noir .btn-ghost:hover:not(:disabled) {
    color: var(--text);
    border-color: var(--border-strong);
}

.theme-noir .btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.75rem;
}

.theme-noir .field {
    margin-bottom: 1rem;
}

.theme-noir label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-bottom: 0.4rem;
}

.theme-noir .input,
.theme-noir textarea.input,
.theme-noir select.input {
    width: 100%;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.6rem 0.75rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    border-radius: 8px;
    outline: none;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.theme-noir .input::placeholder {
    color: var(--text-dim);
}

.theme-noir .input:focus {
    border-color: var(--border-strong);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.theme-noir .alert {
    border: 1px solid var(--danger);
    background: rgba(248, 81, 73, 0.1);
    color: #ffb4b0;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
}

.theme-noir .muted {
    color: var(--text-dim);
}

.theme-noir table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.theme-noir th {
    text-align: left;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    font-weight: 500;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-strong);
}

.theme-noir td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.theme-noir tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.theme-noir .stat-tile {
    display: inline-block;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.9rem 1.4rem;
    border-radius: 12px;
    margin-bottom: 1.25rem;
}

.theme-noir .stat-tile .stat-value {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.7rem;
    color: var(--text);
    display: block;
}

.theme-noir .stat-tile .stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
}

.theme-noir .badge {
    display: inline-block;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    margin-left: 0.5rem;
    border: 1px solid currentColor;
    vertical-align: middle;
}

.theme-noir .badge-primary {
    color: var(--text);
}

.theme-noir .badge-muted {
    color: var(--text-dim);
}

/* --- Agent grid (My Agents) --- */

.cg-agent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.cg-agent-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.cg-agent-card:hover {
    border-color: var(--border-strong);
}

.cg-agent-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}

.cg-agent-card-header h3 {
    margin: 0;
    font-size: 1rem;
}

/* --- Features page (Pages/Features.razor) --- */

.cg-feature-card {
    padding: 0;
    overflow: hidden;
    gap: 0;
}

.cg-feature-image {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-bottom: 1px solid var(--border);
}

.cg-feature-card .cg-agent-card-header,
.cg-feature-card p.muted {
    padding: 0 1.25rem;
}

.cg-feature-card .cg-agent-card-header {
    margin-top: 1.1rem;
}

.cg-feature-card p.muted {
    padding-bottom: 1.25rem;
}

/* --- Task board (Member/Tasks.razor) --- */

.cg-task-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    align-items: start;
}

.cg-task-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    padding: 0 0.2rem 0.75rem;
}

.cg-task-count {
    background: var(--surface-hover);
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    font-size: 0.72rem;
}

.cg-task-empty {
    font-size: 0.82rem;
    padding: 0.4rem 0.2rem;
}

.cg-task-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.cg-task-card h4 {
    margin: 0 0 0.4rem;
    font-size: 0.92rem;
}

.cg-task-description {
    font-size: 0.82rem;
    line-height: 1.4;
    color: var(--text-dim);
    margin: 0 0 0.5rem;
}

.cg-task-note {
    font-size: 0.82rem;
    line-height: 1.4;
    font-style: italic;
    color: var(--text-dim);
    background: var(--surface-hover);
    border-radius: 8px;
    padding: 0.5rem 0.65rem;
    margin: 0 0 0.5rem;
}

.cg-task-timestamp {
    font-size: 0.72rem;
    color: var(--text-dim);
    opacity: 0.75;
    margin: 0;
}

.cg-task-recheck {
    font-size: 0.72rem;
    color: var(--text-dim);
    opacity: 0.75;
    margin: 0.15rem 0 0;
}

.cg-agent-card p.muted {
    font-size: 0.82rem;
    line-height: 1.4;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cg-agent-card-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.cg-new-agent-tile {
    background: transparent;
    border: 1.5px dashed var(--border-strong);
    border-radius: 14px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-dim);
    cursor: pointer;
    min-height: 120px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: border-color 0.15s ease, color 0.15s ease;
    width: 100%;
}

.cg-new-agent-tile:hover {
    border-color: var(--border-strong);
    color: var(--text);
    background: var(--surface-hover);
}

.cg-new-agent-tile .plus {
    font-size: 1.6rem;
    line-height: 1;
}

/* --- Chat page --- */

.cg-chat-page {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    /* Anchors .cg-composer-wrap, which is always absolutely positioned within this box - both its
       "centered" (landing) and default (docked) states, so the transition between them animates
       smoothly instead of jumping between position: static and position: absolute. */
    position: relative;
}

/* ChatGPT-style landing state (ChatBox's LandingMode, before the first message is sent) - takes
   the place of .cg-messages entirely while centered.
   Anchored to the SAME "top: 42%" reference point .cg-composer-wrap.centered uses below, via
   absolute positioning rather than flex layout - a flex-based "push to just above the composer"
   approach (e.g. flex:1 + justify-content:flex-end) computes its own independent position from
   the surrounding box's height, which drifts apart from the composer's fixed 42% anchor on short
   viewports (confirmed broken on mobile: the heading landed BELOW the composer). Sharing one
   anchor point keeps them visually coupled at any viewport size. */
.cg-landing-heading {
    position: absolute;
    left: 0;
    right: 0;
    top: 42%;
    transform: translateY(calc(-100% - 3rem));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.9rem;
    text-align: center;
    padding: 0 2rem;
    animation: cg-landing-fade-in 0.3s ease;
}

.cg-landing-heading h2 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
}

@keyframes cg-landing-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.cg-chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 1rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.cg-chat-header h1 {
    margin: 0;
    font-size: 1.15rem;
}

.cg-messages {
    flex: 1;
    overflow-y: auto;
    margin: 0 -2rem;
    /* Extra bottom padding reserves room for .cg-composer-wrap, which is always position: absolute
       (see .cg-chat-page) and so no longer pushes this element's height via normal flex flow. 8rem
       was measured live against the composer's real rendered height (~124px including its own
       padding and the 0.5rem bottom offset) - a smaller 6.5rem value looked reasonable but left a
       real, if small, residual overlap even scrolled all the way to the bottom. */
    padding: 0.5rem 2rem 8rem;
}

.cg-message-row {
    display: flex;
    gap: 1rem;
    padding: 1.1rem 0;
    max-width: 720px;
    margin: 0 auto;
}

.cg-message-row.assistant {
    background: rgba(255, 255, 255, 0.025);
    margin: 0 -1.25rem;
    padding: 1.1rem 1.25rem;
    border-radius: 12px;
}

.cg-message-row.assistant + .cg-message-row.assistant {
    margin-top: -0.5rem;
}

/* One row standing in for a whole Talk-mode call (ChatBox.razor's BuildDisplayGroups) - WhatsApp-
   style call-log line, not a chat bubble: centered, muted, no avatar. */
.cg-call-log {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0.6rem auto;
    padding: 0.45rem 1rem;
    max-width: fit-content;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-dim);
    font-size: 0.85rem;
}

.cg-call-log i {
    color: var(--accent-strong, currentColor);
}

.cg-message-body {
    flex: 1;
    min-width: 0;
    padding-top: 0.2rem;
    line-height: 1.65;
    font-size: 0.95rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.cg-message-body .who {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-bottom: 0.25rem;
}

.cg-message-image {
    display: block;
    max-width: 320px;
    width: 100%;
    border-radius: 10px;
    margin-top: 0.5rem;
    border: 1px solid var(--border);
}

.cg-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    gap: 0.5rem;
    color: var(--text-dim);
}

/* Rendered inside .cg-composer-wrap itself (see ChatBox.razor's comment there for why a sibling
   placement doesn't work), so it shares .cg-composer's 720px centered column automatically once
   nested the same way - this just adds a bit of breathing room above the input box. */
.cg-send-error {
    max-width: 720px;
    margin: 0 auto 0.75rem;
}

.cg-composer-wrap {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0.5rem;
    transform: translateY(0);
    padding: 1rem 0 0.5rem;
    transition: top 0.45s cubic-bezier(0.4, 0, 0.2, 1), bottom 0.45s ease, transform 0.45s ease;
}

/* Landing state (see .cg-landing-heading): the exact same element, just repositioned - this is
   what makes "type the first message and the composer drops to the bottom" an animation instead
   of a layout jump (position: absolute -> position: static isn't animatable, position: absolute
   with a changing top/transform is). */
.cg-composer-wrap.centered {
    top: 42%;
    bottom: auto;
    transform: translateY(-50%);
}

.cg-composer {
    max-width: 720px;
    margin: 0 auto;
}

.cg-composer-box {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--surface-alt);
    border: 1px solid var(--border-strong);
    border-radius: 1.5rem;
    padding: 0.55rem 0.6rem 0.55rem 1.1rem;
}

.cg-composer-box:focus-within {
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.cg-composer-box textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.95rem;
    line-height: 1.4;
    max-height: 160px;
    padding: 0.35rem 0;
}

.cg-composer-box textarea::placeholder {
    color: var(--text-dim);
}

.cg-send-btn {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--text);
    color: #171717;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: opacity 0.15s ease;
}

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

.cg-readonly-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-dim);
    font-size: 0.85rem;
}

/* --- Responsive: tablet --- */
@media (max-width: 900px) {
    .cp-content-inner {
        max-width: 100%;
        padding: 1.75rem 1.5rem;
    }
}

/* --- Responsive: mobile (sidebar becomes an off-canvas drawer) --- */
@media (max-width: 780px) {
    .cg-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
    }

    .cg-sidebar.open {
        transform: translateX(0);
    }

    .cg-backdrop.open {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 40;
    }

    .cg-topbar {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.85rem 1rem;
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        background: var(--bg);
        z-index: 30;
    }

    .cg-sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: 8px;
        background: none;
        border: 1px solid var(--border);
        color: var(--text);
        cursor: pointer;
        font-size: 1.1rem;
        flex-shrink: 0;
    }

    .cg-topbar-brand {
        font-family: var(--font-display);
        font-weight: 700;
    }

    /* .cg-topbar is sticky at the very top on mobile - push the login pill below it instead of
       letting the two overlap. */
    .cg-topright {
        top: 4.5rem;
        right: 1rem;
    }

    .cp-content-inner {
        padding: 1.25rem 1rem;
    }

    .theme-noir h1 {
        font-size: 1.4rem;
    }

    .theme-noir .card {
        padding: 1rem;
    }

    .cg-agent-grid {
        grid-template-columns: 1fr;
    }

    .cg-task-board {
        grid-template-columns: 1fr;
    }

    .cg-messages {
        margin: 0 -1rem;
        /* The base rule's third value (8rem bottom) reserves room for .cg-composer-wrap, which
           is always position: absolute and pinned to the bottom of the page - this override was
           only meant to tighten the side margins for narrower screens, but the 2-value shorthand
           silently zeroed that reserve back down to 0.5rem too, so on mobile the composer covered
           the newest messages once a conversation scrolled to the bottom. Keep all three values
           in sync with the base rule. */
        padding: 0.5rem 1rem 8rem;
    }

    .cg-message-row.assistant {
        margin: 0 -0.5rem;
        padding: 1rem 0.75rem;
    }

}

/* --- Readability pass --- */
.theme-noir { color-scheme: dark; }
.theme-noir.light-mode { color-scheme: light; }
.theme-noir.light-mode .alert { color: #9d1f17; }
