:root {
  --bg: #0d1320;
  --panel: #161f33;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f2f6ff;
  --muted: #99a7c0;
  --accent: #69e6d3;
  --accent-ink: #063731;
  --danger: #f26d66;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(180deg, #101a2b 0%, #0b111b 100%);
  color: var(--text);
  font-family: "Manrope", sans-serif;
}

.app {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 14px;
  display: grid;
  gap: 10px;
  min-height: 100vh;
  grid-template-rows: auto auto auto 1fr auto auto auto;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
}

.new-chat-btn {
  border: 0;
  border-radius: 10px;
  padding: 9px 12px;
  font-weight: 700;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}

.session-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.chat-list {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding-bottom: 2px;
}

.chat-item {
  min-width: 160px;
  max-width: 220px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.chat-item.active {
  border-color: color-mix(in srgb, var(--accent), white 15%);
  background: rgba(105, 230, 211, 0.14);
}

.chat-open {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
  line-height: 1.2;
}

.chat-delete {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: rgba(242, 109, 102, 0.22);
  color: #ffd9d6;
  cursor: pointer;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  align-self: center;
}

.empty-state h1 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.4rem, 6vw, 2rem);
  color: var(--text);
}

.empty-state p { margin: 8px 0 0; }

.chat-feed {
  display: none;
  overflow: auto;
  max-height: 52vh;
  padding-right: 4px;
}

.chat-feed.active {
  display: grid;
  gap: 10px;
}

.msg {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg.user {
  justify-self: end;
  background: linear-gradient(120deg, #67e5d3, #79eccf);
  color: #10342e;
  max-width: 90%;
}

.msg.assistant {
  justify-self: start;
  background: var(--panel);
  max-width: 95%;
}

.msg.system {
  justify-self: center;
  color: var(--muted);
  background: rgba(255,255,255,0.06);
}

.msg img {
  display: block;
  width: 100%;
  max-width: 280px;
  margin-top: 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.icon-btn,
.send-btn {
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font-family: "Space Grotesk", sans-serif;
}

.icon-btn {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.12);
  color: var(--text);
}

.send-btn {
  padding: 0 14px;
  font-weight: 700;
  background: var(--accent);
  color: var(--accent-ink);
}

.send-btn[disabled], .icon-btn[disabled] {
  opacity: 0.7;
  cursor: not-allowed;
}

.prompt-input {
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  min-width: 0;
  font-size: 1rem;
}

.prompt-input::placeholder { color: #c6d0e380; }

.image-preview-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.image-preview-wrap.hidden { display: none; }

.image-preview-wrap img {
  max-height: 92px;
  border-radius: 9px;
  border: 1px solid var(--line);
}

.image-preview-wrap button {
  border: 0;
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--danger);
  color: white;
}

.status-line {
  margin: 0;
  min-height: 1.2em;
  color: var(--muted);
  font-size: 0.92rem;
}

@media (min-width: 900px) {
  .app {
    padding: 20px 24px;
  }

  .chat-feed {
    max-height: 58vh;
  }
}