@import url("https://fonts.googleapis.com/css2?family=Sora:wght@500;600;700;800&family=Space+Grotesk:wght@400;500;700&display=swap");

:root {
  --bg: #090b12;
  --bg-soft: #0f1320;
  --panel: rgba(15, 19, 32, 0.88);
  --panel-strong: rgba(18, 24, 39, 0.96);
  --panel-float: rgba(14, 18, 29, 0.84);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(70, 184, 255, 0.28);
  --text: #f4f7fb;
  --muted: #92a0ba;
  --muted-strong: #b3bfd4;
  --accent: #46b8ff;
  --accent-strong: #1f87ff;
  --accent-soft: rgba(70, 184, 255, 0.14);
  --emerald: #4be6c2;
  --danger: #ff7f8d;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
  --shadow-soft: 0 16px 40px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  color: var(--text);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(31, 135, 255, 0.24), transparent 26%),
    radial-gradient(circle at 82% 16%, rgba(75, 230, 194, 0.14), transparent 22%),
    linear-gradient(180deg, #0a0e17 0%, #070910 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 30px 30px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 92%);
}

.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;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  height: 100%;
  padding: 18px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(12, 16, 27, 0.94), rgba(9, 11, 18, 0.92));
  backdrop-filter: blur(22px);
  overflow: hidden;
}

.sidebar::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at top right, rgba(70, 184, 255, 0.09), transparent 30%),
    linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.01));
}

.sidebar > * {
  position: relative;
  z-index: 1;
}

