/* agentchattr — dark theme / design tokens */

:root {
    /* --- Surfaces --- */
    --bg: #0f0f17;
    --bg-header: #14141f;
    --bg-input: #1a1a2e;
    --bg-msg: #16161f;
    --bg-msg-hover: #1c1c2a;
    --bg-elevated: #1e1435;
    --bg-subtle: rgba(255, 255, 255, 0.04);
    --bg-overlay: rgba(0, 0, 0, 0.5);

    /* --- Borders --- */
    --border: #2a2a3e;
    --border-strong: #3a3a55;
    --border-subtle: rgba(255, 255, 255, 0.06);

    /* --- Text --- */
    --text: #b8b8c8;
    --text-dim: #6a6a80;
    --text-system: #555570;
    --text-on-accent: #fff;
    --text-muted: #cfc8ea;

    /* --- Semantic colors --- */
    --accent: #7c3aed;
    --accent-soft: rgba(124, 58, 237, 0.15);
    --accent-hover: rgba(124, 58, 237, 0.2);
    --user-color: #a78bfa;
    --system-color: #555570;

    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.2);
    --online: #4ade80;

    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.1);
    --error-color: #f87171;
    --error-soft: rgba(248, 113, 113, 0.15);

    --warning: #fbbf24;
    --pending: #da7756;
    --info: #60a5fa;

    /* --- Neutral tints (white alpha for dark theme) --- */
    --white-02: rgba(255, 255, 255, 0.02);
    --white-03: rgba(255, 255, 255, 0.03);
    --white-06: rgba(255, 255, 255, 0.06);
    --white-08: rgba(255, 255, 255, 0.08);
    --white-10: rgba(255, 255, 255, 0.10);
    --white-12: rgba(255, 255, 255, 0.12);
    --white-15: rgba(255, 255, 255, 0.15);

    /* --- Space --- */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 24px;

    /* --- Radius --- */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-full: 9999px;

    /* --- Typography --- */
    --fs-xs: 11px;
    --fs-sm: 12px;
    --fs-base: 14px;
    --fs-md: 13px;
    --fw-normal: 400;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;
    --lh-tight: 1.3;
    --lh-normal: 1.35;
    --lh-relaxed: 1.5;

    /* --- Motion --- */
    --duration-fast: 120ms;
    --duration-normal: 200ms;
    --duration-slow: 300ms;

    /* --- Shadows --- */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

    /* --- Sidebar (legacy tokens, kept for compat) --- */
    --sb-padding: 8px 16px;
    --sb-gap: 8px;
    --sb-card-radius: 6px;
    --sb-card-border-color: rgba(255, 255, 255, 0.03);
    --sb-card-border-width: 1px;
    --sb-title-fs: 13px;
    --sb-title-fw: 600;
    --sb-title-lh: 1.3;
    --sb-meta-fs: 12px;
    --sb-label-fs: 11px;
    --sb-meta-fw: 400;
    --sb-meta-lh: 1.35;
    --sb-ghost-opacity: 0.5;
    --sb-motion-fast: 160ms;
}

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

/* --- Font themes --- */

body {
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

body, body.font-sans {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
}

body.font-mono {
    font-family: 'Cascadia Code', 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

body.high-contrast {
    --text-dim: #9a9ab0;
    --text-system: #7a7a95;
    --text-muted: #ddd6f5;
    --border: #3a3a55;
    --border-subtle: rgba(255, 255, 255, 0.10);
    --bg-subtle: rgba(255, 255, 255, 0.06);
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* --- Header --- */

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-header);
    border-bottom: none;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    z-index: 2;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo {
    width: 24px;
    height: 24px;
    max-width: 24px;
    max-height: 24px;
    border-radius: 5px;
    object-fit: contain;
    flex-shrink: 0;
}

header h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    line-height: 1;
}

.discord-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px 3px 8px;
    margin-top: 3px;
    border-radius: var(--radius-xl);
    background: var(--white-08);
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.2s, transform 0.2s, background 0.15s, color 0.15s;
    pointer-events: none;
    white-space: nowrap;
}

.header-left:hover .discord-pill {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.discord-pill:hover {
    background: rgba(88, 101, 242, 0.25);
    color: #7289da;
}

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

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

#agent-status {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    max-width: 60vw;
    scrollbar-width: none;
}
#agent-status::-webkit-scrollbar { display: none; }

.status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-xl);
    background: var(--bg-subtle);
    border: 1px solid transparent;
    font-size: 12px;
    transition: background 0.2s, border-color 0.2s;
    cursor: pointer;
    flex-shrink: 0;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: #555;
    transition: background 0.3s;
}

.status-pill.available .status-dot { background: var(--online); }
.status-pill.offline .status-dot { background: #555; }

.status-pill.offline {
    opacity: 0.4;
}

.status-pill.pending {
    border-style: dashed;
    border-color: var(--agent-color, #888);
    opacity: 0.7;
    animation: pending-pulse 2s ease-in-out infinite;
}

.status-pill.pending .status-dot {
    background: var(--agent-color, #888);
    animation: pending-dot-blink 1.5s ease-in-out infinite;
}

@keyframes pending-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.85; }
}

@keyframes pending-dot-blink {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Working state — rotating border in agent color */
@property --border-angle {
    syntax: "<angle>";
    initial-value: 0deg;
    inherits: false;
}

.status-pill.working {
    position: relative;
    border-color: transparent;
}

.status-pill.working .status-dot { background: var(--online); }

.status-pill.working::before {
    content: '';
    position: absolute;
    inset: -1.5px;
    border-radius: inherit;
    padding: 1.5px;
    background: conic-gradient(
        from var(--border-angle),
        var(--agent-color, #4ade80),
        transparent 40%,
        transparent 60%,
        var(--agent-color, #4ade80)
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: spin-border 2s linear infinite;
}

@keyframes spin-border {
    to { --border-angle: 360deg; }
}

.settings-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-dim);
    padding: 5px 7px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: color 0.2s, border-color 0.2s;
}

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

.settings-btn.active {
    color: var(--text);
    border-color: var(--accent);
    background: rgba(124, 58, 237, 0.12);
}

/* --- Shared close / dismiss button --- */

/* Inline dismiss buttons (reply cancel, todo remove) */
.dismiss-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.dismiss-btn:hover { color: var(--text); }
.dismiss-btn.danger:hover { color: var(--error-color); }

/* --- Settings bar --- */

#settings-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
    overflow: hidden;
    max-height: 500px;
    opacity: 1;
    transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.25s ease;
}

#settings-bar.hidden {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-bottom: none;
    pointer-events: none;
}

.settings-field {
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-field label {
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
}

.settings-field input,
.settings-field select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 4px 8px;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    box-shadow: none;
}

.settings-field input { width: 120px; }
.settings-field input[type="number"] { width: 60px; }
.settings-field select { width: 130px; }

.settings-field input:focus,
.settings-field select:focus {
    border-color: var(--accent);
}

.settings-field input:disabled {
    opacity: 0.35;
    pointer-events: none;
}

/* --- Sound settings --- */

.settings-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    flex-shrink: 0;
}

