:root {
  --bg: #0b0d11;
  --sidebar: #11141a;
  --panel: #161a22;
  --text: #eef2f7;
  --muted: #8b95a8;
  --line: #252b36;
  --accent: #6ea8ff;
  --accent-dim: #1b2c4a;
  --user: #1d2636;
  --good: #3dd68c;
  --radius: 18px;
  font-family: "Segoe UI", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
button, select, textarea { font: inherit; color: inherit; }

.shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100%;
}

aside {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px 8px;
}

.mark, .hero-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, #7eb3ff, #4c7dff 55%, #8b5cf6);
  color: #fff;
  font-size: 14px;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.brand small.up { color: var(--good); }

.new-chat {
  border: 1px solid var(--line);
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
}

.history {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history button {
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history button.active,
.history button:hover { background: #1a1f29; color: var(--text); }

.main {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
}

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}

.icon-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  cursor: pointer;
}

.model-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.model-wrap select {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
}

.grow { flex: 1; }

#thread {
  overflow: auto;
  padding: 28px 20px 12px;
}

.empty {
  max-width: 640px;
  margin: 12vh auto 0;
  text-align: center;
}

.hero-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  font-size: 20px;
}

.empty h1 { margin: 0 0 8px; font-weight: 600; letter-spacing: -0.03em; }
.empty p { color: var(--muted); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 22px;
}

.chips button {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--muted);
}

.row {
  display: flex;
  gap: 12px;
  max-width: 820px;
  margin: 0 auto 22px;
  align-items: flex-start;
}

.avatar {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 12px;
  background: #2a3140;
}

.row.user .avatar { background: var(--accent-dim); color: var(--accent); }
.row.assistant .avatar {
  background: linear-gradient(145deg, #7eb3ff, #4c7dff);
  color: #fff;
}

.bubble {
  flex: 1;
  min-width: 0;
  line-height: 1.65;
}

.bubble .who {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.bubble .body { white-space: pre-wrap; word-break: break-word; }
.bubble .body code {
  background: #0f131a;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.92em;
}
.bubble .body pre {
  background: #0f131a;
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 12px;
  overflow: auto;
}

.row.user .bubble {
  background: var(--user);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
}

#composer { padding: 8px 20px 22px; }

.box {
  max-width: 820px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
}

textarea {
  width: 100%;
  background: transparent;
  border: 0;
  resize: none;
  outline: none;
  max-height: 180px;
  line-height: 1.5;
  padding: 6px 4px;
}

.box-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.hint { color: var(--muted); font-size: 12px; }

#send {
  background: var(--accent);
  color: #0b0d11;
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
}

#send:disabled { opacity: 0.45; cursor: default; }

#scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  aside {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    z-index: 4;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  aside.open { transform: none; }
  .icon-btn { display: grid; place-items: center; }
  .hint { display: none; }
}
