/* askEpic — chat-first UI (Gemini-inspired layout, epicEFI branding) */

:root {
  --sidebar-w: 280px;
  --memory-sidebar-w: 260px;
  --bg: #131314;
  --bg-sidebar: #1a1a1c;
  --bg-elevated: #28292a;
  --bg-input: #1e1f20;
  --text: #e3e3e3;
  --text-dim: #9aa0a6;
  --text-faint: #6b7280;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #8ab4f8;
  --accent-soft: rgba(138, 180, 248, 0.15);
  --ok: #81c995;
  --err: #f28b82;
  --radius: 28px;
  --font: "Google Sans Flex", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Code", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* epicEFI logo — white on transparent */
.brand-logo {
  display: block;
  height: 128px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.brand-logo--large {
  height: 176px;
  margin: 0 auto 0.75rem;
}

.brand-logo--small {
  height: 96px;
}

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2rem;
  background: var(--bg-sidebar);
  border-radius: 20px;
  border: 1px solid var(--border);
  text-align: center;
}

.subtitle {
  margin: 0 0 1.5rem;
  color: var(--text-dim);
  font-size: 0.95rem;
}

label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: left;
}

input, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
}

input {
  margin-top: 0.35rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-input);
}

textarea {
  resize: none;
  border: none;
  background: transparent;
  margin: 0;
  padding: 0.9rem 0.5rem 0.9rem 1.15rem;
  min-height: 24px;
  max-height: 200px;
  line-height: 1.5;
}

textarea:focus { outline: none; }

.btn {
  border: none;
  border-radius: 999px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  padding: 0.7rem 1.25rem;
}

.btn.primary {
  background: var(--accent);
  color: #131314;
}

.btn.full { width: 100%; }

.error {
  color: var(--err);
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
  text-align: center;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--memory-sidebar-w);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  grid-column: 1;
  grid-row: 1;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1rem 0.85rem;
  gap: 0.85rem;
  z-index: 200;
}

.sidebar-header {
  flex-shrink: 0;
  padding: 0.15rem 0.25rem;
}

.sidebar-group--repo {
  flex-shrink: 0;
  margin: 0.35rem 0 0.75rem;
  padding: 0 0.25rem;
}

.sidebar-group--memory {
  flex-shrink: 0;
  margin-top: 0.35rem;
}

.memory-panel {
  margin-top: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: #111112;
  border: 1px solid var(--border);
  max-height: 180px;
  overflow: auto;
}

.memory-panel-label {
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin-bottom: 0.4rem;
}

.memory-panel-text {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
}

.memory-panel-status {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: var(--ok);
}

.memory-panel-status.bad {
  color: var(--err);
}

/* Right chat-summary sidebar */
.memory-sidebar {
  grid-column: 3;
  grid-row: 1;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1rem 0.9rem;
  gap: 0.75rem;
  z-index: 180;
}

.memory-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-shrink: 0;
}

.memory-sidebar-header .group-label {
  margin: 0;
}

.memory-sidebar-close {
  display: none;
}

.memory-summary-text {
  margin: 0;
  flex: 1;
  min-height: 0;
  overflow: auto;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
}

.memory-summary-pending {
  margin: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.memory-summary-pending-label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.88rem;
  color: var(--text-dim);
}

.memory-summary-thinking {
  margin: 0;
  padding-left: 1.15rem;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text-dim);
  max-height: 3.2em;
  overflow: hidden;
}

.memory-header-toggle {
  margin-left: auto;
}

.share-header-btn {
  margin-left: 0;
}

.sidebar-bottom {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: auto;
}

.pill-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
}

.pill-btn + .pill-btn {
  margin-top: 0.45rem;
}

.pill-link {
  text-decoration: none;
  box-sizing: border-box;
}

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0 0.15rem;
}

.group-label {
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin-bottom: 0.15rem;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.stat-line code {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text);
}

