/* ===== Design System: 2226 Lab Notebook ===== */

:root {
    /* Paper substrate */
    --bg: #fafbfc;
    --bg-secondary: #f0f2f5;
    --bg-inset: #ebedf0;
    --bg-hover: #f0f2f5;

    /* Ink — high contrast for readability */
    --text: #111318;
    --text-secondary: #3b4455;
    --text-tertiary: #6b7280;

    /* Accent — institutional blue */
    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.06);
    --accent-hover: #1d4ed8;

    /* Ambient status */
    --status-active: #2563eb;
    --status-complete: #059669;
    --status-pending: #6b7280;
    --status-failed: #dc2626;
    --status-queued: #d97706;

    /* Add Stage dropdown compatibility shading (stage-config.js) — plain
       <option> text set directly on --bg, NOT a badge/pill, so it needs its
       own WCAG-AA-verified pairing rather than reusing a status token that
       was only ever contrast-checked in a badge/pill context. Measured with
       the standard WCAG relative-luminance formula against --bg #fafbfc,
       14px normal-weight text (4.5:1 bar, not the 3:1 large-text bar):
         --shade-compatible   #047857 vs #fafbfc = 5.29:1 (darker than
           --status-complete #059669, which is only 3.64:1 here — that
           token is fine in its existing badge/pill usages, just not this
           one, so it is not reused verbatim for this pairing)
         --shade-incompatible #6b7280 vs #fafbfc = 4.67:1 (same value as
           --text-tertiary, which does clear the bar in THIS pairing) */
    --shade-compatible: #047857;
    --shade-incompatible: #6b7280;

    /* Borders */
    --border: #d0d4db;
    --border-subtle: #e2e5ea;

    /* Geometry */
    --radius: 6px;
    --radius-sm: 4px;
    --radius-lg: 8px;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;

    /* Spacing (4px base) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-6: 24px;
    --space-8: 32px;
    --space-12: 48px;

    /* Motion */
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --duration: 150ms;

    /* Aliases — several stylesheets (stage-detail.css, project-detail.css)
       reference these names; without them they silently fell back to
       inherit/transparent and broke in dark mode. They point at the
       theme-aware tokens above, so var() resolves correctly in both themes. */
    --text-primary: var(--text);
    --bg-primary: var(--bg);
    --bg-tertiary: var(--bg-inset);
    --danger: var(--status-failed);
}

/* ===== Dark Theme ===== */
[data-theme="dark"] {
    --bg: #0d1117;
    --bg-secondary: #161b22;
    --bg-inset: #1c2128;
    --bg-hover: #1c2128;
    --text: #e6edf3;
    --text-secondary: #8b949e;
    --text-tertiary: #6e7681;
    --accent: #58a6ff;
    --accent-soft: rgba(88, 166, 255, 0.1);
    --accent-hover: #79c0ff;
    --border: #30363d;
    --border-subtle: #21262d;
    --status-active: #58a6ff;
    --status-complete: #3fb950;
    --status-pending: #6e7681;
    --status-failed: #f85149;
    --status-queued: #d29922;

    /* Add Stage dropdown compatibility shading — see :root above for the
       full rationale. Measured against --bg #0d1117, 14px normal text:
         --shade-compatible   #3fb950 vs #0d1117 = 7.45:1 (same value as
           --status-complete, which already clears the bar in dark mode —
           only the light-mode value above needed to change)
         --shade-incompatible #8b949e vs #0d1117 = 6.15:1 (same value as
           --text-secondary; --text-tertiary #6e7681 is only 4.12:1 here —
           fails AA, so it is NOT reused for this pairing in dark mode) */
    --shade-compatible: #3fb950;
    --shade-incompatible: #8b949e;
}

/* ===== Reset ===== */

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

/* Inherit fonts on form elements (browsers don't do this by default) */
input, select, textarea, button {
    font-family: inherit;
    font-size: inherit;
}

/* Form element base styles */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

/* ===== Typography ===== */

body {
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.6;
    letter-spacing: -0.011em;
    font-weight: 400;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}



h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.3; }
h3 { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.4; }
h4 { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.4; }

/* ===== Layout ===== */

.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 22px;
}

main {
    padding: 60px 0;
    flex: 1;
}

/* ===== Footer ===== */

footer {
    border-top: 1px solid var(--border);
    padding: 12px 0;
    font-size: 12px;
    color: var(--text-tertiary);
}