#sound-settings {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.sound-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sound-label {
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
    min-width: 50px;
}

.sound-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 3px 6px;
    font-family: inherit;
    font-size: 12px;
    outline: none;
    box-shadow: none;
    width: 120px;
}

.sound-select:focus {
    border-color: var(--accent);
    box-shadow: none;
    outline: none;
}

.settings-spacer {
    flex: 1;
}

.settings-danger {
    background: transparent;
    color: var(--error-color);
    border: 1px solid var(--error-color);
    border-radius: var(--radius-sm);
    padding: 4px 14px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.settings-danger:hover {
    background: var(--error-soft);
}

/* Right-side pills in channel bar */
.channel-bar-right {
    position: absolute;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.channel-support {
    color: #f472b6;
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    padding: 3px 10px;
    border: 1px solid rgba(244, 114, 182, 0.35);
    border-radius: 10px;
    background: rgba(244, 114, 182, 0.06);
    transition: background 0.15s, box-shadow 0.15s;
}

.channel-support:hover {
    background: rgba(244, 114, 182, 0.14);
    box-shadow: 0 0 8px rgba(244, 114, 182, 0.15);
}

/* Update available pill */
.update-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--info);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    padding: 3px 10px;
    border: 1px solid color-mix(in srgb, var(--info) 35%, transparent);
    border-radius: 10px;
    background: color-mix(in srgb, var(--info) 6%, transparent);
    transition: background 0.15s, box-shadow 0.15s;
}

.update-pill:hover {
    background: color-mix(in srgb, var(--info) 14%, transparent);
    box-shadow: 0 0 8px color-mix(in srgb, var(--info) 15%, transparent);
}

.update-pill .update-dismiss {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border: none;
    background: none;
    color: inherit;
    opacity: 0.5;
    cursor: pointer;
    padding: 0;
    font-size: 13px;
    line-height: 1;
    transition: opacity 0.15s;
}
.update-pill.hidden { display: none; }

.update-pill .update-dismiss:hover {
    opacity: 1;
}

/* --- Content area (timeline + rules sidebar) --- */

#content-area {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* --- Timeline --- */

main#timeline {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    scroll-behavior: smooth;
    min-width: 0;
    height: 100%;
}

/* --- Loading indicator --- */

#loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 16px;
    color: var(--text-dim);
    font-size: 13px;
}

#loading-indicator.hidden { display: none; }

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

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

#messages {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.message {
    display: flex;
    align-items: flex-start;
    padding: 2px 10px;
    gap: 8px;
    line-height: 1.5;
    position: relative;
    max-width: 100%;
    contain: layout style;
}

.message.self {
    flex-direction: row-reverse;
}

/* --- Avatar --- */

.avatar-wrap {
    position: relative;
    width: 32px;
    flex-shrink: 0;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
    box-shadow: 0 0 8px color-mix(in srgb, var(--bubble-color, currentColor) 12%, transparent);
}

.avatar svg {
    width: 18px;
    height: 18px;
}

/* --- Hat overlay --- */

.hat-overlay {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 14px;
    pointer-events: auto;
    cursor: grab;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hat-overlay svg {
    width: 100%;
    height: 100%;
}

/* Hat drag ghost */
.hat-drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    cursor: grabbing;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

.hat-drag-ghost svg {
    width: 100%;
    height: 100%;
}

/* Trash can */
.hat-trash {
    position: absolute;
    left: -24px;
    top: 4px;
    width: 20px;
    height: 20px;
    color: var(--text-dim);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.15s;
    z-index: 2;
    cursor: default;
}

.hat-trash.visible {
    opacity: 1;
    pointer-events: auto;
    animation: trash-bounce-in 0.25s ease-out;
}

.hat-trash.hover {
    color: var(--error-color);
    transform: scale(1.2);
    filter: drop-shadow(0 0 6px rgba(248, 113, 113, 0.4));
}

.hat-trash.chomping {
    animation: trash-chomp 0.5s ease-out forwards;
}

@keyframes trash-bounce-in {
    0% { transform: scale(0.3); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes trash-chomp {
    0% { transform: scale(1.2); }
    15% { transform: scale(1.2) translateX(-2px); }
    30% { transform: scale(1.2) translateX(2px); }
    45% { transform: scale(1.2) translateX(-1px); }
    60% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(0.8); opacity: 0; }
}

/* --- Chat bubble --- */

.chat-bubble {
    background: color-mix(in srgb, var(--bubble-color, var(--text-dim)) 10%, var(--bg-msg));
    border: 1px solid color-mix(in srgb, var(--bubble-color, var(--text-dim)) 15%, transparent);
    border-radius: 16px;
    border-top-left-radius: 4px;
    padding: 8px 14px;
    max-width: 85%;
    min-width: 80px;
    overflow-wrap: break-word;
    position: relative;
}

.message.self .chat-bubble {
    border-top-left-radius: 16px;
    border-top-right-radius: 4px;
}

.bubble-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
}

.message.self .msg-sender {
    display: none;
}

.message:hover .chat-bubble {
    background: color-mix(in srgb, var(--bubble-color, var(--text-dim)) 15%, var(--bg-msg));
}

/* --- Bubble copy icon (top-right) --- */

.bubble-copy {
    position: absolute;
    top: 6px;
    right: 6px;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 3px;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
    line-height: 0;
}

.message:hover .bubble-copy { opacity: 0.5; }
.bubble-copy:hover { opacity: 1 !important; color: var(--text); background: var(--white-08); }
.bubble-copy.copied { opacity: 1 !important; color: var(--online); }

/* --- Message actions (reply + pin) --- */

.msg-actions {
    display: flex;
    flex-direction: column;
    align-self: center;
    opacity: 0;
    flex-shrink: 0;
}

.message:hover .msg-actions {
    opacity: 1;
}

/* --- Todo strip --- */

.todo-strip {
    width: 3px;
    flex-shrink: 0;
    border-radius: 2px;
    align-self: stretch;
    background: transparent;
    transition: background 0.1s;
}

.message.msg-todo-todo .todo-strip {
    background: var(--accent);
}

.message.msg-todo-done .todo-strip {
    background: var(--online);
}

.message.msg-todo-done {
    opacity: 0.6;
}

/* Hover hint — pin/reply buttons */
.todo-hint {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    color: var(--text-dim);
    user-select: none;
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.todo-hint:hover {
    color: var(--accent);
}

.message.msg-todo-todo .todo-hint {
    color: var(--online);
}

.message.msg-todo-done .todo-hint {
    color: var(--error-color);
}

/* --- Delete button (hover action) --- */

.delete-btn {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    color: var(--text-dim);
    user-select: none;
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.delete-btn:hover {
    color: var(--error-color);
}

/* --- Delete mode --- */

#messages .message:not(.join-msg):not(.system-msg):not(.summary-msg) > :not(.delete-radio) {
    transition: transform 0.2s ease;
}

#messages.delete-mode .message:not(.join-msg):not(.system-msg):not(.summary-msg) > :not(.delete-radio),
#messages.delete-mode .message.session-banner > :not(.delete-radio),
#messages.delete-mode .message.session-draft-card > :not(.delete-radio),
#messages.delete-mode .message.job-breadcrumb > :not(.delete-radio),
#messages.delete-mode .job-group > :not(.delete-radio) {
    transform: translateX(30px);
}

#messages.delete-mode .msg-actions .delete-btn {
    display: none;
}

