@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #212121;
  --sidebar: #171717;
  --surface: #2f2f2f;
  --surface-2: #262626;
  --line: #353535;
  --text: #ececec;
  --muted: #a6a6a6;
  --brand: #10a37f;
  --danger: #8f2d45;
  --mx: 50vw;
  --my: 45vh;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Inter", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  position: relative;
}

.ambient-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1200px 700px at 12% 8%, rgba(16, 163, 127, 0.13), transparent 55%),
    radial-gradient(1000px 700px at 88% 88%, rgba(47, 111, 236, 0.12), transparent 58%),
    linear-gradient(180deg, #1a1a1a 0%, #212121 100%);
}

.mouse-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(
    420px 320px at var(--mx) var(--my),
    rgba(47, 111, 236, 0.18),
    rgba(16, 163, 127, 0.12) 38%,
    rgba(33, 33, 33, 0) 72%
  );
  transition: background-position 0.08s linear;
}

.shell {
  height: 100dvh;
  display: grid;
  grid-template-columns: 290px 1fr;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.sidebar {
  border-left: 1px solid var(--line);
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.sidebar-head {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.logo-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 22px;
  font-weight: 700;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--brand);
}

.meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.actions {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.settings-wrap {
  margin-top: 10px;
  position: relative;
}

.settings-btn {
  width: 100%;
}

.settings-menu {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #1f1f1f;
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn {
  border: 1px solid #404040;
  background: #2a2a2a;
  color: var(--text);
  border-radius: 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px;
  cursor: pointer;
}

.btn.primary {
  border: 0;
  background: var(--brand);
  color: #041f18;
}

.btn.danger {
  border-color: #6f3344;
  color: #ffc8d5;
  background: #3d1f28;
}

.btn.full {
  width: 100%;
}

.list {
  flex: 1;
  min-height: 0;
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.chat-item {
  border: 1px solid #353535;
  background: #1f1f1f;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
}

.chat-item.active {
  border-color: #4a4a4a;
  background: #292929;
}

.chat-title {
  font-size: 14px;
  font-weight: 600;
}

.chat-date {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.main {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  position: relative;
  min-width: 0;
}

.topbar {
  height: 56px;
  border-bottom: 1px solid var(--line);
  background: #1f1f1f;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
}

.title {
  font-size: 20px;
  font-weight: 700;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-link {
  text-decoration: none;
  color: #d1d1d1;
  border: 1px solid #414141;
  background: #2a2a2a;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 12px 10px;
}

.empty-state {
  max-width: 860px;
  margin: 90px auto 0;
  text-align: center;
  direction: ltr;
  unicode-bidi: isolate;
  color: #f2f2f2;
  font-size: clamp(28px, 4vw, 46px);
  font-weight: 500;
  letter-spacing: 0.2px;
}

.wrap {
  max-width: 860px;
  margin: 0 auto;
}

.row {
  margin-bottom: 14px;
}

.bubble {
  border-radius: 18px;
  border: 1px solid transparent;
  padding: 14px 16px;
  line-height: 1.75;
  font-size: 18px;
  text-align: start;
  unicode-bidi: plaintext;
  word-break: break-word;
}

.bubble p {
  margin: 0 0 10px;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.bubble ul {
  margin: 0 0 10px;
  padding-inline-start: 18px;
}

.bubble li {
  margin: 0 0 6px;
}

.bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 1px 6px;
}

.row.user .bubble {
  margin-right: auto;
  max-width: 78%;
  background: #2f6fec;
  color: #fff;
}

.row.assistant .bubble {
  margin-left: auto;
  max-width: 78%;
  background: #2b2b2b;
  border-color: #3a3a3a;
  color: #f0f0f0;
}

.row.error .bubble {
  margin-left: auto;
  max-width: 78%;
  background: var(--danger);
  color: #fff;
}

.composer {
  position: sticky;
  inset-inline: 0;
  bottom: 0;
  z-index: 5;
  padding: 14px 12px 16px;
  background:
    linear-gradient(180deg, rgba(33, 33, 33, 0) 0%, rgba(33, 33, 33, 0.92) 36%, rgba(33, 33, 33, 1) 100%);
}

.composer-wrap {
  max-width: 860px;
  margin: 0 auto;
}

form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input {
  flex: 1;
  height: 52px;
  border-radius: 28px;
  border: 1px solid #3e3e3e;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  padding: 0 16px;
  outline: none;
}

.input.small {
  margin-top: 10px;
  height: 38px;
  border-radius: 20px;
  font-size: 12px;
  background: var(--surface-2);
}

.input:focus {
  border-color: #5a5a5a;
}

.chips {
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border: 1px solid #404040;
  background: #2a2a2a;
  color: #d8d8d8;
  border-radius: 999px;
  padding: 6px 10px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.mobile-only {
  display: none;
}

.mobile-overlay {
  display: none;
}

.auth-wrap {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 14px;
  z-index: 30;
}

.auth-card {
  width: min(420px, 95vw);
  border: 1px solid #3d3d3d;
  border-radius: 14px;
  background: #202020;
  padding: 16px;
}

.auth-title {
  margin: 0 0 10px;
  font-size: 24px;
  color: #fff;
}

.auth-row {
  margin-bottom: 8px;
}

.auth-row .input {
  width: 100%;
}

.auth-alt {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.auth-alt button {
  background: none;
  border: 0;
  color: #83b5ff;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.hide {
  display: none !important;
}

@media (max-width: 920px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(86vw, 360px);
    border-left: 1px solid var(--line);
    transform: translateX(102%);
    transition: transform 0.22s ease;
    z-index: 25;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.36);
    z-index: 20;
  }

  body.sidebar-open .mobile-overlay {
    display: block;
  }

  .mobile-only {
    display: inline-block;
  }

  .topbar {
    gap: 8px;
  }

  .top-actions {
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .site-link {
    max-width: 52vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .messages {
    padding: 10px 8px 140px;
  }

  .row.user .bubble,
  .row.assistant .bubble,
  .row.error .bubble {
    max-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mouse-glow {
    display: none;
  }
}
