/* ===================================================================
   Cograph — Claude warm-light theme
   Design tokens live in :root; everything else references them.
   Palette: cream canvas (#F0EEE6), white cards, coral accent (#D97757).
   =================================================================== */
:root {
    /* Desktop main-view (Timeline/Files) column width; the sidebar fills the rest */
    --tl-col: 640px;
    /* Surfaces — warm charcoal, layered for elevation */
    --bg: #1C1B19;            /* app / canvas backdrop, warm charcoal */
    --surface: #26241F;       /* cards, panels, sidebar */
    --surface-2: #2D2A24;     /* inputs, secondary surfaces */
    --surface-3: #34312B;     /* subtle raised / muted fill */
    --surface-sunken: #151412;/* code blocks, sunken areas */
    --overlay: rgba(0, 0, 0, 0.62); /* modal scrim */
    --hover: rgba(255, 255, 255, 0.05);   /* generic hover fill */
    --hover-strong: rgba(255, 255, 255, 0.09);

    /* Lines */
    --border: #34312B;
    --border-strong: #45413A;

    /* Text */
    --text: #EDEAE3;
    --text-muted: #A39E94;
    --text-faint: #6E6A61;

    /* Brand accent (low-saturation coral) */
    --accent: #C8765A;
    --accent-hover: #D8896F;          /* brightens on dark */
    --accent-ink: #1C1B19;            /* dark text on accent fills */
    --accent-soft: rgba(200, 118, 90, 0.15);
    --accent-border: rgba(200, 118, 90, 0.38);

    /* Status */
    --danger: #D9685A;
    --danger-soft: rgba(217, 104, 90, 0.14);
    --ok: #6BB585;

    /* Shadows (deep, premium-subtle) */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.30);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.38);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);

    /* Node semantic hues — coding/prompt (muted sage) */
    --ct-accent: #6BB585;
    --ct-border: #36433A;
    --ct-head: #232A23;
    --ct-badge-bg: #2A3A2E;
    --ct-badge-fg: #84C79F;

    /* Node semantic hues — loop (deep forest green, darker than prompt) */
    --lp-accent: #3E7A5C;
    --lp-border: #1E3228;
    --lp-head: #131E18;
    --lp-badge-bg: #172820;
    --lp-badge-fg: #50A070;

    /* Node semantic hues — meeting (muted slate-blue) */
    --cb-border: #324250;
    --cb-head: #1F2730;
    --cb-badge-bg: #28384A;
    --cb-badge-fg: #88BCE6;

    /* Node semantic hues — note (kraft-paper sticky on dark) */
    --nt-accent: #C9A24B;
    --nt-badge-bg: #897234;
    --nt-badge-fg: #F2E2A8;
    --nt-head: #272213;       /* knowledge 侧栏头部底色 */
    --nt-border: #443A20;     /* knowledge 侧栏边框 */
}

/* ===== 浅色模式：暖米/牛皮纸调，作为暖炭灰深色的对应版（保留同一套珊瑚强调色 + 语义色）=====
   切换方式：document.documentElement[data-theme="light"]，localStorage 持久化。 */
html[data-theme="light"] {
    --bg: #F4EFE4;            /* 暖米色背景 */
    --surface: #FCF9F2;       /* 卡片/面板，比背景略亮 */
    --surface-2: #EFE8DA;     /* 输入框等次级面 */
    --surface-3: #E6DDCB;     /* 轻微凸起/弱填充 */
    --surface-sunken: #ECE4D4;/* 代码块等下沉区 */
    --overlay: rgba(40, 33, 22, 0.34);
    --hover: rgba(60, 45, 20, 0.05);
    --hover-strong: rgba(60, 45, 20, 0.09);

    --border: #E4DBC9;
    --border-strong: #CFC3AC;

    --text: #2C271E;          /* 暖近黑 */
    --text-muted: #6F6757;
    --text-faint: #9C917E;

    --accent: #BE6A4E;        /* 浅底上略加深的珊瑚以保证对比 */
    --accent-hover: #A9583D;
    --accent-ink: #FBF4EB;    /* 珊瑚填充上的浅色文字 */
    --accent-soft: rgba(190, 106, 78, 0.14);
    --accent-border: rgba(190, 106, 78, 0.42);

    --danger: #C5503B;
    --danger-soft: rgba(197, 80, 59, 0.12);
    --ok: #4E9E6E;

    --shadow-sm: 0 1px 2px rgba(70, 55, 30, 0.10);
    --shadow-md: 0 6px 18px rgba(70, 55, 30, 0.13);
    --shadow-lg: 0 16px 44px rgba(70, 55, 30, 0.20);

    /* coding/prompt (sage) */
    --ct-accent: #4E9E6E;
    --ct-border: #C7DECB;
    --ct-head: #E4F0E6;
    --ct-badge-bg: #DBEEDF;
    --ct-badge-fg: #2E7D52;

    /* loop (deep forest green) */
    --lp-accent: #1A6B42;
    --lp-border: #8DC4A0;
    --lp-head: #C0DECA;
    --lp-badge-bg: #AECFBA;
    --lp-badge-fg: #0E4E2E;

    /* meeting / ideation (slate-blue) */
    --cb-border: #C5D9EA;
    --cb-head: #E2ECF6;
    --cb-badge-bg: #DBE8F5;
    --cb-badge-fg: #2C6FA8;

    /* note / knowledge (kraft) */
    --nt-accent: #A9882E;
    --nt-badge-bg: #ECDCA6;
    --nt-badge-fg: #7E6212;
    --nt-head: #F1E8D0;       /* 浅色：牛皮纸淡色头部 */
    --nt-border: #DDCFA8;
}

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

body {
    overflow: hidden;
    background: var(--bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--text);
    user-select: none;
    /* Native-app feel on touch devices: disable the browser's double-tap-to-zoom
       gesture (e.g. double-tapping a node to rename) and the 300ms tap delay.
       Panning/scrolling inside scrollable panels still works. */
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
}

/* ===== Login Modal ===== */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px 40px;
    min-width: 360px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.modal-content h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text);
}

.modal-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.modal .input-group {
    margin-bottom: 20px;
    text-align: left;
}

.modal .input-group label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

#login-userid,
#login-password {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
}
#login-userid:focus,
#login-password:focus {
    border-color: var(--accent);
}

/* 设置弹窗「切换项目」列表 */
#settings-projects-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}
.settings-project-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 3px;
    transition: all 0.15s;
}
.settings-project-row:hover { border-color: var(--accent-border); background: var(--hover); }
.settings-project-row.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}
.settings-project-open {
    flex: 1;
    min-width: 0;
    border: none;
    background: none;
    color: inherit;
    padding: 7px 8px;
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}
.settings-project-row.active .settings-project-open { font-weight: 650; }
.settings-project-pin {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-faint);
    padding: 6px 7px;
    font-size: 11px;
    cursor: pointer;
}
.settings-project-pin:hover {
    background: var(--surface-3);
    color: var(--text);
}
.settings-project-pin.active {
    background: var(--accent-soft);
    color: var(--accent);
}
.settings-project-pin:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}
.settings-system-section {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.settings-theme-control {
    display: flex;
    gap: 3px;
    padding: 3px;
    border-radius: 9px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.settings-theme-control button {
    flex: 1;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    padding: 7px 10px;
    font-size: 12px;
    cursor: pointer;
}
.settings-theme-control button:hover {
    color: var(--text);
    background: var(--hover);
}
.settings-theme-control button.active {
    color: var(--text);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    font-weight: 650;
}
.input-error {
    font-size: 11px;
    color: var(--danger);
    margin-top: 6px;
}

#login-confirm {
    width: 100%;
    padding: 10px;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 8px;
    color: var(--accent-ink);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.15s;
}

#login-confirm:hover {
    background: var(--accent-hover);
}

/* ===== Top Bar ===== */
#topbar {
    position: fixed;
    top: 0; left: 0;
    /* 桌面端只占左侧主面板列宽，使右上角的控件落在「左侧面板的右上角」，
       而不是被常驻 sidebar 盖住的窗口最右端。移动端在媒体查询里改回全宽。 */
    width: var(--tl-col);
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1001;
}

#topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

/* 顶部常驻项目：最多六个紧凑标签，在固定主栏宽度内均分并省略长名称。 */
#pinned-projects {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.pinned-project-chip {
    position: relative;
    isolation: isolate;
    flex: 1 1 64px;
    min-width: 38px;
    max-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 7px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 550;
    transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.pinned-project-chip:hover {
    color: var(--text);
    background: var(--hover);
}
.pinned-project-chip.active {
    color: var(--accent);
    background: var(--accent-soft);
    border-color: var(--accent-border);
    font-weight: 650;
}
.pinned-project-chip.working {
    color: var(--ct-badge-fg);
    border-color: var(--ct-border);
    background: var(--ct-badge-bg);
}
.pinned-project-chip.working::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset: 0 auto 0 0;
    width: 48%;
    pointer-events: none;
    background: linear-gradient(100deg, transparent 0%, rgba(132, 199, 159, 0.3) 50%, transparent 100%);
    transform: translateX(-160%);
    animation: pinned-project-sweep 2.8s ease-in-out infinite;
}
@keyframes pinned-project-sweep {
    0%   { transform: translateX(-160%); }
    58%  { transform: translateX(310%); }
    100% { transform: translateX(310%); }
}
.pinned-project-chip.temporary {
    max-width: 140px;
}

/* 独立的系统设置入口。 */
#project-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
#project-btn:hover {
    background: var(--surface-3);
    border-color: var(--border-strong);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}
#project-btn:active { transform: translateY(0.5px); }

#topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    transition: box-shadow 0.15s;
}
/* 头像作为退出按钮：裸按钮包住头像，hover 时加一圈强调环 */
#logout-btn {
    background: none;
    border: none;
    padding: 0;
    margin-left: 2px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    line-height: 0;
}
#logout-btn:hover .topbar-avatar {
    box-shadow: 0 0 0 2px var(--accent-border);
}

/* ===== Context Menu ===== */
#context-menu {
    position: fixed;
    z-index: 10000;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
    min-width: 180px;
    box-shadow: var(--shadow-lg);
}
.ctx-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    transition: background 0.1s;
}
.ctx-item:hover {
    background: var(--hover);
}
.ctx-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}
.ctx-item-danger {
    color: var(--danger);
}
.ctx-item-danger:hover {
    background: var(--danger-soft);
}

/* ===== @ Mention Menu ===== */
#mention-menu {
    position: fixed;
    z-index: 12000;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
    min-width: 220px;
    max-width: 320px;
    max-height: 240px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    scrollbar-width: none;
}
#mention-menu::-webkit-scrollbar { display: none; }

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

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