.sidebar-head,
.sidebar-caption,
.sidebar-toolbar,
.composer-row,
.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-head {
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: inline-flex;
  width: 50px;
  height: 50px;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  border: 1px solid rgba(70, 184, 255, 0.22);
  background:
    linear-gradient(180deg, rgba(28, 35, 54, 0.96), rgba(12, 17, 28, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), var(--shadow-soft);
  flex: 0 0 auto;
}

.brand-mark.small {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  box-shadow: none;
}

.brand-mark.hero {
  width: 72px;
  height: 72px;
  border-radius: 22px;
}

.brand-mark svg {
  width: 72%;
  height: 72%;
}

.brand-mark rect {
  fill: none;
  stroke: var(--accent);
  stroke-width: 7;
}

.brand-mark path {
  fill: none;
  stroke: var(--emerald);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-mark circle {
  fill: var(--accent);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-copy.compact {
  gap: 2px;
}

.brand-site {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.brand-name {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
}

.sidebar-controls {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.sidebar-toolbar {
  gap: 10px;
}

.select-wrap {
  display: grid;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
}

.select-wrap span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.select-wrap select,
.composer textarea,
.button {
  font: inherit;
}

.select-wrap select,
.composer textarea {
  width: 100%;
  border: 1px solid var(--line);
  outline: none;
  color: var(--text);
  background: rgba(7, 10, 18, 0.7);
  border-radius: 16px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.select-wrap select:focus,
.composer textarea:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 4px rgba(70, 184, 255, 0.11);
}

.select-wrap select {
  height: 44px;
  padding: 0 14px;
}

.button {
  border: 0;
  cursor: pointer;
  border-radius: 16px;
  padding: 12px 16px;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease, color 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.button-primary {
  color: #03111d;
  background: linear-gradient(135deg, var(--accent), #78d7ff);
  box-shadow: 0 14px 36px rgba(31, 135, 255, 0.24);
}

.button-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #2ca5ff, #95e0ff);
}

.button-subtle {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.button-subtle:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
}

.button-block {
  width: 100%;
}

.sidebar-caption {
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.count-pill,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(70, 184, 255, 0.12);
  background: rgba(70, 184, 255, 0.08);
  color: #c4e8ff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.session-scroll {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
  margin-top: 14px;
}

.session-list {
  display: grid;
  gap: 10px;
}

.session-card {
  width: 100%;
  display: grid;
  gap: 8px;
  text-align: left;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  box-shadow: none;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.session-card:hover,
.session-card.active {
  transform: translateY(-1px);
  border-color: rgba(70, 184, 255, 0.24);
  background: rgba(70, 184, 255, 0.08);
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.16);
}

.session-card strong {
  font-size: 14px;
  line-height: 1.35;
}

.session-card-meta,
.session-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.session-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chat-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 100%;
  overflow: hidden;
  padding: 20px 24px 22px;
}

.chat-topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 72px;
  padding: 2px 0 16px;
  transition: opacity 260ms ease, transform 360ms ease, max-height 360ms ease, padding 360ms ease;
}

.chat-shell.is-empty .chat-topbar {
  max-height: 0;
  min-height: 0;
  padding: 0;
  opacity: 0;
  transform: translateY(-24px);
  pointer-events: none;
  overflow: hidden;
}

.chat-heading {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.session-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.chat-title {
  margin: 0;
  font-family: "Sora", "Space Grotesk", sans-serif;
  font-size: 24px;
  line-height: 1.08;
}

.chat-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.intro-panel {
  align-self: center;
  justify-self: center;
  width: min(100%, 820px);
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 14px;
  padding: 28px 0 36px;
  transition:
    opacity 320ms ease,
    transform 520ms cubic-bezier(0.22, 1, 0.36, 1),
    max-height 520ms cubic-bezier(0.22, 1, 0.36, 1),
    padding 520ms cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-shell.has-history .intro-panel {
  max-height: 0;
  opacity: 0;
  padding: 0;
  transform: translateY(-44px) scale(0.98);
  overflow: hidden;
  pointer-events: none;
}

.intro-label {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.intro-panel h1 {
  margin: 0;
  font-family: "Sora", "Space Grotesk", sans-serif;
  font-size: clamp(44px, 7vw, 80px);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.intro-copy {
  max-width: 42rem;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.composer {
  width: min(100%, 860px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(12, 16, 27, 0.94), rgba(9, 11, 18, 0.96));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.composer-intro {
  margin-top: 10px;
}

.composer-footer {
  align-self: end;
  width: 100%;
  max-width: none;
  margin-top: 16px;
  opacity: 0;
  transform: translateY(26px);
  max-height: 0;
  overflow: hidden;
  pointer-events: none;
  transition:
    opacity 260ms ease,
    transform 420ms cubic-bezier(0.22, 1, 0.36, 1),
    max-height 420ms cubic-bezier(0.22, 1, 0.36, 1),
    margin 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-shell.has-history .composer-footer {
  opacity: 1;
  transform: translateY(0);
  max-height: 176px;
  pointer-events: auto;
}

.composer-field {
  display: block;
  padding: 14px 14px 0;
}

.composer textarea {
  display: block;
  min-height: 30px;
  max-height: 140px;
  resize: none;
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 15px;
  line-height: 1.55;
}

.composer textarea::placeholder {
  color: #6f7c94;
}

.composer-row {
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 14px 14px;
}

.message-scroller {
  min-height: 0;
  overflow: auto;
  padding: 6px 6px 0 0;
  opacity: 0;
  transform: translateY(22px);
  pointer-events: none;
  transition: opacity 260ms ease, transform 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-shell.has-history .message-scroller {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.message-list {
  display: grid;
  gap: 16px;
  padding-bottom: 10px;
}

.message {
  display: flex;
  width: 100%;
}

.message--assistant,
.message--operator {
  justify-content: flex-start;
}

.message--user {
  justify-content: flex-end;
}

.message-card {
  width: min(100%, 860px);
  padding: 14px 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.16);
}

.message--user .message-card {
  max-width: min(78%, 720px);
  color: #07131f;
  background: linear-gradient(135deg, var(--accent), #7cd7ff);
  border-color: rgba(124, 215, 255, 0.28);
}

.message--operator .message-card {
  background: linear-gradient(135deg, rgba(75, 230, 194, 0.12), rgba(70, 184, 255, 0.06));
  border-color: rgba(75, 230, 194, 0.16);
}

.message--assistant.is-pending .message-card {
  border-style: dashed;
}

.message--assistant.is-error .message-card {
  border-color: rgba(255, 127, 141, 0.28);
  background: rgba(255, 127, 141, 0.08);
}

.message-meta {
  gap: 10px;
  margin-bottom: 8px;
}

.message-role {
  color: var(--muted-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.message--user .message-role,
.message--user .message-time {
  color: rgba(3, 17, 29, 0.75);
}

.message-time {
  color: var(--muted);
  font-size: 12px;
}

.message-text {
  line-height: 1.68;
  font-size: 15px;
  white-space: normal;
  word-break: break-word;
}

.typing-dots {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  vertical-align: middle;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted-strong);
  animation: typing-bounce 1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes typing-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }

  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.option-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 6px 0 2px;
  align-items: center;
}

.option-picker-label {
  width: 100%;
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.option-chip {
  border: 1px solid rgba(70, 184, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.option-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(70, 184, 255, 0.34);
  background: rgba(70, 184, 255, 0.08);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 20px;
  cursor: pointer;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.mobile-only {
  display: none;
}

.sidebar-scrim {
  display: none;
}

@media (max-width: 1100px) {
  .chat-shell {
    padding: 18px;
  }

  .intro-panel h1 {
    font-size: clamp(38px, 9vw, 68px);
  }

  .message--user .message-card {
    max-width: 88%;
  }
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .mobile-only {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 340px);
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 26px 80px rgba(0, 0, 0, 0.36);
  }

  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-scrim {
    position: fixed;
    inset: 0;
    display: block;
    background: rgba(4, 6, 10, 0.62);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
    z-index: 20;
  }

  .app-shell.sidebar-open .sidebar-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .chat-shell {
    padding: 16px 14px;
  }

  .brand-inline .brand-copy {
    display: none;
  }
}

@media (max-width: 680px) {
  .sidebar-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .composer,
  .message-card {
    border-radius: 18px;
  }

  .message--user .message-card {
    max-width: 100%;
  }
}
