    /* =============================================
       Terminal Tab
       ============================================= */
    .terminal-wrapper {
      width: 100%;
      height: 100%;
      position: relative;
      background: #000;
    }

    .terminal-overlay {
      position: absolute;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(0,0,0,0.8);
      z-index: 10;
      font-size: 0.9rem;
      color: var(--text-secondary);
    }

    .terminal-overlay.hidden { display: none; }

    .terminal-connecting {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 0.75rem;
    }

    .terminal-spinner {
      width: 32px;
      height: 32px;
      border: 3px solid var(--border-color);
      border-top-color: var(--indigo);
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
    }

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

    #terminal-container {
      width: 100%;
      height: 100%;
    }

    /* =============================================
       Chat Tab
       ============================================= */
    .chat-container {
      display: flex;
      flex-direction: column;
      height: 100%;
      background: var(--bg-primary);
    }

    .chat-toolbar {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.5rem 0.75rem;
      background: var(--glass-bg);
      border-bottom: 1px solid var(--glass-border);
      flex-shrink: 0;
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
    }

    .chat-toolbar select {
      background: var(--bg-input);
      color: var(--text-primary);
      border: 1px solid var(--border-color);
      border-radius: var(--radius-sm);
      padding: 0.3rem 0.5rem;
      font-size: 0.8rem;
      outline: none;
    }

    .chat-toolbar select:focus {
      border-color: var(--indigo);
    }

    .chat-toolbar .chat-status {
      font-size: 0.75rem;
      color: var(--text-muted);
      margin-left: auto;
    }

    .chat-toolbar .chat-status.processing {
      color: var(--amber);
    }

    .chat-toolbar button {
      background: none;
      border: 1px solid var(--border-color);
      color: var(--text-secondary);
      border-radius: var(--radius-sm);
      padding: 0.3rem 0.6rem;
      font-size: 0.75rem;
      cursor: pointer;
      transition: all var(--transition-fast);
    }

    .chat-toolbar button:hover {
      background: var(--bg-card-hover);
      color: var(--text-primary);
    }

    .chat-messages {
      flex: 1;
      overflow-y: auto;
      padding: 1rem;
      display: flex;
      flex-direction: column;
      gap: 0.75rem;
      scroll-behavior: smooth;
    }

    .chat-messages::-webkit-scrollbar {
      width: 6px;
    }

    .chat-messages::-webkit-scrollbar-thumb {
      background: var(--border-color);
      border-radius: 3px;
    }

    .chat-msg {
      display: flex;
      gap: 0.5rem;
      max-width: 85%;
      animation: chatFadeIn 0.2s ease forwards;
    }

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

    .chat-msg.user {
      align-self: flex-end;
      flex-direction: row-reverse;
    }

    .chat-msg.assistant {
      align-self: flex-start;
    }

    .chat-avatar {
      width: 28px;
      height: 28px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 0.75rem;
      font-weight: 600;
      flex-shrink: 0;
      margin-top: 2px;
      transform: translateZ(0);
    }

    .chat-msg.user .chat-avatar {
      background: var(--indigo);
      color: white;
    }

    .chat-msg.assistant .chat-avatar {
      background: var(--emerald-dark);
      color: white;
    }

    .chat-bubble {
      padding: 0.6rem 0.85rem;
      border-radius: var(--radius-md);
      font-size: 0.875rem;
      line-height: 1.55;
      position: relative;
    }

    .chat-msg.user .chat-bubble {
      background: linear-gradient(135deg, var(--indigo), var(--indigo-dark));
      color: white;
      border-bottom-right-radius: 4px;
    }

    .chat-msg.assistant .chat-bubble {
      background: var(--glass-bg);
      border: 1px solid rgba(139,92,246,0.1);
      border-bottom-left-radius: 4px;
      color: var(--text-primary);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
    }

    /* Markdown inside chat */
    .chat-bubble p { margin: 0 0 0.5rem 0; }
    .chat-bubble p:last-child { margin-bottom: 0; }
    .chat-bubble ul, .chat-bubble ol { margin: 0.25rem 0 0.5rem 1.25rem; }
    .chat-bubble li { margin: 0.15rem 0; }
    .chat-bubble strong { color: var(--indigo-light); font-weight: 600; }
    .chat-bubble em { color: var(--text-secondary); }
    .chat-bubble a { color: var(--indigo-light); text-decoration: underline; }
    .chat-bubble h1, .chat-bubble h2, .chat-bubble h3 {
      font-size: 0.95rem;
      margin: 0.5rem 0 0.3rem;
      color: var(--text-primary);
    }

    .chat-bubble code {
      background: rgba(0,0,0,0.3);
      padding: 0.15rem 0.35rem;
      border-radius: 4px;
      font-size: 0.8rem;
      font-family: 'Fira Code', 'JetBrains Mono', monospace;
    }

    .chat-bubble pre {
      background: rgba(5,5,16,0.8);
      border: 1px solid var(--glass-border);
      border-radius: var(--radius-sm);
      padding: 0.65rem;
      margin: 0.4rem 0;
      overflow-x: auto;
      font-size: 0.8rem;
      line-height: 1.4;
    }

    .chat-bubble pre code {
      background: none;
      padding: 0;
      font-size: inherit;
    }

    /* Tool use blocks */
    .chat-tool {
      background: rgba(99, 102, 241, 0.08);
      border: 1px solid rgba(99, 102, 241, 0.2);
      border-radius: var(--radius-sm);
      margin: 0.4rem 0;
      font-size: 0.8rem;
      overflow: hidden;
    }

    .chat-tool-header {
      display: flex;
      align-items: center;
      gap: 0.4rem;
      padding: 0.35rem 0.6rem;
      cursor: pointer;
      color: var(--indigo-light);
      font-weight: 500;
      user-select: none;
    }

    .chat-tool-header:hover {
      background: rgba(99, 102, 241, 0.05);
    }

    .chat-tool-header .tool-icon {
      width: 14px;
      height: 14px;
      opacity: 0.7;
    }

    .chat-tool-header .tool-chevron {
      margin-left: auto;
      transition: transform var(--transition-fast);
      opacity: 0.5;
    }

    .chat-tool-header .tool-chevron.open {
      transform: rotate(90deg);
    }

    .chat-tool-body {
      display: none;
      padding: 0.4rem 0.6rem;
      border-top: 1px solid rgba(99, 102, 241, 0.15);
      color: var(--text-secondary);
      font-family: 'Fira Code', monospace;
      font-size: 0.75rem;
      max-height: 200px;
      overflow-y: auto;
      white-space: pre-wrap;
      word-break: break-all;
    }

    .chat-tool-body.open {
      display: block;
    }

    .chat-tool-result {
      background: rgba(16, 185, 129, 0.08);
      border-color: rgba(16, 185, 129, 0.2);
    }

    .chat-tool-result .chat-tool-header {
      color: var(--emerald);
    }

    .chat-tool-error {
      background: rgba(244, 63, 94, 0.08);
      border-color: rgba(244, 63, 94, 0.2);
    }

    .chat-tool-error .chat-tool-header {
      color: var(--rose);
    }

    /* Thinking/processing indicator */
    .chat-thinking {
      align-self: flex-start;
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.5rem 0.75rem;
      font-size: 0.8rem;
      color: var(--text-muted);
    }

    .chat-thinking .dots {
      display: flex;
      gap: 3px;
    }

    .chat-thinking .dots span {
      width: 5px;
      height: 5px;
      background: var(--indigo);
      border-radius: 50%;
      animation: chatDot 1.2s infinite;
    }

    .chat-thinking .dots span:nth-child(2) { animation-delay: 0.2s; }
    .chat-thinking .dots span:nth-child(3) { animation-delay: 0.4s; }

    @keyframes chatDot {
      0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
      40% { opacity: 1; transform: scale(1.1); }
    }

    /* Chat input area */
    .chat-input-area {
      padding: 0.75rem;
      background: var(--glass-bg);
      border-top: 1px solid var(--glass-border);
      flex-shrink: 0;
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
    }

    .chat-input-wrapper {
      display: flex;
      gap: 0.5rem;
      align-items: flex-end;
    }

    .chat-input-wrapper textarea {
      flex: 1;
      background: var(--bg-input);
      color: var(--text-primary);
      border: 1px solid var(--border-color);
      border-radius: var(--radius-md);
      padding: 0.6rem 0.75rem;
      font-size: 0.875rem;
      font-family: inherit;
      resize: none;
      min-height: 42px;
      max-height: 150px;
      line-height: 1.4;
      outline: none;
      transition: border-color var(--transition-fast);
    }

    .chat-input-wrapper textarea:focus {
      border-color: var(--indigo);
    }

    .chat-input-wrapper textarea::placeholder {
      color: var(--text-muted);
    }

    .chat-send-btn {
      width: 42px;
      height: 42px;
      background: linear-gradient(135deg, var(--indigo), var(--indigo-dark));
      color: white;
      border: 1px solid rgba(255,255,255,0.1);
      border-radius: var(--radius-md);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all var(--transition-fast);
      flex-shrink: 0;
    }

    .chat-send-btn:hover { box-shadow: 0 0 16px rgba(124,58,237,0.4); }
    .chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

    .chat-send-btn svg {
      width: 18px;
      height: 18px;
    }

    .chat-stop-btn {
      width: 42px;
      height: 42px;
      background: var(--rose);
      color: white;
      border: none;
      border-radius: var(--radius-md);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all var(--transition-fast);
      flex-shrink: 0;
    }

    .chat-stop-btn:hover { background: var(--rose-dark); }

    .chat-meta {
      display: flex;
      justify-content: space-between;
      margin-top: 0.35rem;
      font-size: 0.7rem;
      color: var(--text-muted);
      padding: 0 0.25rem;
    }

    .chat-empty {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      color: var(--text-muted);
      gap: 0.5rem;
      padding: 2rem;
    }

    .chat-empty svg {
      width: 48px;
      height: 48px;
      opacity: 0.4;
    }

    .chat-empty p {
      font-size: 0.9rem;
    }

    /* =============================================
       Emma Panel (Global Overlay)
       ============================================= */
    .emma-panel {
      position: fixed;
      top: 53px;
      right: 0;
      width: 440px;
      height: calc(100vh - 53px - env(safe-area-inset-bottom, 0px));
      height: calc(100dvh - 53px - env(safe-area-inset-bottom, 0px));
      min-width: 320px;
      min-height: 400px !important;
      display: flex;
      flex-direction: column;
      background: var(--glass-bg);
      border-left: 1px solid var(--glass-border);
      z-index: 900;
      box-shadow: -4px 0 32px rgba(0, 0, 0, 0.35), -2px 0 12px rgba(139,92,246,0.08);
      transform: translateX(0);
      transition: transform 0.25s ease, opacity 0.25s ease;
      backdrop-filter: blur(var(--glass-blur));
      -webkit-backdrop-filter: blur(var(--glass-blur));
    }
    .emma-panel.resizing { transition: none !important; }
    .emma-panel.dragging { transition: none !important; opacity: 0.92; }

    .emma-panel.collapsed {
      transform: translateX(100%);
      opacity: 0;
      pointer-events: none;
    }

    /* Resize handle — left edge */
    .emma-resize-handle {
      position: absolute;
      left: -4px;
      top: 0;
      width: 8px;
      height: 100%;
      cursor: col-resize;
      z-index: 910;
      background: transparent;
    }
    .emma-resize-handle:hover,
    .emma-resize-handle.active {
      background: linear-gradient(90deg, transparent, rgba(168,85,247,0.35), transparent);
    }

    /* Sidebar toggle replaces old drag handle in header */

    /* Auto-model indicator badge */
    .emma-model-badge {
      display: inline-flex;
      align-items: center;
      gap: 0.2rem;
      font-size: 0.6rem;
      font-weight: 600;
      padding: 0.1rem 0.35rem;
      border-radius: 8px;
      text-transform: uppercase;
      letter-spacing: 0.03em;
    }
    .emma-model-badge.opus { background: rgba(168,85,247,0.2); color: var(--purple); }
    .emma-model-badge.sonnet { background: rgba(99,102,241,0.2); color: var(--indigo-light); }
    .emma-model-badge.haiku { background: rgba(16,185,129,0.2); color: var(--emerald); }
    .emma-model-badge .thinking-dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--purple); animation: emmaPulse 3s ease infinite; }
    @keyframes emmaPulse { 0%,100% { opacity: 0.3; } 50% { opacity: 1; } }

    /* Effort level badge */
    .effort-badge {
      display: inline-flex;
      align-items: center;
      gap: 3px;
      font-size: 0.62rem;
      font-weight: 600;
      padding: 1px 6px;
      border-radius: 8px;
      letter-spacing: 0.03em;
      text-transform: uppercase;
      white-space: nowrap;
      transition: all var(--transition-fast);
    }
    .effort-badge.quick { background: rgba(16,185,129,0.2); color: var(--emerald); }
    .effort-badge.standard { background: rgba(99,102,241,0.2); color: var(--indigo-light); }
    .effort-badge.deep { background: rgba(168,85,247,0.2); color: var(--purple); }
    .effort-badge.maximum { background: rgba(244,63,94,0.2); color: var(--rose); }
    .effort-badge .effort-icon { font-size: 0.7rem; }

    /* Template selector in input area */
    .emma-template-select {
      font-size: 0.65rem;
      padding: 2px 6px;
      background: var(--bg-input);
      color: var(--text-secondary);
      border: 1px solid var(--border-color);
      border-radius: 6px;
      cursor: pointer;
      outline: none;
      transition: all var(--transition-fast);
    }
    .emma-template-select:hover { border-color: var(--border-light); color: var(--text-primary); }
    .emma-template-select:focus { border-color: var(--indigo); }

    /* Todo list bar at bottom */
    .emma-todo-bar {
      border-top: 1px solid var(--glass-border);
      background: rgba(8, 9, 13, 0.7);
      flex-shrink: 0;
      max-height: 140px;
      overflow-y: auto;
      display: none;
    }
    .emma-todo-bar.visible { display: block; }
    .emma-todo-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0.3rem 0.6rem;
      font-size: 0.68rem;
      font-weight: 600;
      color: var(--text-secondary);
      text-transform: uppercase;
      letter-spacing: 0.05em;
      border-bottom: 1px solid var(--border-color);
      position: sticky;
      top: 0;
      background: var(--bg-primary);
      z-index: 1;
    }
    .emma-todo-header .count { background: var(--purple); color: white; border-radius: 8px; padding: 0 0.35rem; font-size: 0.6rem; }
    .emma-todo-list { padding: 0.25rem 0.4rem; }
    .emma-todo-item {
      display: flex;
      align-items: center;
      gap: 0.3rem;
      padding: 0.2rem 0.25rem;
      font-size: 0.7rem;
      color: var(--text-secondary);
      border-radius: 4px;
    }
    .emma-todo-item.active { color: var(--text-primary); background: rgba(168,85,247,0.06); }
    .emma-todo-item .icon { flex-shrink: 0; font-size: 0.65rem; }
    .emma-todo-item .icon.pending { color: var(--text-muted); }
    .emma-todo-item .icon.running { color: var(--purple); animation: emmaSpin 1s linear infinite; }
    .emma-todo-item .icon.done { color: var(--emerald); }
    .emma-todo-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    .emma-panel-header {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.75rem 1rem;
      border-bottom: 1px solid var(--glass-border);
      flex-shrink: 0;
      background: rgba(15, 17, 28, 0.6);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
    }

    /* Emma Activity Feed — persistent across chat switches */
    .emma-activity-bar {
      display: none;
      flex-wrap: wrap;
      align-items: center;
      gap: 0.25rem;
      padding: 0.2rem 0.5rem;
      border-bottom: 1px solid rgba(139,92,246,0.08);
      background: rgba(10, 11, 18, 0.6);
      flex-shrink: 0;
      font-size: 0.6rem;
    }
    .emma-activity-bar.visible { display: flex; }
    .emma-activity-chip {
      display: inline-flex;
      align-items: center;
      gap: 0.2rem;
      padding: 0.1rem 0.35rem;
      border-radius: 3px;
      color: var(--text-secondary);
      white-space: nowrap;
      max-width: 220px;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .emma-activity-chip.active { color: var(--text-primary); background: rgba(139,92,246,0.08); }
    .emma-activity-chip.completed { opacity: 0.5; }
    .emma-activity-chip.error { color: #ef4444; }
    .emma-activity-chip .act-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
    .emma-activity-chip.active .act-dot { background: #f87171; animation: activity-pulse 3.5s ease-in-out infinite; }
    .emma-activity-chip.completed .act-dot { background: #22c55e; }
    .emma-activity-chip.error .act-dot { background: #ef4444; }
    .emma-activity-chip.stale .act-dot { background: #6b7280; }
    @keyframes activity-pulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.3; }
    }

    .emma-task-bar {
      display: none;
      padding: 0.4rem 0.6rem;
      border-bottom: 1px solid var(--glass-border);
      background: rgba(10, 11, 18, 0.7);
      flex-shrink: 0;
      overflow-x: auto;
      gap: 0.4rem;
      flex-wrap: nowrap;
    }
    .emma-task-bar.visible {
      display: flex;
    }
    .emma-task-card {
      display: flex;
      align-items: center;
      gap: 0.35rem;
      padding: 0.25rem 0.5rem;
      border-radius: 6px;
      background: rgba(139, 92, 246, 0.1);
      border: 1px solid rgba(139, 92, 246, 0.2);
      cursor: pointer;
      white-space: nowrap;
      font-size: 0.7rem;
      color: var(--text-secondary);
      transition: all 0.2s;
      min-width: 0;
      flex-shrink: 0;
    }
    .emma-task-card:hover {
      background: rgba(139, 92, 246, 0.2);
      border-color: rgba(139, 92, 246, 0.4);
    }
    .emma-task-card.active {
      border-color: rgba(139, 92, 246, 0.5);
      background: rgba(139, 92, 246, 0.15);
      color: var(--text-primary);
    }
    .emma-task-card .task-spinner {
      width: 10px;
      height: 10px;
      border: 2px solid rgba(139, 92, 246, 0.3);
      border-top: 2px solid var(--accent-primary);
      border-radius: 50%;
      animation: spin 1s linear infinite;
    }
    .emma-task-card .task-title {
      max-width: 120px;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .emma-task-card .task-time {
      color: var(--text-tertiary);
      font-size: 0.62rem;
    }
    .emma-task-card .task-stop {
      color: var(--text-tertiary);
      cursor: pointer;
      font-size: 0.75rem;
      padding: 0 0.15rem;
      line-height: 1;
    }
    .emma-task-card .task-stop:hover {
      color: #ef4444;
    }
    .emma-task-card.done {
      opacity: 0.5;
      border-color: rgba(34, 197, 94, 0.3);
      background: rgba(34, 197, 94, 0.05);
    }
    .emma-task-card.done .task-spinner {
      display: none;
    }

    /* Persistent Task Queue */
    .emma-task-queue-bar {
      display: none;
      padding: 0.35rem 0.5rem;
      border-bottom: 1px solid var(--glass-border);
      background: rgba(10, 11, 18, 0.85);
      flex-shrink: 0;
      gap: 0.35rem;
      flex-wrap: wrap;
      align-items: center;
    }
    .emma-task-queue-bar.visible {
      display: flex;
    }
    .emma-tq-item {
      display: inline-flex;
      align-items: center;
      gap: 0.3rem;
      padding: 0.2rem 0.5rem;
      border-radius: 20px;
      font-size: 0.65rem;
      cursor: pointer;
      transition: all 0.2s;
      border: 1px solid transparent;
      max-width: 180px;
      overflow: hidden;
    }
    .emma-tq-item:hover {
      background: rgba(255,255,255,0.08);
      border-color: rgba(255,255,255,0.12);
    }
    .emma-tq-item.active {
      border-color: rgba(139, 92, 246, 0.4);
      background: rgba(139, 92, 246, 0.12);
    }
    .emma-tq-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      flex-shrink: 0;
      transition: background 0.3s;
    }
    .emma-tq-dot.pulsing {
      animation: tqPulse 3.5s ease-in-out infinite;
    }
    @keyframes tqPulse {
      0%, 100% { opacity: 1; transform: scale(1); }
      50% { opacity: 0.5; transform: scale(0.85); }
    }
    .emma-tq-title {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      color: var(--text-secondary);
      font-weight: 500;
    }
    .emma-tq-dismiss {
      font-size: 0.6rem;
      color: var(--text-muted);
      cursor: pointer;
      padding: 0 2px;
      opacity: 0;
      transition: opacity 0.15s;
    }
    .emma-tq-item:hover .emma-tq-dismiss {
      opacity: 0.7;
    }
    .emma-tq-dismiss:hover {
      opacity: 1 !important;
      color: var(--rose);
    }

    .emma-avatar {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      background: linear-gradient(135deg, #ef4444, #dc2626);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 0.9rem;
      font-weight: 700;
      color: white;
      flex-shrink: 0;
      border: 1px solid rgba(168,85,247,0.3);
    }

    .emma-header-info {
      flex: 1;
      min-width: 0;
    }

    .emma-header-name {
      font-size: 0.9rem;
      font-weight: 700;
      color: var(--text-primary);
      display: flex;
      align-items: center;
      gap: 0.4rem;
    }

    .emma-model-inline {
      font-size: 0.6rem;
      font-weight: 600;
      padding: 0.08rem 0.35rem;
      border-radius: 6px;
      background: rgba(168,85,247,0.2);
      color: var(--purple);
      text-transform: uppercase;
      letter-spacing: 0.03em;
    }

    .emma-header-status {
      font-size: 0.7rem;
      color: var(--text-muted);
      display: flex;
      align-items: center;
      gap: 0.35rem;
    }

    .emma-header-status.processing {
      color: var(--purple);
    }

    .emma-working-dots {
      display: inline-flex;
      gap: 3px;
      align-items: center;
    }
    .emma-working-dots span {
      width: 4px;
      height: 4px;
      border-radius: 50%;
      background: var(--purple);
      animation: emmaWorkDot 3.5s ease-in-out infinite;
    }
    .emma-working-dots span:nth-child(2) { animation-delay: 0.2s; }
    .emma-working-dots span:nth-child(3) { animation-delay: 0.4s; }
    @keyframes emmaWorkDot {
      0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
      40% { opacity: 1; transform: scale(1.2); }
    }

    /* Avatar glow when working */
    .emma-avatar.working {
      animation: emmaAvatarGlow 4s ease-in-out infinite;
      border-color: rgba(168,85,247,0.6);
      will-change: box-shadow;
    }
    @keyframes emmaAvatarGlow {
      0%, 100% { box-shadow: 0 0 10px 3px rgba(168, 85, 247, 0.4), 0 0 20px 6px rgba(168, 85, 247, 0.15); }
      50% { box-shadow: 0 0 18px 8px rgba(168, 85, 247, 0.7), 0 0 32px 12px rgba(168, 85, 247, 0.25); }
    }

    .emma-header-actions {
      display: flex;
      gap: 0.25rem;
    }

    .emma-header-actions button {
      width: 28px;
      height: 28px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: var(--glass-bg);
      border: 1px solid var(--glass-border);
      border-radius: var(--radius-sm);
      color: var(--text-muted);
      cursor: pointer;
      transition: all var(--transition-fast);
    }

    .emma-header-actions button:hover {
      background: var(--bg-card-hover);
      color: var(--text-primary);
    }

    .emma-header-actions button svg {
      width: 14px;
      height: 14px;
      fill: currentColor;
    }

    /* Emma layout: tab strip above chat area */
    .emma-body {
      display: flex;
      flex-direction: column;
      height: 100%;
      overflow: hidden;
      contain: layout;
    }

    /* ---- Pill Tab Strip ---- */
    .emma-tab-strip {
      display: flex;
      align-items: center;
      gap: 4px;
      padding: 5px 8px;
      background: rgba(8, 9, 13, 0.6);
      flex-shrink: 0;
      overflow-x: auto;
      overflow-y: hidden;
      scrollbar-width: none;
      -ms-overflow-style: none;
    }
    .emma-tab-strip::-webkit-scrollbar { display: none; }

    .emma-tab-strip .tab-new-btn {
      width: 26px;
      height: 26px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(255,255,255,0.04);
      border: 1px solid rgba(255,255,255,0.06);
      color: var(--text-muted);
      cursor: pointer;
      border-radius: 999px;
      flex-shrink: 0;
      font-size: 0.85rem;
      transition: all 0.15s;
    }
    .emma-tab-strip .tab-new-btn:hover {
      background: rgba(168, 85, 247, 0.15);
      border-color: rgba(168, 85, 247, 0.3);
      color: var(--purple);
    }

    .emma-tab-browser {
      display: flex;
      flex-direction: column;
      justify-content: center;
      padding: 4px 10px;
      font-size: 0.65rem;
      font-weight: 500;
      color: var(--text-muted);
      background: rgba(255,255,255,0.04);
      border: 1px solid rgba(255,255,255,0.06);
      border-radius: 999px;
      cursor: pointer;
      white-space: nowrap;
      flex: 1 1 0;
      min-width: 80px;
      transition: all 0.15s;
      position: relative;
      overflow: hidden;
    }
    .emma-tab-browser .tab-row {
      display: flex;
      align-items: center;
      gap: 5px;
      width: 100%;
    }

    .emma-tab-browser:hover {
      background: rgba(255,255,255,0.08);
      color: var(--text-primary);
      border-color: rgba(255,255,255,0.1);
    }
    .emma-tab-browser[class*="stage-"]:not(.stage-completed):not(.stage-error):hover {
      filter: brightness(1.15);
    }

    .emma-tab-browser.active {
      background: rgba(139, 92, 246, 0.15);
      color: var(--text-primary);
      border-color: rgba(139, 92, 246, 0.4);
      box-shadow: 0 0 8px rgba(139, 92, 246, 0.12);
    }

    .emma-tab-browser .tab-stage-dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      flex-shrink: 0;
    }

    .emma-tab-browser .tab-title {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      flex: 1;
      min-width: 0;
    }

    .emma-tab-browser .tab-close {
      width: 18px;
      height: 18px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 50%;
      font-size: 0.7rem;
      font-weight: 700;
      line-height: 1;
      color: var(--text-muted);
      cursor: pointer;
      opacity: 0.6;
      transition: all 0.15s;
      flex-shrink: 0;
      margin-right: -4px;
    }
    .emma-tab-browser:hover .tab-close { opacity: 1; }
    .emma-tab-browser .tab-close:hover { opacity: 1 !important; background: rgba(244, 63, 94, 0.25); color: var(--rose); }

    /* Pinned master tab */
    .emma-tab-browser.pinned {
      background: rgba(139, 92, 246, 0.06);
      border-color: rgba(139, 92, 246, 0.15);
    }
    .emma-tab-browser.pinned.active {
      background: rgba(139, 92, 246, 0.18);
      border-color: rgba(139, 92, 246, 0.45);
    }
    .emma-tab-browser.pinned .tab-close { display: none; }
    .emma-tab-browser.pinned .tab-stage-dot {
      background: linear-gradient(135deg, #ef4444, #dc2626);
    }

    .emma-tab-browser .tab-count {
      font-size: 0.5rem;
      background: rgba(139, 92, 246, 0.3);
      color: #c4b5fd;
      padding: 1px 5px;
      border-radius: 999px;
      line-height: 1.3;
      flex-shrink: 0;
    }
    .emma-tab-browser .tab-count:empty { display: none; }

    /* Tab progress bar — real-time smooth transitions */
    .tab-progress-bar {
      position: absolute;
      bottom: 0;
      left: 0;
      height: 3px;
      border-radius: 0 999px 999px 0;
      transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.4s ease;
      opacity: 0.9;
    }
    .tab-progress-bar.active {
      background-image: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.25) 50%, transparent 100%);
      background-size: 200% 100%;
      animation: progressShimmer 1.5s linear infinite;
    }
    @keyframes progressShimmer {
      0% { background-position: -200% 0; }
      100% { background-position: 200% 0; }
    }

    /* --- Stage colors: dot indicators --- */
    .emma-tab-browser.stage-assigning .tab-stage-dot { background: #ef4444; }
    .emma-tab-browser.stage-planning .tab-stage-dot { background: #3b82f6; }
    .emma-tab-browser.stage-working .tab-stage-dot { background: #f59e0b; }
    .emma-tab-browser.stage-discussion .tab-stage-dot { background: #ec4899; }
    .emma-tab-browser.stage-validating .tab-stage-dot { background: #06b6d4; }
    .emma-tab-browser.stage-awaiting_approval .tab-stage-dot { background: #f87171; }
    .emma-tab-browser.stage-interrupted .tab-stage-dot { background: #f97316; }
    .emma-tab-browser.stage-completed .tab-stage-dot { background: #22c55e; }
    .emma-tab-browser.stage-error .tab-stage-dot { background: #ef4444; }

    /* --- Stage pill tints --- */
    .emma-tab-browser.stage-assigning { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.2); }
    .emma-tab-browser.stage-planning { background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.2); }
    .emma-tab-browser.stage-working { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.2); }
    .emma-tab-browser.stage-discussion { background: rgba(236,72,153,0.08); border-color: rgba(236,72,153,0.2); }
    .emma-tab-browser.stage-validating { background: rgba(6,182,212,0.08); border-color: rgba(6,182,212,0.2); }
    .emma-tab-browser.stage-awaiting_approval { background: rgba(167,139,250,0.08); border-color: rgba(167,139,250,0.2); }
    .emma-tab-browser.stage-interrupted { background: rgba(249,115,22,0.08); border-color: rgba(249,115,22,0.2); }
    .emma-tab-browser.stage-completed { background: rgba(34,197,94,0.08); border-color: rgba(34,197,94,0.2); }
    .emma-tab-browser.stage-error { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.25); }

    /* Active pill intensifies */
    .emma-tab-browser.active.stage-assigning { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.4); }
    .emma-tab-browser.active.stage-planning { background: rgba(59,130,246,0.15); border-color: rgba(59,130,246,0.4); }
    .emma-tab-browser.active.stage-working { background: rgba(245,158,11,0.15); border-color: rgba(245,158,11,0.4); }
    .emma-tab-browser.active.stage-discussion { background: rgba(236,72,153,0.15); border-color: rgba(236,72,153,0.4); }
    .emma-tab-browser.active.stage-validating { background: rgba(6,182,212,0.15); border-color: rgba(6,182,212,0.4); }
    .emma-tab-browser.active.stage-awaiting_approval { background: rgba(167,139,250,0.15); border-color: rgba(167,139,250,0.4); }
    .emma-tab-browser.active.stage-completed { background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.35); }
    .emma-tab-browser.active.stage-error { background: rgba(239,68,68,0.18); border-color: rgba(239,68,68,0.45); }

    /* --- Full tab pulsation keyframes --- */
    @keyframes tab-glow-red {
      0%, 100% {
        background: rgba(239, 68, 68, 0.06);
        box-shadow: 0 0 4px rgba(239, 68, 68, 0.1);
      }
      50% {
        background: rgba(239, 68, 68, 0.14);
        box-shadow: 0 0 12px rgba(239, 68, 68, 0.25), 0 0 4px rgba(239, 68, 68, 0.15);
      }
    }
    @keyframes tab-glow-blue {
      0%, 100% {
        background: rgba(59, 130, 246, 0.06);
        box-shadow: 0 0 4px rgba(59, 130, 246, 0.1);
      }
      50% {
        background: rgba(59, 130, 246, 0.14);
        box-shadow: 0 0 12px rgba(59, 130, 246, 0.25), 0 0 4px rgba(59, 130, 246, 0.15);
      }
    }
    @keyframes tab-glow-yellow {
      0%, 100% {
        background: rgba(245, 158, 11, 0.06);
        box-shadow: 0 0 4px rgba(245, 158, 11, 0.1);
      }
      50% {
        background: rgba(245, 158, 11, 0.16);
        box-shadow: 0 0 14px rgba(245, 158, 11, 0.3), 0 0 5px rgba(245, 158, 11, 0.18);
      }
    }
    @keyframes tab-glow-pink {
      0%, 100% {
        background: rgba(236, 72, 153, 0.05);
        box-shadow: 0 0 4px rgba(236, 72, 153, 0.1);
      }
      50% {
        background: rgba(236, 72, 153, 0.13);
        box-shadow: 0 0 12px rgba(236, 72, 153, 0.25), 0 0 4px rgba(236, 72, 153, 0.15);
      }
    }
    @keyframes tab-glow-cyan {
      0% {
        background: rgba(6, 182, 212, 0.05);
        box-shadow: 0 0 4px rgba(6, 182, 212, 0.1);
      }
      33% {
        background: rgba(6, 182, 212, 0.12);
        box-shadow: 0 0 10px rgba(6, 182, 212, 0.2), 0 0 3px rgba(6, 182, 212, 0.1);
      }
      66% {
        background: rgba(6, 182, 212, 0.08);
        box-shadow: 0 0 14px rgba(6, 182, 212, 0.3), 0 0 5px rgba(6, 182, 212, 0.15);
      }
      100% {
        background: rgba(6, 182, 212, 0.05);
        box-shadow: 0 0 4px rgba(6, 182, 212, 0.1);
      }
    }
    @keyframes tab-glow-purple {
      0%, 100% {
        background: rgba(167, 139, 250, 0.05);
        box-shadow: 0 0 4px rgba(167, 139, 250, 0.1);
      }
      50% {
        background: rgba(167, 139, 250, 0.12);
        box-shadow: 0 0 10px rgba(167, 139, 250, 0.2);
      }
    }
    @keyframes tab-glow-orange {
      0%, 100% {
        background: rgba(249, 115, 22, 0.06);
        box-shadow: 0 0 4px rgba(249, 115, 22, 0.1);
      }
      50% {
        background: rgba(249, 115, 22, 0.14);
        box-shadow: 0 0 12px rgba(249, 115, 22, 0.25);
      }
    }

    /* Per-tab agent bar (shown below tab strip for active tab) */
    /* Global agent bar — hidden, agents now shown per-tab */
    .emma-tab-agents { display: none !important; }
    /* Per-tab agent dots — row under each tab */
    .tab-agents-row {
      display: flex;
      gap: 4px;
      justify-content: center;
      padding: 2px 0 1px;
      min-height: 0;
    }
    .tab-agents-row:empty { display: none; }
    .tab-agent-dot {
      width: 7px;
      height: 7px;
      border-radius: 50%;
      flex-shrink: 0;
      transition: all 0.3s;
    }
    .tab-agent-dot.developer { background: #60a5fa; box-shadow: 0 0 4px rgba(96, 165, 250, 0.4); }
    .tab-agent-dot.reviewer { background: #fbbf24; box-shadow: 0 0 4px rgba(251, 191, 36, 0.4); }
    .tab-agent-dot.fixer { background: #fb7185; box-shadow: 0 0 4px rgba(251, 113, 133, 0.4); }
    .tab-agent-dot.researcher { background: #34d399; box-shadow: 0 0 4px rgba(52, 211, 153, 0.4); }
    .tab-agent-dot.agent { background: #f87171; box-shadow: 0 0 4px rgba(167, 139, 250, 0.4); }
    .tab-agent-dot.running { animation: agentDotPulse 3.5s ease-in-out infinite; }
    .tab-agent-dot.done { opacity: 0.35; box-shadow: none; }
    .tab-agent-dot.error { background: #ef4444; box-shadow: 0 0 4px rgba(239, 68, 68, 0.5); }
    @keyframes agentDotPulse {
      0%, 100% { transform: scale(0.9); opacity: 0.65; }
      50% { transform: scale(1.1); opacity: 1; }
    }
    /* Stage label badge on tabs */
    .tab-stage-label {
      font-size: 0.5rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      padding: 0px 4px;
      border-radius: 3px;
      line-height: 1.5;
      flex-shrink: 0;
      white-space: nowrap;
    }
    .tab-stage-label.stage-label-assigning { color: #fca5a5; background: rgba(239, 68, 68, 0.15); }
    .tab-stage-label.stage-label-planning { color: #93c5fd; background: rgba(59, 130, 246, 0.15); }
    .tab-stage-label.stage-label-working { color: #fcd34d; background: rgba(245, 158, 11, 0.15); }
    .tab-stage-label.stage-label-discussion { color: #f9a8d4; background: rgba(236, 72, 153, 0.15); }
    .tab-stage-label.stage-label-validating { color: #67e8f9; background: rgba(6, 182, 212, 0.15); }
    .tab-stage-label.stage-label-awaiting_approval { color: #c4b5fd; background: rgba(167, 139, 250, 0.15); }
    .tab-stage-label.stage-label-interrupted { color: #fdba74; background: rgba(249, 115, 22, 0.15); }

    /* Legacy chip styles kept for compatibility but not rendered */
    .emma-tab-agent-chip { display: none; }

    /* --- Orchestrator View --- */
    .orch-view { padding: 1rem 1.2rem; font-size: 0.78rem; color: var(--text-secondary); }
    .orch-header { margin-bottom: 1.2rem; }
    .orch-title { font-size: 1.1rem; font-weight: 700; color: var(--purple); margin: 0; }
    .orch-subtitle { font-size: 0.7rem; color: var(--text-tertiary); margin-top: 0.15rem; }
    .orch-section { margin-bottom: 1rem; }
    .orch-section-header {
      display: flex; align-items: center; gap: 0.4rem;
      font-size: 0.72rem; font-weight: 600; color: var(--text-primary);
      margin-bottom: 0.4rem; padding-bottom: 0.25rem;
      border-bottom: 1px solid rgba(255,255,255,0.06);
    }
    .orch-section-icon { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
    .orch-task-card {
      display: flex; align-items: center; gap: 0.5rem;
      padding: 0.45rem 0.6rem; margin: 0.25rem 0;
      background: rgba(139, 92, 246, 0.06); border-radius: 8px;
      cursor: pointer; transition: all 0.15s;
      border: 1px solid transparent;
    }
    .orch-task-card:hover { background: rgba(139, 92, 246, 0.12); border-color: rgba(139, 92, 246, 0.2); }
    .orch-task-error { background: rgba(239, 68, 68, 0.06); border-left: 2px solid #ef4444; }
    .orch-task-error:hover { background: rgba(239, 68, 68, 0.12); }
    .orch-api-key-panel { background: rgba(239, 68, 68, 0.06); border: 1px solid rgba(239, 68, 68, 0.2); border-radius: 8px; padding: 0.75rem; margin-bottom: 0.5rem; }
    .orch-api-key-panel input:focus { border-color: #3b82f6; outline: none; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15); }
    .orch-err-badge { font-size: 0.6rem; font-weight: 600; padding: 0.15rem 0.4rem; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.03em; }
    .orch-err-api_key { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
    .orch-err-rate_limit { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
    .orch-err-billing { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
    .orch-err-network { background: rgba(107, 114, 128, 0.15); color: #6b7280; }
    .orch-err-overloaded { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
    .orch-task-done { opacity: 0.7; }
    .orch-task-done:hover { opacity: 1; }
    .orch-task-idle { opacity: 0.5; }
    .orch-task-idle:hover { opacity: 0.8; }
    .orch-task-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
    .orch-task-info { flex: 1; min-width: 0; }
    .orch-task-name { font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .orch-task-meta { font-size: 0.65rem; color: var(--text-tertiary); margin-top: 0.1rem; }
    .orch-stage-badge {
      font-size: 0.6rem; font-weight: 600; padding: 0.1rem 0.35rem;
      border-radius: 4px; border: 1px solid; flex-shrink: 0; text-transform: uppercase; letter-spacing: 0.03em;
    }
    .orch-project-group { margin: 0.3rem 0 0.6rem; padding-left: 0.3rem; border-left: 2px solid rgba(139,92,246,0.15); }
    .orch-project-name { font-size: 0.65rem; font-weight: 600; color: var(--purple); text-transform: uppercase; letter-spacing: 0.05em; padding: 0.15rem 0.4rem; margin-bottom: 0.2rem; opacity: 0.8; }
    .orch-project-tag { display: inline-block; font-size: 0.55rem; font-weight: 600; color: var(--purple); background: rgba(139,92,246,0.1); padding: 0.05rem 0.3rem; border-radius: 3px; margin-right: 0.3rem; vertical-align: middle; text-transform: uppercase; letter-spacing: 0.03em; }
    .orch-pipeline-badges { display: flex; gap: 0.25rem; margin-top: 0.2rem; flex-wrap: wrap; }
    .orch-pipeline-badge { font-size: 0.55rem; font-weight: 600; padding: 0.05rem 0.3rem; border-radius: 3px; border: 1px solid; letter-spacing: 0.03em; }
    .orch-task-decision { background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.2); }
    .orch-task-decision:hover { background: rgba(245,158,11,0.15); border-color: rgba(245,158,11,0.35); }
    /* Collapsible activity log */
    .orch-log-section .orch-log-toggle { cursor: pointer; user-select: none; }
    .orch-log-chevron { font-size: 0.6rem; transition: transform 0.2s; }
    .orch-log-section.collapsed .orch-log-chevron { transform: rotate(-90deg); }
    .orch-log-section.collapsed .orch-log-content { display: none; }
    .orch-log-content { max-height: 400px; overflow-y: auto; }
    /* Revert button */
    .orch-revert-btn {
      font-size: 0.6rem; padding: 0.15rem 0.4rem; border-radius: 4px;
      border: 1px solid rgba(239,68,68,0.3); background: rgba(239,68,68,0.08);
      color: #f87171; cursor: pointer; white-space: nowrap; flex-shrink: 0;
      transition: all 0.15s;
    }
    .orch-revert-btn:hover { background: rgba(239,68,68,0.2); border-color: rgba(239,68,68,0.5); }
    /* Checkpoint card */
    .orch-checkpoint-card { background: rgba(139,92,246,0.06); border-left: 2px solid rgba(139,92,246,0.3); }

    /* --- Delegate Bar --- */
    .orch-delegate-bar {
      display: flex; gap: 0.4rem; align-items: center;
      padding: 0.5rem 0.6rem; margin-bottom: 1rem;
      background: rgba(139,92,246,0.06); border: 1px solid rgba(139,92,246,0.12);
      border-radius: 10px; backdrop-filter: blur(8px);
    }
    .orch-delegate-select {
      font-size: 0.72rem; padding: 0.35rem 0.5rem; border-radius: 6px;
      background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
      color: var(--text-primary); outline: none; cursor: pointer; flex-shrink: 0;
    }
    .orch-delegate-select:focus { border-color: var(--purple); }
    .orch-delegate-input {
      flex: 1; min-width: 0; font-size: 0.75rem; padding: 0.35rem 0.6rem;
      border-radius: 6px; background: rgba(255,255,255,0.04);
      border: 1px solid rgba(255,255,255,0.08); color: var(--text-primary); outline: none;
    }
    .orch-delegate-input::placeholder { color: var(--text-muted); }
    .orch-delegate-input:focus { border-color: var(--purple); }
    .orch-delegate-btn {
      font-size: 0.72rem; font-weight: 600; padding: 0.35rem 0.75rem;
      border-radius: 6px; border: none; cursor: pointer; white-space: nowrap;
      background: var(--purple); color: #fff; transition: all 0.15s; flex-shrink: 0;
    }
    .orch-delegate-btn:hover { background: #7c3aed; }
    .orch-delegate-btn:disabled { opacity: 0.4; cursor: default; }

    /* --- Live task card enhancements --- */
    .orch-task-live {
      font-size: 0.62rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace;
      margin-top: 0.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
      max-width: 100%;
    }
    .orch-progress-dots {
      display: flex; align-items: center; gap: 0.2rem; margin-top: 0.2rem;
    }
    .orch-progress-dot {
      width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.1);
      transition: background 0.3s;
    }
    .orch-progress-dot.active { box-shadow: 0 0 4px currentColor; }
    .orch-progress-label { font-size: 0.52rem; color: var(--text-muted); margin: 0 0.1rem; }
    .orch-stop-btn {
      font-size: 0.6rem; font-weight: 600; padding: 0.2rem 0.45rem;
      border-radius: 5px; border: 1px solid rgba(239,68,68,0.3);
      background: rgba(239,68,68,0.08); color: #f87171;
      cursor: pointer; white-space: nowrap; flex-shrink: 0; transition: all 0.15s;
    }
    .orch-stop-btn:hover { background: rgba(239,68,68,0.2); border-color: rgba(239,68,68,0.5); }
    .orch-decisions-urgent {
      border-left: 3px solid #f59e0b !important;
      animation: orch-pulse-amber 2s ease-in-out infinite;
    }
    @keyframes orch-pulse-amber {
      0%, 100% { border-left-color: #f59e0b; }
      50% { border-left-color: #fbbf24; box-shadow: -2px 0 8px rgba(245,158,11,0.15); }
    }
    .orch-decision-other {
      display: flex; gap: 0.3rem; align-items: center; margin-top: 0.3rem; padding-left: 1.2rem;
    }
    .orch-decision-other input {
      flex: 1; font-size: 0.68rem; padding: 0.25rem 0.5rem; border-radius: 5px;
      background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1);
      color: var(--text-primary); outline: none;
    }
    .orch-decision-other input:focus { border-color: #f59e0b; }
    .orch-decision-other button {
      font-size: 0.62rem; padding: 0.2rem 0.5rem; border-radius: 5px;
      border: 1px solid rgba(245,158,11,0.3); background: rgba(245,158,11,0.1);
      color: #f59e0b; cursor: pointer; white-space: nowrap;
    }
    .orch-decision-other button:hover { background: rgba(245,158,11,0.2); }
    .orch-agent-chips { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-top: 0.15rem; }
    .orch-agent-chip {
      font-size: 0.55rem; padding: 0.05rem 0.3rem; border-radius: 3px;
      background: rgba(139,92,246,0.1); color: var(--purple); font-weight: 500;
    }
    .orch-badge-count {
      font-size: 0.6rem; font-weight: 700; min-width: 16px; height: 16px;
      display: inline-flex; align-items: center; justify-content: center;
      border-radius: 8px; padding: 0 4px;
    }

    .orch-empty { padding: 2rem 1rem; text-align: center; opacity: 0.4; }
    .orch-empty-icon { font-size: 2rem; margin-bottom: 0.5rem; font-weight: 700; color: var(--purple); }

    /* Auto-approve project toggles */
    .orch-auto-section { padding: 0.5rem 0.75rem; border-bottom: 1px solid rgba(255,255,255,0.04); }
    .orch-auto-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0; }
    .orch-auto-project { flex: 1; font-size: 0.72rem; font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .orch-auto-label { font-size: 0.62rem; color: var(--text-muted); margin-right: 0.25rem; white-space: nowrap; }
    .orch-auto-toggle { position: relative; width: 32px; height: 18px; flex-shrink: 0; }
    .orch-auto-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
    .orch-auto-toggle .auto-slider { position: absolute; inset: 0; background: rgba(255,255,255,0.08); border-radius: 9px; cursor: pointer; transition: background 0.2s; }
    .orch-auto-toggle .auto-slider::before { content: ''; position: absolute; width: 14px; height: 14px; left: 2px; bottom: 2px; background: var(--text-muted); border-radius: 50%; transition: transform 0.2s, background 0.2s; }
    .orch-auto-toggle input:checked + .auto-slider { background: rgba(34,197,94,0.25); }
    .orch-auto-toggle input:checked + .auto-slider::before { transform: translateX(14px); background: #22c55e; }
    .orch-auto-badge { display: inline-block; font-size: 0.58rem; padding: 0.1rem 0.35rem; border-radius: 3px; background: rgba(34,197,94,0.12); color: #22c55e; font-weight: 600; letter-spacing: 0.03em; }
    .orch-auto-log { font-size: 0.62rem; color: var(--text-muted); padding: 0.15rem 0 0 1.8rem; opacity: 0.7; font-style: italic; }

    /* Chat area fills remaining space */
    .emma-chat-area {
      flex: 1 1 0;
      display: flex;
      flex-direction: column;
      min-height: 120px;
      overflow: hidden;
    }

    .emma-messages {
      flex: 1 1 0;
      min-height: 0;
      overflow-y: auto;
      overflow-x: hidden;
      padding: 0.75rem;
      display: flex;
      flex-direction: column;
      gap: 0.6rem;
      scroll-behavior: smooth;
    }

    .emma-messages::-webkit-scrollbar { width: 5px; }
    .emma-messages::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

    .emma-msg {
      display: flex;
      gap: 0.4rem;
      max-width: 100%;
      min-width: 0;
      animation: chatFadeIn 0.2s ease forwards;
    }

    .emma-msg.user {
      align-self: flex-end;
      flex-direction: row-reverse;
      max-width: 92%;
    }

    .emma-msg.assistant {
      align-self: flex-start;
    }

    .emma-msg .chat-avatar {
      width: 24px;
      height: 24px;
      font-size: 0.65rem;
      flex-shrink: 0;
    }

    .emma-msg.user .chat-avatar {
      background: var(--indigo);
      color: white;
    }

    .emma-msg.assistant .chat-avatar {
      background: var(--emma-avatar-grad, linear-gradient(135deg, #ef4444, #dc2626));
      color: white;
    }

    .emma-msg .chat-bubble {
      padding: 0.5rem 0.7rem;
      font-size: 0.825rem;
      line-height: 1.5;
      min-width: 0;
      overflow-wrap: break-word;
      word-break: break-word;
    }

    .emma-msg.user .chat-bubble {
      background: linear-gradient(135deg, var(--emma-accent, var(--indigo)), var(--emma-accent-dark, var(--indigo-dark)));
      color: white;
      border-bottom-right-radius: 4px;
      position: relative;
      overflow: hidden;
    }

    .emma-msg.user .chat-bubble::after {
      content: '';
      position: absolute;
      inset: 0;
      background: var(--glass-shine);
      pointer-events: none;
      border-radius: inherit;
    }

    .emma-msg.assistant .chat-bubble {
      background: var(--emma-bubble-bg, var(--glass-bg));
      border: 1px solid var(--emma-bubble-border, rgba(168,85,247,0.12));
      border-bottom-left-radius: 4px;
      color: var(--text-primary);
      max-width: 100%;
      overflow: visible;
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
    }

    /* Constrain all content inside Emma bubbles */
    .emma-msg .chat-bubble-assistant {
      min-width: 0;
      overflow: visible;
      overflow-wrap: break-word;
      word-break: break-word;
    }

    .emma-msg .chat-bubble-assistant pre {
      overflow-x: auto;
      max-width: 100%;
      white-space: pre-wrap;
      word-break: break-all;
      font-size: 0.75rem;
      background: rgba(0, 0, 0, 0.2);
      padding: 0.5rem;
      border-radius: 4px;
      margin: 0.3rem 0;
    }

    .emma-msg .chat-bubble-assistant code {
      font-size: 0.78em;
      background: rgba(0, 0, 0, 0.2);
      padding: 0.1rem 0.3rem;
      border-radius: 3px;
      word-break: break-all;
    }

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

    .emma-msg .chat-bubble-assistant p {
      margin: 0.25rem 0;
      overflow-wrap: break-word;
    }

    .emma-msg .chat-bubble-assistant ul,
    .emma-msg .chat-bubble-assistant ol {
      padding-left: 1.2rem;
      margin: 0.25rem 0;
    }

    .emma-msg .chat-bubble-assistant li {
      margin: 0.1rem 0;
    }

    .emma-msg .chat-bubble-assistant h1,
    .emma-msg .chat-bubble-assistant h2,
    .emma-msg .chat-bubble-assistant h3 {
      font-size: 0.9rem;
      margin: 0.4rem 0 0.2rem;
    }

    .emma-msg .chat-bubble-assistant table {
      font-size: 0.75rem;
      border-collapse: collapse;
      width: 100%;
      overflow-x: auto;
      display: block;
    }

    .emma-msg .chat-bubble-assistant th,
    .emma-msg .chat-bubble-assistant td {
      padding: 0.2rem 0.4rem;
      border: 1px solid var(--border-color);
      text-align: left;
    }

    .emma-text-content {
      min-width: 0;
      overflow-wrap: break-word;
      word-break: break-word;
    }

    .emma-input-area {
      padding: 0.75rem 0.75rem max(0.75rem, env(safe-area-inset-bottom, 12px)) 0.75rem;
      border-top: 1px solid rgba(139, 92, 246, 0.3);
      flex-shrink: 0;
      position: sticky;
      bottom: 0;
      z-index: 10;
      min-height: 60px;
      background: rgba(10, 11, 20, 0.95);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5), 0 -1px 0 rgba(139, 92, 246, 0.15);
    }

    .emma-input-wrapper {
      display: flex;
      gap: 0.4rem;
      align-items: flex-end;
    }

    .emma-input-wrapper textarea {
      flex: 1;
      background: rgba(20, 22, 35, 0.9);
      color: var(--text-primary);
      border: 1px solid rgba(139, 92, 246, 0.2);
      border-radius: var(--radius-md);
      padding: 0.55rem 0.7rem;
      font-size: 16px; /* >=16px prevents iOS auto-zoom on focus */
      font-family: inherit;
      resize: none;
      min-height: 40px;
      max-height: 120px;
      line-height: 1.4;
      outline: none;
      transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    }

    .emma-input-wrapper textarea:focus {
      border-color: rgba(139, 92, 246, 0.5);
      box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12), 0 0 12px rgba(139, 92, 246, 0.08);
    }

    .emma-input-wrapper textarea::placeholder {
      color: var(--text-muted);
    }

    .emma-send-btn {
      width: 40px;
      height: 40px;
      background: var(--emma-avatar-grad, linear-gradient(135deg, #ef4444, #dc2626));
      color: white;
      border: 1px solid rgba(255,255,255,0.15);
      border-radius: var(--radius-md);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all var(--transition-fast);
      flex-shrink: 0;
      box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
    }

    .emma-send-btn:hover { box-shadow: 0 0 16px rgba(168,85,247,0.4), 0 0 32px rgba(168,85,247,0.15); }
    .emma-send-btn svg { width: 16px; height: 16px; }

    .emma-stop-btn {
      width: 38px;
      height: 38px;
      background: var(--rose);
      color: white;
      border: none;
      border-radius: var(--radius-md);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all var(--transition-fast);
      flex-shrink: 0;
    }

    .emma-stop-btn:hover { background: var(--rose-dark); }

    /* --- File Attach UI --- */
    .emma-attach-btn {
      width: 38px;
      height: 38px;
      background: transparent;
      color: var(--text-muted);
      border: 1px solid var(--border-color);
      border-radius: var(--radius-md);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all var(--transition-fast);
      flex-shrink: 0;
    }
    .emma-attach-btn:hover { color: var(--text-primary); border-color: var(--purple); }
    .emma-attach-btn svg { width: 16px; height: 16px; }

    /* --- Chat Toolbar (accent + tone) --- */
    .emma-chat-toolbar {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.35rem 0.75rem;
      border-top: 1px solid var(--glass-border);
      background: rgba(15, 17, 28, 0.4);
      flex-shrink: 0;
      overflow-x: auto;
      scrollbar-width: none;
    }
    .emma-chat-toolbar::-webkit-scrollbar { display: none; }

    .emma-toolbar-group {
      display: flex;
      align-items: center;
      gap: 0.3rem;
      flex-shrink: 0;
    }

    .emma-toolbar-label {
      font-size: 0.65rem;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.05em;
      white-space: nowrap;
    }

    .emma-color-swatch {
      width: 18px;
      height: 18px;
      border-radius: 50%;
      border: 2px solid transparent;
      cursor: pointer;
      transition: all 0.15s;
      flex-shrink: 0;
    }
    .emma-color-swatch:hover { transform: scale(1.15); }
    .emma-color-swatch.active { border-color: white; box-shadow: 0 0 6px rgba(255,255,255,0.3); }

    .emma-tone-chip {
      padding: 0.2rem 0.5rem;
      border-radius: 12px;
      font-size: 0.7rem;
      border: 1px solid var(--border-color);
      background: transparent;
      color: var(--text-secondary);
      cursor: pointer;
      transition: all 0.15s;
      white-space: nowrap;
      flex-shrink: 0;
    }
    .emma-tone-chip:hover { border-color: var(--text-secondary); color: var(--text-primary); }
    .emma-tone-chip.active {
      background: var(--emma-accent, var(--purple));
      border-color: var(--emma-accent, var(--purple));
      color: white;
    }

    .emma-toolbar-sep {
      width: 1px;
      height: 16px;
      background: var(--border-color);
      flex-shrink: 0;
    }

    @media (pointer: coarse) {
      .emma-color-swatch { width: 24px; height: 24px; }
      .emma-tone-chip { padding: 0.3rem 0.6rem; font-size: 0.75rem; min-height: 32px; }
    }

    .emma-attachments-preview {
      display: none;
      flex-wrap: wrap;
      gap: 0.35rem;
      padding: 0.4rem 0.75rem 0;
    }
    .emma-attachments-preview.visible { display: flex; }

    .emma-attachment-chip {
      display: inline-flex;
      align-items: center;
      gap: 0.3rem;
      padding: 0.2rem 0.5rem;
      background: rgba(168, 85, 247, 0.15);
      border: 1px solid rgba(168, 85, 247, 0.3);
      border-radius: 20px;
      font-size: 0.7rem;
      color: var(--text-secondary);
      max-width: 240px;
      white-space: nowrap;
    }
    .emma-attachment-chip.has-thumb {
      border-radius: 8px;
      padding: 0.15rem;
      max-width: 280px;
      flex-direction: column;
      align-items: flex-start;
      white-space: normal;
    }
    .emma-attachment-chip .chip-thumb {
      width: 100%;
      max-width: 260px;
      max-height: 120px;
      object-fit: cover;
      border-radius: 6px;
      display: block;
    }
    .emma-attachment-chip .chip-meta {
      display: flex;
      align-items: center;
      gap: 0.3rem;
      padding: 0.1rem 0.25rem;
      width: 100%;
    }
    .emma-attachment-chip .chip-icon { flex-shrink: 0; }
    .emma-attachment-chip .chip-name { overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
    .emma-attachment-chip .chip-size { color: var(--text-muted); flex-shrink: 0; }
    .emma-attachment-chip .chip-remove {
      cursor: pointer;
      color: var(--text-muted);
      font-size: 0.8rem;
      line-height: 1;
      padding: 0 0.15rem;
      flex-shrink: 0;
    }
    .emma-attachment-chip .chip-remove:hover { color: var(--rose); }
    .emma-attachment-chip.uploading { opacity: 0.6; }
    .emma-attachment-chip.uploading::after {
      content: '';
      width: 10px; height: 10px;
      border: 2px solid var(--purple);
      border-top-color: transparent;
      border-radius: 50%;
      animation: spin 0.6s linear infinite;
      flex-shrink: 0;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    .emma-msg-attachments {
      display: flex;
      flex-wrap: wrap;
      gap: 0.35rem;
      margin-top: 0.35rem;
    }
    .emma-msg-attachment {
      display: inline-flex;
      align-items: center;
      gap: 0.25rem;
      padding: 0.15rem 0.45rem;
      background: rgba(168, 85, 247, 0.12);
      border-radius: 12px;
      font-size: 0.65rem;
      color: var(--purple);
    }
    .emma-msg-attachment-img {
      max-width: 48px;
      max-height: 48px;
      border-radius: 4px;
      border: 1px solid var(--glass-border);
      cursor: pointer;
      transition: opacity 0.15s;
      flex-shrink: 0;
      object-fit: cover;
    }
    .emma-msg-attachment-img:hover { opacity: 0.85; }
    .emma-msg-attachments-carousel {
      display: flex;
      gap: 6px;
      overflow-x: auto;
      overflow-y: hidden;
      max-width: 100%;
      padding: 4px 0;
      margin-top: 0.35rem;
      scrollbar-width: thin;
      scrollbar-color: var(--border-color) transparent;
      -webkit-overflow-scrolling: touch;
    }
    .emma-msg-attachments-carousel::-webkit-scrollbar {
      height: 4px;
    }
    .emma-msg-attachments-carousel::-webkit-scrollbar-thumb {
      background: var(--border-color);
      border-radius: 2px;
    }

    .emma-chat-area.drag-over {
      outline: 2px dashed var(--purple);
      outline-offset: -4px;
      background: rgba(168, 85, 247, 0.05);
    }

    .emma-download-link {
      display: inline-flex;
      align-items: center;
      gap: 0.3rem;
      padding: 0.25rem 0.6rem;
      background: rgba(99, 102, 241, 0.15);
      border: 1px solid rgba(99, 102, 241, 0.3);
      border-radius: 8px;
      font-size: 0.75rem;
      color: var(--indigo-light);
      text-decoration: none;
      margin-top: 0.3rem;
      transition: background var(--transition-fast);
    }
    .emma-download-link:hover { background: rgba(99, 102, 241, 0.25); text-decoration: none; }

    .emma-agents-bar {
      border-top: 1px solid rgba(139, 92, 246, 0.15);
      background: linear-gradient(180deg, rgba(15, 17, 28, 0.95) 0%, rgba(10, 11, 18, 0.98) 100%);
      flex-shrink: 0;
      max-height: 160px;
      overflow-y: auto;
      display: none;
      padding-bottom: env(safe-area-inset-bottom, 0px);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      scrollbar-width: thin;
    }
    .emma-agents-bar.visible { display: block; }
    .emma-agents-header {
      display: flex;
      align-items: center;
      gap: 0.4rem;
      padding: 0.35rem 0.75rem;
      font-size: 0.62rem;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.08em;
      border-bottom: 1px solid rgba(139, 92, 246, 0.08);
      position: sticky;
      top: 0;
      background: rgba(15, 17, 28, 0.95);
      z-index: 1;
    }
    .emma-agents-header .count {
      background: linear-gradient(135deg, #ef4444, #dc2626);
      color: white;
      border-radius: 10px;
      padding: 0.05rem 0.4rem;
      font-size: 0.55rem;
      font-weight: 700;
      min-width: 16px;
      text-align: center;
    }
    .emma-agents-list { padding: 0.3rem 0.5rem; display: flex; flex-direction: column; gap: 0.2rem; }
    .emma-agent-item {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.35rem 0.5rem;
      font-size: 0.68rem;
      color: var(--text-secondary);
      border-radius: 8px;
      transition: all 0.3s ease;
      background: rgba(255, 255, 255, 0.02);
      border: 1px solid transparent;
      position: relative;
      overflow: hidden;
    }
    .emma-agent-item.active {
      color: var(--text-primary);
      background: rgba(139, 92, 246, 0.06);
      border-color: rgba(139, 92, 246, 0.12);
    }
    .emma-agent-item.fading { opacity: 0; transform: translateX(10px); }
    .emma-agent-progress {
      position: absolute;
      bottom: 0;
      left: 0;
      height: 2px;
      background: linear-gradient(90deg, #ef4444, #dc2626);
      border-radius: 0 0 8px 8px;
      transition: width 0.5s ease;
    }
    .emma-agent-badge {
      flex-shrink: 0;
      font-size: 0.55rem;
      font-weight: 700;
      text-transform: uppercase;
      padding: 0.15rem 0.4rem;
      border-radius: 4px;
      letter-spacing: 0.04em;
    }
    .emma-agent-badge.developer { background: rgba(59,130,246,0.12); color: #60a5fa; border: 1px solid rgba(59,130,246,0.2); }
    .emma-agent-badge.reviewer { background: rgba(245,158,11,0.12); color: #fbbf24; border: 1px solid rgba(245,158,11,0.2); }
    .emma-agent-badge.fixer { background: rgba(244,63,94,0.12); color: #fb7185; border: 1px solid rgba(244,63,94,0.2); }
    .emma-agent-badge.researcher { background: rgba(16,185,129,0.12); color: #34d399; border: 1px solid rgba(16,185,129,0.2); }
    .emma-agent-badge.agent { background: rgba(168,85,247,0.12); color: #c084fc; border: 1px solid rgba(168,85,247,0.2); }
    .emma-agent-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .emma-agent-status { flex-shrink: 0; font-size: 0.7rem; }
    .emma-agent-status.running { color: #f87171; animation: activity-pulse 3.5s ease-in-out infinite; }
    .emma-agent-status.done { color: #22c55e; }
    .emma-agent-status.error { color: #ef4444; }
    .emma-agent-status.recovered { color: #fbbf24; animation: activity-pulse 3.5s ease-in-out infinite; }
    .emma-agent-elapsed { flex-shrink: 0; font-size: 0.58rem; color: var(--text-muted); opacity: 0.6; }

    /* Deliberation Thread Panel */
    .emma-delib-bar {
      border-top: 1px solid rgba(139, 92, 246, 0.2);
      background: linear-gradient(180deg, rgba(20, 15, 35, 0.98) 0%, rgba(12, 10, 22, 0.99) 100%);
      flex-shrink: 0;
      max-height: 300px;
      overflow-y: auto;
      display: none;
      scrollbar-width: thin;
      transition: max-height 0.3s ease;
    }
    .emma-delib-bar.visible { display: block; }
    .emma-delib-bar.collapsed { max-height: 36px; overflow: hidden; }
    .emma-delib-header {
      display: flex;
      align-items: center;
      gap: 0.4rem;
      padding: 0.4rem 0.75rem;
      font-size: 0.62rem;
      font-weight: 600;
      color: #c4b5fd;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      border-bottom: 1px solid rgba(139, 92, 246, 0.12);
      position: sticky;
      top: 0;
      background: rgba(20, 15, 35, 0.98);
      z-index: 2;
      cursor: pointer;
      user-select: none;
    }
    .emma-delib-header:hover { background: rgba(139, 92, 246, 0.08); }
    .emma-delib-header .delib-toggle {
      margin-left: auto;
      font-size: 0.7rem;
      opacity: 0.5;
      transition: transform 0.2s;
    }
    .emma-delib-bar.collapsed .delib-toggle { transform: rotate(-90deg); }
    .emma-delib-round {
      padding: 0.15rem 0.75rem;
      font-size: 0.55rem;
      font-weight: 700;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.1em;
      opacity: 0.5;
      border-top: 1px solid rgba(139, 92, 246, 0.06);
      margin-top: 0.2rem;
    }
    .emma-delib-entry {
      padding: 0.5rem 0.75rem;
      border-bottom: 1px solid rgba(255, 255, 255, 0.03);
      animation: delib-slide-in 0.3s ease;
    }
    @keyframes delib-slide-in {
      from { opacity: 0; transform: translateY(6px); }
      to { opacity: 1; transform: translateY(0); }
    }
    .emma-delib-entry-header {
      display: flex;
      align-items: center;
      gap: 0.4rem;
      margin-bottom: 0.25rem;
    }
    .emma-delib-entry-header .emma-agent-badge {
      font-size: 0.5rem;
      padding: 0.1rem 0.3rem;
    }
    .emma-delib-type {
      font-size: 0.55rem;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }
    .emma-delib-type.proposal { color: #60a5fa; }
    .emma-delib-type.critique { color: #fbbf24; }
    .emma-delib-type.defense { color: #60a5fa; }
    .emma-delib-type.revision { color: #34d399; }
    .emma-delib-type.agreement { color: #22c55e; }
    .emma-delib-type.rebuttal { color: #fb7185; }
    .emma-delib-ref {
      font-size: 0.5rem;
      color: var(--text-muted);
      opacity: 0.5;
      margin-left: auto;
    }
    .emma-delib-content {
      font-size: 0.65rem;
      color: var(--text-secondary);
      line-height: 1.45;
      max-height: 120px;
      overflow-y: auto;
      padding: 0.3rem 0.5rem;
      background: rgba(255, 255, 255, 0.02);
      border-radius: 6px;
      border-left: 2px solid rgba(139, 92, 246, 0.2);
      scrollbar-width: thin;
      white-space: pre-wrap;
      word-break: break-word;
    }
    .emma-delib-entry.critique .emma-delib-content { border-left-color: rgba(245, 158, 11, 0.3); }
    .emma-delib-entry.defense .emma-delib-content { border-left-color: rgba(59, 130, 246, 0.3); }
    .emma-delib-entry.revision .emma-delib-content { border-left-color: rgba(16, 185, 129, 0.3); }
    .emma-delib-entry.agreement .emma-delib-content { border-left-color: rgba(34, 197, 94, 0.3); }
    .emma-delib-entry.rebuttal .emma-delib-content { border-left-color: rgba(244, 63, 94, 0.3); }
    .emma-delib-status {
      display: flex;
      align-items: center;
      gap: 0.4rem;
      padding: 0.35rem 0.75rem;
      font-size: 0.58rem;
      color: var(--text-muted);
      font-style: italic;
    }
    .emma-delib-status .delib-dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: #f87171;
      animation: activity-pulse 3.5s ease-in-out infinite;
    }
    .emma-delib-resolved {
      padding: 0.4rem 0.75rem;
      font-size: 0.6rem;
      background: rgba(34, 197, 94, 0.06);
      border-top: 1px solid rgba(34, 197, 94, 0.15);
      color: #86efac;
    }
    .emma-delib-resolved strong { color: #22c55e; }

    .emma-empty {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      color: var(--text-muted);
      gap: 0.5rem;
      padding: 2rem 1rem;
      text-align: center;
    }

    .emma-empty .emma-logo {
      width: 48px;
      height: 48px;
      border-radius: 50%;
      background: linear-gradient(135deg, #ef4444, #dc2626);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.5rem;
      font-weight: 700;
      color: white;
      margin-bottom: 0.5rem;
    }

    .emma-empty p {
      font-size: 0.85rem;
    }

    .emma-empty p:last-child {
      font-size: 0.75rem;
      opacity: 0.6;
    }

    .emma-toggle-btn {
      display: flex;
      align-items: center;
      gap: 0.45rem;
      padding: 0.25rem 0.7rem 0.25rem 0.25rem;
      border-radius: 20px;
      background: rgba(168, 85, 247, 0.08);
      color: var(--purple);
      border: 1px solid rgba(168, 85, 247, 0.2);
      font-size: 0.8rem;
      font-weight: 600;
      cursor: pointer;
      transition: all var(--transition-fast);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
    }

    .emma-toggle-btn:hover {
      background: rgba(168, 85, 247, 0.18);
      transform: scale(1.02);
    }

    .emma-toggle-btn .emma-topbar-avatar {
      width: 26px;
      height: 26px;
      border-radius: 50%;
      background: linear-gradient(135deg, #ef4444, #dc2626);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 0.7rem;
      font-weight: 700;
      color: white;
      flex-shrink: 0;
      overflow: hidden;
      background-size: cover;
      background-position: center;
    }

    .emma-toggle-btn .emma-topbar-name {
      font-size: 0.8rem;
      font-weight: 600;
      color: var(--purple);
    }

    .emma-toggle-btn .emma-topbar-status {
      width: 7px;
      height: 7px;
      border-radius: 50%;
      background: var(--emerald);
      flex-shrink: 0;
    }

    .emma-toggle-btn.active {
      background: rgba(168, 85, 247, 0.25);
      border-color: var(--purple);
    }

    /* Emma working glow — pulsing ring when processing (uses accent color) */
    @keyframes emmaWorkingGlow {
      0%, 100% { box-shadow: 0 0 6px 2px rgba(245, 158, 11, 0.5), 0 0 12px 4px rgba(245, 158, 11, 0.2); }
      50% { box-shadow: 0 0 10px 4px rgba(245, 158, 11, 0.8), 0 0 20px 8px rgba(245, 158, 11, 0.35); }
    }

    .emma-toggle-btn.emma-working {
      animation: emmaWorkingGlow 2s ease-in-out infinite;
      border-color: var(--amber);
    }

    /* Subtle white glow when idle (not working) */
    .emma-toggle-btn:not(.emma-working) {
      box-shadow: 0 0 6px 1px rgba(255, 255, 255, 0.12);
      transition: box-shadow 0.4s ease, all var(--transition-fast);
    }