.mention-item-badge {
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 6px;
    flex-shrink: 0;
}

.mention-item-badge[data-type="knowledge"] { background: var(--nt-badge-bg); color: var(--nt-badge-fg); }
.mention-item-badge[data-type="idea"] { background: var(--cb-badge-bg); color: var(--cb-badge-fg); }
.mention-item-badge[data-type="prompt"] { background: var(--ct-badge-bg); color: var(--ct-badge-fg); }
.mention-item-badge[data-type="loop"] { background: var(--lp-badge-bg); color: var(--lp-badge-fg); }

.mention-item-title {
    flex: 1;
    font-size: 13px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mention-item-type {
    font-size: 11px;
    color: var(--text-faint);
    flex-shrink: 0;
}

/* ===== Sidebar ===== */
#sidebar {
    position: fixed;
    top: 0; right: 0;
    width: calc(100vw - var(--tl-col)); /* fill everything right of the main-view column */
    height: var(--app-height, 100dvh);
    background: var(--surface);
    border-left: 1px solid var(--sidebar-border, var(--border));
    display: flex;
    flex-direction: column;
    z-index: 1100;
    transition: transform 0.25s ease;
    box-shadow: -8px 0 32px rgba(70, 58, 42, 0.08);
}

#sidebar.sidebar-closed {
    transform: translateX(100%);
}

#sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    padding: 0 16px;
    border-bottom: 1px solid var(--sidebar-border, var(--border));
    background: var(--sidebar-header-bg, var(--surface-2));
    flex-shrink: 0;
}

#sidebar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--sidebar-accent, var(--text));
}

.sidebar-title-text {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}
.sidebar-title-text.untitled {
    color: var(--text-muted);
    border-bottom: 1px dashed currentColor;
    font-weight: 400;
    cursor: text;
}
.sidebar-title-input {
    flex: 0 1 280px;
    min-width: 80px;
    width: 280px;
    padding: 3px 6px;
    border: 1px solid var(--sidebar-border, var(--border));
    border-radius: 6px;
    outline: none;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
.sidebar-title-input:focus {
    border-color: var(--sidebar-accent, var(--accent));
}
/* Sidebar themes by mode */
#sidebar[data-mode="prompt"] {
    --sidebar-border: var(--ct-border);
    --sidebar-header-bg: var(--ct-head);
    --sidebar-accent: var(--ct-badge-fg);
}
#sidebar[data-mode="loop"] {
    --sidebar-border: var(--lp-border);
    --sidebar-header-bg: var(--lp-head);
    --sidebar-accent: var(--lp-badge-fg);
}
#sidebar[data-mode="loop"] .sidebar-badge {
    background: var(--lp-badge-bg);
    color: var(--lp-badge-fg);
}
#sidebar[data-mode="idea"] {
    --sidebar-border: var(--cb-border);
    --sidebar-header-bg: var(--cb-head);
    --sidebar-accent: var(--cb-badge-fg);
}
#sidebar[data-mode="knowledge"] {
    --sidebar-border: var(--nt-border);
    --sidebar-header-bg: var(--nt-head);
    --sidebar-accent: var(--nt-badge-fg);
}
#sidebar[data-mode="fileman"] {
    --sidebar-border: var(--nt-border);
    --sidebar-header-bg: var(--nt-head);
    --sidebar-accent: var(--nt-badge-fg);
}
#sidebar[data-mode="timeline"] {
    --sidebar-border: var(--border);
    --sidebar-header-bg: var(--surface-2);
    --sidebar-accent: var(--text-muted);
}
.sidebar-badge {
    width: 24px;
    height: 24px;
    background: var(--ct-badge-bg);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--ct-badge-fg);
}

#sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 6px;
    margin-right: 2px;
    border-radius: 6px;
    flex-shrink: 0;
}
#sidebar-close:hover {
    background: var(--hover);
    color: var(--text);
}

/* Delete current node — only shown when a node detail (note/meeting/coding) is open */
#sidebar-delete {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 6px;
    margin-left: 2px;
    border-radius: 6px;
    flex-shrink: 0;
}
#sidebar-delete:hover {
    background: var(--danger-soft);
    color: var(--danger);
}
/* 删除按钮只在 Files 视图（data-candelete="1"）打开节点时出现；Timeline 仅作更新记录，不可删除 */
#sidebar[data-candelete="1"][data-mode="knowledge"] #sidebar-delete,
#sidebar[data-candelete="1"][data-mode="idea"] #sidebar-delete,
#sidebar[data-candelete="1"][data-mode="prompt"] #sidebar-delete,
#sidebar[data-candelete="1"][data-mode="loop"] #sidebar-delete {
    display: flex;
}
/* Placeholder state: nothing to go back to on desktop — hide the back chevron */
#sidebar[data-mode="empty"] #sidebar-close {
    display: none;
}

/* ===== Sidebar empty / placeholder state ===== */
.sidebar-empty {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px;
    text-align: center;
    color: var(--text-faint);
}
.sidebar-empty-icon svg {
    width: 40px;
    height: 40px;
    opacity: 0.45;
}
.sidebar-empty-text {
    font-size: 13.5px;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

/* ===== Chat Messages ===== */
#chat-messages {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    user-select: text;
}

#chat-messages > * {
    margin-bottom: 12px;
}

.chat-msg {
    max-width: 100%;
    font-size: 13.5px;
    line-height: 1.65;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-msg .bubble {
    padding: 10px 14px;
    border-radius: 12px;
}

.chat-msg.user {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.bubble-images {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
    width: 100%;
    max-width: 80%;
    margin-left: auto;
}

.bubble-img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
    border: 1px solid var(--border);
}

.chat-msg.user .bubble {
    background: var(--sidebar-accent, var(--accent));
    color: var(--accent-ink);
    border-radius: 14px 14px 4px 14px;
    max-width: 80%;
    font-size: 13px;
}

.chat-msg.user .msg-side {
    justify-content: flex-end; /* 时间靠近头像 */
}
.chat-msg.user .msg-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.agent-card-wrap {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 8px;
}

/* 头像竖排列（用户消息: .msg-side，AI消息: .msg-avatar-col）*/
.msg-side, .msg-avatar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.chat-time-divider {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    padding: 10px 0 4px;
    user-select: none;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}
.agent-card-wrap .msg-avatar-col {
    margin-top: 10px;
}
.agent-card-wrap .msg-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
}

.agent-card-wrap .msg-avatar svg {
    width: 16px;
    height: 16px;
    color: var(--accent);
}

.agent-card-wrap .agent-card {
    flex: 1;
    min-width: 0;
}

/* Agent activity card */
.agent-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    animation: fadeInUp 0.25s ease;
}

.agent-card-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 12px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.agent-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ok);
    flex-shrink: 0;
    animation: pulse 1.5s infinite;
}
.agent-pulse.done {
    background: var(--ok);
    animation: none;
}
.agent-pulse.error {
    background: var(--danger);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(62, 157, 91, 0.5); }
    50% { opacity: 0.7; box-shadow: 0 0 0 4px rgba(62, 157, 91, 0); }
}

.agent-status-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-card.done .agent-card-status {
    color: var(--text-faint);
}

.agent-card-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
}
.agent-card-tools:empty {
    display: none;
}

.agent-tool-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    border-radius: 6px;
    font-size: 11px;
    color: var(--text-muted);
    max-width: 100%;
    animation: fadeInUp 0.15s ease;
}
.agent-tool-tag.running {
    border-color: var(--accent);
}
.agent-tool-tag.failed {
    background: rgba(220, 70, 70, 0.08);
    border-color: rgba(220, 70, 70, 0.35);
}
.agent-tool-tag.declined {
    opacity: 0.72;
}

.agent-tool-icon {
    display: flex;
    align-items: center;
    color: var(--accent);
}
.agent-tool-icon svg {
    width: 12px;
    height: 12px;
}

.agent-tool-name {
    color: var(--accent);
    font-weight: 600;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 10px;
    flex-shrink: 0;
}

.agent-tool-detail {
    color: var(--text-muted);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.agent-tool-state {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 800;
    color: var(--text-faint);
}
.agent-tool-tag.running .agent-tool-state {
    color: var(--accent);
    animation: pulse 1.2s ease-in-out infinite;
}
.agent-tool-tag.failed .agent-tool-state {
    color: #dc4646;
}

.agent-card-body {
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
}
.agent-card-body:empty {
    display: none;
}
.agent-card-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.agent-card-body a:hover { color: var(--accent-hover); }

.agent-app-action {
    display: flex;
    padding: 0 14px 11px;
}
.agent-card-body:empty + .agent-app-action {
    padding-top: 10px;
}
.agent-app-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.agent-app-link:hover {
    color: var(--accent);
    border-color: var(--accent-border);
    background: var(--accent-soft);
}
.agent-app-link-arrow {
    color: var(--text-faint);
    font-size: 10px;
}

.chat-msg.system-msg {
    background: none;
    border: none;
    color: var(--text-faint);
    font-size: 11px;
    text-align: center;
    padding: 4px;
}

/* 加载动效：三点跳动 */
.loading-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 20px 0;
}
.loading-dots span {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-faint);
    animation: loading-bounce 1.2s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes loading-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40%            { transform: translateY(-6px); opacity: 1; }
}


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

/* Code blocks in messages */
.chat-msg .bubble pre {
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 12px;
    line-height: 1.5;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.chat-msg .bubble code {
    background: var(--surface-3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.chat-msg .bubble pre code {
    background: none;
    padding: 0;
}

.chat-msg .bubble a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.chat-msg .bubble a:hover {
    color: var(--accent-hover);
}

/* ===== Chat Input ===== */
#chat-input-area {
    padding: 12px 16px;
    flex-shrink: 0;
}

#chat-status {
    font-size: 11px;
    color: var(--text-faint);
    margin-bottom: 6px;
    min-height: 16px;
}

#chat-status.running {
    color: var(--sidebar-accent, var(--accent));
}
#chat-status.ctx-locked {
    color: #c74040;
    font-weight: 500;
}

#image-preview-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 0 6px 0;
}

.img-preview-thumb {
    position: relative;
    display: inline-flex;
}

.img-preview-thumb.uploading img {
    opacity: .55;
}