@keyframes radio-in {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

.delete-radio {
    position: absolute;
    left: 10px;
    top: 7px;
    width: 22px;
    height: 22px;
    border-radius: var(--radius-full);
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
    z-index: 5;
    animation: radio-in 0.15s ease-out;
}

.delete-radio:hover {
    border-color: var(--error-color);
}

.delete-radio.selected {
    border-color: var(--error-color);
    background: var(--error-color);
    box-shadow: inset 0 0 0 3px var(--bg);
}

/* --- Delete confirmation bar --- */

#delete-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 10px 16px;
    background: var(--error-soft);
    border: none;
    z-index: 5;
    overflow: hidden;
    max-height: 60px;
    opacity: 1;
    transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.25s ease;
}

#delete-bar.hidden {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    pointer-events: none;
}

.delete-bar-count {
    font-size: 13px;
    color: var(--text);
    min-width: 100px;
    text-align: center;
}

.delete-bar-cancel {
    background: transparent;
    color: var(--text);
    border: none;
    border-radius: var(--radius-md);
    padding: 8px 16px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.delete-bar-cancel:hover {
    background: var(--white-08);
}

.delete-bar-confirm {
    background: var(--error-color);
    color: var(--text-on-accent);
    border: none;
    border-radius: var(--radius-md);
    padding: 8px 16px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

.delete-bar-confirm:hover { opacity: 0.85; }
.delete-bar-confirm:disabled { opacity: 0.4; cursor: default; }

/* --- Reply quotes --- */

.reply-quote {
    font-size: 12px;
    color: var(--text-dim);
    padding: 3px 0 3px 8px;
    margin-bottom: 4px;
    border-left: 2px solid var(--white-15);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 100px);
}

.reply-quote:hover {
    color: var(--text);
    border-left-color: var(--accent);
}

.reply-sender { font-weight: 600; }

/* --- Reply button --- */

.reply-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    padding: 2px 6px;
    white-space: nowrap;
}

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

/* --- Reply preview bar (above input) --- */

#reply-preview {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    margin-bottom: 6px;
    background: var(--bg-subtle);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-preview-label {
    color: var(--accent);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.reply-cancel { margin-left: auto; }

/* --- Message entrance animation --- */

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

.message {
    animation: msg-in 0.2s ease-out both;
}

/* --- Message highlight flash --- */

.message.highlight .chat-bubble {
    box-shadow: 0 0 0 2px var(--accent);
    transition: box-shadow 1.5s ease-out;
}

/* --- Clickable file paths --- */

.file-link {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dotted var(--accent);
    cursor: pointer;
}

.file-link:hover {
    color: var(--user-color);
    border-bottom-style: solid;
}

/* --- Todos panel --- */

#pins-panel {
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    max-height: 300px;
    overflow-y: auto;
    flex-shrink: 0;
    opacity: 1;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}

#pins-panel.hidden {
    max-height: 0;
    opacity: 0;
    border-bottom: none;
    pointer-events: none;
    overflow: hidden;
}

.pins-header {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
}


.todo-item {
    padding: 4px 16px;
    font-size: 13px;
    line-height: 1.5;
    display: flex;
    align-items: baseline;
    gap: 6px;
    border-bottom: 1px solid var(--sb-card-border-color);
    cursor: pointer;
}

.todo-item:hover { background: var(--bg-msg-hover); }
.todo-item.todo-done { opacity: 0.5; }
.todo-item.todo-done .msg-text { text-decoration: line-through; }

.todo-item .msg-sender { font-weight: 600; font-size: 12px; }
.todo-item .msg-text { flex: 1; }

.todo-check {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--accent);
    padding: 0;
    flex-shrink: 0;
}

.todo-check.done { color: var(--online); }
.todo-check:hover { opacity: 0.7; }


.pins-empty {
    padding: 12px 16px;
    color: var(--text-dim);
    font-size: 13px;
    font-style: italic;
}

/* --- Channel bar --- */

#channel-bar {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 16px;
    background: var(--bg-header);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    min-height: 36px;
    z-index: 1;
}

#channel-tabs {
    grid-column: 2;
    display: flex;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
    align-items: center;
}

#channel-tabs::-webkit-scrollbar { display: none; }

.channel-tab {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    position: relative;
    max-width: 160px;
}

.channel-tab.active {
    max-width: none;
}

.channel-tab-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-tab:hover {
    background: var(--white-06);
    color: var(--text);
}

.channel-tab.active {
    background: color-mix(in srgb, var(--user-color) 12%, var(--bg-header));
    color: var(--user-color);
    font-weight: 600;
}

.channel-tab.active:hover {
    background: color-mix(in srgb, var(--user-color) 18%, var(--bg-header));
}

.channel-unread-dot {
    background: var(--pending);
    color: var(--text-on-accent);
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Edit/delete icons on tab hover — animated slide-in (only for active tab) */
.channel-tab-actions {
    display: flex;
    align-items: center;
    gap: 1px;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-width 0.2s ease, opacity 0.2s ease, margin-left 0.2s ease;
    margin-left: 0;
}
.channel-tab.editing .channel-tab-actions {
    max-width: 40px;
    opacity: 1;
    margin-left: 4px;
}

.channel-tab.confirm-delete .channel-tab-label {
    color: var(--error-color);
}

.channel-delete-confirm {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 4px;
}

.channel-delete-confirm button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: background 0.15s;
}

.channel-delete-confirm button:hover { background: var(--white-08); }
.ch-confirm-yes { color: var(--error-color); }
.ch-confirm-no { color: var(--text-dim); }

