/* Darwin Chat — focused full-screen chat layout */

:root {
  --bg-0: #060a0f;
  --bg-1: #0b1118;
  --bg-2: #111a22;
  --bg-3: #1a2530;
  --line: #1c2630;
  --line-strong: #2a3645;
  --ink-0: #e6edf3;
  --ink-1: #b4c0cc;
  --ink-2: #7c8b99;
  --ink-3: #56636e;
  --brand: #9FEF00;
  --brand-soft: #c4ff5e;
  --brand-dim: #6b9626;
  --brand-ink: #020806;
  --font-sans: 'Geist', -apple-system, system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, monospace;

  --hist-w: 260px;
  --hist-collapsed-w: 56px;
  --companion-w: 320px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100vh; overflow: hidden; background: var(--bg-0); color: var(--ink-0); font-family: var(--font-sans); }
#root { height: 100vh; }

/* ====================================================
   SHELL — 3-column grid
   ==================================================== */
.chat-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: var(--hist-w) 1fr var(--companion-w);
  background: var(--bg-0);
  position: relative;
  overflow: hidden;
}
.chat-shell.hist-collapsed { grid-template-columns: var(--hist-collapsed-w) 1fr var(--companion-w); }
.chat-shell.no-companion   { grid-template-columns: var(--hist-w) 1fr; }
.chat-shell.no-companion.hist-collapsed { grid-template-columns: var(--hist-collapsed-w) 1fr; }

@media (max-width: 1280px) {
  .chat-shell { grid-template-columns: var(--hist-w) 1fr; }
  .chat-companion { display: none; }
}
@media (max-width: 900px) {
  .chat-shell { grid-template-columns: var(--hist-collapsed-w) 1fr; }
  .chat-hist:not(.collapsed) { position: absolute; z-index: 20; left: 0; top: 0; bottom: 0; width: var(--hist-w); }
}

/* ====================================================
   HISTORY LEFT
   ==================================================== */
.chat-hist {
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.chat-hist.collapsed { padding-top: 12px; align-items: center; }

.hist-new {
  margin: 12px;
  padding: 10px 14px;
  background: transparent;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--ink-1);
  font-family: inherit; font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: flex-start; gap: 8px;
}
.hist-new:hover { border-color: var(--brand-dim); color: var(--brand); }
.hist-new.collapsed {
  margin: 0;
  width: 36px; height: 36px;
  padding: 0;
  border-radius: 8px;
  font-size: 18px;
  justify-content: center;
}

.hist-top { flex-shrink: 0; }

.hist-search { padding: 0 12px 8px; }
.hist-search input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink-0);
  font-family: inherit; font-size: 12px;
  outline: none;
}
.hist-search input:focus { border-color: var(--brand-dim); }
.hist-search input::placeholder { color: var(--ink-3); }

.hist-list {
  flex: 1; overflow-y: auto;
  padding: 8px 8px 24px;
  display: flex; flex-direction: column; gap: 16px;
}
.hist-group { display: flex; flex-direction: column; gap: 2px; }
.hist-group-head {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-3); padding: 4px 8px 6px;
}
.hist-conv {
  display: flex; flex-direction: column; gap: 4px;
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
}
.hist-conv:hover { background: var(--bg-2); }
.hist-conv.active {
  background: var(--bg-2);
  border-color: var(--brand-dim);
  box-shadow: inset 2px 0 0 var(--brand);
}
.hist-conv-title {
  font-size: 12px; color: var(--ink-1);
  line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.hist-conv.active .hist-conv-title { color: var(--ink-0); font-weight: 500; }
.hist-conv-time {
  font-family: var(--font-mono); font-size: 9px;
  letter-spacing: 0.08em; color: var(--ink-3);
}

/* ====================================================
   MAIN (center column)
   ==================================================== */
.chat-main {
  display: flex; flex-direction: column;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(159,239,0,0.025), transparent 70%),
    linear-gradient(rgba(159,239,0,0.02) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, rgba(159,239,0,0.02) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--bg-0);
}

/* Topbar */
.chat-topbar {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  height: 60px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 17, 24, 0.6);
  backdrop-filter: blur(8px);
}
.topbar-toggle {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
}
.topbar-toggle:hover { border-color: var(--ink-3); color: var(--ink-0); }
.topbar-title { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.topbar-darwin-mini {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--brand-dim);
  background: radial-gradient(circle at 50% 30%, #0d2818, #020806 70%);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.topbar-darwin-mini svg {
  width: auto; height: 86px;
  margin-top: -10px;
}
.topbar-name {
  font-size: 14px; font-weight: 600; letter-spacing: -0.01em;
}
.topbar-name .ver {
  font-family: var(--font-mono); font-size: 10px; color: var(--ink-3);
  font-weight: 400; margin-left: 6px;
}
.topbar-role {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.1em; color: var(--brand-dim);
  margin-top: 2px;
}
.topbar-role .pip {
  width: 5px; height: 5px; border-radius: 50%; background: var(--brand);
  box-shadow: 0 0 4px var(--brand);
  animation: chat-pulse 2.4s infinite;
}
@keyframes chat-pulse { 50% { opacity: 0.4; } }

.topbar-actions { display: flex; gap: 6px; align-items: center; }
.topbar-actions button {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-2);
  cursor: pointer; font-size: 14px;
}
.topbar-actions button:hover { background: var(--bg-2); color: var(--ink-0); border-color: var(--line); }
.topbar-user {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  font-family: var(--font-mono);
}