.img-preview-state {
    display: none;
    position: absolute;
    inset: 0;
    margin: auto;
    width: 18px;
    height: 18px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.img-preview-thumb.uploading .img-preview-state {
    display: block;
    border: 2px solid rgba(255, 255, 255, .65);
    border-top-color: var(--sidebar-accent, var(--accent));
    animation: prompt-image-spin .8s linear infinite;
}

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

.img-preview-thumb.error .img-preview-state {
    display: flex;
    background: var(--danger);
}

#chat-status.upload-error {
    color: var(--danger);
}

.img-preview-thumb img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.img-preview-remove {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--danger);
    color: white;
    border: none;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}

#image-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    transition: color 0.15s, background 0.15s;
}

#image-upload-btn:hover {
    color: var(--text);
    background: var(--surface-3);
}

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

#chat-input {
    flex: 1;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    padding: 8px 12px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.4;
    outline: none;
    max-height: 120px;
    overflow-y: auto;
    scrollbar-width: none;
    min-height: 20px;
    white-space: pre-wrap;
    word-break: break-word;
}
#chat-input:empty::before {
    content: attr(data-placeholder);
    color: var(--text-faint);
    pointer-events: none;
}
#chat-input::-webkit-scrollbar {
    display: none;
}
#chat-input .mention-tag {
    display: inline-flex;
    align-items: center;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent-border);
    border-radius: 4px;
    padding: 0 5px;
    font-size: 12px;
    font-weight: 500;
    cursor: default;
    white-space: nowrap;
    user-select: none;
    vertical-align: baseline;
    line-height: 1.5;
    margin: 0 1px;
}

#chat-input:focus {
    border-color: var(--sidebar-accent, var(--accent));
}

#chat-input.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

#chat-send:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#chat-send, #chat-stop, #listener-agent-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#chat-send {
    background: var(--sidebar-accent, var(--accent));
    color: var(--accent-ink);
}
#chat-send:hover {
    filter: brightness(1.08);
}
#chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#listener-agent-btn {
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
#listener-agent-btn:hover {
    color: #5f63d8;
    border-color: rgba(95, 99, 216, 0.45);
    background: rgba(111, 116, 241, 0.08);
}
#listener-agent-btn.active {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, #5f63d8, #8c6de8);
    box-shadow: 0 0 0 4px rgba(111, 116, 241, 0.12), 0 5px 16px rgba(77, 74, 188, 0.25);
}

/* ===== Session 旁听 Agent / GPT Live-inspired listening surface ===== */
.listener-live-panel {
    --listener-scale: 1;
    --listener-halo-opacity: 0.32;
    position: absolute;
    inset: 0;
    z-index: 20;
    margin: 0 !important;
    padding: 16px 20px 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    color: var(--text);
    background:
      radial-gradient(circle at 50% 38%, rgba(130, 115, 238, 0.13), transparent 34%),
      radial-gradient(circle at 25% 18%, rgba(88, 174, 245, 0.10), transparent 30%),
      linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, #eef0ff 4%), var(--surface));
    animation: listener-panel-in 0.24s ease-out;
}
@keyframes listener-panel-in {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}
.listener-live-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.listener-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
}
.listener-live-badge > span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ef5f68;
    box-shadow: 0 0 0 4px rgba(239, 95, 104, 0.12);
    animation: listener-record-dot 1.8s ease-in-out infinite;
}
@keyframes listener-record-dot { 50% { opacity: 0.45; } }
.listener-live-stop {
    padding: 6px 11px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: color-mix(in srgb, var(--surface) 84%, transparent);
    cursor: pointer;
    font-size: 12px;
}
.listener-live-stop:hover { color: #d34d59; border-color: rgba(211, 77, 89, 0.35); }
.listener-live-stage {
    flex: 1;
    min-height: 230px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.listener-orb-wrap {
    position: relative;
    width: 150px;
    height: 150px;
    display: grid;
    place-items: center;
    margin-bottom: 22px;
}
.listener-orb-halo {
    position: absolute;
    inset: 5px;
    border-radius: 50%;
    opacity: var(--listener-halo-opacity);
    background: conic-gradient(from 80deg, #6dd5ed, #7474ec, #b985e7, #7cc8f2, #6dd5ed);
    filter: blur(20px);
    transform: scale(var(--listener-scale));
    transition: transform 90ms linear, opacity 90ms linear;
    animation: listener-halo-spin 8s linear infinite;
}
.listener-orb {
    position: relative;
    width: 104px;
    height: 104px;
    border-radius: 46% 54% 55% 45% / 53% 43% 57% 47%;
    background:
      radial-gradient(circle at 32% 24%, rgba(255,255,255,.95), rgba(255,255,255,0) 24%),
      radial-gradient(circle at 72% 72%, #c074dc, transparent 42%),
      linear-gradient(145deg, #67cde8 5%, #6d7ee8 48%, #9d70dc 88%);
    box-shadow: inset -12px -16px 28px rgba(65, 49, 155, .22), inset 10px 12px 22px rgba(255,255,255,.24), 0 18px 45px rgba(74, 78, 191, .24);
    transform: scale(var(--listener-scale));
    transition: transform 90ms linear;
    animation: listener-orb-breathe 4.2s ease-in-out infinite, listener-orb-morph 7s ease-in-out infinite alternate;
}
@keyframes listener-halo-spin { to { rotate: 360deg; } }
@keyframes listener-orb-breathe { 50% { filter: brightness(1.08) saturate(1.08); } }
@keyframes listener-orb-morph {
    50% { border-radius: 55% 45% 46% 54% / 44% 58% 42% 56%; rotate: 5deg; }
    100% { border-radius: 48% 52% 60% 40% / 56% 42% 58% 44%; rotate: -4deg; }
}
.listener-live-panel[data-state="thinking"] .listener-orb {
    animation-duration: 1.15s, 2.3s;
    box-shadow: inset -12px -16px 28px rgba(65,49,155,.22), inset 10px 12px 22px rgba(255,255,255,.24), 0 0 52px rgba(113,91,229,.42);
}
.listener-live-panel[data-state="error"] .listener-orb {
    filter: grayscale(.45) opacity(.72);
}
.listener-live-status {
    font-size: 16px;
    font-weight: 650;
    letter-spacing: -0.01em;
    color: var(--text);
}
.listener-live-note {
    margin-top: 7px;
    color: var(--text-faint);
    font-size: 12px;
}
.listener-prompt-card {
    width: min(100%, 680px);
    margin: 0 auto 12px;
    padding: 12px 14px;
    border: 1px solid rgba(111, 104, 222, 0.22);
    border-radius: 13px;
    background: color-mix(in srgb, var(--surface) 88%, #8582ee 12%);
    box-shadow: 0 8px 28px rgba(65, 58, 151, 0.08);
    animation: fadeInUp .2s ease-out;
}
.listener-prompt-label {
    margin-bottom: 5px;
    color: #6f68d8;
    font-size: 11px;
    font-weight: 700;
}
.listener-prompt-text { font-size: 13px; line-height: 1.55; }
.listener-prompt-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
    color: var(--text-faint);
    font-size: 11px;
}
.listener-prompt-actions button {
    border: 0;
    border-radius: 999px;
    padding: 5px 10px;
    color: #fff;
    background: #716bdd;
    cursor: pointer;
    white-space: nowrap;
}
.listener-live-transcript {
    width: min(100%, 680px);
    max-height: 145px;
    margin: 0 auto;
    padding: 12px 14px;
    overflow-y: auto;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.55;
    flex-shrink: 0;
}
.listener-live-line { display: flex; gap: 9px; margin: 5px 0; }
.listener-live-speaker { min-width: 54px; color: var(--text); font-weight: 650; }
.listener-live-interim { opacity: .5; }
.listener-live-empty { text-align: center; color: var(--text-faint); }

@media (max-width: 768px) {
    .listener-live-panel { padding: 14px 16px 12px; }
    .listener-orb-wrap { width: 125px; height: 125px; margin-bottom: 15px; }
    .listener-orb { width: 88px; height: 88px; }
    .listener-live-stage { min-height: 185px; }
    .listener-live-transcript { max-height: 125px; padding: 10px 4px; }
}

@media (prefers-reduced-motion: reduce) {
    .listener-orb, .listener-orb-halo, .listener-live-badge > span { animation: none; }
}

#chat-stop {
    background: var(--danger-soft);
    color: var(--danger);
}
#chat-stop:hover {
    background: rgba(199, 73, 58, 0.18);
}

.compact-summary-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--sidebar-accent, var(--accent));
    border-radius: 10px;
    padding: 10px 14px;
    margin: 6px 0 12px;
    font-size: 13px;
    overflow-x: hidden;
    word-break: break-word;
    overflow-wrap: break-word;
}
.compact-summary-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--sidebar-accent, var(--accent));
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.compact-summary-body {
    color: var(--text-faint);
    line-height: 1.55;
    font-size: 12.5px;
    overflow-x: hidden;
}
.compact-summary-body p { margin: 0 0 4px; }
.compact-summary-body p:last-child { margin-bottom: 0; }

/* compact 进行中 / 失败卡片 */
.compact-progress-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 12px;
    color: var(--text-muted);
    margin: 2px 0;
}
.compact-progress-card svg { flex-shrink: 0; opacity: 0.7; }
.compact-progress-error { color: var(--danger); }
.compact-progress-error svg { opacity: 1; stroke: var(--danger); }

/* compact 进行中：突出的流光卡片 */
.compact-progress-active {
    gap: 11px;
    padding: 13px 16px;
    margin: 8px 0;
    border-radius: 12px;
    background: linear-gradient(110deg,
        var(--surface-2) 0%, var(--surface-2) 35%,
        color-mix(in srgb, var(--sidebar-accent, var(--accent)) 14%, var(--surface-2)) 50%,
        var(--surface-2) 65%, var(--surface-2) 100%);
    background-size: 220% 100%;
    border: 1px solid color-mix(in srgb, var(--sidebar-accent, var(--accent)) 35%, var(--border));
    animation: compactShimmer 1.8s ease-in-out infinite;
}
.compact-progress-active svg {
    opacity: 1;
    stroke: var(--sidebar-accent, var(--accent));
    width: 16px; height: 16px;
    animation: compactPulse 1.4s ease-in-out infinite;
}
.compact-progress-text { display: flex; flex-direction: column; gap: 2px; }
.compact-progress-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.compact-progress-sub {
    font-size: 11px;
    color: var(--text-faint);
}
@keyframes compactShimmer {
    0% { background-position: 130% 0; }
    100% { background-position: -130% 0; }
}
@keyframes compactPulse {
    0%, 100% { opacity: 0.55; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.08); }
}

