:root {
    /* Surfaces */
    --bg: #0b0c10;
    --bg-elevated: #14161c;
    --bg-elevated-hover: #191c24;
    --bg-input: #1a1d25;
    --border: #23262f;
    --border-strong: #2f3340;

    /* Text */
    --text: #ecedf2;
    --text-dim: #8b8f9c;
    --text-faint: #5f636f;

    /* Accent + status */
    --accent: #5b7cfa;
    --accent-hover: #6f8bff;
    --accent-soft: rgba(91, 124, 250, 0.14);
    --danger: #f0616a;
    --danger-soft: rgba(240, 97, 106, 0.14);
    --success: #38d399;
    --success-soft: rgba(56, 211, 153, 0.14);
    --warning: #f5a623;

    /* Shared channel colors; individual agents use generated accents. */
    --agent-team: #6b7280;

    /* Scale */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-full: 999px;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45);

    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --duration-fast: 0.12s;
    --duration: 0.18s;

    --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Several elements below set display:flex/block via a class selector,
   which (being an author style) otherwise wins over the UA's
   [hidden]{display:none} regardless of selector specificity -- without
   this, toggling the `hidden` attribute silently does nothing. */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

button {
    font-family: inherit;
    cursor: pointer;
}

a { color: inherit; }

::selection { background: var(--accent-soft); }

/* ---------- Auth ---------- */

.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(600px circle at 20% 10%, rgba(91, 124, 250, 0.08), transparent 60%),
        radial-gradient(500px circle at 85% 90%, rgba(176, 115, 255, 0.06), transparent 60%),
        var(--bg);
}

.auth-card {
    width: 360px;
    padding: var(--space-6);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.auth-title {
    margin: 0;
    font-size: 21px;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.auth-subtitle {
    margin: 4px 0 var(--space-6);
    color: var(--text-dim);
    font-size: 13px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.auth-form label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
    margin-top: var(--space-3);
}

.auth-form input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 11px 13px;
    font-size: 14px;
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.auth-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-form button {
    margin-top: var(--space-5);
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 11px 13px;
    font-size: 14px;
    font-weight: 600;
    transition: background var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
}

.auth-form button:hover { background: var(--accent-hover); }
.auth-form button:active { transform: scale(0.98); }

.auth-error {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(240, 97, 106, 0.25);
    border-radius: var(--radius-sm);
    padding: 11px 13px;
    font-size: 13px;
    margin-bottom: var(--space-3);
}

/* ---------- App shell ---------- */

.app-shell {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 248px;
    flex-shrink: 0;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-5) var(--space-4);
    border-bottom: 1px solid var(--border);
}

.logo-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
}

.logo-text {
    font-weight: 650;
    font-size: 14px;
    letter-spacing: -0.01em;
}

.channel-list {
    list-style: none;
    margin: 0;
    padding: var(--space-2);
    flex: 1;
    overflow-y: auto;
}

.channel-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
    transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}

.channel-item:hover {
    background: var(--bg-elevated-hover);
    color: var(--text);
}

.channel-item.active {
    background: var(--accent-soft);
    color: var(--text);
}

.channel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.channel-dot--team { background: var(--agent-team); }

.channel-label { flex: 1; }

.agent-status-badge {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: transparent;
    transition: background var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.agent-status-badge.status-idle { background: var(--text-faint); }
.agent-status-badge.status-thinking { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.agent-status-badge.status-error { background: var(--danger); box-shadow: 0 0 6px var(--danger); }

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border);
}

.conn-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: background var(--duration) var(--ease);
}

.conn-indicator--online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.conn-indicator--offline { background: var(--danger); }
.conn-indicator--polling { background: var(--warning); }

.btn-link {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: color var(--duration-fast) var(--ease);
    padding: 0;
}

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

/* ---------- Chat pane ---------- */

.chat-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header {
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: baseline;
    gap: var(--space-3);
}

.chat-header h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.chat-subtitle {
    color: var(--text-dim);
    font-size: 12px;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4) var(--space-6);
    display: flex;
    flex-direction: column;
}

.load-more {
    align-self: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: var(--radius-full);
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: var(--space-3);
    transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}

.load-more:hover { background: var(--bg-elevated-hover); color: var(--text); }

.msg {
    display: flex;
    gap: var(--space-3);
    padding: 7px 0;
    max-width: 720px;
    animation: msg-in var(--duration) var(--ease);
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: white;
    overflow: hidden;
}

.msg-avatar--team { background: var(--agent-team); }
.msg-avatar--user { background: #3a3f4d; }

.msg-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.msg-body { min-width: 0; }

.msg-meta {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    margin-bottom: 2px;
}

.msg-sender {
    font-weight: 650;
    font-size: 13px;
}

.msg-time {
    font-size: 11px;
    color: var(--text-faint);
}

.msg-content {
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.message-form {
    display: flex;
    align-items: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border);
}

.message-input-wrap {
    position: relative;
    flex: 1;
}

.message-form textarea {
    width: 100%;
    resize: none;
    height: 44px;
    min-height: 44px;
    max-height: 300px;
    overflow-y: auto;
    transition: height var(--duration-fast) var(--ease), border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 11px 13px;
    font-size: 14px;
    font-family: inherit;
    display: block;
    line-height: 1.4;
}

.message-form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.message-form button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    height: 44px;
    padding: 0 20px;
    font-weight: 600;
    font-size: 14px;
    transition: background var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
}

.message-form button:hover { background: var(--accent-hover); }
.message-form button:active { transform: scale(0.97); }

/* ---------- @Mention autocomplete ---------- */

.mention-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    max-width: 320px;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 20;
    animation: pop-in var(--duration-fast) var(--ease);
}

@keyframes pop-in {
    from { opacity: 0; transform: translateY(4px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.mention-option {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    color: var(--text);
    transition: background var(--duration-fast) var(--ease);
}

.mention-option:hover,
.mention-option.active {
    background: var(--bg-elevated-hover);
}

.mention-option .channel-dot {
    width: 7px;
    height: 7px;
}

.mention-option .mention-option-slug {
    color: var(--text-faint);
    font-size: 11px;
    margin-left: auto;
}

/* ---------- Mention highlight inside rendered messages ---------- */

.mention {
    border-radius: 5px;
    padding: 1px 6px;
    font-weight: 650;
    white-space: nowrap;
}


/* ---------- Header actions ---------- */

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.settings-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}

.settings-link:hover { background: var(--bg-elevated-hover); color: var(--text); }
.settings-link svg { display: block; }

/* ---------- Settings pages ---------- */

.settings-shell {
    max-width: 680px;
    margin: 0 auto;
    padding: var(--space-6) var(--space-5) 80px;
}

.settings-header {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
}

.settings-header h1 {
    font-size: 19px;
    font-weight: 650;
    letter-spacing: -0.01em;
    margin: 0;
    flex: 1;
}

.settings-nav {
    display: flex;
    gap: var(--space-1);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 3px;
}

.settings-nav a {
    text-decoration: none;
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}

.settings-nav a:hover { color: var(--text); }
.settings-nav a.active { background: var(--accent); color: white; }

.settings-main {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.settings-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    transition: border-color var(--duration) var(--ease);
}

.settings-card h2 {
    margin: 0;
    font-size: 14.5px;
    font-weight: 650;
}

.settings-card > p.settings-slug {
    margin: -8px 0 0;
}

.settings-card label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
}

.settings-card input[type="text"],
.settings-card input[type="password"] {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 10px 12px;
    font-size: 14px;
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.settings-card input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.settings-card button[type="submit"] {
    align-self: flex-start;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    transition: background var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease), opacity var(--duration-fast) var(--ease);
    position: relative;
}

.settings-card button[type="submit"]:hover:not(:disabled) { background: var(--accent-hover); }
.settings-card button[type="submit"]:active:not(:disabled) { transform: scale(0.97); }
.settings-card button[type="submit"]:disabled { opacity: 0.7; cursor: default; }

.settings-card button.is-loading {
    color: transparent;
}

.settings-card button.is-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.agent-form-head {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.settings-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.settings-avatar--fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 15px;
    font-weight: 700;
    overflow: hidden;
}

.settings-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.settings-slug {
    font-size: 11.5px;
    color: var(--text-dim);
}

.settings-card code {
    font-size: 11px;
    word-break: break-all;
    color: var(--text);
    background: var(--bg-input);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    display: inline-block;
}

.totp-qr {
    width: 176px;
    height: 176px;
    background: white;
    border-radius: var(--radius);
    padding: 8px;
    align-self: flex-start;
}

/* ---------- Avatar picker (click-the-avatar pattern) ---------- */

.avatar-picker {
    position: relative;
    width: 52px;
    height: 52px;
    flex-shrink: 0;
}

.avatar-picker-circle {
    width: 52px;
    height: 52px;
    cursor: pointer;
    transition: filter var(--duration-fast) var(--ease);
}

.avatar-picker-hint {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    /* Purely decorative -- must never intercept clicks, or a real mouse
       (which hit-tests the topmost element) hits this overlay instead of
       the circle underneath and the picker becomes unclickable. Hover is
       driven by :hover on the parent .avatar-picker, not on this element,
       so pointer-events:none doesn't affect the reveal transition. */
    pointer-events: none;
    transition: opacity var(--duration-fast) var(--ease);
}

.avatar-picker:hover .avatar-picker-hint {
    opacity: 1;
}

.avatar-picker:hover .avatar-picker-circle {
    filter: brightness(0.85);
}

.avatar-picker-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 30;
    min-width: 152px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    animation: pop-in var(--duration-fast) var(--ease);
}

.avatar-picker-menu button {
    background: none;
    border: none;
    text-align: left;
    color: var(--text);
    font-size: 13px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    transition: background var(--duration-fast) var(--ease);
}

.avatar-picker-menu button:hover:not(:disabled) { background: var(--bg-elevated-hover); }

.avatar-picker-menu button:disabled {
    color: var(--text-faint);
    cursor: default;
}

.avatar-picker-menu button[data-action="remove"]:not(:disabled) { color: var(--danger); }

/* ---------- Toasts ---------- */

.toast-host {
    position: fixed;
    bottom: var(--space-5);
    right: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    z-index: 100;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    color: var(--text);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13px;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
    max-width: 320px;
}

.toast--visible {
    opacity: 1;
    transform: translateY(0);
}

.toast--error {
    border-color: rgba(240, 97, 106, 0.35);
    color: #ffb3b8;
}

.toast--ok {
    border-color: rgba(56, 211, 153, 0.3);
}

/* ========================================================================== */
/* The Sons Control Center                                                    */
/* ========================================================================== */

:root {
    --control-bg: #090b10;
    --control-sidebar: #0d1017;
    --control-panel: #11151e;
    --control-panel-2: #151a25;
    --control-panel-hover: #191f2c;
    --control-input: #0d1118;
    --control-canvas: #0c1017;
    --control-overlay: rgba(2, 4, 8, .72);
    --control-line: #242b39;
    --control-line-strong: #343d50;
    --control-text: #f4f6fb;
    --control-muted: #9ba4b5;
    --control-faint: #697386;
    --control-violet: #8b6cff;
    --control-violet-strong: #7352f5;
    --control-violet-soft: rgba(139, 108, 255, 0.14);
    --control-cyan: #35c8e6;
    --control-green: #42d6a4;
    --control-amber: #ffb457;
    --control-rose: #ff738d;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --control-radius-sm: 8px;
    --control-radius: 12px;
    --control-radius-lg: 18px;
    --control-ease: cubic-bezier(.16, 1, .3, 1);
}