.channel-tab-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: var(--text-dim);
    border-radius: 3px;
    display: flex;
    align-items: center;
}
.channel-tab-actions button:hover { background: var(--white-08); }
.channel-tab-actions .ch-edit-btn:hover { color: var(--text); }
.channel-tab-actions .ch-delete-btn:hover { color: var(--error-color); }

/* Add button — sits in the 3rd grid column to the right of tabs */
.channel-add {
    grid-column: 3;
    justify-self: start;
    margin-left: 8px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-md);
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    flex-shrink: 0;
}

#channel-bar:hover .channel-add { opacity: 1; }
.channel-add:hover { color: var(--accent); }

.channel-add.disabled {
    opacity: 0 !important;
    pointer-events: none;
}

/* Inline channel input (replaces the + button when creating) */
.channel-inline-create {
    display: flex;
    align-items: center;
    gap: 4px;
    animation: fadeIn 0.1s ease;
}

.channel-inline-create .channel-input-prefix {
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
    user-select: none;
}

.channel-inline-create input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    padding: 3px 8px;
    width: 120px;
    outline: none;
}

.channel-inline-create input:focus { border-color: var(--accent); }

.channel-inline-create button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 4px;
    line-height: 1;
    border-radius: var(--radius-sm);
}

.channel-inline-create .confirm-btn { color: var(--accent); }
.channel-inline-create .confirm-btn:hover { background: var(--accent-soft); }
.channel-inline-create .cancel-btn { color: var(--text-dim); }
.channel-inline-create .cancel-btn:hover { background: var(--white-06); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Hashtag styling in messages */
.msg-hashtag {
    color: var(--accent);
    font-weight: 500;
    background: rgba(124, 58, 237, 0.1);
    padding: 1px 4px;
    border-radius: 3px;
    cursor: default;
}

/* --- Channel context menu (right-click for rename) --- */

.channel-ctx-menu {
    position: fixed;
    background: var(--bg-header);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 4px;
    z-index: 100;
    min-width: 120px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.channel-ctx-menu button {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    padding: 6px 12px;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.channel-ctx-menu button:hover { background: var(--white-06); }
.channel-ctx-menu button.danger { color: var(--error-color); }
.channel-ctx-menu button.danger:hover { background: var(--error-soft); }

/* --- Sidebar panels (rules + jobs shared) --- */

#rules-panel {
    --panel-w: 320px;
    width: var(--panel-w);
    min-width: 220px;
    max-width: 50vw;
    flex-shrink: 0;
    background: var(--bg-header);
    border-left: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-right: 0;
    transition: margin-right 0.25s ease, opacity 0.2s ease;
    position: relative;
}

#rules-panel.hidden {
    margin-right: calc(-1 * var(--panel-w));
    opacity: 0;
    pointer-events: none;
}

/* Full-height drag grip on left edge */
.rules-grip,
.jobs-grip {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border);
    transition: background 0.15s;
}

.rules-grip:hover,
.rules-grip.dragging,
.jobs-grip:hover,
.jobs-grip.dragging {
    background: var(--accent);
}

.rules-grip::after,
.jobs-grip::after {
    content: '';
    width: 2px;
    height: 32px;
    border-left: 1px solid var(--white-15);
    border-right: 1px solid var(--white-15);
}

.rules-header,
.jobs-header {
    display: flex;
    align-items: center;
    padding: var(--sb-padding);
    font-size: var(--sb-title-fs);
    font-weight: var(--sb-title-fw);
    line-height: var(--sb-title-lh);
    color: var(--text-dim);
    border-bottom: var(--sb-card-border-width) solid var(--border);
    flex-shrink: 0;
    gap: var(--sb-gap);
}

.rules-counter {
    font-size: var(--sb-label-fs);
    font-weight: 400;
    color: var(--text-dim);
    opacity: 0.7;
}

.rules-remind-btn {
    margin-left: auto;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--accent);
    background: rgba(124, 58, 237, 0.1);
    color: var(--accent);
    transition: background 0.15s, color 0.15s;
}

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

.rules-remind-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.rules-soft-warning {
    padding: 4px var(--sb-padding);
    font-size: var(--sb-meta-fs);
    color: var(--text-dim);
    opacity: 0.6;
    font-style: italic;
    text-align: center;
}

#rules-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.rules-empty,
.jobs-empty {
    padding: 24px 16px;
    color: var(--text-dim);
    font-size: var(--sb-meta-fs);
    line-height: var(--sb-meta-lh);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

/* Sidebar group headers (shared by rules + jobs panels) */
.rules-group-header,
.jobs-group-header {
    padding: var(--sb-padding);
    padding-bottom: 4px;
    font-size: var(--sb-label-fs);
    font-weight: var(--sb-title-fw);
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: var(--sb-card-border-width) solid var(--border);
    margin-bottom: 2px;
}

.rules-group-header.draft,
.jobs-group-header.open {
    color: var(--text-dim);
    border-bottom-color: var(--sb-card-border-color);
}

.rules-group-header.active,
.jobs-group-header.done {
    color: var(--success);
    border-bottom-color: var(--success-soft);
}

.rules-group-header.archived,
.jobs-group-header.archived {
    color: rgba(239, 68, 68, 0.5);
    border-bottom-color: var(--danger-soft);
}

/* Collapsible group behavior (rules: .archived, jobs: .collapsible) */
.rules-group-header.archived,
.jobs-group-header.collapsible {
    cursor: pointer;
    user-select: none;
    transition: color var(--sb-motion-fast);
}

.rules-group-header.archived:hover,
.jobs-group-header.collapsible:hover { color: var(--text); }

.rules-group-header.archived::before,
.jobs-group-header.collapsible::before {
    content: '▾ ';
    font-size: 9px;
}

.rules-group-header.archived.collapsed::before,
.jobs-group-header.collapsed::before {
    content: '▸ ';
}

.rules-group-header.empty-group,
.jobs-group-header.empty-group { opacity: 0.35; }

.rules-group-header.drop-target,
.jobs-group-header.drop-target {
    background: rgba(109, 138, 235, 0.12);
    border-bottom-color: var(--accent);
    color: var(--accent) !important;
    opacity: 1;
}

.rules-group-items,
.jobs-group-items {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.25s ease;
}
.rules-group-items.collapsed,
.jobs-group-items.collapsed {
    grid-template-rows: 0fr;
}
.rules-group-items-inner,
.jobs-group-items-inner {
    overflow: hidden;
    min-height: 0;
}

.rules-group-items .rule-card:last-child,
.jobs-group-items .job-card:last-child { border-bottom: none; }

.rules-centered-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 16px;
    font-size: var(--sb-meta-fs);
    color: var(--text-dim);
    opacity: 0.4;
    text-align: center;
}

