/* ============================================================
   EvilynAI Webclient — layout + components
   ============================================================
   Editorial-gothic cockpit. Centered chat hero, ornamented
   left control panel, candlelit ambient glow.
   ============================================================ */

* { box-sizing: border-box; }
html, body, #root { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg-2);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  overflow: hidden;
}

:root {
  /* Tweakable */
  --glow-strength: 0.6;          /* 0–1 — multiplier for crimson aura */
  --panel-width: 340px;
}

/* ============================================================
   SHELL
   ============================================================ */
.shell {
  height: 100vh;
  display: grid;
  grid-template-rows: 60px 1fr;
  position: relative;
  isolation: isolate;
  background: var(--bg);
}

/* Ambient candlelight — sits behind everything */
.ambient {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1100px 600px at 90% -5%, rgba(168,24,28,calc(0.10 * var(--glow-strength))), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(168,24,28,calc(0.08 * var(--glow-strength))), transparent 60%),
    radial-gradient(900px 700px at 50% 50%, rgba(107,14,20,calc(0.05 * var(--glow-strength))), transparent 65%);
  transition: opacity var(--dur-slow) var(--ease-out);
}
.ambient.motion::before {
  content: "";
  position: absolute; inset: -20%;
  background: radial-gradient(450px 350px at 30% 40%, rgba(195,50,55,calc(0.07 * var(--glow-strength))), transparent 70%);
  animation: emberDrift 22s var(--ease-in-out) infinite alternate;
}
.ambient.motion::after {
  content: "";
  position: absolute; inset: -20%;
  background: radial-gradient(360px 300px at 70% 60%, rgba(168,24,28,calc(0.06 * var(--glow-strength))), transparent 70%);
  animation: emberDrift2 28s var(--ease-in-out) infinite alternate;
}
@keyframes emberDrift {
  0%   { transform: translate(0, 0)    scale(1); }
  100% { transform: translate(80px, -40px) scale(1.15); }
}
@keyframes emberDrift2 {
  0%   { transform: translate(0, 0)    scale(1.1); }
  100% { transform: translate(-60px, 50px) scale(0.95); }
}

/* Optional warm grain — keeps surfaces painterly */
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  opacity: 0.035; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============================================================
   TOP BAR
   ============================================================ */
.topbar {
  position: relative;
  z-index: 10;
  display: flex; align-items: center;
  gap: 14px;
  padding: 0 20px;
  height: 60px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(8,6,10,0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.topbar__brand { display: flex; align-items: center; gap: 12px; }
.topbar__brand img {
  width: 32px; height: 32px;
  filter: drop-shadow(0 4px 14px rgba(168,24,28,calc(0.55 * var(--glow-strength))));
}
.topbar__title {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg-1);
  line-height: 1;
}
.topbar__title em { color: var(--accent); font-style: italic; font-weight: 500; }
.topbar__divider { width: 1px; height: 22px; background: var(--border); }
.topbar__thread {
  font-family: var(--font-body);
  font-style: italic; font-size: 14px;
  color: var(--fg-3);
}
.topbar__spacer { flex: 1; }
.topbar__status {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-ui); font-size: 12px; color: var(--fg-3);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: rgba(15,12,17,0.5);
}
.topbar__status .dot {
  width: 7px; height: 7px; border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 8px rgba(107,138,90,0.7);
  animation: dotPulse 2.4s ease-in-out infinite;
}
.topbar__status .dot.warn { background: var(--warning); box-shadow: 0 0 8px rgba(201,148,43,0.7); }
.topbar__status .dot.err  { background: var(--danger);  box-shadow: 0 0 8px rgba(168,24,28,0.7); }
@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ============================================================
   BODY GRID — three layout variants
   ============================================================ */