/* ===== Loop 节点专属样式 ===== */
/* 配置表单 */
.loop-config-form {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.loop-config-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 600;
    color: var(--lp-badge-fg);
    letter-spacing: 0.03em;
}
.loop-field { display: flex; flex-direction: column; gap: 5px; }
.loop-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}
.loop-required { color: var(--accent); }
.loop-field-hint {
    font-size: 11px;
    color: var(--text-faint);
    line-height: 1.5;
    margin-top: 2px;
}
.loop-input {
    font-size: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 8px 10px;
    resize: vertical;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
}
.loop-input:focus { border-color: var(--lp-accent); }
.loop-input-number { width: 80px; resize: none; }
.loop-config-actions { padding-top: 4px; }
.loop-start-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    background: var(--lp-accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.loop-start-btn:hover:not(:disabled) { opacity: 0.85; }
.loop-start-btn:disabled { opacity: 0.45; cursor: not-allowed; }
/* 运行态控制栏（位于 chat-input-area 内，替代文本输入行）*/
.loop-control-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}
.loop-iter-label {
    font-size: 12px;
    color: var(--text-muted);
    flex: 1;
}
.loop-stop-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.loop-stop-btn:hover { background: color-mix(in srgb, var(--danger) 18%, transparent); }
/* 自动生成的 prompt 气泡（带 ∞ badge）*/
.loop-auto-msg .bubble {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.loop-auto-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    color: var(--lp-badge-fg);
    background: var(--lp-badge-bg);
    border-radius: 10px;
    padding: 2px 8px 2px 6px;
    width: fit-content;
}
/* Loop 结束卡片 */
.loop-done-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    margin: 8px 0;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.loop-done-ok {
    color: var(--lp-accent);
    border-color: color-mix(in srgb, var(--lp-accent) 25%, transparent);
    background: color-mix(in srgb, var(--lp-accent) 8%, var(--surface-2));
}
/* Loop 结束后底部的 New Loop 按钮栏 */
.loop-ended-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}
.loop-new-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    background: var(--lp-accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.loop-new-btn:hover { opacity: 0.85; }
.loop-hist-hint {
    font-size: 12px;
    color: var(--text-faint);
}
/* 历史记录列表（在配置表单顶部显示） */
.loop-history-list {
    padding: 12px 16px 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}
.loop-history-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-faint);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 8px;
}
.loop-history-item {
    padding: 8px 10px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.12s;
    margin-bottom: 4px;
}
.loop-history-item:hover { background: var(--hover); }
.loop-history-goal {
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.loop-history-meta {
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 2px;
}

/* slash 命令工具栏（compact 等按钮所在行）*/
#chat-slash-row {
    display: flex;
    align-items: center;
    padding-bottom: 8px;
}
#chat-slash-left {
    flex: 0 0 auto;
}
#chat-slash-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
}

/* compact + token 进度条的组合控件 */
#chat-compact-group {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-2);
    max-width: 100%;
}

/* token 用量条（sidebar）*/
#ctx-token-bar {
    flex: 1;
    min-width: 80px;
    height: 28px;
    border-right: 1px solid var(--border);
    background: transparent;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 0 9px;
}
#ctx-token-fill {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    transition: width 0.4s ease;
    pointer-events: none;
}
#ctx-token-fill.ctx-ok     { background: rgba(92, 158, 112, 0.22); }
#ctx-token-fill.ctx-warn   { background: rgba(200, 133, 53, 0.25); }
#ctx-token-fill.ctx-danger { background: rgba(199, 64, 64, 0.28); }
#ctx-token-label {
    position: relative;
    z-index: 1;
    font-size: 11px;
    color: var(--text-faint);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

#chat-compact {
    height: 28px;
    padding: 0 10px;
    gap: 5px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    display: flex;
    align-items: center;
    font-size: 12px;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}
#chat-compact:hover {
    background: var(--hover);
    color: var(--text);
}

/* ===== 自定义滚动条：左侧主面板（会话列表/文件）+ 右侧对话区，统一贴合主题 =====
   细、透明轨道、圆角拇指，两侧留 2px 透明边做内缩感，hover 提亮。 */
.timeline-body::-webkit-scrollbar,
#notes-panel::-webkit-scrollbar,
#chat-messages::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}
.timeline-body::-webkit-scrollbar-track,
#notes-panel::-webkit-scrollbar-track,
#chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.timeline-body::-webkit-scrollbar-thumb,
#notes-panel::-webkit-scrollbar-thumb,
#chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
.timeline-body::-webkit-scrollbar-thumb:hover,
#notes-panel::-webkit-scrollbar-thumb:hover,
#chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-faint);
    background-clip: padding-box;
}
/* Firefox */
.timeline-body,
#notes-panel,
#chat-messages {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

/* ===== Note Editor (in sidebar) ===== */
.note-editor {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.7;
    padding: 0;
    outline: none;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.note-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--text-faint);
    pointer-events: none;
}

/* Rich text elements inside note editor */
.note-editor h1 { font-size: 22px; font-weight: 700; margin: 16px 0 8px; line-height: 1.3; color: var(--text); }
.note-editor h2 { font-size: 18px; font-weight: 600; margin: 14px 0 6px; line-height: 1.35; color: var(--text); }
.note-editor h3 { font-size: 15px; font-weight: 600; margin: 12px 0 4px; line-height: 1.4; color: var(--text); }
.note-editor ul, .note-editor ol { margin: 6px 0; padding-left: 24px; }
.note-editor li { margin: 2px 0; }
.note-editor blockquote {
    border-left: 3px solid var(--accent-border);
    margin: 8px 0;
    padding: 4px 12px;
    color: var(--text-muted);
}
.note-editor strong { font-weight: 700; }
.note-editor em { font-style: italic; }
.note-editor u { text-decoration: underline; }
.note-editor s { text-decoration: line-through; color: var(--text-faint); }
.note-editor a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.note-editor a:hover { color: var(--accent-hover); }

/* Floating toolbar */
#note-toolbar {
    position: fixed;
    z-index: 12000;
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2px;
    gap: 1px;
    box-shadow: var(--shadow-lg);
    transform: translateX(-50%);
}
#note-toolbar button {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    min-width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#note-toolbar button:hover {
    background: var(--hover);
    color: var(--text);
}
.note-toolbar-sep {
    width: 1px;
    height: 16px;
    background: var(--border);
    margin: 0 2px;
}

.mention-tag {
    display: inline-flex;
    align-items: center;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent-border);
    border-radius: 4px;
    padding: 0 6px;
    margin: 0 1px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    vertical-align: baseline;
    line-height: 1.6;
}

.mention-tag:hover {
    background: rgba(217, 119, 87, 0.2);
    border-color: var(--accent);
}

.mention-tag.deleted {
    background: var(--surface-3);
    color: var(--text-faint);
    border-color: var(--border);
    text-decoration: line-through;
}

/* ===== Agent 模型指示器（sidebar 标题栏） ===== */
#agent-model-indicator {
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-left: 6px;
    border: 1px solid var(--ct-border);
    border-radius: 8px;
    color: var(--text-muted);
    background: var(--surface, rgba(0,0,0,0.04));
    flex-shrink: 0;
}
.agent-model-icon,
.agent-model-icon svg {
    display: block;
    width: 16px;
    height: 16px;
}

/* ===== Settings Modal ===== */
#settings-modal {
    z-index: 2000;
}
.settings-modal-content {
    width: min(880px, calc(100vw - 32px));
    min-width: 0;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    text-align: left;
    padding: 22px 24px 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
/* Mobile tab switcher — hidden on desktop */
.settings-mobile-tabs {
    display: none;
}
.settings-body {
    display: flex;
    gap: 0;
    align-items: flex-start;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.settings-col {
    flex: 1;
    min-width: 0;
    min-height: 0;
    max-height: 100%;
    align-self: stretch;
    padding: 0 20px;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.settings-col:first-child { padding-left: 0; }
.settings-col:last-child { padding-right: 0; }
.settings-col-divider {
    width: 1px;
    align-self: stretch;
    background: var(--border);
    flex-shrink: 0;
}
.settings-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    margin-bottom: 18px;
}
.settings-modal-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}
.settings-modal-header button {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 6px;
}
.settings-modal-header button:hover {
    background: var(--hover);
    color: var(--text);
}
/* ===== Settings: 分区 ===== */
.settings-section-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 6px;
}
/* ===== Settings: Target Applications ===== */
#settings-apps-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}
.settings-apps-empty {
    font-size: 13px;
    color: var(--text-faint);
    padding: 16px;
    text-align: center;
    border: 1px dashed var(--border-strong);
    border-radius: 10px;
}
.settings-app-row {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.settings-app-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: var(--ct-badge-bg);
    color: var(--ct-badge-fg);
}
.settings-app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.settings-app-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.settings-app-tag {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface-3);
    border-radius: 4px;
    padding: 1px 5px;
    margin-left: 4px;
    vertical-align: middle;
}
.settings-app-port {
    font-size: 12px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--accent);
    text-decoration: none;
}
.settings-app-port:hover { text-decoration: underline; }
.settings-app-remove {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--text-faint);
    font-size: 18px;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1;
}
.settings-app-remove:hover { background: var(--danger-soft); color: var(--danger); }
/* 每个应用一行里的「CLAUDE.md」按钮 —— 编辑该应用工作目录下的 CLAUDE.md */
.settings-app-md {
    flex-shrink: 0;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    padding: 5px 9px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
.settings-app-md:hover {
    background: var(--accent-soft);
    border-color: var(--accent-border);
}
.settings-app-https,
.settings-app-start {
    flex-shrink: 0;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    padding: 5px 7px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.settings-app-https.active,
.settings-app-start.active {
    background: var(--accent-soft);
    border-color: var(--accent-border);
    color: var(--accent);
}
.settings-app-https:hover,
.settings-app-start:hover { background: var(--hover); }

/* app status dot */
.app-status-dot {
    flex-shrink: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-faint);
    transition: background 0.2s;
}
.app-status-dot.running { background: #34c759; }
.app-status-dot.degraded { background: #ff9f0a; cursor: pointer; }
.app-status-dot.stopped { background: #ff3b30; cursor: pointer; }
.app-status-dot.stopped:hover { background: #ff6b61; }
.app-status-dot.starting {
    background: #ff9f0a;
    animation: dot-pulse 0.8s ease-in-out infinite alternate;
}
@keyframes dot-pulse { from { opacity: 0.5; } to { opacity: 1; } }

/* ===== Confirm Dialog ===== */
#confirm-dialog { z-index: 3000; }
.confirm-dialog-content {
    max-width: 340px;
    padding: 28px 32px 24px;
}
.confirm-dialog-icon {
    margin-bottom: 12px;
}
.confirm-dialog-content p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 20px;
}
.confirm-dialog-buttons {
    display: flex;
    gap: 10px;
}
.confirm-btn-cancel, .confirm-btn-ok {
    flex: 1;
    padding: 9px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.confirm-btn-cancel {
    background: var(--surface-3);
    color: var(--text-muted);
}
.confirm-btn-cancel:hover {
    background: var(--hover-strong);
    color: var(--text);
}
.confirm-btn-ok {
    background: var(--danger);
    color: #fff;
}
.confirm-btn-ok:hover {
    background: #b03e30;
}

/* ===== Input Dialog (custom prompt) ===== */
#input-dialog { z-index: 3000; }
.input-dialog-content {
    max-width: 340px;
    padding: 24px 24px 20px;
    text-align: left;
}
.input-dialog-content h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 14px;
}
#input-dialog-field {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
}
#input-dialog-field:focus { border-color: var(--accent); }
.input-dialog-buttons {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}
.input-dialog-buttons button {
    flex: 1;
    padding: 9px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.input-dialog-ok {
    background: var(--accent);
    color: var(--accent-ink);
}
.input-dialog-ok:hover { background: var(--accent-hover); }

/* ===== CLAUDE.md Editor Sidebar ===== */
.claudemd-editor {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
    padding: 0;
    resize: none;
    outline: none;
}
.claudemd-editor::placeholder {
    color: var(--text-faint);
}

/* ===== 主视图容器（Messages / Timeline / Hierarchy 共用）===== */
#timeline-view {
    position: fixed;
    top: 52px; left: 0; right: 0; bottom: calc(56px + env(safe-area-inset-bottom, 0px)); /* leave room for the bottom nav (+ iPhone home indicator) */
    background: var(--bg);
    display: flex;
    flex-direction: column;
    z-index: 999;
    overflow: hidden;
}

/* Fixed create button — pinned at the bottom of the view, above the bottom nav */
#add-fab {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    padding: 8px 16px 12px;
    background: linear-gradient(to top, var(--bg) 72%, transparent);
}
#add-fab .tl-add-wrap {
    width: 100%;
    max-width: 568px;
    margin: 0;
}
/* Desktop: sidebar opens side-by-side — main view is a fixed-width left column,
   the sidebar fills all remaining width to its right */
body.sidebar-open #timeline-view {
    right: auto;
    width: var(--tl-col);
}