/* ====================================================
   CHAT BODY — scrollable
   ==================================================== */
.chat-body {
  flex: 1;
  overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 32px 24px 24px;
}

/* Conversation flow (centered column) */
.chat-flow {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: flex; flex-direction: column;
  gap: 24px;
}

.chat-row { display: flex; }
.chat-row.user { justify-content: flex-end; }
.chat-row.bot  { justify-content: flex-start; }

.chat-user-bubble {
  max-width: 78%;
  padding: 12px 16px;
  background: var(--bg-3);
  color: var(--ink-0);
  border-radius: 14px 14px 4px 14px;
  font-size: 14px; line-height: 1.5;
}

.chat-bot {
  max-width: 100%;
  display: flex; flex-direction: column; gap: 8px;
}
.chat-thinking {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--brand);
  padding-left: 4px;
}
.chat-thinking .pip {
  width: 5px; height: 5px; border-radius: 50%; background: var(--brand);
  box-shadow: 0 0 4px var(--brand);
  animation: chat-pulse 1.2s infinite;
}
.chat-bot-bubble {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-left: 2px solid var(--brand);
  border-radius: 4px 14px 14px 14px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-bot-bubble.loading {
  flex-direction: row; align-items: center; gap: 12px; padding: 12px 16px;
}
.chat-content {
  margin: 0;
  font-size: 14px; line-height: 1.55;
  color: var(--ink-1);
}
.chat-content strong { color: var(--ink-0); font-weight: 600; }
.chat-content code {
  font: 500 12px/1.4 var(--font-mono);
  background: var(--bg-2); border: 1px solid var(--line);
  padding: 1px 5px; border-radius: 3px; color: var(--brand);
}

.chat-bullet {
  margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column; gap: 6px;
}
.chat-bullet li {
  font-size: 13.5px; line-height: 1.55; color: var(--ink-1);
  padding-left: 18px; position: relative;
}
.chat-bullet li::before {
  content: ""; position: absolute; left: 4px; top: 9px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--brand);
}
.chat-bullet li strong { color: var(--ink-0); font-weight: 600; }
.chat-bullet li code {
  font: 500 12px/1.4 var(--font-mono);
  background: var(--bg-2); padding: 1px 4px; border-radius: 3px; color: var(--brand);
}

.chat-cta {
  margin: 4px 0 0;
  padding: 10px 12px;
  background: rgba(159,239,0,0.06);
  border: 1px solid rgba(159,239,0,0.2);
  border-radius: 6px;
  font-size: 13px; color: var(--ink-0); line-height: 1.5;
}
.chat-cta strong { color: var(--brand); }

.chat-sources {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding-top: 6px; border-top: 1px dashed var(--line);
}
.chat-sources-label {
  font-family: var(--font-mono); font-size: 9px;
  letter-spacing: 0.14em; color: var(--ink-3);
  margin-right: 4px;
}
.chat-src {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 11px;
  color: var(--ink-1);
  font-family: var(--font-mono);
}
.chat-src .dot {
  width: 6px; height: 6px; border-radius: 50%;
  flex-shrink: 0;
}

.chat-actions {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding-top: 6px;
}
.chat-actions button {
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink-2);
  font-family: inherit; font-size: 11px;
  cursor: pointer;
}
.chat-actions button:hover { color: var(--brand); border-color: var(--brand-dim); background: rgba(159,239,0,0.04); }

/* Typing indicator */
.typing { display: inline-flex; align-items: center; gap: 4px; }
.typing span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--brand);
  animation: chat-dot 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
.typing-label {
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.06em; color: var(--ink-2);
}
@keyframes chat-dot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.7); }
  40%           { opacity: 1; transform: scale(1); }
}

/* ====================================================
   COMPOSER (bottom)
   ==================================================== */