footer .container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.footer-sep {
    opacity: 0.4;
}

/* ===== Header — Thin Rule ===== */

header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 48px;
    max-width: none;
    width: 100%;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: 0;
    flex: 1;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.logo {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text);
    text-decoration: none;
    flex-shrink: 0;
    margin-right: 4px;
}

.logo:hover {
    color: var(--text);
}

/* Breadcrumb navigation */
.nav-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: 0;
}

.nav-breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: color var(--duration) var(--ease);
}

.nav-breadcrumb a:hover {
    color: var(--accent);
}

.nav-sep {
    color: var(--text-tertiary);
    font-size: 12px;
    margin: 0 6px;
    flex-shrink: 0;
}

.nav-project-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}
.nav-project-name[contenteditable] {
    cursor: text;
    border-radius: 3px;
    padding: 1px 4px;
    margin: -1px -4px;
    outline: none;
}
.nav-project-name[contenteditable]:hover {
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.nav-project-name[contenteditable]:focus {
    background: var(--bg-secondary);
    box-shadow: 0 0 0 1px var(--accent);
}

.nav-status-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
    margin-left: 8px;
    border: none;
    cursor: default;
}

select.nav-status-badge {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    padding-right: 18px;
    width: auto;
    max-width: 120px;
    background-repeat: no-repeat;
    background-position: right 5px center;
    background-size: 10px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

.nav-status-badge.status-started {
    background-color: var(--accent-soft);
    color: var(--accent);
}

.nav-status-badge.status-in-progress {
    background-color: #3b82f620;
    color: #60a5fa;
}

.nav-status-badge.status-completed {
    background-color: #22c55e20;
    color: #22c55e;
}

/* ===== User Menu Dropdown ===== */

.user-menu {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 3px 6px 3px 3px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--duration) var(--ease);
}

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

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-menu-name {
    font-size: 13px;
    font-weight: 500;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-btn svg {
    flex-shrink: 0;
    opacity: 0.5;
    transition: transform var(--duration) var(--ease);
}

.user-menu.open .user-menu-btn svg:last-child {
    transform: rotate(180deg);
}

.user-panel {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 240px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    z-index: 200;
    animation: fadeIn 0.15s var(--ease);
    overflow: hidden;
}

.user-panel.open {
    display: block;
}

.user-panel-header {
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--border-subtle);
}

.user-panel-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.user-panel-email {
    display: block;
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-panel-items {
    padding: 4px 0;
}

.user-panel-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    font-family: var(--font-sans);
    text-align: left;
}

.user-panel-item:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.user-panel-item svg {
    flex-shrink: 0;
    opacity: 0.6;
}

.user-panel-item--danger {
    color: var(--status-failed);
}

.user-panel-item--danger:hover {
    background: rgba(220, 38, 38, 0.06);
    color: var(--status-failed);
}

.user-panel-sep {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}

/* Section label (design correction 2026-07-02, item 9) — the same
   Label type token design-system.md documents (11px / 600 / 0.06em
   tracking), reused verbatim from .sw-taskbar-label so both "this is a
   distinct group" cues in the app share one typographic language. */