/* Rule card — mirrors .job-card */
.rule-card {
    padding: var(--sb-padding);
    border-bottom: var(--sb-card-border-width) solid var(--sb-card-border-color);
    transition: background var(--sb-motion-fast);
    min-width: 0;
    cursor: pointer;
}

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

.rule-card.dragging {
    opacity: 0.35;
    transform: scale(0.97);
}

.rule-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rule-status-dot,
.job-status-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.rule-status-dot.draft,
.job-status-dot.open { background: var(--text-dim); }
.rule-status-dot.active,
.job-status-dot.done { background: var(--success); }
.rule-status-dot.archived,
.job-status-dot.archived { background: var(--text-dim); opacity: 0.4; }

.rule-text {
    font-size: var(--sb-title-fs);
    color: var(--text);
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: var(--sb-title-lh);
    min-width: 0;
    flex: 1;
}

.rule-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.1s;
    flex-shrink: 0;
}

.rule-card:hover .rule-actions { opacity: 0.6; }

.rule-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: all 0.15s;
}

.rule-actions button:hover {
    background: var(--white-06);
}

.rule-actions button.delete-btn:hover { opacity: 1; color: var(--danger); background: var(--danger-soft); }

.rule-reason {
    font-size: var(--sb-meta-fs);
    color: var(--text-dim);
    font-style: italic;
    overflow-wrap: break-word;
    margin-top: 2px;
    padding-left: 12px;
}


/* Inline edit fields */

.rule-card.editing .rule-text,
.rule-card.editing .rule-reason {
    display: none;
}

.rule-edit-field {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 6px 8px;
    font-family: inherit;
    font-size: 13px;
    width: 100%;
    resize: none;
    outline: none;
    margin-bottom: 4px;
    overflow: hidden;
    min-height: 32px;
}

.rule-edit-field:focus {
    border-color: var(--accent);
}

.rule-edit-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.rule-edit-actions button {
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: none;
}

.rule-edit-actions .save-btn {
    background: var(--accent);
    color: var(--text-on-accent);
}

.rule-edit-actions .cancel-btn {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.rule-edit-actions .cancel-btn:hover {
    color: var(--text);
}

.rule-edit-actions .delete-inline-btn {
    background: transparent;
    color: var(--text-dim);
    opacity: 0.5;
}

.rule-edit-actions .delete-inline-btn:hover {
    color: var(--danger);
    opacity: 1;
}


/* --- Header button badges --- */

.rules-badge,
.jobs-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--pending);
    color: var(--text-on-accent);
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}

.rules-badge.hidden,
.jobs-badge.hidden { display: none; }

#rules-toggle,
#jobs-toggle {
    position: relative;
}

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

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

.msg-text {
    word-break: break-word;
}

.msg-text .mention {
    font-weight: 600;
    /* color set inline from agent config */
    background: color-mix(in srgb, currentColor 10%, transparent);
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid color-mix(in srgb, currentColor 15%, transparent);
}

/* --- Markdown inside messages --- */

.msg-text p { margin: 0.3em 0; }
.msg-text p:first-child { margin-top: 0; }
.msg-text p:last-child { margin-bottom: 0; }

.msg-text strong { font-weight: 700; color: #f0f0f5; }
.msg-text em { font-style: italic; }

.msg-text code {
    background: var(--white-08);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.9em;
}

.msg-text pre {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    margin: 6px 0;
    overflow-x: hidden;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.msg-text pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: 0.85em;
    display: block;
    white-space: inherit;
    overflow-wrap: inherit;
    word-break: inherit;
}

.msg-text ul, .msg-text ol {
    margin: 4px 0;
    padding-left: 20px;
}

.msg-text li { margin: 2px 0; }

.msg-text blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 10px;
    margin: 4px 0;
    color: var(--text-dim);
}

.msg-text h1, .msg-text h2, .msg-text h3,
.msg-text h4, .msg-text h5, .msg-text h6 {
    margin: 6px 0 2px;
    font-size: 1em;
    font-weight: 700;
    color: #f0f0f5;
}

.msg-text h1 { font-size: 1.15em; }
.msg-text h2 { font-size: 1.1em; }

.msg-text hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 6px 0;
}

.msg-text a {
    color: var(--accent);
    text-decoration: none;
}

.msg-text a:hover { text-decoration: underline; }

.msg-text table {
    border-collapse: collapse;
    margin: 6px 0;
    font-size: 0.9em;
}

.msg-text th, .msg-text td {
    border: 1px solid var(--border);
    padding: 3px 8px;
}

.msg-text th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
}

/* --- Join/leave messages --- */

.message.join-msg {
    justify-content: center;
    gap: 6px;
    padding: 2px 10px;
    opacity: 0.5;
}

.join-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    align-self: center;
}

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

.message.system-msg {
    color: var(--text-system);
    font-style: italic;
    font-size: 12px;
    justify-content: center;
    overflow-wrap: break-word;
    text-align: center;
}

/* Proposal cards */
.message.proposal-msg {
    justify-content: center;
    align-items: center;
    padding: 8px 16px;
}

.message.proposal-msg .delete-radio,
.message.self .delete-radio {
    top: 50%;
    transform: translateY(-50%);
    animation: radio-in-centered 0.2s ease-out both;
}

@keyframes radio-in-centered {
    from { opacity: 0; transform: translateY(-50%) scale(0.5); }
    to { opacity: 1; transform: translateY(-50%) scale(1); }
}

.proposal-card {
    max-width: 690px;
    width: 100%;
    background: rgba(124, 58, 237, 0.06);
    border: 1px solid rgba(124, 58, 237, 0.15);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
}

.proposal-card.proposal-resolved {
    opacity: 0.5;
}

.proposal-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.proposal-pill {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
}

.proposal-author {
    font-size: 12px;
    font-weight: 500;
}

.proposal-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    line-height: 1.3;
}

.proposal-body {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.5;
    margin-bottom: 10px;
}

.proposal-body p { margin: 0 0 6px; }
.proposal-body p:last-child { margin-bottom: 0; }

.proposal-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.proposal-accept {
    background: var(--accent);
    color: var(--text-on-accent);
    border: none;
    padding: 5px 16px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.15s;
}
.proposal-accept:hover { opacity: 0.85; }

