:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #08090b;
  --panel: #101216;
  --panel-2: #151821;
  --border: #252a35;
  --border-strong: #383f4f;
  --text: #f4f7fb;
  --muted: #9098a8;
  --muted-2: #646d7d;
  --accent: #f1f5f9;
  --danger: #ff6b6b;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 25% 0%, rgba(70, 84, 109, 0.2), transparent 32rem),
    linear-gradient(145deg, #08090b 0%, #10131a 48%, #090a0d 100%);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: var(--accent);
  color: #0a0c10;
  font-weight: 650;
  min-height: 42px;
  padding: 0 16px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  outline: none;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.gate {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 24px;
}

.gate-panel {
  display: grid;
  gap: 18px;
  width: min(420px, 100%);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(16, 18, 22, 0.88);
  box-shadow: var(--shadow);
  padding: 28px;
}

.gate-panel h1,
.brand h1 {
  margin: 0;
  font-size: 23px;
  letter-spacing: 0;
}

.gate-panel input {
  height: 46px;
  padding: 0 14px;
}

.gate-error {
  min-height: 20px;
  margin: -4px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.app {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  height: 100%;
}

.sidebar {
  display: flex;
  min-width: 0;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: rgba(10, 12, 16, 0.7);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 18px 16px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  min-height: 38px;
  place-items: center;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.conversation-list {
  display: grid;
  align-content: start;
  gap: 6px;
  overflow: auto;
  padding: 0 12px 16px;
}

.conversation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: 8px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 8px 8px 12px;
  background: transparent;
}

.conversation.active {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.055);
}

.conversation-title {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-meta {
  color: var(--muted-2);
  font-size: 12px;
}

.delete-chat {
  display: grid;
  width: 28px;
  min-height: 28px;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted-2);
  padding: 0;
}

.delete-chat:hover {
  color: var(--danger);
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  height: 100%;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 14px;
  align-items: end;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 14, 18, 0.78);
  padding: 16px 20px;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.field select {
  height: 42px;
  padding: 0 12px;
}

.system-field textarea {
  min-height: 42px;
  max-height: 140px;
  resize: vertical;
  padding: 10px 12px;
}

.messages {
  display: grid;
  align-content: start;
  gap: 18px;
  overflow: auto;
  padding: 26px clamp(18px, 4vw, 56px);
}

.empty {
  display: grid;
  min-height: 100%;
  place-items: center;
  color: var(--muted-2);
  text-align: center;
}

.message {
  display: grid;
  gap: 8px;
  max-width: 920px;
}

.message.user {
  justify-self: end;
  width: min(760px, 92%);
}

.message.assistant {
  justify-self: start;
  width: min(920px, 100%);
}

.role {
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.bubble {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  padding: 15px 16px;
}

.user .bubble {
  background: rgba(241, 245, 249, 0.92);
  color: #090b10;
}

.markdown {
  line-height: 1.62;
  overflow-wrap: anywhere;
}

.markdown > :first-child {
  margin-top: 0;
}

.markdown > :last-child {
  margin-bottom: 0;
}

.markdown pre {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0b0d12;
  padding: 14px;
}

.markdown code {
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.15em 0.35em;
}

.markdown pre code {
  background: transparent;
  padding: 0;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  border-top: 1px solid var(--border);
  background: rgba(12, 14, 18, 0.86);
  padding: 16px 20px 20px;
}

.composer textarea {
  max-height: 180px;
  min-height: 48px;
  resize: none;
  padding: 13px 14px;
  line-height: 1.35;
}

.composer-actions {
  display: flex;
  gap: 10px;
}

.secondary {
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
}

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

  .sidebar {
    max-height: 190px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .composer-actions {
    justify-content: flex-end;
  }
}