.user-panel-section-label {
    padding: 6px 14px 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

/* ===== Generic custom-select (app-shell review §4.9) =====
   Same visual language as .user-menu/.user-panel above — a native <select>'s
   OPEN option-list popup can't be styled with CSS at all (a platform
   limitation), so initCustomSelect() in base.js replaces it with this. */
.custom-select {
    position: relative;
    display: inline-flex;
}
.custom-select-native {
    display: none;
}
.custom-select-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 12px;
    transition: all var(--duration) var(--ease);
}
.custom-select-btn:hover {
    background: var(--bg-secondary);
    color: var(--text);
}
.custom-select-caret {
    flex-shrink: 0;
    opacity: 0.5;
    transition: transform var(--duration) var(--ease);
}
.custom-select.open .custom-select-caret {
    transform: rotate(180deg);
}
.custom-select-panel {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 100%;
    max-width: 320px;
    max-height: 260px;
    overflow-y: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    z-index: 200;
    animation: fadeIn 0.15s var(--ease);
    padding: 4px;
}
.custom-select.open .custom-select-panel {
    display: block;
}
.custom-select-item {
    display: block;
    width: 100%;
    padding: 6px 10px;
    font-size: 12px;
    color: var(--text-secondary);
    border: none;
    background: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
    text-align: left;
    white-space: nowrap;
}
.custom-select-item:hover {
    background: var(--bg-secondary);
    color: var(--text);
}
.custom-select-item.selected {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

/* Legacy nav (non-project pages) */
nav {
    display: flex;
    gap: 2rem;
    align-items: center;
}

nav a {
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color var(--duration) var(--ease);
}

nav a:hover {
    color: var(--accent);
}

/* ===== Buttons — Instrument Controls ===== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all var(--duration) var(--ease);
    font-family: var(--font-sans);
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn.btn-secondary.active,
.btn.code-file-btn.active,
.code-file-btn.active {
    background: var(--accent) !important;
    color: #fff !important;
    border-color: var(--accent) !important;
}

.btn-success {
    background: #22c55e;
    color: #fff;
    border: 1px solid #22c55e;
}
.btn-success:hover {
    background: #16a34a;
    border-color: #16a34a;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
}

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

.btn-danger {
    background: transparent;
    color: var(--status-failed);
    border: 1px solid rgba(220, 38, 38, 0.3);
}

.btn-danger:hover {
    background: rgba(220, 38, 38, 0.06);
    border-color: var(--status-failed);
}

.btn-warning {
    background: #f59e0b;
    color: #fff;
    border: 1px solid #f59e0b;
}
.btn-warning:hover {
    background: #d97706;
    border-color: #d97706;
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
    padding: 7px 0;
    border: none;
}

.btn-text:hover {
    color: var(--accent);
}

/* ===== Cards ===== */

.card {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 24px;
    transition: background var(--duration) var(--ease);
}

.card:hover {
    background: var(--bg-secondary);
}

/* ===== Form Elements ===== */

input, textarea, select {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font-sans);
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder, textarea::placeholder {
    color: var(--text-tertiary);
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
}

.form-group {
    margin-bottom: 20px;
}

/* ===== Icons ===== */

.icon {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
}

.icon-lg {
    width: 48px;
    height: 48px;
}

/* ===== Toast Notifications ===== */

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 450px;
    pointer-events: auto;
    animation: fadeIn 0.2s var(--ease);
}

.toast.toast-success {
    border-top: 2px solid var(--status-complete);
}

.toast.toast-error {
    border-top: 2px solid var(--status-failed);
}

.toast.toast-info {
    border-top: 2px solid var(--accent);
}

.toast.toast-loading {
    border-top: 2px solid var(--status-queued);
}

/* Spinner element inside a loading toast */
.toast-spinner {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    border: 2px solid var(--status-queued);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.toast-success .toast-icon { color: var(--status-complete); }
.toast-error .toast-icon { color: var(--status-failed); }
.toast-info .toast-icon { color: var(--accent); }

.toast-message {
    flex: 1;
    font-size: 13px;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    margin: -4px;
    opacity: 0.6;
    transition: opacity var(--duration);
}

.toast-close:hover {
    opacity: 1;
}

.toast.removing {
    animation: fadeOut 0.2s var(--ease) forwards;
}

/* ===== Confirm Modal ===== */

.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 10001;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s var(--ease);
}

.confirm-overlay.active {
    display: flex;
}

.confirm-dialog {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.1);
    animation: scaleIn 0.2s var(--ease);
}

.confirm-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 8px;
}

.confirm-message {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 24px;
    /* preserve embedded newlines (e.g. a code-block preview set via
       textContent -- see the stray-run() strip confirmation in
       stage-config.js) while still wrapping long lines normally */
    white-space: pre-wrap;
}

.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.confirm-actions .btn {
    min-width: 80px;
}

/* Input modal field */
.input-modal-field {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.input-modal-field:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

/* ===== Modal shell =====
   Emitted by the modal()/modal_header()/modal_actions() macros in
   partials/modal_macro.html — single source of truth for every modal in the
   app (consolidated 2026-07 from the near-duplicate copies that used to live
   in project-detail.css, projects.css, and admin_users.html's local
   <style> block). `.modal h2` / `.modal > p` are intentionally NOT
   consolidated here — those differ per page (24px titles in project/stage
   modals vs 18px elsewhere) and stay defined where they already were. */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 480px;
    max-height: 95vh;
    overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.1);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    flex: 1;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ===== Keyboard shortcut badges ===== */

kbd {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    padding: 1px 5px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    margin-right: 4px;
    line-height: 1.6;
}

/* ===== Jobs Indicator ===== */

