/* ─── LINE Chat Section ──────────────────────────────────────────────── */
.line-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.line-section-dev {
  font-size: 11.5px;
  color: var(--fg-2);
  padding: 8px 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
}
.line-loading, .line-error {
  font-size: 11.5px;
  color: var(--fg-3);
  padding: 8px 10px;
}
.line-error { color: #dc2626; }
.line-empty {
  font-size: 14px;
  color: var(--fg-3);
  padding: 14px 10px;
  text-align: center;
  background: var(--bg);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* Group picker */
.line-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.line-picker-instr {
  font-size: 11.5px;
  color: var(--fg-2);
  padding: 8px 10px;
  background: var(--bg-soft);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  line-height: 1.5;
}
.line-picker-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.line-picker-count {
  font-size: 13px;
  color: var(--fg-3);
}
.line-group-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}
.line-group-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
}
.line-group-item:hover:not(:disabled) {
  background: var(--bg-soft);
  border-color: var(--accent);
}
.line-group-item:disabled { opacity: 0.5; cursor: not-allowed; }
.line-group-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}
.line-group-noname {
  color: var(--fg-3);
  font-style: italic;
  font-weight: 500;
}
.line-group-meta {
  font-size: 10.5px;
  color: var(--fg-3);
  margin-top: 2px;
}

/* Linked view */
.line-linked {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.line-linked-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
}
.line-linked-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: 4px;
}
.line-linked-info { flex: 1; min-width: 0; }
.line-linked-name {
  font-size: 13px;
  font-weight: 600;
  color: #14532d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.line-linked-stats {
  font-size: 10.5px;
  color: #166534;
  margin-top: 1px;
}
.line-linked-summary {
  font-size: 10.5px;
  color: #166534;
  text-align: right;
  padding: 2px 6px 0;
  font-weight: 500;
}
.line-unlink {
  flex: none;
  font-size: 13px;
  padding: 3px 7px;
  color: #b91c1c;
  border: 1px solid transparent;
  border-radius: 4px;
}
.line-unlink:hover:not(:disabled) {
  background: #fee2e2;
  border-color: #fecaca;
}

/* Add another group inline panel */
.line-add-group-row {
  display: flex;
  flex-direction: column;
}
.line-add-group-btn {
  align-self: flex-start;
  font-size: 13px;
  padding: 5px 10px;
  color: var(--fg-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.line-add-group-btn:hover {
  background: var(--bg-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.line-add-group-panel {
  padding: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.line-agent-panel {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid #dbe3ef;
  border-radius: var(--radius);
}
.line-agent-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.line-agent-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
}
.line-agent-subtitle {
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--fg-3);
}
.line-agent-unread {
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  color: #075985;
  background: #e0f2fe;
  border: 1px solid #bae6fd;
  border-radius: 999px;
  padding: 3px 7px;
  white-space: nowrap;
}
.line-agent-controls,
.line-agent-copy-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.line-agent-create {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  padding: 6px 10px;
}
.line-agent-created {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 9px;
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
}
.line-agent-created-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: #14532d;
}
.line-agent-created-head span {
  font-size: 10.5px;
  color: #166534;
}
.line-agent-prompt {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  font: 11px/1.45 var(--mono, "JetBrains Mono", monospace);
  color: var(--fg);
  background: var(--bg);
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 7px 8px;
}
.line-agent-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.line-agent-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.line-agent-card-main {
  flex: 1;
  min-width: 0;
}
.line-agent-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--fg);
}
.line-agent-token {
  font: 10.5px/1.2 var(--mono, "JetBrains Mono", monospace);
  color: var(--fg-3);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 6px;
}
.line-agent-card-meta {
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--fg-3);
}
.line-agent-readstates {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 6px;
}
.line-agent-readstates span {
  font-size: 10.5px;
  color: var(--fg-3);
}
.line-agent-readstates span.has-unread {
  color: #92400e;
  font-weight: 600;
}
.line-agent-revoke {
  flex: none;
  color: #b91c1c;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 6px;
}
.line-agent-revoke:hover:not(:disabled) {
  background: #fee2e2;
  border-color: #fecaca;
}
.line-agent-note {
  font-size: 14px;
  color: var(--fg-3);
  line-height: 1.45;
}

