/* ecolyxis.css — app-specific widgets (chat, modals, toasts, workspace UI)
   restyled for the Syntrans dark glass theme (body #343a40 + bg image,
   translucent black cards, light text). Extracted from the retired style.css;
   layout, buttons and typography now come from Bootstrap 5 / Syntrans app.css.
   In-flow surfaces use the translucent glass --bg-card; floating surfaces
   (menus, modals) use the solid --bg-elevated so content can't bleed through. */
:root {
    --bg: #262b31;
    --bg-card: rgb(0 0 0 / 0.24);
    --bg-elevated: #262b31;
    --bg-sidebar: rgb(0 0 0 / 0.24);
    --bg-secondary: #2e343b;
    --bg-input: rgb(0 0 0 / 0.26);
    --bg-primary: #262b31;
    --bg-tertiary: rgb(255 255 255 / 0.08);
    --bg-hover: rgb(255 255 255 / 0.08);
    --text: #e5e9ec;
    --text-secondary: #b8c1c8;
    --text-muted: #99a4ad;
    --green-primary: #2ecc71;
    --green-hover: #58d68d;
    --primary: #2da44e;
    --primary-hover: #218838;
    --accent: #58a6ff;
    --accent-secondary: #a78bfa;
    --danger: #f85149;
    --danger-hover: #da3633;
    --warning: #d29922;
    --border: rgb(255 255 255 / 0.14);
    --border-color: rgb(255 255 255 / 0.12);
    --card-bg: rgb(0 0 0 / 0.24);
    --on-primary: #ffffff;
    --radius: 8px;
    --text-primary: #e5e9ec;

    /* Bootstrap 5 root variable overrides — BS5 hard-codes light values
       (--bs-body-bg: #fff, --bs-body-color: #212529) at :root.  Without
       overriding them, every BS5 component that references these vars
       (.form-control, .modal-content, .input-group-text, etc.) inherits
       white backgrounds with near-black text.  Pin them to the dark theme
       so all BS5 components match without needing per-component overrides. */
    --bs-body-bg: #262b31;
    --bs-body-bg-rgb: 38, 43, 49;
    --bs-body-color: #e5e9ec;
    --bs-body-color-rgb: 229, 233, 236;
    --bs-emphasis-color: #ffffff;
    --bs-emphasis-color-rgb: 255, 255, 255;
    --bs-secondary-color: rgba(229, 233, 236, 0.75);
    --bs-secondary-color-rgb: 229, 233, 236;
    --bs-secondary-bg: #2e343b;
    --bs-secondary-bg-rgb: 46, 52, 59;
    --bs-tertiary-color: rgba(229, 233, 236, 0.5);
    --bs-tertiary-color-rgb: 229, 233, 236;
    --bs-tertiary-bg: #30363d;
    --bs-tertiary-bg-rgb: 48, 54, 61;
    --bs-border-color: rgb(255 255 255 / 0.14);
    --bs-border-color-translucent: rgba(255, 255, 255, 0.14);
    --bs-highlight-bg: rgba(210, 153, 34, 0.2);
    --bs-card-bg: rgb(0 0 0 / 0.24);
    --bs-card-color: inherit;
    --bs-modal-bg: #262b31;
    --bs-modal-color: #e5e9ec;
}

/* Bootstrap 5 reconciliation — BS5 ships blue always-underlined links and
   blue focus rings; restore the theme's look (green accents, underline on
   hover only). Loaded after bootstrap.min.css/app.css so these win. */
a {
    color: #2ecc71;
    text-decoration: none;
}
a:hover {
    color: #58d68d;
    text-decoration: underline;
}
/* Form controls: BS5 sets background-color: var(--bs-body-bg) which is now
   overridden above, but also explicitly pin translucent bg + light text so
   disabled inputs and input-group-text stay readable on the dark theme. */
.form-control, .form-select {
    background-color: var(--bg-input);
    color: var(--text);
    border-color: var(--border);
}
.form-control:focus, .form-select:focus {
    border-color: #2ea44f;
    box-shadow: 0 0 0 0.2rem rgba(46, 164, 79, 0.25);
}
.form-control:disabled, .form-control[readonly] {
    background-color: var(--bg-secondary);
    color: var(--text-muted);
    opacity: 0.7;
}
.form-control::placeholder {
    color: var(--text-muted);
}
.input-group-text {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    border-color: var(--border);
}
.form-check-input:checked {
    background-color: #2ea44f;
    border-color: #2ea44f;
}
.form-check-input:focus {
    border-color: #2ea44f;
    box-shadow: 0 0 0 0.2rem rgba(46, 164, 79, 0.25);
}
/* BS5 cards likewise pin their own colour var (--bs-card-color, near-black),
   which the BS4-era Syntrans theme never expected — its glass cards rely on
   inheriting the light body text. Restore inheritance, and lighten the
   muted-text utility (BS5 maps it to a dark gray with !important). */
.card { color: inherit; }
.text-muted { color: rgb(229 233 236 / 0.68) !important; }