.jobs-indicator {
    position: relative;
}

.jobs-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 3px 6px;
    cursor: pointer;
    color: var(--text-tertiary);
    transition: all var(--duration) var(--ease);
}

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

.jobs-btn.has-jobs {
    color: var(--accent);
}

.jobs-btn.has-jobs svg {
    animation: breathe 2s ease-in-out infinite;
}

.jobs-count {
    display: none;
    font-size: 10px;
    font-weight: 600;
    font-family: var(--font-mono);
    background: var(--accent);
    color: white;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.jobs-count.visible {
    display: inline-flex;
}

.jobs-panel {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 320px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    z-index: 200;
    animation: fadeIn 0.15s var(--ease);
}

.jobs-panel.open {
    display: block;
}

.jobs-panel-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    padding: 8px 12px 6px;
    border-bottom: 1px solid var(--border-subtle);
}

.jobs-panel-list {
    max-height: 320px;
    overflow-y: auto;
}

.job-item {
    position: relative;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background var(--duration) var(--ease);
}

.job-item:last-child {
    border-bottom: none;
}

.job-item:hover {
    background: var(--bg-secondary);
}

.job-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.job-item-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
}

.job-item-project {
    font-size: 10px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

.job-item-progress {
    height: 3px;
    background: var(--bg-inset);
    border-radius: 2px;
    overflow: hidden;
}

.job-item-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.job-item-bar.failed {
    background: var(--status-failed);
}

.job-item-message {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font-mono);
}

.job-item-slot {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 5px;
    font-size: 9px;
    font-weight: 600;
    color: var(--status-active);
    background: rgba(56, 139, 253, 0.12);
    border: 1px solid rgba(56, 139, 253, 0.35);
    border-radius: 3px;
    font-family: var(--font-mono);
    vertical-align: 1px;
}

.job-item-runaway {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 5px;
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    background: var(--status-failed);
    border-radius: 3px;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    vertical-align: 1px;
}

.job-item.is-runaway {
    border-left: 3px solid var(--status-failed);
}

.job-item-cancel {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid var(--border-subtle);
    background: var(--bg);
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.job-item-cancel:hover {
    background: var(--status-failed);
    color: white;
    border-color: var(--status-failed);
}

.jobs-empty {
    padding: 16px 12px;
    text-align: center;
    font-size: 11px;
    color: var(--text-tertiary);
}

/* ===== Status Indicator System ===== */

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot--active   { background: var(--status-active); }
.status-dot--complete { background: var(--status-complete); }
.status-dot--pending  { background: var(--status-pending); }
.status-dot--failed   { background: var(--status-failed); }
.status-dot--queued   { background: var(--status-queued); animation: breathe 2s ease-in-out infinite; }
.status-dot--running  { background: var(--status-active); animation: breathe 2s ease-in-out infinite; }

.status-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font-mono);
}

/* ===== Utility Classes ===== */

.mono { font-family: var(--font-mono); }
.dim  { opacity: 0.5; }
.ghost { opacity: 0.35; }

/* ===== Animations ===== */

@keyframes breathe {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

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

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

@keyframes scaleIn {
    from { transform: scale(0.97); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

/* ===== Command Palette ===== */

.cmd-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 10002;
    display: none;
    justify-content: center;
    padding-top: 20vh;
}

.cmd-overlay.active {
    display: flex;
}

.cmd-dialog {
    width: 520px;
    max-height: 400px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    animation: scaleIn 0.12s var(--ease);
    align-self: flex-start;
}

.cmd-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.cmd-input-wrap svg {
    flex-shrink: 0;
    color: var(--text-tertiary);
}

.cmd-input {
    flex: 1;
    border: none;
    background: none;
    font-size: 15px;
    color: var(--text);
    outline: none;
    padding: 0;
    width: auto;
}

.cmd-input::placeholder {
    color: var(--text-tertiary);
}

.cmd-results {
    overflow-y: auto;
    max-height: 320px;
    padding: 4px 0;
}

.cmd-group-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    padding: 8px 16px 4px;
}

.cmd-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.08s;
    font-size: 14px;
    color: var(--text);
}

.cmd-item:hover,
.cmd-item.selected {
    background: var(--bg-secondary);
}

.cmd-item svg {
    flex-shrink: 0;
    color: var(--text-tertiary);
}

.cmd-item-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cmd-item-hint {
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    flex-shrink: 0;
}

