/* ═══════════════════════════════════════════════
   CHAT APP - Exact design from original
═══════════════════════════════════════════════ */
#chatApp {
  display: none;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-base);
}

#chatApp.active { display: flex; }

/* ─── Header ─── */
.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.chat-header::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(30,106,168,.15), transparent);
}

.header-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: #fff;
  border: 1px solid rgba(30,106,168,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.header-logo img { width: 28px; height: 28px; object-fit: contain; }

.header-info { flex: 1; }

.header-info h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.1px;
}

#headerSubtitle {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.header-actions {
  margin-right: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ─── Token Badge ─── */
.token-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: 99px;
  font-size: 12px;
}

.token-badge svg { width: 13px; height: 13px; color: var(--accent); }

#tokenCount { color: var(--text-primary); font-weight: 600; }

/* ─── Messages Area ─── */
.chat-messages {
  flex: 1;
  min-height: 0;       /* fix: flex child must be 0 to allow overflow-y to work */
  overflow-y: auto;
  padding: 32px 24px;
  flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
  background:
    radial-gradient(ellipse 50% 30% at 20% 10%, rgba(30,106,168,.04) 0%, transparent 60%),
    radial-gradient(ellipse 40% 25% at 80% 90%, rgba(45,212,191,.03) 0%, transparent 60%),
    var(--bg-base);
}

/* ─── Welcome Block ─── */
.welcome-block {
  align-self: center;
  text-align: center;
  padding: 60px 24px 40px;
  max-width: 560px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.welcome-icon-wrap {
  width: 88px;
  height: 88px;
  border-radius: 26px;
  background: #fff;
  border: 1px solid rgba(30,106,168,.15);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  box-shadow: 0 16px 48px rgba(30,106,168,.12), 0 0 0 12px rgba(30,106,168,.04);
}

.welcome-icon-wrap img { width: 56px; height: 56px; object-fit: contain; }

.welcome-block h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.4px;
  margin-bottom: 10px;
  color: #1e6aa8;
}

.welcome-block p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.75;
  margin-bottom: 32px;
  max-width: 400px;
}

/* ─── Suggestions ─── */
.suggestions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 480px;
}

.suggestion-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  text-align: right;
  outline: none;
}

.suggestion-chip:hover {
  border-color: rgba(59,126,255,.4);
  color: var(--text-accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(59,126,255,.1);
}

.chip-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(59,126,255,.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chip-icon svg { width: 15px; height: 15px; color: var(--accent); }

/* ─── Messages ─── */
.msg {
  display: flex;
  gap: 12px;
  max-width: 76%;
  animation: msgIn .28s cubic-bezier(.34,1.2,.64,1) both;
}

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

.msg.user {
  align-self: flex-start;
  flex-direction: row;
}

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

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg.user .msg-avatar {
  background: rgba(30,106,168,.1);
  border: 1px solid rgba(30,106,168,.2);
}

.msg.assistant .msg-avatar {
  background: #fff;
  border: 1px solid rgba(30,106,168,.2);
  box-shadow: 0 4px 12px rgba(30,106,168,.15);
  overflow: hidden;
}

.msg-avatar img { width: 24px; height: 24px; object-fit: contain; }

.msg-avatar svg { width: 15px; height: 15px; color: #1e6aa8; }

.msg.user .msg-avatar svg { color: rgba(30,106,168,.8); }

.msg-bubble-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.msg-body {
  padding: 13px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.8;
  word-break: break-word;
  position: relative;
}

.msg.user .msg-body {
  background: var(--user-bg);
  border: 1px solid rgba(30,106,168,.2);
  border-bottom-right-radius: 5px;
  color: #fff;
  --user-bg: linear-gradient(135deg,#1e6aa8,#164d7a);
}

.msg.assistant .msg-body {
  background: var(--bot-bg);
  border: 1px solid var(--border-mid);
  border-bottom-left-radius: 5px;
  box-shadow: var(--shadow-sm);
  --bot-bg: #ffffff;
}

.msg-time {
  font-size: 10.5px;
  color: var(--text-muted);
  padding: 0 4px;
}

.msg.user .msg-time { text-align: right; }
.msg.assistant .msg-time { text-align: left; }

/* ─── Markdown rendering inside assistant messages ─── */
.msg-body h1, .msg-body h2, .msg-body h3, .msg-body h4 {
  margin: 16px 0 10px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
}
.msg-body h1 { font-size: 18px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.msg-body h2 { font-size: 16px; }
.msg-body h3 { font-size: 15px; color: var(--accent); }
.msg-body h4 { font-size: 14px; }

.msg-body p { margin: 8px 0; }

.msg-body ul, .msg-body ol {
  margin: 8px 0;
  padding-right: 20px;
}
.msg-body li { margin: 4px 0; }

.msg-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}
.msg-body th, .msg-body td {
  border: 1px solid var(--border-mid);
  padding: 8px 10px;
  text-align: right;
}
.msg-body th {
  background: var(--bg-elevated);
  font-weight: 600;
  color: var(--text-primary);
}
.msg-body tr:nth-child(even) { background: rgba(30,106,168,.04); }

.msg-body blockquote {
  margin: 10px 0;
  padding: 10px 14px;
  border-right: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 6px 6px 0;
  color: var(--text-secondary);
}

.msg-body pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 10px 0;
  font-size: 13px;
  line-height: 1.6;
}
.msg-body code {
  background: rgba(30,106,168,.1);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'IBM Plex Mono', monospace;
}
.msg-body pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
}

.msg-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.msg-body a {
  color: var(--accent);
  text-decoration: none;
}
.msg-body a:hover { text-decoration: underline; }

.msg-body img {
  max-width: 100%;
  border-radius: 8px;
  margin: 8px 0;
}

/* ─── Tool Status ─── */
.tool-status {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: 99px;
  font-size: 12px;
  color: var(--text-secondary);
  animation: msgIn .28s ease both;
  margin: 4px 0;
}

.tool-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
  animation: toolPulse 1.2s ease infinite;
}

@keyframes toolPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .4; transform: scale(.8); }
}