.timeline-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* ===== 会话列表（IM 风格）===== */
.conv-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}
/* 日期分组：左侧一个很窄的日期列（日期 + 一条细竖线 rail），右侧是该日的会话行容器。
   竖线把日期列下方原本空白的纵向空间利用起来，并直观地框出「同一天」这个区域。*/
.conv-group {
    display: flex;
    align-items: stretch;
    gap: 7px;
}
.conv-date {
    position: relative;
    flex: 0 0 32px;
    width: 32px;
    text-align: center;
    padding-top: 14px;
    font-size: 10px;
    line-height: 1.2;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    user-select: none;
}
/* 日期文字下方贯穿整组高度的细竖线 */
.conv-date::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 32px;
    bottom: 6px;
    width: 1px;
    background: var(--border);
}
.conv-group-rows {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0; /* 行之间靠内缩细分割线分隔（微信/QQ 风格），不再留卡片间距 */
}
/* ===== Unified list rows — Session(.conv-row) + Files(.file-row) =====
   微信/QQ 风格：行本身不再是带边框/底色/阴影的实体卡片，而是透明行 +
   从标题处起的内缩细分割线 + 整行柔和 hover。两个面板共用这套视觉。*/
.conv-row,
.file-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 10px;
    border-radius: 10px;
    cursor: pointer;
    background: transparent;
    border: none;
    box-shadow: none;
    transition: background 0.12s;
}
.conv-row:hover,
.file-row:hover { background: var(--hover); }
.conv-row.selected,
.file-row.selected { background: var(--accent-soft); }
/* 内缩细分割线（对齐到标题起点；hover/选中/末行时隐藏）*/
.conv-row::after,
.file-row::after {
    content: '';
    position: absolute;
    left: 51px;
    right: 10px;
    bottom: 0;
    height: 1px;
    background: var(--border);
}
.conv-row:hover::after,
.file-row:hover::after,
.conv-row.selected::after,
.file-row.selected::after,
.conv-row:last-child::after,
.file-row:last-child::after { opacity: 0; }
.conv-icon,
.file-row-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.conv-icon svg,
.file-row-icon svg { width: 15px; height: 15px; }
.conv-row[data-type="idea"] .conv-icon { background: var(--cb-badge-bg); color: var(--cb-badge-fg); }
.conv-row[data-type="prompt"] .conv-icon { background: var(--ct-badge-bg); color: var(--ct-badge-fg); }
.conv-row[data-type="loop"] .conv-icon { background: var(--lp-badge-bg); color: var(--lp-badge-fg); }
.conv-body { flex: 1; min-width: 0; }
.conv-title-row { display: flex; align-items: baseline; }
.conv-title {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-row.unread .conv-title { font-weight: 700; }
.conv-app-chip {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 500;
    color: var(--ct-accent);
    background: color-mix(in srgb, var(--ct-accent) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--ct-accent) 25%, transparent);
    border-radius: 4px;
    padding: 1px 5px;
    margin-right: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}