.cmd-empty {
    padding: 20px 16px;
    text-align: center;
    font-size: 13px;
    color: var(--text-tertiary);
}

/* ===== Stage Duration ===== */

.stage-duration {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.stage-duration svg {
    opacity: 0.5;
}

/* ===== Relative Timestamps ===== */

.timeago {
    cursor: default;
}

/* ===== Loading / Spinner ===== */

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 6px;
    vertical-align: middle;
}

/* HTMX loading indicator */
.htmx-indicator {
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-tertiary);
}

.htmx-indicator::before {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-flex;
}


/* ===== Mobile Responsiveness (≤640px) ===== */

@media (max-width: 640px) {
    /* Tighter container padding */
    .container {
        padding: 0 12px;
    }

    main {
        padding: 24px 0;
    }

    /* Header: hide username text, keep avatar */
    .user-menu-name {
        display: none;
    }

    .user-menu-btn svg:last-child {
        display: none;
    }

    /* Nav breadcrumb: tighter spacing */
    .nav-project-name {
        max-width: 140px;
    }

    /* Dropdown panels: cap at viewport */
    .user-panel {
        width: min(240px, calc(100vw - 24px));
        right: -8px;
    }

    .jobs-panel {
        width: min(320px, calc(100vw - 24px));
        right: -8px;
    }

    /* Toast: full-width centered */
    .toast-container {
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    .toast {
        min-width: 0;
        max-width: none;
        width: 100%;
    }

    /* Command palette: fit viewport */
    .cmd-dialog {
        width: calc(100vw - 32px);
    }

    /* Smaller headings on mobile */
    h1 { font-size: 22px; }
    h2 { font-size: 18px; }
}

/* ===== Package entitlements modal ===== */

.pkg-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 4px;
}

.pkg-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    opacity: 0.55;
    transition: opacity var(--duration) var(--ease), border-color var(--duration) var(--ease);
}

.pkg-card--enabled {
    opacity: 1;
    border-color: var(--accent-soft);
    background: var(--accent-soft);
}

.pkg-card-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
    margin: 0;
}

.pkg-card-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.pkg-card-toggle {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.pkg-card-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 4px 0 0;
    line-height: 1.4;
}

@media (max-width: 640px) {
    .pkg-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Admin tab bar (shared: /admin/packages + /admin/users) ── */
.admin-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}
.admin-tab {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
    display: inline-block;
}
.admin-tab:hover { color: var(--text); }
.admin-tab--active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ── Page header (shared: project detail, account tokens, account packages) ── */
.page-header {
    margin-bottom: 1.5rem;
}
.page-header h1 {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
}
.page-header p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.875rem;
}

/* ── Card sub-section title (shared within account_tokens.html) ── */
.card-section-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 1rem;
}
.card-section-title--tight {
    margin-bottom: 0.25rem;
}