.tool-status.done .tool-dot {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: none;
}

.tool-status.done {
  border-color: var(--success);
}

.tool-status.error {
  border-color: #fca5a5;
  background: #fef2f2;
  border-radius: 12px;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.tool-status.error .tool-dot {
  background: #dc2626;
  box-shadow: 0 0 8px #dc2626;
  animation: none;
}

.tool-status-icon { width: 14px; height: 14px; color: var(--text-muted); }

/* ─── Typing Indicator ─── */
.typing-indicator {
  align-self: flex-end;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
  background: var(--bot-bg);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  border-bottom-left-radius: 5px;
  animation: msgIn .28s ease both;
  box-shadow: var(--shadow-sm);
  --bot-bg: #131f35;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(110,168,254,.5);
  animation: typingBounce 1.4s ease infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); background: rgba(110,168,254,.4); }
  40% { transform: translateY(-6px); background: rgba(110,168,254,.9); }
}

/* ─── Agent Colors ─── */
.agent-1 { color: #1e6aa8; background: rgba(30,106,168,.1);  border-color: rgba(30,106,168,.25); }
.agent-2 { color: #0ea5e9; background: rgba(14,165,233,.1);  border-color: rgba(14,165,233,.25); }
.agent-3 { color: #8b5cf6; background: rgba(139,92,246,.1);  border-color: rgba(139,92,246,.25); }
.agent-4 { color: #f59e0b; background: rgba(245,158,11,.1);  border-color: rgba(245,158,11,.25); }

/* ─── Agent Thinking Card (replaces plain typing indicator) ─── */
.agent-thinking {
  align-self: flex-end;
  display: flex;
  gap: 10px;
  padding: 11px 15px;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  border-bottom-left-radius: 5px;
  box-shadow: var(--shadow-sm);
  animation: msgIn .28s ease both;
  max-width: min(320px, 76%);
  width: fit-content;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.agent-thinking::after {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 3px;
  background: currentColor;
  opacity: 0.45;
}

.thinking-avatar {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: #fff;
  border: 1px solid rgba(30,106,168,.2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(30,106,168,.12);
}

.thinking-avatar img { width: 20px; height: 20px; object-fit: contain; }

.thinking-content { flex: 1; min-width: 0; }

.thinking-top {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 5px;
}

.thinking-name {
  font-size: 13px; font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.thinking-dots { display: flex; gap: 3px; align-items: center; }

.thinking-dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(110,168,254,.5);
  animation: typingBounce 1.4s ease infinite;
}

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

.thinking-bottom {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px;
}

.thinking-tier {
  display: inline-block;
  padding: 1px 7px; border-radius: 4px;
  font-size: 10px; font-weight: 700;
  border: 1px solid; letter-spacing: .3px;
}

.thinking-model { color: var(--text-muted); font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.thinking-sep { opacity: 0.3; font-size: 11px; }

.thinking-status-text {
  font-size: 11px;
  color: var(--text-secondary);
  font-style: italic;
}

/* ─── Message Footer ─── */
.msg-footer {
  display: flex; align-items: center; gap: 5px;
  padding: 2px 4px; flex-wrap: wrap;
  font-size: 11px; color: var(--text-muted);
}

.msg-agent-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 99px;
  font-size: 10.5px; font-weight: 600;
  white-space: nowrap; border: 1px solid;
}

.msg-agent-badge::before {
  content: ''; width: 5px; height: 5px;
  border-radius: 50%; background: currentColor; flex-shrink: 0;
}

.msg-tier-tag {
  font-size: 10px; padding: 1px 5px; border-radius: 3px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-muted); font-weight: 500;
}

.msg-stat-sep { opacity: 0.35; }
.msg-stat { font-size: 10.5px; }
.msg-stat.cost { color: #10b981; font-weight: 500; }

/* ─── Response Rating (soft / subtle, yet visible) ─── */
.msg-rating {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 4px; margin-top: 2px; flex-wrap: wrap;
  animation: msgIn .35s ease both;
}
.msg-rating-q {
  font-size: 11px; color: var(--text-muted); opacity: .85;
}
.msg-rating-q.rated { color: #10b981; opacity: 1; font-weight: 500; }
.rating-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0;
  border: 1px solid var(--border); border-radius: 9px;
  background: transparent; color: var(--text-muted);
  cursor: pointer; opacity: .7;
  transition: all .18s ease;
}
.rating-btn svg { width: 15px; height: 15px; }
.rating-btn:hover { opacity: 1; transform: translateY(-1px); }
.rating-btn.up:hover    { color: #10b981; border-color: #10b98155; background: #10b9810f; }
.rating-btn.down:hover  { color: #ef4444; border-color: #ef444455; background: #ef44440f; }
.rating-btn.selected { opacity: 1; }
.rating-btn.up.selected   { color: #10b981; border-color: #10b98166; background: #10b9811a; }
.rating-btn.down.selected { color: #ef4444; border-color: #ef444466; background: #ef44441a; }
.rating-btn:disabled { cursor: default; }
.msg-rating-stars {
  display: inline-flex; align-items: center; gap: 2px;
  padding-right: 4px; border-right: 1px solid var(--border);
  margin-right: 2px; animation: msgIn .3s ease both;
}
.rating-star {
  background: none; border: none; padding: 1px; cursor: pointer;
  font-size: 16px; line-height: 1; color: #d1d5db; opacity: .9;
  transition: transform .12s ease, color .12s ease;
}
.rating-star:hover { transform: scale(1.18); }
.rating-star.on { color: #f59e0b; }
.msg-rating-thanks {
  font-size: 11px; color: #10b981; font-weight: 500;
  display: inline-flex; align-items: center; gap: 4px;
  animation: msgIn .35s ease both;
}

/* ─── Header Per-Model Stats Row ─── */
.agent-stats-row {
  display: flex; gap: 6px;
  align-items: center; flex-wrap: wrap;
}

.agent-stat-chip {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 500; border: 1px solid;
  white-space: nowrap; animation: msgIn .3s ease both;
}

.chip-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; opacity: 0.7; flex-shrink: 0;
}

.chip-name { font-weight: 600; }
.chip-val::before, .chip-cost::before { content: '·'; margin-left: 4px; opacity: 0.4; }

/* ─── Input Bar ─── */
.chat-input-bar {
  padding: 16px 24px 20px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.chat-input-bar::before {
  content: '';
  position: absolute;
  top: -1px; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(59,126,255,.15), transparent);
}

.input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 820px;
  margin: 0 auto;
  background: var(--bg-input);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 8px 10px 8px 8px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#chatInput {
  flex: 1;
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  resize: none;
  min-height: 40px;
  max-height: 140px;
  outline: none;
}

#chatInput::placeholder { color: var(--text-muted); }

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
  box-shadow: 0 4px 14px rgba(59,126,255,.4);
}

.send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(59,126,255,.5);
}

.send-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

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

/* Mic button */
.mic-btn {
  width: 38px; height: 38px;
  border-radius: 10px; border: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  color: var(--text-muted);
  cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  flex-shrink: 0; transition: all var(--transition);
}
.mic-btn:hover { border-color: var(--accent); color: var(--accent); }
.mic-btn.recording {
  background: rgba(239,68,68,.15);
  border-color: #ef4444;
  color: #ef4444;
  animation: micPulse 1.2s ease infinite;
}
@keyframes micPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.3); }
  50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}
.mic-btn svg { width: 16px; height: 16px; }

/* Image attach preview bar */
.image-preview-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: rgba(59,126,255,.08);
  border: 1px solid rgba(59,126,255,.25);
  border-radius: var(--radius);
  margin-bottom: 8px; animation: msgIn .2s ease;
  font-size: 13px; color: var(--text-primary);
}
.image-preview-bar span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-preview-bar button {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 14px; line-height: 1;
}
.image-preview-bar button:hover { color: #ef4444; }

/* Invoice "view" button inside a chat bubble */
.inv-view-btn {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 8px; padding: 7px 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #fff; border: none; border-radius: 9px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
  box-shadow: 0 3px 10px rgba(59,126,255,.35);
}
.inv-view-btn:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(59,126,255,.45); }

/* Invoice modal */
.inv-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); padding: 20px;
}
.inv-modal.open { display: flex; animation: msgIn .15s ease; }
.inv-modal-card {
  background: var(--bg-elevated, #fff); color: var(--text-primary);
  border: 1px solid var(--border-mid); border-radius: 14px;
  width: 100%; max-width: 560px; max-height: 85vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.inv-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border-mid);
  font-weight: 700; font-size: 15px;
}
.inv-modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 18px; cursor: pointer; line-height: 1;
}
.inv-modal-close:hover { color: #ef4444; }
.inv-modal-body { padding: 16px 18px; overflow-y: auto; }
.inv-modal-foot { padding: 10px 18px; border-top: 1px solid var(--border-mid); }
.inv-raw-toggle {
  background: var(--bg-base, #f4f6fb); border: 1px solid var(--border-mid);
  color: var(--text-muted); border-radius: 8px; padding: 6px 12px;
  font-family: inherit; font-size: 12px; cursor: pointer;
}
.inv-raw {
  margin: 0; padding: 14px 18px; max-height: 240px; overflow: auto;
  background: #0f172a; color: #cbd5e1; font-size: 12px;
  direction: ltr; text-align: left; white-space: pre-wrap; word-break: break-all;
}

/* Invoice tables */
.inv-table {
  width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 13px;
}
.inv-table th, .inv-table td {
  border: 1px solid var(--border-mid); padding: 7px 10px; text-align: right;
  vertical-align: top;
}
.inv-table > tbody > tr > th {
  background: var(--bg-base, #f4f6fb); width: 38%; font-weight: 600; color: var(--text-muted);
}
.inv-items thead th { background: rgba(59,126,255,.12); font-weight: 700; }
.inv-section-title { font-weight: 700; font-size: 13px; margin: 6px 0; color: var(--accent); }
.inv-empty { color: var(--text-muted); font-size: 12px; }

/* Recording bar */
.recording-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.2);
  border-radius: var(--radius);
  margin-bottom: 8px; animation: msgIn .2s ease;
}
.recording-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #ef4444;
  animation: micPulse 1s ease infinite;
}
.recording-timer { font-size: 13px; color: #ef4444; font-weight: 600; font-variant-numeric: tabular-nums; }
.recording-label { font-size: 12px; color: var(--text-muted); flex: 1; }
.recording-cancel {
  font-size: 12px; color: var(--text-muted);
  background: none; border: none; cursor: pointer;
  text-decoration: underline;
}

/* STT notice */
.stt-notice {
  align-self: center;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  background: rgba(16,185,129,.08);
  border: 1px solid rgba(16,185,129,.2);
  border-radius: 99px;
  font-size: 11px; color: #10b981;
  animation: msgIn .28s ease both;
  margin: 4px 0;
}

.input-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 10px;
  max-width: 820px;
  margin-inline: auto;
}

