  /* ── Thread Panel ── */
  .thread-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  .thread-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-anchor: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .thread-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-dim);
    font-size: 14px;
  }

  .msg {
    max-width: 70%;
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
  }
  .msg-body { white-space: normal; }
  .msg-body p { margin: 4px 0; }
  .msg-body code { background: rgba(255,255,255,0.1); padding: 1px 4px; border-radius: 3px; font-size: 12px; }
  .msg-body pre { white-space: pre-wrap; }
  .msg-body ul, .msg-body ol { margin: 4px 0; padding-left: 20px; }
  .msg-body h1, .msg-body h2, .msg-body h3, .msg-body h4, .msg-body h5, .msg-body h6 { margin: 8px 0 4px; }
  .msg-body table { border-collapse: collapse; margin: 4px 0; font-size: 12px; }
  .msg-body th, .msg-body td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; }
  .msg-body th { background: rgba(255,255,255,0.05); font-weight: 600; }
  .msg.to-agent {
    align-self: flex-end;
    background: #1a3a5c;
    border: 1px solid rgba(88,166,255,0.3);
  }
  .msg.from-agent {
    align-self: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
  }
  .msg-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 6px;
    width: 100%;
    margin-bottom: 2px;
    font-size: 10px;
    color: var(--text-dim);
  }
  .msg-route {
    font-size: 10px;
    color: var(--text-dim);
    opacity: 0.7;
    white-space: nowrap;
  }
  .msg-sender {
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    width: 100%;
  }
  .msg-topic {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    background: rgba(88,166,255,0.08);
    color: var(--text-dim);
    white-space: nowrap;
  }
  .msg-copy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 6px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.15s, border-color 0.15s;
    color: var(--text-dim);
    font-size: 11px;
  }
  .msg-copy:hover { opacity: 1; color: var(--accent); border-color: var(--accent); }
  .msg-time {
    font-size: 10px;
    white-space: nowrap;
    opacity: 0.6;
  }
  .msg-meta {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
  }
  .msg-status {
    font-size: 10px;
    white-space: nowrap;
  }
  .msg-status.pending { color: var(--text-dim); }
  .msg-status.delivered { color: var(--green); }
  .msg-status.failed { color: var(--red); }
  .msg.withdrawn { opacity: 0.5; }
  .msg.withdrawn .msg-body { text-decoration: line-through; }
  .msg-withdraw {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 20px;
    padding: 0 6px;
    font-size: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
  }
  .msg-withdraw:hover { opacity: 1; color: var(--red); border-color: var(--red); }

  .topic-breadcrumbs {
    display: flex;
    gap: 6px;
    padding: 4px 12px;
    overflow-x: auto;
    flex-wrap: nowrap;
    border-top: 1px solid var(--border);
    background: var(--surface);
    scrollbar-width: none;
  }
  .topic-breadcrumbs::-webkit-scrollbar { display: none; }
  .topic-breadcrumbs:empty { display: none; }
  .topic-chip {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(88,166,255,0.1);
    color: var(--text-dim);
    cursor: pointer;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: all 0.15s;
  }
  .topic-chip:hover { background: rgba(88,166,255,0.25); color: var(--accent); }
  .topic-chip.active { background: rgba(88,166,255,0.2); color: var(--accent); border-color: var(--accent); }

  /* ── Input ── */
  .thread-input {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: var(--surface);
  }
  .thread-input textarea {
    flex: 0 0 100%;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    resize: none;
    overflow-y: auto;
    min-height: 36px;
    height: 36px;
    max-height: 120px;
    line-height: 1.4;
  }
  .thread-input textarea:focus { border-color: var(--accent); }
  .thread-input .upload-wrap { order: 1; }
  .thread-input #interruptBtn {
    order: 3;
    margin-left: auto;
    background: var(--red, #e53935);
  }
  .thread-input #sendBtn {
    order: 4;
  }
  .thread-input button {
    padding: 8px 16px;
    min-width: 88px;
    border-radius: 6px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    text-align: center;
  }
  .thread-input button:hover { opacity: 0.9; }
  .thread-input button:disabled { opacity: 0.5; cursor: not-allowed; }
  .thread-input textarea:disabled { opacity: 0.5; cursor: not-allowed; }

  /* ── Upload Button ── */
  .upload-wrap {
    position: relative;
    display: inline-flex;
  }
  .upload-wrap input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
  }
  .upload-wrap input[type="file"]:disabled { cursor: not-allowed; }
  .upload-btn {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .upload-btn:hover { border-color: var(--accent); color: var(--accent); }
  .upload-btn.disabled { opacity: 0.5; cursor: not-allowed; }
  .upload-wrap.uploading { pointer-events: none; }
  .upload-wrap.uploading .upload-btn {
    color: transparent;
  }
  .upload-wrap.uploading .upload-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 14px; height: 14px;
    border: 2px solid var(--text-dim);
    border-top-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
  }

  .msg.file-upload .file-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
  }
  .msg.file-upload .file-icon { font-size: 16px; }

  /* ── Voice Dictation ── */
  .voice-controls {
    display: none;
    align-items: center;
    gap: 6px;
    order: 2;
  }
  .voice-controls.voice-enabled {
    display: flex;
  }
  .voice-toggle {
    display: flex;
    align-items: center;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    overflow: hidden;
  }
  .voice-toggle button {
    padding: 8px 10px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
    white-space: nowrap;
  }
  .voice-toggle button.active {
    background: var(--green);
    color: #fff;
  }
  .voice-toggle button:not(.active):hover {
    background: rgba(88,166,255,0.1);
  }
  .voice-btn {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--surface);
    color: var(--text-dim);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  .voice-btn:hover { border-color: var(--accent); color: var(--accent); }
  .voice-btn.recording {
    border-color: #e74c3c;
    background: #e74c3c;
    color: #fff;
    animation: voice-pulse 1.5s ease-in-out infinite;
  }
  .voice-btn.disabled { opacity: 0.4; cursor: not-allowed; }
  .voice-btn.inactive { opacity: 0.3; cursor: default; }
  @keyframes voice-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(231, 76, 60, 0); }
  }
  .voice-partial {
    font-size: 11px;
    color: var(--text-dim);
    font-style: italic;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Mobile mic toggle — hidden on desktop, shown on mobile via responsive.css */
  .mobile-mic-btn {
    display: none;
  }

  .thread-panel.drag-over {
    outline: 2px dashed var(--accent);
    outline-offset: -4px;
    background: rgba(88,166,255,0.05);
  }
  /* ── System message ── */
  .msg.system-msg {
    align-self: center;
    max-width: 90%;
    background: rgba(139,148,158,0.08);
    border: 1px dashed var(--border);
    color: var(--text-dim);
    font-size: 12px;
    font-style: italic;
  }