.body {
  position: relative;
  display: grid;
  min-height: 0;
  transition: grid-template-columns var(--dur-slow) var(--ease-out);
}
.body--atelier  { grid-template-columns: var(--panel-width) 1fr; }
.body--codex    { grid-template-columns: 64px 1fr; }
.body--codex.has-expanded { grid-template-columns: 64px var(--panel-width) 1fr; }
.body--curtain  { grid-template-columns: 1fr; }
.body--curtain .left-panel { /* overlay */
  position: absolute; top: 0; bottom: 0; left: 0;
  width: var(--panel-width);
  z-index: 12;
  transform: translateX(-100%);
  transition: transform 320ms var(--ease-flame);
  box-shadow: 18px 0 60px rgba(0,0,0,0.55);
}
.body--curtain.curtain-open .left-panel { transform: translateX(0); }
.body--curtain .scrim {
  position: absolute; inset: 0; z-index: 11;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.body--curtain.curtain-open .scrim { opacity: 1; pointer-events: auto; }

/* ============================================================
   CODEX — narrow icon rail
   ============================================================ */
.rail {
  background: rgba(15,12,17,0.7);
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  align-items: center; gap: 4px;
  padding: 14px 0 14px;
  position: relative; z-index: 5;
}
.rail__icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-3);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all var(--dur-fast) var(--ease-out);
}
.rail__icon:hover {
  background: var(--ink-900);
  border-color: var(--border-soft);
  color: var(--ink-100);
}
.rail__icon.active {
  background: rgba(168,24,28,0.12);
  border-color: rgba(168,24,28,0.35);
  color: var(--crimson-200);
  box-shadow: 0 0 14px rgba(168,24,28,calc(0.3 * var(--glow-strength)));
}
.rail__icon .badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-family: var(--font-ui); font-weight: 700; font-size: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(168,24,28,0.5);
}
.rail__spacer { flex: 1; }

/* ============================================================
   LEFT PANEL
   ============================================================ */
.left-panel {
  background: linear-gradient(180deg, rgba(15,12,17,0.85), rgba(8,6,10,0.85));
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  min-height: 0;
  position: relative;
  z-index: 4;
}
.left-panel__head {
  display: flex; align-items: center;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border-soft);
  gap: 10px;
}
.left-panel__title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 600;
  color: var(--fg-1);
  letter-spacing: -0.005em;
}
.left-panel__title em { color: var(--accent); font-style: italic; }
.left-panel__sub {
  font-family: var(--font-body); font-style: italic;
  font-size: 12px; color: var(--fg-4);
  margin-top: 2px;
}
.left-panel__head-spacer { flex: 1; }
.left-panel__body {
  flex: 1; overflow-y: auto;
  padding: 6px 0 28px;
  display: flex; flex-direction: column;
}
.left-panel__body::-webkit-scrollbar { width: 8px; }
.left-panel__body::-webkit-scrollbar-thumb {
  background: var(--ink-700); border-radius: 4px;
}
.left-panel__body::-webkit-scrollbar-track { background: transparent; }

/* Ornament divider between sections */
.ornament {
  height: 24px;
  margin: 4px 18px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.5;
  color: var(--ink-600);
  font-family: var(--font-display); font-size: 14px;
  letter-spacing: 1em;
}

/* ============================================================
   CP SECTION
   ============================================================ */
