:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #07111f;
  color: #edf6ff;
  --panel: rgba(11, 28, 47, 0.94);
  --line: rgba(148, 185, 219, 0.16);
  --accent: #43d6b5;
  --accent-dark: #072b29;
  --muted: #91a8bc;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 15% 0%, rgba(19, 114, 126, 0.28), transparent 34rem),
    linear-gradient(145deg, #07111f, #081726 52%, #06101c);
}
button, textarea, input { font: inherit; }
button { cursor: pointer; }

.shell {
  width: min(100%, 820px);
  min-height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: rgba(4, 13, 24, 0.5);
  border-inline: 1px solid var(--line);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.8rem;
  padding: max(0.9rem, env(safe-area-inset-top)) 1rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 31, 0.88);
  backdrop-filter: blur(16px);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 2.65rem;
  aspect-ratio: 1;
  border-radius: 0.85rem;
  color: #05201f;
  background: linear-gradient(135deg, #72efd2, #36bcae);
  font-weight: 900;
  box-shadow: 0 0 30px rgba(67, 214, 181, 0.2);
}
h1, h2, p { margin: 0; }
h1 { font-size: 1rem; letter-spacing: 0.01em; }
.topbar p { margin-top: 0.2rem; color: var(--muted); font-size: 0.76rem; }
.icon-button {
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 0.75rem;
  color: #dcecff;
  background: transparent;
  font-size: 1.2rem;
}
.icon-button:hover { background: rgba(255, 255, 255, 0.07); }

.messages {
  overflow-y: auto;
  padding: 1.2rem 1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.message { display: flex; }
.message.user { justify-content: flex-end; }
.bubble {
  max-width: min(82%, 610px);
  padding: 0.82rem 1rem;
  border-radius: 1.1rem 1.1rem 1.1rem 0.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  line-height: 1.48;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.user .bubble {
  color: #04211e;
  background: var(--accent);
  border-color: transparent;
  border-radius: 1.1rem 1.1rem 0.25rem 1.1rem;
}
.pending .bubble { color: var(--muted); }

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 0.7rem;
  padding: 0.8rem 1rem max(0.8rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(7, 17, 31, 0.92);
  backdrop-filter: blur(16px);
}
textarea {
  width: 100%;
  max-height: 9rem;
  resize: none;
  padding: 0.82rem 1rem;
  border: 1px solid rgba(148, 185, 219, 0.24);
  border-radius: 1.15rem;
  outline: none;
  color: #edf6ff;
  background: #0c1b2d;
}
textarea:focus { border-color: rgba(67, 214, 181, 0.75); }
.composer button {
  width: 2.9rem;
  height: 2.9rem;
  border: 0;
  border-radius: 50%;
  color: #04211e;
  background: var(--accent);
  font-size: 1.3rem;
  font-weight: 800;
}
.composer button:disabled { opacity: 0.45; cursor: wait; }

dialog {
  width: min(calc(100% - 2rem), 460px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  color: #edf6ff;
  background: #0a192a;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}
dialog::backdrop { background: rgba(0, 5, 10, 0.72); backdrop-filter: blur(4px); }
.settings-card { padding: 1.2rem; }
.dialog-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.2rem; }
.settings-card label { display: block; margin-bottom: 0.45rem; font-size: 0.86rem; }
.settings-card input {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  color: #edf6ff;
  background: #07111f;
}
.hint { margin-top: 0.45rem; color: var(--muted); font-size: 0.76rem; }
.dialog-actions { display: flex; justify-content: space-between; gap: 0.8rem; margin-top: 1.4rem; }
.dialog-actions button { padding: 0.72rem 1rem; border-radius: 0.75rem; }
.secondary { border: 1px solid var(--line); color: #edf6ff; background: transparent; }
.primary { border: 0; color: #04211e; background: var(--accent); font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (min-width: 821px) {
  body { padding: 1.2rem; }
  .shell { min-height: calc(100dvh - 2.4rem); max-height: calc(100dvh - 2.4rem); border-radius: 1.4rem; overflow: hidden; box-shadow: 0 30px 100px rgba(0,0,0,.35); }
}