/* BS5 tables carry their own colour vars (dark text on transparent) which
   are unreadable on the dark theme */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: #e5e9ec;
    --bs-table-border-color: rgb(255 255 255 / 0.14);
    --bs-table-striped-color: #e5e9ec;
    --bs-table-striped-bg: rgb(255 255 255 / 0.04);
    --bs-table-hover-color: #ffffff;
    --bs-table-hover-bg: rgb(255 255 255 / 0.06);
}

/* Primary buttons use the Ecolyxis brand green — the stock Syntrans build
   ships them purple (#673ab7). Loaded after bootstrap.min.css/app.css so
   these equal-specificity rules win. */
.btn-primary {
    color: #fff;
    background-color: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover,
.btn-primary:focus, .btn-primary.focus,
.btn-primary.disabled, .btn-primary:disabled,
.btn-primary:not(:disabled):not(.disabled):active,
.btn-primary:not(:disabled):not(.disabled).active,
.show > .btn-primary.dropdown-toggle {
    color: #fff;
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}
.btn-primary:focus, .btn-primary.focus,
.btn-primary:not(:disabled):not(.disabled):active:focus,
.btn-primary:not(:disabled):not(.disabled).active:focus,
.show > .btn-primary.dropdown-toggle:focus {
    box-shadow: 0 0 0 0.2rem rgba(45, 164, 78, 0.5);
}
.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline-primary:hover,
.btn-outline-primary:not(:disabled):not(.disabled):active,
.btn-outline-primary:not(:disabled):not(.disabled).active,
.show > .btn-outline-primary.dropdown-toggle {
    color: #fff;
    background-color: var(--primary);
    border-color: var(--primary);
}
.btn-outline-primary:focus, .btn-outline-primary.focus,
.btn-outline-primary:not(:disabled):not(.disabled):active:focus,
.btn-outline-primary:not(:disabled):not(.disabled).active:focus {
    box-shadow: 0 0 0 0.2rem rgba(45, 164, 78, 0.5);
}

/* Auth card: darken like the pricing cards so the form reads against the
   bright regions of the bg-theme image */
.section-authentication-login .card {
    background-color: rgb(0 0 0 / 0.35);
}

/* Outline-secondary buttons sit on the dark Syntrans theme; the stock
   slate #5a7684 is nearly invisible against it — use a light outline. */
.btn-outline-secondary {
    color: #e5e9ec;
    border-color: rgba(255, 255, 255, 0.5);
}
.btn-outline-secondary:hover,
.btn-outline-secondary:not(:disabled):not(.disabled):active,
.btn-outline-secondary:not(:disabled):not(.disabled).active,
.show > .btn-outline-secondary.dropdown-toggle {
    color: #1f2328;
    background-color: #e5e9ec;
    border-color: #e5e9ec;
}
.btn-outline-secondary:focus, .btn-outline-secondary.focus,
.btn-outline-secondary:not(:disabled):not(.disabled):active:focus,
.btn-outline-secondary:not(:disabled):not(.disabled).active:focus {
    box-shadow: 0 0 0 0.2rem rgba(229, 233, 236, 0.3);
}

/* Bootstrap has no bare .btn-outline — alias used by chat.js retry buttons */
.btn-outline {
    color: var(--text);
    background-color: transparent;
    border: 1px solid var(--border);
}
.btn-outline:hover { background-color: var(--bg-hover); }

/* Public pages reuse the Syntrans wrapper without a sidebar */
.wrapper.no-sidebar .top-header { left: 0 !important; margin-left: 0 !important; }
.wrapper.no-sidebar .top-header,
.wrapper.no-sidebar .page-content-wrapper,
.wrapper.no-sidebar .footer { margin-left: 0; }

/* Sticky footer: .wrapper's height:100% never resolves (body has no fixed
   height), so the absolute-positioned .footer floats up when the content is
   shorter than the viewport. Pin the wrapper to the viewport instead. */
.wrapper { min-height: 100vh; }

/* Loading skeletons (#155) */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-secondary, #161b22) 25%,
        var(--bg-tertiary, #21262d) 50%,
        var(--bg-secondary, #161b22) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
}
.skeleton-text { height: 1rem; margin-bottom: 0.5rem; }
.skeleton-card {
    height: 80px;
    border-radius: 12px;
    margin-bottom: 1rem;
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Toast notification system (#154) */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}
.eco-toast {
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--on-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
    animation: toastIn 0.25s ease-out;
    max-width: 360px;
}
.eco-toast.eco-toast-success { background: var(--accent, #2ea44f); }
.eco-toast.eco-toast-error { background: var(--danger); }
.eco-toast.eco-toast-info { background: var(--bg-secondary, #161b22); border: 1px solid var(--border); }
@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* Billing page classes (#140) */
.billing-api-credits {
    margin-top: 1.5rem;
}
.billing-api-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.billing-api-desc {
    font-size: 0.85rem;
    opacity: 0.8;
    margin: 0.25rem 0 0;
}

/* Workspace modal disabled button (#131) */
/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}
.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.stat-link {
    text-decoration: none;
    color: inherit;
}
.stat-link:hover {
    text-decoration: none;
}
.stat-card.highlight {
    border-color: var(--green-primary);
}
.stat-card.error-highlight {
    border-color: var(--danger);
}

/* Tier Badge */
.tier-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}
.tier-free {
    background: rgba(139, 148, 158, 0.15);
    color: var(--text-muted);
}
.tier-premium {
    background: rgba(46, 204, 113, 0.15);
    color: var(--green-primary);
}
.tier-badge-sm {
    font-size: 0.65rem;
    padding: 1px 6px;
}

/* Thread Grid */
.thread-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
    gap: 16px;
}
.thread-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    position: relative;
    transition: border-color 0.2s;
    overflow: hidden;
    max-width: 100%;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.thread-card:hover {
    border-color: var(--text-muted);
}
.thread-card a {
    color: inherit;
    text-decoration: none;
}
.thread-card a:hover {
    text-decoration: none;
}
.thread-card h3 {
    font-size: 1rem;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.thread-card-meta {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
    overflow-wrap: break-word;
    min-width: 0;
}
.thread-card-snippet {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.btn-delete {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0;
    transition: opacity 0.2s;
}
.thread-card:hover .btn-delete {
    opacity: 1;
}

/* Thread export dropdown (dashboard + workspace detail) */
.btn-export {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
    position: absolute;
    top: 8px;
    right: 36px;
}
.btn-export:hover { opacity: 1; }
.export-dropdown { position: absolute; top: 4px; right: 4px; }
.export-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 50;
    min-width: 160px;
    overflow: hidden;
}
.export-menu.show { display: block; }
.export-menu a {
    display: block;
    padding: 8px 14px;
    font-size: 0.85rem;
    color: var(--text);
    text-decoration: none;
}
.export-menu a:hover { background: var(--bg-hover); }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}
.empty-state p {
    margin-bottom: 1rem;
}

/* ===== Chat ===== */
.chat-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Chat Header */
.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 56px;
    gap: 12px;
}
.chat-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}
.chat-model {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.chat-header-title {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s;
    overflow: hidden;
}
.chat-header-title:hover {
    background: var(--bg-secondary, #161b22);
}
.header-title-text {
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary, #e6edf3);
}
.header-title-edit-icon {
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity 0.15s;
    color: var(--text-muted, #8b949e);
    flex-shrink: 0;
}
.chat-header-title:hover .header-title-edit-icon {
    opacity: 1;
}
.header-title-input {
    flex: 1;
    font-size: 1.1rem;
    font-weight: 600;
    background: var(--bg-secondary, #161b22);
    color: var(--text-primary, #e6edf3);
    border: 2px solid var(--accent, #2ea44f) !important;
    border-radius: 6px;
    padding: 4px 8px;
    box-shadow: 0 0 0 3px rgba(46, 164, 79, 0.2);
    outline: none;
    border: 1px solid var(--accent, #2ecc71);
    border-radius: 4px;
    padding: 2px 6px;
    outline: none;
    min-width: 100px;
}
.chat-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.model-select {
    outline: none;
    background: var(--bg-secondary, #161b22);
    color: var(--text-muted, #8b949e);
    border: 1px solid var(--border, #30363d);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    min-width: 140px;
}
.model-select:hover {
    border-color: var(--accent, #2ecc71);
}
.model-select:focus {
    border-color: var(--accent, #2ecc71);
    box-shadow: 0 0 0 2px rgba(46, 204, 113, 0.15);
}

/* Rate Limit */
.rate-limit-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 2px 8px;
    background: var(--bg-input);
    border-radius: 10px;
}
.rate-limit-bar {
    height: 3px;
    background: var(--bg-input);
    overflow: hidden;
}
.rate-limit-fill {
    height: 100%;
    background: var(--green-primary);
    transition: width 0.3s;
}
.rate-limit-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}
.rate-limit-modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    text-align: center;
}
.rate-limit-modal-content h3 {
    margin-bottom: 1rem;
}
.rate-limit-modal-content p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}
.rate-limit-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* Chat Messages */
.chat-messages {
    touch-action: pan-y;
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Messages */
.message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    position: relative;
}
.message-content {
    flex: 1;
    min-width: 0;
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
}
.message-avatar {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.2rem;
}
.message-text {
    line-height: 1.7;
    font-size: 0.95rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.message-text p {
    margin-bottom: 0.8em;
}
.message-text p:last-child {
    margin-bottom: 0;
}
.message-text pre {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    overflow-x: auto;
    margin: 0.8em 0;
    font-size: 0.85rem;
}
.message-text code {
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}
.message-text pre code {
    background: none;
    padding: 0;
}
.message-text ul, .message-text ol {
    padding-left: 1.5em;
    margin: 0.5em 0;
}
.message-text blockquote {
    border-left: 3px solid var(--border);
    padding-left: 1em;
    color: var(--text-muted);
    margin: 0.5em 0;
}
.message-text a {
    color: var(--accent);
}
.message-text table {
    border-collapse: collapse;
    margin: 0.8em 0;
    width: 100%;
}
.message-text th, .message-text td {
    border: 1px solid var(--border);
    padding: 6px 12px;
    text-align: left;
}
.message-text th {
    background: var(--bg-input);
}


/* Token Warning/Danger */
.message-tokens-warning .message-content {
    border-left: 3px solid var(--warning);
}
.message-tokens-danger .message-content {
    border-left: 3px solid var(--danger);
}

/* Tinted user card + assistant avatar ring (turn differentiation) */
.message-user .message-content {
    background: rgba(46, 204, 113, 0.08);
    border-color: rgba(46, 204, 113, 0.28);
}
.message-avatar {
    border-radius: 50%;
    background: var(--bg-input);
    border: 1px solid var(--border);
}
.message-assistant .message-avatar {
    border-color: var(--green-primary);
    box-shadow: 0 0 0 1px rgba(46, 204, 113, 0.35);
}

/* Error message card */
.message-error .message-content {
    background: rgba(248, 81, 73, 0.08);
    border-color: rgba(248, 81, 73, 0.4);
}

/* Code blocks: language label + copy button */
.message-text pre { position: relative; }
.code-copy {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    color: var(--text-secondary);
}
.message-text pre:hover .code-copy,
.code-copy:focus-visible { opacity: 1; }
.code-lang {
    position: absolute;
    top: 6px;
    left: 10px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    pointer-events: none;
}

/* Long-answer collapsing */
.message.collapsible.collapsed .message-text {
    max-height: 640px;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, #000 78%, transparent);
            mask-image: linear-gradient(to bottom, #000 78%, transparent);
}
.collapse-toggle {
    margin-top: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.78rem;
    padding: 4px 10px;
}
.collapse-toggle:hover { color: var(--text); }

/* Card enter animation */
@keyframes msgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}
.message { animation: msgIn 0.18s ease-out; }
@media (prefers-reduced-motion: reduce) {
    .message { animation: none; }
}

/* Stop-generating button (mirrors #send-btn sizing) */
#stop-btn {
    align-items: center;
    justify-content: center;
    background: var(--danger);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: var(--on-primary);
    width: 32px;
    height: 32px;
    display: flex;
    flex-shrink: 0;
    transition: background 0.2s;
}
#stop-btn:hover {
    background: var(--danger-hover);
}
#stop-btn svg {
    width: 16px;
    height: 16px;
}

/* Image lightbox */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: zoom-out;
    padding: 24px;
}
.lightbox-overlay img {
    max-width: 95vw;
    max-height: 95vh;
    border-radius: var(--radius);
}
.message-text img { cursor: zoom-in; }

/* Generated-image caption + download */
.image-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
    font-size: 0.7rem;
    color: var(--text-muted);
}
.image-download {
    text-decoration: none;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1px 7px;
}
.image-download:hover { color: var(--text); background: var(--bg-input); }

/* Thinking Indicator */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.thinking-dots {
    display: flex;
    gap: 4px;
}
.thinking-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: dotPulse 1.4s infinite ease-in-out;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* Collapsed reasoning chip — how many "thinking" tokens were spent before
   the answer. The reasoning text itself is never shown or stored. */
.thinking-chip {
    display: inline-block;
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-muted, rgba(127, 127, 127, 0.12));
    border-radius: 10px;
    padding: 2px 8px;
    margin-bottom: 6px;
    user-select: none;
}

/* Streaming Cursor */
.streaming-cursor::after {
    content: '▊';
    animation: blink 0.7s infinite;
    color: var(--green-primary);
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ===== Context Wheel ===== */
.context-wheel {
    position: relative;
    width: 36px;
    height: 36px;
    cursor: pointer;
    flex-shrink: 0;
}
.context-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}
.context-ring-bg {
    fill: none;
    stroke: var(--bg-input);
    stroke-width: 3;
}
.context-ring-fill {
    fill: none;
    stroke: var(--green-primary);
    stroke-width: 3;
    stroke-dasharray: 97.39;
    stroke-dashoffset: 97.39;
    transition: stroke-dashoffset 0.3s, stroke 0.3s;
    stroke-linecap: round;
}
.context-ring-fill.warn {
    stroke: var(--warning);
}
.context-ring-fill.danger {
    stroke: var(--danger);
}
.context-pct {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.55rem;
    font-weight: 600;
    color: var(--text-muted);
    pointer-events: none;
}
.context-pct.warn { color: var(--warning); }
.context-pct.danger { color: var(--danger); }

/* Context Menu */
.ctx-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 0;
    min-width: 260px;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    margin-top: 4px;
}
.ctx-menu.open {
    display: block;
}
.ctx-menu-title {
    padding: 8px 14px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ctx-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.85rem;
}
.ctx-menu-item:hover {
    background: var(--bg-input);
}
.ctx-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}
.ctx-label {
    display: block;
    font-weight: 500;
}
.ctx-desc {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.ctx-menu-sep {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* ===== Chat Input Area ===== */
.chat-input-area {
    border-top: 1px solid var(--border);
    padding: 12px 24px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
}
#chat-form {
    max-width: 800px;
    margin: 0 auto;
}
.image-preview-area {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.image-preview-item {
    position: relative;
    width: 60px;
    height: 60px;
}
.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.image-preview-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--danger);
    color: var(--on-primary);
    border: none;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 12px;
}
.chat-input-row textarea {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1rem;
    resize: vertical;max-height:200px;
    outline: none;
    max-height: 200px;
    line-height: 1.5;
    font-family: inherit;
}
.chat-input-row textarea::placeholder {
    color: var(--text-muted);
}
.btn-attach {
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    padding: 4px;
}
.btn-attach:hover {
    color: var(--text);
}
.btn-attach svg {
    width: 20px;
    height: 20px;
}
.btn-attach input {
    display: none;
}
.send-stop-wrapper {
    position: relative;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}
.send-stop-wrapper #send-btn,
.send-stop-wrapper #stop-btn {
    position: absolute;
    inset: 0;
    width: 32px;
    height: 32px;
}
#send-btn {
    background: var(--green-primary);
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}
#send-btn:hover {
    background: var(--green-hover);
}
#send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
#send-btn svg {
    width: 16px;
    height: 16px;
    stroke: var(--on-primary);
}

/* Message Images */
.message-images {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.message-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* Edit Area */
.edit-area {
    margin-top: 4px;
}
.edit-textarea {
    width: 100%;
    min-height: 60px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 8px 12px;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    outline: none;
}
.edit-textarea:focus {
    border-color: var(--green-primary);
}
.edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* ===== Image Generation Progress ===== */
.gen-progress-container {
    width: 100%;
    max-width: 300px;
}
.gen-progress-bar-bg {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}
.gen-progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--green-primary);
    border-radius: 3px;
    transition: width 0.3s;
}
.gen-progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== Reconnection Banner ===== */
.reconnect-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(248, 81, 73, 0.9);
    color: var(--on-primary);
    text-align: center;
    padding: 8px;
    font-size: 0.85rem;
    z-index: 10001;
}