.cp-section {
  padding: 14px 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.cp-section__head {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
  user-select: none;
}
.cp-section__head .chev {
  margin-left: auto;
  color: var(--fg-4);
  transition: transform var(--dur-base) var(--ease-out);
}
.cp-section.collapsed .chev { transform: rotate(-90deg); }
.cp-section.collapsed .cp-section__body { display: none; }

.cp-section__icon {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: rgba(168,24,28,0.08);
  border: 1px solid rgba(168,24,28,0.20);
  color: var(--crimson-300);
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 26px;
}
.cp-section__title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 17px;
  color: var(--fg-1);
  font-weight: 500;
  letter-spacing: -0.005em;
}
.cp-section__count {
  margin-left: 4px;
  font-family: var(--font-ui);
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(168,24,28,0.15);
  border: 1px solid rgba(168,24,28,0.3);
  color: var(--crimson-200);
}
.cp-section__body {
  display: flex; flex-direction: column; gap: 8px;
  animation: fadeIn var(--dur-base) var(--ease-out);
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   TOOL REQUEST CARDS
   ============================================================ */
.tool-req {
  background: linear-gradient(180deg, rgba(74,10,14,0.42), rgba(20,8,12,0.55));
  border: 1px solid rgba(168,24,28,0.35);
  border-radius: var(--radius-lg);
  padding: 12px 13px;
  display: flex; flex-direction: column; gap: 9px;
  box-shadow: 0 6px 20px rgba(168,24,28,calc(0.18 * var(--glow-strength))), 0 1px 0 rgba(255,255,255,0.04) inset;
  position: relative;
  animation: slideIn 380ms var(--ease-flame);
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}
.tool-req__head {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-ui); font-size: 12px;
  color: var(--crimson-200);
}
.tool-req__head .tool-name {
  font-family: var(--font-mono); font-weight: 500;
  color: var(--ink-100);
  letter-spacing: -0.01em;
}
.tool-req__head .time {
  margin-left: auto;
  font-family: var(--font-mono); font-size: 11px;
  color: var(--fg-4);
}
.tool-req__desc {
  font-family: var(--font-body); font-style: italic;
  font-size: 13px; color: var(--ink-200);
  line-height: 1.45;
}
.tool-req__args {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--fg-3);
  padding: 7px 9px;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  max-height: 80px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
}
.tool-req__actions {
  display: flex; gap: 6px;
}
.btn--approve {
  flex: 1;
  font-family: var(--font-ui); font-weight: 600; font-size: 12px;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--accent);
  border: 0;
  color: white;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset, 0 4px 12px rgba(168,24,28,calc(0.35 * var(--glow-strength)));
  transition: all var(--dur-fast) var(--ease-out);
}
.btn--approve:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn--approve:active { transform: scale(0.98); }
.btn--deny {
  flex: 1;
  font-family: var(--font-ui); font-weight: 600; font-size: 12px;
  padding: 7px 12px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-3);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.btn--deny:hover { color: var(--ink-100); border-color: var(--ink-500); }

.tool-req--resolved {
  opacity: 0.55;
  background: var(--ink-900);
  border-color: var(--border-soft);
  box-shadow: none;
}
.tool-req--resolved .tool-req__head { color: var(--fg-4); }
.tool-req__resolution {
  font-family: var(--font-ui); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--fg-3);
  display: inline-flex; align-items: center; gap: 5px;
}
.tool-req__resolution.approved { color: var(--success); }
.tool-req__resolution.denied { color: var(--fg-4); }

.cp-empty {
  font-family: var(--font-body); font-style: italic;
  font-size: 13px; color: var(--fg-4);
  padding: 10px 0;
}

/* ============================================================
   WINDOW CARD (System Monitor — short/long term)
   ============================================================ */
.window-card {
  background: linear-gradient(180deg, rgba(15,12,17,0.85), rgba(8,6,10,0.6));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 11px 12px 10px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
}
.window-card::before {
  content: "";
  position: absolute;
  left: 11px; right: 11px; top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(168,24,28,calc(0.5 * var(--glow-strength))), transparent);
}
.window-card__head {
  display: flex; align-items: baseline; gap: 8px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--border-soft);
  margin-bottom: 2px;
}
.window-card__title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 14px;
  font-weight: 600;
  color: var(--crimson-200);
  letter-spacing: 0;
}
.window-card__sub {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 11px;
  color: var(--fg-4);
}

/* ============================================================
   MONITOR STATS
   ============================================================ */
.stat-row {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px;
  font-family: var(--font-ui); font-size: 12px;
  color: var(--fg-3);
  padding: 4px 0;
}
.stat-row .label { color: var(--fg-3); }
.stat-row .value {
  font-family: var(--font-mono); font-size: 12px;
  color: var(--ink-200);
}
.stat-row .value.accent { color: var(--crimson-200); }
.stat-row .value.dim { color: var(--fg-4); }

.stat-bar {
  height: 4px; border-radius: 2px;
  background: var(--ink-800);
  overflow: hidden;
  margin-top: 4px;
}
.stat-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--crimson-700), var(--crimson-400));
  border-radius: 2px;
  transition: width var(--dur-base) var(--ease-out);
}