.line-analysis-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.line-since-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--fg-3);
}
.line-since-select {
  padding: 3px 6px;
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--fg);
}

.line-preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}
.line-preset-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: 13px;
  padding: 7px 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--fg);
  text-align: left;
}
.line-preset-btn:hover:not(:disabled) {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}
.line-preset-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.line-preset-btn.is-busy { background: var(--accent-bg); color: var(--accent); }
.line-preset-cached  { border-color: #bbf7d0; background: #f0fdf4; }
.line-preset-cached:hover:not(:disabled) {
  background: #dcfce7; border-color: #86efac; color: #14532d;
}
.line-preset-stale   { border-color: #fde68a; background: #fffbeb; }
.line-preset-stale:hover:not(:disabled) {
  background: #fef3c7; border-color: #fcd34d; color: #78350f;
}
.line-preset-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.line-preset-badge {
  flex: none;
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 99px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.line-preset-badge-cached { background: #16a34a; color: #fff; }
.line-preset-badge-stale  { background: #d97706; color: #fff; }

/* Result panel — cache + stale states */
.line-cache-badge {
  margin-left: 6px;
  font-size: 9.5px;
  padding: 1px 5px;
  background: #16a34a;
  color: #fff;
  border-radius: 99px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.line-analysis-meta-label { font-weight: 700; color: var(--fg-2); }
.line-analysis-meta-sep { margin: 0 2px; }
.line-analysis-stamp {
  font-size: 10.5px;
  color: var(--fg-3);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.line-stale-indicator { color: #d97706; font-weight: 600; }
.line-refresh-btn {
  font-size: 10.5px;
  padding: 3px 8px;
  background: #fef3c7;
  color: #78350f;
  border: 1px solid #fcd34d;
  border-radius: 99px;
  cursor: pointer;
  font-weight: 600;
}
.line-refresh-btn:hover:not(:disabled) {
  background: #fde68a;
  border-color: #f59e0b;
}
.line-refresh-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.line-analysis-result.is-stale {
  border-left: 3px solid #f59e0b;
}

.line-custom-row {
  display: flex;
  gap: 5px;
}
.line-custom-input {
  flex: 1;
  padding: 6px 8px;
  font-size: 11.5px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--fg);
  outline: none;
}
.line-custom-input:focus { border-color: var(--accent); }
.line-custom-btn {
  flex: none;
  font-size: 13px;
  padding: 6px 12px;
}

.line-analysis-result {
  margin-top: 4px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.line-analysis-meta {
  font-size: 10.5px;
  color: var(--fg-3);
  font-weight: 600;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.line-analysis-text {
  font-size: 14px;
  color: var(--fg);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
}

/* ─── LINE chat history viewer ─────────────────────────────────────────── */
.line-chat-toggle-row {
  margin-top: 12px;
}
.line-chat-toggle {
  font-size: 13px;
}

.line-chat-viewer {
  margin-top: 10px;
  border: 1px solid var(--bd-1);
  border-radius: 10px;
  background: var(--bg-2, #f8f9fb);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.line-chat-tools {
  display: grid;
  grid-template-columns: minmax(150px, 0.6fr) minmax(220px, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: var(--bg-1, #fff);
  border-bottom: 1px solid var(--bd-1);
}

.line-chat-group-select {
  min-width: 0;
  height: 32px;
  padding: 0 8px;
  font-size: 13px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
}

.line-chat-search {
  min-width: 0;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.line-chat-search:focus-within,
.line-chat-group-select:focus {
  border-color: var(--accent);
}

.line-chat-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
}

.line-chat-search-clear {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--fg-3);
  cursor: pointer;
}

.line-chat-search-clear:hover {
  background: var(--bg-hover);
  color: var(--fg);
}

.line-chat-tool-meta {
  font-size: 13px;
  color: var(--fg-3);
  white-space: nowrap;
  text-align: right;
}

@media (max-width: 760px) {
  .line-chat-tools {
    grid-template-columns: 1fr;
  }
  .line-chat-tool-meta {
    text-align: left;
  }
}

.line-chat-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 10px 0 10px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--bd-1);
}
.line-chat-group-tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--fg-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.line-chat-group-tab:hover { background: var(--bg-2); }
.line-chat-group-tab.is-active {
  background: var(--bg-2);
  border-color: var(--bd-2);
  color: var(--fg-0);
  font-weight: 600;
}
.line-chat-group-count {
  font-size: 13px;
  color: var(--fg-3);
  background: var(--bd-1);
  padding: 1px 6px;
  border-radius: 999px;
}

.line-chat-scroll {
  height: 480px;
  overflow-y: auto;
  padding: 10px 14px 14px 14px;
  background: var(--bg-2, #f0f2f5);
}

.line-chat-loadmore {
  text-align: center;
  margin: 4px 0 10px 0;
}
.line-chat-empty {
  padding: 40px 0;
  text-align: center;
  color: var(--fg-3);
  font-size: 14px;
}

.line-chat-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.line-chat-day-sep {
  text-align: center;
  margin: 16px 0 8px 0;
  position: relative;
}
.line-chat-day-sep span {
  display: inline-block;
  font-size: 13px;
  color: var(--fg-3);
  background: var(--bg-2);
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--bd-1);
}

.line-chat-bubble-row {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 8px;
  margin-top: 1px;
}
.line-chat-bubble-row.has-header {
  margin-top: 10px;
}

.line-chat-avatar {
  width: 32px;
  height: 32px;
}
.line-chat-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.line-chat-avatar-fallback {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: oklch(0.75 0.10 230);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.line-chat-bubble-col {
  min-width: 0;
}
.line-chat-bubble-name {
  font-size: 13px;
  color: var(--fg-2);
  font-weight: 600;
  margin-bottom: 2px;
  margin-left: 2px;
}

.line-chat-bubble {
  display: inline-flex;
  align-items: flex-end;
  gap: 6px;
  background: white;
  padding: 6px 10px;
  border-radius: 12px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.05);
  max-width: 85%;
  word-break: break-word;
}
.line-chat-bubble-time {
  font-size: 12px;
  color: var(--fg-3);
  flex-shrink: 0;
}

.line-chat-bubble-image,
.line-chat-bubble-video,
.line-chat-bubble-sticker {
  background: transparent;
  padding: 0;
  box-shadow: none;
  align-items: flex-end;
}
.line-chat-bubble-image .line-chat-bubble-time,
.line-chat-bubble-video .line-chat-bubble-time,
.line-chat-bubble-sticker .line-chat-bubble-time {
  background: rgba(0,0,0,0.5);
  color: white;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: -28px;
  margin-bottom: 4px;
  position: relative;
  z-index: 1;
}

.line-chat-text {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.4;
}

.line-chat-image {
  display: block;
  line-height: 0;
  border-radius: 10px;
  overflow: hidden;
  max-width: 280px;
}
.line-chat-image img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  background: var(--bd-1);
}
.line-chat-media-missing {
  min-width: 140px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--fg-3);
  background: var(--bg-soft);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.line-chat-video {
  max-width: 320px;
  max-height: 320px;
  border-radius: 10px;
  background: black;
  display: block;
}

.line-chat-audio {
  height: 36px;
  max-width: 280px;
}

.line-chat-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  text-decoration: none;
  color: inherit;
}
.line-chat-file-icon {
  font-size: 24px;
}
.line-chat-file-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.line-chat-file-name {
  font-size: 13px;
  color: var(--fg-0);
  font-weight: 500;
  text-decoration: underline;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}
.line-chat-file-size {
  font-size: 13px;
  color: var(--fg-3);
}

.line-chat-sticker {
  width: 110px;
  height: 110px;
  object-fit: contain;
  display: block;
}

.line-chat-location {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
}
.line-chat-location-icon {
  font-size: 18px;
}
.line-chat-location-title {
  font-weight: 600;
}
.line-chat-location-addr {
  font-size: 13px;
  color: var(--fg-3);
}

/* Segmented control */
.seg-group {
  display: inline-flex;
  border: 1px solid var(--border, #ddd);
  border-radius: 6px;
  overflow: hidden;
  font-size: 13px;
}
.seg-btn {
  padding: 4px 14px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border, #ddd);
  cursor: pointer;
  color: var(--fg-2, #666);
  font-weight: 500;
  transition: background .15s, color .15s;
}
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { background: var(--bg-2, #f5f5f5); }
.seg-btn.active {
  background: var(--accent, #2a9);
  color: #fff;
}

/* Cost/MD tooltip */
.cost-tooltip-wrap {
  position: relative;
  cursor: default;
}
.cost-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 6px;
  background: var(--bg-2, #222);
  color: var(--fg-1, #eee);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.cost-tooltip-wrap:hover .cost-tooltip {
  display: block;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LINE Chat Hub (line-hub.jsx) — two-pane inbox: group rail + group detail.
   Zinc-monochrome, dense, flat-at-rest. Saturated color is signal only
   (link status dot, AI-confidence meter).
   ═══════════════════════════════════════════════════════════════════════════ */
.lh-hub {
  height: 100%;
  min-height: 0;
  display: flex;
  background: var(--bg);
}
.lh-num, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ── Left rail ─────────────────────────────────────────────────────────────── */
.lh-rail {
  flex: 0 0 312px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--bg-soft);
}
.lh-rail-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 10px;
}
.lh-rail-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.lh-rail-total {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-3);
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  padding: 1px 7px;
}
.lh-icon-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: var(--radius-sm);
  color: var(--fg-2);
  cursor: pointer;
  font-size: 14px;
  transition: background 150ms ease, border-color 150ms ease;
}
.lh-icon-btn:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--line-strong); }
.lh-icon-btn:disabled { opacity: 0.5; cursor: default; }
.lh-spin { display: inline-block; animation: lh-spin 0.7s linear infinite; }
@keyframes lh-spin { to { transform: rotate(360deg); } }

.lh-search {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 14px 10px;
  padding: 0 10px;
  height: 34px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--fg-3);
}
.lh-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lh-search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--fg);
  min-width: 0;
}
.lh-search input::placeholder { color: var(--fg-4); }

.lh-filters {
  display: flex;
  gap: 4px;
  padding: 0 14px 8px;
  flex-wrap: wrap;
}
.lh-filter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 999px;
  font-family: inherit;
  font-size: 12px;
  color: var(--fg-3);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}
.lh-filter:hover { background: var(--bg-hover); color: var(--fg); }
.lh-filter.is-on { background: var(--accent); color: #fff; }
.lh-filter-n { font-size: 11px; opacity: 0.85; }
.lh-filter.is-on .lh-filter-n { opacity: 1; }

.lh-rail-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lh-rail-empty, .lh-rail-skel { padding: 18px 12px; }
.lh-rail-empty { font-size: 14px; color: var(--fg-3); text-align: center; }

.lh-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background 150ms ease, border-color 150ms ease;
}
.lh-row:hover { background: var(--bg-hover); }
.lh-row.is-active { background: var(--accent-soft); border-color: var(--accent-dim, var(--line-strong)); }
.lh-row-top { display: flex; align-items: baseline; gap: 8px; }
.lh-row-name {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lh-row.is-active .lh-row-name { color: var(--accent); }
.lh-noname { color: var(--fg-4); font-style: italic; font-weight: 500; }
.lh-row-time { flex: 0 0 auto; font-size: 11px; color: var(--fg-3); font-family: var(--font-mono); }
.lh-row-time.is-dim { color: var(--fg-4); }
.lh-row-bottom { display: flex; align-items: center; gap: 8px; }
.lh-row-count { margin-left: auto; font-size: 11px; color: var(--fg-3); }

/* Link-status chips */
.lh-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 200px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lh-chip-linked { background: var(--bg-sunken); color: var(--fg-2); border: 1px solid var(--line); }
.lh-chip-linked.lg { font-size: 12.5px; padding: 3px 11px; }
.lh-chip-agent {
  color: #7c2d12;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  gap: 4px;
}
.lh-chip-unlinked {
  color: var(--fg-4);
  border: 1px dashed var(--line-strong);
  background: transparent;
}
.lh-dot { width: 7px; height: 7px; border-radius: 50%; background: #06c755; flex: 0 0 auto; } /* LINE green = signal */

/* Skeleton */
.lh-skel-row { padding: 10px; display: flex; flex-direction: column; gap: 7px; }
.lh-skel-line { height: 9px; border-radius: 4px; background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--bg-hover) 50%, var(--bg-sunken) 75%); background-size: 200% 100%; animation: lh-shimmer 1.3s ease infinite; }
.lh-skel-line.w70 { width: 70%; } .lh-skel-line.w40 { width: 40%; }
@keyframes lh-shimmer { to { background-position: -200% 0; } }

/* ── Detail pane ───────────────────────────────────────────────────────────── */
.lh-detail {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  animation: lh-fade 180ms ease;
}
@keyframes lh-fade { from { opacity: 0; } to { opacity: 1; } }
.lh-detail-head { padding: 18px 22px 12px; }
.lh-detail-title h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--fg);
  text-wrap: balance;
}
.lh-detail-sub { margin-top: 4px; font-size: 14px; color: var(--fg-3); }
.lh-detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.lh-detail-tags .lh-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; }

/* Link bar */
.lh-linkbar { padding: 0 22px 12px; }
.lh-linkbar-linked { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.lh-linkbar-label { font-size: 12.5px; color: var(--fg-3); }
.lh-linkbar-grow { flex: 1; }
.lh-linkbar-unlinked {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.lh-linkbar-manual { display: flex; align-items: center; gap: 8px; color: var(--fg-3); }

.lh-select {
  height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2371717a' stroke-width='1.3' fill='none'/%3E%3C/svg%3E") no-repeat right 9px center;
  font-family: inherit;
  font-size: 13px;
  color: var(--fg);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  min-width: 0;
}
.lh-linkbar-manual .lh-select { flex: 1; }
.lh-select.sm { height: 28px; font-size: 12px; }
.lh-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.lh-botmeta {
  margin: 0 22px 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
}
.lh-botmeta-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg-2);
}
.lh-botmeta-head > span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.lh-botmeta-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(260px, 1.2fr);
  gap: 10px;
}
.lh-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--fg-3);
}
.lh-input-action {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.lh-input-action > svg {
  flex: 0 0 auto;
  color: var(--fg-3);
}
.lh-input-action .lh-input { flex: 1; }
.lh-icon-btn.mini {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
}
.lh-botmeta-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}
.lh-botmeta-hint {
  min-width: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--fg-3);
}
.lh-agent-registry {
  margin: 0 22px 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg);
}
.lh-agent-registry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.lh-agent-registry-head > span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg-2);
}
.lh-agent-create {
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr);
  gap: 10px 14px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  overflow: hidden;
}
.lh-agent-create .lh-field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
  border: none;
  background: transparent;
}
.lh-agent-create .lh-field > span {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--fg);
}
.lh-agent-create .lh-field small {
  display: block;
  min-height: 15px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--fg-3);
}
.lh-agent-create .lh-input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 36px;
  border-color: var(--line);
  background: var(--bg);
  font-size: 12.5px;
  font-weight: 500;
}
.lh-agent-create .lh-select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 36px;
  border-color: var(--line);
  background-color: var(--bg);
  font-size: 12.5px;
  font-weight: 500;
}
.lh-agent-create .lh-field:nth-child(3) .lh-input,
.lh-agent-create .lh-field:nth-child(4) .lh-input {
  font-family: var(--font-mono);
  font-size: 11.5px;
}
.lh-agent-create .lh-input:disabled {
  color: var(--fg-4);
  background: var(--bg-sunken);
  cursor: not-allowed;
}
.lh-agent-create-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
  font-size: 12px;
  color: var(--fg-3);
}
.lh-agent-create-actions span {
  min-width: 0;
  line-height: 1.35;
}
.lh-agent-create-actions .lh-btn-primary {
  flex: none;
  min-width: 76px;
  height: 34px;
  justify-content: center;
}
.lh-agent-empty {
  margin-top: 10px;
  font-size: 12px;
  color: var(--fg-3);
}
.lh-agent-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.lh-agent-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.lh-agent-card-main {
  min-width: 0;
}
.lh-agent-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
}
.lh-agent-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--fg-3);
}
.lh-agent-error {
  color: var(--danger);
}
.lh-agent-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  flex: 0 0 auto;
}

