﻿    :root {
      --bg-body: #0A1128;
      --bg-sidebar: #0A1128;
      --bg-card: #1C2541;
      --bg-card-hover: #263268;
      --bg-input: #141B36;
      --bg-button: #E2B05F;
      --bg-button-hover: #c99a4f;
      --bg-button-text: #0A1128;
      --bg-nav-active: rgba(226, 176, 95, 0.14);
      --border: #161E3A;
      --border-light: #2A3462;
      --text-primary: #E0E1DD;
      --text-secondary: #a5a7a1;
      --text-muted: #6e7069;
      --priority-high: #ef4444;
      --priority-medium: #f59e0b;
      --priority-low: #5BC0BE;
      --col-dot: #5BC0BE;
      --avatar-agent: #E2B05F;
      --avatar-human: #5BC0BE;
      --accent: #E2B05F;
      --accent-secondary: #5BC0BE;
      --sidebar-w: 210px;
    }

    /* ---- Light theme overrides ---- */
    [data-theme="light"] {
      --bg-body: #f7f8fb;
      --bg-sidebar: #ffffff;
      --bg-card: #ffffff;
      --bg-card-hover: #f1f2f7;
      --bg-input: #f1f2f7;
      --bg-button-text: #0A1128;
      --bg-nav-active: rgba(226, 176, 95, 0.12);
      --border: #e4e6ee;
      --border-light: #d6d9e3;
      --text-primary: #1C2541;
      --text-secondary: #525867;
      --text-muted: #8a8f9e;
      --col-dot: #5BC0BE;
    }
    [data-theme="light"] body { color: var(--text-primary); }

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

    body {
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
      background: var(--bg-body);
      color: var(--text-primary);
      height: 100vh;
      height: 100dvh;
      overflow: hidden;
    }

    ::-webkit-scrollbar { width: 6px; height: 6px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
    ::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

    /* ---- Layout ---- */
    .layout { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

    /* ---- Sidebar ---- */
    .sidebar {
      width: var(--sidebar-w);
      background: var(--bg-sidebar);
      border-right: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      flex-shrink: 0;
      z-index: 100;
    }
    .sb-hdr {
      padding: 14px 16px;
      display: flex;
      align-items: center;
      gap: 10px;
      border-bottom: 1px solid var(--border);
    }
    .sb-logo {
      width: 28px; height: 28px;
      background: var(--bg-button);
      border-radius: 7px;
      display: flex; align-items: center; justify-content: center;
    }
    .sb-logo .material-symbols-outlined { font-size: 16px; color: var(--bg-button-text); }
    .sb-hdr h1 { font-size: 14.5px; font-weight: 600; letter-spacing: -0.2px; }
    .sb-close {
      display: none; margin-left: auto; background: none; border: none;
      color: var(--text-muted); cursor: pointer; padding: 4px;
    }
    .sb-nav { padding: 8px; flex: 1; overflow-y: auto; }
    .sb-footer { padding: 8px; border-top: 1px solid var(--border); }
    .nav-logout {
      display: flex; align-items: center; gap: 10px;
      padding: 8px 10px; border-radius: 8px;
      cursor: pointer; color: var(--text-muted);
      font-size: 13px; transition: all 0.15s; user-select: none;
      background: none; border: none; width: 100%; font-family: inherit;
      -webkit-tap-highlight-color: transparent;
    }
    .nav-logout:hover { background: rgba(239,68,68,0.1); color: #ef4444; }
    .nav-logout .material-symbols-outlined { font-size: 19px; width: 20px; text-align: center; }
    .nav-item {
      display: flex; align-items: center; gap: 10px;
      padding: 8px 10px; border-radius: 8px;
      cursor: pointer; color: var(--text-secondary);
      font-size: 13.5px; transition: all 0.15s; user-select: none;
      -webkit-tap-highlight-color: transparent;
    }
    .nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text-primary); }
    .nav-item.active { background: var(--bg-nav-active); color: var(--text-primary); font-weight: 500; }
    .nav-item .material-symbols-outlined { font-size: 19px; width: 20px; text-align: center; }

    /* ---- Sidebar overlay (mobile) ---- */
    .sidebar-overlay {
      display: none; position: fixed; inset: 0;
      background: rgba(0,0,0,0.5); z-index: 99;
    }

    /* ---- Mobile top bar ---- */
    .mobile-topbar {
      display: none;
      padding: 10px 16px;
      align-items: center;
      gap: 10px;
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
      background: var(--bg-body);
    }
    .hamburger {
      background: none; border: none; color: var(--text-primary);
      cursor: pointer; padding: 4px; display: flex; align-items: center;
      -webkit-tap-highlight-color: transparent;
    }
    .hamburger .material-symbols-outlined { font-size: 24px; }
    .mobile-topbar h1 { font-size: 14.5px; font-weight: 600; letter-spacing: -0.2px; }

    /* ---- Main ---- */
    .main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

    /* ---- Action bar ---- */
    .action-bar { padding: 14px 24px; display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }
    .btn {
      padding: 7px 14px; border-radius: 8px; border: none;
      cursor: pointer; font-size: 13px; font-weight: 500;
      transition: all 0.15s; font-family: inherit; line-height: 1.4;
      -webkit-tap-highlight-color: transparent;
    }
    .btn-primary { background: var(--bg-button); color: var(--bg-button-text); font-weight: 600; }
    .btn-primary:hover { background: var(--bg-button-hover); }
    .btn-secondary { background: var(--bg-card); color: var(--text-secondary); border: 1px solid var(--border-light); }
    .btn-secondary:hover { color: var(--text-primary); background: var(--bg-card-hover); }
    .btn-filter {
      background: transparent; color: var(--text-secondary);
      border: 1px solid var(--border-light); padding: 7px 14px;
    }
    .btn-filter:hover, .btn-filter.active { color: var(--text-primary); background: rgba(255,255,255,0.04); }
    .btn-danger { background: var(--priority-high); color: white; }
    .btn-danger:hover { background: #dc2626; }
    .filter-dd {
      background: var(--bg-input); color: var(--text-secondary);
      border: 1px solid var(--border-light); padding: 7px 12px;
      border-radius: 8px; font-size: 13px; font-family: inherit; cursor: pointer;
    }

    .mfa-panel {
      margin: 20px 24px 8px;
      padding: 16px;
      border: 1px solid var(--border-light);
      border-radius: 8px;
      background: var(--bg-card);
    }
    .mfa-panel.required { border-color: rgba(245,158,11,0.55); }
    .mfa-panel-main, .mfa-policy, .mfa-inline-form, .mfa-actions, .mfa-status-line {
      display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    }
    .mfa-panel-main { justify-content: space-between; }
    .mfa-title { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 14px; }
    .mfa-title .material-symbols-outlined { color: var(--accent); font-size: 20px; }
    .mfa-status-line { margin-top: 8px; }
    .mfa-pill { padding: 3px 8px; border-radius: 999px; font-size: 11px; border: 1px solid var(--border-light); color: var(--text-secondary); }
    .mfa-pill.on { color: #5BC0BE; border-color: rgba(91,192,190,0.35); background: rgba(91,192,190,0.08); }
    .mfa-pill.off, .mfa-pill.warn { color: #f59e0b; border-color: rgba(245,158,11,0.35); background: rgba(245,158,11,0.08); }
    .mfa-policy { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
    .mfa-toggle, .mfa-grace { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 13px; }
    .mfa-grace input, .mfa-inline-form input {
      background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border-light);
      border-radius: 8px; padding: 7px 10px; font: inherit;
    }
    .mfa-grace input { width: 72px; }
    .mfa-setup { margin-top: 14px; display: grid; grid-template-columns: 168px minmax(220px, 1fr); gap: 14px; align-items: center; }
    .mfa-setup canvas { background: white; border-radius: 8px; padding: 8px; }
    .mfa-manual-key { font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--text-secondary); word-break: break-all; }
    .mfa-backup-codes { margin-top: 14px; display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
    .mfa-backup-codes code { padding: 7px 8px; border-radius: 6px; background: var(--bg-input); color: var(--text-primary); text-align: center; }
    .mfa-error { margin-top: 10px; color: #ef4444; font-size: 12px; }

    /* ---- Kanban ---- */
    .kanban { flex: 1; display: flex; gap: 12px; padding: 0 24px 20px; overflow-x: auto; min-height: 0; }
    .column { min-width: 250px; flex: 1; display: flex; flex-direction: column; }
    .col-hdr {
      display: flex; align-items: center; gap: 8px;
      padding: 8px 4px; margin-bottom: 8px; flex-shrink: 0;
    }
    .col-dot { width: 8px; height: 8px; border-radius: 50%; }
    .col-name { font-size: 13.5px; font-weight: 500; color: var(--text-secondary); }
    .col-count { font-size: 13px; color: var(--text-muted); }
    .col-add-btn {
      margin-left: auto; width: 22px; height: 22px;
      background: transparent; border: 1px solid var(--border-light);
      border-radius: 5px; color: var(--text-muted);
      cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 15px;
    }
    .col-add-btn:hover { color: var(--text-primary); border-color: var(--text-muted); }
    .col-cards {
      flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
      padding: 2px; border-radius: 8px; min-height: 40px;
      transition: background 0.15s, outline 0.15s;
    }
    .col-cards.drag-over {
      background: rgba(226, 176, 95, 0.06);
      outline: 2px dashed rgba(226, 176, 95, 0.3);
      outline-offset: -2px;
    }
    .col-empty { color: var(--text-muted); font-size: 12.5px; text-align: center; padding: 16px 0; }

    /* ---- Card ---- */
    .card {
      background: var(--bg-card); border: 1px solid var(--border);
      border-radius: 10px; padding: 13px 14px; cursor: grab;
      transition: background 0.12s, border-color 0.12s, transform 0.12s;
      -webkit-tap-highlight-color: transparent;
    }
    .card:hover { background: var(--bg-card-hover); border-color: var(--border-light); }
    .card.dragging { opacity: 0.4; transform: scale(0.97); }
    .card-top { display: flex; align-items: flex-start; gap: 8px; }
    .dot {
      width: 8px; height: 8px; border-radius: 50%;
      margin-top: 5px; flex-shrink: 0;
    }
    .dot.high { background: var(--priority-high); }
    .dot.medium { background: var(--priority-medium); }
    .dot.low { background: var(--priority-low); }
    .card-title {
      font-size: 13.5px; font-weight: 500; line-height: 1.35;
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
    }
    .card-desc {
      font-size: 12px; color: var(--text-secondary); margin-top: 4px;
      line-height: 1.4; overflow: hidden; text-overflow: ellipsis;
      display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
      padding-left: 16px;
    }
    .card-foot {
      display: flex; align-items: center; gap: 8px;
      margin-top: 10px; padding-left: 16px;
    }
    .avatar {
      width: 20px; height: 20px; border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      font-size: 10px; font-weight: 700; color: white; flex-shrink: 0;
    }
    .avatar.agent { background: var(--avatar-agent); color: var(--bg-button-text); }
    .avatar.human { background: var(--avatar-human); color: var(--bg-button-text); }
    .card-proj {
      font-size: 11.5px; color: var(--text-secondary);
      display: flex; align-items: center; gap: 4px;
    }
    .proj-dot { width: 6px; height: 6px; border-radius: 50%; }
    .card-time { margin-left: auto; font-size: 11px; color: var(--text-muted); white-space: nowrap; }

    /* ---- Card status actions (mobile) ---- */
    .card-actions {
      display: none;
      gap: 4px; margin-top: 8px; padding-left: 16px; flex-wrap: wrap;
    }
    .card-actions .card-move-btn {
      background: var(--bg-input); border: 1px solid var(--border-light);
      color: var(--text-secondary); font-size: 10px; padding: 3px 8px;
      border-radius: 5px; cursor: pointer; font-family: inherit;
      -webkit-tap-highlight-color: transparent;
    }
    .card-actions .card-move-btn:hover,
    .card-actions .card-move-btn:active { color: var(--text-primary); border-color: var(--bg-button); }

    /* ---- Modal ---- */
    .modal-bg {
      position: fixed; inset: 0; background: rgba(0,0,0,0.55);
      z-index: 200; display: flex; align-items: center; justify-content: center;
      padding: 16px;
    }
    .modal {
      background: #1C2541; border: 1px solid var(--border-light);
      border-radius: 14px; padding: 24px; width: 500px; max-width: 100%;
      max-height: 90vh; max-height: 90dvh; overflow-y: auto;
      box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    }
    .modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 18px; }
    .field { margin-bottom: 14px; }
    .field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; font-weight: 500; }
    .field input, .field textarea, .field select {
      width: 100%; background: var(--bg-input); border: 1px solid var(--border-light);
      border-radius: 8px; padding: 9px 12px; color: var(--text-primary);
      font-family: inherit; font-size: 16px; outline: none;
    }
    .field input:focus, .field textarea:focus, .field select:focus {
      border-color: var(--bg-button);
    }
    .field textarea { height: 72px; resize: vertical; }
    .field-row { display: flex; gap: 12px; }
    .field-row .field { flex: 1; }
    .modal-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

    .session-timeout-modal-bg {
      position: fixed; inset: 0; background: rgba(0,0,0,0.68);
      z-index: 500; display: none; align-items: center; justify-content: center;
      padding: 16px; backdrop-filter: blur(6px);
    }
    .session-timeout-modal-bg.visible { display: flex; }
    .session-timeout-modal {
      background: var(--bg-card); border: 1px solid var(--border-light);
      border-radius: 18px; padding: 24px; width: 420px; max-width: 100%;
      box-shadow: 0 24px 80px rgba(0,0,0,0.5); text-align: center;
    }
    .session-timeout-icon {
      width: 52px; height: 52px; border-radius: 50%; margin: 0 auto 14px;
      display: flex; align-items: center; justify-content: center;
      background: rgba(226,176,95,0.16); color: var(--bg-button);
    }
    .session-timeout-icon .material-symbols-outlined { font-size: 28px; }
    .session-timeout-modal h3 { margin: 0 0 8px; font-size: 18px; font-weight: 700; }
    .session-timeout-modal p { margin: 0; color: var(--text-secondary); font-size: 13px; line-height: 1.5; }
    .session-timeout-countdown {
      display: inline-flex; margin-top: 16px; padding: 7px 12px; border-radius: 999px;
      background: rgba(239,68,68,0.12); color: #f87171; font-weight: 700; font-variant-numeric: tabular-nums;
    }

    /* ---- Chat ---- */
    .chat-view { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
    .chat-hdr {
      padding: 12px 20px; border-bottom: 1px solid var(--border);
      display: flex; align-items: center; gap: 12px; flex-shrink: 0;
      background: var(--bg-sidebar);
    }
    .chat-hdr h2 { font-size: 16px; font-weight: 600; margin: 0; flex: 1; }
    .chat-hdr .agent-status {
      font-size: 11px; color: #5BC0BE; font-weight: 400;
    }
    .chat-hdr .agent-status::before {
      content: ''; display: inline-block; width: 6px; height: 6px;
      border-radius: 50%; background: #5BC0BE; margin-right: 5px;
      vertical-align: middle;
    }
    .hdr-avatar {
      width: 36px; height: 36px; border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      font-size: 15px; font-weight: 700; color: white; flex-shrink: 0;
      text-transform: uppercase; letter-spacing: -0.5px;
    }
    .hdr-avatar img {
      width: 100%; height: 100%; border-radius: 50%; object-fit: cover;
    }
    .chat-msgs {
      flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px 12px;
      display: flex; flex-direction: column; gap: 10px;
      background: var(--bg-body);
      background-image: radial-gradient(circle at 20% 50%, rgba(226,176,95,0.03) 0%, transparent 50%),
                        radial-gradient(circle at 80% 20%, rgba(91,192,190,0.03) 0%, transparent 50%);
      scroll-behavior: smooth;
    }
    .msg { display: flex; gap: 8px; max-width: 85%; animation: msgIn 0.2s ease-out; min-width: 0; }
    @keyframes msgIn {
      from { opacity: 0; transform: translateY(8px); }
      to { opacity: 1; transform: translateY(0); }
    }
    .msg.user { flex-direction: row-reverse; align-self: flex-end; }
    .msg.assistant { align-self: flex-start; }
    .msg-avatar {
      width: 28px; height: 28px; border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      font-size: 10px; font-weight: 700; color: white; flex-shrink: 0;
      margin-top: 2px;
    }
    .msg-avatar.user { background: var(--bg-button); color: var(--bg-button-text); }
    .msg-avatar.assistant { background: var(--avatar-human); }
    .msg-bubble {
      padding: 10px 14px; border-radius: 16px;
      font-size: 14px; line-height: 1.5; position: relative;
      word-wrap: break-word; overflow-wrap: break-word;
      min-width: 0; overflow: hidden;
    }
    .msg-bubble.user {
      background: var(--bg-button); border-bottom-right-radius: 4px;
      color: var(--bg-button-text);
    }
    .msg-bubble.assistant {
      background: var(--bg-card); border: 1px solid var(--border);
      border-bottom-left-radius: 4px;
    }
    .msg-meta {
      display: flex; align-items: center; justify-content: flex-end;
      gap: 6px; margin-top: 2px;
    }
    .msg-time {
      font-size: 10px; color: rgba(10,17,40,0.55);
      white-space: nowrap;
    }
    .msg-bubble.assistant .msg-time { color: var(--text-muted); }
    .msg-content { word-break: break-word; min-width: 0; overflow: hidden; }
    .msg-content p { margin: 0 0 6px 0; }
    .msg-content p:last-child { margin-bottom: 0; }
    .msg-content code {
      background: rgba(0,0,0,0.25); padding: 2px 6px; border-radius: 4px;
      font-size: 13px; font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
      word-break: break-all;
    }
    .msg-content pre {
      background: rgba(0,0,0,0.35); border-radius: 10px; padding: 12px 14px;
      overflow-x: auto; margin: 8px 0; font-size: 12.5px; line-height: 1.5;
      border: 1px solid rgba(255,255,255,0.06);
      max-width: 100%; box-sizing: border-box;
    }
    .msg-content pre code { background: none; padding: 0; font-size: 12.5px; word-break: normal; }
    .msg-content strong { font-weight: 600; }
    .msg-content em { font-style: italic; }
    .msg-content del { text-decoration: line-through; opacity: 0.7; }
    .msg-content h2, .msg-content h3, .msg-content h4 {
      font-weight: 600; margin: 8px 0 4px; line-height: 1.3;
    }
    .msg-content h2 { font-size: 16px; }
    .msg-content h3 { font-size: 15px; }
    .msg-content h4 { font-size: 14px; }
    .msg-content ul, .msg-content ol { margin: 4px 0; padding-left: 20px; }
    .msg-content li { margin-bottom: 3px; }
    .msg-content blockquote {
      border-left: 3px solid var(--bg-button); margin: 6px 0;
      padding: 4px 12px; color: var(--text-secondary);
      background: rgba(226,176,95,0.06); border-radius: 0 6px 6px 0;
    }
    .msg-content hr {
      border: none; border-top: 1px solid var(--border-light);
      margin: 8px 0;
    }
    .msg-content table {
      border-collapse: collapse; font-size: 12.5px; margin: 6px 0;
      width: 100%; overflow-x: auto; display: block;
    }
    .msg-content th, .msg-content td {
      border: 1px solid var(--border-light); padding: 4px 8px; text-align: left;
      white-space: nowrap;
    }
    .msg-content th { background: rgba(0,0,0,0.15); font-weight: 600; }
    .msg-content a {
      color: #E2B05F; text-decoration: none; border-bottom: 1px solid rgba(226,176,95,0.35);
      word-break: break-all;
    }
    .msg-content a:hover { border-bottom-color: #E2B05F; }
    .msg-bubble.user .msg-content a { color: rgba(10,17,40,0.9); border-bottom-color: rgba(10,17,40,0.35); }
    .msg-bubble.user .msg-content a:hover { border-bottom-color: rgba(10,17,40,0.7); }
    .msg-bubble.user .msg-content code { background: rgba(10,17,40,0.18); }
    .msg-bubble.user .msg-content pre { background: rgba(10,17,40,0.22); border-color: rgba(10,17,40,0.12); }
    .msg-bubble.user .msg-content blockquote { border-left-color: rgba(10,17,40,0.5); background: rgba(10,17,40,0.1); color: rgba(10,17,40,0.8); }

    /* Date separators */
    .date-separator {
      display: flex; align-items: center; justify-content: center;
      padding: 8px 0; max-width: 100%;
    }
    .date-separator-label {
      background: rgba(255,255,255,0.08); color: var(--text-secondary);
      padding: 4px 14px; border-radius: 12px; font-size: 12px; font-weight: 500;
      white-space: nowrap;
    }

    /* Scroll-to-bottom FAB */
    .scroll-bottom-fab {
      position: absolute; bottom: 80px; right: 16px;
      width: 40px; height: 40px; border-radius: 50%;
      background: var(--bg-card); border: 1px solid var(--border-light);
      color: var(--text-secondary); cursor: pointer;
      display: none; align-items: center; justify-content: center;
      box-shadow: 0 2px 8px rgba(0,0,0,0.3);
      z-index: 10; transition: opacity 0.2s, transform 0.2s;
    }
    .scroll-bottom-fab.visible { display: flex; }
    .scroll-bottom-fab:hover { background: var(--bg-hover); }
    .scroll-bottom-fab .unread-badge {
      position: absolute; top: -6px; right: -6px;
      background: var(--bg-button); color: var(--bg-button-text);
      font-size: 10px; font-weight: 700; border-radius: 10px;
      min-width: 18px; height: 18px; display: flex;
      align-items: center; justify-content: center; padding: 0 4px;
    }

    /* Chat loading states */
    .chat-skeleton {
      display: flex; align-items: center; justify-content: center;
      height: 100%; min-height: 200px;
    }
    .chat-skel-spinner {
      width: 28px; height: 28px; border-radius: 50%;
      border: 2px solid var(--border-light);
      border-top-color: var(--text-secondary);
      animation: chatSpin 0.8s linear infinite;
    }
    .chat-loading-older {
      text-align: center; padding: 10px; color: var(--text-secondary);
      font-size: 12px; opacity: 0.7;
    }
    @keyframes chatSpin { to { transform: rotate(360deg); } }

    /* Message grouping */
    .msg.grouped { margin-top: -6px; }
    .msg.grouped .msg-avatar { visibility: hidden; }
    .msg.grouped .msg-bubble { border-top-left-radius: 6px; }
    .msg.grouped.user .msg-bubble { border-top-right-radius: 6px; }
    .msg.first-in-group .msg-bubble.assistant { border-bottom-left-radius: 6px; }
    .msg.first-in-group.user .msg-bubble { border-bottom-right-radius: 6px; }

    /* Drag-drop overlay */
    .drag-overlay {
      position: absolute; inset: 0; z-index: 100;
      background: rgba(10,17,40,0.85);
      display: none; align-items: center; justify-content: center;
      border: 3px dashed var(--bg-button); border-radius: 12px;
    }
    .drag-overlay.visible { display: flex; }
    .drag-overlay-text {
      color: #fff; font-size: 18px; font-weight: 600;
      display: flex; flex-direction: column; align-items: center; gap: 8px;
    }
    .drag-overlay-text .material-symbols-outlined { font-size: 48px; color: var(--bg-button); }

    /* Long-press context menu */
    .msg-context-menu {
      position: fixed; z-index: 200;
      background: var(--bg-card); border: 1px solid var(--border-light);
      border-radius: 12px; padding: 4px 0; min-width: 160px;
      box-shadow: 0 4px 20px rgba(0,0,0,0.4);
      animation: msgIn 0.15s ease-out;
    }
    .msg-context-item {
      display: flex; align-items: center; gap: 10px;
      padding: 10px 16px; cursor: pointer; color: var(--text-primary);
      font-size: 14px; transition: background 0.1s;
    }
    .msg-context-item:hover { background: var(--bg-hover); }
    .msg-context-item .material-symbols-outlined { font-size: 18px; color: var(--text-secondary); }
    .msg-context-item.danger { color: #f87171; }
    .msg-context-item.danger .material-symbols-outlined { color: #f87171; }

    /* ---- Reply preview (quoted message in bubble) ---- */
    .reply-preview {
      display: flex; gap: 6px; padding: 6px 8px; margin-bottom: 4px;
      background: rgba(255,255,255,0.05); border-radius: 8px;
      cursor: pointer; transition: background 0.15s;
    }
    .reply-preview:hover { background: rgba(255,255,255,0.1); }
    .reply-preview-bar {
      width: 3px; border-radius: 2px; background: var(--bg-button); flex-shrink: 0;
    }
    .reply-preview-body { min-width: 0; overflow: hidden; }
    .reply-preview-name {
      display: block; font-size: 11px; font-weight: 600; color: var(--bg-button);
      margin-bottom: 1px;
    }
    .reply-preview-text {
      display: block; font-size: 12px; color: var(--text-muted);
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
      max-width: 280px;
    }

    /* ---- Reply bar above composer ---- */
    .reply-bar {
      display: flex; align-items: center; gap: 8px;
      padding: 8px 12px; background: var(--bg-card);
      border-top: 1px solid var(--border-light);
      border-left: 3px solid var(--bg-button);
      animation: slideDown 0.15s ease-out;
    }
    .reply-bar-preview { flex: 1; min-width: 0; overflow: hidden; }
    .reply-bar-name {
      font-size: 12px; font-weight: 600; color: var(--bg-button);
      display: block;
    }
    .reply-bar-text {
      font-size: 12px; color: var(--text-muted);
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .reply-bar-close {
      background: none; border: none; color: var(--text-muted);
      font-size: 18px; cursor: pointer; padding: 4px;
      border-radius: 50%; transition: background 0.1s;
    }
    .reply-bar-close:hover { background: var(--bg-hover); }
    @keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

    /* ---- Reactions row ---- */
    .msg-reactions {
      display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px;
    }
    .reaction-chip {
      display: inline-flex; align-items: center; gap: 3px;
      padding: 2px 8px; border-radius: 12px;
      background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
      cursor: pointer; font-size: 14px; transition: all 0.15s;
      color: var(--text-primary);
    }
    .reaction-chip:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.2); }
    .reaction-chip.mine { background: rgba(226,176,95,0.2); border-color: var(--bg-button); }
    .reaction-count { font-size: 11px; color: var(--text-muted); }
    .reaction-chip.add-reaction {
      padding: 2px 6px; opacity: 0; transition: opacity 0.15s;
    }
    .msg:hover .reaction-chip.add-reaction,
    .msg-reactions:hover .reaction-chip.add-reaction { opacity: 1; }

    /* ---- Emoji picker popup ---- */
    .emoji-picker-popup {
      position: fixed; z-index: 250;
      background: var(--bg-card); border: 1px solid var(--border-light);
      border-radius: 12px; padding: 8px; display: flex; gap: 4px;
      box-shadow: 0 4px 20px rgba(0,0,0,0.4);
      animation: msgIn 0.15s ease-out;
    }
    .emoji-pick-btn {
      font-size: 22px; width: 36px; height: 36px;
      display: flex; align-items: center; justify-content: center;
      background: none; border: none; border-radius: 8px;
      cursor: pointer; transition: background 0.1s;
    }
    .emoji-pick-btn:hover { background: var(--bg-hover); }

    /* ---- Edited badge ---- */
    .msg-edited {
      font-size: 10px; color: var(--text-muted); font-style: italic;
      margin-left: 6px;
    }

    /* ---- Deleted message ---- */
    .msg.deleted .msg-bubble { opacity: 0.5; font-style: italic; }

    /* ---- 3-dot menu button on messages ---- */
    .msg-menu-btn {
      position: absolute; top: 4px; right: -8px;
      background: none; border: none; color: var(--text-muted);
      cursor: pointer; opacity: 0; transition: opacity 0.15s;
      padding: 2px; border-radius: 50%; z-index: 5;
    }
    .msg-menu-btn .material-symbols-outlined { font-size: 16px; }
    .msg:hover .msg-menu-btn { opacity: 0.7; }
    .msg-menu-btn:hover { opacity: 1 !important; background: var(--bg-hover); }
    .msg { position: relative; }

    /* ---- Message highlight (scroll-to target) ---- */
    .msg-highlight { animation: msgHighlight 1.5s ease-out; }
    @keyframes msgHighlight {
      0% { background: rgba(226,176,95,0.3); }
      100% { background: transparent; }
    }

    /* ---- Search modal ---- */
    .search-modal-bg {
      position: fixed; inset: 0; z-index: 300;
      background: rgba(0,0,0,0.6); display: flex;
      align-items: flex-start; justify-content: center;
      padding-top: 80px;
      animation: fadeIn 0.15s ease-out;
    }
    .search-modal {
      width: 100%; max-width: 520px;
      background: var(--bg-card); border: 1px solid var(--border-light);
      border-radius: 16px; overflow: hidden;
      box-shadow: 0 8px 40px rgba(0,0,0,0.5);
      animation: slideDown 0.2s ease-out;
    }
    .search-modal-hdr {
      display: flex; align-items: center; gap: 8px;
      padding: 12px 16px; border-bottom: 1px solid var(--border-light);
    }
    .search-modal-hdr .material-symbols-outlined { color: var(--text-muted); font-size: 20px; }
    .search-input {
      flex: 1; background: none; border: none; color: var(--text-primary);
      font-size: 15px; outline: none;
    }
    .search-input::placeholder { color: var(--text-muted); }
    .search-results {
      max-height: 400px; overflow-y: auto;
    }
    .search-result-item {
      padding: 10px 16px; cursor: pointer;
      border-bottom: 1px solid rgba(255,255,255,0.04);
      transition: background 0.1s;
    }
    .search-result-item:hover { background: var(--bg-hover); }
    .search-result-role {
      font-size: 11px; font-weight: 600; color: var(--bg-button);
      margin-bottom: 2px;
    }
    .search-result-text {
      font-size: 13px; color: var(--text-primary);
      display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
      overflow: hidden;
    }
    .search-result-text mark {
      background: rgba(250, 204, 21, 0.3); color: inherit;
      border-radius: 2px; padding: 0 1px;
    }
    .search-result-time {
      font-size: 11px; color: var(--text-muted); margin-top: 2px;
    }
    .search-loading, .search-empty {
      padding: 24px; text-align: center; color: var(--text-muted);
      font-size: 13px;
    }
    @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

        .streaming .msg-content::after {
      content: ''; display: inline-block;
      width: 2px; height: 16px; background: var(--bg-button);
      animation: cursor-blink 0.8s step-end infinite;
      vertical-align: text-bottom; margin-left: 2px;
    }
    @keyframes cursor-blink { 50% { opacity: 0; } }
    .typing-indicator {
      display: flex; align-items: center; gap: 8px; padding: 6px 0;
    }
    .typing-dots { display: flex; gap: 3px; align-items: center; }
    .typing-dots span {
      width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted);
      animation: typingBounce 1.4s ease-in-out infinite;
      opacity: 0.4;
    }
    .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
    .typing-dots span:nth-child(3) { animation-delay: 0.4s; }
    @keyframes typingBounce {
      0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
      30% { transform: translateY(-5px); opacity: 1; }
    }
    .typing-label {
      font-size: 12px; color: var(--text-muted);
    }
    .typing-timer {
      font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums;
      margin-left: auto;
    }
    /* Thinking/reasoning token display */
    .thinking-section {
      margin-bottom: 8px; border-radius: 8px;
      background: rgba(226, 176, 95, 0.08); border: 1px solid rgba(226, 176, 95, 0.2);
      overflow: hidden; font-size: 13px;
    }
    .thinking-header {
      display: flex; align-items: center; gap: 6px; padding: 8px 12px;
      cursor: pointer; user-select: none; color: var(--accent);
      font-weight: 500;
    }
    .thinking-header:hover { background: rgba(226, 176, 95, 0.05); }
    .thinking-chevron {
      transition: transform 0.2s; font-size: 10px; display: inline-block;
    }
    .thinking-section.collapsed .thinking-chevron { transform: rotate(-90deg); }
    .thinking-section.collapsed .thinking-body { display: none; }
    .thinking-body {
      padding: 0 12px 10px; color: var(--text-muted); line-height: 1.5;
      max-height: 200px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
    }
    .thinking-spinner {
      display: inline-block; width: 12px; height: 12px;
      border: 2px solid rgba(226, 176, 95, 0.3); border-top-color: var(--accent);
      border-radius: 50%; animation: thinkSpin 0.8s linear infinite;
    }
    @keyframes thinkSpin {
      to { transform: rotate(360deg); }
    }
    .thinking-section.done .thinking-spinner { display: none; }
    .thinking-section.done .thinking-header { color: var(--text-muted); }

    /* Tool-use chips (shown below typing indicator during agent work) */
    .tool-chips {
      display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px;
    }
    .tool-chip {
      display: inline-flex; align-items: center; gap: 5px;
      background: rgba(226, 176, 95, 0.12); border: 1px solid rgba(226, 176, 95, 0.25);
      border-radius: 12px; padding: 3px 10px 3px 6px; font-size: 11px;
      color: var(--text-secondary); animation: chipIn 0.2s ease-out;
    }
    @keyframes chipIn {
      from { opacity: 0; transform: scale(0.9); }
      to { opacity: 1; transform: scale(1); }
    }
    .tool-chip-icon {
      font-size: 13px; color: var(--bg-button); animation: toolSpin 2s linear infinite;
    }
    @keyframes toolSpin {
      0% { transform: rotate(0deg); }
      25% { transform: rotate(15deg); }
      50% { transform: rotate(0deg); }
      75% { transform: rotate(-15deg); }
      100% { transform: rotate(0deg); }
    }
    .tool-chip-name { font-weight: 500; }
    .tool-chip-time {
      font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 10px;
    }

    /* Message status ticks (WhatsApp-style) */
    .msg-status {
      display: inline-flex; align-items: center; margin-left: 2px;
    }
    .msg-status .material-symbols-outlined {
      font-size: 14px; font-variation-settings: 'FILL' 0, 'wght' 400;
    }
    .msg-status.queued .material-symbols-outlined { color: rgba(255,255,255,0.35); font-size: 12px; }
    .msg-status.sending .material-symbols-outlined { color: rgba(255,255,255,0.35); }
    .msg-status.sent .material-symbols-outlined { color: rgba(255,255,255,0.5); }
    .msg-status.delivered .material-symbols-outlined { color: #5BC0BE; }
    .msg-status.failed .material-symbols-outlined { color: #f87171; cursor: pointer; }

    /* Stop button (replaces send when agent is busy) */
    .chat-stop {
      width: 40px; height: 40px; border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      padding: 0; flex-shrink: 0;
      background: #ef4444; color: white; border: none; cursor: pointer;
      transition: background 0.15s, transform 0.1s;
      animation: stopPulse 2s ease-in-out infinite;
    }
    .chat-stop:hover { background: #dc2626; }
    .chat-stop:active { transform: scale(0.95); }
    @keyframes stopPulse {
      0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
      50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    }

    /* Agent status transitions in header */
    .agent-status { transition: color 0.2s; }
    .agent-status.agent-status-busy { color: #facc15 !important; }
    .agent-status.agent-status-busy::before { background: #facc15 !important; animation: statusPulse 1.5s ease-in-out infinite; }
    @keyframes statusPulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.4; }
    }

    /* Chat error cards (rate limit, auth, etc.) */
    .msg-bubble.error {
      background: rgba(239, 68, 68, 0.08) !important;
      border-color: rgba(239, 68, 68, 0.25) !important;
    }
    .chat-error-card { padding: 2px 0; }
    .chat-err-header {
      display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
    }
    .chat-err-icon { font-size: 18px; color: #f87171; }
    .chat-err-label {
      font-size: 13px; font-weight: 600; color: #fca5a5;
    }
    .chat-err-code {
      font-weight: 400; font-size: 11px; color: var(--text-muted);
      background: rgba(255,255,255,0.06); padding: 1px 6px;
      border-radius: 4px; margin-left: 4px;
    }
    .chat-err-message {
      font-size: 13px; color: var(--text-secondary); line-height: 1.5;
      margin-bottom: 4px;
    }
    .chat-err-hint {
      font-size: 12px; color: var(--text-muted); line-height: 1.4;
      margin-bottom: 8px; font-style: italic;
    }
    .chat-err-retry {
      display: inline-flex; align-items: center; gap: 4px;
      background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.3);
      color: #fca5a5; border-radius: 8px; padding: 5px 12px;
      font-size: 12px; font-weight: 500; cursor: pointer;
      transition: background 0.15s;
    }
    .chat-err-retry:hover { background: rgba(239, 68, 68, 0.25); }

    .chat-input:disabled { opacity: 0.5; cursor: not-allowed; }
    .chat-bar {
      padding: 10px 16px; border-top: 1px solid var(--border);
      display: flex; gap: 8px; flex-shrink: 0; align-items: center;
      background: var(--bg-sidebar);
    }
    .chat-input {
      flex: 1; border: none; outline: none; font-size: 15px;
      background: transparent; color: var(--text-primary);
      padding: 10px 0; resize: none; overflow-y: auto;
      max-height: 120px; min-height: 20px; line-height: 1.4;
      font-family: inherit;
    }
    .chat-input:focus { border-color: var(--bg-button); }
    .chat-input::placeholder { color: var(--text-muted); }
    .chat-send {
      width: 40px; height: 40px; border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      padding: 0; flex-shrink: 0;
      background: var(--bg-button); color: var(--bg-button-text); border: none; cursor: pointer;
      transition: background 0.15s, transform 0.1s;
    }
    .chat-send:hover { background: var(--bg-button-hover); }
    .chat-send:active { transform: scale(0.95); }
    .attach-btn, .voice-btn {
      width: 40px; height: 40px; border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      background: none; border: none; color: var(--text-muted);
      cursor: pointer; flex-shrink: 0; transition: color 0.15s;
    }
    .attach-btn:hover, .voice-btn:hover { color: var(--text-primary); }
    .voice-btn.recording {
      color: var(--priority-high); animation: pulse-rec 1.5s ease-in-out infinite;
    }
    @keyframes pulse-rec {
      0%, 100% { transform: scale(1); }
      50% { transform: scale(1.15); }
    }

    /* ---- Table views ---- */
    .table-view { flex: 1; overflow-y: auto; padding: 20px 24px; }
    .table-hdr {
      display: flex; justify-content: space-between; align-items: center;
      margin-bottom: 16px;
    }
    .table-hdr h2 { font-size: 18px; font-weight: 600; }
    .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table {
      width: 100%; border-collapse: separate; border-spacing: 0;
      background: var(--bg-card); border: 1px solid var(--border);
      border-radius: 10px; overflow: hidden; min-width: 500px;
    }
    .data-table th {
      background: rgba(255,255,255,0.025); padding: 10px 14px;
      font-size: 11.5px; color: var(--text-muted); font-weight: 600;
      text-transform: uppercase; letter-spacing: 0.5px; text-align: left;
      border-bottom: 1px solid var(--border);
    }
    .data-table td {
      padding: 10px 14px; font-size: 13px; color: var(--text-secondary);
      border-bottom: 1px solid var(--border);
      max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .data-table tr:last-child td { border-bottom: none; }
    .data-table tr:hover td { background: rgba(255,255,255,0.02); }
    .row-actions { display: flex; gap: 6px; }
    .row-actions button {
      background: transparent; border: 1px solid var(--border-light);
      color: var(--text-muted); padding: 4px 8px; border-radius: 5px;
      font-size: 11px; cursor: pointer; font-family: inherit;
    }
    .row-actions button:hover { color: var(--text-primary); border-color: var(--text-muted); }
    .row-actions button.del:hover { color: var(--priority-high); border-color: var(--priority-high); }

    /* ---- Projects grid ---- */
    .proj-grid {
      display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
      gap: 12px; padding: 20px 24px;
    }
    .proj-card {
      background: var(--bg-card); border: 1px solid var(--border);
      border-radius: 10px; padding: 18px; display: flex; align-items: center; gap: 12px;
    }
    .proj-color { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
    .proj-name { font-size: 14px; font-weight: 500; }

    /* ---- Placeholder ---- */
    .placeholder {
      flex: 1; display: flex; flex-direction: column; align-items: center;
      justify-content: center; color: var(--text-muted); gap: 12px;
    }
    .placeholder .material-symbols-outlined { font-size: 48px; opacity: 0.35; }
    .placeholder p { font-size: 14px; }

    /* ========================================
       MOBILE RESPONSIVE (< 768px)
       ======================================== */
    
    /* ---- Bottom Navigation (Mobile) ---- */
    .btm-nav {
      display: none; position: fixed; bottom: 0; left: 0; right: 0;
      background: var(--bg-sidebar); border-top: 1px solid var(--border);
      z-index: 100; padding: 4px 0 env(safe-area-inset-bottom, 4px);
    }
    .btm-nav-inner {
      display: flex; justify-content: space-around; align-items: center;
    }
    .btm-nav-item {
      display: flex; flex-direction: column; align-items: center;
      padding: 6px 12px; border-radius: 12px; cursor: pointer;
      color: var(--text-muted); text-decoration: none;
      transition: color 0.15s; min-width: 56px; background: none; border: none;
    }
    .btm-nav-item.active { color: var(--bg-button); }
    .btm-nav-item .material-symbols-outlined { font-size: 24px; }
    .btm-nav-item span:last-child { font-size: 10px; margin-top: 2px; }
    @media (max-width: 768px) {
      .btm-nav { display: block; }
      .sidebar { /* hidden via transform in off-canvas drawer below */ }
      .layout { padding-bottom: 60px; }
    }

    @media (max-width: 768px) {
      /* Sidebar becomes off-canvas drawer */
      .sidebar {
        display: block !important;
        position: fixed; left: 0; top: 0; bottom: 0;
        width: 260px; z-index: 101;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: none;
      }
      .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.4);
      }
      .sidebar-overlay.visible { display: block; }
      .sb-close { display: flex; }

      /* Show mobile top bar */
      .mobile-topbar { display: flex; }

      /* Action bar */
      .action-bar { padding: 10px 16px; gap: 6px; }
      .btn { padding: 8px 12px; font-size: 12px; }
      .filter-dd { padding: 8px 10px; font-size: 12px; }

      /* Kanban: stack columns vertically */
      .kanban {
        flex-direction: column;
        padding: 0 16px 16px;
        overflow-x: hidden;
        overflow-y: auto;
        gap: 16px;
      }
      .column {
        min-width: unset;
        flex: none;
      }
      .col-cards {
        max-height: none;
        overflow-y: visible;
      }

      /* Show card move buttons on mobile (no drag & drop) */
      .card-actions { display: flex; }
      .card { cursor: default; }

      /* Chat */
      .msg { max-width: 92%; }
      .chat-hdr { padding: 10px 12px; }
      .chat-hdr h2 { font-size: 15px; }
      .chat-msgs { padding: 10px 8px; gap: 4px; }
      .chat-bar { padding: 8px 8px; gap: 6px; }
      .chat-input { padding: 9px 14px; font-size: 15px; }
      .chat-send { width: 38px; height: 38px; }
      .chat-stop { width: 38px; height: 38px; }
      .attach-btn, .voice-btn { width: 38px; height: 38px; }
      .msg-avatar { width: 24px; height: 24px; font-size: 9px; }
      .msg-bubble { font-size: 14px; padding: 10px 12px; }
      .msg-content pre { padding: 10px; font-size: 12px; }
      .msg-content code { font-size: 12px; }

      /* Table */
      .table-view { padding: 16px; }
      .table-hdr { flex-wrap: wrap; gap: 8px; }
      .data-table { min-width: 400px; }

      /* Modal */
      .modal { padding: 20px 16px; border-radius: 12px; }
      .modal h3 { font-size: 15px; }
      .field-row { flex-direction: column; gap: 0; }

      /* Projects */
      .proj-grid { padding: 16px; grid-template-columns: 1fr; }
    }

    /* Extra small (< 400px) */
    @media (max-width: 400px) {
      .kanban { padding: 0 12px 12px; }
      .chat-msgs { padding: 12px; }
      .table-view { padding: 12px; }
    }

    /* ========================================
       PHASE 1: PWA CHAT UPGRADE
       ======================================== */

    /* Conversation picker */
    .conv-picker-btn {
      display: flex; align-items: center; gap: 8px;
      background: none; border: none; color: var(--text-primary);
      cursor: pointer; padding: 4px 8px; border-radius: 8px;
      font-family: inherit; -webkit-tap-highlight-color: transparent;
    }
    .conv-picker-btn:hover { background: rgba(255,255,255,0.04); }
    .conv-picker-btn h2 { font-size: 17px; font-weight: 600; margin: 0; }
    .conv-arrow { font-size: 18px !important; color: var(--text-muted); transition: transform 0.2s; }
    .conv-picker.open ~ .chat-hdr .conv-arrow,
    .conv-picker-btn[aria-expanded="true"] .conv-arrow { transform: rotate(180deg); }
    .chat-hdr { position: relative; }
    .conv-picker {
      position: absolute; top: 100%; left: 0; right: 0;
      background: var(--bg-card); border: 1px solid var(--border-light);
      border-radius: 0 0 12px 12px; max-height: 0; overflow: hidden;
      transition: max-height 0.25s ease; z-index: 50;
      box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    }
    .conv-picker.open { max-height: 320px; overflow-y: auto; }
    .conv-picker-hdr {
      display: flex; justify-content: space-between; align-items: center;
      padding: 10px 16px; border-bottom: 1px solid var(--border);
      font-size: 12px; color: var(--text-muted); font-weight: 600;
      text-transform: uppercase; letter-spacing: 0.5px;
    }
    .conv-new-btn {
      background: var(--bg-button); color: var(--bg-button-text); border: none;
      padding: 4px 10px; border-radius: 6px; font-size: 12px;
      cursor: pointer; font-family: inherit; text-transform: none; letter-spacing: 0;
    }
    .conv-new-btn:hover { background: var(--bg-button-hover); }

    /* Agent contacts panel (slides from right) */
    .agents-overlay {
      position: fixed; top: 0; left: 0; right: 0; bottom: 0;
      background: rgba(0,0,0,0.5); z-index: 200;
      opacity: 0; pointer-events: none; transition: opacity 0.2s;
    }
    .agents-overlay.open { opacity: 1; pointer-events: auto; }
    .agents-panel {
      position: fixed; top: 0; right: -300px; bottom: 0; width: 300px;
      background: var(--bg-card); z-index: 201; transition: right 0.25s ease;
      display: flex; flex-direction: column; border-left: 1px solid var(--border);
      box-shadow: -4px 0 24px rgba(0,0,0,0.3);
    }
    .agents-panel.open { right: 0; }
    .agents-panel-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .agents-panel-hdr {
      display: flex; align-items: center; gap: 8px; padding: 16px;
      border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 600;
    }
    .agents-panel-hdr .close-btn {
      margin-left: auto; background: none; border: none; color: var(--text-muted);
      cursor: pointer; font-size: 20px; padding: 4px;
    }
    .agent-contact {
      display: flex; align-items: center; gap: 12px; padding: 14px 16px;
      cursor: pointer; transition: background 0.1s; border-bottom: 1px solid var(--border-light);
    }
    .agent-contact:hover { background: rgba(255,255,255,0.04); }
    .agent-contact.active { background: var(--bg-nav-active); }
    .agent-avatar {
      width: 40px; height: 40px; border-radius: 50%;
      background: var(--bg-button); display: flex; align-items: center;
      justify-content: center; font-size: 18px; font-weight: 700;
      color: var(--bg-button-text); flex-shrink: 0; text-transform: uppercase;
    }
    .agent-info { flex: 1; overflow: hidden; }
    .agent-name { font-size: 14px; font-weight: 600; }
    .agent-role { font-size: 12px; color: var(--text-muted); overflow: hidden;
      text-overflow: ellipsis; white-space: nowrap; }

    .conv-item {
      display: flex; align-items: center; gap: 8px;
      padding: 10px 16px; cursor: pointer; transition: background 0.1s;
    }
    .conv-item:hover { background: rgba(255,255,255,0.04); }
    .conv-item.active { background: var(--bg-nav-active); }
    .conv-item-title {
      flex: 1; font-size: 13.5px; overflow: hidden;
      text-overflow: ellipsis; white-space: nowrap;
    }
    .conv-item-preview {
      font-size: 11.5px; color: var(--text-muted);
      max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .conv-item-count { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
    .conv-del {
      background: none; border: none; color: var(--text-muted);
      font-size: 16px; cursor: pointer; padding: 0 4px;
      opacity: 0; transition: opacity 0.1s; flex-shrink: 0;
    }
    .conv-item:hover .conv-del { opacity: 1; }
    .conv-del:hover { color: var(--priority-high); }

    /* Attachment button (uses .attach-btn from chat section) */
    .attach-btn .material-symbols-outlined { font-size: 22px; }

    /* Voice button (uses .voice-btn from chat section) */
    /* ---- Voice Recording: Telegram-style ---- */
    .voice-btn.recording { color: #5BC0BE; }

    .voice-rec-bar {
      position: absolute; bottom: 0; left: 0; right: 0;
      height: 52px; background: var(--bg-sidebar);
      border-top: 1px solid var(--border);
      display: flex; align-items: center; padding: 0 8px;
      z-index: 50; animation: slideUp 0.15s ease-out;
    }
    @keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

    .voice-rec-bar .rec-dot {
      width: 10px; height: 10px; border-radius: 50%; background: #ef4444;
      margin: 0 8px 0 8px; flex-shrink: 0;
      animation: blink-dot 1s ease-in-out infinite;
    }
    @keyframes blink-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

    .voice-rec-bar .rec-time {
      font-size: 15px; color: var(--text-primary); font-variant-numeric: tabular-nums;
      min-width: 44px; margin-right: 12px;
    }

    .voice-rec-bar .slide-cancel {
      flex: 1; display: flex; align-items: center; justify-content: center;
      color: var(--text-muted); font-size: 14px; gap: 4px;
      user-select: none; -webkit-user-select: none;
    }
    .voice-rec-bar .slide-cancel .material-symbols-outlined { font-size: 16px; }

    .voice-rec-bar .rec-mic-btn {
      width: 48px; height: 48px; border-radius: 50%;
      background: #5BC0BE; border: none; color: white;
      display: flex; align-items: center; justify-content: center;
      cursor: pointer; flex-shrink: 0; position: relative;
      box-shadow: 0 0 0 6px rgba(91,192,190,0.3);
    }
    .voice-rec-bar .rec-mic-btn .material-symbols-outlined { font-size: 24px; }

    /* ---- Voice Preview Bar (Telegram-style) ---- */
    .voice-prev-bar {
      position: absolute; bottom: 0; left: 0; right: 0;
      height: 56px; background: var(--bg-sidebar);
      border-top: 1px solid var(--border);
      display: flex; align-items: center; padding: 0 8px; gap: 8px;
      z-index: 50; animation: slideUp 0.15s ease-out;
    }

    .voice-prev-bar .vp-delete {
      width: 42px; height: 42px; border-radius: 50%;
      background: none; border: none; color: var(--text-muted);
      display: flex; align-items: center; justify-content: center;
      cursor: pointer; flex-shrink: 0;
    }
    .voice-prev-bar .vp-delete:active { color: var(--priority-high); }
    .voice-prev-bar .vp-delete .material-symbols-outlined { font-size: 24px; }

    .voice-prev-bar .vp-track {
      flex: 1; height: 40px; border-radius: 20px;
      background: #5BC0BE; display: flex; align-items: center;
      padding: 0 6px; position: relative; overflow: hidden;
    }

    .voice-prev-bar .vp-track .vp-trim {
      width: 6px; height: 100%; background: rgba(0,0,0,0.15);
      display: flex; align-items: center; justify-content: center;
      flex-shrink: 0;
    }
    .voice-prev-bar .vp-track .vp-trim-handle {
      width: 3px; height: 18px; border-radius: 2px; background: white;
    }

    .voice-prev-bar .vp-track .vp-wave {
      flex: 1; height: 28px; display: flex; align-items: center;
      gap: 1.5px; overflow: hidden; padding: 0 4px;
    }
    .voice-prev-bar .vp-track .vp-wave .vbar {
      width: 2px; border-radius: 1px; background: rgba(255,255,255,0.5);
      min-height: 3px;
    }

    .voice-prev-bar .vp-track .vp-play-badge {
      position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
      background: rgba(28,37,65,0.85); border-radius: 14px;
      padding: 4px 12px; display: flex; align-items: center; gap: 6px;
      backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    }
    .voice-prev-bar .vp-track .vp-play-badge .material-symbols-outlined {
      font-size: 18px; color: white;
    }
    .voice-prev-bar .vp-track .vp-play-badge .vp-dur {
      font-size: 14px; color: white; font-variant-numeric: tabular-nums;
    }

    .voice-prev-bar .vp-send {
      width: 48px; height: 48px; border-radius: 50%;
      background: #5BC0BE; border: none; color: white;
      display: flex; align-items: center; justify-content: center;
      cursor: pointer; flex-shrink: 0;
    }
    .voice-prev-bar .vp-send:active { background: #46a8a6; }
    .voice-prev-bar .vp-send .material-symbols-outlined { font-size: 22px; }









    /* ---- Agent Profile Panel ---- */
    .agent-profile-panel {
      position: fixed; top: 0; right: -320px; bottom: 0; width: 320px;
      background: var(--bg-sidebar); border-left: 1px solid var(--border);
      z-index: 150; transition: right 0.25s ease; overflow-y: auto;
      box-shadow: -4px 0 16px rgba(0,0,0,0.3);
    }
    .agent-profile-panel.open { right: 0; }
    .agent-profile-overlay {
      position: fixed; inset: 0; background: rgba(0,0,0,0.4);
      z-index: 149; display: none;
    }
    .agent-profile-overlay.open { display: block; }
    .ap-header {
      padding: 24px 20px; text-align: center;
      border-bottom: 1px solid var(--border);
    }
    .ap-avatar {
      width: 72px; height: 72px; border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      font-size: 28px; font-weight: 700; color: white;
      margin: 0 auto 12px; text-transform: uppercase;
    }
    .ap-name { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
    .ap-status { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; justify-content: center; gap: 6px; }
    .ap-close {
      position: absolute; top: 12px; right: 12px;
      background: none; border: none; color: var(--text-muted);
      cursor: pointer; padding: 4px; border-radius: 50%;
    }
    .ap-close:hover { color: var(--text-primary); }
    .ap-section { padding: 16px 20px; border-bottom: 1px solid var(--border); }
    .ap-section-title { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
    .ap-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; }
    .ap-row-label { color: var(--text-muted); }
    .ap-row-value { color: var(--text-primary); font-weight: 500; }
    .ap-actions { padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; }
    .ap-action-btn {
      padding: 10px; border-radius: 10px; border: 1px solid var(--border);
      background: var(--bg-card); color: var(--text-primary); cursor: pointer;
      display: flex; align-items: center; gap: 8px; font-size: 13px;
    }
    .ap-action-btn:hover { border-color: var(--bg-button); }
    .ap-action-btn .material-symbols-outlined { font-size: 18px; color: var(--bg-button); }
    @media (max-width: 768px) {
      .agent-profile-panel { width: 85%; max-width: 320px; }
    }

    /* ---- Image Lightbox ---- */
    .lightbox-overlay {
      position: fixed; inset: 0; background: rgba(0,0,0,0.95); z-index: 200;
      display: flex; align-items: center; justify-content: center;
      flex-direction: column; cursor: pointer; animation: fadeIn 0.2s ease-out;
    }
    .lightbox-img {
      max-width: 95%; max-height: 85vh; object-fit: contain;
      border-radius: 8px; touch-action: none; transition: transform 0.1s ease-out;
    }
    .lightbox-close {
      position: absolute; top: 16px; right: 16px;
      background: rgba(255,255,255,0.15); border: none; color: white;
      width: 40px; height: 40px; border-radius: 50%;
      display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 201;
    }
    .lightbox-close .material-symbols-outlined { font-size: 24px; }

    /* ---- Agent Activity Feed ---- */
    /* ---- Activity View ---- */
    .activity-view { flex: 1; overflow-y: auto; padding: 20px 24px; }
    .activity-header {
      padding: 20px 24px 16px; display: flex; flex-direction: column; gap: 14px;
    }
    .activity-title-group { display: flex; flex-direction: column; gap: 4px; }
    .activity-title { font-size: 22px; font-weight: 700; color: var(--text-primary); letter-spacing: 0.2px; }
    .activity-subtitle { font-size: 13px; color: var(--text-muted); line-height: 1.5; max-width: 640px; }
    .activity-search {
      display: flex; align-items: center; gap: 10px;
      background: var(--bg-input); border: 1px solid var(--border);
      border-radius: 10px; padding: 9px 14px; transition: border-color 0.15s;
    }
    .activity-search:focus-within { border-color: var(--bg-button); }
    .activity-search input {
      flex: 1; background: none; border: none; outline: none;
      color: var(--text-primary); font-size: 14px; font-family: inherit;
    }
    .activity-search .material-symbols-outlined { font-size: 18px; color: var(--text-muted); }
    .activity-agent-scroll {
      display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px;
      -webkit-overflow-scrolling: touch; scrollbar-width: none;
    }
    .activity-agent-scroll::-webkit-scrollbar { display: none; }
    .activity-agent-chip {
      position: relative; display: flex; flex-direction: column; gap: 5px;
      padding: 11px 14px; border-radius: 14px;
      background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-hover) 100%);
      border: 1px solid var(--border);
      cursor: pointer; min-width: 120px; transition: all 0.18s ease; flex-shrink: 0;
    }
    .activity-agent-chip:hover { border-color: var(--bg-button); transform: translateY(-1px); }
    .activity-agent-chip.active {
      background: linear-gradient(135deg, rgba(226,176,95,0.12) 0%, rgba(91,192,190,0.08) 100%);
      border-color: var(--bg-button);
      box-shadow: 0 0 0 2px rgba(226,176,95,0.15);
    }
    .activity-agent-chip-top {
      display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-primary);
    }
    .activity-agent-chip-meta {
      font-size: 11px; color: var(--text-muted); white-space: nowrap;
      overflow: hidden; text-overflow: ellipsis;
    }
    .activity-agent-chip .chip-dot,
    .activity-status-dot {
      width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
    }
    .activity-agent-chip .chip-dot.idle,
    .activity-status-dot.idle,
    .activity-status-dot.completed { background: #5BC0BE; }
    .activity-agent-chip .chip-dot.working,
    .activity-status-dot.working {
      background: #facc15;
      box-shadow: 0 0 6px rgba(250,204,21,0.6);
      animation: pulse-dot 1.4s ease-in-out infinite;
    }
    .activity-agent-chip .chip-dot.stalled,
    .activity-status-dot.stalled { background: #fb7185; }
    .activity-agent-chip .chip-dot.error,
    .activity-status-dot.error { background: #ef4444; }
    .activity-agent-chip .chip-dot.unknown,
    .activity-status-dot.unknown { background: var(--text-muted); }

    .activity-summary {
      display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px;
      padding: 0 24px 20px;
    }
    .activity-overview-card {
      position: relative; overflow: hidden;
      background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-hover) 100%);
      border: 1px solid var(--border); border-radius: 14px;
      padding: 18px 18px 16px;
      display: flex; flex-direction: column; gap: 8px;
      transition: border-color 0.18s;
    }
    .activity-overview-card::before {
      content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
      background: linear-gradient(90deg, var(--bg-button), #5BC0BE); opacity: 0.8;
    }
    .activity-overview-card:hover { border-color: var(--border-light); }
    .activity-overview-label {
      font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600;
    }
    .activity-overview-value {
      font-size: 20px; font-weight: 700; color: var(--text-primary); line-height: 1.25;
    }
    .activity-overview-value.subtle {
      font-size: 14px; font-weight: 600; color: var(--text-secondary);
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .activity-overview-note {
      font-size: 11.5px; color: var(--text-muted); line-height: 1.4;
      overflow: hidden; text-overflow: ellipsis;
      display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    }

    .activity-body { display: flex; flex-direction: column; gap: 18px; }
    .activity-primary-card,
    .activity-run-card,
    .activity-empty-panel {
      position: relative; overflow: hidden;
      background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-hover) 100%);
      border: 1px solid var(--border); border-radius: 16px; padding: 20px;
    }
    .activity-primary-card::before {
      content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
      background: linear-gradient(90deg, var(--bg-button), #5BC0BE); opacity: 0.8;
    }
    .activity-primary-card {
      cursor: pointer; border-left: 3px solid var(--border-light);
      transition: border-color 0.18s, transform 0.18s;
    }
    .activity-primary-card:hover { transform: translateY(-1px); }
    .activity-primary-card.state-working { border-left-color: #facc15; }
    .activity-primary-card.state-working::before { background: linear-gradient(90deg, #facc15, #f59e0b); }
    .activity-primary-card.state-completed { border-left-color: #5BC0BE; }
    .activity-primary-card.state-completed::before { background: linear-gradient(90deg, #5BC0BE, #5BC0BE); }
    .activity-primary-card.state-error { border-left-color: #ef4444; }
    .activity-primary-card.state-error::before { background: linear-gradient(90deg, #ef4444, #f97316); }
    .activity-primary-card.state-stalled { border-left-color: #fb7185; }
    .activity-primary-card.state-stalled::before { background: linear-gradient(90deg, #fb7185, #ef4444); }
    .activity-collapse-chevron {
      color: var(--text-muted); font-size: 22px;
      transition: transform 0.2s ease;
    }
    .activity-primary-card.expanded .activity-collapse-chevron { transform: rotate(180deg); }
    .activity-card-summary-line {
      display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px;
      font-size: 12.5px; color: var(--text-secondary);
    }
    .activity-summary-line-item {
      display: inline-flex; align-items: center; gap: 6px;
      max-width: 100%; min-width: 0;
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .activity-summary-line-item .material-symbols-outlined {
      font-size: 15px; color: var(--text-muted);
    }
    .activity-primary-card.expanded .activity-card-summary-line { display: none; }
    .activity-card-body { margin-top: 4px; }
    .activity-run-card { border-left-width: 3px; transition: border-color 0.18s, transform 0.18s; }
    .activity-run-card:hover { transform: translateY(-1px); }
    .activity-run-card.state-working { border-left-color: #facc15; }
    .activity-run-card.state-completed { border-left-color: #5BC0BE; }
    .activity-run-card.state-error { border-left-color: #ef4444; }
    .activity-run-card.state-stalled { border-left-color: #fb7185; }
    .activity-run-card.state-idle,
    .activity-run-card.state-unknown { border-left-color: var(--border-light); }
    .activity-run-card { padding: 0; overflow: hidden; }
    .activity-run-summary {
      display: flex; align-items: center; justify-content: space-between;
      gap: 12px; width: 100%; padding: 12px 14px; background: transparent;
      border: 0; color: inherit; cursor: pointer; text-align: left;
      font: inherit;
    }
    .activity-run-summary:hover:not(:disabled) { background: rgba(255,255,255,0.03); }
    .activity-run-summary:disabled { cursor: default; }
    .activity-run-summary-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
    .activity-run-summary-line1 {
      display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0;
    }
    .activity-run-source {
      font-size: 13px; font-weight: 600; color: var(--text-primary);
    }
    .activity-run-step {
      font-size: 12px; color: var(--text-secondary);
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
      max-width: 260px;
    }
    .activity-run-summary-line2 {
      display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
      font-size: 11px; color: var(--text-muted);
    }
    .activity-run-summary-sep { opacity: 0.6; }
    .activity-run-summary-abs { color: var(--text-secondary); }
    .activity-run-chevron {
      font-size: 20px !important; color: var(--text-muted); flex-shrink: 0;
      transition: transform 0.15s ease;
    }
    .activity-run-card.open .activity-run-chevron { color: var(--text-secondary); }
    .activity-run-details {
      padding: 0 14px 14px 14px;
      display: flex; flex-direction: column; gap: 12px;
      border-top: 1px solid var(--border-light);
      padding-top: 12px;
    }
    .activity-run-session {
      font-size: 11px; color: var(--text-muted); word-break: break-all;
    }
    .activity-run-session code {
      background: rgba(255,255,255,0.04); padding: 2px 6px; border-radius: 6px;
      font-family: inherit; color: var(--text-secondary);
    }
    .activity-card-head,
    .activity-run-top {
      display: flex; align-items: flex-start; justify-content: space-between;
      gap: 12px; flex-wrap: wrap;
    }
    .activity-card-title-wrap,
    .activity-run-head {
      display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1;
    }
    .activity-card-title,
    .activity-run-title {
      font-size: 15px; font-weight: 700; color: var(--text-primary); letter-spacing: 0.1px;
    }
    .activity-card-title { font-size: 17px; }
    .activity-card-subtitle,
    .activity-run-subtitle {
      font-size: 12px; color: var(--text-muted);
      word-break: break-all; font-family: 'SF Mono', 'Fira Code', monospace;
    }
    .activity-pill-row,
    .activity-run-badges {
      display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    }
    .activity-pill {
      display: inline-flex; align-items: center; gap: 6px;
      padding: 4px 10px; border-radius: 12px;
      border: 1px solid transparent; font-size: 11px; font-weight: 600;
      text-transform: uppercase; letter-spacing: 0.4px;
    }
    .activity-pill.state-working { background: rgba(250,204,21,0.14); color: #fde047; border-color: rgba(250,204,21,0.26); }
    .activity-pill.state-error { background: rgba(239,68,68,0.14); color: #fca5a5; border-color: rgba(239,68,68,0.26); }
    .activity-pill.state-stalled { background: rgba(251,113,133,0.14); color: #fda4af; border-color: rgba(251,113,133,0.26); }
    .activity-pill.state-idle,
    .activity-pill.state-completed { background: rgba(74,222,128,0.14); color: #86efac; border-color: rgba(74,222,128,0.26); }
    .activity-pill.state-unknown { background: rgba(156,163,175,0.12); color: #d1d5db; border-color: rgba(156,163,175,0.2); }
    .activity-pill.source {
      background: rgba(226,176,95,0.14); color: #edc67e; border-color: rgba(226,176,95,0.24);
      text-transform: none; letter-spacing: 0.1px;
    }

    .activity-meta-grid,
    .activity-run-grid {
      display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px;
      margin-top: 16px;
    }
    .activity-meta-item {
      background: rgba(0, 0, 0, 0.2); border: 1px solid var(--border);
      border-radius: 10px; padding: 12px;
    }
    .activity-run-grid .activity-meta-item { background: var(--bg-input); }
    .activity-meta-label {
      font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
    }
    .activity-meta-value {
      font-size: 13px; font-weight: 600; color: var(--text-primary); line-height: 1.45; margin-top: 6px;
      word-break: break-word;
    }

    .activity-preview-grid {
      display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px;
    }
    .activity-preview-card {
      background: rgba(226,176,95,0.04); border: 1px solid rgba(226,176,95,0.15);
      border-radius: 10px; padding: 14px;
    }
    .activity-preview-label {
      font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
    }
    .activity-preview-text {
      margin-top: 8px; font-size: 13px; line-height: 1.55; color: var(--text-secondary);
      white-space: pre-wrap; word-break: break-word;
    }

    .activity-error-callout,
    .activity-run-error {
      margin-top: 16px; padding: 12px 14px; border-radius: 10px;
      border: 1px solid rgba(239,68,68,0.24); background: rgba(239,68,68,0.09);
      color: #fecaca; font-size: 12.5px; line-height: 1.5;
    }

    .activity-section { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
    .activity-section-title {
      font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.7px; font-weight: 700;
    }
    .activity-run-list { display: flex; flex-direction: column; gap: 12px; }
    .activity-run-preview {
      padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,0.03);
      border: 1px solid rgba(255,255,255,0.04); font-size: 12px; color: var(--text-secondary); line-height: 1.5;
      white-space: pre-wrap; word-break: break-word; margin-top: 10px;
    }

    .activity-loading {
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      padding: 48px 20px; color: var(--text-muted); gap: 16px;
    }
    .activity-loading .activity-spinner {
      width: 36px; height: 36px; border: 3px solid rgba(226,176,95,0.2);
      border-top-color: var(--bg-button); border-radius: 50%;
      animation: activity-spin 0.8s linear infinite;
    }
    .activity-loading .activity-loading-text { font-size: 13px; font-weight: 500; }
    @keyframes activity-spin { to { transform: rotate(360deg); } }
    .activity-chips-skeleton { display: flex; gap: 8px; overflow: hidden; }
    .activity-chips-skeleton .skel-chip {
      width: 120px; height: 44px; border-radius: 14px;
      background: linear-gradient(90deg, var(--bg-card) 25%, rgba(226,176,95,0.1) 50%, var(--bg-card) 75%);
      background-size: 200% 100%; animation: skel-shimmer 1.5s ease infinite;
    }
    @keyframes skel-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
    .activity-empty,
    .activity-empty-panel {
      text-align: center; color: var(--text-muted);
    }
    .activity-empty { padding: 60px 20px; }
    .activity-empty-panel { padding: 32px 20px; }
    .activity-empty .material-symbols-outlined,
    .activity-empty-panel .material-symbols-outlined {
      font-size: 42px; display: block; margin-bottom: 10px; opacity: 0.35;
    }

    @media (max-width: 900px) {
      .activity-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .activity-meta-grid,
      .activity-run-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .activity-preview-grid { grid-template-columns: 1fr; }
    }
    @media (max-width: 640px) {
      .activity-header { padding: 16px; gap: 12px; }
      .activity-view { padding: 16px; }
      .activity-title { font-size: 19px; }
      .activity-meta-grid,
      .activity-run-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
      .activity-meta-item { padding: 10px; }
      .activity-primary-card,
      .activity-run-card,
      .activity-empty-panel { padding: 14px; border-radius: 12px; }
      .activity-agent-chip { min-width: 100px; padding: 9px 12px; }
      .activity-card-head,
      .activity-run-top { gap: 8px; }

      /* Compact summary bar: one row of 3 tight cells instead of 3 stacked cards */
      .activity-summary {
        grid-template-columns: 1fr 1fr 1fr; gap: 0;
        padding: 0 16px 12px;
      }
      .activity-overview-card {
        border-radius: 0; padding: 10px 10px 10px;
        gap: 4px; border-right: none;
        background: var(--bg-card); min-width: 0;
      }
      .activity-overview-card:first-child { border-top-left-radius: 12px; border-bottom-left-radius: 12px; }
      .activity-overview-card:last-child { border-top-right-radius: 12px; border-bottom-right-radius: 12px; border-right: 1px solid var(--border); }
      .activity-overview-card:not(:last-child) { border-right: 1px solid var(--border); }
      .activity-overview-card::before { display: none; }
      .activity-overview-label { font-size: 9.5px; letter-spacing: 0.4px; }
      .activity-overview-value { font-size: 13px; line-height: 1.2; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
      .activity-overview-value.subtle { font-size: 12px; }
      .activity-overview-note { display: none; }
      .activity-pill { padding: 2px 6px; font-size: 9.5px; letter-spacing: 0.3px; }
    }

    /* ---- Media Gallery ---- */
    .gallery-view { flex: 1; overflow-y: auto; padding: 16px; }
    .gallery-tabs {
      display: flex; gap: 0; border-bottom: 1px solid var(--border);
      padding: 0 16px; flex-shrink: 0;
    }
    .gallery-tab {
      padding: 10px 16px; font-size: 13px; cursor: pointer;
      color: var(--text-muted); border-bottom: 2px solid transparent;
      background: none; border-top: none; border-left: none; border-right: none;
      transition: all 0.15s;
    }
    .gallery-tab.active { color: var(--bg-button); border-bottom-color: var(--bg-button); }
    .gallery-grid {
      display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
      padding: 8px 0;
    }
    .gallery-item {
      aspect-ratio: 1; overflow: hidden; border-radius: 4px;
      cursor: pointer; position: relative; background: var(--bg-card);
    }
    .gallery-item img, .gallery-item video {
      width: 100%; height: 100%; object-fit: cover;
    }
    .gallery-item .gallery-play-icon {
      position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
      background: rgba(0,0,0,0.5); border-radius: 50%; width: 36px; height: 36px;
      display: flex; align-items: center; justify-content: center;
    }
    .gallery-item .gallery-play-icon .material-symbols-outlined { color: white; font-size: 20px; }
    .gallery-audio-list { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
    .gallery-audio-item {
      display: flex; align-items: center; gap: 10px; padding: 10px 12px;
      background: var(--bg-card); border-radius: 10px; border: 1px solid var(--border);
    }
    .gallery-audio-item .material-symbols-outlined { font-size: 20px; color: var(--bg-button); }
    .gallery-audio-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .gallery-audio-meta { font-size: 11px; color: var(--text-muted); }
    .gallery-file-list { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; }
    .gallery-file-item {
      display: flex; align-items: center; gap: 10px; padding: 10px 12px;
      background: var(--bg-card); border-radius: 10px; border: 1px solid var(--border);
      cursor: pointer; text-decoration: none; color: var(--text-primary);
    }
    .gallery-file-item:hover { border-color: var(--bg-button); }
    .gallery-empty { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 14px; }
    .gallery-load-more {
      display: block; margin: 12px auto; padding: 8px 24px; border-radius: 20px;
      background: var(--bg-card); border: 1px solid var(--border); color: var(--text-primary);
      cursor: pointer; font-size: 13px;
    }

    /* ---- Agents Directory ---- */
    .agents-grid {
      display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
      gap: 20px; padding: 24px;
    }
    .agent-card {
      position: relative;
      background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-hover) 100%);
      border: 1px solid var(--border); border-radius: 14px;
      padding: 0; cursor: pointer; overflow: hidden;
      transition: transform 0.18s ease, border-color 0.18s, box-shadow 0.18s;
      display: flex; flex-direction: column;
    }
    .agent-card::before {
      content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
      background: linear-gradient(90deg, var(--bg-button), #5BC0BE);
      opacity: 0.8;
    }
    .agent-card:hover {
      transform: translateY(-2px);
      border-color: var(--bg-button);
      box-shadow: 0 8px 24px rgba(226, 176, 95, 0.15);
    }
    .agent-card-head {
      display: flex; align-items: flex-start; gap: 14px;
      padding: 22px 22px 14px;
    }
    .agent-card-avatar {
      width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0;
      background: linear-gradient(135deg, #E2B05F 0%, #5BC0BE 100%);
      display: flex; align-items: center; justify-content: center;
      font-size: 22px; font-weight: 700; color: #fff;
      box-shadow: 0 4px 12px rgba(226, 176, 95, 0.3);
    }
    .agent-card-head-info { flex: 1; min-width: 0; }
    .agent-card-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
    .agent-card-name {
      font-size: 17px; font-weight: 700; color: var(--text-primary);
      letter-spacing: 0.2px;
    }
    .agent-card-status-pill {
      display: inline-flex; align-items: center; gap: 5px;
      padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600;
      text-transform: uppercase; letter-spacing: 0.5px;
    }
    .agent-card-status-pill.working {
      background: rgba(91, 192, 190, 0.18); color: #5BC0BE;
    }
    .agent-card-status-pill.idle {
      background: rgba(156, 163, 175, 0.12); color: var(--text-secondary);
    }
    .agent-card-status-pill.unknown {
      background: rgba(156, 163, 175, 0.08); color: var(--text-muted);
    }
    .agent-card-status-pill.error {
      background: rgba(239, 68, 68, 0.15); color: var(--priority-high);
    }
    .agent-card-status-pill .chip-dot {
      width: 6px; height: 6px; border-radius: 50%; background: currentColor;
    }
    .agent-card-status-pill.working .chip-dot {
      box-shadow: 0 0 6px currentColor;
      animation: pulse-dot 1.8s ease-in-out infinite;
    }
    @keyframes pulse-dot {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.4; }
    }
    .agent-card-id {
      font-size: 12px; color: var(--text-muted);
      margin-top: 3px; font-family: 'SF Mono', 'Fira Code', monospace;
    }
    .agent-card-desc {
      padding: 0 22px 14px; font-size: 13px; color: var(--text-secondary);
      line-height: 1.5;
      overflow: hidden; text-overflow: ellipsis;
      display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    }
    .agent-card-model {
      display: flex; align-items: center; gap: 8px;
      padding: 0 22px 14px; font-size: 12px; color: var(--text-secondary);
    }
    .agent-card-model-icon {
      width: 24px; height: 24px; border-radius: 6px;
      background: var(--bg-input); display: flex; align-items: center; justify-content: center;
      color: var(--bg-button);
    }
    .agent-card-model-icon .material-symbols-outlined { font-size: 14px; }
    .agent-card-model-name {
      font-family: 'SF Mono', 'Fira Code', monospace; font-size: 11.5px;
      color: var(--text-primary); white-space: nowrap;
      overflow: hidden; text-overflow: ellipsis;
    }
    .agent-card-stats {
      display: grid; grid-template-columns: 1fr 1fr 1fr;
      border-top: 1px solid var(--border);
      background: rgba(0, 0, 0, 0.15);
    }
    .agent-card-stat {
      padding: 12px 8px; text-align: center;
      border-right: 1px solid var(--border);
    }
    .agent-card-stat:last-child { border-right: none; }
    .agent-card-stat-value {
      font-size: 16px; font-weight: 700; color: var(--text-primary);
      line-height: 1.2;
    }
    .agent-card-stat-label {
      font-size: 10px; color: var(--text-muted);
      text-transform: uppercase; letter-spacing: 0.5px;
      margin-top: 3px;
    }
    .agent-card-footer {
      display: flex; align-items: center; justify-content: space-between;
      padding: 12px 22px; font-size: 12px; color: var(--text-muted);
      border-top: 1px solid var(--border);
    }
    .agent-card-footer-left { display: flex; align-items: center; gap: 6px; }
    .agent-card-footer-left .material-symbols-outlined { font-size: 14px; }
    .agent-card-cta {
      display: inline-flex; align-items: center; gap: 4px;
      color: var(--bg-button); font-weight: 600; font-size: 12px;
      transition: gap 0.18s;
    }
    .agent-card:hover .agent-card-cta { gap: 8px; }
    .agent-card-cta .material-symbols-outlined { font-size: 16px; }

    /* Overview tab content */
    .agent-overview { padding: 24px 32px; overflow-y: auto; flex: 1; }
    .agent-overview-grid {
      display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
      gap: 14px; margin-bottom: 24px;
    }
    .agent-overview-stat {
      background: var(--bg-card); border: 1px solid var(--border);
      border-radius: 10px; padding: 16px;
    }
    .agent-overview-stat-label {
      font-size: 11px; color: var(--text-muted); text-transform: uppercase;
      letter-spacing: 0.5px; margin-bottom: 6px;
    }
    .agent-overview-stat-value {
      font-size: 22px; font-weight: 700; color: var(--text-primary);
      line-height: 1.2;
    }
    .agent-overview-stat-sub {
      font-size: 11px; color: var(--text-muted); margin-top: 4px;
    }
    .agent-overview-section { margin-bottom: 24px; }
    .agent-overview-section h3 {
      font-size: 13px; font-weight: 600; color: var(--text-secondary);
      text-transform: uppercase; letter-spacing: 0.5px; margin: 0 0 10px;
    }
    .agent-overview-row {
      display: flex; justify-content: space-between; align-items: center;
      padding: 10px 14px; background: var(--bg-card);
      border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px;
      font-size: 13px;
    }
    .agent-overview-row-label { color: var(--text-secondary); }
    .agent-overview-row-value {
      color: var(--text-primary); font-family: 'SF Mono', 'Fira Code', monospace;
      font-size: 12px; max-width: 60%;
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .agent-overview-chips { display: flex; flex-wrap: wrap; gap: 6px; }
    .agent-overview-chip {
      display: inline-flex; align-items: center; gap: 4px;
      padding: 4px 10px; background: var(--bg-card);
      border: 1px solid var(--border); border-radius: 12px;
      font-size: 11.5px; color: var(--text-secondary);
    }
    .agent-overview-chip .material-symbols-outlined {
      font-size: 13px; color: var(--bg-button);
    }

    /* Agent Detail */
    .agent-detail-header {
      display: flex; align-items: center; gap: 12px; padding: 16px 24px;
      border-bottom: 1px solid var(--border);
    }
    .agent-detail-header .btn-back {
      display: flex; align-items: center; gap: 4px; background: none; border: none;
      color: var(--text-secondary); cursor: pointer; font-size: 13px; padding: 6px 10px;
      border-radius: 6px; transition: background 0.12s;
    }
    .agent-detail-header .btn-back:hover { background: var(--bg-card); }
    .agent-detail-header h2 { font-size: 18px; font-weight: 600; color: var(--text-primary); margin: 0; }
    .agents-tabs {
      display: flex; gap: 0; border-bottom: 1px solid var(--border);
      padding: 0 24px; flex-shrink: 0; overflow-x: auto;
    }
    .agents-tab {
      padding: 12px 18px; font-size: 13px; cursor: pointer;
      color: var(--text-muted); background: none;
      border: none; border-bottom: 2px solid transparent;
      transition: all 0.15s; white-space: nowrap; font-family: inherit;
    }
    .agents-tab:hover { color: var(--text-secondary); }
    .agents-tab.active { color: var(--bg-button); border-bottom-color: var(--bg-button); }
    .agents-file-content { padding: 24px 32px; overflow-y: auto; flex: 1; }
    .agents-file-loading {
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      padding: 60px 20px; color: var(--text-muted);
    }
    .agents-empty {
      text-align: center; padding: 60px 20px; color: var(--text-muted); font-size: 14px;
    }

    /* Markdown rendered content */
    .md-content { color: var(--text-secondary); line-height: 1.7; font-size: 14px; }
    .md-content h1 { font-size: 24px; font-weight: 700; color: var(--text-primary); margin: 28px 0 12px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
    .md-content h2 { font-size: 20px; font-weight: 600; color: var(--text-primary); margin: 24px 0 10px; }
    .md-content h3 { font-size: 16px; font-weight: 600; color: var(--text-primary); margin: 20px 0 8px; }
    .md-content h4, .md-content h5, .md-content h6 { font-size: 14px; font-weight: 600; color: var(--text-primary); margin: 16px 0 6px; }
    .md-content p { margin: 0 0 12px; }
    .md-content ul, .md-content ol { margin: 0 0 12px; padding-left: 24px; }
    .md-content li { margin-bottom: 4px; }
    .md-content blockquote {
      border-left: 3px solid var(--bg-button); margin: 0 0 12px; padding: 8px 16px;
      background: rgba(226,176,95,0.06); border-radius: 0 6px 6px 0; color: var(--text-secondary);
    }
    .md-content code {
      background: var(--bg-input); padding: 2px 6px; border-radius: 4px;
      font-size: 12.5px; font-family: 'SF Mono', 'Fira Code', monospace;
    }
    .md-content pre {
      background: var(--bg-input); padding: 16px; border-radius: 8px;
      overflow-x: auto; margin: 0 0 12px; border: 1px solid var(--border);
    }
    .md-content pre code { background: none; padding: 0; font-size: 13px; }
    .md-content table { width: 100%; border-collapse: collapse; margin: 0 0 12px; }
    .md-content th, .md-content td {
      border: 1px solid var(--border); padding: 8px 12px; text-align: left; font-size: 13px;
    }
    .md-content th { background: var(--bg-input); color: var(--text-primary); font-weight: 600; }
    .md-content a { color: var(--bg-button); text-decoration: none; }
    .md-content a:hover { text-decoration: underline; }
    .md-content hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
    .md-content img { max-width: 100%; border-radius: 8px; }

    /* ---- Costs View ---- */
    .costs-view { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
    .costs-header {
      padding: 20px 24px 16px; display: flex; justify-content: space-between;
      align-items: flex-start; gap: 16px; flex-wrap: wrap;
    }
    .costs-title-group { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
    .costs-title {
      font-size: 22px; font-weight: 700; color: var(--text-primary); letter-spacing: 0.2px;
    }
    .costs-subtitle {
      font-size: 13px; color: var(--text-muted); line-height: 1.5; max-width: 640px;
    }
    .costs-range-group {
      display: inline-flex; gap: 0; background: var(--bg-card);
      border: 1px solid var(--border); border-radius: 10px; padding: 3px;
      flex-shrink: 0;
    }
    .costs-range {
      padding: 6px 14px; font-size: 12px; font-weight: 600;
      background: none; border: none; color: var(--text-muted);
      border-radius: 7px; cursor: pointer; font-family: inherit;
      transition: all 0.15s;
    }
    .costs-range:hover { color: var(--text-secondary); }
    .costs-range.active {
      background: linear-gradient(135deg, var(--bg-button), #5BC0BE);
      color: #fff; box-shadow: 0 2px 8px rgba(226, 176, 95, 0.3);
    }

    .costs-summary {
      display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px;
      padding: 0 24px 20px;
    }
    .costs-overview-card {
      position: relative; overflow: hidden;
      background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-hover) 100%);
      border: 1px solid var(--border); border-radius: 14px;
      padding: 18px 18px 16px;
      display: flex; flex-direction: column; gap: 8px;
      transition: border-color 0.18s;
    }
    .costs-overview-card::before {
      content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
      background: linear-gradient(90deg, var(--bg-button), #5BC0BE); opacity: 0.8;
    }
    .costs-overview-card:hover { border-color: var(--border-light); }
    .costs-overview-label {
      font-size: 10.5px; color: var(--text-muted);
      text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600;
    }
    .costs-overview-value {
      font-size: 22px; font-weight: 700; color: var(--text-primary); line-height: 1.15;
    }
    .costs-overview-value.subtle {
      font-size: 15px; font-weight: 600; color: var(--text-secondary);
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
      font-family: 'SF Mono', 'Fira Code', monospace;
    }
    .costs-overview-note {
      font-size: 11.5px; color: var(--text-muted); line-height: 1.4;
    }

    .costs-charts {
      display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
      padding: 0 24px 20px;
    }
    .costs-chart-card {
      position: relative; overflow: hidden;
      background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-hover) 100%);
      border: 1px solid var(--border); border-radius: 16px; padding: 20px;
    }
    .costs-chart-card::before {
      content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
      background: linear-gradient(90deg, var(--bg-button), #5BC0BE); opacity: 0.8;
    }
    .costs-chart-title {
      font-size: 13px; font-weight: 700; color: var(--text-secondary);
      margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px;
    }
    .costs-chart-wrap { position: relative; height: 280px; }

    .costs-table-card {
      margin: 0 24px 20px;
      background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-hover) 100%);
      border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
    }
    .costs-table-title {
      font-size: 13px; font-weight: 700; color: var(--text-secondary);
      padding: 16px 20px 10px; text-transform: uppercase; letter-spacing: 0.5px;
    }
    .costs-table-scroll { overflow-x: auto; }
    .costs-table {
      width: 100%; border-collapse: collapse; font-size: 13px;
    }
    .costs-table thead th {
      text-align: left; padding: 10px 16px;
      font-size: 11px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase;
      color: var(--text-muted); background: rgba(0, 0, 0, 0.2);
      border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
      white-space: nowrap;
    }
    .costs-table tbody td {
      padding: 12px 16px; border-bottom: 1px solid var(--border);
      color: var(--text-secondary);
    }
    .costs-table tbody tr:hover td { background: rgba(226, 176, 95, 0.04); }
    .costs-table tbody tr:last-child td { border-bottom: none; }
    .costs-table .ct-agent { color: var(--text-primary); font-weight: 600; }
    .costs-table .ct-model {
      font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px;
      color: var(--text-secondary);
    }
    .costs-table .ct-num {
      text-align: right; font-variant-numeric: tabular-nums;
      font-family: 'SF Mono', 'Fira Code', monospace;
    }
    .costs-table th.ct-num { text-align: right; }
    .costs-table .ct-total { color: var(--text-primary); font-weight: 600; }

    /* ---- Settings View ---- */
    .settings-view { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
    .settings-header {
      padding: 20px 24px 16px; display: flex; justify-content: space-between;
      align-items: flex-start; gap: 16px; flex-wrap: wrap;
    }
    .settings-title-group { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
    .settings-title { font-size: 22px; font-weight: 700; color: var(--text-primary); letter-spacing: 0.2px; }
    .settings-subtitle { font-size: 13px; color: var(--text-muted); line-height: 1.5; max-width: 640px; }
    .settings-panel {
      margin: 0 24px 20px; padding: 18px;
      background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
      display: flex; flex-direction: column; gap: 16px; max-width: 780px;
    }
    .settings-panel-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--text-primary); }
    .settings-panel-title .material-symbols-outlined { color: var(--accent); font-size: 20px; }
    .settings-policy-grid { display: grid; grid-template-columns: repeat(2, minmax(180px, 1fr)); gap: 14px; }
    .settings-field { display: flex; flex-direction: column; gap: 7px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
    .settings-select {
      width: 100%; background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border-light);
      border-radius: 8px; padding: 8px 10px; font: inherit; cursor: pointer;
    }
    .settings-summary {
      display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
      border-top: 1px solid var(--border); padding-top: 14px;
    }
    .settings-summary div { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--text-muted); font-size: 12px; }
    .settings-summary strong { color: var(--text-primary); font-size: 13px; }
    .settings-meta { color: var(--text-muted); font-size: 12px; }
    .settings-error, .settings-ok { font-size: 12px; padding: 9px 10px; border-radius: 8px; }
    .settings-error { color: #fecaca; background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.28); }
    .settings-ok { color: #99f6e4; background: rgba(91,192,190,0.1); border: 1px solid rgba(91,192,190,0.28); }
    .settings-actions { display: flex; justify-content: flex-end; }

    @media (max-width: 900px) {
      .costs-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .costs-charts { grid-template-columns: 1fr; }
      .costs-chart-wrap { height: 240px; }
    }
    @media (max-width: 640px) {
      .costs-header { padding: 16px; gap: 12px; }
      .costs-summary { padding: 0 16px 16px; gap: 10px; grid-template-columns: 1fr 1fr; }
      .costs-charts { padding: 0 16px 16px; gap: 12px; }
      .costs-table-card { margin: 0 16px 16px; border-radius: 12px; }
      .costs-title { font-size: 19px; }
      .costs-overview-card { padding: 14px 14px 12px; }
      .costs-overview-value { font-size: 17px; }
      .costs-overview-note { display: none; }
      .costs-table thead th,
      .costs-table tbody td { padding: 10px 12px; font-size: 12px; }
      .settings-header { padding: 16px; }
      .settings-panel { margin: 0 16px 16px; }
      .settings-policy-grid, .settings-summary { grid-template-columns: 1fr; }
      .settings-title { font-size: 19px; }
    }

    /* ---- Slash Commands ---- */
    .slash-menu {
      position: absolute; bottom: 100%; left: 12px; right: 12px;
      background: var(--bg-card); border: 1px solid var(--border);
      border-radius: 12px; padding: 6px 0; z-index: 60;
      box-shadow: 0 -4px 16px rgba(0,0,0,0.3); max-height: 200px; overflow-y: auto;
    }
    .slash-item {
      padding: 8px 14px; cursor: pointer; display: flex; align-items: center; gap: 10px;
      transition: background 0.1s;
    }
    .slash-item:hover, .slash-item.selected { background: rgba(226,176,95,0.15); }
    .slash-item-cmd { font-weight: 600; color: var(--bg-button); font-size: 14px; }
    .slash-item-desc { font-size: 12px; color: var(--text-muted); }
    .system-msg {
      text-align: center; padding: 4px 12px; font-size: 12px;
      color: var(--text-muted); font-style: italic;
    }

    /* ---- Message Status & Queue ---- */
    .msg-status { display: inline-flex; align-items: center; gap: 2px; margin-left: 4px; }
    .msg-status .material-symbols-outlined { font-size: 13px; }
    .msg-status.sent { color: rgba(255,255,255,0.4); }
    .msg-status.queued { color: #facc15; }
    .msg-status.processed { color: #5BC0BE; }
    .queue-count-badge {
      background: #facc15; color: #000; font-size: 10px; font-weight: 700;
      padding: 1px 5px; border-radius: 8px; margin-left: 6px;
    }

    /* ---- Agent Activity Indicator ---- */
    .agent-activity {
      display: flex; align-items: center; gap: 6px;
      padding: 2px 0; font-size: 12px; color: var(--text-muted);
      min-height: 18px;
    }
    .agent-activity .activity-dot {
      width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
    }
    .agent-activity .activity-dot.starting { background: #facc15; animation: pulse-dot 1s ease infinite; }
    .agent-activity .activity-dot.thinking { background: #edc67e; animation: pulse-dot 1.2s ease infinite; }
    .agent-activity .activity-dot.writing { background: #5BC0BE; animation: pulse-dot 0.8s ease infinite; }
    .agent-activity .activity-dot.tool { background: #f97316; animation: pulse-dot 0.6s ease infinite; }
    @keyframes pulse-dot { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(0.8); } }

    /* Pending attachments strip */
    .pending-attachments {
      display: flex; gap: 8px; padding: 8px 24px 0;
      flex-wrap: wrap; flex-shrink: 0;
    }
    .pending-attachments:empty { display: none; padding: 0; }
    .pending-att {
      display: flex; align-items: center; gap: 6px;
      background: var(--bg-card); border: 1px solid var(--border-light);
      border-radius: 8px; padding: 6px 10px; font-size: 12px;
      color: var(--text-secondary); max-width: 200px;
    }
    .pending-att img {
      width: 40px; height: 40px; object-fit: cover; border-radius: 4px;
    }
    .pending-att-name {
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
    }
    .pending-att .material-symbols-outlined { font-size: 18px; flex-shrink: 0; }
    .pending-att-remove {
      background: none; border: none; color: var(--text-muted);
      font-size: 16px; cursor: pointer; padding: 0 2px; flex-shrink: 0;
      line-height: 1;
    }
    .pending-att-remove:hover { color: var(--priority-high); }

    /* Media in chat messages */
    .att-image { margin-top: 6px; }
    .att-image img {
      max-width: 280px; max-height: 220px; border-radius: 12px;
      cursor: pointer; object-fit: cover; display: block;
    }
    .att-audio { margin-top: 6px; }
    .att-audio-player {
      display: flex; align-items: center; gap: 10px;
      padding: 8px 12px; border-radius: 12px;
      background: rgba(0,0,0,0.15); min-width: 220px; max-width: 300px;
    }

    /* ============================================================
       SECRETS WARNING MODAL
       ============================================================ */
    .secrets-overlay {
      position: fixed; inset: 0; z-index: 9999;
      background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
      display: flex; align-items: center; justify-content: center;
      animation: fadeIn 0.15s ease;
    }
    .secrets-modal {
      background: var(--bg-card); border: 1px solid var(--border-light);
      border-radius: 16px; padding: 28px 24px; max-width: 420px; width: 90%;
      box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    }
    .secrets-modal-icon { text-align: center; margin-bottom: 12px; }
    .secrets-modal-title {
      text-align: center; font-size: 18px; font-weight: 600;
      color: var(--text-primary); margin-bottom: 8px;
    }
    .secrets-modal-desc {
      text-align: center; font-size: 14px; color: var(--text-secondary); margin-bottom: 12px;
    }
    .secrets-modal-list {
      list-style: none; padding: 0; margin: 0 0 16px;
      display: flex; flex-direction: column; gap: 6px;
    }
    .secrets-modal-list li {
      font-size: 13px; color: var(--text-primary); padding: 6px 10px;
      background: rgba(239,68,68,0.08); border-radius: 8px;
      border-left: 3px solid #ef4444;
    }
    .secrets-modal-hint {
      font-size: 12px; color: var(--text-muted); margin-bottom: 20px;
      line-height: 1.5; text-align: center;
    }
    .secrets-modal-actions {
      display: flex; gap: 10px; justify-content: center;
    }
    .secrets-btn-cancel {
      padding: 8px 20px; border-radius: 8px; border: 1px solid var(--border-light);
      background: transparent; color: var(--text-primary); font-size: 14px;
      cursor: pointer; font-weight: 500;
    }
    .secrets-btn-cancel:hover { background: var(--bg-card-hover); }
    .secrets-btn-send {
      padding: 8px 20px; border-radius: 8px; border: none;
      background: #ef4444; color: white; font-size: 14px;
      cursor: pointer; font-weight: 500;
    }
    .secrets-btn-send:hover { background: #dc2626; }

    /* ============================================================
       ACCESSIBILITY
       ============================================================ */
    .sr-only {
      position: absolute !important;
      width: 1px; height: 1px;
      padding: 0; margin: -1px; overflow: hidden;
      clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
    }
    *:focus-visible {
      outline: 2px solid var(--bg-button);
      outline-offset: 2px;
    }
    /* Respect user preference for reduced motion */
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
      }
    }

    /* ============================================================
       MOBILE POLISH (sub-480px + iOS keyboard-aware)
       ============================================================ */
    @media (max-width: 480px) {
      .chat-bar {
        padding: 8px 10px;
        gap: 6px;
      }
      .chat-input {
        font-size: 16px; /* prevents iOS zoom-on-focus */
      }
      .msg-bubble {
        max-width: 85%;
      }
      .chat-msgs {
        padding: 8px 6px;
      }
      .secrets-modal {
        padding: 20px 16px;
      }
      .chat-stop, .chat-send {
        min-width: 40px;
        padding: 8px 10px;
      }
      .voice-btn {
        min-width: 40px;
      }
    }

    /* iOS keyboard-aware composer: use dynamic viewport units so the
       composer stays above the keyboard when it pops up. */
    @supports (height: 100dvh) {
      .layout {
        height: 100dvh;
      }
      body {
        height: 100dvh;
      }
    }

    /* Safe-area inset for notched devices (iPhone X+) */
    .chat-bar {
      padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    }
    .msg-bubble.user .att-audio-player { background: rgba(0,0,0,0.2); }
    .att-audio-play {
      width: 36px; height: 36px; border-radius: 50%;
      background: var(--bg-button); border: none; color: var(--bg-button-text);
      display: flex; align-items: center; justify-content: center;
      cursor: pointer; flex-shrink: 0; transition: transform 0.1s;
    }
    .att-audio-play:active { transform: scale(0.93); }
    .att-audio-play .material-symbols-outlined { font-size: 20px; }
    .att-audio-wave {
      flex: 1; height: 32px; display: flex; align-items: center;
      gap: 2px; cursor: pointer; position: relative;
    }
    .att-audio-wave-bar {
      flex: 1; height: 100%; background: rgba(255,255,255,0.2);
      border-radius: 2px; min-width: 2px; transition: background 0.1s;
      position: relative; overflow: hidden;
    }
    .att-audio-wave-bar.played { background: var(--bg-button); }
    .msg-bubble.user .att-audio-wave-bar { background: rgba(10,17,40,0.3); }
    .msg-bubble.user .att-audio-wave-bar.played { background: rgba(10,17,40,0.85); }
    .att-audio-time {
      font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums;
      white-space: nowrap; min-width: 32px; text-align: right;
    }
    .msg-bubble.user .att-audio-time { color: rgba(10,17,40,0.65); }
    .att-video { margin-top: 6px; position: relative; }
    .att-video video {
      max-width: 280px; max-height: 220px; border-radius: 12px; display: block;
      background: #000;
    }
    .att-doc {
      display: flex; align-items: center; gap: 10px;
      margin-top: 6px; padding: 10px 14px; border-radius: 12px;
      background: rgba(0,0,0,0.12); text-decoration: none; color: inherit;
      transition: background 0.15s; max-width: 280px;
    }
    .att-doc:hover { background: rgba(0,0,0,0.22); }
    .att-doc .material-symbols-outlined { font-size: 28px; color: var(--bg-button); flex-shrink: 0; }
    .att-doc-info { flex: 1; min-width: 0; }
    .att-doc-name {
      display: block; font-size: 13px; font-weight: 500;
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .att-doc-size { display: block; font-size: 11px; color: var(--text-muted); margin-top: 1px; }
    .att-dl { font-size: 20px !important; color: var(--text-muted); flex-shrink: 0; }

    /* Lightbox */
    .lightbox {
      position: fixed; inset: 0; background: rgba(0,0,0,0.92);
      display: flex; align-items: center; justify-content: center;
      z-index: 1000; cursor: pointer; padding: 16px;
    }
    .lightbox img {
      max-width: 95vw; max-height: 95vh; object-fit: contain; border-radius: 4px;
    }
    .lb-close {
      position: absolute; top: 16px; right: 16px;
      background: rgba(255,255,255,0.1); border: none;
      color: white; font-size: 24px; width: 40px; height: 40px;
      border-radius: 50%; cursor: pointer; display: flex;
      align-items: center; justify-content: center;
    }

    /* Install prompt */
    .install-banner {
      display: flex; align-items: center; gap: 12px;
      padding: 10px 20px; background: linear-gradient(135deg, var(--bg-button), #c99a4f);
      color: white; font-size: 13px; flex-shrink: 0;
    }
    .install-banner .material-symbols-outlined { font-size: 20px; }
    .install-banner-text { flex: 1; }
    .install-banner button {
      background: rgba(255,255,255,0.2); border: none; color: white;
      padding: 6px 14px; border-radius: 6px; cursor: pointer;
      font-family: inherit; font-size: 12px; font-weight: 500;
    }
    .install-dismiss {
      background: none !important; padding: 4px 6px !important;
      font-size: 18px !important; opacity: 0.7;
    }

    /* Mobile adjustments for new chat elements */
    @media (max-width: 768px) {
      .pending-attachments { padding: 6px 10px 0; }
      .att-image img, .att-video video { max-width: 220px; }
      .att-doc { max-width: 240px; }
      .att-audio-player { min-width: 200px; max-width: 260px; }
      .agents-panel { width: 100%; right: -100%; }
      .agents-grid { padding: 16px; grid-template-columns: 1fr; }
      .agents-file-content { padding: 16px; }
      .agents-tabs { padding: 0 16px; }
      .agent-detail-header { padding: 12px 16px; }
    }

    /* === Code block wrapper with copy button === */
    .code-block-wrap { position: relative; margin: 8px 0; border-radius: 8px; overflow: hidden; background: #141B36; }
    .code-block-hdr { display: flex; align-items: center; justify-content: space-between; padding: 4px 12px; background: rgba(255,255,255,0.04); font-size: 11px; color: var(--text-dim); }
    .code-lang { text-transform: uppercase; letter-spacing: 0.5px; }
    .code-copy-btn { background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 2px 6px; border-radius: 4px; display: flex; align-items: center; }
    .code-copy-btn:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
    .code-block-wrap pre { margin: 0 !important; border-radius: 0 !important; }
    .code-block-wrap pre code { font-size: 13px; line-height: 1.5; }

    /* === Link preview cards === */
    .link-preview-card { display: flex; gap: 12px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 6px 0; text-decoration: none; color: inherit; background: var(--bg-card); transition: background 0.15s; max-width: 480px; overflow: hidden; }
    .link-preview-card:hover { background: var(--bg-card-hover); }
    .lpc-img { width: 80px; height: 80px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
    .lpc-text { display: flex; flex-direction: column; gap: 2px; overflow: hidden; min-width: 0; }
    .lpc-title { font-weight: 600; font-size: 13px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .lpc-desc { font-size: 12px; color: var(--text-dim); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    .lpc-site { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-dim); margin-top: auto; }
    .lpc-favicon { width: 14px; height: 14px; border-radius: 2px; }

    /* === @mention highlights === */
    .mention-chip { background: rgba(226, 176, 95, 0.15); color: #edc67e; padding: 1px 4px; border-radius: 4px; font-weight: 500; cursor: default; }
    .mention-popup { position: fixed; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 1200; max-height: 200px; overflow-y: auto; min-width: 180px; }
    .mention-popup-item { padding: 8px 12px; cursor: pointer; font-size: 13px; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
    .mention-popup-item:hover, .mention-popup-item.active { background: var(--bg-card-hover); }
    .mention-popup-item .mention-icon { width: 24px; height: 24px; border-radius: 50%; background: var(--bg-button); display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--bg-button-text); }

    /* === Offline queue badge === */
    .offline-badge { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--priority-medium); color: #0A1128; padding: 8px 14px; border-radius: 20px; font-size: 13px; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.3); z-index: 1100; display: flex; align-items: center; gap: 6px; cursor: pointer; animation: slideUp 0.3s ease; }
    .offline-badge.online { background: var(--bg-button); color: var(--bg-button-text); }
    .offline-badge:hover { filter: brightness(1.1); }
    .offline-badge .material-symbols-outlined { font-size: 18px; }
    @keyframes slideUp { from { transform: translate(-50%, 40px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* Group chat author label */
.msg-author { font-size: 11px; font-weight: 600; color: var(--accent,#E2B05F); margin-bottom: 2px; opacity: .85; }
.msg.user .msg-author { text-align: right; }


/* Slack-style chat subsections in the sidebar */
.sb-chat-section { margin: 4px 0 8px; padding: 0 4px; }
.sb-sub-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px 4px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .7px; text-transform: uppercase;
  color: var(--text-muted); user-select: none;
}
.sb-sub-add {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; width: 22px; height: 22px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  padding: 0; transition: all .15s;
}
.sb-sub-add:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.sb-sub-list { display: flex; flex-direction: column; gap: 1px; margin-bottom: 4px; }
.sb-sub-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 18px; border-radius: 6px;
  cursor: pointer; color: var(--text-secondary);
  font-size: 12.5px; user-select: none; transition: all .12s;
  -webkit-tap-highlight-color: transparent;
}
.sb-sub-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.sb-sub-item.active { background: var(--bg-nav-active); color: var(--text-primary); font-weight: 500; }
.sb-sub-avatar {
  width: 20px; height: 20px; border-radius: 50%;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.sb-sub-avatar.sb-sub-group { background: var(--accent, #E2B05F); color: white; }
.sb-sub-avatar img, .sb-sub-avatar .hdr-avatar { width: 100%; height: 100%; border-radius: 50%; }
.sb-sub-name {
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-sub-count {
  font-size: 10px; background: rgba(255,255,255,0.08);
  padding: 1px 6px; border-radius: 10px; color: var(--text-muted);
}
.sb-sub-empty {
  padding: 6px 18px; font-size: 11.5px; color: var(--text-muted); font-style: italic;
}

/* ============ MEMORY PAGE — Obsidian-style ============ */
.mem-page {
  display: flex; flex-direction: column; height: 100%; overflow: hidden;
  background: var(--bg-body);
}

/* Agent switcher */
.mem-agent-bar {
  display: flex; gap: 6px; padding: 12px 16px 0; flex-wrap: wrap; flex-shrink: 0;
}
.mem-agent-pill {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 14px; border-radius: 20px; border: 1px solid rgba(255,255,255,.08);
  background: transparent; color: rgba(255,255,255,.45); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.mem-agent-pill:hover { border-color: rgba(226,176,95,.25); color: rgba(255,255,255,.7); }
.mem-agent-pill.active {
  background: rgba(226,176,95,.12); border-color: rgba(226,176,95,.35);
  color: #edc67e; font-weight: 600;
}
.mem-agent-count {
  background: rgba(255,255,255,.06); padding: 1px 6px; border-radius: 10px;
  font-size: 10px; color: rgba(255,255,255,.3); margin-left: 2px;
}

/* Tab bar */
.mem-tab-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 0; flex-shrink: 0; gap: 12px;
}
.mem-tabs { display: flex; gap: 4px; }
.mem-tab {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 14px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: rgba(255,255,255,.4); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.mem-tab:hover { color: rgba(255,255,255,.6); background: rgba(255,255,255,.03); }
.mem-tab.active {
  background: rgba(226,176,95,.1); border-color: rgba(226,176,95,.25); color: #edc67e;
}
.mem-tab-badge {
  background: rgba(226,176,95,.2); color: #edc67e; padding: 1px 7px;
  border-radius: 10px; font-size: 10px; font-weight: 700;
}
.mem-search-inline {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06);
  border-radius: 8px; padding: 4px 10px;
}
.mem-search-inline input {
  background: none; border: none; color: #fff; font-size: 12px; outline: none;
  width: 160px;
}
.mem-search-inline input::placeholder { color: rgba(255,255,255,.25); }

/* Error */
.mem-error {
  display: flex; align-items: center; gap: 6px;
  margin: 8px 16px 0; padding: 8px 12px; border-radius: 8px;
  background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.15);
  color: #ef4444; font-size: 12px;
}

/* Content area */
.mem-content { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

/* Graph layout */
.mem-graph-layout { flex: 1; display: flex; overflow: hidden; position: relative; }
.mem-graph-area {
  flex: 1; position: relative; margin: 10px 16px;
  border-radius: 12px; border: 1px solid rgba(255,255,255,.04);
  background: rgba(0,0,0,.25); overflow: hidden;
}
.mem-graph-canvas { width: 100%; height: 100%; position: absolute; inset: 0; }

/* Graph floating toolbar */
.mem-graph-toolbar {
  position: absolute; top: 10px; left: 10px; z-index: 50;
  display: flex; gap: 6px; flex-wrap: wrap;
}
.mem-graph-explore {
  display: flex; gap: 4px; background: rgba(10,17,40,.85);
  border: 1px solid rgba(255,255,255,.08); border-radius: 8px;
  padding: 4px; backdrop-filter: blur(12px);
}
.mem-graph-explore input {
  background: none; border: none; color: #fff; font-size: 12px;
  padding: 4px 8px; outline: none; width: 160px;
}
.mem-graph-explore input::placeholder { color: rgba(255,255,255,.25); }
.mem-graph-search-type {
  display: flex; gap: 4px; background: rgba(10,17,40,.85);
  border: 1px solid rgba(255,255,255,.08); border-radius: 8px;
  padding: 4px; backdrop-filter: blur(12px);
}
.mem-graph-search-type select {
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08);
  border-radius: 6px; color: #fff; font-size: 11px; padding: 4px 6px; outline: none;
}

/* Graph floating controls (right side) */
.mem-graph-controls {
  position: absolute; top: 10px; right: 10px; z-index: 50;
  display: flex; flex-direction: column; gap: 3px;
}
.mem-graph-controls button {
  width: 30px; height: 30px; border-radius: 7px;
  background: rgba(10,17,40,.85); border: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.5); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(12px); transition: all .12s;
}
.mem-graph-controls button:hover { border-color: rgba(226,176,95,.3); color: #edc67e; }
.mem-graph-controls button .material-symbols-outlined { font-size: 16px; }

/* Stats badge */
.mem-graph-stats {
  position: absolute; bottom: 10px; left: 10px; z-index: 50;
  display: flex; align-items: center; gap: 5px;
  background: rgba(10,17,40,.85); border: 1px solid rgba(255,255,255,.06);
  border-radius: 7px; padding: 5px 10px; font-size: 10px;
  color: rgba(255,255,255,.35); backdrop-filter: blur(12px);
}

/* Detail panel — slides in from right */
.mem-detail-panel {
  width: 0; min-width: 0; overflow: hidden;
  background: rgba(10,17,40,.97); border-left: 1px solid rgba(255,255,255,.04);
  transition: width .25s ease, min-width .25s ease, padding .25s ease;
  padding: 0; flex-shrink: 0;
}
.mem-detail-panel.open {
  width: 300px; min-width: 300px; padding: 16px;
  overflow-y: auto;
}
.mem-detail-inner { animation: memSlideIn .2s ease; }
@keyframes memSlideIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}
.mem-detail-link:hover { background: rgba(226,176,95,.08); }

/* Bottom add bar */
.mem-add-bar {
  display: flex; gap: 6px; padding: 8px 16px 12px; flex-shrink: 0;
  align-items: center; border-top: 1px solid rgba(255,255,255,.04);
}

/* Shared button styles */
.mem-btn-primary {
  padding: 6px 12px; border-radius: 7px;
  background: linear-gradient(135deg,#E2B05F,#c99a4f); color: #fff;
  border: none; font-size: 11px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 4px; white-space: nowrap;
  transition: opacity .12s;
}
.mem-btn-primary:hover { opacity: .9; }
.mem-btn-primary:disabled { opacity: .5; cursor: default; }
.mem-btn-secondary {
  padding: 6px 12px; border-radius: 7px;
  background: rgba(255,255,255,.06); color: rgba(255,255,255,.7);
  border: 1px solid rgba(255,255,255,.08); font-size: 11px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; gap: 4px;
  transition: all .12s;
}
.mem-btn-secondary:hover { border-color: rgba(226,176,95,.25); color: #edc67e; }
.mem-btn-accent {
  padding: 6px 14px; border-radius: 7px;
  background: rgba(91,192,190,.12); color: #5BC0BE;
  border: 1px solid rgba(91,192,190,.25); font-size: 11px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; gap: 4px;
  transition: all .12s;
}
.mem-btn-accent:hover { background: rgba(91,192,190,.18); }
.mem-btn-accent:disabled { opacity: .5; cursor: default; }
.mem-select {
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06);
  border-radius: 7px; padding: 6px 8px; color: #fff; font-size: 11px; outline: none;
}
.mem-input-grow {
  flex: 1; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06);
  border-radius: 7px; padding: 6px 10px; color: #fff; font-size: 12px; outline: none;
  transition: border-color .15s;
}
.mem-input-grow:focus { border-color: rgba(226,176,95,.35); }
.mem-input-grow::placeholder { color: rgba(255,255,255,.2); }

/* Working memory */
.mem-working-layout { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 10px 16px; gap: 10px; }
.mem-working-bar { display: flex; gap: 6px; flex-shrink: 0; }
.mem-working-content { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.mem-working-list { display: flex; flex-direction: column; gap: 6px; }
.mem-working-card {
  background: rgba(255,255,255,.02); border: 1px solid rgba(255,255,255,.04);
  border-radius: 10px; padding: 12px; transition: border-color .15s;
}
.mem-working-card:hover { border-color: rgba(226,176,95,.15); }
.mem-working-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.mem-working-num {
  background: rgba(226,176,95,.12); color: #edc67e; padding: 1px 8px;
  border-radius: 10px; font-size: 10px; font-weight: 700;
}
.mem-working-rel { font-size: 10px; color: rgba(255,255,255,.25); }
.mem-working-card-body {
  font-size: 12px; color: rgba(255,255,255,.65); line-height: 1.6;
}
.mem-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 10px; color: rgba(255,255,255,.2); font-size: 13px;
}

/* Audit */
.mem-audit { margin-top: 8px; }
.mem-audit-title {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; color: rgba(255,255,255,.3);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px;
}
.mem-audit-list { display: flex; flex-direction: column; gap: 2px; }
.mem-audit-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px; border-radius: 5px; font-size: 10px;
  background: rgba(255,255,255,.01);
}
.mem-audit-time { color: rgba(255,255,255,.2); min-width: 120px; }
.mem-audit-op { color: #E2B05F; font-weight: 600; min-width: 80px; }
.mem-audit-agent { color: rgba(255,255,255,.3); }

/* ---- Memory: graph empty-state + ingestion CTA ---- */
.mem-empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; padding: 40px 24px; text-align: center; gap: 12px;
}
.mem-empty-icon { color: rgba(226,176,95,.18); }
.mem-empty-icon .material-symbols-outlined { font-size: 64px; }
.mem-empty-title { font-size: 18px; font-weight: 700; color: #E0E1DD; }
.mem-empty-sub { color: rgba(255,255,255,.45); font-size: 13px; max-width: 480px; line-height: 1.5; }
.mem-empty-noop {
  margin-top: 12px; padding: 12px 18px; border-radius: 10px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.6); font-size: 12px;
  display: inline-flex; align-items: center; gap: 8px; max-width: 540px;
}
.mem-source-grid {
  display: grid; grid-template-columns: repeat(2, minmax(180px, 240px));
  gap: 12px; margin-top: 18px;
}
.mem-source-card {
  background: rgba(15,18,30,.6); border: 1px solid rgba(226,176,95,.18);
  border-radius: 12px; padding: 16px; text-align: center;
}
.mem-source-num { font-size: 28px; font-weight: 700; color: #E2B05F; line-height: 1; }
.mem-source-label { font-size: 12px; color: rgba(255,255,255,.7); margin-top: 6px; font-weight: 500; }
.mem-source-path { font-size: 10px; color: rgba(255,255,255,.3); margin-top: 4px; font-family: ui-monospace, Menlo, monospace; word-break: break-all; }
.mem-ingest-actions {
  margin-top: 20px; display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.mem-ingest-hint { color: rgba(255,255,255,.35); font-size: 11px; max-width: 380px; }
.mem-ingest-running {
  margin-top: 18px; padding: 14px 18px; border-radius: 10px;
  background: rgba(91,192,190,.06); border: 1px solid rgba(91,192,190,.25);
  display: flex; align-items: center; gap: 14px; max-width: 520px;
}
.mem-ingest-status { font-size: 13px; color: #5BC0BE; font-weight: 600; }
.mem-ingest-tail { font-size: 11px; color: rgba(255,255,255,.4); margin-top: 2px; font-family: ui-monospace, Menlo, monospace; max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mem-ingest-spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(91,192,190,.2); border-top-color: #5BC0BE;
  animation: mem-spin .8s linear infinite;
}
@keyframes mem-spin { to { transform: rotate(360deg); } }

/* ---- Memory: header tweaks ---- */
.mem-loading-pip { font-size: 11px; color: rgba(255,255,255,.35); margin-left: auto; padding: 2px 8px; }
.mem-tab-meta { color: rgba(255,255,255,.35); font-size: 11px; display: flex; align-items: center; gap: 6px; }

/* ---- Memory: working tab — context files + working set ---- */
.mem-working-layout { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 24px; }
.mem-working-section { display: flex; flex-direction: column; gap: 10px; }
.mem-section-head {
  display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600;
  color: rgba(255,255,255,.7); text-transform: uppercase; letter-spacing: .5px;
}
.mem-section-count { color: rgba(255,255,255,.3); font-weight: 400; margin-left: 4px; }
.mem-empty-inline { color: rgba(255,255,255,.35); font-size: 12px; padding: 14px 0; font-style: italic; }
.mem-context-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px;
}
.mem-context-card {
  background: rgba(15,18,30,.6); border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px; padding: 10px 12px;
}
.mem-context-name { font-size: 12px; font-weight: 600; color: #E2B05F; font-family: ui-monospace, Menlo, monospace; }
.mem-context-meta { font-size: 10px; color: rgba(255,255,255,.3); margin-top: 3px; }
.mem-working-card.anchored { border-color: rgba(226,176,95,.4); background: rgba(226,176,95,.04); }
.mem-working-anchor { font-size: 10px; color: #E2B05F; font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.mem-working-class {
  font-size: 10px; padding: 1px 6px; border-radius: 4px;
  background: rgba(91,192,190,.1); color: #5BC0BE; font-family: ui-monospace, Menlo, monospace;
}

/* ---- Feed (agent-authored posts) ---- */
.feed-view { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.feed-inner { width: min(100%, 860px); margin: 0 auto; padding: 24px clamp(18px, 4vw, 36px) 56px; }
.feed-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.feed-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.feed-head .feed-sub { font-size: 12px; color: var(--text-muted); }
.feed-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-bottom: 22px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.feed-card-alert {
  border-color: rgba(239,68,68,.42);
  box-shadow: 0 10px 22px rgba(239,68,68,.10), 0 1px 3px rgba(0,0,0,.18);
}
.feed-card-alert .feed-card-header {
  background: linear-gradient(90deg, rgba(239,68,68,.13), transparent 72%);
  border-bottom: 1px solid rgba(239,68,68,.18);
}
.feed-card-alert .feed-card-avatar {
  background: #ef4444;
  color: #fff;
}
.feed-card-alert .feed-card-footer {
  background: linear-gradient(90deg, rgba(239,68,68,.08), transparent 70%);
}
.feed-card-alert .btn-primary {
  background: #ef4444;
  color: #fff;
}
.feed-card-alert .btn-primary:hover { background: #dc2626; }
.feed-card-header {
  padding: 18px clamp(20px, 3vw, 30px) 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.feed-card-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: var(--bg-button-text);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.feed-card-meta { flex: 1; min-width: 0; }
.feed-card-title {
  font-weight: 600; font-size: 15.5px; color: var(--text-primary);
  line-height: 1.3;
}
.feed-card-subtitle { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.feed-card-body {
  padding: 12px clamp(20px, 3vw, 30px) 10px;
  font-size: 15px; line-height: 1.65; color: var(--text-secondary);
}
.feed-card-body h1, .feed-card-body h2, .feed-card-body h3 { color: var(--text-primary); line-height: 1.25; margin: 16px 0 8px; }
.feed-card-body h1 { font-size: 20px; }
.feed-card-body h2 { font-size: 17px; }
.feed-card-body h3 { font-size: 15px; }
.feed-card-body p { margin: 8px 0; }
.feed-card-body table { border-collapse: collapse; width: 100%; min-width: 640px; margin: 10px 0; font-size: 13px; display: block; overflow-x: auto; }
.feed-card-body thead, .feed-card-body tbody, .feed-card-body tr { width: 100%; }
.feed-card-body th, .feed-card-body td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.feed-card-body th { background: var(--bg-input); color: var(--text-primary); }
.feed-card-body pre { background: var(--bg-input); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; overflow-x: auto; font-size: 12.5px; margin: 10px 0; }
.feed-card-body code { font-family: ui-monospace, Menlo, monospace; }
.feed-fade {
  position: absolute; left: 0; right: 0; bottom: 0; height: 64px;
  background: linear-gradient(transparent, var(--bg-card));
  pointer-events: none;
}
.feed-readmore {
  background: none; border: none; cursor: pointer; padding: 0 clamp(20px, 3vw, 30px) 12px;
  color: var(--accent); font-size: 13px; font-weight: 600; font-family: inherit;
}
.feed-card-attachments { padding: 4px clamp(20px, 3vw, 30px) 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.feed-attach {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 18px;
  background: var(--bg-input); border: 1px solid var(--border);
  text-decoration: none; color: var(--text-secondary); font-size: 12.5px;
  transition: background .15s, border-color .15s;
}
.feed-attach:hover { background: var(--bg-card-hover); border-color: var(--border-light); }
.feed-attach .feed-attach-size { color: var(--text-muted); }
.feed-card-footer {
  padding: 14px clamp(20px, 3vw, 30px);
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; align-items: center; gap: 8px;
}
.feed-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600;
}
.feed-chip .material-symbols-outlined { font-size: 14px; }
.feed-chip.alert { background: rgba(239,68,68,.15); color: #ef4444; }
.feed-chip.report { background: var(--bg-nav-active); color: var(--accent); }
.feed-chip.notice { background: rgba(91,192,190,.15); color: var(--accent-secondary); }
.feed-new-chip {
  padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 700;
  background: rgba(91,192,190,.18); color: var(--accent-secondary);
}
.feed-empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.feed-empty .material-symbols-outlined { font-size: 48px; }

@media (max-width: 640px) {
  .feed-inner { padding: 14px 10px 40px; }
  .feed-card { border-radius: 12px; margin-bottom: 14px; }
  .feed-card-header { padding: 14px 14px 10px; align-items: flex-start; }
  .feed-card-avatar { width: 34px; height: 34px; font-size: 14px; }
  .feed-card-body { padding: 10px 14px 8px; font-size: 14px; line-height: 1.55; }
  .feed-card-body h1 { font-size: 18px; }
  .feed-card-body h2 { font-size: 16px; }
  .feed-readmore { padding: 0 14px 10px; }
  .feed-card-attachments { padding: 4px 14px 14px; }
  .feed-card-footer { padding: 12px 14px; }
}

/* ---- Audit detail timeline ---- */
.audit-view { flex: 1; min-height: 0; overflow-y: auto; }
.audit-detail-panel {
  border-top: 1px solid var(--border);
  padding: 12px 16px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  background: rgba(0,0,0,.05);
}
.audit-detail-field {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--bg-input);
  min-width: 0;
}
.audit-detail-label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 5px;
}
.audit-detail-value {
  color: var(--text-primary);
  font-size: 13px;
  word-break: break-word;
}
.audit-detail-field pre {
  margin: 0;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.45;
  max-height: 260px;
  overflow-y: auto;
}


/* ---- Docs / Knowledge Library ---- */
.docs-view { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(360px, 1fr) minmax(360px, .9fr); gap: 18px; padding: 20px 24px; overflow: hidden; }
.docs-main, .docs-detail { min-height: 0; overflow-y: auto; }
.docs-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.docs-header h2 { margin: 0; font-size: 20px; font-weight: 700; }
.docs-filter-row { display: flex; gap: 8px; margin-bottom: 10px; }
.docs-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.docs-list { display: flex; flex-direction: column; gap: 8px; }
.docs-card { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-card); color: var(--text-primary); cursor: pointer; font: inherit; }
.docs-card:hover, .docs-card.active { border-color: var(--accent); background: var(--bg-card-hover); }
.docs-card-icon { color: var(--accent); font-size: 22px; flex-shrink: 0; }
.docs-card-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.docs-card-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docs-card-meta { color: var(--text-muted); font-size: 12px; }
.docs-agent-badge { padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; color: var(--accent-secondary); background: rgba(91,192,190,.15); flex-shrink: 0; }
.docs-detail { border: 1px solid var(--border); border-radius: 12px; background: var(--bg-card); }
.docs-back-btn { display: none; }
.docs-detail-inner { padding: 18px; }
.docs-detail-top { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.docs-detail-top h3 { margin: 0 0 4px; font-size: 18px; }
.docs-detail-meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 12px; }
.docs-detail-meta span { padding: 3px 8px; border-radius: 999px; font-size: 11px; color: var(--text-secondary); background: var(--bg-input); border: 1px solid var(--border); }
.docs-preview { margin-top: 14px; color: var(--text-secondary); line-height: 1.6; }
.docs-preview h1, .docs-preview h2, .docs-preview h3 { color: var(--text-primary); margin: 14px 0 8px; }
.docs-preview p { margin: 8px 0; }
.docs-preview ul, .docs-preview ol { margin: 8px 0 8px 22px; }
.docs-empty-detail { height: 100%; min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--text-muted); text-align: center; padding: 20px; }
.docs-empty-detail .material-symbols-outlined { font-size: 42px; opacity: .6; }
@media (max-width: 900px) {
  .docs-view { grid-template-columns: 1fr; overflow-y: auto; }
  .docs-main, .docs-detail { overflow: visible; }
  .docs-detail { display: none; }
  .docs-view.docs-has-selection .docs-main { display: none; }
  .docs-view.docs-has-selection .docs-detail { display: block; }
  .docs-back-btn { display: inline-flex; align-items: center; gap: 6px; }
}
@media (max-width: 640px) {
  .docs-view { padding: 14px 10px; gap: 12px; }
  .docs-header { align-items: flex-start; flex-direction: column; }
  .docs-header .btn-primary { width: 100%; justify-content: center; }
  .docs-agent-badge { display: none; }
}


/* ---- Settings control room additions ---- */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(320px, 1fr)); gap: 16px; padding: 0 24px 24px; }
.settings-panel.settings-wide { max-width: none; margin: 0; }
.settings-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 24px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.settings-tab { display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; border: none; border-bottom: 2px solid transparent; background: none; color: var(--text-muted); font-size: 13px; font-weight: 650; cursor: pointer; margin-bottom: -1px; border-radius: 6px 6px 0 0; }
.settings-tab .material-symbols-outlined { font-size: 18px; }
.settings-tab:hover { color: var(--text-primary); background: var(--bg-input); }
.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.settings-tab-body { padding: 0 24px 24px; }
.settings-tab-body .settings-panel { max-width: 760px; margin: 0; }
.settings-prefs-form { display: flex; flex-direction: column; gap: 12px; padding: 14px; margin-bottom: 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-input); }
.settings-input { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-panel); color: var(--text-primary); font-size: 13px; }
.settings-input:focus { outline: none; border-color: var(--accent); }
.settings-field-hint { color: var(--text-muted); font-size: 11px; font-weight: 500; }
.settings-info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 38px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-input); }
.settings-row span { color: var(--text-muted); font-size: 12px; font-weight: 600; }
.settings-row strong { color: var(--text-primary); font-size: 13px; text-align: right; font-weight: 650; min-width: 0; }
.settings-pill { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: capitalize; }
.settings-pill.ok { color: var(--accent-secondary); background: rgba(91,192,190,.14); }
.settings-pill.warn { color: #f59e0b; background: rgba(245,158,11,.14); }
.settings-pill.bad { color: #ef4444; background: rgba(239,68,68,.14); }
.settings-source-list { display: flex; flex-direction: column; gap: 10px; }
.settings-source-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-input); }
@media (max-width: 980px) { .settings-grid { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .settings-grid { padding: 0 16px 16px; gap: 12px; } .settings-tabs { padding: 0 8px; overflow-x: auto; flex-wrap: nowrap; } .settings-tab { flex: 0 0 auto; } .settings-tab-body { padding: 0 16px 16px; } .settings-info-grid, .settings-policy-grid { grid-template-columns: 1fr; } .settings-row { align-items: flex-start; flex-direction: column; gap: 4px; } .settings-row strong { text-align: left; } .settings-source-card { align-items: flex-start; flex-direction: column; } }

/* ---- Task detail (full-page view) ---- */
.task-detail { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.task-detail-inner { width: min(100%, 860px); margin: 0 auto; padding: 24px clamp(18px, 4vw, 36px) 56px; }
.task-back-btn { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 16px; border-radius: 20px; padding: 7px 14px; }
.task-detail-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; margin-bottom: 24px; }
.task-detail-header { margin-bottom: 4px; }
.task-detail-titlewrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.task-detail-titlewrap h2 { margin: 0; font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.task-recurring-ico { font-size: 20px; color: var(--accent); }
.task-status-pill { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 3px 10px; border-radius: 12px; background: var(--bg-input); color: var(--text-muted); border: 1px solid var(--border); }
.task-status-pill.ok { color: #22c55e; background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.3); }
.task-status-pill.warn { color: #f59e0b; background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.3); }
.task-status-pill.err { color: #ef4444; background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.3); }
.task-run-info { margin-top: 8px; font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-run-sep { color: var(--text-muted); }
.task-run-pending { color: var(--accent); font-weight: 600; }
.task-detail-desc { margin-top: 12px; font-size: 13.5px; line-height: 1.55; color: var(--text-secondary); white-space: pre-wrap; }
.task-detail-meta { margin-top: 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 20px; }
.task-meta-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.task-meta-row .material-symbols-outlined { font-size: 16px; color: var(--text-muted); }
.task-meta-lbl { color: var(--text-muted); min-width: 70px; }
.task-meta-val { color: var(--text-secondary); font-weight: 500; text-transform: capitalize; }
.task-detail-controls { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-detail-controls .btn { display: inline-flex; align-items: center; gap: 6px; border-radius: 20px; padding: 7px 14px; font-size: 12.5px; }
.btn-danger-outline { background: transparent; color: #ef4444; border: 1px solid rgba(239,68,68,.4); }
.btn-danger-outline:hover { background: rgba(239,68,68,.1); }
.task-runs-hdr { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; }
.task-runs-hdr h3 { margin: 0; font-size: 16px; font-weight: 600; }
.task-runs-hdr .material-symbols-outlined { color: var(--text-muted); }
.task-runs-sub { font-size: 12px; color: var(--text-muted); }
.task-timeline { display: flex; flex-direction: column; gap: 10px; }
.task-timeline-item { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-secondary); background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.task-timeline-item .material-symbols-outlined { font-size: 18px; color: var(--text-muted); }
.task-timeline-when { margin-left: auto; color: var(--text-muted); font-size: 12px; }
@media (max-width: 640px) {
  .task-detail-inner { padding: 16px 14px 40px; }
  .task-detail-card { padding: 16px; }
  .task-detail-meta { grid-template-columns: 1fr; }
}