.mini-card {
  background: var(--ink-900);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 9px 10px;
  font-family: var(--font-body); font-size: 13px;
  color: var(--ink-200);
  font-style: italic;
  line-height: 1.5;
}
.mini-card .mini-card__label {
  display: block;
  font-family: var(--font-ui);
  font-style: normal;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-4);
  margin-bottom: 3px;
}

/* ============================================================
   LOGS
   ============================================================ */
.log-tabs {
  display: flex; gap: 2px;
  padding: 3px;
  border-radius: 8px;
  background: var(--ink-900);
  border: 1px solid var(--border-soft);
}
.log-tab {
  flex: 1;
  font-family: var(--font-ui); font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em;
  padding: 5px 8px;
  border-radius: 6px;
  background: transparent;
  border: 0;
  color: var(--fg-3);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.log-tab:hover { color: var(--ink-100); }
.log-tab.active {
  background: rgba(168,24,28,0.18);
  color: var(--crimson-200);
}
.log-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 1px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: rgba(0,0,0,0.30);
  padding: 6px;
}
.log-list::-webkit-scrollbar { width: 6px; }
.log-list::-webkit-scrollbar-thumb { background: var(--ink-700); border-radius: 3px; }
.log-entry {
  font-family: var(--font-mono); font-size: 11px;
  line-height: 1.5;
  padding: 4px 7px;
  border-radius: 4px;
  display: grid; grid-template-columns: 56px 50px 1fr; gap: 6px;
  align-items: baseline;
  color: var(--ink-300);
  animation: fadeInLog var(--dur-base) var(--ease-out);
}
@keyframes fadeInLog {
  from { opacity: 0; transform: translateY(-2px); }
  to { opacity: 1; transform: translateY(0); }
}
.log-entry:hover { background: rgba(255,255,255,0.025); }
.log-entry .ts { color: var(--fg-4); }
.log-entry .lvl {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
}
.log-entry.info .lvl    { color: var(--info); }
.log-entry.warn .lvl    { color: var(--warning); }
.log-entry.error .lvl   { color: var(--crimson-300); }
.log-entry.success .lvl { color: var(--success); }
.log-entry.debug .lvl   { color: var(--fg-4); }
.log-entry .logmsg { color: var(--ink-200); white-space: pre-wrap; word-break: break-word; }
/* ============================================================
   ACTIVITY LOG (richer than raw logs — narrated)
   ============================================================ */
.activity-list {
  display: flex; flex-direction: column;
  gap: 2px;
  border-left: 1px solid var(--border);
  margin-left: 5px;
  padding-left: 12px;
  position: relative;
}
.activity-item {
  position: relative;
  font-family: var(--font-ui); font-size: 12px;
  color: var(--fg-3);
  padding: 5px 0;
  line-height: 1.45;
}
.activity-item::before {
  content: "";
  position: absolute;
  left: -16px; top: 10px;
  width: 7px; height: 7px;
  border-radius: 999px;
  background: var(--ink-600);
  border: 2px solid var(--ink-1000);
}
.activity-item.accent::before { background: var(--crimson-400); box-shadow: 0 0 6px rgba(168,24,28,0.5); }
.activity-item.success::before { background: var(--success); }
.activity-item.error::before { background: var(--danger); }
.activity-item .what { color: var(--ink-200); }
.activity-item .when {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--fg-4);
  margin-left: 6px;
}

/* ============================================================
   TOOL SETTINGS
   ============================================================ */
.tool-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--ink-900);
  border: 1px solid var(--border-soft);
  transition: border-color var(--dur-fast) var(--ease-out);
}
.tool-row:hover { border-color: var(--border); }
.tool-row__icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--ink-800);
  border: 1px solid var(--border-soft);
  color: var(--fg-3);
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 28px;
}
.tool-row__main { flex: 1; min-width: 0; }
.tool-row__name {
  font-family: var(--font-ui); font-weight: 600; font-size: 13px;
  color: var(--ink-100);
}
.tool-row__meta {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--fg-4);
  margin-top: 2px;
}
.tool-row__status {
  font-family: var(--font-ui); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}
