/* L40 brand-adjacent — keep visual signal close to l40.com (dark slate + cyan accent)
   without pulling the whole token system in. */
:root {
  --bg: #0f1419;
  --surface: #161b22;
  --surface-2: #1d242d;
  --border: #283039;
  --text: #e6edf3;
  --text-muted: #9aa7b3;
  --accent: #38bdf8;        /* L40 cyan */
  --accent-soft: rgba(255,138,61,0.15);
  --user-bubble: #1f2731;
  --assistant-bubble: #161b22;
  --error: #ff6b6b;
  --radius: 12px;
  --maxw: 820px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; cursor: pointer; }

/* ───── Login ───── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-card h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.brand-sub { color: var(--text-muted); margin: 4px 0 24px; font-size: 14px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card label { font-size: 13px; color: var(--text-muted); }
.login-card input {
  width: 100%; padding: 12px 14px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 15px; outline: none;
  transition: border-color 0.15s;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  width: 100%; padding: 12px 16px; margin-top: 4px;
  background: var(--accent); color: #0f1419;
  border: none; border-radius: 8px;
  font-size: 15px; font-weight: 600;
  transition: filter 0.15s;
}
.login-card button:hover { filter: brightness(1.08); }
.err { color: var(--error); font-size: 13px; margin: 4px 0 0; }

/* ───── Chat shell ───── */
.chat-body { display: flex; flex-direction: column; height: 100vh; }
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand-row { display: flex; align-items: baseline; gap: 12px; }
.brand-row .brand { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.brand-row .brand-sub { margin: 0; font-size: 13px; }
.header-actions { display: flex; gap: 8px; }
.ghost-btn {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 12px; font-size: 13px;
  transition: all 0.15s;
}
.ghost-btn:hover { color: var(--text); border-color: var(--text-muted); }

/* ───── Thread ───── */
.thread {
  flex: 1; overflow-y: auto;
  padding: 24px 16px;
}
.turn {
  max-width: var(--maxw);
  margin: 0 auto 16px;
  padding: 16px 20px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.6;
  font-size: 15px;
}
.turn.user { background: var(--user-bubble); border: 1px solid var(--border); }
.turn.assistant { background: var(--assistant-bubble); border: 1px solid var(--border); border-left: 3px solid var(--accent); }
.turn.assistant .turn-actions {
  margin-top: 12px;
  display: flex; gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.turn.assistant .copy-btn,
.turn.assistant .redraft-btn {
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 10px; font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.turn.assistant .copy-btn:hover,
.turn.assistant .redraft-btn:hover { color: var(--text); border-color: var(--text-muted); }
.turn.assistant .copy-btn.copied { color: var(--accent); border-color: var(--accent); }
.turn.assistant .copy-btn.secondary { opacity: 0.85; }
.turn.assistant .redraft-btn { background: transparent; }
.turn.assistant .redraft-btn.secondary { font-style: italic; }

.turn.assistant .turn-redraft-row {
  display: flex; gap: 6px; margin-left: 4px; padding-left: 8px;
  border-left: 1px solid var(--border);
}

/* Meta row — word count + Pangram chip + deadline countdown */
.turn-meta {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.meta-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border);
  letter-spacing: 0.02em;
}
.wc-chip.over-limit { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
/* AI-detection chips (Pangram + GPTZero) — green / yellow / red bands */
.detector-chip.detector-human { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.detector-chip.detector-ai-assisted { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.detector-chip.detector-ai-generated { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.detector-chip.detector-unknown { color: var(--text-muted); }
/* "Humanized via X" chip — shown when Undetectable rewrote the draft */
.rewrote-chip {
  background: #ecfeff;
  color: #155e75;
  border-color: #a5f3fc;
  font-style: italic;
}
.deadline-chip { font-variant-numeric: tabular-nums; }
.deadline-chip.urgent { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.deadline-chip.closed { background: #f3f4f6; color: #6b7280; text-decoration: line-through; }

/* Bio card — collapsible.
   Override .turn's `white-space: pre-wrap` so the indented innerHTML
   template doesn't render literal blank lines + line-break the inline
   links between revfactor.io / · / LinkedIn. */
.bio-card,
.bio-card * {
  white-space: normal;
}
.bio-card {
  margin-top: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
}
.bio-card summary {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  list-style: none;
  user-select: none;
}
.bio-card summary::before { content: '▸ '; }
.bio-card[open] summary::before { content: '▾ '; }
.bio-card summary:hover { color: var(--text); }
.bio-grid {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 14px;
  padding: 4px 14px 14px;
  align-items: start;
}
.bio-headshot {
  width: 80px; height: 80px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
}
.bio-name { font-size: 14px; font-weight: 600; color: var(--text); }
.bio-title { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.bio-links { font-size: 12px; margin-top: 6px; }
.bio-links a { color: var(--accent); text-decoration: none; }
.bio-links a:hover { text-decoration: underline; }
.bio-creds { font-size: 12px; color: var(--text-muted); margin-top: 8px; font-style: italic; line-height: 1.5; }

/* Rating widget */
.rate-widget {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
  margin-left: 4px;
}
.rate-label {
  color: var(--text-muted); font-size: 12px; margin-right: 2px;
}
.rate-star {
  background: transparent; color: var(--border);
  border: none; padding: 2px 4px; font-size: 18px; line-height: 1;
  transition: color 0.1s, transform 0.1s;
}
.rate-star:hover { color: var(--accent); transform: scale(1.15); }
.rate-star.selected { color: var(--accent); }
.rate-notes {
  flex: 1; min-width: 180px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 10px; font-size: 12px; outline: none;
  font-family: inherit;
}
.rate-notes:focus { border-color: var(--accent); }
.rate-status {
  color: var(--text-muted); font-size: 11px;
  margin-left: 4px;
}
.turn-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); font-weight: 600; margin-bottom: 8px;
}
/* Loading state — bouncing dots + cycling status text */
.thinking {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 24px;
}
.thinking-dots {
  display: inline-flex;
  gap: 5px;
  align-items: flex-end;
}
.thinking-dots span {
  width: 7px;
  height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  display: inline-block;
  animation: dot-bounce 1.3s ease-in-out infinite;
  opacity: 0.6;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.18s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes dot-bounce {
  0%, 70%, 100% { transform: translateY(0);    opacity: 0.45; }
  35%           { transform: translateY(-6px); opacity: 1;    }
}
.thinking-status {
  font-size: 13px;
  font-style: italic;
  transition: opacity 0.4s ease;
}
.thinking-status.fading { opacity: 0; }

/* ───── Composer ───── */
.composer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 16px 18px;
}
.composer textarea {
  width: 100%; max-width: var(--maxw); margin: 0 auto; display: block;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px;
  font-family: inherit; font-size: 15px; line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}
.composer textarea:focus { border-color: var(--accent); }
.composer-row {
  max-width: var(--maxw); margin: 10px auto 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.composer .hint { color: var(--text-muted); font-size: 12px; }
.composer button#send {
  background: var(--accent); color: #0f1419;
  border: none; border-radius: 8px;
  padding: 9px 18px; font-size: 14px; font-weight: 600;
  transition: filter 0.15s;
}
.composer button#send:hover { filter: brightness(1.08); }
.composer button#send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ───── Mobile ───── */
@media (max-width: 640px) {
  .chat-header { padding: 12px 14px; }
  .brand-row .brand-sub { display: none; }
  .turn { padding: 14px 16px; font-size: 14.5px; }
  .composer { padding: 10px 12px 14px; }
}


/* Author selector — L40 multi-author */
.author-select-label {
  font-size: 12px;
  color: var(--muted);
  margin-right: 8px;
  font-weight: 600;
}
.author-select {
  background: var(--surface, #1e293b);
  color: var(--text, #f8fafc);
  border: 1px solid var(--border, #334155);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  margin-right: 12px;
  min-width: 280px;
}
.author-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.author-select option:disabled {
  color: #64748b;
}


/* ── Client switcher (brand-name dropdown) ─────────────────────────────── */
.client-switch { position: relative; }
.client-switch-btn {
  background: none; border: none; color: inherit; font: inherit; font-weight: 700;
  cursor: pointer; padding: 0; display: inline-flex; align-items: center; gap: 6px;
}
.client-switch-btn .caret { font-size: 11px; opacity: .55; }
.client-switch-btn:hover .caret { opacity: 1; }
.client-menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 50; min-width: 210px;
  background: #111a2c; border: 1px solid #1f2b40; border-radius: 10px; padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.client-menu-item {
  display: block; padding: 8px 12px; border-radius: 7px; text-decoration: none;
  color: var(--accent, #e6edf3); font-size: 14px; font-weight: 600;
}
.client-menu-item:hover { background: rgba(255,255,255,.06); }
.client-menu-item.current { outline: 1px solid var(--accent); }
.client-menu-item.all { color: #8b98a9; font-weight: 400; border-top: 1px solid #1f2b40; margin-top: 4px; padding-top: 10px; }