/* ===== Collaboration Notes Widget (07.22.26-collaboration-notes-phase1,
   restyled + repositioned 07.22.26-collab-widget-polish, resized + moved to
   the right 07.22.26-collab-widget-resize-reposition) =====
   Global floating chat-bubble — see app/templates/base.html's widget block
   and app/static/js/collab-widget.js for markup/wiring.

   Anchored bottom-RIGHT (owner preference, this round — was bottom-left).
   Two real right-side conflicts were surveyed (grep -n "position: fixed" -A5
   app/static/css/*.css, re-run this round; nothing new beyond these two):

   1. .toast-container (below, position: fixed; bottom: 20px; right: 20px;
      z-index: 10000) shares this EXACT corner — not just adjacent, the same
      anchor point. Deliberately left as an ACCEPTED, documented overlap
      (not actively avoided): while a toast is visible it will sit on
      top of (z-index 10000 > this widget's 9500) and cover the FAB. Chose
      accept-over-avoid because (a) frequency — toasts fire on nearly every
      save/action; actively shifting the FAB's `right` offset every time one
      appears/clears would make a persistent global control visibly jitter
      during ordinary use, worse than the brief cover-up itself, whereas the
      AI panel below opens rarely and deliberately, so a one-time shift on
      open/close doesn't fight the eye; (b) duration — default toast
      lifetime is 4000ms (showToast()'s default, app/static/js/base.js), so
      the FAB is unreachable for a few seconds at most in the common case
      (a "loading"-type toast with no fixed duration is the one real
      exception — narrow, and a user isn't typically also reaching for
      Messages mid-upload); (c) this is exactly the standard toast contract
      already accepted everywhere else in this app — a toast transiently
      covering whatever happens to occupy that corner, same as it would
      cover ordinary page content. If this becomes a real complaint, revisit
      with the same measure-and-shift mechanism used for #2 below.
   2. .project-ai-panel (stage-detail.css, position: fixed; right: 0;
      width: 400px; height: 100vh) — the AI Workflow Planner side panel.
      ACTIVELY avoided (not just documented): unlike the toast, this is
      opened deliberately by the user and can stay open for an entire work
      session, full-height, 400px wide — a static bottom-right FAB would be
      completely and durably hidden behind it, not just briefly grazed.
      collab-widget.js's updateWidgetPlacement() (same function, same
      MutationObserver, as the vertical fix below) measures the panel's own
      live bounding rect and raises `right` via --collab-widget-right
      whenever it reports a non-zero size (i.e. .open). See that function's
      comment for the full mechanism.

   z-index sits below the toast/confirm/cmd-palette overlays (10000-10002)
   so those still win when active, but above ordinary page content and the
   header's own dropdowns (200).

   Both `right` and `bottom` read a custom property with a 20px fallback:
   collab-widget.js's updateWidgetPlacement() sets --collab-widget-bottom to
   raise the widget clear of .dag-legend (project-detail.css) on the
   Workflow tab ONLY when the legend's live rect actually comes near the
   widget's own (nominal, default-corner) rect — a genuine 2D overlap test,
   not an existence check (07.22.26-collab-widget-placement-bug fixed a
   live-production regression here: the pre-fix existence-only check kept
   raising the widget on every Workflow-tab pageview even on an ordinary
   non-tiled layout, where the far-left legend and this far-right widget can
   never actually collide) — and --collab-widget-right to shift it clear of
   .project-ai-panel per #2 above, same corrected gate. See that function's
   own comment for why an adaptive fix was chosen over guessing a static
   corner for either axis. */

.collab-widget {
    position: fixed;
    right: var(--collab-widget-right, 20px);
    bottom: var(--collab-widget-bottom, 20px);
    z-index: 9500;
}

/* Item 5 (07.22.26-collab-widget-polish): was a solid filled --accent
   circle with a heavy box-shadow — a much bolder treatment than any other
   control in this app. Restyled to this app's flat/bordered/toolbar-icon-
   button language (.jobs-btn, below, is the direct reference) — --accent
   now only appears as an icon color on .has-unread, matching
   .jobs-btn.has-jobs, never as a fill. Stays circular (unlike .jobs-btn)
   and keeps a light elevation shadow (toast-strength, not the old heavy
   one) because — unlike .jobs-btn, which lives inside the header toolbar
   with guaranteed contrast against the header background — this is a
   persistent element floating over arbitrary, unpredictable page content
   and needs to stay visually findable without going back to a filled
   accent circle.

   Sized 36px (07.22.26-collab-widget-resize-reposition, down from 48px) —
   not a guessed round number: matches this app's own existing 36px
   icon-button convention (.ai-send-btn / .project-ai-send-btn, both below
   in stage-detail.css — the send button inside this SAME AI planner panel),
   which is also the closest sibling in "affordance floating over
   content" weight. Plain toolbar icon buttons run smaller still
   (.jobs-btn renders 28x22, .project-ai-header-btn/.btn-icon-danger are
   28x28, .sw-action-btn is 26x26) — deliberately not matched exactly,
   since this FAB (unlike those) has no guaranteed-contrast toolbar
   background behind it and needs to stay findable per the elevation note
   above. The mobile override below (≤640px) stays 44px, UNCHANGED by this
   resize — that's the accessibility touch-target floor (WCAG 2.5.5 / Apple
   HIG), an independent constraint from the desktop icon-affordance sizing
   this pass is matching; mobile ending up larger than desktop is
   intentional, not an oversight. */
.collab-widget-fab {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    transition: background var(--duration) var(--ease), color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}

.collab-widget-fab:hover {
    color: var(--text-secondary);
    background: var(--bg-secondary);
}

.collab-widget-fab.has-unread {
    color: var(--accent);
}