.chat-composer-wrap {
  flex-shrink: 0;
  padding: 16px 24px 20px;
  background: linear-gradient(180deg, transparent, var(--bg-0) 40%);
}
.chat-composer {
  width: 100%; max-width: 760px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 8px;
}
.composer-quick {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.composer-quick button {
  padding: 5px 10px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.composer-quick button:hover { color: var(--brand); border-color: var(--brand-dim); background: rgba(159,239,0,0.04); }

.composer-field {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px 10px 16px;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer-field:focus-within {
  border-color: var(--brand-dim);
  box-shadow: 0 0 0 3px rgba(159,239,0,0.08), 0 8px 32px rgba(0,0,0,0.4);
}
.composer-field textarea {
  flex: 1;
  background: none; border: none; outline: none;
  color: var(--ink-0);
  font-family: inherit; font-size: 14px; line-height: 1.5;
  resize: none; padding: 6px 0;
  min-height: 26px; max-height: 140px;
}
.composer-field textarea::placeholder { color: var(--ink-3); }
.composer-send {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--brand); color: var(--brand-ink);
  border: 0; font-size: 18px; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.composer-send:hover:not(:disabled) { background: var(--brand-soft); }
.composer-send:disabled { opacity: 0.3; cursor: not-allowed; }

.composer-hint {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.08em; color: var(--ink-3);
  padding: 0 4px;
}
.composer-hint .pip {
  width: 5px; height: 5px; border-radius: 50%; background: var(--brand);
}

/* ====================================================
   EMPTY STATE (hero Darwin Welcome)
   ==================================================== */
.chat-empty {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 28px;
  padding: 40px 20px;
  max-width: 760px; margin: 0 auto; width: 100%;
}
.chat-empty-darwin {
  position: relative;
  animation: chat-float 5s ease-in-out infinite;
}
@keyframes chat-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
.chat-empty-darwin::after {
  content: ""; position: absolute;
  bottom: -8px; left: 50%; transform: translateX(-50%);
  width: 220px; height: 16px;
  background: radial-gradient(ellipse at center, rgba(159,239,0,0.25), transparent 70%);
  filter: blur(3px);
}
.chat-empty-copy {
  text-align: center;
  max-width: 540px;
}
.chat-empty-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--brand); margin-bottom: 12px;
}
.chat-empty-eyebrow .pip {
  width: 6px; height: 6px; border-radius: 50%; background: var(--brand);
  box-shadow: 0 0 6px var(--brand);
}
.chat-empty-title {
  font-size: 32px; font-weight: 600; letter-spacing: -0.02em;
  margin: 0 0 12px; line-height: 1.1;
}
.chat-empty-title em { color: var(--brand); font-style: normal; }
.chat-empty-lede {
  font-size: 14px; color: var(--ink-2);
  line-height: 1.55; margin: 0;
}
.chat-empty-lede strong { color: var(--ink-0); }

.chat-empty-suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 640px;
}
.chat-sug {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: left; cursor: pointer;
  transition: all 0.15s;
}
.chat-sug:hover {
  border-color: var(--brand-dim);
  background: rgba(159,239,0,0.04);
  transform: translateY(-1px);
}
.chat-sug-icon {
  font-size: 20px; flex-shrink: 0;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.chat-sug-meta { min-width: 0; flex: 1; }
.chat-sug-title {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--brand); margin-bottom: 4px;
}
.chat-sug-q {
  font-size: 13px; color: var(--ink-1);
  line-height: 1.4;
}

/* ====================================================
   COMPANION RAIL (right)
   ==================================================== */
.chat-companion {
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, rgba(159,239,0,0.04), transparent 70%),
    var(--bg-1);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 16px;
  gap: 14px;
  overflow: hidden;
  position: relative;
}
.companion-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--brand); color: #020806;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 700;
  box-shadow: 0 0 32px rgba(159,239,0,0.25);
}

.companion-frame {
  position: relative;
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  background:
    linear-gradient(rgba(159,239,0,0.02) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, rgba(159,239,0,0.02) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  min-height: 320px;
}
.companion-tag {
  position: absolute;
  top: 12px; left: 12px;
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 9px;
  letter-spacing: 0.18em; color: var(--ink-3);
  z-index: 2;
}
.companion-tag .pip {
  width: 5px; height: 5px; border-radius: 50%; background: var(--brand);
  box-shadow: 0 0 5px var(--brand);
  animation: chat-pulse 2s infinite;
}
.companion-darwin {
  position: relative;
  z-index: 2;
  animation: chat-float 5s ease-in-out infinite;
}
.companion-glow {
  position: absolute;
  bottom: 30px; left: 50%; transform: translateX(-50%);
  width: 180px; height: 14px;
  background: radial-gradient(ellipse at center, rgba(159,239,0,0.3), transparent 70%);
  filter: blur(3px);
}

.companion-card {
  flex-shrink: 0;
  padding: 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.companion-status {
  display: flex; align-items: center; gap: 8px;
}
.companion-status .pip {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand-dim);
}
.companion-status .pip.thinking {
  background: var(--brand);
  box-shadow: 0 0 6px var(--brand);
  animation: chat-pulse 0.9s infinite;
}
.companion-status .pip.welcome {
  background: var(--brand);
  box-shadow: 0 0 6px var(--brand);
}
.companion-status .pip.idle {
  background: var(--ink-3);
}
.companion-status .state-label {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.14em; color: var(--brand);
}
.companion-caption {
  margin: 0;
  font-size: 13px;
  color: var(--ink-1);
  line-height: 1.4;
}
.companion-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}
.companion-stats > div { display: flex; flex-direction: column; gap: 2px; }
.companion-stats .l {
  font-family: var(--font-mono); font-size: 9px;
  letter-spacing: 0.1em; color: var(--ink-3);
}
.companion-stats .v {
  font-family: var(--font-mono); font-size: 14px;
  font-weight: 600; color: var(--ink-0);
}
