:root {
  --bg: #060b17;
  --panel: rgba(10, 17, 34, 0.66);
  --panel-strong: rgba(8, 14, 28, 0.92);
  --text: #e6edf8;
  --muted: #9fb0cb;
  --brand: #22d3ee;
  --brand-strong: #0891b2;
  --border: rgba(122, 158, 220, 0.28);
  --ok: #10b981;
  --warn: #f59e0b;
  --error: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "IBM Plex Sans", sans-serif;
  background:
    radial-gradient(circle at 12% 16%, #103d69 0%, transparent 42%),
    radial-gradient(circle at 88% 14%, #0e3d59 0%, transparent 44%),
    linear-gradient(130deg, #020617 0%, #091127 50%, #0f172a 100%);
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  z-index: -1;
  filter: blur(50px);
  opacity: 0.25;
  border-radius: 9999px;
}

.bg-orb-a {
  width: 240px;
  height: 240px;
  background: #0ea5e9;
  top: 10vh;
  left: 5vw;
}

.bg-orb-b {
  width: 320px;
  height: 320px;
  background: #14b8a6;
  right: 6vw;
  bottom: 8vh;
}

.app-shell {
  width: min(1180px, 94vw);
  margin: 3vh auto;
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 14px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow:
    0 14px 48px rgba(2, 6, 23, 0.45),
    inset 0 1px 0 rgba(180, 213, 255, 0.07);
}

.sidebar {
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 78vh;
}

.sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.chat-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.chat-item {
  width: 100%;
  text-align: left;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(2, 6, 23, 0.44);
  color: var(--text);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.chat-item:hover {
  border-color: rgba(6, 182, 212, 0.65);
  transform: translateY(-1px);
}

.chat-item.active {
  border-color: rgba(6, 182, 212, 0.95);
  background: rgba(3, 20, 36, 0.8);
}

.chat-title {
  display: block;
  font-weight: 600;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-meta {
  font-size: 0.78rem;
  color: var(--muted);
}

.chat-actions {
  margin-top: 8px;
  display: flex;
  gap: 10px;
}

.action {
  font-size: 0.75rem;
  color: #67e8f9;
}

.action.delete {
  color: #fca5a5;
}

.chat-main {
  padding: 22px;
  display: flex;
  flex-direction: column;
  min-height: 78vh;
}

.header h1 {
  margin: 0 0 8px;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  letter-spacing: 0.02em;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.model-pill {
  display: inline-block;
  margin: 0;
  padding: 8px 12px;
  font-size: 0.88rem;
  color: #d1fae5;
  border: 1px solid rgba(16, 185, 129, 0.5);
  border-radius: 9999px;
  background: rgba(16, 185, 129, 0.15);
}

.response-wrap {
  margin-top: 16px;
  flex: 1;
  min-height: 0;
}

.response-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.response-head h2 {
  margin: 0 0 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.timer {
  color: var(--warn);
  font-size: 0.85rem;
}

.hidden {
  visibility: hidden;
}

.conversation {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(4, 10, 24, 0.76);
  padding: 14px;
  height: min(52vh, 620px);
  overflow-y: auto;
}

.empty-state {
  color: var(--muted);
  font-size: 0.94rem;
}

.msg {
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(16, 26, 51, 0.7);
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 10px;
}

.msg.user {
  border-color: rgba(34, 211, 238, 0.52);
  background: linear-gradient(145deg, rgba(6, 56, 79, 0.64), rgba(7, 42, 70, 0.54));
}

.msg.assistant {
  border-color: rgba(148, 163, 184, 0.35);
}

.msg-role {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.msg-body {
  white-space: pre-wrap;
  line-height: 1.45;
}

.msg-body a {
  color: #67e8f9;
  text-decoration: underline;
  text-underline-offset: 2px;
}

#chat-form {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(122, 158, 220, 0.18);
  border-radius: 14px;
  background: rgba(6, 13, 28, 0.54);
}

.composer-tools {
  display: flex;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.field {
  min-width: 170px;
}

.field-grow {
  flex: 1;
}

.hidden-input {
  display: none;
}

.label-inline {
  display: block;
  margin: 0 0 6px;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

select,
input[type="email"] {
  width: 100%;
  border: 1px solid rgba(122, 158, 220, 0.34);
  border-radius: 10px;
  background: rgba(11, 22, 43, 0.78);
  color: var(--text);
  padding: 9px 10px;
  font-family: inherit;
  font-size: 0.92rem;
}

select:focus,
input[type="email"]:focus {
  outline: none;
  border-color: var(--brand);
}

.label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 500;
}

textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(12, 21, 42, 0.72);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 180ms ease;
}

textarea:focus {
  outline: none;
  border-color: var(--brand);
}

.captcha-wrap {
  margin-top: 12px;
}

.turnstile-slot {
  min-height: 70px;
}

.captcha-note {
  margin: 8px 0 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.captcha-note.ready {
  color: var(--ok);
}

.captcha-note.error {
  color: var(--error);
}

.row {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

button {
  border: none;
  border-radius: 11px;
  padding: 10px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  color: #06202a;
  background: linear-gradient(135deg, #14b8a6 0%, #67e8f9 100%);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(6, 182, 212, 0.3);
}

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

.btn-subtle {
  background: rgba(34, 211, 238, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.35);
  color: #b7f7ff;
  box-shadow: none;
  padding: 8px 12px;
}

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

.status.waiting {
  color: var(--warn);
}

.status.success {
  color: var(--ok);
}

.status.error {
  color: var(--error);
}

@media (max-width: 930px) {
  .app-shell {
    grid-template-columns: 1fr;
    margin: 3vh auto;
  }

  .sidebar,
  .chat-main {
    min-height: auto;
  }

  .chat-list {
    max-height: 220px;
  }

  .composer-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .field {
    min-width: 0;
  }
}