.tool-row__status.on  { background: rgba(107,138,90,0.15); color: var(--success); border: 1px solid rgba(107,138,90,0.4); }
.tool-row__status.off { background: var(--ink-800); color: var(--fg-4); border: 1px solid var(--border); }

/* Toggle switch */
.toggle {
  width: 32px; height: 18px;
  border-radius: 999px;
  background: var(--ink-700);
  position: relative;
  cursor: pointer;
  transition: background var(--dur-fast);
  border: 0; padding: 0;
  flex: 0 0 32px;
}
.toggle::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 999px;
  background: var(--ink-300);
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast);
}
.toggle.on { background: var(--accent); box-shadow: 0 0 10px rgba(168,24,28,calc(0.35 * var(--glow-strength))); }
.toggle.on::after { transform: translateX(14px); background: white; }

/* ============================================================
   INTEGRATIONS
   ============================================================ */
.integration-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--ink-900);
  border: 1px solid var(--border-soft);
}
.integration-row__name {
  font-family: var(--font-ui); font-weight: 600; font-size: 13px;
  color: var(--ink-100);
}
.integration-row__status {
  font-family: var(--font-body); font-style: italic; font-size: 12px;
  color: var(--fg-3);
}
.integration-row__status.ok { color: var(--success); }
.integration-row__status.stale { color: var(--warning); }
.integration-row__action {
  margin-left: auto;
  font-family: var(--font-ui); font-weight: 600; font-size: 11px;
  padding: 5px 11px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-200);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.integration-row__action:hover {
  border-color: var(--crimson-500);
  color: var(--crimson-200);
  background: rgba(168,24,28,0.08);
}

/* ============================================================
   CHAT MAIN
   ============================================================ */
.chat-main {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 0;
  min-width: 0;
  z-index: 2;
}
.thread {
  overflow-y: auto;
  padding: 36px 24px 24px;
  display: flex; flex-direction: column;
}
.thread__inner {
  max-width: 760px; width: 100%;
  margin: 0 auto;
  display: flex; flex-direction: column;
  gap: 18px;
}
.thread__divider {
  text-align: center;
  font-family: var(--font-body); font-style: italic;
  font-size: 12px; color: var(--fg-4);
  letter-spacing: 0.18em;
  text-transform: lowercase;
  padding: 4px 0 12px;
}
.thread__divider::before, .thread__divider::after {
  content: "❦";
  margin: 0 14px;
  color: var(--ink-600);
}

/* ============================================================
   MESSAGES
   ============================================================ */
.msg {
  display: flex; gap: 12px;
  align-items: flex-start;
  max-width: 100%;
  animation: msgIn 360ms var(--ease-flame);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg.from-user { justify-content: flex-end; }
.msg__avatar {
  width: 32px; height: 32px;
  flex: 0 0 32px;
  border-radius: 999px;
  background: #06040a;
  padding: 2px;
  filter: drop-shadow(0 4px 10px rgba(168,24,28,calc(0.45 * var(--glow-strength))));
}
.msg__bubble {
  font-family: var(--font-body);
  font-size: 15.5px; line-height: 1.6;
  padding: 12px 16px;
  border-radius: 14px;
  max-width: min(580px, 78%);
  word-wrap: break-word;
  color: var(--ink-100);
}
.msg.from-user .msg__bubble {
  background: var(--ink-800);
  border: 1px solid var(--ink-700);
  border-bottom-right-radius: 4px;
}
.msg.from-evilyn .msg__bubble {
  background: linear-gradient(180deg, #1a0e12, #14080c);
  border: 1px solid rgba(168,24,28,0.22);
  border-top-left-radius: 4px;
  box-shadow: 0 6px 20px rgba(168,24,28,calc(0.15 * var(--glow-strength)));
}
.msg.from-evilyn .msg__bubble em { color: var(--crimson-200); font-style: italic; }
.msg.from-system .msg__bubble {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--fg-3);
  font-style: italic;
  font-size: 14px;
  text-align: center;
  max-width: 100%;
}

/* Streaming caret */
.caret {
  display: inline-block;
  width: 6px; height: 16px;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--crimson-400);
  border-radius: 1px;
  animation: caretBlink 0.85s steps(2) infinite;
}
@keyframes caretBlink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Inline tool action indicator */
.msg__tool-indicator {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 8px;
  font-family: var(--font-ui); font-size: 11px;
  color: var(--crimson-300);
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(168,24,28,0.10);
  border: 1px solid rgba(168,24,28,0.3);
}