/* ===== Spinner ===== */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0,0,0,0.25);
    border-top-color: var(--on-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Input Small ===== */
.input-sm {
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.85rem;
    outline: none;
}
.input-sm:focus {
    border-color: var(--green-primary);
}

/* ===== API Flash ===== */
.api-flash {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.85rem;
}
.api-flash-success { background: rgba(46, 204, 113, 0.15); border: 1px solid var(--green-primary); color: var(--green-primary); }
.api-flash-error { background: rgba(248, 81, 73, 0.15); border: 1px solid var(--danger); color: var(--danger); }

/* ===== API Section ===== */
.api-section {
    margin-bottom: 2rem;
}
.api-section h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}


/* ===== Issue #63: Message Card Header & Consolidated Action Bar ===== */

/* Message header row at top of .message-content */
.msg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgb(255 255 255 / 0.1);
}
.msg-header-role {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 7px;
    border-radius: 8px;
    line-height: 1.5;
    flex-shrink: 0;
}
.message-user .msg-header-role {
    background: rgba(46, 204, 113, 0.15);
    color: var(--green-primary);
}
.message-assistant .msg-header-role {
    background: rgba(88, 166, 255, 0.12);
    color: var(--accent);
}
.msg-header-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
}
.msg-header-tokens {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 3px;
}