/* Scaled with the FAB (07.22.26-collab-widget-resize-reposition): 16px
   (was 18px), border-radius 8px (was 9px) to stay a true circle/pill —
   matches .jobs-count's own 16px/8px badge convention (base.css, above)
   exactly, rather than a naive proportional scale-down (18 * 36/48 = 13.5,
   which would crowd the "99+" text at the unchanged 10px font). Corner
   offset tightened -3px → -2px to match the smaller FAB's own corner
   radius proportionally (screenshot-verified, not just computed). */
.collab-widget-badge {
    display: none;
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    background: var(--status-failed);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font-mono);
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--bg);
}

.collab-widget-badge.visible {
    display: flex;
}

/* Opens LEFTWARD (right: 0, was left: 0) — a direct consequence of the FAB
   itself moving to the right edge, not just a style tweak: with the FAB
   anchored via `right`, a panel still anchored via `left: 0` would open
   FROM the FAB's left edge and extend 360px further right, off the edge of
   the viewport entirely. Mirrors .jobs-panel's own right:0 (base.css,
   above) — the same "panel opens away from the edge its trigger is docked
   to" convention already used for the header's own edge-docked dropdown. */
.collab-widget-panel {
    display: none;
    flex-direction: column;
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    width: 360px;
    max-height: 520px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
    overflow: hidden;
    animation: scaleIn 0.12s var(--ease);
}

.collab-widget-panel.open {
    display: flex;
}

.collab-view {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.collab-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    flex-shrink: 0;
}

.collab-back-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    font-size: 16px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.collab-back-btn:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.collab-thread-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Item 2 (07.22.26-collab-widget-polish): live project search at the top
   of the list view. */
.collab-thread-search-wrap {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.collab-thread-search {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 5px 9px;
    font-family: var(--font-sans);
    font-size: 12.5px;
    color: var(--text);
    background: var(--bg);
    box-sizing: border-box;
}

.collab-thread-search:focus {
    outline: none;
    border-color: var(--accent);
}

.collab-thread-list {
    overflow-y: auto;
    flex: 1;
}

.collab-thread-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background var(--duration) var(--ease);
}

.collab-thread-row:last-child {
    border-bottom: none;
}

.collab-thread-row:hover {
    background: var(--bg-secondary);
}

/* Item 3 (07.22.26-collab-widget-polish): the in-page project, pinned to
   the top of the default list by collab-widget.js's pinCurrentProject() —
   "Current" is spelled out explicitly rather than relying on position
   alone (position moves once other threads have unread activity ranked
   above it in the non-pinned case, so a bare "it's just always first"
   convention isn't legible on its own). */
.collab-thread-row.current {
    background: var(--accent-soft);
}

.collab-thread-current-tag {
    margin-left: 6px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--accent);
    vertical-align: middle;
}

.collab-thread-row-name {
    font-size: 13px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.collab-thread-badge {
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font-mono);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    flex-shrink: 0;
}

.collab-empty, .collab-loading, .collab-error {
    padding: 24px 14px;
    text-align: center;
    font-size: 12px;
    color: var(--text-tertiary);
}

.collab-error {
    color: var(--status-failed);
}

/* Item 0 x item 3 fix (platform-qa routed back, 07.22.26-collab-widget-
   polish): the list-fetch error can now render ALONGSIDE the pinned
   current-project row (not only alone, in an otherwise-empty list) — see
   renderThreadList()'s comment. A compact left-aligned banner with a
   divider reads better stacked above a row than the centered full-panel
   `.collab-error` treatment it's based on. */
.collab-list-error {
    padding: 10px 14px;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid var(--border-subtle);
}

.collab-retry-btn {
    margin-top: 8px;
}

.collab-list-error .collab-retry-btn {
    margin-top: 0;
    flex-shrink: 0;
}

.collab-thread-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 120px;
}

.collab-note {
    max-width: 90%;
}

.collab-note-meta {
    display: flex;
    gap: 6px;
    align-items: baseline;
    font-size: 10px;
    color: var(--text-tertiary);
    margin-bottom: 2px;
    font-family: var(--font-mono);
}

.collab-note-author {
    font-weight: 600;
    color: var(--text-secondary);
}

.collab-note-body {
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--text);
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 7px 10px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Pending/failed send bubbles (07.22.26-collab-widget-send-blockers, bug 1
   fix) — the send path must never be indistinguishable between success and
   failure. `.collab-note-pending`/`.collab-note-failed` are visually
   distinct from a normal, confirmed `.collab-note` (dashed border, dimmed
   for pending / status-failed tint for failed) so a user scanning the
   thread can immediately tell "still sending" or "didn't send" apart from
   "this really is a delivered message" — never silently identical. */
