:root {
  --bg: #05060f;
  --bg2: #0a0e18;
  --panel: #0c1220cc;
  --line: #1a2440;
  --text: #e8eefc;
  --muted: #8b9bb8;
  --a: #7cf0ff;
  --b: #c77cff;
  --ok: #5dffb0;
  --bad: #ff6b8a;
  --radius: 18px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  color: var(--text);
  background:
    radial-gradient(900px 500px at 15% -10%, #1a1240 0%, transparent 55%),
    radial-gradient(800px 480px at 100% 0%, #0a2840 0%, transparent 50%),
    radial-gradient(600px 400px at 50% 120%, #0d1f2a 0%, transparent 45%),
    var(--bg);
}
a { color: var(--a); text-decoration: none; }
button, input, textarea { font: inherit; }

.app {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
}

/* top bar like modern AI apps */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: #070b14d9;
  backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 0.7rem; }
.brand img { width: 36px; height: 36px; border-radius: 10px; }
.brand h1 {
  margin: 0; font-size: 1.05rem; letter-spacing: 0.28em; font-weight: 650;
  background: linear-gradient(90deg, var(--a), var(--b));
  -webkit-background-clip: text; color: transparent;
}
.brand small { display: block; color: var(--muted); letter-spacing: 0.04em; font-size: 0.72rem; margin-top: 0.1rem; }
.top-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; align-items: center; }
.pill {
  border: 1px solid var(--line); background: transparent; color: var(--text);
  border-radius: 999px; padding: 0.4rem 0.85rem; cursor: pointer;
}
.pill.primary {
  border: 0; color: #041018; font-weight: 700;
  background: linear-gradient(120deg, #5b8cff, #b56cff);
}
.userchip { color: var(--muted); font-size: 0.85rem; }

/* layout */
.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 64px);
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .side.open { display: block; position: fixed; inset: 64px 0 auto 0; z-index: 15; max-height: 50vh; overflow: auto; }
}

.side {
  border-right: 1px solid var(--line);
  background: #070b14aa;
  padding: 1rem;
}
.side h3 {
  margin: 0 0 0.6rem; font-size: 0.72rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
}
.side .item {
  display: block; width: 100%; text-align: left;
  border: 1px solid transparent; background: transparent; color: var(--text);
  border-radius: 12px; padding: 0.65rem 0.75rem; cursor: pointer; margin-bottom: 0.35rem;
}
.side .item:hover, .side .item.active { background: #121a2c; border-color: var(--line); }
.side .meta { color: var(--muted); font-size: 0.8rem; line-height: 1.45; margin-top: 1rem; }

.main {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: calc(100vh - 64px);
}

.hero-empty {
  max-width: 720px; margin: 8vh auto 0; padding: 1rem; text-align: center;
}
.hero-empty h2 {
  margin: 0 0 0.6rem; font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 600;
}
.hero-empty p { color: var(--muted); line-height: 1.55; }
.suggest {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-top: 1.4rem; text-align: left;
}
@media (max-width: 640px) { .suggest { grid-template-columns: 1fr; } }
.suggest button {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 14px; padding: 0.85rem 1rem; cursor: pointer; text-align: left;
}
.suggest button:hover { border-color: #2a3a66; }

#log {
  overflow: auto; padding: 1.1rem 1.1rem 0.5rem;
  display: flex; flex-direction: column; gap: 0.9rem;
  max-width: 880px; width: 100%; margin: 0 auto;
}
.msg {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.9rem 1rem; background: var(--panel); line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}
.msg.user { align-self: flex-end; background: #0d1528; border-color: #243356; max-width: 85%; }
.msg.bot { align-self: flex-start; max-width: 95%; }
.msg .role {
  font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 0.35rem;
}
.msg.user .role { color: var(--a); }
.msg.bot .role { color: var(--b); }
.msg pre {
  overflow: auto; background: #050814; border-radius: 12px; padding: 0.75rem;
  border: 1px solid var(--line); font-size: 0.82rem;
}
.msg a.site {
  display: inline-block; margin-top: 0.55rem; padding: 0.35rem 0.7rem;
  border-radius: 999px; background: #122018; color: var(--ok); border: 1px solid #1d5c40;
}

.composer-wrap {
  border-top: 1px solid var(--line);
  background: #070b14e6;
  padding: 0.85rem 1rem 1.1rem;
}
.composer {
  max-width: 880px; margin: 0 auto;
  display: grid; gap: 0.55rem;
  border: 1px solid var(--line); border-radius: 18px; background: #0a101c;
  padding: 0.65rem 0.75rem;
}
.composer:focus-within { border-color: #3a4d80; box-shadow: 0 0 0 3px #7cf0ff18; }
#inp {
  width: 100%; min-height: 56px; max-height: 180px; resize: vertical;
  border: 0; outline: none; background: transparent; color: var(--text);
}
.composer-row { display: flex; justify-content: space-between; gap: 0.5rem; align-items: center; }
.hint { color: var(--muted); font-size: 0.75rem; }
#send {
  border: 0; border-radius: 999px; padding: 0.55rem 1.1rem; cursor: pointer; font-weight: 700;
  background: linear-gradient(120deg, #5b8cff, #b56cff); color: #041018;
}
#send:disabled { opacity: 0.5; cursor: wait; }

/* auth modal */
.modal-bg {
  position: fixed; inset: 0; background: #000a; display: none; place-items: center; z-index: 50; padding: 1rem;
}
.modal-bg.show { display: grid; }
.modal {
  width: min(420px, 100%);
  background: #0b1220; border: 1px solid var(--line); border-radius: 18px; padding: 1.2rem;
  box-shadow: 0 20px 80px #000a;
}
.modal h2 { margin: 0 0 0.35rem; }
.modal p { color: var(--muted); margin: 0 0 1rem; font-size: 0.9rem; }
.modal label { display: block; font-size: 0.78rem; color: var(--muted); margin: 0.55rem 0 0.25rem; }
.modal input {
  width: 100%; border-radius: 12px; border: 1px solid var(--line);
  background: #070b14; color: var(--text); padding: 0.65rem 0.75rem;
}
.modal .err { color: var(--bad); font-size: 0.85rem; min-height: 1.2em; margin-top: 0.5rem; }
.modal .actions { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }

.footer-note {
  text-align: center; color: var(--muted); font-size: 0.72rem; padding: 0.35rem;
}