.status-chip {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.status-chip.ok { color: var(--ok); }
.status-chip.bad { color: var(--err); }
.status-chip.busy { color: var(--accent); }

.log-box {
  border-radius: 8px;
  background: #111112;
  border: 1px solid var(--border);
  overflow: hidden;
}

.log-box.active {
  border-color: rgba(138, 180, 248, 0.3);
}

.log-label {
  padding: 0.35rem 0.55rem;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
}

.log-text {
  margin: 0;
  padding: 0.45rem 0.55rem;
  height: calc(1.25em * 4);
  max-height: calc(1.25em * 4);
  overflow-y: auto;
  overflow-x: hidden;
  font-family: var(--mono);
  font-size: 0.62rem;
  line-height: 1.25;
  color: var(--text-faint);
  white-space: pre-wrap;
  word-break: break-all;
  scrollbar-width: thin;
  scrollbar-color: #444 transparent;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.user-pill {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.text-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.text-btn:hover { color: var(--text); }

/* Main */
.main {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(ellipse 70% 45% at 50% 38%, rgba(95, 114, 185, 0.1), transparent 65%),
    var(--bg);
}

.main-header {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.share-header-btn {
  margin-left: 0;
  font-size: 0.9rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.icon-btn:hover { background: var(--bg-elevated); }

.main-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1rem 0.5rem;
  min-height: 0;
}

/* Empty: center greeting + composer + hint */
.center-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 0 1rem 2rem;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.main:not(.has-chat) .main-body {
  justify-content: center;
}

.main:not(.has-chat) .messages {
  display: none;
}

.main:not(.has-chat) .center-panel {
  flex: 0;
}

/* With chat: composer at bottom, hide greeting */
.main.has-chat .main-body {
  justify-content: flex-end;
}

.main.has-chat .center-panel {
  flex-shrink: 0;
  width: 100%;
  max-width: none;
  padding: 0.75rem 1rem 1.25rem;
  background: linear-gradient(transparent, var(--bg) 25%);
}

.main.has-chat .privacy-note {
  margin-top: 0.5rem;
}

.main.has-chat .greeting,
.main.has-chat .greeting-hint {
  display: none;
}

.main.has-chat .composer-area {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.greeting {
  margin: 0;
  font-size: clamp(1.6rem, 3.5vw, 2.1rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text);
  text-align: center;
  line-height: 1.25;
}

.greeting-hint {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.88rem;
  text-align: center;
  line-height: 1.5;
  max-width: 520px;
}

.greeting-hint.agent-error {
  color: #f87171;
}

.privacy-note {
  margin: 0.65rem 0 0;
  color: var(--text-faint);
  font-size: 0.78rem;
  text-align: center;
  line-height: 1.45;
  max-width: 520px;
}

.privacy-note--stats {
  max-width: none;
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  text-align: left;
  background: rgba(242, 139, 130, 0.08);
  border: 1px solid rgba(242, 139, 130, 0.25);
  border-radius: 12px;
  color: var(--text-dim);
}

.composer-area {
  width: 100%;
}

.composer {
  display: flex;
  align-items: flex-end;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.3rem 0.35rem 0.3rem 0.55rem;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.2);
  gap: 0.15rem;
}

.composer:focus-within {
  border-color: rgba(138, 180, 248, 0.35);
}

.composer-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.attach-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding-top: 0.35rem;
}

.attach-list.hidden { display: none !important; }

.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-dim);
}

.attach-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 12rem;
}

.attach-chip button {
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0;
}

.attach-chip button:hover {
  color: var(--err);
}

.attach-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attach-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent);
}

.attach-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.composer.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.4rem 0.5rem 0;
  justify-content: flex-end;
}

.msg-attach-image {
  margin: 0;
  max-width: min(320px, 82%);
  text-align: right;
}

.msg-attach-image img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  width: auto;
  height: auto;
  border-radius: 12px;
  cursor: zoom-in;
  background: var(--bg-elevated);
}

.msg-attach-image figcaption {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.send-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent);
}

.send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Chat messages */
.msg {
  max-width: 760px;
  margin: 0 auto 1.25rem;
  padding: 0 0.5rem;
}

.msg.user .msg-body {
  margin-left: auto;
  max-width: 82%;
  padding: 0.8rem 1rem;
  background: var(--bg-elevated);
  border-radius: 18px 18px 4px 18px;
  font-size: 0.94rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.assistant .msg-body {
  font-size: 0.94rem;
  line-height: 1.65;
  word-break: break-word;
}

.msg.assistant .md-body p {
  margin: 0 0 0.85rem;
}

.msg.assistant .md-body p:last-child {
  margin-bottom: 0;
}

.msg.assistant .md-h1,
.msg.assistant .md-h2,
.msg.assistant .md-h3,
.msg.assistant .md-h4 {
  margin: 1rem 0 0.5rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}

.msg.assistant .md-h1 { font-size: 1.15rem; }
.msg.assistant .md-h2 { font-size: 1.05rem; }
.msg.assistant .md-h3 { font-size: 0.98rem; }
.msg.assistant .md-h4 { font-size: 0.92rem; }

.msg.assistant .md-list {
  margin: 0 0 0.85rem;
  padding-left: 1.25rem;
}

.msg.assistant .md-list li {
  margin-bottom: 0.35rem;
}

.msg.assistant .md-table-wrap {
  margin: 0.75rem 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.msg.assistant .md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  line-height: 1.45;
}

.msg.assistant .md-table th,
.msg.assistant .md-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.msg.assistant .md-table th {
  background: #1a1b1e;
  color: var(--text);
  font-weight: 600;
}

.msg.assistant .md-table tr:last-child td {
  border-bottom: none;
}

.msg.assistant .md-table tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.msg.assistant .inline-code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 0.12em 0.35em;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  color: #c4d7ff;
}