html[data-theme="light"] {
    --bg: #f3f5f8;
    --bg-elevated: #ffffff;
    --bg-elevated-hover: #f4f6fa;
    --bg-input: #f7f8fb;
    --border: #dfe3ea;
    --border-strong: #cbd2dc;
    --text: #172033;
    --text-dim: #526075;
    --text-faint: #6d788a;
    --accent: #6548d8;
    --accent-hover: #5638c7;
    --accent-soft: rgba(101, 72, 216, .10);
    --control-bg: #f2f4f7;
    --control-sidebar: #ffffff;
    --control-panel: #ffffff;
    --control-panel-2: #f7f8fb;
    --control-panel-hover: #f1f3f7;
    --control-input: #f8f9fb;
    --control-canvas: #eef1f5;
    --control-overlay: rgba(24, 31, 43, .38);
    --control-line: #dfe3e9;
    --control-line-strong: #c8ced8;
    --control-text: #172033;
    --control-muted: #4f5d72;
    --control-faint: #68758a;
    --control-violet: #6548d8;
    --control-violet-strong: #5638c7;
    --control-violet-soft: rgba(101, 72, 216, .10);
    --control-cyan: #087f9c;
    --control-green: #137b5a;
    --control-amber: #9a5b09;
    --control-rose: #b52f4b;
    --shadow-sm: 0 1px 2px rgba(23, 32, 51, .08);
    --shadow-md: 0 10px 28px rgba(23, 32, 51, .10);
    --shadow-lg: 0 22px 60px rgba(23, 32, 51, .14);
}

.control-body {
    min-height: 100dvh;
    height: auto;
    overflow: hidden;
    background:
        radial-gradient(900px 520px at 66% -12%, rgba(115, 82, 245, .12), transparent 60%),
        radial-gradient(700px 520px at 100% 95%, rgba(53, 200, 230, .055), transparent 58%),
        var(--control-bg);
    color: var(--control-text);
    font-size: 14px;
}

.control-body button,
.control-body input,
.control-body textarea,
.control-body select { font: inherit; }

.control-body button,
.control-body [role="button"] { touch-action: manipulation; }

.control-body :focus-visible {
    outline: 2px solid var(--control-cyan);
    outline-offset: 2px;
}

.icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.control-body svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
    flex: 0 0 auto;
}

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.skip-link {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 2000;
    transform: translateY(-150%);
    padding: 10px 14px;
    border-radius: var(--control-radius-sm);
    background: var(--control-text);
    color: var(--control-bg);
    font-weight: 700;
    transition: transform .18s var(--control-ease);
}

.skip-link:focus { transform: translateY(0); }

.control-shell {
    display: flex;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
}

.command-sidebar {
    position: relative;
    z-index: 60;
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--control-sidebar);
    border-right: 1px solid var(--control-line);
    box-shadow: 24px 0 80px rgba(0, 0, 0, .16);
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 76px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .045);
}

.brand-row > div:nth-child(2) {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.brand-row strong {
    font-size: 13px;
    line-height: 1.1;
    letter-spacing: .18em;
}

.brand-row small {
    color: var(--control-faint);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.brand-mark {
    position: relative;
    width: 28px;
    height: 34px;
    display: inline-flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    padding: 6px;
    border: 1px solid rgba(139, 108, 255, .4);
    border-radius: 10px;
    background: linear-gradient(145deg, rgba(139, 108, 255, .25), rgba(53, 200, 230, .08));
    box-shadow: 0 0 26px rgba(139, 108, 255, .18), inset 0 1px rgba(255,255,255,.1);
}

.brand-mark span {
    width: 3px;
    border-radius: 4px;
    background: linear-gradient(180deg, #b7a7ff, var(--control-violet));
    box-shadow: 0 0 8px rgba(139, 108, 255, .6);
}

.brand-mark span:nth-child(1) { height: 10px; }
.brand-mark span:nth-child(2) { height: 17px; }
.brand-mark span:nth-child(3) { height: 13px; }
.brand-mark.mini { width: 23px; height: 28px; padding: 5px; border-radius: 8px; }

.primary-navigation { padding: 14px 10px 4px; }

.nav-button,
.channel-nav-button {
    position: relative;
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--control-muted);
    text-decoration: none;
    text-align: left;
    cursor: pointer;
    transition: color .16s ease, background .16s ease, box-shadow .16s ease;
}

.nav-button svg,
.channel-nav-button svg { width: 18px; height: 18px; }

.nav-button:hover,
.channel-nav-button:hover {
    color: var(--control-text);
    background: rgba(255, 255, 255, .045);
}

.nav-button.is-active,
.channel-nav-button.is-active {
    color: #fff;
    background: linear-gradient(90deg, rgba(139, 108, 255, .17), rgba(139, 108, 255, .065));
    box-shadow: inset 2px 0 var(--control-violet);
}

.nav-button.is-active svg,
.channel-nav-button.is-active svg { color: #aa96ff; }

.channel-nav-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 34px; align-items: center; gap: 2px; border-radius: 9px; }
.channel-nav-row.is-active { background: linear-gradient(90deg, rgba(139, 108, 255, .17), rgba(139, 108, 255, .065)); box-shadow: inset 2px 0 var(--control-violet); }
.channel-nav-row .channel-nav-button { min-width: 0; }
.channel-nav-row .channel-nav-button.is-active { background: transparent; box-shadow: none; }
.channel-more-button { width: 32px; height: 32px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--control-faint); font-size: 22px; line-height: 1; cursor: pointer; opacity: .68; transition: opacity .16s ease, color .16s ease, background .16s ease; }
.channel-more-button span { display: block; transform: translateY(-1px); }
.channel-more-button:hover, .channel-more-button:focus-visible { opacity: 1; color: var(--control-text); background: rgba(255, 255, 255, .07); }
.channel-pin-indicator, .channel-lock-indicator { display: inline-flex; color: var(--control-faint); }
.channel-pin-indicator svg, .channel-lock-indicator svg { width: 13px; height: 13px; }
.channel-context-menu { position: fixed; z-index: 180; width: 210px; padding: 6px; border: 1px solid var(--control-line-strong); border-radius: 12px; background: var(--control-panel); box-shadow: 0 18px 50px rgba(0, 0, 0, .38); }
.channel-context-menu[hidden] { display: none; }
.channel-context-menu button { width: 100%; min-height: 40px; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--control-text); font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
.channel-context-menu button:hover, .channel-context-menu button:focus-visible { background: rgba(139, 108, 255, .12); }
.channel-context-menu button.danger { color: var(--control-rose); }

.nav-count {
    margin-left: auto;
    min-width: 22px;
    height: 20px;
    display: grid;
    place-items: center;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(255,255,255,.06);
    color: var(--control-faint);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.sidebar-section {
    min-height: 0;
    padding: 16px 10px 4px;
}

.sidebar-section:nth-of-type(2) {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--control-line-strong) transparent;
}

.sidebar-section-head,
.sidebar-label {
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    color: var(--control-faint);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.mini-icon-button,
.icon-button {
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--control-muted);
    cursor: pointer;
    transition: color .16s ease, background .16s ease, border-color .16s ease;
}

.mini-icon-button { width: 32px; height: 32px; border-radius: 8px; }
.mini-icon-button svg { width: 15px; height: 15px; }
.icon-button:hover,
.mini-icon-button:hover { color: var(--control-text); background: rgba(255,255,255,.06); border-color: var(--control-line); }

.channel-navigation { display: flex; flex-direction: column; gap: 2px; }

.channel-nav-icon {
    width: 25px;
    height: 25px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 7px;
    background: rgba(255,255,255,.035);
    color: var(--control-faint);
}

.channel-nav-icon svg { width: 14px; height: 14px; }
.channel-nav-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.channel-nav-copy strong { overflow: hidden; color: inherit; font-size: 12.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.channel-nav-copy small { overflow: hidden; color: var(--control-faint); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.channel-nav-status { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: var(--control-faint); }
.channel-nav-status.is-live { background: var(--control-green); box-shadow: 0 0 8px rgba(66,214,164,.6); }

.sidebar-build {
    flex: 0 0 auto;
    padding-bottom: 12px;
    border-top: 1px solid rgba(255,255,255,.045);
}

.local-only-dot {
    width: 7px;
    height: 7px;
    margin-left: auto;
    border-radius: 50%;
    background: var(--control-green);
    box-shadow: 0 0 7px rgba(66,214,164,.5);
}

.sidebar-account {
    flex: 0 0 auto;
    padding: 10px;
    border-top: 1px solid var(--control-line);
}

.account-link {
    min-height: 54px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px;
    border-radius: 10px;
    color: inherit;
    text-decoration: none;
    transition: background .16s ease;
}

.account-link:hover { background: rgba(255,255,255,.045); }
.account-link > svg { width: 16px; height: 16px; color: var(--control-faint); }
.user-avatar,
.agent-avatar {
    position: relative;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.13);
    border-radius: 11px;
    background: linear-gradient(145deg, rgba(139,108,255,.45), rgba(53,200,230,.22));
    color: white;
    font-size: 12px;
    font-weight: 750;
    box-shadow: inset 0 1px rgba(255,255,255,.12);
}

.user-avatar { width: 36px; height: 36px; }
.user-avatar img,
.agent-avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.account-copy strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.account-copy small { color: var(--control-faint); font-size: 10px; }

.connection-row {
    min-height: 30px;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 8px 0;
    color: var(--control-faint);
    font-size: 10px;
}

.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--control-rose); }
.connection-dot.is-online { background: var(--control-green); box-shadow: 0 0 7px rgba(66,214,164,.6); }
.connection-dot.is-polling { background: var(--control-amber); }
.theme-toggle {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    margin-left: auto;
    border: 1px solid var(--control-line);
    border-radius: 9px;
    background: var(--control-panel-2);
    color: var(--control-muted);
    cursor: pointer;
}
.theme-toggle:hover { color: var(--control-text); border-color: var(--control-line-strong); }
.theme-toggle svg { width: 15px; height: 15px; }

.text-button,
.text-link-button {
    min-height: 36px;
    padding: 6px 8px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--control-muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

.text-button:hover,
.text-link-button:hover { color: var(--control-text); background: rgba(255,255,255,.045); }

.sidebar-close,
.sidebar-scrim,
.mobile-topbar { display: none; }

.workspace-shell {
    min-width: 0;
    flex: 1;
    height: 100dvh;
    overflow: hidden;
}

.workspace-main {
    height: 100%;
    overflow: hidden;
}

.app-view {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--control-line-strong) transparent;
}

.overview-view,
.agents-view,
.memory-view {
    padding: clamp(28px, 4vw, 58px) clamp(24px, 5vw, 72px) 64px;
}

.automations-view { padding: 30px clamp(20px, 3vw, 42px) 34px; }

.page-header {
    max-width: 1380px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 32px;
    margin: 0 auto 32px;
}

.page-header > div:first-child { max-width: 760px; }
.page-header h1 { margin: 5px 0 8px; font-size: clamp(28px, 3.1vw, 46px); line-height: 1.06; letter-spacing: -.045em; }
.page-header p { max-width: 680px; margin: 0; color: var(--control-muted); font-size: 14px; line-height: 1.65; }
.compact-header h1 { font-size: clamp(27px, 2.5vw, 38px); }

.eyebrow {
    color: #9c88ff;
    font-size: 10px;
    font-weight: 750;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.primary-button,
.secondary-button,
.send-mission-button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-weight: 700;
    font-size: 12.5px;
    cursor: pointer;
    transition: transform .14s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease, opacity .16s ease;
}