/* Consolidated action bar at bottom */
.msg-actions {
    display: flex;
    gap: 2px;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgb(255 255 255 / 0.1);
}
.msg-action {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.15s, background 0.15s;
    padding: 4px 6px;
    border-radius: 6px;
    color: var(--text-muted);
}
.msg-action:hover,
.msg-action:focus-visible {
    opacity: 1;
    background: var(--bg-input);
}
.msg-action.copied { color: var(--green-primary); opacity: 1; }

/* Secondary actions toggle */
.msg-actions-more-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s, background 0.15s;
    padding: 4px 6px;
    border-radius: 6px;
    color: var(--text-muted);
}
.msg-actions-more-btn:hover,
.msg-actions-more-btn:focus-visible {
    opacity: 1;
    background: var(--bg-input);
}

/* Secondary dropdown */
.msg-actions-secondary {
    display: none;
    position: absolute;
    bottom: calc(100% + 4px);
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
    min-width: 140px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 100;
    flex-direction: column;
}
.msg-actions-secondary.open {
    display: flex;
}
.msg-actions-secondary .msg-action {
    width: 100%;
    text-align: left;
    padding: 6px 10px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
}
.msg-actions-secondary .msg-action:hover {
    opacity: 1;
    background: var(--bg-input);
}
.msg-actions-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}