.msg.assistant .code-block-wrap {
  margin: 0.75rem 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0d1117;
}

.msg.assistant .code-lang {
  display: block;
  padding: 0.35rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  background: #161b22;
  border-bottom: 1px solid var(--border);
}

.msg.assistant .code-block {
  margin: 0;
  padding: 0;
  overflow-x: auto;
  background: transparent;
}

.msg.assistant .code-block code {
  display: block;
  padding: 0.85rem 1rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  tab-size: 2;
  background: transparent;
}

.msg.thinking .msg-body {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text-dim);
  font-size: 0.88rem;
}

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

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

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

@keyframes bounce {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

.spinner::after {
  content: "";
  width: 0.75em;
  height: 0.75em;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  margin-left: 0.35rem;
}

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

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 150;
}

.sidebar-backdrop:not(.hidden) {
  display: block;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.45);
  }

  .sidebar.open { transform: translateX(0); }

  .memory-sidebar {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(var(--memory-sidebar-w), 88vw);
    grid-column: auto;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.45);
  }

  .memory-sidebar.open { transform: translateX(0); }
  .memory-sidebar-close { display: inline-flex; }

  .main { grid-column: 1; }
  .main-header { display: flex; }
}

@media (min-width: 901px) {
  .memory-sidebar-close { display: none; }
  .memory-header-toggle { display: none; }
}

/* —— Usage /stats page —— */
.stats-page {
  min-height: 100%;
  background: var(--bg);
}

.stats-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
}

.stats-back {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
}

.stats-back:hover { text-decoration: underline; }

.stats-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.stats-main {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.5rem;
}

.stats-loading,
.stats-empty {
  color: var(--text-dim);
  text-align: center;
  margin: 2rem 0;
}

.stats-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.stats-card {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem 1.15rem;
}

.stats-card-label {
  color: var(--text-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.stats-card-value {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.stats-card-sub {
  margin-top: 0.35rem;
  color: var(--text-faint);
  font-size: 0.8rem;
}

.stats-panel {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.15rem 1.25rem 1.35rem;
  margin-bottom: 1.15rem;
}

.stats-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.stats-panel-head .stats-section-title {
  margin: 0;
}

.stats-section-title {
  margin: 0 0 0.85rem;
  font-size: 1rem;
  font-weight: 600;
}

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.export-btn:hover {
  border-color: rgba(255, 255, 255, 0.18);
}

.usage-table-wrap {
  width: 100%;
  max-height: calc(2.7rem * 10 + 2.8rem); /* ~10 body rows + header */
  overflow: auto;
}

.usage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.usage-table th,
.usage-table td {
  text-align: left;
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.usage-table th {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  position: sticky;
  top: 0;
  background: var(--bg-sidebar);
  z-index: 1;
}

.usage-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.usage-table .num {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

.usage-table .status-ok { color: var(--ok); }
.usage-table .status-bad { color: var(--err); }

.usage-table .chat-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}

.usage-table .chat-link:hover {
  text-decoration: underline;
}

.usage-table .chat-link-muted {
  color: var(--muted);
}

.stats-chart-wrap {
  width: 100%;
  margin-bottom: 0.75rem;
}

.stats-chart-wrap canvas {
  width: 100%;
  height: 180px;
  display: block;
}

.topics-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.topic-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr) auto;
  gap: 0.65rem;
  align-items: center;
  font-size: 0.9rem;
}

.topic-label {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic-bar-wrap {
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
}

.topic-bar {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.topic-count {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
  text-align: right;
}

.pill-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
  margin-top: 0.65rem;
}

@media (max-width: 700px) {
  .stats-cards { grid-template-columns: 1fr; }
  .topic-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
  }
  .topic-bar-wrap { grid-column: 1 / -1; order: 3; }
}


.msg-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.msg-copy {
  border: 1px solid var(--border, rgba(128, 128, 128, 0.35));
  background: transparent;
  color: inherit;
  opacity: 0.6;
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 0.72rem;
  cursor: pointer;
}

.msg-copy:hover { opacity: 1; background: var(--bg-elevated); }

.msg-stats {
  padding-left: 2px;
  font-size: 0.72rem;
  line-height: 1.4;
  opacity: 0.55;
  font-variant-numeric: tabular-nums;
}

.msg.assistant.streaming .msg-body::after {
  content: "▍";
  animation: caret-blink 1s steps(2) infinite;
}

@keyframes caret-blink {
  50% { opacity: 0; }
}
