:root {
  --bg: #0b1220;
  --bg-2: #111a2d;
  --panel: rgba(17, 24, 39, 0.84);
  --surface: rgba(20, 28, 47, 0.92);
  --surface-2: rgba(255, 255, 255, 0.04);
  --line: rgba(148, 163, 184, 0.16);
  --text: #edf2ff;
  --muted: #a7b2c9;
  --accent: #6ecbff;
  --accent-2: #8ff0b0;
  --danger: #ff98a7;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(110, 203, 255, 0.09), transparent 26%),
    linear-gradient(180deg, #0b1220 0%, #080d18 100%);
  color: var(--text);
  font-family: "Manrope", sans-serif;
}

body {
  padding: 12px;
}

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

code,
pre,
h1,
h2,
h3,
strong {
  font-family: "Space Grotesk", sans-serif;
}

.app {
  width: min(1320px, 100%);
  margin: 0 auto;
}

.topbar,
.surface,
.composer-shell,
.settings-drawer {
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(15, 22, 37, 0.82);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), #7f8cff);
  color: #07111d;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
}

.topbar-actions,
.composer-actions,
.mode-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.main-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
}

.main-shell.inspector-open {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.thread-shell {
  min-height: calc(100vh - 250px);
  border-radius: 30px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 18px;
  box-shadow: var(--shadow);
}

.thread {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.thread-empty {
  padding: 46px 22px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  text-align: center;
  line-height: 1.65;
}

.thread-row {
  display: flex;
}

.thread-row.user {
  justify-content: flex-end;
}

.thread-row.assistant,
.thread-row.system,
.thread-row.error {
  justify-content: flex-start;
}

.bubble {
  width: min(880px, 100%);
  border-radius: 26px;
  padding: 16px 18px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.thread-row.user .bubble {
  width: min(760px, 100%);
  background: linear-gradient(135deg, rgba(110, 203, 255, 0.2), rgba(93, 135, 255, 0.18));
}

.thread-row.assistant .bubble,
.thread-row.system .bubble {
  background: rgba(255, 255, 255, 0.05);
}

.thread-row.error .bubble {
  background: rgba(255, 152, 167, 0.16);
}

.bubble-role {
  display: block;
  margin-bottom: 8px;
  color: var(--accent-2);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.video-card {
  display: grid;
  gap: 14px;
}

.video-card video {
  width: 100%;
  border-radius: 18px;
  background: #03060d;
}

.video-meta {
  color: var(--muted);
}

.inspector {
  display: grid;
  gap: 16px;
}

.surface {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 24px;
  padding: 16px;
  background: var(--surface);
}

.section-head,
.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.section-kicker,
.meta-item span {
  color: var(--muted);
  font-size: 0.82rem;
}

.section-kicker {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.meta-list,
.model-list {
  display: grid;
  gap: 12px;
}

.meta-item,
.model-pill {
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--surface-2);
  padding: 12px;
}

.meta-item code {
  display: block;
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-pill .topline {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 6px;
}

.tag,
.status-badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 6px 10px;
}

.tag {
  background: rgba(143, 240, 176, 0.12);
  color: var(--accent-2);
  font-size: 0.76rem;
}

.status-badge {
  background: rgba(110, 203, 255, 0.12);
  color: var(--accent);
  font-size: 0.82rem;
}

.status-badge.subtle {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.json-preview {
  margin: 0;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.composer-shell {
  position: sticky;
  bottom: 0;
  z-index: 10;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(13, 18, 31, 0.9);
  box-shadow: var(--shadow);
}

.advanced-block {
  margin-top: 12px;
}

.advanced-panels {
  margin-top: 12px;
}

.advanced-panel {
  display: none;
  padding: 14px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.advanced-panel.active {
  display: block;
}

.composer-box {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.assistant-strip {
  display: flex;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.field-grow {
  flex: 1;
}

.label-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.help-icon {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 0.75rem;
  cursor: help;
}

.assist-button {
  align-self: stretch;
}

.grid-two,
.grid-three {
  display: grid;
  gap: 12px;
}

.grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inline-toggle {
  justify-content: center;
}

.inline-toggle input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

input,
textarea,
select {
  width: 100%;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(8, 13, 24, 0.82);
  color: var(--text);
  padding: 14px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(110, 203, 255, 0.25);
  border-color: rgba(110, 203, 255, 0.4);
}

.mode-pill,
.primary-button,
.secondary-button,
.ghost-button {
  border: 0;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease;
}

.mode-pill,
.primary-button,
.secondary-button,
.ghost-button {
  padding: 11px 16px;
  border-radius: 999px;
}

.mode-pill {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.mode-pill.active {
  background: linear-gradient(135deg, var(--accent), #89a7ff);
  color: #08121d;
  font-weight: 700;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), #89a7ff);
  color: #08121d;
  font-weight: 800;
}

.secondary-button,
.ghost-button {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.ghost-button.small,
.wide {
  width: auto;
}

.wide {
  width: 100%;
}

.mode-pill:hover,
.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 17, 0.64);
}

.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(460px, 100%);
  height: 100vh;
  padding: 18px;
  background: rgba(11, 17, 29, 0.97);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: auto;
}

.help-popover {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(2, 8, 17, 0.36);
  z-index: 45;
}

.help-popover-card {
  width: min(560px, 100%);
  padding: 16px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(10, 15, 26, 0.98);
  box-shadow: var(--shadow);
}

.help-popover-card p {
  margin: 0;
  color: var(--text);
  line-height: 1.6;
}

.drawer-body {
  display: grid;
  gap: 14px;
}

.hidden {
  display: none;
}

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

@media (max-width: 760px) {
  body {
    padding: 8px;
  }

  .topbar,
  .thread-shell,
  .composer-shell,
  .surface,
  .settings-drawer {
    border-radius: 20px;
  }

  .topbar,
  .section-head,
  .drawer-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .grid-two,
  .grid-three {
    grid-template-columns: 1fr;
  }

  .assistant-strip {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions,
  .composer-actions,
  .mode-row {
    width: 100%;
  }

  .ghost-button,
  .secondary-button,
  .primary-button {
    width: 100%;
  }

  .bubble,
  .thread-row.user .bubble {
    width: 100%;
  }
}