.collab-note-pending .collab-note-body,
.collab-note-failed .collab-note-body {
    border: 1px dashed var(--border);
}

.collab-note-pending .collab-note-body {
    opacity: 0.65;
}

.collab-note-failed .collab-note-body {
    border-color: var(--status-failed);
}

.collab-note-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 3px;
    font-family: var(--font-mono);
}

.collab-note-status-failed {
    color: var(--status-failed);
}

.collab-note-retry-btn {
    background: none;
    border: 1px solid var(--status-failed);
    color: var(--status-failed);
    border-radius: var(--radius-sm);
    padding: 1px 8px;
    font-size: 10px;
    font-family: var(--font-mono);
    cursor: pointer;
}

.collab-note-retry-btn:not(:disabled):hover {
    background: var(--status-failed);
    color: #fff;
}

/* code-review-torvalds, round 3: the retry button now locks in step with
   composeInput/composeSend (hasPendingSend() — see collab-widget.js), so it
   needs its own visibly-not-live state, matching
   .collab-compose-input:disabled / .collab-compose-send:disabled below —
   an enabled-LOOKING control that silently no-ops on click is the exact bug
   this round closes; it must not just be functionally inert, it must LOOK
   inert. */
.collab-note-retry-btn:disabled {
    opacity: 0.5;
    cursor: default;
    border-color: var(--border);
    color: var(--text-tertiary);
}

.collab-mention-chip {
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 3px;
    padding: 0 3px;
    font-weight: 600;
}

.collab-compose {
    border-top: 1px solid var(--border-subtle);
    padding: 10px 12px;
    flex-shrink: 0;
    position: relative;
}

.collab-compose-input {
    width: 100%;
    resize: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 7px 9px;
    font-family: var(--font-sans);
    font-size: 12.5px;
    color: var(--text);
    background: var(--bg);
    box-sizing: border-box;
}

.collab-compose-input:focus {
    outline: none;
    border-color: var(--accent);
}

.collab-compose-input:disabled {
    opacity: 0.6;
    cursor: default;
}

.collab-compose-send {
    margin-top: 6px;
    width: 100%;
    padding: 6px 12px;
    font-size: 12.5px;
}

.collab-compose-send:disabled {
    opacity: 0.6;
    cursor: default;
}

.collab-mention-dropdown {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(100% + 4px);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    max-height: 160px;
    overflow-y: auto;
    z-index: 2;
}

.collab-mention-item {
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.collab-mention-item .collab-mention-name {
    color: var(--text);
}

.collab-mention-item .collab-mention-handle {
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    font-size: 10px;
}

.collab-mention-item.active,
.collab-mention-item:hover {
    background: var(--accent-soft);
}

.collab-mention-empty {
    padding: 8px 10px;
    font-size: 11px;
    color: var(--text-tertiary);
}

/* Per-project unread-notes chip — prepended by collab-widget.js into
   projects.html's .card-badges-row (see that template's comment). Styled as
   a filled pill (unlike the plain-text .badge-* siblings it sits next to)
   so it visibly reads as clickable/actionable, not a static descriptor. */
.collab-card-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: var(--accent);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    border-radius: 8px;
    padding: 1px 6px;
    cursor: pointer;
    border: none;
}

.collab-card-badge:hover {
    background: var(--accent-hover);
}

@media (max-width: 640px) {
    /* 07.22.26-collab-widget-resize-reposition: left -> right, mirroring
       the desktop rule's own change above. `right`/`bottom` are hardcoded
       here (not var(--collab-widget-right/bottom, ...)) same as they always
       were pre-this-round — the adaptive placement JS was already a
       desktop-only affordance (this override always won the cascade on a
       narrow viewport); not a new gap introduced by this pass, just kept
       parallel across both axes rather than fixed further (out of this
       round's 2-item scope). .collab-widget-fab intentionally stays 44px,
       NOT scaled down with the desktop 36px resize above — see that rule's
       own comment (accessibility touch-target floor, an independent axis
       from the desktop icon-affordance match this pass makes). */
    .collab-widget {
        right: 10px;
        bottom: 10px;
    }

    .collab-widget-fab {
        width: 44px;
        height: 44px;
    }

    .collab-widget-panel {
        width: calc(100vw - 20px);
        max-height: 72vh;
    }
}