.proposal-request-changes {
    background: none;
    color: var(--text-dim);
    border: 1px solid var(--accent);
    padding: 5px 16px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.proposal-request-changes:hover { color: var(--accent); background: rgba(124, 58, 237, 0.08); }

.proposal-dismiss {
    background: none;
    color: var(--text-dim);
    border: 1px solid var(--border);
    padding: 5px 16px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.proposal-dismiss:hover { color: var(--text); border-color: var(--text-dim); }

.proposal-status-resolved {
    font-size: 11px;
    color: var(--text-dim);
    font-style: italic;
    margin-top: 6px;
}

/* rule-proposal-card inherits .proposal-card purple styling */

.rule-proposal-text {
    font-size: 14px;
    color: var(--text);
    line-height: 1.4;
    margin-bottom: 2px;
}

/* Rules trash zone — reuses Jobs archive-trash-zone styles */

.message.summary-msg {
    justify-content: center;
    padding: 8px 16px;
}

.summary-card {
    max-width: 690px;
    width: 100%;
    background: var(--white-03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 10px 14px;
    text-align: center;
}

.summary-pill {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    background: var(--white-06);
    padding: 2px 8px;
    border-radius: var(--radius-lg);
    margin-right: 6px;
}

.summary-author {
    font-size: 11px;
    font-weight: 500;
}

.summary-text {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.5;
    margin-top: 6px;
    white-space: pre-wrap;
    text-align: left;
}

.message.error-msg .chat-bubble {
    border-color: var(--error-color);
    color: var(--error-color);
}

.msg-attachments {
    margin-top: 6px;
}

.msg-attachments img {
    max-width: 300px;
    max-height: 200px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.msg-attachments img:hover {
    border-color: var(--accent);
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

/* --- Typing indicator --- */

#typing-indicator {
    padding: 6px 10px;
    color: var(--text-dim);
    font-size: 12px;
    font-style: italic;
}

#typing-indicator.hidden { display: none; }

.typing-name { font-weight: 600; }

/* --- Scroll anchor --- */

#scroll-anchor {
    position: fixed;
    bottom: 130px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: var(--text-on-accent);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 60;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: opacity 0.2s, bottom 0.2s ease-out;
}

#scroll-anchor:hover {
    transform: translateX(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
#scroll-anchor.hidden { display: none; }

.unread-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--error-color);
    color: var(--text-on-accent);
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* --- Date dividers --- */

.date-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0 8px;
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-indent: 0.06em;
}

.date-divider::before,
.date-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* --- Code copy button --- */

.code-copy-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--white-08);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-family: inherit;
    font-size: 11px;
    padding: 2px 8px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}

pre:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover { color: var(--text); background: var(--white-12); }

/* --- Image modal --- */

#image-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    cursor: zoom-out;
}

#image-modal.hidden { display: none; }

#image-modal img {
    max-width: 80vw;
    max-height: 85vh;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    cursor: default;
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--white-10);
    border: none;
    color: var(--text-on-accent);
    font-size: 48px;
    width: 56px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: var(--radius-lg);
    transition: background 0.15s;
    user-select: none;
}

.modal-nav:hover { background: rgba(255, 255, 255, 0.2); }
.modal-prev { left: 16px; }
.modal-next { right: 16px; }

.modal-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
    font-weight: 600;
}

/* --- Agent naming lightbox --- */

.agent-name-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.15s ease-out;
}

.agent-name-modal.hidden { display: none; }

.agent-name-dialog {
    background: var(--bg-header);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 28px 32px;
    min-width: 320px;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: modal-slide-in 0.2s ease-out;
}

@keyframes modal-slide-in {
    from { opacity: 0; transform: translateY(-12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.agent-name-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 8px;
}

.agent-name-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.agent-name-avatar svg {
    width: 22px;
    height: 22px;
}

.agent-name-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.agent-name-subtitle {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 18px;
}

.agent-name-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.agent-name-input:focus {
    border-color: var(--agent-color, var(--accent));
}

.agent-name-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.agent-name-actions button {
    padding: 8px 18px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.15s, opacity 0.15s;
    font-family: inherit;
}

.agent-name-cancel {
    background: var(--white-06);
    color: var(--text-dim);
}

.agent-name-cancel:hover {
    background: var(--white-10);
    color: var(--text);
}

.agent-name-confirm {
    background: var(--agent-color, var(--accent));
    color: var(--text-on-accent);
}

.agent-name-confirm:hover {
    opacity: 0.85;
}

/* --- Agent Roles --- */

.agent-role-section {
    margin-top: 14px;
}

.agent-role-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.agent-role-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.role-preset-chip {
    padding: 4px 10px;
    border-radius: var(--radius-xl);
    font-size: 12px;
    background: var(--white-06);
    color: var(--text-dim);
    border: 1px solid var(--white-08);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.role-preset-chip:hover {
    background: var(--white-10);
    color: var(--text);
}

.role-preset-chip.active {
    background: var(--agent-color, var(--accent));
    color: var(--text-on-accent);
    border-color: transparent;
}

.agent-role-input {
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--white-10);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
    font-family: inherit;
}

.agent-role-input:focus {
    border-color: var(--agent-color, var(--accent));
}

.role-tag {
    margin-left: 4px;
    font-size: 11px;
    opacity: 0.7;
}

/* --- Bubble role pill (top-right of message, left of copy) --- */

.bubble-role {
    position: relative;
    background: none;
    border: none;
    padding: 0;
    border-radius: var(--radius-md);
    font-size: 11px;
    color: var(--text-dim);
    cursor: pointer;
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    order: 1;
    transition: opacity 0.15s, background 0.15s, max-width 0.2s ease, padding 0.2s ease;
    line-height: 1;
}

.bubble-role.has-role {
    opacity: 0.7;
    max-width: 120px;
    padding: 1px 6px;
    overflow: visible;
    order: 0;
    background: color-mix(in srgb, var(--bubble-color, var(--text-dim)) 15%, transparent);
    color: var(--bubble-color, var(--text-dim));
}

.message:hover .bubble-role { opacity: 0.4; max-width: 120px; padding: 1px 6px; color: var(--bubble-color, var(--text-dim)); }
.message:hover .bubble-role.has-role { opacity: 0.7; }
.bubble-role:hover { opacity: 1 !important; background: color-mix(in srgb, var(--bubble-color, var(--text-dim)) 25%, transparent); }

/* --- Bubble role picker popup --- */

.bubble-role-picker {
    position: absolute;
    background: var(--bg-header);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    z-index: 100;
    max-width: 280px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    animation: picker-in 0.1s ease-out;
}

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

.bubble-role-picker .role-preset-chip {
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 10px;
}

.bubble-role-custom {
    width: 100%;
    margin-top: 2px;
}

.bubble-role-input {
    width: 100%;
    padding: 4px 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--white-10);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text);
    font-size: 11px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.bubble-role-input:focus {
    border-color: var(--accent);
}

.bubble-role-input::placeholder {
    color: var(--text-dim);
}

/* --- Slash command hint --- */

#input.slash-hint-active::placeholder {
    color: var(--accent);
    opacity: 0.7;
}

/* --- Footer / Input --- */

