:root {
  --bg0: #020806;
  --bg1: #040c08;
  --bg2: #07120c;
  --g1: #5eff9f;
  --g2: #00ff88;
  --g3: #00cc66;
  --t0: #e8fff2;
  --t1: #b8e6c8;
  --t2: #7aa890;
  --line: rgba(0, 204, 102, 0.16);
  --font: "Space Grotesk", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg0); color: var(--t0); font-family: var(--font); }
body {
  background:
    radial-gradient(1000px 500px at 80% -10%, rgba(0, 204, 102, 0.14), transparent 55%),
    radial-gradient(800px 400px at -10% 80%, rgba(0, 255, 136, 0.06), transparent 50%),
    linear-gradient(180deg, #030a07, #020806);
  min-height: 100vh;
}
.grid-bg {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(0, 204, 102, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 204, 102, 0.04) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at center, black 15%, transparent 75%);
}
.scan {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,.03) 3px);
  opacity: .35;
}
.top, .shell { position: relative; z-index: 2; }
.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 22px; border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px); background: rgba(2, 8, 6, 0.75);
}
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
.mark { width: 28px; height: 34px; }
.name { font-weight: 700; letter-spacing: .14em; font-size: .92rem; }
.accent { color: var(--g3); }
.pill {
  font-size: .65rem; letter-spacing: .12em; border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 8px; color: var(--g1); margin-left: 4px;
}
.sub { font-family: var(--mono); font-size: .62rem; color: var(--t2); letter-spacing: .14em; text-transform: uppercase; margin-top: 2px; }
.top-actions { display: flex; gap: 14px; align-items: center; }
.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--t1);
  border-radius: 999px; padding: 8px 14px; font: inherit; cursor: pointer; text-decoration: none; font-size: .85rem;
}
.status { font-family: var(--mono); font-size: .72rem; color: var(--t2); display: flex; align-items: center; gap: 8px; }
.status i { width: 8px; height: 8px; border-radius: 50%; background: #666; display: inline-block; }
.status.ok i { background: var(--g2); box-shadow: 0 0 10px var(--g2); }
.status.bad i { background: #ff6b6b; }

.shell {
  display: grid; grid-template-columns: 260px 1fr; gap: 0;
  max-width: 1200px; margin: 0 auto; min-height: calc(100vh - 74px);
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { border-right: none !important; border-bottom: 1px solid var(--line); }
}
.side {
  padding: 20px 16px; border-right: 1px solid var(--line);
  background: rgba(4, 12, 8, 0.55);
}
.side h2 { margin: 0 0 6px; font-size: 1rem; }
.hint, .legal { color: var(--t2); font-size: .82rem; line-height: 1.4; }
.tool {
  width: 100%; text-align: left; margin: 6px 0; padding: 11px 12px;
  border-radius: 10px; border: 1px solid var(--line); background: rgba(0, 204, 102, 0.06);
  color: var(--t0); font: inherit; cursor: pointer;
}
.tool:hover { border-color: var(--g3); }
.side-card {
  margin-top: 16px; padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(12, 30, 20, 0.5);
}
.label { font-family: var(--mono); font-size: .65rem; color: var(--t2); letter-spacing: .12em; text-transform: uppercase; }
.mono { font-family: var(--mono); font-size: .78rem; color: var(--g1); margin-top: 4px; }

.chat-wrap { display: flex; flex-direction: column; min-height: calc(100vh - 74px); }
.messages { flex: 1; overflow: auto; padding: 22px 18px 12px; display: flex; flex-direction: column; gap: 12px; }
.bubble {
  max-width: min(760px, 92%); padding: 12px 14px; border-radius: 14px;
  border: 1px solid var(--line); line-height: 1.5; white-space: pre-wrap; word-break: break-word;
  animation: rise .35s ease both;
}
.bubble.user { align-self: flex-end; background: rgba(0, 204, 102, 0.12); }
.bubble.assistant { align-self: flex-start; background: rgba(7, 18, 12, 0.85); }
.bubble .role { font-family: var(--mono); font-size: .65rem; color: var(--t2); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 6px; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.composer {
  border-top: 1px solid var(--line); padding: 14px 16px 18px;
  background: rgba(2, 8, 6, 0.85);
}
.composer textarea {
  width: 100%; resize: vertical; min-height: 56px; max-height: 180px;
  border-radius: 12px; border: 1px solid var(--line); background: #010504;
  color: var(--t0); font: inherit; padding: 12px 14px; outline: none;
}
.composer textarea:focus { border-color: var(--g3); box-shadow: 0 0 0 3px rgba(0, 204, 102, 0.12); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; }
.check { font-size: .82rem; color: var(--t2); display: flex; gap: 8px; align-items: center; }
.send {
  border: 1px solid rgba(0, 255, 136, 0.35); border-radius: 999px; padding: 10px 20px;
  background: linear-gradient(180deg, rgba(0, 204, 102, 0.28), rgba(0, 153, 77, 0.12));
  color: var(--t0); font: inherit; font-weight: 600; cursor: pointer;
}
.send:disabled { opacity: .45; cursor: not-allowed; }

.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55);
  display: grid; place-items: center; padding: 16px;
}
.modal.hidden { display: none; }
.modal-card {
  width: min(640px, 100%); background: #04100a; border: 1px solid var(--line);
  border-radius: 16px; padding: 16px;
}
.modal-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-h h3 { margin: 0; }
#toolInput {
  width: 100%; border-radius: 10px; border: 1px solid var(--line); background: #010504;
  color: var(--t0); padding: 10px; margin-bottom: 10px; font-family: var(--mono); font-size: .8rem;
}
.tool-out {
  margin-top: 12px; max-height: 240px; overflow: auto; background: #010504;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px; color: #8fd9ad; font-size: .75rem;
}