/* ─── Modal ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(6px);
  z-index: 300;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 400px;
  margin: 20px;
  animation: cardIn .25s cubic-bezier(.34,1.2,.64,1) both;
}

.modal-body {
  padding: 32px;
  text-align: center;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
}

/* ─── Analysis / report modals ─── */
.an-overlay { position: fixed; inset: 0; z-index: 1100; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,.55); padding: 20px; }
.an-overlay.open { display: flex; animation: msgIn .15s ease; }
.an-card { background: var(--bg-elevated,#fff); color: var(--text-primary); border: 1px solid var(--border-mid); border-radius: 14px; width: 100%; max-width: 720px; max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.an-card.small { max-width: 460px; }
.an-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border-mid); font-weight: 700; font-size: 15px; }
.an-head .an-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.an-close { background: none; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer; line-height: 1; }
.an-close:hover { color: #ef4444; }
.an-badge { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--text-accent); white-space: nowrap; }
.an-body { padding: 16px 18px; overflow-y: auto; flex: 1; min-height: 180px; }
.an-foot { padding: 10px 14px; border-top: 1px solid var(--border-mid); display: flex; gap: 8px; align-items: flex-end; }
.an-foot textarea { flex: 1; resize: none; border: 1px solid var(--border-mid); border-radius: 10px; padding: 9px 12px; font-family: inherit; font-size: 13px; background: var(--bg-base,#fff); color: var(--text-primary); max-height: 120px; }
.an-send { background: linear-gradient(135deg,var(--accent),var(--accent-dim)); color:#fff; border:none; border-radius:10px; padding: 10px 16px; font-family: inherit; font-weight:600; font-size:13px; cursor:pointer; }
.an-send:disabled { opacity: .5; cursor: default; }
/* setup form */
.an-field { margin-bottom: 14px; }
.an-field > label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.an-field select, .an-field input { width: 100%; box-sizing: border-box; border: 1px solid var(--border-mid); border-radius: 9px; padding: 9px 11px; font-family: inherit; font-size: 13px; background: var(--bg-base,#fff); color: var(--text-primary); }
.an-grid2 { display: flex; gap: 10px; }
.an-grid2 > div { flex: 1; }
.an-toggle { display: flex; gap: 8px; }
.an-toggle button { flex: 1; padding: 9px; border: 1px solid var(--border-mid); border-radius: 9px; background: var(--bg-base,#fff); color: var(--text-secondary); font-family: inherit; font-size: 13px; font-weight:600; cursor: pointer; }
.an-toggle button.active { border-color: var(--accent); color: var(--text-accent); background: var(--accent-soft); }
.an-start { width: 100%; margin-top: 4px; background: linear-gradient(135deg,var(--accent),var(--accent-dim)); color:#fff; border:none; border-radius:10px; padding: 11px; font-family: inherit; font-weight:700; font-size:14px; cursor:pointer; }
.an-start:disabled { opacity:.5; cursor:default; }
/* modal chat bubbles */
.an-msg { margin-bottom: 12px; display: flex; }
.an-msg.user { justify-content: flex-start; }
.an-msg.assistant { justify-content: flex-end; }
.an-bub { max-width: 92%; padding: 10px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.75; word-wrap: break-word; overflow-wrap: anywhere; }
.an-msg.assistant .an-bub { background: var(--bg-base,#f4f6fb); color: var(--text-primary); }
.an-msg.user .an-bub { background: var(--accent-soft); color: var(--text-accent); }
.an-bub table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 12.5px; }
.an-bub th, .an-bub td { border: 1px solid var(--border-mid); padding: 5px 8px; text-align: right; }
.an-status { font-size: 12px; color: var(--text-muted); margin: 6px 0; display:flex; align-items:center; gap:6px; }
/* A rule and gap keep this from reading as a conclusion of the report. */
.an-meta {
  font-size: 11px; color: var(--text-muted);
  margin-top: 14px; padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px;
  cursor: help;
}
.an-meta-sep { opacity: .45; }

/* Money state: green collected, amber partly collected, red cost nobody paid,
   grey no cost at all. Colour goes on the figure, not the whole line. */
.an-cost, .msg-stat.cost { font-weight: 600; }
.an-cost.cost-paid,    .msg-stat.cost.cost-paid    { color: var(--success); }
.an-cost.cost-partial, .msg-stat.cost.cost-partial { color: var(--warning); }
.an-cost.cost-unpaid,  .msg-stat.cost.cost-unpaid  { color: var(--danger); }
.an-cost.cost-free,    .msg-stat.cost.cost-free    { color: var(--text-muted); font-weight: 400; }

/* Structured Phase-1 questions (general analysis) */
.anq { border: 1px solid var(--border-mid); border-radius: 12px; padding: 14px; margin: 10px 0 14px; background: var(--bg-base,#fff); }
.anq-head { font-size: 13.5px; font-weight: 700; margin-bottom: 4px; }
.anq-intro { font-size: 12.5px; color: var(--text-secondary); line-height: 1.7; margin-bottom: 12px; }
.anq-item { border-top: 1px dashed var(--border-mid); padding: 11px 0 4px; }
.anq-item:first-of-type { border-top: none; }
.anq-top { display: flex; align-items: flex-start; gap: 7px; margin-bottom: 4px; }
.anq-num { flex: none; width: 20px; height: 20px; border-radius: 999px; background: var(--accent-soft); color: var(--text-accent); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.anq-q { font-size: 13px; font-weight: 600; line-height: 1.65; flex: 1; }
.anq-item textarea { width: 100%; box-sizing: border-box; resize: vertical; min-height: 38px; border: 1px solid var(--border-mid); border-radius: 9px; padding: 8px 10px; font-family: inherit; font-size: 12.5px; background: var(--bg-elevated,#fff); color: var(--text-primary); }
.anq-actions { display: flex; gap: 8px; margin-top: 14px; }
.anq-actions button { flex: 1; border-radius: 10px; padding: 10px; font-family: inherit; font-weight: 700; font-size: 13px; cursor: pointer; border: 1px solid var(--border-mid); }
.anq-submit { background: linear-gradient(135deg,var(--accent),var(--accent-dim)); color: #fff; border-color: transparent !important; }
.anq-skip { background: var(--bg-elevated,#fff); color: var(--text-secondary); }
.anq.locked { opacity: .6; }
.anq.locked textarea, .anq.locked button { pointer-events: none; }


/* ─── Responsive ─── */
@media (max-width: 640px) {
  .msg { max-width: 90%; }
  .chat-messages { padding: 20px 16px; }
  .auth-card { padding: 32px 22px; }
  .suggestions { grid-template-columns: 1fr; }
  .chat-input-bar { padding: 12px 16px 16px; }
  .an-card { max-width: 100%; }
}

/* ═══════════════════════════════════════════════════════════
   تقرير التحليل بصيغة HTML (يولّده الأيجنت 3/4 داخل نافذة التحليل)
   الكلاسات مطابقة لما تفرضه app/prompts/analysis_html_output.txt
   ═══════════════════════════════════════════════════════════ */

/* A report is a document, not a bubble. Bubbles sit left (flex-end resolves to
   left under RTL); full width starts it at the right and fits its tables. */
.an-msg.assistant:has(> .an-bub.an-html) { display: block; }
/* The same report reopened from the conversation history. */
.msg.msg-has-report { max-width: 100%; }
.msg-body.msg-report { line-height: 1.9; text-align: right; overflow-x: auto; }
.an-bub.an-html {
  max-width: 100%; width: 100%;
  padding: 16px 18px;
  line-height: 1.9;
  text-align: right;
  /* display:block on the table itself would cost it column sizing. */
  overflow-x: auto;
}

.wk-report h1 { font-size: 18px; margin: 0 0 .5em; line-height: 1.6; color: var(--wakeed-blue-dark); }
.wk-report h2 { font-size: 15px; margin: 1.8em 0 .6em; line-height: 1.6; padding-bottom: .4em;
                color: var(--wakeed-blue-dark); border-bottom: 2px solid var(--accent-glow); }
.wk-report h3 { font-size: 14px; margin: 1.4em 0 .5em; line-height: 1.6; color: var(--wakeed-blue); }
.wk-report section { margin: 0 0 1.6em; }
.wk-report p { margin: 0 0 1em; }
.wk-report ul, .wk-report ol { margin: 0 0 1.2em; padding-inline-start: 1.5em; }
.wk-report li { margin: 0 0 .6em; }
.wk-report li:last-child { margin-bottom: 0; }
.wk-report li::marker { color: var(--wakeed-teal-dark); }
.wk-report strong { color: var(--wakeed-blue-dark); }
.wk-report .wk-meta { color: var(--text-secondary); font-size: 13px; }

/* Rounded frame: overflow clips the corners against the header fill. */
.wk-report table {
  border-collapse: separate; border-spacing: 0; width: 100%;
  margin: 1em 0 1.5em; font-size: 13px; line-height: 1.8;
  border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden;
}
.wk-report th, .wk-report td {
  border-bottom: 1px solid var(--border); padding: 11px 13px;
  text-align: right; vertical-align: top;
}
.wk-report thead th {
  background: var(--accent-soft); color: var(--wakeed-blue-dark); font-weight: 600;
  white-space: nowrap; border-bottom: 2px solid var(--accent-glow);
}
.wk-report tbody tr:last-child td { border-bottom: none; }

/* A coloured edge as well as the tint, so the row reads without colour. */
.wk-report tr.ok     { background: rgba(34,197,94,.07);  box-shadow: inset 3px 0 0 var(--success); }
.wk-report tr.warn   { background: rgba(245,158,11,.08); box-shadow: inset 3px 0 0 var(--warning); }
.wk-report tr.danger { background: rgba(239,68,68,.07);  box-shadow: inset 3px 0 0 var(--danger); }

.wk-report .badge {
  display: inline-block; padding: 3px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 600; line-height: 1.7;
  white-space: nowrap; border: 1px solid transparent;
}
.wk-report .badge.ok     { background: rgba(34,197,94,.14);  color: #15803d; border-color: rgba(34,197,94,.35); }
.wk-report .badge.warn   { background: rgba(245,158,11,.16); color: #a16207; border-color: rgba(245,158,11,.38); }
.wk-report .badge.danger { background: rgba(239,68,68,.13);  color: #b91c1c; border-color: rgba(239,68,68,.32); }

.wk-report .up   { color: #15803d; font-weight: 600; }
.wk-report .down { color: #b91c1c; font-weight: 600; }
.wk-report .flat { color: var(--text-muted); }

/* ─── Stop control ─── */

/* One button, two jobs: send while idle, stop while a reply streams. */
.send-btn .ic-stop { display: none; }
.send-btn.stopping .ic-send { display: none; }
.send-btn.stopping .ic-stop { display: block; }
.send-btn.stopping { background: var(--danger); border-color: var(--danger); }

.an-send.stopping { background: var(--danger); border-color: var(--danger); color: #fff; }
.an-send.stopping:hover { filter: brightness(.93); }

/* A stopped reply is unfinished, not failed — muted, not alarming. */
.msg-stopped {
  font-size: 11.5px; color: var(--text-muted);
  margin-top: 6px; padding-top: 6px;
  border-top: 1px dashed var(--border-mid);
}

/* ─── Report components ───
   The model writes structure and class names only; behaviour is attached by
   anActivateReport() and every rule below is ours. */

.wk-cards {
  display: grid; gap: 10px; margin: 1em 0 1.5em;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.wk-card {
  display: flex; flex-direction: column; gap: 3px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-top: 3px solid var(--wakeed-blue-light);
}
.wk-card.ok     { border-top-color: var(--success); }
.wk-card.warn   { border-top-color: var(--warning); }
.wk-card.danger { border-top-color: var(--danger); }
.wk-card-label { font-size: 11.5px; color: var(--text-secondary); }
.wk-card-value { font-size: 19px; font-weight: 700; color: var(--wakeed-blue-dark); line-height: 1.4; }
.wk-card-note  { font-size: 11px; color: var(--text-muted); }

/* Tabs stay open until activated, so a partial or malformed strip still
   shows every panel rather than hiding the answer. */
.wk-tabs { margin: 1em 0 1.5em; }
.wk-tablist { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 2px solid var(--border); }
.wk-tab {
  padding: 8px 15px; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.wk-tab:hover { color: var(--wakeed-blue); }
.wk-tab.is-active { color: var(--wakeed-blue-dark); border-bottom-color: var(--wakeed-teal); }
.wk-panel { padding-top: 14px; }
.wk-tabs.is-live .wk-panel { display: none; }
.wk-tabs.is-live .wk-panel.is-active { display: block; }

.wk-slider {
  display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding-bottom: 6px; margin: 1em 0 .4em; scrollbar-width: thin;
}
.wk-slide {
  flex: 0 0 clamp(200px, 62%, 300px); scroll-snap-align: start;
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--bg-elevated); border: 1px solid var(--border);
}
.wk-slide > :first-child { margin-top: 0; }
.wk-slide > :last-child  { margin-bottom: 0; }
.wk-slider-nav { display: flex; gap: 6px; justify-content: flex-end; margin-bottom: 1.2em; }
.wk-slider-nav button {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  background: var(--bg-elevated); border: 1px solid var(--border-mid);
  color: var(--text-secondary); font-size: 17px; line-height: 1;
}
.wk-slider-nav button:hover { background: var(--accent-soft); color: var(--wakeed-blue); }

/* ─── Dark mode ───
   Only the report repaints: the surrounding app has no dark theme yet, and a
   half-converted screen reads worse than a consistently light one. */
@media (prefers-color-scheme: dark) {
  .an-bub.an-html {
    --bg-elevated: #1c2431; --border: rgba(255,255,255,.09); --border-mid: rgba(255,255,255,.16);
    --text-primary: #e6ecf3; --text-secondary: #9fb0c4; --text-muted: #7c8da3;
    --wakeed-blue: #6cb6ee; --wakeed-blue-dark: #9fd0f5; --wakeed-blue-light: #4a9bd6;
    --accent-soft: rgba(108,182,238,.12); --accent-glow: rgba(108,182,238,.28);
    background: #141b26; color: var(--text-primary);
  }
  .an-bub.an-html .wk-report tr.ok     { background: rgba(34,197,94,.12); }
  .an-bub.an-html .wk-report tr.warn   { background: rgba(245,158,11,.13); }
  .an-bub.an-html .wk-report tr.danger { background: rgba(239,68,68,.13); }
  .an-bub.an-html .wk-report thead th  { background: rgba(108,182,238,.12); }
  .an-bub.an-html .badge.ok     { color: #86efac; }
  .an-bub.an-html .badge.warn   { color: #fcd34d; }
  .an-bub.an-html .badge.danger { color: #fca5a5; }
  .an-bub.an-html .up   { color: #86efac; }
  .an-bub.an-html .down { color: #fca5a5; }
}

/* ─── Print ───
   Paper has no tabs and no scroll: every panel and slide is laid out in full. */
@media print {
  /* Everything printed stays in normal flow. The usual visibility+absolute trick
     prints one page and silently drops the rest: an absolutely positioned box
     does not paginate. So hide the app by taking it out of the document, and
     lift every height cap and scroll container between <body> and the report —
     each one of them clips at its own edge otherwise. */
  body > * { display: none !important; }
  body > .an-overlay.open {          /* the setup dialog is an overlay too */
    display: block !important; position: static; inset: auto;
    background: none; padding: 0; z-index: auto;
  }
  .an-card {
    max-width: none; max-height: none; height: auto; display: block;
    border: none; border-radius: 0; box-shadow: none; overflow: visible;
    background: #fff;
  }
  .an-body { overflow: visible; max-height: none; height: auto; padding: 0; }
  .an-head, .an-foot, .an-tools, .an-meta, .an-status, .an-redo,
  .an-msg.user, .wk-slider-nav, .wk-tablist { display: none !important; }
  .an-msg, .an-msg.assistant { display: block; }
  .an-bub, .an-bub.an-html {
    max-width: none; width: auto; max-height: none; overflow: visible;
    padding: 0; background: #fff; box-shadow: none; border: none;
  }

  /* Paper has no tabs and no horizontal scroll: lay every panel out in full. */
  .wk-tabs.is-live .wk-panel { display: block !important; }
  .wk-slider { display: block; overflow: visible; }
  .wk-slide { break-inside: avoid; margin-bottom: 10px; }
  .wk-report section, .wk-card, .wk-report tr { break-inside: avoid; }
  .wk-report h2 { break-after: avoid; }
  .wk-report table { font-size: 11px; }
  .wk-report thead { display: table-header-group; }   /* repeat headers per page */
  @page { margin: 14mm; }
}

.an-tools { display: flex; gap: 6px; margin-inline-start: auto; }
.an-tool {
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 14px;
  background: transparent; border: 1px solid var(--border-mid); color: var(--text-secondary);
}
.an-tool:hover { background: var(--accent-soft); color: var(--wakeed-blue); }

.an-redo {
  margin-inline-start: 10px; padding: 3px 11px; border-radius: 99px; cursor: pointer;
  font-family: inherit; font-size: 11.5px; font-weight: 600;
  background: var(--accent-soft); color: var(--wakeed-blue);
  border: 1px solid var(--accent-glow);
}
.an-redo:hover { background: var(--wakeed-blue); color: #fff; border-color: var(--wakeed-blue); }

/* ─── Conversations drawer ───
   A drawer rather than a column: #chatApp is a full-height flex column, and
   turning it into a row would mean wrapping every existing child. The page is
   RTL, so it opens from the right. Light only, like the rest of the app — the
   one dark block in this file is scoped to the report bubble. */
.conv-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 300px;
  max-width: 86vw;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-inline-start: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform var(--transition);
}

.conv-drawer.open { transform: translateX(0); }

.conv-scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(15, 23, 42, .35);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.conv-scrim.open { opacity: 1; pointer-events: auto; }

.conv-head {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 64px;
  padding: 0 16px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.conv-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }

.conv-x {
  margin-inline-start: auto;
  width: 30px; height: 30px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border-mid);
  color: var(--text-secondary);
  font-family: inherit;
}

.conv-x:hover { background: var(--accent-soft); color: var(--wakeed-blue); }

.conv-new {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px 12px 4px;
  padding: 10px 14px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  background: var(--wakeed-blue);
  color: #fff;
  border: none;
  transition: background var(--transition);
}

.conv-new svg { width: 15px; height: 15px; }
.conv-new:hover { background: var(--wakeed-blue-dark); }

.conv-list { flex: 1; min-height: 0; overflow-y: auto; padding: 10px; }

.conv-item {
  display: block;
  width: 100%;
  text-align: start;
  padding: 10px 12px 8px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-family: inherit;
  transition: background var(--transition), border-color var(--transition);
}

.conv-item:hover { background: var(--bg-elevated); border-color: var(--border-mid); }
.conv-item.active { border-color: var(--wakeed-blue); background: var(--accent-soft); }

.conv-item-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.conv-actions { display: flex; align-items: center; gap: 2px; }

.conv-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}
.conv-icon-btn svg { width: 15px; height: 15px; }
.conv-icon-btn:hover { background: var(--bg-hover); }
.conv-rename:hover { color: var(--wakeed-blue); }

.conv-title-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 3px 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--wakeed-blue);
  border-radius: var(--radius-xs);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.conv-share-btn[data-share="current"] { color: var(--success); }
.conv-share-btn[data-share="outdated"] { color: var(--warning); }

/* ─── Share dialog ─── */
.share-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, .45);
}

.share-overlay.open { display: flex; }

.share-dialog {
  width: 100%;
  max-width: 460px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.share-dialog-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.share-dialog-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.share-note { margin: 0; font-size: 13px; line-height: 1.7; color: var(--text-secondary); }
.share-note-error { color: var(--danger); }
.share-hint { margin: 0; font-size: 11.5px; color: var(--text-muted); }

.share-field { display: flex; flex-direction: column; gap: 6px; }
.share-field label { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.share-field-line { display: flex; gap: 8px; }

.share-field-line input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font-size: 13px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-xs);
}

.share-copy, .share-btn {
  padding: 8px 12px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-xs);
}

.share-copy:hover, .share-btn:hover { background: var(--accent-soft); color: var(--wakeed-blue); }
.share-btn-primary { color: #fff; background: var(--wakeed-blue); border-color: var(--wakeed-blue); }
.share-btn-primary:hover { color: #fff; background: var(--wakeed-blue-dark); }
.share-btn-danger { color: var(--danger); border-color: rgba(239, 68, 68, .35); }
.share-btn-danger:hover { color: var(--danger); background: rgba(239, 68, 68, .08); }
.share-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.conv-empty, .conv-loading {
  padding: 18px 12px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
}