/* meta 行（左对齐）：时间 · 轮数/token bar · 预览。时间/轮数都在左侧，右侧只留红点。*/
.conv-meta-row { display: flex; align-items: center; gap: 7px; margin-top: 3px; }
.conv-rounds {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-faint);
    background: var(--surface-2);
    border-radius: 7px;
    padding: 0 6px;
}
/* token 进度条（会话列表 coding 节点）*/
.conv-ctx-bar {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.conv-ctx-label {
    font-size: 10.5px;
    font-variant-numeric: tabular-nums;
    color: var(--text-faint);
    white-space: nowrap;
}
.conv-ctx-track {
    width: 54px;
    height: 5px;
    background: rgba(128,128,128,0.18);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid rgba(128,128,128,0.15);
    box-sizing: border-box;
}
.conv-ctx-fill {
    display: block;
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}
.conv-ctx-fill.ctx-ok     { background: #5c9e70; }
.conv-ctx-fill.ctx-warn   { background: #c88535; }
.conv-ctx-fill.ctx-danger { background: #c74040; }
.conv-preview {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* 右列：留给未读红点 / 正在工作的用户头像（QQ 风格，时间不再占用右侧）*/
.conv-right {
    flex-shrink: 0;
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.conv-unread-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: #f85149;
    box-shadow: 0 0 0 2px rgba(248, 81, 73, 0.22);
}
.conv-skel { cursor: default; pointer-events: none; }

/* ===== 节点「正在被处理」：行内扫光 + 右侧工作者头像 ===== */
/* 工作者头像（替代红点），外圈一圈呼吸光环表示活跃 */
.conv-worker-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px var(--accent);
    animation: conv-worker-pulse 1.8s ease-in-out infinite;
}
.conv-worker-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
}
@keyframes conv-worker-pulse {
    0%, 100% { box-shadow: 0 0 0 2px var(--accent), 0 0 0 4px rgba(200, 118, 90, 0); }
    50%      { box-shadow: 0 0 0 2px var(--accent), 0 0 0 5px rgba(200, 118, 90, 0.28); }
}
/* 整行扫光：一束斜向高光在行内来回扫过，提示有人正在此节点工作 */
.conv-row.working {
    overflow: hidden;
    background: rgba(107, 181, 133, 0.12); /* 绿色淡底（编码绿 --ct-accent）*/
}
.conv-row.working::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 45%;
    pointer-events: none;
    z-index: 0;
    background: linear-gradient(100deg, transparent 0%, rgba(132, 199, 159, 0.22) 50%, transparent 100%); /* 绿色扫光 */
    transform: translateX(-160%);
    animation: conv-sweep 3.4s ease-in-out infinite;
}
/* 让内容压在扫光之上，避免文字被高光冲淡 */
.conv-row.working > * { position: relative; z-index: 1; }
@keyframes conv-sweep {
    0%   { transform: translateX(-160%); }
    55%  { transform: translateX(420%); }
    100% { transform: translateX(420%); } /* 扫过后停顿一会再来，节奏更柔和 */
}
@media (prefers-reduced-motion: reduce) {
    .conv-row.working::before,
    .conv-worker-avatar,
    .pinned-project-chip.working::before { animation: none; }
}

/* ===== Versions 视图：Git 式版本图（版本线 / 主干 / 分支 / 合并）===== */
.vg-wrap { display: flex; flex-direction: column; padding: 12px 16px 28px; max-width: 640px; margin: 0 auto; width: 100%; gap: 22px; }
.vg-line { display: flex; flex-direction: column; }
.vg-line-head { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin-bottom: 8px; }
.vg-line-title { font-size: 13px; font-weight: 700; color: var(--text); }
.vg-line-count { font-size: 11px; color: var(--text-faint); }

.vg-rows { display: flex; flex-direction: column; }
/* 一行 = [左留白 1fr | 圆点轨道 | 右标签 1fr]：圆点轨道恒在面板正中，标签在右侧。 */
.vg-row { display: grid; grid-template-columns: 1fr 22px 1fr; align-items: stretch; column-gap: 8px; cursor: pointer; }
.vg-graph { grid-column: 2; position: relative; display: flex; justify-content: center; }
/* 主干竖线：贯穿整列，连接相邻版本点 */
.vg-graph::before { content: ''; position: absolute; top: 0; bottom: 0; left: 10px; width: 2px; background: var(--border-strong); }
.vg-row:first-child .vg-graph::before { top: 14px; }
.vg-row:last-child .vg-graph::before { bottom: calc(100% - 14px); }
.vg-dot { position: relative; z-index: 1; margin-top: 8px; width: 11px; height: 11px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--bg); }
/* 极简标签行（替代旧的宽气泡），放在中线右侧那一列 */
.vg-mini { grid-column: 3; justify-self: start; display: flex; align-items: center; gap: 7px; min-width: 0; padding: 5px 8px; margin-bottom: 3px; border-radius: 8px; }
.vg-row:hover .vg-mini { background: var(--surface-2); }
.vg-mini-rounds { font-size: 11px; color: var(--text-faint); white-space: nowrap; }
/* 分支行：圆点右移 + 异色 + 一条小横向连接桩接回主干 */
.vg-branch .vg-graph { width: 40px; }
.vg-branch .vg-dot { margin-left: 18px; background: #b07cff; }
.vg-branch .vg-dot::before { content: ''; position: absolute; top: 4px; left: -20px; width: 20px; height: 2px; background: #b07cff; z-index: -1; }
/* 合并行：菱形（绿色）；冲突未解：红色 */
.vg-merge .vg-dot { border-radius: 2px; transform: rotate(45deg); background: #2ea043; }
.vg-conflict .vg-dot { background: #e5534b; }

.vg-avatar { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; object-fit: cover; }
.vg-avatar-fallback { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 10px; font-weight: 700; }
.vg-author { font-size: 12.5px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vg-turn-node { font-size: 11px; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 999px; }
/* 开放点（进行中，同一人持续开发）：圆点呼吸 */
.vg-open .vg-dot { background: var(--accent); animation: vg-pulse 1.6s ease-in-out infinite; }
@keyframes vg-pulse { 0%,100% { box-shadow: 0 0 0 3px var(--bg), 0 0 0 4px var(--accent-border); } 50% { box-shadow: 0 0 0 3px var(--bg), 0 0 0 7px transparent; } }
.vg-live { font-size: 11px; font-weight: 600; color: var(--accent); margin-left: 6px; }

/* 版本详情里的逐轮开发记录 */
.vg-turn { border-left: 2px solid var(--border-strong); padding: 4px 0 8px 10px; margin-top: 8px; }
.vg-turn-head { display: flex; align-items: center; gap: 8px; }
.vg-turn-idx { font-size: 11px; font-weight: 700; color: var(--accent); }
.vg-turn-by { font-size: 12px; font-weight: 600; color: var(--text); }
.vg-turn-time { margin-left: auto; font-size: 11px; color: var(--text-faint); }
.vg-turn-prompt { margin-top: 4px; font-size: 12.5px; line-height: 1.5; color: var(--text); white-space: pre-wrap; word-break: break-word; }

/* 版本详情面板（右侧） */
.vg-detail { padding: 14px 16px 24px; }
.vg-detail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.vg-detail-head .vg-avatar { width: 32px; height: 32px; font-size: 13px; }
.vg-detail-author { font-size: 14px; font-weight: 700; color: var(--text); }
.vg-detail-time { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.vg-detail-k { font-size: 11px; font-weight: 700; color: var(--text-muted); min-width: 48px; }
.vg-detail-block { margin-top: 12px; }
.vg-detail-block .vg-detail-k { display: block; margin-bottom: 5px; }
.vg-detail-conflict { margin: 6px 0 12px; font-size: 12.5px; line-height: 1.5; color: #e5534b; background: #e5534b14; border: 1px solid #e5534b44; border-radius: 10px; padding: 9px 11px; }
.vg-open-conv { margin-top: 18px; width: 100%; border: 1px solid var(--accent-border); background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 10px; font-size: 13px; font-weight: 600; cursor: pointer; }
.vg-open-conv:hover { background: var(--accent); color: var(--accent-ink); }

/* ===== Ideation 群聊面板（楼层 + 平铺回复）===== */
.idea-thread {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px 6px;
}
/* 每个独立 idea（楼层）外围用一个面板卡片包裹 */
.idea-floor {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 11px 13px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.16);
}
.idea-empty { color: var(--text-muted); font-size: 13px; padding: 8px 2px; }
.idea-msg-head { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
.idea-avatar { width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0; object-fit: cover; }
.idea-avatar-fallback {
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: #fff;
}
.idea-msg-name { font-size: 12px; font-weight: 600; color: var(--text); }
.idea-msg-menu {
    background: none; border: none; cursor: pointer; padding: 0 2px;
    color: var(--text-muted); font-size: 15px; line-height: 1;
    border-radius: 4px; flex-shrink: 0;
    opacity: 0; transition: opacity 0.15s;
}
.idea-floor:hover .idea-msg-menu,
.idea-reply:hover .idea-msg-menu { opacity: 1; }
.idea-msg-menu:hover { background: var(--surface-2); color: var(--text); }
.idea-edit-input {
    width: 100%; box-sizing: border-box; resize: none;
    font-size: 13.5px; line-height: 1.6; color: var(--text);
    background: var(--surface-2); border: 1px solid var(--accent);
    border-radius: 6px; padding: 6px 8px; outline: none;
    font-family: inherit;
}
.idea-edit-wrap { display: flex; flex-direction: column; gap: 4px; }
.idea-edit-img-strip { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0; }
.idea-edit-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 2px; }
.idea-edit-save, .idea-edit-cancel {
    font-size: 12px; padding: 3px 10px; border-radius: 5px; cursor: pointer; border: none;
}
.idea-edit-save { background: var(--accent); color: #fff; }
.idea-edit-save:hover { filter: brightness(1.08); }
.idea-edit-cancel { background: var(--surface-3); color: var(--text-muted); }
.idea-edit-cancel:hover { background: var(--surface-2); color: var(--text); }
.idea-bubble { font-size: 13.5px; line-height: 1.6; color: var(--text); white-space: pre-wrap; word-break: break-word; }
/* 图片全屏预览遮罩 */
.idea-img-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.85);
    display: flex; align-items: center; justify-content: center;
    cursor: zoom-out;
}
.idea-img-preview-full {
    max-width: 92vw; max-height: 88vh;
    border-radius: 6px; box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    object-fit: contain;
}
/* 气泡内图片可点击 */
img.idea-img { cursor: zoom-in; }
.idea-bubble code { background: var(--surface-3); padding: 1px 4px; border-radius: 4px; }
.idea-bubble a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.idea-bubble a:hover { color: var(--accent-hover); }
.idea-composer {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.idea-composer-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.idea-composer-imgs {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    padding: 2px 0;
}
.idea-composer-img-thumb {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 7px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--border);
}
.idea-composer-img-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.idea-composer-img-thumb.uploading { opacity: 0.5; }
.idea-composer-img-remove {
    position: absolute;
    top: 2px; right: 2px;
    width: 17px; height: 17px;
    background: rgba(0,0,0,0.65);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
}
.idea-composer-input {
    flex: 1;
    min-width: 0;
    resize: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 11px;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    line-height: 1.5;
    max-height: 160px;
    box-sizing: border-box;
}
.idea-composer-input:focus { outline: none; border-color: var(--accent); }
.idea-composer-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
}
.idea-composer-attach {
    flex-shrink: 0;
    background: none;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 5px 8px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    line-height: 1;
}
.idea-composer-attach:hover { background: var(--surface-2); color: var(--text); }
.idea-composer-send {
    flex-shrink: 0;
    background: var(--accent);
    color: #1C1B19;
    border: none;
    border-radius: 9px;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.idea-composer-send:hover { filter: brightness(1.08); }
.idea-bubble .idea-img {
    max-width: 100%;
    max-height: 280px;
    border-radius: 8px;
    margin-top: 6px;
    display: block;
    cursor: pointer;
}

.tl-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}
/* Skeleton loading shown after login until the first project_state arrives.
   Reused by the conversation-list skeleton (.conv-skel rows). */
.tl-skel {
    background: var(--surface-3);
    border-radius: 6px;
    position: relative;
    overflow: hidden;
}
.tl-skel::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
    animation: tl-shimmer 1.2s ease-in-out infinite;
}
.tl-skel-line {
    height: 11px;
    margin-bottom: 7px;
}
.tl-skel-line-sm {
    height: 9px;
    margin-bottom: 0;
}
@keyframes tl-shimmer {
    100% { transform: translateX(100%); }
}

/* ===== Timeline bottom add-button (glowing orange) ===== */
.tl-add-wrap {
    position: relative;
    margin-top: 8px;
    padding-bottom: 4px;
}
.tl-add-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 14px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(217, 119, 87, 0.40);
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.tl-add-card:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 26px rgba(217, 119, 87, 0.55);
}
.tl-add-card:active {
    transform: scale(0.98);
}
.tl-add-card svg {
    width: 20px;
    height: 20px;
}
/* Type picker pops UPWARD so it's always visible above the bottom-pinned button */
.tl-add-menu {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 8px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    animation: fadeInUp 0.15s ease;
}
.tl-add-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 14px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.12s;
}
.tl-add-opt:hover {
    background: var(--hover);
}
.tl-add-opt svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}
.tl-add-agent-icon,
.tl-add-agent-icon svg {
    display: block;
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}
/* Files view: the add button sits at the top, so its menu drops downward */
.tl-add-down .tl-add-menu {
    bottom: auto;
    top: calc(100% + 8px);
}
/* 创建第二步：App 选择列表的表头（含返回） */
.tl-add-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}
.tl-add-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
}
.tl-add-back:hover { background: var(--hover); }
.tl-add-back svg { width: 14px; height: 14px; }
.tl-add-empty {
    padding: 12px 14px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-muted);
}
.tl-add-port { color: var(--text-faint); font-weight: 500; }
.tl-add-tag {
    margin-left: 4px;
    padding: 0 5px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 5px;
    background: var(--surface-3);
    color: var(--text-muted);
}

/* ===== Files view (folder-organized) ===== */
/* Top tab bar: Ideation / Knowledge / Coding — one category visible at a time. */
.files-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    /* 背景与页面同色（非卡片色）：不再像一个独立面板，只用于 sticky 时遮挡下方滚动内容；
       四个 tab 的底色由 .files-tab.active 自己提供。 */
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 2;
}
.files-tab {
    flex: 1;
    min-width: 0; /* 允许在窄屏收缩，否则四个 tab 撑出横向滚动条 */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 6px;
    border: none;
    border-radius: 9px;
    background: none;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.files-tab-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.files-tab-icon { flex-shrink: 0; }
.files-tab:hover { background: var(--hover); }
.files-tab.active { background: var(--surface-3); color: var(--text); }
.files-tab-icon { display: flex; align-items: center; }
.files-tab-icon svg { width: 15px; height: 15px; }
.files-tab[data-type="idea"].active .files-tab-icon { color: var(--cb-badge-fg); }
.files-tab[data-type="knowledge"].active .files-tab-icon { color: var(--nt-accent); }
.files-tab[data-type="prompt"].active .files-tab-icon { color: var(--ct-badge-fg); }
.files-tab[data-type="loop"].active .files-tab-icon { color: var(--lp-badge-fg); }
.files-tab-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-faint);
    background: var(--surface-2);
    border-radius: 8px;
    padding: 1px 6px;
    min-width: 18px;
    text-align: center;
}
.files-tab.active .files-tab-count { color: var(--text-muted); }
.files-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 4px;
}
/* 文件夹展开/折叠的小箭头（用于 Knowledge 下的用户文件夹 .user-folder-head）*/
.files-folder-chev {
    display: flex;
    align-items: center;
    color: var(--text-faint);
    transition: transform 0.15s;
}
.files-folder-chev svg { width: 14px; height: 14px; }
.files-folder-count {
    font-size: 12px;
    color: var(--text-faint);
    background: var(--surface-3);
    border-radius: 10px;
    padding: 1px 9px;
    min-width: 22px;
    text-align: center;
}
/* First level under a type folder: same indent + guide rail as deeper levels,
   so its notes/folders read as nested rather than sitting at the top level. */