footer {
    position: relative;
    padding: 12px 16px;
    background: var(--bg-header);
    border-top: none;
    box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    z-index: 2;
}

/* --- Mention toggles --- */

#mention-toggles {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
}
#mention-toggles::-webkit-scrollbar { display: none; }

#mention-toggles:empty { display: none; }

.mention-toggle {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text-dim);
    padding: 3px 12px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.mention-toggle:hover {
    border-color: var(--agent-color, var(--accent));
    color: var(--agent-color, var(--accent));
}

.mention-toggle.active {
    background: color-mix(in srgb, var(--agent-color, var(--accent)) 20%, transparent);
    border-color: var(--agent-color, var(--accent));
    color: var(--agent-color, var(--accent));
}

#attachments {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 0;
}

#attachments:empty { display: none; }

#attachments .attachment-preview {
    position: relative;
    display: inline-block;
}

#attachments .attachment-preview img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

#attachments .attachment-preview .remove-btn {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    background: var(--error-color);
    color: var(--text-on-accent);
    border: none;
    border-radius: var(--radius-full);
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

#attachments:not(:empty) {
    margin-bottom: 8px;
}

#input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.sender-label {
    color: var(--user-color);
    font-weight: 600;
    font-size: 13px;
    padding: 10px 0;
    white-space: nowrap;
    flex-shrink: 0;
}

#input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text);
    padding: 10px 14px;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    outline: none;
    min-height: 40px;
    max-height: 120px;
    overflow-y: auto;
    scrollbar-width: none;
    transition: border-color 0.2s;
}
#input::-webkit-scrollbar { display: none; }

#input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

#input::placeholder {
    color: var(--text-dim);
}

#mic {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-dim);
    padding: 0 10px;
    min-height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

#mic:hover {
    color: var(--text);
    border-color: var(--accent);
}

#mic.recording {
    color: var(--error-color);
    border-color: var(--error-color);
    background: rgba(248, 113, 113, 0.1);
    animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(248, 113, 113, 0); }
}

#send {
    background: var(--accent);
    color: var(--text-on-accent);
    border: none;
    border-radius: var(--radius-lg);
    padding: 0 20px;
    min-height: 40px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

/* Split send + clock button */
.send-group {
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
}

.send-group #send {
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    padding-right: 14px;
}

.send-clock {
    background: var(--accent);
    color: var(--text-on-accent);
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0 9px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.send-clock:hover { background: color-mix(in srgb, var(--accent) 80%, white); }

#send:hover { opacity: 0.85; }
#send:active { opacity: 0.7; }

.send-group.inactive #send,
.send-group.inactive .send-clock {
    background: color-mix(in srgb, var(--accent) 35%, var(--bg-header));
    color: color-mix(in srgb, var(--text-on-accent) 40%, transparent);
    cursor: default;
}
.send-group.inactive #send:hover { opacity: 1; }
.send-group.inactive .send-clock:hover {
    background: color-mix(in srgb, var(--accent) 35%, var(--bg-header));
}

/* Schedule popover */
.schedule-popover {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 16px;
    background: var(--bg-header);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
    width: 300px;
    z-index: 30;
    animation: picker-in 0.15s ease-out;
}
.schedule-popover.hidden { display: none; }

.sched-pop-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.sched-pop-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.15s;
}
.sched-pop-close:hover { color: var(--text); }

.sched-pop-body {
    padding: 8px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sched-pop-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sched-pop-label {
    font-size: 13px;
    color: var(--text-dim);
    min-width: 42px;
    flex-shrink: 0;
}

.sched-pop-select {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    padding: 7px 10px;
    outline: none;
    min-width: 0;
}
.sched-pop-select:focus { border-color: var(--accent); }

.sched-pop-select-sm { flex: 0 1 auto; min-width: 0; width: auto; }
.sched-time-colon { color: var(--text-dim); font-size: 14px; font-weight: 600; }
.sched-time-row { gap: 4px; }

.sched-pop-num {
    width: 56px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    padding: 7px 4px 7px 10px;
    outline: none;
    text-align: center;
    -moz-appearance: textfield;
}
.sched-pop-num:focus { border-color: var(--accent); }

/* Custom spinner buttons */
.sched-pop-num::-webkit-inner-spin-button,
.sched-pop-num::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.sched-num-wrap {
    display: flex;
    align-items: stretch;
    position: relative;
}
.sched-num-wrap .sched-pop-num {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    border-right: none;
    width: 46px;
}
.sched-num-btns {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    overflow: hidden;
    flex-shrink: 0;
}
.sched-num-btns button {
    background: var(--bg-input);
    border: none;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-dim);
    cursor: pointer;
    padding: 0;
    width: 20px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    line-height: 1;
    transition: background 0.1s, color 0.1s;
}
.sched-num-btns button:last-child { border-bottom: none; }
.sched-num-btns button:hover { background: var(--accent-hover); color: var(--accent); }

.sched-pop-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}

/* Custom checkbox */
.sched-pop-check input {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border-strong);
    border-radius: 4px;
    background: var(--bg-input);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s;
}
.sched-pop-check input:checked {
    background: var(--accent);
    border-color: var(--accent);
}
.sched-pop-check input:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.sched-pop-check input:hover { border-color: var(--accent); }

/* Dim "When" row when recurring is active */
.sched-dimmed {
    opacity: 0.3;
    pointer-events: none;
    transition: opacity 0.2s;
}

.sched-recurring-fields.hidden { display: none; }

.sched-pop-error {
    font-size: 11px;
    color: var(--warning);
    padding: 0 16px 4px;
}
.sched-pop-error.hidden { display: none; }

.sched-pop-submit:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.sched-pop-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 8px 16px 14px;
    border-top: 1px solid var(--border-subtle);
}

.sched-pop-cancel {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 7px 16px;
    cursor: pointer;
    transition: background 0.15s;
}
.sched-pop-cancel:hover { background: var(--white-06); }

.sched-pop-submit {
    background: var(--accent);
    color: var(--text-on-accent);
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 20px;
    cursor: pointer;
    transition: opacity 0.15s;
}
.sched-pop-submit:hover { opacity: 0.85; }

.input-hint {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 6px;
}

/* --- Schedule strip (composer-adjacent) --- */

#schedules-bar {
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    overflow: hidden;
    animation: schedulesFadeIn 0.25s ease;
}
#schedules-bar.hidden { display: none; }

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

.schedules-bar-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    color: var(--text-dim);
    transition: color 0.15s;
}
.schedules-bar-summary:hover { color: var(--text); }

.schedules-icon { flex-shrink: 0; opacity: 0.7; }
.schedules-count { font-weight: 500; color: var(--text); font-size: 12px; }
.schedules-next { font-size: 11px; opacity: 0.7; }
.schedules-see-all {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    white-space: nowrap;
}
.schedules-see-all:hover { text-decoration: underline; }