.primary-button,
.send-mission-button {
    background: linear-gradient(135deg, #9479ff, #7150ed);
    color: white;
    box-shadow: 0 8px 25px rgba(115,82,245,.2), inset 0 1px rgba(255,255,255,.18);
}

.primary-button:hover,
.send-mission-button:hover { background: linear-gradient(135deg, #a18aff, #7b5af3); box-shadow: 0 10px 30px rgba(115,82,245,.3), inset 0 1px rgba(255,255,255,.2); }
.primary-button:active,
.secondary-button:active,
.send-mission-button:active { transform: scale(.98); }
.primary-button:disabled,
.secondary-button:disabled,
.send-mission-button:disabled { cursor: not-allowed; opacity: .45; transform: none; box-shadow: none; }
.primary-button svg,
.secondary-button svg,
.send-mission-button svg { width: 16px; height: 16px; }

.secondary-button {
    border-color: var(--control-line-strong);
    background: rgba(255,255,255,.035);
    color: var(--control-text);
}

.secondary-button:hover { border-color: #4c5870; background: rgba(255,255,255,.065); }
.header-button-row { display: flex; align-items: center; gap: 10px; }

.panel-card {
    border: 1px solid var(--control-line);
    border-radius: var(--control-radius-lg);
    background: linear-gradient(145deg, rgba(20,25,35,.91), rgba(15,19,27,.94));
    box-shadow: 0 18px 50px rgba(0,0,0,.16), inset 0 1px rgba(255,255,255,.025);
}

.overview-grid {
    max-width: 1380px;
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(280px, .65fr);
    gap: 20px;
    margin: 0 auto 44px;
}

.mission-card {
    position: relative;
    min-height: 240px;
    overflow: visible;
    border-color: rgba(139,108,255,.28);
    background:
        radial-gradient(480px 190px at 0 0, rgba(139,108,255,.13), transparent 60%),
        linear-gradient(145deg, rgba(21,25,37,.96), rgba(14,18,26,.97));
}

.mission-card::after {
    content: "";
    position: absolute;
    inset: auto 10% -1px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(139,108,255,.65), transparent);
}

.mission-card-head,
.mission-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px;
}

.mission-card-head { border-bottom: 1px solid rgba(255,255,255,.055); }
.mission-card-head > div { display: flex; align-items: center; gap: 9px; }
.mission-card-head strong { font-size: 12px; letter-spacing: .02em; }
.status-pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--control-green); box-shadow: 0 0 0 4px rgba(66,214,164,.1), 0 0 10px rgba(66,214,164,.4); }
.keyboard-hint { padding: 4px 7px; border: 1px solid var(--control-line); border-radius: 6px; color: var(--control-faint); font-size: 10px; }

.mission-card textarea {
    width: 100%;
    min-height: 104px;
    display: block;
    resize: none;
    padding: 20px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--control-text);
    font-size: clamp(16px, 1.7vw, 20px);
    line-height: 1.55;
}