.files-list {
    padding: 2px 0 6px;
}
.files-empty {
    padding: 10px 16px 12px 8px;
    font-size: 12px;
    color: var(--text-faint);
}
/* .file-row 的基础样式与 .conv-row 合并在上方「Unified list rows」一节 */

/* Nested level: indent + vertical guide rail so the hierarchy is clearly visible */
.files-children {
    margin-left: 15px;
}
/* 缩进导引竖线只在二级及更深的嵌套出现（见 renderUserFolder 的 depth 判定） */
.files-children-rail {
    padding-left: 13px;
    border-left: 1.5px solid var(--border-strong);
}
/* Hierarchy 视图里的节点图标比会话列表略小，并与文件夹图标同宽以对齐 */
.file-row-icon { width: 26px; height: 26px; }
.file-row-icon svg { width: 13px; height: 13px; }
.file-row[data-type="idea"] .file-row-icon { background: var(--cb-badge-bg); color: var(--cb-badge-fg); }
.file-row[data-type="knowledge"] .file-row-icon { background: var(--nt-badge-bg); color: var(--nt-badge-fg); }
.file-row[data-type="prompt"] .file-row-icon { background: var(--ct-badge-bg); color: var(--ct-badge-fg); }
.file-row[data-type="loop"] .file-row-icon { background: var(--lp-badge-bg); color: var(--lp-badge-fg); }
.file-row-body {
    flex: 1;
    min-width: 0;
}
.file-row-title {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-row-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
.file-row-act {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--text-faint);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.file-row-act:hover {
    background: var(--hover);
    color: var(--accent);
}
.file-row-act svg { width: 17px; height: 17px; }

.user-folder-head {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 46px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
    transition: background 0.12s;
}
.user-folder-head:hover {
    background: var(--hover);
}
.user-folder-head .files-folder-chev {
    color: var(--text-faint);
    transition: transform 0.15s;
}
.user-folder-head.open .files-folder-chev {
    transform: rotate(90deg);
}
.user-folder-head .files-folder-chev svg { width: 13px; height: 13px; }
/* 文件夹图标：与叶子节点图标同尺寸、左对齐，但不带底色徽标——只用线框图标本身着色 */
.user-folder-icon {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: none;
    color: var(--nt-badge-fg);
}
.user-folder-icon svg { width: 18px; height: 18px; }
.user-folder-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-folder-menu {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--text-faint);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.user-folder-menu:hover {
    background: var(--hover);
    color: var(--text);
}
.user-folder-menu svg { width: 16px; height: 16px; }

/* ===== Bottom Nav Bar ===== */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    /* iPhone: env(safe-area-inset-bottom) 给 home indicator 留白（需 meta viewport-fit=cover），桌面端为 0 */
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding: 0 16px env(safe-area-inset-bottom, 0px);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1200;
}
body.sidebar-open #bottom-nav {
    right: calc(100vw - var(--tl-col)); /* desktop: nav stays under the main-view column, beside the sidebar */
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    padding: 6px 20px;
    cursor: pointer;
    border-radius: 8px;
    transition: color 0.15s, background 0.15s;
}
.bottom-nav-item:hover {
    color: var(--text);
    background: var(--hover);
}
.bottom-nav-item.active {
    color: var(--accent);
}
.bottom-nav-item.active svg {
    stroke: var(--accent);
}

/* ===== Skills：可用 Skill 列表与详情 ===== */
.skills-wrap { width: 100%; max-width: 640px; margin: 0 auto; padding: 12px 16px 28px; }
.skill-agent-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 12px; padding: 3px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); }
.skill-agent-tab { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--text-muted); font-size: 12px; cursor: pointer; }
.skill-agent-tab:hover { color: var(--text); background: var(--hover); }
.skill-agent-tab.active { color: var(--accent); background: var(--accent-soft); font-weight: 650; }
.skill-agent-tab-count { min-width: 18px; padding: 1px 5px; border-radius: 999px; background: var(--surface-3); color: var(--text-faint); font-size: 9.5px; font-weight: 500; }
.skill-agent-tab.active .skill-agent-tab-count { background: var(--accent); color: var(--accent-ink); }
.skills-loading, .skill-detail-loading, .skill-detail-error { padding: 28px 16px; color: var(--text-muted); font-size: 13px; text-align: center; }
.skills-filter-empty { padding: 36px 16px; color: var(--text-faint); font-size: 12.5px; text-align: center; }
.skill-detail-error { color: #e5534b; }
.skills-summary { display: flex; align-items: center; gap: 7px; color: var(--text-muted); font-size: 12px; padding: 2px 4px 14px; }
.skills-summary svg { width: 15px; height: 15px; color: var(--accent); }
.skills-summary strong { color: var(--text); }
.skills-section { margin-bottom: 20px; }
.skills-section-head { display: flex; align-items: baseline; gap: 8px; padding: 0 4px 7px; font-size: 12px; font-weight: 700; color: var(--text); }
.skills-section-hint { font-size: 10.5px; font-weight: 400; color: var(--text-faint); }
.skills-count { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--surface-2); color: var(--text-muted); text-align: center; font-size: 10px; }
.skills-list { overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.skill-row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: inherit; text-align: left; cursor: pointer; }
.skill-row:last-child { border-bottom: 0; }
.skill-row:hover { background: var(--hover); }
.skill-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--hover); }
.skill-row-icon { width: 30px; height: 30px; flex: 0 0 30px; display: flex; align-items: center; justify-content: center; border-radius: 9px; color: var(--accent); background: var(--accent-soft); }
.skill-row-icon svg { width: 15px; height: 15px; }
.skill-row-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.skill-row-title { font-size: 13px; font-weight: 650; color: var(--text); }
.skill-row-description { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: var(--text-muted); }
.skill-row-meta { display: flex; align-items: center; gap: 7px; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 10px; color: var(--text-faint); }
.skill-agent, .skill-scope-badge { display: inline-flex; align-items: center; flex-shrink: 0; padding: 1px 6px; border-radius: 999px; background: var(--surface-3); color: var(--text-muted); font-size: 10px; }
.skill-agent[data-agent="codex"] { color: #2787d8; background: rgba(39, 135, 216, 0.12); }
.skill-agent[data-agent="claude"] { color: #d97745; background: rgba(217, 119, 69, 0.13); }
.skill-row-chevron { width: 15px; height: 15px; flex-shrink: 0; color: var(--text-faint); }
.skill-row-actions { display: flex; align-items: center; flex-shrink: 0; }
.skill-delete { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 7px; color: var(--text-faint); opacity: 0; transition: opacity 0.15s, color 0.15s, background 0.15s; }
.skill-delete svg { width: 14px; height: 14px; }
.skill-row:hover .skill-delete, .skill-delete:focus-visible { opacity: 1; }
.skill-delete:hover, .skill-delete:focus-visible { color: #e5534b; background: #e5534b14; outline: none; }
.skill-detail { padding: 14px 16px 28px; }
.skill-detail-head { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.skill-detail-name { font-size: 17px; font-weight: 750; color: var(--text); word-break: break-word; }
.skill-detail-badges { display: flex; gap: 6px; margin-top: 8px; }
.skill-scope-badge { background: var(--accent-soft); color: var(--accent); }
.skill-detail-description { margin-top: 10px; font-size: 12.5px; line-height: 1.55; color: var(--text-muted); }
.skill-detail-location { margin-top: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10.5px; color: var(--text-faint); word-break: break-all; }
.skill-detail-source { margin-top: 14px; }
.skill-detail-source-head { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.skill-detail-source-head .skill-detail-location { margin-top: 0; }
.skill-detail-content { margin: 0; padding: 14px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.skill-detail-truncated { margin-top: 8px; color: var(--text-faint); font-size: 11px; }
.skill-detail-deleted { margin: 18px 16px; padding: 12px; border: 1px solid #e5534b44; border-radius: 10px; background: #e5534b14; color: #e5534b; font-size: 12.5px; text-align: center; }
.skill-topology { height: 100%; min-height: 0; display: flex; flex-direction: column; padding: 14px 16px 12px; }
.skill-topology-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 11px; }
.skill-topology-title { color: var(--text); font-size: 14px; font-weight: 700; }
.skill-topology-hint { margin-top: 4px; color: var(--text-faint); font-size: 10.5px; }
.skill-topology-hint code { padding: 1px 5px; border-radius: 5px; background: var(--surface-2); color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.skill-topology-stats { flex-shrink: 0; padding: 4px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-muted); font-size: 10px; }
.skill-topology-canvas { flex: 1; min-height: 260px; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-sunken); }
.skill-topology-svg { display: block; width: 100%; height: 100%; min-height: 260px; cursor: grab; touch-action: none; }
.skill-topology-svg.panning { cursor: grabbing; }
.skill-graph-bg { fill: transparent; }
.skill-graph-edges line { stroke: var(--border-strong); stroke-width: 1.1; opacity: 0.58; transition: opacity 0.12s, stroke 0.12s; }
.skill-graph-edges marker path, #skill-graph-arrow path { fill: var(--text-faint); }
.skill-graph-node { cursor: pointer; outline: none; transition: opacity 0.12s; }
.skill-graph-node circle { stroke-width: 2; fill: var(--surface-2); transition: fill 0.12s, stroke 0.12s, filter 0.12s; }
.skill-graph-node text { fill: var(--text-muted); font-size: 9.5px; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; font-weight: 400; paint-order: stroke; stroke: var(--surface-sunken); stroke-width: 2.5px; stroke-linejoin: round; }
.skill-graph-node.scope-project circle { stroke: var(--accent); }
.skill-graph-node.scope-user circle { stroke: #2787d8; }
.skill-graph-node.scope-system circle { stroke: #8f7cc3; }
.skill-graph-node.scope-plugin circle { stroke: var(--ok); }
.skill-graph-node:hover circle, .skill-graph-node:focus-visible circle, .skill-graph-node.related circle { fill: var(--surface-3); filter: drop-shadow(0 0 5px var(--accent-border)); }
.skill-graph-node:hover text, .skill-graph-node:focus-visible text, .skill-graph-node.related text { fill: var(--text); font-weight: 650; }
.skill-graph-node.dimmed, .skill-graph-edges line.dimmed { opacity: 0.12; }
.skill-graph-edges line.related { opacity: 1; stroke: var(--accent); stroke-width: 1.8; }
.skill-topology-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding-top: 10px; color: var(--text-faint); font-size: 9.5px; }
.skill-topology-legend span { display: inline-flex; align-items: center; gap: 4px; }
.skill-topology-legend i { width: 7px; height: 7px; border: 2px solid; border-radius: 50%; }
.skill-topology-legend i[data-scope="project"] { border-color: var(--accent); }
.skill-topology-legend i[data-scope="user"] { border-color: #2787d8; }
.skill-topology-legend i[data-scope="system"] { border-color: #8f7cc3; }
.skill-topology-legend i[data-scope="plugin"] { border-color: var(--ok); }
.skill-topology-help { margin-left: auto; }

/* Notes panel (in-page, replaces timeline body) */
#notes-panel {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}
#notes-panel.visible {
    display: flex;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
    .bottom-nav-item { padding-left: 10px; padding-right: 10px; }
    .skill-delete { opacity: 1; }
    .settings-app-https,
    .settings-app-start { display: none; }
    /* Settings modal: single-panel + tab switcher */
    .settings-modal-content {
        width: calc(100vw - 24px);
        padding: 16px 14px 18px;
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px);
        overflow: hidden;
    }
    .settings-mobile-tabs {
        display: flex;
        flex-shrink: 0;
        gap: 0;
        background: var(--surface-2);
        border-radius: 10px;
        padding: 3px;
        margin-bottom: 14px;
    }
    .settings-mobile-tab {
        flex: 1;
        border: none;
        background: none;
        color: var(--text-muted);
        font-size: 13px;
        font-weight: 500;
        padding: 8px 0;
        border-radius: 8px;
        cursor: pointer;
        transition: background 0.15s, color 0.15s;
    }
    .settings-mobile-tab.active {
        background: var(--surface);
        color: var(--text);
        font-weight: 600;
        box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    }
    .settings-body {
        display: block;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    .settings-col-divider {
        display: none;
    }
    .settings-col {
        padding: 0;
        display: none;
        max-height: none;
        overflow: visible;
    }
    .settings-col.active {
        display: block;
    }

    /* Top bar */
    #topbar {
        padding: 0 8px;
        height: 44px;
        width: auto;     /* 移动端恢复全宽（无侧栏并排） */
        right: 0;
    }
    #topbar-left { gap: 4px; }
    #topbar-right { gap: 4px; }
    #topbar-left button { padding: 4px; }
    #project-name-display { font-size: 13px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    /* Timeline full width, leave room for bottom nav (+ iPhone home indicator) */
    #timeline-view {
        top: 44px;
        bottom: calc(56px + env(safe-area-inset-bottom, 0px));
        right: 0 !important;
        width: auto !important; /* override the desktop fixed-column width */
    }

    .conv-list {
        padding: 8px 10px;
        max-width: 100%;
    }

    /* Hierarchy 顶部四标签栏在窄屏收紧：减小内边距/间距、隐藏数字徽标，
       避免四个 tab 撑出横向溢出（桌面端不受影响）。 */
    .files-tab {
        padding: 8px 4px;
        gap: 4px;
        font-size: 12px;
    }
    .files-tab-count { display: none; }

    /* Mobile Chrome/Safari auto-zoom the page layer when a focused text field has
       font-size < 16px. Force >= 16px on focusable text surfaces so focusing them
       (e.g. tapping the rename pencil to edit a title) doesn't zoom the page. */
    .note-editor, #chat-input, .claudemd-editor, .idea-composer-input, .idea-edit-input,
    input, textarea, select, [contenteditable="true"] {
        font-size: 16px;
    }
    /* These selectors carry higher specificity than the generic `input` rule above,
       so override them explicitly to prevent browser auto-zoom on focus. */
    .sidebar-title-input,
    #login-userid, #login-password {
        font-size: 16px;
    }

    /* Sidebar fullscreen on mobile.
       Height tracks the visual viewport (--app-height, set by JS) so the bottom
       input area stays visible above the on-screen keyboard; falls back to dvh. */
    #sidebar {
        width: 100vw;
        top: 0;
        height: var(--app-height, 100dvh);
        z-index: 2000;
    }
    #sidebar.sidebar-closed {
        transform: translateX(100%);
    }
    body.sidebar-open #timeline-view {
        right: 0 !important;
    }
    /* Mobile: the sidebar covers the screen, so hide the nav + add button underneath it */
    body.sidebar-open #bottom-nav {
        display: none !important;
    }
    body.sidebar-open #add-fab {
        display: none !important;
    }
    /* Back chevron: a touch more tap area on mobile */
    #sidebar-close {
        padding: 6px 8px;
    }
    /* Fullscreen sidebar: keep the chat input clear of the iPhone home indicator */
    #chat-input-area {
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    /* Login modal */
    .modal-content {
        min-width: unset;
        width: 90vw;
        padding: 24px 20px;
    }

}