/* Typing indicator */
.typing {
  display: inline-flex; gap: 5px; align-items: center;
  padding: 14px 16px;
}
.typing span {
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--crimson-300);
  opacity: 0.4;
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.18s; }
.typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty {
  height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; gap: 18px;
  padding: 32px;
}
.empty img {
  width: 110px; height: 110px;
  filter: drop-shadow(0 18px 40px rgba(168,24,28,calc(0.55 * var(--glow-strength))));
  animation: floaty 6s var(--ease-in-out) infinite alternate;
}
@keyframes floaty {
  from { transform: translateY(-2px); }
  to { transform: translateY(2px); }
}
.empty__title {
  font-family: var(--font-display); font-style: italic; font-weight: 500;
  font-size: 48px; color: var(--ink-100); line-height: 1.05;
  text-wrap: balance;
}
.empty__title em { color: var(--crimson-300); }
.empty__sub {
  font-family: var(--font-body); font-size: 17px;
  color: var(--fg-3);
  max-width: 46ch; line-height: 1.55; text-wrap: pretty;
}
.empty__suggestions {
  display: flex; gap: 8px; flex-wrap: wrap;
  justify-content: center;
  max-width: 580px;
  margin-top: 4px;
}

/* ============================================================
   COMPOSER
   ============================================================ */
.composer-wrap {
  padding: 12px 24px 22px;
  border-top: 1px solid var(--border-soft);
  background: linear-gradient(180deg, transparent, rgba(8,6,10,0.65) 30%);
}
.composer {
  max-width: 760px;
  margin: 0 auto;
  background: var(--ink-900);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px 14px 10px;
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 14px 32px rgba(0,0,0,0.45);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast);
}
.composer:focus-within {
  border-color: rgba(168,24,28,0.55);
  box-shadow: 0 0 0 3px rgba(168,24,28,calc(0.18 * var(--glow-strength))),
              0 14px 32px rgba(0,0,0,0.45);
}
.composer__input {
  font-family: var(--font-body);
  font-size: 15.5px; line-height: 1.55;
  color: var(--ink-100);
  background: transparent;
  border: 0; outline: none; resize: none;
  width: 100%;
  min-height: 24px; max-height: 200px;
}
.composer__input::placeholder { color: var(--fg-4); font-style: italic; }
.composer__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.composer__hint { font-family: var(--font-body); font-style: italic; font-size: 12px; color: var(--fg-4); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  font-family: var(--font-ui); font-weight: 600; font-size: 14px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  transition: all var(--dur-fast) var(--ease-out);
}
.btn--primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset, 0 4px 14px rgba(168,24,28,calc(0.4 * var(--glow-strength)));
}
.btn--primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn--primary:active { transform: scale(0.98); }
.btn--primary:disabled {
  background: var(--ink-800); color: var(--fg-4);
  box-shadow: none; cursor: not-allowed;
}
.btn--ghost {
  background: transparent; color: var(--ink-200);
  border: 1px solid var(--border);
  padding: 7px 14px;
}
.btn--ghost:hover {
  border-color: var(--crimson-500);
  color: var(--ink-100);
  background: rgba(168,24,28,0.06);
}
.iconbtn {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-3);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.iconbtn:hover {
  border-color: var(--crimson-500);
  color: var(--ink-100);
  background: rgba(168,24,28,0.06);
}
.iconbtn--lg { width: 36px; height: 36px; border-radius: 10px; }

/* Suggestion buttons (empty state) */
.suggestion {
  font-family: var(--font-body); font-style: italic;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-200);
  cursor: pointer;
  transition: all var(--dur-base) var(--ease-flame);
}
.suggestion:hover {
  border-color: var(--crimson-500);
  background: rgba(168,24,28,0.08);
  color: var(--ink-100);
  transform: translateY(-1px);
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