.mission-card textarea::placeholder { color: #5e687a; }
.mission-footer { padding-top: 12px; }
.audience-button {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid var(--control-line);
    border-radius: 9px;
    background: rgba(255,255,255,.03);
    color: var(--control-muted);
    cursor: pointer;
}
.audience-button:hover { color: var(--control-text); background: rgba(255,255,255,.055); }
.audience-button svg { width: 16px; height: 16px; }
.audience-button .chevron { width: 13px; height: 13px; }
.send-mission-button { min-width: 142px; }

.system-card { padding: 18px; }
.system-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; color: var(--control-muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.live-badge { display: inline-flex; align-items: center; gap: 6px; color: var(--control-green); font-size: 9px; letter-spacing: .1em; }
.live-badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 7px currentColor; }
.system-metric { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,.055); }
.system-metric:last-child { border-bottom: 0; }
.system-metric > div:first-child { display: flex; flex-direction: column; gap: 3px; }
.system-metric small { color: var(--control-faint); font-size: 10px; }
.system-metric strong { font-size: 17px; letter-spacing: -.02em; }
.metric-icon { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 10px; }
.metric-icon svg { width: 17px; height: 17px; }
.metric-icon.violet { background: rgba(139,108,255,.13); color: #a792ff; }
.metric-icon.cyan { background: rgba(53,200,230,.11); color: var(--control-cyan); }
.metric-icon.green { background: rgba(66,214,164,.11); color: var(--control-green); }
.metric-icon.amber { background: rgba(255,180,87,.11); color: var(--control-amber); }
.metric-icon.rose { background: rgba(255,115,141,.11); color: var(--control-rose); }

.dashboard-section { max-width: 1380px; margin: 0 auto 42px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.section-heading h2 { margin: 4px 0 0; font-size: 20px; letter-spacing: -.025em; }
.text-link-button { min-height: 40px; display: inline-flex; align-items: center; gap: 5px; }
.text-link-button svg { width: 14px; height: 14px; }

.agent-dashboard-grid,
.agent-studio-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.agent-card {
    position: relative;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
    overflow: hidden;
    border: 1px solid var(--control-line);
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(19,24,34,.9), rgba(14,18,26,.94));
    text-align: left;
    transition: transform .2s var(--control-ease), border-color .2s ease, background .2s ease;
}

button.agent-card { color: inherit; cursor: pointer; }
.agent-card:hover { transform: translateY(-2px); border-color: #384256; background: linear-gradient(145deg, rgba(23,29,41,.95), rgba(16,20,29,.97)); }
.agent-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 2px; background: linear-gradient(180deg, transparent, var(--agent-accent, var(--control-violet)), transparent); opacity: .8; }
.agent-card-head { display: flex; align-items: center; gap: 12px; }
.agent-card .agent-avatar { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(145deg, color-mix(in srgb, var(--agent-accent, var(--control-violet)) 55%, #24293a), #191e2b); }
.agent-card-title { min-width: 0; flex: 1; }
.agent-card-title strong { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.agent-card-title span { display: block; margin-top: 3px; overflow: hidden; color: var(--control-faint); font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.agent-state { display: inline-flex; align-items: center; gap: 5px; color: var(--control-green); font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.agent-state i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 7px currentColor; }
.agent-state.is-thinking { color: var(--control-amber); }
.agent-state.is-error { color: var(--control-rose); }
.agent-state.is-archived { color: var(--control-faint); }
.agent-card.is-archived { opacity: .68; border-style: dashed; }
.agent-card.is-archived:hover, .agent-card.is-archived:focus-visible { opacity: .9; }
.agent-card-description { min-height: 42px; display: -webkit-box; overflow: hidden; color: var(--control-muted); font-size: 11.5px; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.agent-card-footer { display: flex; align-items: center; gap: 7px; margin-top: auto; }
.agent-chip { max-width: 55%; display: inline-flex; align-items: center; gap: 4px; overflow: hidden; padding: 5px 8px; border: 1px solid rgba(255,255,255,.065); border-radius: 999px; background: rgba(255,255,255,.03); color: var(--control-faint); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.agent-chip svg { width: 11px; height: 11px; }
.agent-chip.is-connected { border-color: rgba(66,214,164,.17); color: #72dcb8; background: rgba(66,214,164,.055); }
.agent-card-action { margin-left: auto; color: var(--control-faint); }
.agent-card-action svg { width: 15px; height: 15px; }

.empty-card {
    min-height: 180px;
    display: grid;
    place-items: center;
    padding: 28px;
    border: 1px dashed var(--control-line-strong);
    border-radius: 14px;
    color: var(--control-muted);
    text-align: center;
}

.quick-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.quick-card { min-height: 82px; display: flex; align-items: center; gap: 13px; padding: 14px; border: 1px solid var(--control-line); border-radius: 13px; background: rgba(17,21,30,.75); color: inherit; text-align: left; cursor: pointer; transition: background .16s ease, border-color .16s ease, transform .16s ease; }
.quick-card:hover { transform: translateY(-1px); border-color: var(--control-line-strong); background: rgba(22,27,39,.9); }
.quick-card > span:nth-child(2) { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.quick-card strong { font-size: 12px; }
.quick-card small { color: var(--control-faint); font-size: 10px; }
.quick-arrow { width: 14px !important; height: 14px !important; color: var(--control-faint); }

/* Chat */

.chat-view { display: flex; flex-direction: column; overflow: hidden; }
.chat-header-new { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px clamp(18px, 3vw, 38px); border-bottom: 1px solid var(--control-line); background: rgba(11,14,20,.76); backdrop-filter: blur(18px); }
.chat-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.channel-symbol { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid rgba(139,108,255,.2); border-radius: 12px; background: var(--control-violet-soft); color: #a893ff; }
.channel-symbol svg { width: 19px; height: 19px; }
.chat-heading h1 { margin: 0; font-size: 16px; letter-spacing: -.02em; }
.chat-heading p { margin: 4px 0 0; overflow: hidden; color: var(--control-faint); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.chat-header-actions { display: flex; align-items: center; gap: 10px; }
.member-stack { display: flex; align-items: center; padding-left: 8px; }
.member-stack .agent-avatar { width: 30px; height: 30px; margin-left: -8px; border: 2px solid #0e1118; border-radius: 9px; font-size: 9px; }
.member-stack .member-overflow { width: 30px; height: 30px; display: grid; place-items: center; margin-left: -8px; border: 2px solid #0e1118; border-radius: 9px; background: var(--control-panel-2); color: var(--control-muted); font-size: 9px; }

.chat-view .messages { min-height: 0; flex: 1; overflow-y: auto; padding: 20px clamp(18px, 5vw, 72px) 28px; }
.message-list { width: min(860px, 100%); margin: 0 auto; }
.chat-view .load-more { min-height: 38px; margin: 0 auto 18px; border-color: var(--control-line); background: var(--control-panel); color: var(--control-muted); }
.chat-view .msg { position: relative; max-width: none; gap: 12px; padding: 11px 0; }
.chat-view .msg + .msg { border-top: 1px solid rgba(255,255,255,.025); }
.chat-view .msg-avatar { width: 34px; height: 34px; border-radius: 10px; }
.chat-view .msg-body { max-width: min(720px, calc(100% - 46px)); }
.chat-view .msg-sender { font-size: 12px; }
.chat-view .msg-time { font-size: 9px; }
.chat-view .msg-content { color: #dce1ec; font-size: 13px; line-height: 1.65; }
.chat-view .mention { display: inline-flex; align-items: center; padding: 1px 4px; border-radius: 4px; background: var(--control-violet-soft); color: #b8a9ff; font-weight: 650; }
.chat-view .msg-error .msg-content { color: #ffb3bf; }

.chat-empty { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; text-align: center; }
.chat-empty h2,
.flow-empty h2 { margin: 17px 0 6px; font-size: 17px; }
.chat-empty p,
.flow-empty p { max-width: 430px; margin: 0; color: var(--control-faint); font-size: 11.5px; line-height: 1.6; }
.empty-orbit { width: 58px; height: 58px; display: grid; place-items: center; border: 1px solid rgba(139,108,255,.23); border-radius: 19px; background: radial-gradient(circle, rgba(139,108,255,.19), rgba(139,108,255,.04)); color: #a994ff; box-shadow: 0 0 34px rgba(139,108,255,.1); }
.empty-orbit svg { width: 24px; height: 24px; }

.message-form-new { flex: 0 0 auto; width: min(900px, calc(100% - 36px)); margin: 0 auto 18px; padding: 10px; border: 1px solid var(--control-line-strong); border-radius: 15px; background: rgba(18,22,31,.94); box-shadow: 0 15px 50px rgba(0,0,0,.28), inset 0 1px rgba(255,255,255,.025); backdrop-filter: blur(16px); }
.composer-context { min-height: 25px; display: flex; align-items: center; gap: 8px; padding: 0 4px 7px; }
.composer-context > span { display: inline-flex; align-items: center; gap: 5px; padding: 3px 7px; border-radius: 6px; background: rgba(255,255,255,.035); color: var(--control-faint); font-size: 9px; }
.composer-context svg { width: 12px; height: 12px; }
.composer-context .memory-context-chip { background: rgba(66,214,164,.07); color: #76dfbc; }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.message-form-new .message-input-wrap { min-width: 0; flex: 1; }
.message-form-new textarea { width: 100%; min-height: 44px; max-height: 220px; display: block; resize: none; overflow-y: auto; padding: 11px 12px; border: 0; outline: 0; background: transparent; color: var(--control-text); font-size: 14px; line-height: 1.55; }
.message-form-new textarea::placeholder { color: #687183; }
.composer-send { width: 44px; height: 44px; display: grid; place-items: center; flex: 0 0 auto; border: 0; border-radius: 11px; background: linear-gradient(135deg, #9277ff, #6f4fe6); color: white; cursor: pointer; box-shadow: 0 6px 20px rgba(115,82,245,.25); transition: transform .14s ease, filter .14s ease; }
.composer-send:hover { filter: brightness(1.08); }
.composer-send:active { transform: scale(.96); }
.composer-send:disabled { cursor: not-allowed; opacity: .45; }
.composer-send svg { width: 18px; height: 18px; }
.composer-help { padding: 5px 5px 0; color: var(--control-faint); font-size: 9px; text-align: right; }
.message-form-new .mention-dropdown { bottom: calc(100% + 12px); left: 0; width: min(390px, calc(100vw - 48px)); max-height: 260px; padding: 6px; border: 1px solid var(--control-line-strong); border-radius: 12px; background: #151a24; box-shadow: 0 18px 50px rgba(0,0,0,.45); }
.message-form-new .mention-option { min-height: 44px; border-radius: 8px; }
.message-form-new .mention-option.active { background: var(--control-violet-soft); }

/* Agent Studio */

.filter-toolbar { max-width: 1380px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 auto 18px; }
.search-field { width: min(420px, 100%); min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border: 1px solid var(--control-line); border-radius: 10px; background: rgba(17,21,30,.75); color: var(--control-faint); }
.search-field svg { width: 16px; height: 16px; }
.search-field input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--control-text); }
.search-field input::placeholder { color: var(--control-faint); }
.security-note { display: flex; align-items: center; gap: 7px; color: var(--control-faint); font-size: 10px; }
.security-note svg { width: 14px; height: 14px; color: var(--control-green); }
.agent-studio-grid { max-width: 1380px; margin: 0 auto; }
.agent-studio-grid .agent-card { min-height: 215px; }
.agent-studio-grid .agent-card-description { min-height: 54px; -webkit-line-clamp: 3; }
.agent-capabilities { display: flex; flex-wrap: wrap; gap: 5px; }
.agent-capabilities span { padding: 4px 7px; border-radius: 5px; background: rgba(255,255,255,.035); color: var(--control-faint); font-size: 8.5px; text-transform: capitalize; }

/* Dialogs and forms */

.app-dialog { width: min(900px, calc(100vw - 32px)); max-height: min(900px, calc(100dvh - 32px)); padding: 0; overflow: hidden; border: 1px solid var(--control-line-strong); border-radius: 18px; background: #11151e; color: var(--control-text); box-shadow: 0 36px 120px rgba(0,0,0,.7); }
.app-dialog::backdrop { background: rgba(2,4,8,.72); backdrop-filter: blur(8px); }
.dialog-shell { max-height: min(900px, calc(100dvh - 32px)); display: flex; flex-direction: column; }
.narrow-dialog { width: min(580px, calc(100vw - 32px)); }
.dialog-header { flex: 0 0 auto; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 22px 24px 18px; border-bottom: 1px solid var(--control-line); }
.dialog-header h2 { margin: 4px 0 5px; font-size: 21px; letter-spacing: -.03em; }
.dialog-header p { margin: 0; color: var(--control-faint); font-size: 11px; }
.dialog-body { min-height: 0; overflow-y: auto; padding: 22px 24px; }
.dialog-footer { flex: 0 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding: 14px 24px; border-top: 1px solid var(--control-line); background: rgba(9,12,17,.45); }
.agent-form-grid { display: flex; flex-direction: column; gap: 24px; }
.form-section { display: flex; flex-direction: column; gap: 15px; padding-bottom: 24px; border-bottom: 1px solid rgba(255,255,255,.055); }
.form-section:last-child { padding-bottom: 0; border-bottom: 0; }
.form-section-title { display: flex; align-items: flex-start; gap: 12px; }
.form-section-title > span { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid rgba(139,108,255,.24); border-radius: 8px; background: var(--control-violet-soft); color: #a994ff; font-size: 9px; font-weight: 800; }
.form-section-title h3 { margin: 0 0 3px; font-size: 13px; }
.form-section-title p { margin: 0; color: var(--control-faint); font-size: 10px; }
.field-grid { display: grid; gap: 14px; }
.field-grid.two-columns { grid-template-columns: repeat(2, minmax(0,1fr)); }
.wide-field { grid-column: 1 / -1; }
.dialog-body label,
.memory-form label { display: flex; flex-direction: column; gap: 7px; color: var(--control-muted); font-size: 10px; font-weight: 650; letter-spacing: .02em; }
.dialog-body input:not([type="checkbox"]):not([type="range"]),
.dialog-body textarea,
.dialog-body select,
.memory-form input:not([type="checkbox"]) { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--control-line); border-radius: 9px; outline: 0; background: #0d1118; color: var(--control-text); font-size: 13px; transition: border-color .16s ease, box-shadow .16s ease; }
.dialog-body textarea { min-height: 100px; resize: vertical; line-height: 1.55; }
.dialog-body input:focus,
.dialog-body textarea:focus,
.dialog-body select:focus,
.memory-form input:focus { border-color: var(--control-violet); box-shadow: 0 0 0 3px rgba(139,108,255,.12); }
.dialog-body input::placeholder,
.dialog-body textarea::placeholder,
.memory-form input::placeholder { color: #596274; }
.handle-field { display: flex; align-items: center; border: 1px solid var(--control-line); border-radius: 9px; background: #0d1118; }
.handle-field:focus-within { border-color: var(--control-violet); box-shadow: 0 0 0 3px rgba(139,108,255,.12); }
.handle-field > span { padding-left: 12px; color: var(--control-faint); }
.handle-field input { border: 0 !important; box-shadow: none !important; }
.secret-field { display: flex; align-items: center; border: 1px solid var(--control-line); border-radius: 9px; background: #0d1118; }
.secret-field:focus-within { border-color: var(--control-violet); box-shadow: 0 0 0 3px rgba(139,108,255,.12); }
.secret-field input { min-width: 0; flex: 1; border: 0 !important; box-shadow: none !important; }
.secret-field .text-button { margin-right: 5px; }
.field-help { color: var(--control-faint); font-size: 9px; font-weight: 450; text-align: right; }
.temperature-row { padding: 12px 14px; border: 1px solid var(--control-line); border-radius: 10px; background: rgba(255,255,255,.018); }
.temperature-row > label { flex-direction: row; justify-content: space-between; }
.temperature-row output { color: #aa96ff; font-variant-numeric: tabular-nums; }
.temperature-row input { width: 100%; accent-color: var(--control-violet); }
.temperature-row > div { display: flex; justify-content: space-between; color: var(--control-faint); font-size: 8.5px; }
.capability-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.capability-card { position: relative; min-height: 68px; flex-direction: row !important; align-items: center; gap: 9px !important; padding: 10px; border: 1px solid var(--control-line); border-radius: 10px; background: rgba(255,255,255,.018); cursor: pointer; }
.capability-card:has(input:checked) { border-color: rgba(139,108,255,.35); background: rgba(139,108,255,.055); }
.capability-card input { position: absolute; opacity: 0; pointer-events: none; }
.capability-card .metric-icon { width: 32px; height: 32px; }
.capability-card > span:nth-of-type(2) { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.capability-card strong { color: var(--control-text); font-size: 10.5px; }
.capability-card small { color: var(--control-faint); font-size: 8.5px; }
.capability-card i { width: 18px; height: 18px; display: grid; place-items: center; border: 1px solid var(--control-line-strong); border-radius: 5px; color: transparent; }
.capability-card i svg { width: 12px; height: 12px; }
.capability-card:has(input:checked) i { border-color: var(--control-violet); background: var(--control-violet); color: white; }
.member-fieldset { margin: 18px 0 0; padding: 0; border: 0; }
.member-fieldset legend { margin-bottom: 10px; color: var(--control-muted); font-size: 10px; font-weight: 650; }
.group-agent-options { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.group-agent-option { min-height: 58px; flex-direction: row !important; align-items: center; gap: 10px !important; padding: 9px; border: 1px solid var(--control-line); border-radius: 10px; background: rgba(255,255,255,.018); cursor: pointer; }
.group-agent-option:has(input:checked) { border-color: rgba(139,108,255,.38); background: rgba(139,108,255,.07); }
.group-agent-option .agent-avatar { width: 34px; height: 34px; border-radius: 9px; }
.group-agent-option > span:nth-of-type(2) { min-width: 0; flex: 1; }
.group-agent-option strong { display: block; overflow: hidden; color: var(--control-text); font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.group-agent-option small { display: block; margin-top: 2px; color: var(--control-faint); font-size: 8.5px; }

/* Automation canvas */

.automation-layout { height: calc(100dvh - 160px); min-height: 580px; display: grid; grid-template-columns: 240px minmax(0,1fr); gap: 14px; }
.workflow-sidebar { min-height: 0; display: flex; flex-direction: column; overflow: hidden; border-radius: 14px; }
.workflow-sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 15px; border-bottom: 1px solid var(--control-line); }
.workflow-sidebar-head strong { font-size: 11px; }
.workflow-sidebar-head span { min-width: 22px; height: 20px; display: grid; place-items: center; border-radius: 999px; background: rgba(255,255,255,.05); color: var(--control-faint); font-size: 9px; }
.workflow-list { min-height: 0; flex: 1; overflow-y: auto; padding: 7px; }
.workflow-list-button { width: 100%; min-height: 64px; display: flex; align-items: flex-start; gap: 9px; padding: 10px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--control-muted); text-align: left; cursor: pointer; }
.workflow-list-button:hover { background: rgba(255,255,255,.035); }
.workflow-list-button.is-active { border-color: rgba(139,108,255,.23); background: rgba(139,108,255,.075); color: var(--control-text); }
.workflow-list-button > span:first-child { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: rgba(139,108,255,.1); color: #a48fff; }
.workflow-list-button svg { width: 14px; height: 14px; }
.workflow-list-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.workflow-list-copy strong { overflow: hidden; font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.workflow-list-copy small { color: var(--control-faint); font-size: 8.5px; }
.workflow-enabled-dot { width: 6px; height: 6px; margin-top: 5px; border-radius: 50%; background: var(--control-faint); }
.workflow-enabled-dot.is-active { background: var(--control-green); box-shadow: 0 0 7px rgba(66,214,164,.5); }
.workflow-list-empty { padding: 26px 12px; color: var(--control-faint); font-size: 10px; line-height: 1.6; text-align: center; }
.flow-workspace { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; border-radius: 14px; }
.flow-toolbar { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 10px 15px; border-bottom: 1px solid var(--control-line); }
.flow-toolbar > div:first-child { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.flow-toolbar input { width: min(360px, 46vw); border: 0; outline: 0; background: transparent; color: var(--control-text); font-size: 13px; font-weight: 700; }
.flow-toolbar > div span { color: var(--control-faint); font-size: 8.5px; }
.switch-label { flex-direction: row !important; align-items: center; gap: 8px !important; cursor: pointer; }
.switch-label input { position: absolute; opacity: 0; }
.switch-ui { position: relative; width: 34px; height: 20px; border-radius: 999px; background: #2a3140; transition: background .18s ease; }
.switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #8992a3; transition: transform .2s var(--control-ease), background .18s ease; }
.switch-label input:checked + .switch-ui { background: rgba(139,108,255,.42); }
.switch-label input:checked + .switch-ui::after { transform: translateX(14px); background: #b5a6ff; }
.flow-tip { min-height: 36px; display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-bottom: 1px solid rgba(255,255,255,.04); background: rgba(139,108,255,.035); color: var(--control-faint); font-size: 9px; }
.flow-tip svg { width: 13px; height: 13px; color: #9f8cff; }
.flow-canvas { position: relative; min-height: 0; flex: 1; overflow: auto; background-color: #0c1017; background-image: radial-gradient(circle, rgba(93,105,127,.25) 1px, transparent 1.2px); background-size: 22px 22px; }
.flow-lines { position: absolute; inset: 0; width: 1400px; height: 900px; overflow: visible; pointer-events: none; }
.flow-line { fill: none; stroke: rgba(139,108,255,.72); stroke-width: 2; filter: drop-shadow(0 0 5px rgba(139,108,255,.28)); }
.flow-line-bg { fill: none; stroke: rgba(255,255,255,.07); stroke-width: 6; }
.flow-nodes { position: relative; width: 1400px; height: 900px; }
.flow-node { position: absolute; width: 196px; min-height: 92px; display: flex; align-items: center; gap: 10px; padding: 12px 15px; border: 1px solid #30394a; border-radius: 12px; background: linear-gradient(145deg, rgba(24,29,41,.98), rgba(15,19,27,.99)); box-shadow: 0 12px 30px rgba(0,0,0,.25); cursor: grab; user-select: none; touch-action: none; }
.flow-node:active { cursor: grabbing; }
.flow-node.is-source { border-color: var(--control-violet); box-shadow: 0 0 0 3px rgba(139,108,255,.1), 0 14px 36px rgba(0,0,0,.3); }
.flow-node .agent-avatar { width: 38px; height: 38px; border-radius: 10px; }
.flow-node-copy { min-width: 0; flex: 1; }
.flow-node-copy strong { display: block; overflow: hidden; font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.flow-node-copy small { display: block; margin-top: 3px; overflow: hidden; color: var(--control-faint); font-size: 8.5px; text-overflow: ellipsis; white-space: nowrap; }
.flow-port { position: absolute; top: 50%; width: 18px; height: 18px; display: grid; place-items: center; padding: 0; border: 2px solid #151a24; border-radius: 50%; background: var(--control-violet); color: white; cursor: crosshair; transform: translateY(-50%); box-shadow: 0 0 0 2px rgba(139,108,255,.25); }
.flow-port::after { content: ""; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.flow-port.in { left: -9px; background: #2a3140; color: #aeb6c7; box-shadow: 0 0 0 2px rgba(255,255,255,.07); }
.flow-port.out { right: -9px; }
.flow-port:hover { transform: translateY(-50%) scale(1.18); }
.flow-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 2; padding: 30px; text-align: center; }
.flow-empty .secondary-button { margin-top: 17px; }
.routing-rules { flex: 0 0 auto; max-height: 170px; overflow-y: auto; border-top: 1px solid var(--control-line); background: rgba(10,13,18,.72); }
.routing-rule { min-height: 52px; display: grid; grid-template-columns: minmax(120px, .5fr) 20px minmax(120px,.5fr) minmax(180px,1.2fr) 36px; align-items: center; gap: 9px; padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,.04); }
.routing-rule:last-child { border-bottom: 0; }
.routing-rule strong { overflow: hidden; font-size: 9.5px; text-overflow: ellipsis; white-space: nowrap; }
.routing-rule > svg { width: 13px; height: 13px; color: var(--control-violet); }
.routing-rule input { min-height: 34px; padding: 7px 9px; border: 1px solid var(--control-line); border-radius: 7px; outline: 0; background: #0d1118; color: var(--control-text); font-size: 9.5px; }
.routing-rule input:focus { border-color: var(--control-violet); }
.routing-rule button { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--control-faint); cursor: pointer; }
.routing-rule button:hover { background: rgba(255,115,141,.08); color: var(--control-rose); }
.routing-rule button svg { width: 14px; height: 14px; }

/* Local memory */

.privacy-badge { min-height: 38px; display: inline-flex; align-items: center; gap: 7px; padding: 0 11px; border: 1px solid rgba(66,214,164,.19); border-radius: 999px; background: rgba(66,214,164,.055); color: #77debd; font-size: 10px; font-weight: 650; }
.privacy-badge svg { width: 13px; height: 13px; }
.memory-layout { max-width: 1380px; display: grid; grid-template-columns: minmax(350px,.8fr) minmax(420px,1.2fr); gap: 18px; margin: 0 auto; }
.memory-connect-card,
.memory-agents { padding: 24px; }
.memory-visual { position: relative; height: 126px; display: grid; place-items: center; overflow: hidden; margin: -4px -4px 18px; }
.memory-visual::before { content: ""; position: absolute; width: 230px; height: 84px; border: 1px solid rgba(139,108,255,.15); border-radius: 50%; transform: rotate(-8deg); }
.memory-visual::after { content: ""; position: absolute; width: 180px; height: 112px; border: 1px solid rgba(53,200,230,.12); border-radius: 50%; transform: rotate(16deg); }
.vault-core { position: relative; z-index: 2; width: 62px; height: 62px; display: grid; place-items: center; border: 1px solid rgba(139,108,255,.35); border-radius: 21px; background: radial-gradient(circle at 35% 30%, rgba(174,151,255,.4), rgba(91,63,201,.17) 60%, rgba(15,18,27,.9)); color: #c0b1ff; box-shadow: 0 0 45px rgba(139,108,255,.2), inset 0 1px rgba(255,255,255,.16); }
.vault-core svg { width: 29px; height: 29px; }
.memory-visual > span { position: absolute; z-index: 3; width: 7px; height: 7px; border-radius: 50%; background: var(--control-cyan); box-shadow: 0 0 9px currentColor; }
.memory-visual > span:nth-of-type(1) { left: 17%; top: 35%; color: var(--control-cyan); }
.memory-visual > span:nth-of-type(2) { right: 19%; top: 25%; color: var(--control-violet); background: currentColor; }
.memory-visual > span:nth-of-type(3) { right: 25%; bottom: 18%; color: var(--control-green); background: currentColor; }
.memory-connect-copy h2,
.memory-agents-head h2 { margin: 4px 0 7px; font-size: 18px; }
.memory-connect-copy p { margin: 0 0 20px; color: var(--control-muted); font-size: 11.5px; line-height: 1.65; }
.memory-connect-copy code { padding: 2px 5px; border: 1px solid var(--control-line); border-radius: 5px; background: #0b0f15; color: #a99aff; font-size: 10px; }
.memory-form { display: flex; flex-direction: column; gap: 8px; }
.memory-form label:not(:first-child) { margin-top: 6px; }
.checkbox-row { min-height: 44px; flex-direction: row !important; align-items: center; gap: 10px !important; margin-top: 8px !important; cursor: pointer; }
.checkbox-row input { width: 17px; height: 17px; accent-color: var(--control-violet); }
.memory-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.local-storage-note { display: flex; align-items: flex-start; gap: 10px; margin-top: 18px; padding: 11px; border: 1px solid rgba(66,214,164,.12); border-radius: 10px; background: rgba(66,214,164,.035); color: var(--control-faint); font-size: 9px; line-height: 1.55; }
.local-storage-note svg { width: 15px; height: 15px; flex: 0 0 auto; color: var(--control-green); }
.local-storage-note strong { display: block; margin-bottom: 2px; color: #8ce4c6; }
.memory-agents-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--control-line); }
.memory-agent-list { display: flex; flex-direction: column; }
.memory-agent-row { min-height: 70px; display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid rgba(255,255,255,.045); }
.memory-agent-row:last-child { border-bottom: 0; }
.memory-agent-row .agent-avatar { width: 38px; height: 38px; border-radius: 10px; }
.memory-agent-copy { min-width: 0; flex: 1; }
.memory-agent-copy strong { display: block; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.memory-agent-copy code { display: block; margin-top: 4px; overflow: hidden; color: var(--control-faint); font-size: 8.5px; text-overflow: ellipsis; white-space: nowrap; }
.memory-state { min-width: 72px; display: flex; align-items: center; justify-content: flex-end; gap: 6px; color: var(--control-faint); font-size: 8.5px; }
.memory-state i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.memory-state.is-ready { color: var(--control-green); }

/* Auth additions */

.auth-card--register { width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; }
.auth-brand-mark { width: 42px; height: 42px; display: flex; align-items: flex-end; justify-content: center; gap: 4px; margin-bottom: 18px; padding: 9px; border: 1px solid rgba(139,108,255,.35); border-radius: 13px; background: linear-gradient(145deg, rgba(139,108,255,.23), rgba(53,200,230,.07)); box-shadow: 0 0 30px rgba(139,108,255,.15); }
.auth-brand-mark span { width: 4px; border-radius: 5px; background: linear-gradient(#b7a7ff,#8062f5); box-shadow: 0 0 8px rgba(139,108,255,.5); }
.auth-brand-mark span:nth-child(1) { height: 12px; }
.auth-brand-mark span:nth-child(2) { height: 22px; }
.auth-brand-mark span:nth-child(3) { height: 16px; }
.auth-form small { color: var(--text-faint); font-size: 11px; }
.auth-form input,
.auth-form button { min-height: 44px; }
.auth-footer { margin: 20px 0 0; color: var(--text-dim); font-size: 12px; text-align: center; }
.auth-footer a { color: #a994ff; }
.auth-totp-setup h2 { margin: 8px 0; font-size: 17px; }
.auth-totp-setup > p { color: var(--text-dim); font-size: 12px; line-height: 1.5; }
.auth-totp-setup img { display: block; margin: 14px auto; padding: 8px; border-radius: 12px; background: white; }
.auth-secret { display: block; padding: 10px; overflow-wrap: anywhere; border-radius: 8px; background: var(--bg-input); color: var(--text); font-size: 12px; text-align: center; }
.auth-form button:disabled { cursor: not-allowed; opacity: .55; }

/* Toast refinement */

.control-body .toast-host { right: 22px; bottom: 22px; z-index: 1100; }
.control-body .toast { min-width: 250px; padding: 13px 15px; border-color: var(--control-line-strong); background: #171c27; box-shadow: 0 16px 50px rgba(0,0,0,.45); }

/* Light theme uses the same depth hierarchy without inverting the UI. */
html[data-theme="light"] .control-body {
    background: var(--control-bg);
}
html[data-theme="light"] .brand-mark,
html[data-theme="light"] .auth-brand-mark {
    background: #f0edff;
    box-shadow: none;
}
html[data-theme="light"] .panel-card,
html[data-theme="light"] .agent-card,
html[data-theme="light"] .quick-card,
html[data-theme="light"] .mission-card,
html[data-theme="light"] .flow-node {
    background: var(--control-panel);
    box-shadow: 0 10px 28px rgba(23, 32, 51, .07);
}
html[data-theme="light"] .mission-card {
    border-color: #d6cffa;
}
html[data-theme="light"] .primary-button,
html[data-theme="light"] .send-mission-button,
html[data-theme="light"] .composer-send {
    background: #5b3fc4;
    box-shadow: 0 7px 18px rgba(91, 63, 196, .18);
}
html[data-theme="light"] .primary-button:hover,
html[data-theme="light"] .send-mission-button:hover {
    background: #4d31b5;
}
html[data-theme="light"] .chat-header-new,
html[data-theme="light"] .mobile-topbar {
    background: rgba(255, 255, 255, .92);
}
html[data-theme="light"] .message-form-new,
html[data-theme="light"] .app-dialog,
html[data-theme="light"] .mention-dropdown,
html[data-theme="light"] .control-body .toast {
    background: var(--control-panel);
    box-shadow: 0 14px 38px rgba(23, 32, 51, .13);
}
html[data-theme="light"] .chat-view .msg-content { color: #283449; }
html[data-theme="light"] .member-stack .agent-avatar,
html[data-theme="light"] .member-stack .member-overflow { border-color: #fff; }
html[data-theme="light"] .dialog-body input:not([type="checkbox"]):not([type="range"]),
html[data-theme="light"] .dialog-body textarea,
html[data-theme="light"] .dialog-body select,
html[data-theme="light"] .memory-form input:not([type="checkbox"]),
html[data-theme="light"] .handle-field,
html[data-theme="light"] .secret-field,
html[data-theme="light"] .routing-rule input {
    background: var(--control-input);
    color: var(--control-text);
}
html[data-theme="light"] .flow-canvas {
    background-color: var(--control-canvas);
    background-image: radial-gradient(circle, rgba(82, 96, 118, .24) 1px, transparent 1.2px);
}
html[data-theme="light"] .flow-line-bg { stroke: rgba(46, 55, 71, .12); }
html[data-theme="light"] .dialog-footer,
html[data-theme="light"] .routing-rules { background: #f8f9fb; }
html[data-theme="light"] .auth-body {
    background: #f2f4f7;
}
html[data-theme="light"] .auth-card { background: #fff; }

@media (max-width: 1180px) {
    .agent-dashboard-grid,
    .agent-studio-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .quick-grid { grid-template-columns: 1fr; }
    .quick-card { min-height: 70px; }
    .capability-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .memory-layout { grid-template-columns: 1fr; }
}

.security-view { padding: 42px clamp(24px,4vw,64px) 64px; overflow-y: auto; }
.security-summary-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.security-summary { padding: 20px; display: grid; gap: 7px; }
.security-summary > span { color: var(--control-muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.security-summary strong { color: var(--control-text); font-size: 24px; letter-spacing: -.03em; }
.security-summary small { color: var(--control-subtle); line-height: 1.45; }
.security-layout { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.security-panel { padding: 20px; min-width: 0; }
.security-events-panel { grid-column: 1/-1; }
.security-list { display: grid; gap: 8px; }
.security-row { min-height: 62px; display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--control-line); border-radius: 12px; background: var(--control-panel-2); }
.security-row > span:nth-child(2) { min-width: 0; display: grid; gap: 4px; }
.security-row strong { color: var(--control-text); font-size: 13px; overflow-wrap: anywhere; }
.security-row small { color: var(--control-muted); font-size: 12px; overflow-wrap: anywhere; }
.security-event-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--control-cyan); box-shadow: 0 0 0 4px color-mix(in srgb,var(--control-cyan) 13%,transparent); }
.security-event-dot.warning { background: var(--control-amber); box-shadow: 0 0 0 4px color-mix(in srgb,var(--control-amber) 13%,transparent); }
.security-event-dot.critical { background: var(--control-rose); box-shadow: 0 0 0 4px color-mix(in srgb,var(--control-rose) 13%,transparent); }
.skeleton-line { height: 62px; border-radius: 12px; background: linear-gradient(90deg,var(--control-panel-2),var(--control-panel-hover),var(--control-panel-2)); background-size: 200% 100%; animation: skeleton 1.4s ease infinite; }
@keyframes skeleton { to { background-position: -200% 0; } }

.bundle-section { background: color-mix(in srgb,var(--control-violet) 4%,var(--control-panel)); }
.bundle-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.bundle-card { position:relative; min-height:110px; display:flex!important; flex-direction:column; align-items:flex-start!important; gap:6px!important; padding:14px; border:1px solid var(--control-line); border-radius:12px; background:var(--control-panel-2); cursor:pointer; }
.bundle-card:has(input:checked) { border-color:var(--control-violet); box-shadow:0 0 0 3px var(--control-violet-soft); background:color-mix(in srgb,var(--control-violet) 7%,var(--control-panel)); }
.bundle-card input { position:absolute; opacity:0; }
.bundle-card strong { color:var(--control-text); font-size:13px; }
.bundle-card small { color:var(--control-muted); font-size:11px; line-height:1.4; }
.bundle-card i { margin-top:auto; color:var(--control-faint); font-size:9px; font-style:normal; font-weight:800; text-transform:uppercase; letter-spacing:.08em; }
.agent-delete-trigger {
    min-height: 40px;
    display: inline-flex;
    flex: 0 0 auto !important;
    align-items: center;
    gap: 8px;
    margin-right: auto !important;
    padding: 0 12px;
    border: 1px solid color-mix(in srgb, var(--control-rose) 26%, var(--control-line));
    border-radius: 9px;
    background: color-mix(in srgb, var(--control-rose) 5%, transparent);
    color: color-mix(in srgb, var(--control-rose) 82%, var(--control-text));
    font: inherit;
    font-size: 11px;
    font-weight: 650;
    cursor: pointer;
    transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}
.agent-delete-trigger svg { width: 15px; height: 15px; stroke-width: 1.8; }
.agent-delete-trigger:hover { border-color: color-mix(in srgb, var(--control-rose) 48%, var(--control-line)); background: color-mix(in srgb, var(--control-rose) 10%, transparent); color: var(--control-rose); }
.agent-delete-trigger:active { transform: translateY(1px); }
.agent-delete-trigger:focus-visible { outline: 3px solid color-mix(in srgb, var(--control-rose) 24%, transparent); outline-offset: 2px; }
.dependency-list { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin-bottom:20px; }
.dependency-list>div { display:grid; gap:4px; padding:14px; border:1px solid var(--control-line); border-radius:10px; background:var(--control-panel-2); }
.dependency-list strong { font-size:22px; color:var(--control-text); }
.dependency-list span { color:var(--control-muted); font-size:10px; }
.delete-confirm-label { display:grid; gap:8px; color:var(--control-muted); font-size:12px; }
.delete-confirm-label > span { display:block; line-height:1.5; }
.delete-confirm-label > small { color:var(--control-faint); font-size:10px; font-weight:500; }
.delete-confirm-label > .field-error { color:var(--control-rose); }
.delete-confirm-label input { height:44px; padding:0 12px; border:1px solid var(--control-line); border-radius:9px; background:var(--control-input); color:var(--control-text); }
.delete-confirm-label input[aria-invalid="true"] { border-color:var(--control-rose); box-shadow:0 0 0 3px color-mix(in srgb,var(--control-rose) 12%,transparent); }
.danger-note { padding:12px; border:1px solid color-mix(in srgb,var(--control-rose) 28%,var(--control-line)); border-radius:9px; background:color-mix(in srgb,var(--control-rose) 7%,transparent); color:var(--control-muted); font-size:11px; line-height:1.5; }
.danger-button { min-height:44px; padding:0 16px; border:1px solid transparent; border-radius:9px; background:#b72d48; color:#fff; font-weight:750; cursor:pointer; }
.danger-button:disabled { cursor:not-allowed; opacity:.42; filter:saturate(.65); }
.step-up-body { display:grid; grid-template-columns:auto minmax(0,1fr); align-items:start; gap:10px 12px; }
.step-up-body>div { display:grid; gap:4px; }
.step-up-body>div>strong { font-size:14px; }
.step-up-body>div>p { margin:0; color:var(--control-muted); font-size:11px; line-height:1.55; }
.step-up-body>label, .step-up-body>input, .step-up-body>.field-error { grid-column:1/-1; }
.step-up-body>label { margin-top:8px; }
.step-up-body>input { height:50px!important; font-size:20px!important; font-weight:750; letter-spacing:.28em; text-align:center; font-variant-numeric:tabular-nums; }
.step-up-body>.field-error { margin:0; color:var(--control-rose); font-size:11px; line-height:1.45; }
.chat-settings-body { display:grid; gap:10px; }
.settings-action-card { width:100%; min-height:68px; display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:12px; padding:11px 13px; border:1px solid var(--control-line); border-radius:12px; background:var(--control-panel-2); color:var(--control-text); text-align:left; cursor:pointer; }
.settings-action-card:hover { border-color:var(--control-line-strong); background:var(--control-panel-hover); }
.settings-action-card>span:nth-child(2) { display:grid; gap:4px; }
.settings-action-card strong { font-size:13px; }
.settings-action-card small { color:var(--control-muted); font-size:10px; line-height:1.4; }
.settings-action-card>svg { width:16px; height:16px; color:var(--control-faint); }
.settings-action-card.danger-soft strong { color:var(--control-rose); }

/* Light mode is an editorial surface system, not an inverted dark palette. */
html[data-theme="light"] .control-shell { background:#edf1f5; }
html[data-theme="light"] .command-sidebar { background:#f8fafc; border-color:#d8dee7; box-shadow:12px 0 40px rgba(31,45,67,.07); }
html[data-theme="light"] .brand-row { border-bottom-color:#e1e6ed; }
html[data-theme="light"] .nav-button { color:#566479; }
html[data-theme="light"] .nav-button:hover { background:#eef1f6; color:#202b3e; }
html[data-theme="light"] .nav-button.is-active { background:#e9e5fb; color:#5139b6; box-shadow:inset 3px 0 #6548d8; }
html[data-theme="light"] .sidebar-label,
html[data-theme="light"] .sidebar-section-head { color:#727e90; }
html[data-theme="light"] .sidebar-account { border-top-color:#dfe4eb; background:#f4f6f9; }
html[data-theme="light"] .account-link:hover { background:#e9edf3; }
html[data-theme="light"] .workspace-main { background:linear-gradient(180deg,#f4f6f9 0,#edf1f5 100%); }
html[data-theme="light"] .page-header h1 { color:#111b2d; }
html[data-theme="light"] .page-header p { color:#5b687b; }
html[data-theme="light"] .panel-card,
html[data-theme="light"] .agent-card,
html[data-theme="light"] .quick-card { border-color:#dce2ea; box-shadow:0 1px 2px rgba(23,34,51,.04),0 12px 32px rgba(23,34,51,.055); }
html[data-theme="light"] .agent-card:hover,
html[data-theme="light"] .quick-card:hover { border-color:#c6ced9; box-shadow:0 2px 4px rgba(23,34,51,.05),0 18px 42px rgba(23,34,51,.09); transform:translateY(-2px); }
html[data-theme="light"] .mission-card { background:#fff; border-color:#cec5f3; box-shadow:0 18px 50px rgba(67,49,137,.09); }
html[data-theme="light"] .mission-card textarea { color:#172033; }
html[data-theme="light"] input,
html[data-theme="light"] textarea,
html[data-theme="light"] select { caret-color:#6548d8; }
html[data-theme="light"] input:focus,
html[data-theme="light"] textarea:focus,
html[data-theme="light"] select:focus { border-color:#8d7adb!important; box-shadow:0 0 0 3px rgba(101,72,216,.12); }
html[data-theme="light"] .secondary-button { background:#fff; border-color:#cfd6e0; color:#29364a; box-shadow:0 1px 2px rgba(20,31,47,.04); }
html[data-theme="light"] .secondary-button:hover { background:#f6f7fa; border-color:#b8c2cf; }
html[data-theme="light"] .privacy-badge,
html[data-theme="light"] .security-note { background:#edf8f4; border-color:#c6e8dc; color:#17664f; }
html[data-theme="light"] .chat-view { background:#f0f3f7; }
html[data-theme="light"] .message-form-new { border-color:#d7dde6; background:#fff; }
html[data-theme="light"] .msg-content { color:#263348; }
html[data-theme="light"] .security-row { background:#fafbfd; }
html[data-theme="light"] .app-dialog::backdrop { background:rgba(28,38,55,.35); backdrop-filter:blur(5px); }
html[data-theme="light"] .dialog-shell { background:#fff; border-color:#d8dee7; box-shadow:0 30px 90px rgba(24,35,52,.18); }
html[data-theme="light"] .dialog-header,
html[data-theme="light"] .dialog-footer { background:#fafbfd; border-color:#e0e5ec; }

@media (max-width: 900px) {
    .control-body { overflow: hidden; }
    .command-sidebar { position: fixed; inset: 0 auto 0 0; width: min(290px, calc(100vw - 48px)); transform: translateX(-105%); transition: transform .24s var(--control-ease); }
    .command-sidebar.is-open { transform: translateX(0); }
    .sidebar-close { display: grid; margin-left: auto; }
    .sidebar-scrim { position: fixed; inset: 0; z-index: 50; display: block; background: rgba(2,4,8,.68); backdrop-filter: blur(3px); }
    .mobile-topbar { height: var(--topbar-height); display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--control-line); background: rgba(12,15,22,.88); backdrop-filter: blur(16px); }
    .mobile-brand { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 800; letter-spacing: .13em; }
    .workspace-shell { width: 100%; }
    .workspace-main { height: calc(100dvh - var(--topbar-height)); }
    .overview-view,
    .agents-view,
    .memory-view,
    .security-view { padding: 26px 18px 44px; }
    .automations-view { padding: 18px 14px 20px; }
    .overview-grid { grid-template-columns: 1fr; }
    .system-card { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
    .system-card-head { grid-column: 1/-1; }
    .system-metric { align-items: flex-start; padding: 10px 0; border-right: 1px solid rgba(255,255,255,.055); border-bottom: 0; }
    .system-metric:last-child { border-right: 0; }
    .system-metric .metric-icon { display: none; }
    .chat-view .messages { padding-left: 18px; padding-right: 18px; }
    .automation-layout { height: auto; min-height: calc(100dvh - 190px); grid-template-columns: 1fr; }
    .workflow-sidebar { max-height: 170px; }
    .flow-workspace { min-height: 620px; }
}

@media (max-width: 640px) {
    .bundle-grid { grid-template-columns:1fr; }
    .security-summary-grid,
    .security-layout { grid-template-columns: 1fr; }
    .security-events-panel { grid-column: auto; }
    .page-header { flex-direction: column; align-items: stretch; gap: 18px; margin-bottom: 24px; }
    .page-header h1 { font-size: 30px; }
    .page-header .primary-button { width: 100%; }
    .overview-grid { margin-bottom: 34px; }
    .mission-card-head,
    .mission-footer { padding-left: 14px; padding-right: 14px; }
    .mission-card textarea { padding: 17px 14px; font-size: 16px; }
    .mission-footer { align-items: stretch; flex-direction: column; }
    .mission-footer button { width: 100%; }
    .system-card { display: block; }
    .system-metric { align-items: center; border-right: 0; border-bottom: 1px solid rgba(255,255,255,.055); }
    .system-metric .metric-icon { display: grid; }
    .agent-dashboard-grid,
    .agent-studio-grid { grid-template-columns: 1fr; }
    .filter-toolbar { align-items: stretch; flex-direction: column; }
    .security-note { padding-left: 4px; }
    .chat-header-new { min-height: 70px; padding: 10px 14px; }
    .member-stack { display: none; }
    .message-form-new { width: calc(100% - 20px); margin-bottom: max(10px, env(safe-area-inset-bottom)); }
    .composer-help { display: none; }
    .field-grid.two-columns,
    .capability-grid,
    .group-agent-options { grid-template-columns: 1fr; }
    .dialog-header,
    .dialog-body,
    .dialog-footer { padding-left: 16px; padding-right: 16px; }
    .dialog-footer > button { flex: 1; }
    .header-button-row { width: 100%; }
    .header-button-row button { flex: 1; }
    .automation-layout { min-height: 720px; }
    .workflow-sidebar { max-height: 150px; }
    .flow-workspace { min-height: 650px; }
    .routing-rule { grid-template-columns: 1fr 16px 1fr 34px; }
    .routing-rule input { grid-column: 1/-1; grid-row: 2; }
    .memory-connect-card,
    .memory-agents { padding: 17px; }
    .memory-actions { flex-direction: column-reverse; }
    .memory-actions button { width: 100%; }
    .memory-agents-head { align-items: flex-start; flex-direction: column; }
    .memory-agents-head button { width: 100%; }
    .control-body .toast-host { left: 10px; right: 10px; bottom: 10px; }
    .control-body .toast { min-width: 0; max-width: none; width: 100%; }
}

/* ========================================================================== */
/* Obsidian Ledger — Control Center only                                      */
/* ========================================================================== */

.control-body.is-overview-route {
    --ledger-bg:#11100e;
    --ledger-sidebar:#0a0a09;
    --ledger-surface:#171613;
    --ledger-surface-2:#1e1c18;
    --ledger-surface-3:#25221d;
    --ledger-text:#f2ede3;
    --ledger-muted:#aba397;
    --ledger-faint:#7f786d;
    --ledger-line:#37332b;
    --ledger-line-strong:#514a3d;
    --ledger-brass:#b58a4a;
    --ledger-brass-strong:#d0aa70;
    --ledger-success:#6f9b7a;
    --ledger-warning:#c28a3d;
    --ledger-error:#b55353;
    background:var(--ledger-bg);
    color:var(--ledger-text);
}

html[data-theme="light"] .control-body.is-overview-route {
    --ledger-bg:#f1ece2;
    --ledger-sidebar:#e5ded1;
    --ledger-surface:#f8f4ec;
    --ledger-surface-2:#ede6da;
    --ledger-surface-3:#fff;
    --ledger-text:#191611;
    --ledger-muted:#625b50;
    --ledger-faint:#7b7164;
    --ledger-line:#ccc1b0;
    --ledger-line-strong:#9e907c;
    --ledger-brass:#76501f;
    --ledger-brass-strong:#5d3c16;
    --ledger-success:#3f7350;
    --ledger-warning:#8a5a16;
    --ledger-error:#a33f3f;
}

html[data-theme="light"] .control-body.is-overview-route .command-sidebar {
    background: var(--ledger-sidebar);
    border-color: var(--ledger-line);
    box-shadow: none;
}

.is-overview-route .command-sidebar {
    background:var(--ledger-sidebar);
    border-right-color:var(--ledger-line);
    color:var(--ledger-muted);
}
.is-overview-route .brand-row { border-bottom:1px solid var(--ledger-line); }
.is-overview-route .brand-row strong { color:var(--ledger-text); letter-spacing:.18em; }
.is-overview-route .brand-row small { color:var(--ledger-faint); font-family:ui-sans-serif,system-ui,sans-serif; letter-spacing:.14em; }
.is-overview-route .brand-mark { border-color:var(--ledger-line-strong); border-radius:3px; background:transparent; box-shadow:none; }
.is-overview-route .brand-mark span { background:var(--ledger-brass); box-shadow:none; }
.is-overview-route .primary-navigation { padding-top:18px; }
.is-overview-route .primary-navigation::before,
.is-overview-route .sidebar-section-head>span::before,
.is-overview-route .sidebar-build>.sidebar-label::before { color:var(--ledger-brass); font:500 9px/1.2 ui-monospace,SFMono-Regular,Menlo,monospace; letter-spacing:.08em; }
.is-overview-route .primary-navigation::before { content:"01 / OPERATE"; display:block; padding:0 11px 8px; }
.is-overview-route .sidebar-section-head>span { color:var(--ledger-muted); }
.is-overview-route .sidebar-section-head>span::before { content:"02 / "; }
.is-overview-route .sidebar-build>.sidebar-label::before { content:"03 / "; }
.is-overview-route .nav-button,
.is-overview-route .channel-nav-button { border-radius:2px; }
.is-overview-route .nav-button:hover,
.is-overview-route .channel-nav-button:hover { background:var(--ledger-surface); color:var(--ledger-text); }
.is-overview-route .nav-button.is-active,
.is-overview-route .channel-nav-button.is-active,
.is-overview-route .channel-nav-row.is-active { background:var(--ledger-surface-2); color:var(--ledger-text); box-shadow:inset 3px 0 var(--ledger-brass); }
.is-overview-route .nav-button.is-active svg,
.is-overview-route .channel-nav-button.is-active svg { color:var(--ledger-brass-strong); }
.is-overview-route .sidebar-account { border-top-color:var(--ledger-line); background:var(--ledger-sidebar); }

.overview-view {
    padding:0 40px 64px;
    background:var(--ledger-bg);
    color:var(--ledger-text);
    font-family:ui-sans-serif,system-ui,var(--font);
}
.overview-view h1,
.overview-view h2,
.overview-view .ledger-metrics strong { font-family:Georgia,"Times New Roman",serif; font-weight:500; }
.overview-view button { font-family:ui-sans-serif,system-ui,var(--font); }
.ledger-header {
    min-height:112px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:32px;
    padding:24px 0 22px;
    border-bottom:1px solid var(--ledger-line);
}
.ledger-kicker,
.ledger-label,
.ledger-metrics span,
.ledger-table-head,
.ledger-roster-head,
.ledger-command-meta { font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:10px; letter-spacing:.1em; text-transform:uppercase; }
.ledger-kicker { display:block; color:var(--ledger-brass-strong); }
.ledger-heading-block h1 { margin:8px 0 2px; font-size:clamp(36px,4vw,52px); line-height:.94; letter-spacing:-.035em; }
.ledger-heading-block p { margin:7px 0 0; color:var(--ledger-muted); font-size:13px; }
.ledger-header-actions { display:flex; align-items:center; gap:10px; }
.ledger-system-state { min-height:44px; display:flex; align-items:center; gap:10px; padding:0 16px; border-left:1px solid var(--ledger-line); }
.ledger-system-state>span:last-child { display:grid; gap:2px; }
.ledger-system-state small { color:var(--ledger-faint); font:500 9px/1 ui-monospace,SFMono-Regular,Menlo,monospace; text-transform:uppercase; letter-spacing:.1em; }
.ledger-system-state strong { color:var(--ledger-text); font-size:11px; text-transform:uppercase; letter-spacing:.08em; }
.ledger-status-dot { width:7px; height:7px; border-radius:50%; background:var(--ledger-faint); }
.ledger-status-dot.is-success { background:var(--ledger-success); }
.ledger-primary-action,
.ledger-secondary-action,
.ledger-text-action,
.ledger-audience { min-height:44px; display:inline-flex; align-items:center; justify-content:center; gap:8px; border-radius:3px; cursor:pointer; transition:background .15s ease,border-color .15s ease,color .15s ease; }
.ledger-primary-action { padding:0 17px; border:1px solid var(--ledger-brass); background:var(--ledger-brass); color:#15110b; font-size:12px; font-weight:700; }
.ledger-primary-action:hover { border-color:var(--ledger-brass-strong); background:var(--ledger-brass-strong); }
.ledger-primary-action:focus-visible,
.ledger-secondary-action:focus-visible,
.ledger-text-action:focus-visible,
.ledger-audience:focus-visible { outline:2px solid var(--ledger-brass-strong)!important; outline-offset:3px; }
.ledger-primary-action svg { width:15px; height:15px; }
.ledger-secondary-action { padding:0 14px; border:1px solid var(--ledger-line-strong); background:transparent; color:var(--ledger-text); font-size:11px; }
.ledger-secondary-action:hover { background:var(--ledger-surface-2); }

.ledger-command {
    display:grid;
    grid-template-columns:48px minmax(140px,1.1fr) minmax(260px,3fr) minmax(120px,.8fr) 112px;
    align-items:stretch;
    gap:0;
    margin-top:32px;
    border-top:1px solid var(--ledger-line-strong);
    border-bottom:1px solid var(--ledger-line-strong);
    background:var(--ledger-surface);
}
.ledger-section-index { color:var(--ledger-brass); font:500 10px/1 ui-monospace,SFMono-Regular,Menlo,monospace; letter-spacing:.08em; }
.ledger-command>.ledger-section-index { padding:20px 12px; border-right:1px solid var(--ledger-line); }
.ledger-command-copy { padding:18px 20px; border-right:1px solid var(--ledger-line); }
.ledger-label { color:var(--ledger-faint); }
.ledger-command-copy h2 { margin:10px 0 0; font-size:24px; line-height:1.05; }
.ledger-command-input { position:relative; display:grid; grid-template-columns:auto 1fr; align-items:start; gap:10px; padding:17px 18px 12px; border-right:1px solid var(--ledger-line); background:var(--ledger-surface-2); }
.ledger-command-input>span { padding-top:5px; color:var(--ledger-brass-strong); font:600 16px/1 ui-monospace,SFMono-Regular,Menlo,monospace; }
.ledger-command-input textarea { width:100%; min-height:58px; resize:none; border:0; outline:0; background:transparent; color:var(--ledger-text); font-size:15px; line-height:1.5; }
.ledger-command-input textarea::placeholder { color:var(--ledger-faint); }
.ledger-command-input:focus-within { box-shadow:inset 0 -2px var(--ledger-brass); }
.ledger-command-meta { grid-column:1/-1; display:flex; flex-wrap:wrap; justify-content:space-between; gap:8px; color:var(--ledger-faint); font-size:8px; }
.ledger-audience { align-self:stretch; flex-direction:column; padding:12px; border:0; border-right:1px solid var(--ledger-line); background:transparent; color:var(--ledger-muted); text-align:left; }
.ledger-audience span { font:500 8px/1 ui-monospace,SFMono-Regular,Menlo,monospace; text-transform:uppercase; letter-spacing:.1em; }
.ledger-audience strong { color:var(--ledger-text); font-size:11px; }
.ledger-audience svg { width:12px; height:12px; }
.ledger-audience:hover { background:var(--ledger-surface-3); }
.ledger-send { align-self:center; min-height:44px; margin:12px; }

.ledger-metrics { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); margin:32px 0 40px; border-top:1px solid var(--ledger-line); border-bottom:1px solid var(--ledger-line); }
.ledger-metrics article { min-width:0; display:grid; gap:4px; padding:16px 18px; border-right:1px solid var(--ledger-line); }
.ledger-metrics article:last-child { border-right:0; }
.ledger-metrics span { color:var(--ledger-faint); font-size:8px; }
.ledger-metrics strong { overflow:hidden; color:var(--ledger-text); font-size:clamp(25px,2.5vw,36px); line-height:1; text-overflow:ellipsis; white-space:nowrap; }
.ledger-metrics small { color:var(--ledger-muted); font-size:10px; }

.ledger-workspace-grid { display:grid; grid-template-columns:minmax(0,2fr) minmax(260px,.78fr); gap:24px; margin-bottom:40px; }
.ledger-panel { border-top:2px solid var(--ledger-line-strong); border-bottom:1px solid var(--ledger-line); background:transparent; }
.ledger-panel-header { min-height:76px; display:flex; align-items:center; justify-content:space-between; gap:20px; padding:14px 0; border-bottom:1px solid var(--ledger-line); }
.ledger-panel-header>div { display:flex; align-items:flex-start; gap:16px; }
.ledger-panel-header h2 { margin:4px 0 0; font-size:22px; }
.ledger-text-action { padding:0; border:0; background:transparent; color:var(--ledger-muted); font-size:10px; text-transform:uppercase; letter-spacing:.08em; }
.ledger-text-action:hover { color:var(--ledger-brass-strong); }
.ledger-text-action svg { width:13px; height:13px; }
.ledger-table-head,
.ledger-operation-row { display:grid; grid-template-columns:100px minmax(170px,1.5fr) minmax(100px,.8fr) 76px 100px; align-items:center; gap:14px; }
.ledger-table-head { min-height:34px; padding:0 12px; border-bottom:1px solid var(--ledger-line); color:var(--ledger-faint); font-size:8px; }
.ledger-operation-row { width:100%; min-height:64px; padding:9px 12px; border:0; border-bottom:1px solid var(--ledger-line); background:transparent; color:var(--ledger-muted); text-align:left; }
.ledger-operation-row:hover { background:var(--ledger-surface-2); }
.ledger-operation-row>span:nth-child(2) { display:grid; gap:3px; }
.ledger-operation-row strong { color:var(--ledger-text); font-size:11px; }
.ledger-operation-row small { color:var(--ledger-faint); font-size:9px; }
.ledger-agent-state { display:inline-flex; align-items:center; gap:7px; color:var(--ledger-success); font-size:9px; font-weight:650; text-transform:uppercase; letter-spacing:.06em; }
.ledger-agent-state>i { width:6px; height:6px; border-radius:50%; background:currentColor; }
.ledger-agent-state.is-thinking { color:var(--ledger-warning); }
.ledger-agent-state.is-error { color:var(--ledger-error); }
.ledger-table-empty { min-height:160px; display:grid; align-content:center; justify-items:center; gap:5px; color:var(--ledger-faint); text-align:center; }
.ledger-table-empty strong { color:var(--ledger-text); font:500 22px/1.1 Georgia,"Times New Roman",serif; }
.ledger-table-empty span { font-size:11px; }

.ledger-attention { padding-left:20px; border-left:1px solid var(--ledger-line); }
.ledger-attention-list { min-height:150px; }
.ledger-attention-item,
.ledger-clear-state { display:grid; grid-template-columns:8px minmax(0,1fr); gap:10px; padding:14px 0; border-bottom:1px solid var(--ledger-line); }
.ledger-attention-item>span { width:7px; height:7px; margin-top:4px; border-radius:50%; background:var(--ledger-warning); }
.ledger-attention-item.is-error>span { background:var(--ledger-error); }
.ledger-attention-item>div,
.ledger-clear-state>div { display:grid; gap:4px; }
.ledger-attention-item strong,
.ledger-clear-state strong { color:var(--ledger-text); font-size:11px; }
.ledger-attention-item small,
.ledger-clear-state small { color:var(--ledger-muted); font-size:10px; line-height:1.45; }
.ledger-shortcuts { margin-top:22px; border-top:1px solid var(--ledger-line-strong); }
.ledger-shortcuts button { width:100%; min-height:44px; display:flex; align-items:center; justify-content:space-between; padding:0; border:0; border-bottom:1px solid var(--ledger-line); background:transparent; color:var(--ledger-muted); font-size:10px; text-transform:uppercase; letter-spacing:.06em; }
.ledger-shortcuts button:hover { color:var(--ledger-brass-strong); }
.ledger-shortcuts svg { width:13px; height:13px; }

.ledger-roster { margin-bottom:24px; }
.ledger-roster-head,
.ledger-agent-row { display:grid; grid-template-columns:minmax(210px,1.35fr) minmax(180px,1fr) minmax(130px,.8fr) 100px 90px; align-items:center; gap:18px; }
.ledger-roster-head { min-height:34px; padding:0 12px; border-bottom:1px solid var(--ledger-line); color:var(--ledger-faint); font-size:8px; }
.ledger-agent-row { width:100%; min-height:70px; padding:10px 12px; border:0; border-bottom:1px solid var(--ledger-line); background:transparent; color:var(--ledger-muted); text-align:left; }
.ledger-agent-row:hover { background:var(--ledger-surface-2); box-shadow:inset 3px 0 var(--ledger-brass); }
.ledger-agent-identity { min-width:0; display:flex; align-items:center; gap:11px; }
.ledger-agent-identity>i { color:var(--ledger-brass); font:500 9px/1 ui-monospace,SFMono-Regular,Menlo,monospace; font-style:normal; }
.ledger-avatar { width:36px; height:36px; display:grid; place-items:center; flex:0 0 auto; overflow:hidden; border:1px solid var(--ledger-line-strong); border-radius:2px; background:var(--ledger-surface-3); color:var(--ledger-text); font-size:10px; font-weight:700; }
.ledger-avatar img { width:100%; height:100%; object-fit:cover; }
.ledger-agent-identity>span:last-child,
.ledger-agent-provider { min-width:0; display:grid; gap:3px; }
.ledger-agent-identity strong,
.ledger-agent-provider strong { overflow:hidden; color:var(--ledger-text); font-size:11px; text-overflow:ellipsis; white-space:nowrap; }
.ledger-agent-identity small,
.ledger-agent-provider small { overflow:hidden; color:var(--ledger-faint); font:400 9px/1.2 ui-monospace,SFMono-Regular,Menlo,monospace; text-overflow:ellipsis; white-space:nowrap; }
.ledger-agent-capability { overflow:hidden; font-size:10px; text-transform:capitalize; text-overflow:ellipsis; white-space:nowrap; }
.ledger-agent-access { display:flex; align-items:center; justify-content:space-between; gap:6px; color:var(--ledger-muted); font-size:9px; text-transform:uppercase; letter-spacing:.05em; }
.ledger-agent-access svg { width:12px; height:12px; }
.ledger-empty { min-height:150px; display:grid; place-items:center; align-content:center; gap:7px; color:var(--ledger-muted); text-align:center; }
.ledger-empty strong { color:var(--ledger-text); font:500 23px/1.1 Georgia,"Times New Roman",serif; }
.ledger-empty span { font-size:11px; }
.ledger-empty button { min-height:38px; margin-top:8px; padding:0 13px; border:1px solid var(--ledger-line-strong); border-radius:3px; background:transparent; color:var(--ledger-text); }

html[data-theme="light"] .is-overview-route .nav-button:hover,
html[data-theme="light"] .is-overview-route .channel-nav-button:hover,
html[data-theme="light"] .ledger-operation-row:hover,
html[data-theme="light"] .ledger-agent-row:hover { background:var(--ledger-surface-2); }
html[data-theme="light"] .ledger-primary-action { color:#fff; }

@media (max-width:1180px) {
    .overview-view { padding-left:28px; padding-right:28px; }
    .ledger-header { align-items:flex-start; }
    .ledger-header-actions { flex-wrap:wrap; justify-content:flex-end; }
    .ledger-command { grid-template-columns:42px minmax(130px,.8fr) minmax(240px,2fr) 120px; }
    .ledger-command .ledger-send { grid-column:4; }
    .ledger-audience { grid-column:3; border-top:1px solid var(--ledger-line); border-left:1px solid var(--ledger-line); }
    .ledger-send { grid-column:4; grid-row:2; }
    .ledger-command-input { grid-row:1/3; }
    .ledger-command-copy,.ledger-command>.ledger-section-index { grid-row:1/3; }
    .ledger-roster-head,.ledger-agent-row { grid-template-columns:minmax(190px,1.3fr) minmax(160px,1fr) 100px 90px; }
    .ledger-roster-head>span:nth-child(3),.ledger-agent-capability { display:none; }
}

@media (max-width:900px) {
    .overview-view { padding:0 20px 48px; }
    .ledger-header { min-height:0; align-items:flex-start; flex-direction:column; padding:24px 0; }
    .ledger-header-actions { width:100%; justify-content:flex-start; }
    .ledger-command { grid-template-columns:42px 1fr; }
    .ledger-command>.ledger-section-index { grid-row:auto; }
    .ledger-command-copy { grid-row:auto; border-right:0; }
    .ledger-command-input { grid-column:1/-1; grid-row:auto; border-top:1px solid var(--ledger-line); border-right:0; }
    .ledger-audience { grid-column:1/2; border-left:0; border-right:1px solid var(--ledger-line); }
    .ledger-send { grid-column:2; grid-row:auto; justify-self:end; min-width:132px; }
    .ledger-metrics { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .ledger-metrics article:nth-child(2n) { border-right:0; }
    .ledger-metrics article { border-bottom:1px solid var(--ledger-line); }
    .ledger-metrics article:last-child { grid-column:1/-1; border-bottom:0; }
    .ledger-workspace-grid { grid-template-columns:1fr; }
    .ledger-attention { padding-left:0; border-left:0; }
    .ledger-table-head,.ledger-operation-row { grid-template-columns:90px minmax(150px,1fr) 90px; }
    .ledger-table-head>span:nth-child(4),.ledger-table-head>span:nth-child(5),.ledger-operation-row>span:nth-child(4),.ledger-operation-row>span:nth-child(5) { display:none; }
}

@media (max-width:620px) {
    .overview-view { padding:0 16px 40px; }
    .ledger-heading-block h1 { font-size:38px; }
    .ledger-header-actions { display:grid; grid-template-columns:1fr 1fr; }
    .ledger-system-state { grid-column:1/-1; padding-left:0; border-left:0; }
    .ledger-secondary-action,.ledger-primary-action { width:100%; }
    .ledger-command-copy h2 { font-size:21px; }
    .ledger-command-meta span:nth-child(2) { display:none; }
    .ledger-metrics { grid-template-columns:1fr 1fr; }
    .ledger-panel-header { align-items:flex-start; }
    .ledger-text-action { min-height:36px; }
    .ledger-table-head { display:none; }
    .ledger-operation-row { grid-template-columns:90px 1fr; }
    .ledger-operation-row>span:nth-child(n+3) { display:none; }
    .ledger-roster-head { display:none; }
    .ledger-agent-row { grid-template-columns:1fr 82px; }
    .ledger-agent-provider,.ledger-agent-capability,.ledger-agent-access { display:none; }
}

@media (prefers-reduced-motion:reduce) {
    .overview-view *,
    .overview-view *::before,
    .overview-view *::after { transition-duration:.01ms!important; animation-duration:.01ms!important; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