/* ==================== Ideation 模式胶囊切换（header 右侧）==================== */
#goal-mode-capsule {
    display: flex;
    align-items: center;
    background: var(--surface, rgba(0,0,0,0.06));
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2px;
    gap: 0;
    flex-shrink: 0;
}
.gmc-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 24px;
    padding: 0 10px;
    border-radius: 14px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}
.gmc-btn[data-mode="chat"].active {
    background: rgba(0,0,0,0.12);
    color: var(--text);
}
.gmc-btn[data-mode="goal"].active {
    background: #16a34a;
    color: #fff;
}

#idea-mode-capsule {
    display: flex;
    align-items: center;
    background: var(--surface, rgba(0,0,0,0.06));
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2px;
    gap: 0;
    flex-shrink: 0;
}
.imc-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    padding: 0;
}
.imc-btn.active {
    background: var(--accent);
    color: var(--accent-ink);
}

/* ==================== 同步会议模式 ==================== */
.meeting-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0 0 12px 0;
}
.meeting-status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px 8px;
    font-size: 13px;
    color: var(--text-muted);
}
.meeting-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    transition: background 0.3s;
}
.meeting-dot.meeting-dot-active {
    background: #ef4444;
    box-shadow: 0 0 0 3px rgba(239,68,68,0.2);
    animation: meeting-pulse 1.2s infinite;
}
@keyframes meeting-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(239,68,68,0.2); }
    50% { box-shadow: 0 0 0 6px rgba(239,68,68,0.08); }
}
.meeting-transcript {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.meeting-hint {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 24px 0;
    line-height: 1.6;
}
.meeting-line {
    display: flex;
    gap: 8px;
    align-items: baseline;
    font-size: 14px;
    line-height: 1.6;
    animation: meeting-fadein 0.2s ease;
}
@keyframes meeting-fadein {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}
.meeting-interim {
    opacity: 0.55;
}
.meeting-speaker {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent, #3b82f6);
    white-space: nowrap;
    flex-shrink: 0;
    padding-top: 2px;
}
.meeting-text {
    color: var(--text);
    word-break: break-all;
}
.meeting-controls {
    display: flex;
    gap: 10px;
    padding: 8px 16px 0;
    flex-shrink: 0;
}
.meeting-btn-start {
    flex: 1;
    padding: 10px 0;
    border-radius: 8px;
    border: none;
    background: var(--accent, #3b82f6);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.meeting-btn-start:disabled { opacity: 0.5; cursor: not-allowed; }
.meeting-btn-save {
    padding: 10px 18px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
}
.meeting-btn-save:hover { background: var(--hover-bg, rgba(0,0,0,0.05)); }

/* ==================== 声纹注册面板 ==================== */
.meeting-voiceprint-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    flex-wrap: wrap;
    flex-shrink: 0;
}
.mvp-members {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex: 1;
}
.mvp-member {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 4px;
    border-radius: 16px;
    border: 1.5px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}
.mvp-member.registered {
    border-color: var(--accent);
    color: var(--accent);
}
.mvp-member.self {
    border-color: var(--border-strong);
    color: var(--text);
}
.mvp-avatar {
    width: 18px; height: 18px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700; color: #fff;
    flex-shrink: 0;
    object-fit: cover;
}
.mvp-avatar-action {
    position: relative;
    display: inline-flex;
    width: 22px;
    height: 22px;
    align-items: center;
    justify-content: center;
    padding: 2px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    color: inherit;
}
.mvp-avatar-action:hover,
.mvp-avatar-action:focus-visible {
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    box-shadow: 0 0 0 2px var(--accent-border);
    outline: none;
}
.mvp-avatar-action:disabled { cursor: wait; opacity: 0.65; }
.mvp-avatar-action.busy .mvp-avatar { animation: mvp-pulse 1s ease-in-out infinite; }
.mvp-avatar-mic {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 12px;
    height: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--surface);
    font-size: 7px;
    line-height: 1;
    box-shadow: 0 0 0 1px var(--border);
}
@keyframes mvp-pulse { 50% { opacity: 0.5; transform: scale(0.92); } }
.mvp-name { font-size: 12px; }
.mvp-check { font-size: 11px; }
.mvp-voiceprint-tip {
    color: var(--text-muted);
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
}
/* ==================== 声纹注册展开面板 ==================== */
.mvp-enroll-panel {
    width: 100%;
    margin-top: 8px;
    padding: 12px;
    background: var(--surface);
    border-radius: 10px;
    border: 1.5px solid var(--accent);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.mvp-enroll-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.mvp-enroll-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.mvp-countdown {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
    transition: background 0.3s;
}
.mvp-read-prompt {
    font-size: 11px;
    color: var(--text-muted);
}
.mvp-read-text {
    font-size: 14px;
    line-height: 1.65;
    color: var(--text);
    background: var(--surface-2);
    padding: 10px 12px;
    border-radius: 8px;
}
.mvp-waveform {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 38px;
    padding: 0 2px;
}
.mvp-bar {
    flex: 1;
    background: var(--accent);
    border-radius: 2px;
    height: 4px;
    transition: height 0.12s ease;
    opacity: 0.7;
}
.mvp-progress-track {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}
.mvp-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    width: 0%;
    transition: width 1s linear;
}
.mvp-enroll-uploading {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}
.mvp-spinner {
    width: 14px; height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: mvp-spin 0.8s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}
@keyframes mvp-spin { to { transform: rotate(360deg); } }
.mvp-enroll-error {
    font-size: 12px;
    color: #e53e3e;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.mvp-retry-btn {
    padding: 2px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    cursor: pointer;
    font-size: 11px;
    color: var(--text-muted);
}