/* Hover-reveal on desktop, always visible on touch */
@media (hover: hover) {
    .msg-actions { opacity: 0; transition: opacity 0.15s; }
    .message:hover .msg-actions,
    .message:focus-within .msg-actions { opacity: 1; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===== Code Block ===== */
.code-block {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    overflow-x: auto;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
}

/* ===== Misc ===== */
.mono {
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ===== Biometric Modal ===== */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6); display: flex; align-items: center;
    justify-content: center; z-index: 1000;
}
.modal-card {
    background: var(--bg-elevated); border-radius: 12px; width: 90%; max-width: 420px;
    padding: 24px; box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3 { margin: 0; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; }
.modal-body h4 { margin: 0 0 8px; }
.webauthn-device {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 12px; background: var(--bg-secondary); border-radius: 8px; margin-bottom: 8px;
}
.webauthn-device-name { font-size: 14px; }
.webauthn-device-date { font-size: 11px; color: var(--text-muted); }
.webauthn-device button { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 16px; }

/* ===== Utility Classes ===== */
.text-muted-sm { color: var(--text-muted); font-size: 13px; margin-bottom: 12px; }
.text-error { color: var(--danger); }
.mt-sm { margin-top: 12px; }
.mb-xs { margin-bottom: 4px; }

/* ===== Image Upscale ===== */
.generated-image-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
}
.generated-image {
    transition: opacity 0.3s;
}
.upscale-btn-container {
    margin-top: 6px;
}
.btn-upscale {
    background: var(--accent, #6366f1);
    color: var(--on-primary);
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.85em;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-upscale:hover {
    background: var(--accent-hover, #4f46e5);
}
.upscale-max {
    color: var(--success, #22c55e);
    font-size: 0.85em;
}
.upscale-error {
    color: var(--error, #ef4444);
    font-size: 0.85em;
}

/* Video Generation */
.generated-video-wrapper {
    display: inline-block;
    max-width: 400px;
}
.generated-video-wrapper video {
    max-width: 100%;
    border-radius: 8px;
}

/* Form hint for accessibility */
.form-hint {
  display: block;
  font-size: 0.78rem;
  color: var(--text-secondary, #888);
  margin-top: 4px;
}

/* TTS (Read Aloud) Button */
.btn-tts {
    top: 0;
    right: 2.2rem;
}
.btn-tts:active,
.btn-tts:hover {
    transform: scale(1.2);
}

/* ===== Workspace sidebar styles ===== */
.sidebar-workspaces {
    padding: 0 12px;
    max-height: none;
    overflow: visible;
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 4px 4px;
    margin-top: 4px;
}

.sidebar-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.workspace-group {
    margin-bottom: 2px;
}

.workspace-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 13px;
    color: var(--text);
}

.workspace-header:hover {
    background: var(--bg-hover);
}

.workspace-collapse-icon {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s;
    width: 12px;
    text-align: center;
}

.workspace-collapse-icon.expanded {
    transform: rotate(90deg);
}

.workspace-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.workspace-thread-count {
    font-size: 11px;
    color: var(--text-muted);
}

.workspace-menu-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1;
}

.workspace-menu-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.workspace-threads {
    padding-left: 12px;
}

.workspace-threads .thread-item {
    padding-left: 20px;
}

.ws-new-chat-form {
    padding: 2px 8px 4px 20px;
}

.ws-new-chat-btn {
    width: 100%;
    font-size: 12px;
    color: var(--text-muted);
    opacity: 0.7;
}

.ws-new-chat-btn:hover {
    opacity: 1;
    color: var(--text);
}

.btn-icon {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1;
}

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

/* Workspace context menu */
.ws-context-menu {
    position: fixed;
    background: var(--bg-elevated, #262b31);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
    min-width: 160px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1000;
}

.ws-context-menu-item {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: var(--text);
    text-align: left;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

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

.ws-context-menu-item.danger {
    color: var(--danger);
}

/* Create workspace modal */
.ws-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ws-modal {
    background: var(--bg-elevated, #262b31);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 400px;
}

.ws-modal h3 {
    margin: 0 0 16px;
    color: var(--text);
}

.ws-modal input, .ws-modal textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg, #0f0f1a);
    color: var(--text);
    margin-bottom: 12px;
    font-size: 14px;
    box-sizing: border-box;
}

.ws-modal textarea {
    min-height: 60px;
    resize: vertical;
}

.ws-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Workspace context badge */
.ws-ctx-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-secondary);
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
    margin-left: 8px;
    border: 1px solid rgba(139, 92, 246, 0.25);
}
.ws-ctx-badge[hidden] {
    display: none;
}

/* Delete chat button - Issue #71 */
.delete-chat-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
}
.delete-chat-btn:hover {
    color: var(--danger);
    background: rgba(239,68,68,0.1);
}


/* Accessibility fixes */
.modal-overlay[style*="display:none"] { visibility: hidden; pointer-events: none; }
.skip-link:focus { outline: 2px solid var(--primary,#2ea44f); }
.suggestion-chip { cursor: pointer; }
details summary { cursor: pointer; padding: 8px 0; font-weight: 600; }
details[open] summary { margin-bottom: 8px; }

/* #141: Hide focusable elements in inert modals */
[inert] { pointer-events: none; }
[inert] * { visibility: hidden; }

/* Thread selection / bulk delete (moved from admin.css for dashboard use) */
.thread-card.selected {
  border-color: var(--green-hover);
  box-shadow: 0 0 0 2px rgba(39,174,96,0.3);
}
.thread-card .thread-checkbox {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  cursor: pointer;
  display: none;
  accent-color: var(--green-hover);
}
.thread-card.selectable .thread-checkbox {
  display: block;
}
.thread-card.selectable .btn-delete {
  display: none;
}
.thread-select-btn {
  background: var(--bg-secondary, #16162a);
  border: 1px solid var(--border, #2a2a3e);
  color: var(--text, #e8e8f0);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.thread-select-btn:hover {
  background: var(--border, #2a2a3e);
}
.thread-select-btn.active {
  background: var(--green-hover);
  border-color: var(--green-hover);
  color: var(--on-primary);
}
.bulk-action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary, #16162a);
  border-top: 1px solid var(--border, #2a2a3e);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 200;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
}
.bulk-action-bar.visible {
  transform: translateY(0);
}
.bulk-action-info {
  color: var(--text, #e8e8f0);
  font-size: 0.88rem;
  font-weight: 600;
}
.bulk-action-buttons {
  display: flex;
  gap: 8px;
}
.btn-bulk-delete {
  background: var(--danger);
  color: var(--on-primary);
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-bulk-delete:hover {
  background: var(--danger-hover);
}
.btn-bulk-cancel {
  background: var(--border, #2a2a3e);
  color: var(--text, #e8e8f0);
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}
.btn-bulk-cancel:hover {
  background: var(--text-secondary, #8888aa);
}

/* Workspace modal disabled button (#131) */
.ws-modal .btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Name truncation for cards (#workspace-overflow) */
.ws-name, .ws-name h3, .ws-name h6 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* Pace.js progress bar — dark theme override (pace.min.css hardcodes #fff) */
.pace .pace-progress { background: var(--green-primary, #2ecc71); }
.pace .pace-progress-inner { box-shadow: 0 0 10px var(--green-primary, #2ecc71), 0 0 5px var(--green-primary, #2ecc71); }
.pace .pace-activity { border-top-color: var(--green-primary, #2ecc71); border-left-color: var(--green-primary, #2ecc71); }

/* ═══ Sidebar Theme: Gradient (winner — promoted from variant C) ═══ */
.sidebar-theme-gradient .sidebar-wrapper {
    background: linear-gradient(180deg, #1a2e1a 0%, #1a2630 40%, #1a2228 100%) !important;
    border-right: 1px solid rgba(46,204,113,0.1) !important;
}
.sidebar-theme-gradient .sidebar-header {
    background: linear-gradient(90deg, #1a2e1a, #1a2630) !important;
    border-bottom: 1px solid rgba(46,204,113,0.08) !important;
}
.sidebar-theme-gradient .metismenu a {
    border-radius: 8px;
    margin: 2px 6px;
    padding: 9px 12px !important;
    transition: all 0.2s !important;
}
.sidebar-theme-gradient .metismenu a:hover,
.sidebar-theme-gradient .metismenu .mm-active > a {
    background: linear-gradient(90deg, rgba(46,204,113,0.18), rgba(20,184,166,0.08)) !important;
    color: #fff !important;
    box-shadow: 0 0 12px rgba(46,204,113,0.15);
}
.sidebar-theme-gradient .metismenu .parent-icon {
    color: #14b8a6;
}
.sidebar-theme-gradient .metismenu a:hover .parent-icon,
.sidebar-theme-gradient .metismenu .mm-active > a .parent-icon {
    color: var(--green-primary) !important;
}
.sidebar-theme-gradient .menu-label {
    color: rgba(20,184,166,0.4);
}
.sidebar-theme-gradient .logo-text {
    background: linear-gradient(135deg, #2ecc71, #14b8a6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.sidebar-theme-gradient .toggle-btn {
    color: var(--green-primary) !important;
}

/* ===== MOBILE CHAT OPTIMIZATION ===== */
/* Target phones and small tablets — eliminates wasted space on chat pages */

/* 1. Hide the fixed top header bar — saves 70px vertical space */
@media screen and (max-width: 1024px) {
    /* Remove top header entirely on mobile chat */
    body.chat-page .top-header {
        display: none !important;
    }

    /* Content starts at top — no margin for header */
    body.chat-page .page-content-wrapper {
        margin-top: 0 !important;
    }

    /* Remove page-content padding — chat fills 100% */
    body.chat-page .page-content {
        padding: 0 !important;
    }

    /* Chat shell uses full viewport height */
    body.chat-page .chat-shell {
        height: 100vh !important;
        height: 100dvh !important; /* Dynamic viewport — accounts for mobile browser chrome */
        border-radius: 0 !important;
        margin: 0 !important;
    }

    /* 2. Compact chat header — was 56px min + 32px padding = 70px+ total */
    .chat-header {
        padding: 8px 12px !important;
        min-height: 44px !important;
        gap: 6px !important;
        position: sticky;
        top: 0;
        z-index: 10;
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        background: rgb(0 0 0 / 0.65) !important;
    }

    /* Smaller title text on mobile */
    .header-title-text {
        font-size: 0.95rem !important;
    }

    /* Compact model selector */
    .model-select {
        min-width: 0 !important;
        max-width: 130px;
        font-size: 0.72rem !important;
        padding: 4px 8px !important;
    }

    /* Hide edit icon on mobile (no hover) */
    .header-title-edit-icon {
        display: none !important;
    }

    /* Hide rate limit badge to save space */
    .rate-limit-badge {
        display: none !important;
    }

    /* 3. Compact chat messages — reduce padding and gaps */
    .chat-messages {
        padding: 8px 12px !important;
        gap: 10px !important;
    }

    /* Messages use full width — remove max-width constraint */
    .message {
        max-width: 100% !important;
        gap: 8px !important;
    }

    /* Smaller avatars on mobile */
    .message-avatar {
        width: 26px !important;
        height: 26px !important;
        font-size: 0.85rem !important;
    }

    /* Compact message bubbles */
    .message-content {
        padding: 10px 12px !important;
    }

    /* Compact message header */
    .msg-header {
        margin-bottom: 4px !important;
    }
    .msg-header-role {
        font-size: 0.72rem !important;
    }
    .msg-header-time {
        font-size: 0.68rem !important;
    }
    .msg-header-tokens {
        display: none !important; /* Token count not essential on mobile */
    }

    /* 4. Compact chat input area — was 12px 24px padding */
    .chat-input-area {
        padding: 8px 12px !important;
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    }

    #chat-form {
        max-width: 100% !important;
    }

    .chat-input-row {
        padding: 6px 10px !important;
        border-radius: 10px !important;
    }

    .chat-input-row textarea {
        font-size: 16px !important; /* Prevent iOS zoom — must be 16px */
        max-height: 120px !important;
    }

    /* 5. Context wheel — smaller on mobile */
    .context-wheel svg {
        width: 30px !important;
        height: 30px !important;
    }
    .context-pct {
        font-size: 0.65rem !important;
    }

    /* 6. Compact empty state */
    .chat-empty-state {
        padding: 1rem !important;
    }
    .chat-empty-state > div:first-child {
        font-size: 2.5rem !important;
        margin-bottom: 0.5rem !important;
    }
    .chat-empty-state h2 {
        font-size: 1.1rem !important;
        margin-bottom: 0.25rem !important;
    }
    .chat-empty-state p {
        font-size: 0.85rem !important;
        margin-bottom: 1rem !important;
    }
    .chat-empty-state > div:last-child {
        max-width: 100% !important;
    }
    .suggestion-chip {
        font-size: 0.8rem !important;
    }

    /* 7. Message actions — more compact on mobile */
    .msg-actions {
        gap: 2px !important;
    }
    .msg-action {
        font-size: 0.85rem !important;
    }

    /* 8. Generated images — responsive sizing */
    .generated-image, .message-image {
        max-width: 100% !important;
    }

    /* 9. Thinking chips — compact */
    .thinking-chip {
        font-size: 0.75rem !important;
        padding: 4px 8px !important;
    }

    /* 10. Sprint/agent task cards — compact */
    .sprint-task-card {
        margin: 6px 0 !important;
    }
    .task-header {
        padding: 6px 10px !important;
    }
    .task-body {
        padding: 6px 10px !important;
        max-height: 300px !important;
    }

    /* 11. Delete button in header — smaller */
    .delete-chat-btn {
        padding: 4px !important;
    }
    .delete-chat-btn svg {
        width: 14px !important;
        height: 14px !important;
    }

    /* 12. Context menu — full width dropdown on mobile */
    .ctx-menu {
        position: fixed !important;
        top: 44px !important;
        left: 0 !important;
        right: 0 !important;
        max-width: 100% !important;
        border-radius: 0 0 12px 12px !important;
    }

    /* 13. Modal overlays — full screen on mobile */
    .modal-overlay {
        padding: 0 !important;
    }
    .modal-card {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: 90vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }
}

/* Extra-small phones (≤380px) — even more aggressive */
@media screen and (max-width: 380px) {
    .chat-header {
        padding: 6px 8px !important;
    }
    .model-select {
        max-width: 110px;
        font-size: 0.68rem !important;
    }
    .header-title-text {
        font-size: 0.85rem !important;
    }
    .message-avatar {
        display: none !important; /* Hide avatars on tiny screens */
    }
    .message {
        gap: 0 !important;
    }
    .chat-messages {
        padding: 6px 8px !important;
        gap: 8px !important;
    }
    .message-content {
        padding: 8px 10px !important;
        font-size: 0.92rem !important;
    }
}

/* Landscape orientation — use height more aggressively */
@media screen and (max-width: 1024px) and (orientation: landscape) and (max-height: 500px) {
    .chat-shell {
        height: 100dvh !important;
    }
    .chat-header {
        padding: 4px 12px !important;
        min-height: 36px !important;
    }
    .chat-input-area {
        padding: 4px 12px !important;
    }
    .chat-input-row textarea {
        max-height: 60px !important;
    }
}
.wrapper.no-sidebar .left-topbar { display: flex !important; }