/* Buttons */
.lh-btn-primary, .lh-btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}
.lh-btn-primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.lh-btn-primary:hover:not(:disabled) { background: var(--accent-deep, var(--fg)); }
.lh-btn-ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); }
.lh-btn-ghost:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--line-strong); }
.lh-btn-ghost.danger { color: var(--danger); border-color: color-mix(in oklab, var(--danger) 35%, var(--line)); }
.lh-btn-ghost.danger:hover:not(:disabled) { background: color-mix(in oklab, var(--danger) 8%, transparent); }
.lh-btn-primary.sm, .lh-btn-ghost.sm { height: 28px; padding: 0 11px; font-size: 12px; }
.lh-btn-primary:disabled, .lh-btn-ghost:disabled { opacity: 0.5; cursor: default; }
.lh-link-plain { background: none; border: none; color: var(--accent); font-size: 12px; cursor: pointer; font-family: inherit; padding: 0; }
.lh-link-plain:hover { text-decoration: underline; }

/* AI suggestions */
.lh-suggest-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: flex-start;
  padding: 7px 12px;
  border: 1px solid var(--accent-dim, var(--line-strong));
  background: var(--bg);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  transition: background 150ms ease;
}
.lh-suggest-trigger:hover { background: var(--accent-soft); }
.lh-suggest-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--fg-3);
  padding: 4px 2px;
}
.lh-suggest { display: flex; flex-direction: column; gap: 8px; }
.lh-suggest-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-3);
}
.lh-suggest-head > span { display: inline-flex; align-items: center; gap: 5px; }
.lh-suggest-empty { font-size: 14px; color: var(--fg-3); }
.lh-suggest-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.lh-suggest-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.lh-suggest-name { font-size: 13px; font-weight: 600; color: var(--fg); }
.lh-suggest-reason { font-size: 14px; color: var(--fg-3); line-height: 1.4; }
.lh-meter { height: 4px; border-radius: 999px; background: var(--bg-sunken); overflow: hidden; }
.lh-meter-fill { height: 100%; border-radius: 999px; }
.lh-meter-fill.tone-ok { background: var(--success, #00a433); }
.lh-meter-fill.tone-warn { background: var(--warn, #e87c00); }
.lh-meter-fill.tone-low { background: var(--muted-light, #a1a1aa); }
.lh-suggest-side { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.lh-conf { font-size: 13px; font-weight: 600; }
.lh-conf.tone-ok { color: var(--success, #00a433); }
.lh-conf.tone-warn { color: var(--warn, #e87c00); }
.lh-conf.tone-low { color: var(--fg-3); }

/* Tabs */
.lh-tabs {
  display: flex;
  gap: 2px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
}
.lh-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 13px;
  margin-bottom: -1px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-3);
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease;
}
.lh-tab:hover:not(:disabled) { color: var(--fg); }
.lh-tab.is-on { color: var(--fg); border-bottom-color: var(--accent); }
.lh-tab:disabled { color: var(--fg-4); cursor: default; }
.lh-tab-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

/* Chat thread */
.lh-thread { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.lh-thread-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-bottom: 1px solid var(--line-soft, var(--line));
  color: var(--fg-3);
}
.lh-thread-search input {
  flex: 0 1 280px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  height: 30px;
  padding: 0 10px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--fg);
  outline: none;
}
.lh-thread-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lh-thread-clear { background: none; border: none; color: var(--fg-3); cursor: pointer; padding: 4px; display: inline-flex; }
.lh-thread-meta { margin-left: auto; font-size: 11.5px; color: var(--fg-3); }
.lh-thread-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 22px 20px; background: var(--bg-soft); }
.lh-thread-state { text-align: center; font-size: 12.5px; color: var(--fg-3); padding: 32px 12px; }
.lh-thread-loadmore { text-align: center; padding: 4px 0 12px; }

/* Analysis tab */
.lh-analysis { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.lh-analysis-bar { display: flex; align-items: center; gap: 10px; }
.lh-since { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--fg-3); }
.lh-preset-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.lh-preset {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  cursor: pointer;
  text-align: left;
  transition: background 150ms ease, border-color 150ms ease;
}
.lh-preset:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--line-strong); }
.lh-preset:disabled { opacity: 0.55; cursor: default; }
.lh-preset.is-busy { color: var(--fg-3); }
.lh-preset-badge { font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 999px; font-family: var(--font-mono); }
.lh-preset-badge.tone-cached { background: var(--bg-sunken); color: var(--fg-3); }
.lh-preset-badge.tone-stale { background: color-mix(in oklab, var(--warn, #e87c00) 14%, transparent); color: var(--warn, #e87c00); }
.lh-custom { display: flex; gap: 8px; }
.lh-input {
  flex: 1;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  font-family: inherit;
  font-size: 13px;
  color: var(--fg);
  outline: none;
  min-width: 0;
}
.lh-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lh-agent-wrap { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 22px 24px; }

/* Empty / error state */
.lh-detail-empty { align-items: center; justify-content: center; }
.lh-empty-card { max-width: 340px; text-align: center; padding: 24px; }
.lh-empty-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--fg-3);
  margin-bottom: 14px;
}
.lh-empty-card h2 { margin: 0 0 8px; font-size: 16px; font-weight: 600; color: var(--fg); }
.lh-empty-card p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--fg-3); }

/* Responsive: stack the rail above the detail on narrow screens */
@media (max-width: 820px) {
  .lh-hub { flex-direction: column; }
  .lh-rail { flex: 0 0 auto; max-height: 42vh; border-right: none; border-bottom: 1px solid var(--line); }
  .lh-detail-head, .lh-linkbar, .lh-tabs, .lh-thread-search { padding-left: 16px; padding-right: 16px; }
  .lh-botmeta { margin-left: 16px; margin-right: 16px; }
  .lh-botmeta-grid { grid-template-columns: 1fr; }
  .lh-botmeta-actions { align-items: flex-start; flex-direction: column; }
  .lh-agent-registry { margin-left: 16px; margin-right: 16px; }
  .lh-agent-create { grid-template-columns: 1fr; }
  .lh-agent-create-actions, .lh-agent-card { align-items: flex-start; flex-direction: column; }
  .lh-agent-actions { justify-content: flex-start; }
  .lh-thread-scroll, .lh-analysis, .lh-agent-wrap { padding-left: 16px; padding-right: 16px; }
  .lh-preset-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .lh-detail { animation: none; }
  .lh-spin { animation: none; }
  .lh-skel-line { animation: none; }
  .lh-row, .lh-filter, .lh-tab, .lh-preset, .lh-btn-primary, .lh-btn-ghost, .lh-icon-btn, .lh-suggest-trigger { transition: none; }
}

/* ── Needs-action signal (last message is from the client) ──────────────────── */
.lh-filters .lh-filter:first-child.is-on { background: var(--warn, #e87c00); color: #fff; }
.lh-action-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn, #e87c00);
  margin-right: 1px;
}
.lh-row.needs-action .lh-row-name { color: var(--fg); }
.lh-row.needs-action:not(.is-active) { background: color-mix(in oklab, var(--warn, #e87c00) 6%, transparent); }

/* ── Participants bar (team vs client) ──────────────────────────────────────── */
.lh-people { margin: 0 22px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-soft); }
.lh-people-loading { padding: 9px 12px; font-size: 12px; color: var(--fg-3); }
.lh-people-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 12px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--fg-2);
  cursor: pointer;
  text-align: left;
}
.lh-people-stat { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; white-space: nowrap; }
.lh-people-stat b { color: var(--fg); }
.lh-people-names { flex: 1; min-width: 0; color: var(--fg-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lh-people-summary > svg { flex: 0 0 auto; color: var(--fg-3); transition: transform 150ms ease; }
.lh-people.is-open .lh-people-summary > svg { transform: rotate(180deg); }
.lh-pk { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.lh-pk.team { background: var(--info, #4060d6); }
.lh-pk.customer { background: #06c755; }
.lh-people-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 4px 12px 12px;
  border-top: 1px solid var(--line-soft, var(--line));
}
.lh-people-col { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.lh-people-head { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-3); margin-bottom: 3px; }
.lh-person { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--fg); min-width: 0; }
.lh-person-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lh-person-alias { font-size: 11px; color: var(--fg-4); flex: 0 0 auto; }
.lh-person-count { margin-left: auto; font-size: 11px; color: var(--fg-3); flex: 0 0 auto; }
@media (max-width: 820px) {
  .lh-people { margin-left: 16px; margin-right: 16px; }
  .lh-people-detail { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .lh-people-summary > svg { transition: none; } }

/* ── Sender tag inside chat bubbles (team / client) — used by line-chat.jsx ─── */
.line-sender-tag {
  display: inline-block;
  margin-left: 7px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  vertical-align: middle;
  line-height: 16px;
}
.line-sender-tag.is-team { background: color-mix(in oklab, var(--info, #4060d6) 14%, transparent); color: var(--info, #4060d6); }
.line-sender-tag.is-customer { background: var(--bg-sunken); color: var(--fg-3); }