.schedules-bar-list {
    border-top: 1px solid var(--border);
    max-height: 200px;
    overflow-y: auto;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}
.schedules-bar-list.hidden {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    border-top: none;
}

.schedule-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    font-size: 12px;
    border-bottom: 1px solid var(--border-subtle);
}
.schedule-row:last-child { border-bottom: none; }

.schedule-targets {
    font-weight: 600;
    color: var(--accent);
    flex-shrink: 0;
}
.schedule-prompt {
    flex: 1;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.schedule-interval {
    flex-shrink: 0;
    color: var(--text-dim);
    font-size: 11px;
}
.schedule-toggle {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 13px;
    color: var(--text-muted);
    opacity: 0.6;
    transition: opacity 0.15s, color 0.15s;
}
.schedule-toggle:hover { opacity: 1; }
.schedule-row.paused .schedule-toggle { color: var(--warning); opacity: 1; }
.schedule-delete {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    opacity: 0.5;
    transition: opacity 0.15s, color 0.15s;
}
.schedule-delete:hover { opacity: 1; color: var(--danger); }

.schedule-toggle-inline,
.schedule-delete-inline {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    opacity: 0.5;
    transition: opacity 0.15s, color 0.15s;
}
.schedule-toggle-inline { margin-left: auto; }
.schedule-delete-inline { margin-left: 4px; }
.schedule-toggle-inline:hover,
.schedule-delete-inline:hover { opacity: 1; }
.schedule-toggle-inline.paused { color: var(--warning); opacity: 1; }
.schedule-delete-inline:hover { color: var(--danger); }

.schedule-row.paused .schedule-targets,
.schedule-row.paused .schedule-prompt,
.schedule-row.paused .schedule-interval {
    opacity: 0.4;
}

/* Green flash on schedule creation */
#schedules-bar {
    transition: background 0.3s ease, border-color 0.3s ease;
}
#schedules-bar.sched-flash {
    background: color-mix(in srgb, var(--success) 12%, var(--bg-subtle));
    border-color: color-mix(in srgb, var(--success) 30%, var(--border));
}

/* --- Slash command menu --- */

#slash-menu {
    position: absolute;
    bottom: 100%;
    left: 16px;
    right: 16px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg-header);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.4);
    margin-bottom: 8px;
    z-index: 20;
}

#slash-menu.hidden { display: none; }

.slash-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.1s;
}

.slash-item:hover,
.slash-item.active {
    background: var(--accent-hover);
}

.slash-cmd {
    font-weight: 600;
    color: var(--accent);
    font-size: 13px;
    white-space: nowrap;
}

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

/* --- Mention autocomplete menu --- */

#mention-menu {
    position: absolute;
    bottom: 100%;
    left: 16px;
    right: 16px;
    max-height: 260px;
    overflow-y: auto;
    background: var(--bg-header);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.4);
    margin-bottom: 8px;
    z-index: 21;
}

#mention-menu.hidden { display: none; }

.mention-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.1s;
}

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

.mention-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

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

/* --- Dropzone --- */

#dropzone {
    position: fixed;
    inset: 0;
    background: var(--accent-soft);
    border: 3px dashed var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#dropzone.hidden { display: none; }

.dropzone-inner {
    background: var(--bg-header);
    padding: 24px 48px;
    border-radius: var(--radius-xl);
    font-size: 18px;
    font-weight: 600;
    color: var(--accent);
}

/* --- Scrollbar --- */

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

/* --- Mobile responsiveness --- */

@supports (height: 100dvh) {
    body,
    #app {
        height: 100dvh;
    }
}

#mobile-quick-actions {
    display: none;
}

#mobile-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 35;
}

#mobile-panel-backdrop.hidden {
    display: none;
}

@media (max-width: 900px) {
    #mobile-quick-actions {
        display: flex;
        gap: 6px;
        padding: 6px 8px;
        background: var(--bg-header);
        border-bottom: 1px solid var(--border-subtle);
    }

    #mobile-quick-actions .settings-btn {
        width: 34px;
        height: 34px;
    }

    header {
        padding: 8px 10px;
        gap: 8px;
    }

    .header-left {
        gap: 8px;
        min-width: 0;
    }

    header h1 {
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 30vw;
    }

    .subtitle,
    .discord-pill,
    .channel-support {
        display: none;
    }

    .header-right {
        gap: 6px;
        min-width: 0;
    }

    #agent-status {
        gap: 6px;
        max-width: 52vw;
    }

    .status-pill {
        padding: 4px 8px;
        font-size: 11px;
    }

    #channel-bar {
        padding: 6px 8px;
        gap: 6px;
    }

    main#timeline {
        padding: 8px;
    }

    .message {
        padding: 2px 4px;
        gap: 6px;
    }

    .avatar-wrap,
    .avatar {
        width: 26px;
        height: 26px;
    }

    .avatar svg {
        width: 14px;
        height: 14px;
    }

    .chat-bubble {
        max-width: 100%;
    }

    footer {
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    }

    #input-row {
        gap: 6px;
    }

    .sender-label {
        display: none;
    }

    #session-launch-btn,
    #mic,
    #send,
    .send-clock {
        min-height: 38px;
    }

    #input {
        min-height: 38px;
        padding: 9px 10px;
        font-size: 14px;
    }

    .send-group #send {
        padding: 0 12px;
    }

    .send-clock {
        padding: 0 8px;
    }

    #mention-toggles {
        margin-bottom: 6px;
    }

    #slash-menu,
    #mention-menu {
        left: 8px;
        right: 8px;
        max-height: 45vh;
    }

    .schedule-popover {
        left: 8px;
        right: 8px;
        width: auto;
    }

    #rules-panel,
    #jobs-panel,
    #settings-bar,
    #pins-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(92vw, 360px);
        max-width: 92vw;
        z-index: 40;
        box-shadow: -8px 0 24px rgba(0, 0, 0, 0.45);
        background: var(--bg-header);
        overflow-y: auto;
    }

    #settings-bar {
        left: auto;
        padding-top: 56px;
    }

    #pins-panel {
        left: auto;
    }
}

@media (max-width: 480px) {
    header h1 {
        max-width: 22vw;
        font-size: 13px;
    }

    #agent-status {
        max-width: 58vw;
    }

    .status-pill {
        padding: 3px 7px;
    }

    .settings-btn {
        width: 30px;
        height: 30px;
    }

    .mention-toggle {
        font-size: 11px;
        padding: 3px 9px;
    }

    .send-group #send {
        padding: 0 10px;
        font-size: 13px;
    }
}


