:root {
  --bg: #070604;
  --panel: #0d0a08;
  --panel-2: #15100c;
  --panel-3: #1e130c;
  --text: #fff8ef;
  --muted: #b7aca3;
  --dim: #776b62;
  --line: #2d211b;
  --line-2: #51402e;
  --cyan: #44e9ff;
  --green: #bdff63;
  --amber: #ffd166;
  --orange: #ff4d00;
  --orange-2: #ff8a00;
  --red: #ff7a7a;
  --sans: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
}

body {
  overflow: hidden;
}

body.modal-open {
  overflow: hidden;
}

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

button,
a,
select {
  color: inherit;
}

button {
  cursor: pointer;
}

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

a {
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.chat-app {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  width: 100vw;
  height: 100dvh;
  background:
    linear-gradient(to right, rgba(255, 77, 0, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(68, 233, 255, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 42px 42px;
}

.chat-sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 77, 0, 0.08), transparent 28%),
    rgba(13, 10, 8, 0.98);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 70px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 77, 0, 0.55);
  background:
    radial-gradient(circle at 30% 20%, rgba(68, 233, 255, 0.22), transparent 54%),
    radial-gradient(circle at 70% 78%, rgba(255, 77, 0, 0.22), transparent 62%),
    rgba(255, 255, 255, 0.025);
}

.brand-mark img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  filter:
    invert(1)
    brightness(1.18)
    contrast(1.08)
    drop-shadow(0 0 8px rgba(68, 233, 255, 0.34));
}

.brand-wordmark {
  display: grid;
  align-items: center;
  width: 116px;
  height: 30px;
}

.brand-wordmark img {
  width: 100%;
  height: auto;
  filter:
    invert(1)
    brightness(1.2)
    contrast(1.12);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
}

.icon-btn:hover {
  border-color: var(--orange);
  color: var(--text);
}

.sidebar-close {
  display: none;
}

.sidebar-actions {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.side-action,
.signin-btn,
.ghost-btn,
.mode-btn,
.send-btn,
.vote-bar button,
.modal-primary,
.modal-secondary {
  min-height: 38px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 600;
}

.side-action {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  text-align: left;
}

.side-action span {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 11px;
}

.side-action.primary,
.send-btn,
.modal-primary {
  border-color: var(--orange);
  background: linear-gradient(135deg, var(--orange), var(--orange-2));
  color: #130701;
}

.side-action:hover,
.signin-btn:hover,
.ghost-btn:hover,
.mode-btn:hover,
.vote-bar button:hover,
.modal-secondary:hover {
  border-color: var(--orange);
  color: var(--text);
}

.history-tools {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.search-box {
  display: grid;
  gap: 6px;
}

.search-box span,
.eyebrow,
.quota-label,
.history-group h2,
.user-prompt span,
.lane-card header span,
.metric-row,
.lane-card footer,
.hint-row,
.model-panel-head,
.model-check small,
.select-wrap span,
.top-status {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.search-box input,
.select-wrap select,
.composer textarea {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: #090706;
  color: var(--text);
}

.search-box input {
  height: 38px;
  padding: 0 10px;
}

.history-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
}

.history-group {
  margin-bottom: 18px;
}

.history-group h2 {
  margin: 0 0 8px;
}

.history-item {
  display: grid;
  width: 100%;
  gap: 2px;
  margin-bottom: 6px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  text-align: left;
}

.history-item:hover,
.history-item.active {
  border-color: var(--line-2);
  background: rgba(255, 77, 0, 0.08);
}

.history-item span {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item small,
.history-empty {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
}

.history-empty {
  padding: 16px 10px;
}

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--line);
}

.quota-card {
  display: grid;
  gap: 2px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 77, 0, 0.12), rgba(68, 233, 255, 0.05)),
    var(--panel-2);
}

.quota-card strong {
  color: var(--text);
}

.quota-card span:last-child {
  color: var(--muted);
  font-size: 12px;
}

.signin-btn {
  display: grid;
  place-items: center;
  margin-top: 10px;
}

.chat-main {
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
}

.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 6, 4, 0.94);
}

.mobile-menu {
  display: none;
  margin-left: 12px;
}

.mode-switch {
  display: flex;
  min-width: 0;
  height: 100%;
  overflow-x: auto;
}

.mode-btn {
  min-width: max-content;
  min-height: 58px;
  padding: 0 18px;
  border-width: 0 1px 0 0;
  border-radius: 0;
  background: transparent;
}

.mode-btn.active {
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 77, 0, 0.16), transparent),
    var(--panel-2);
}

.top-status {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  white-space: nowrap;
}

.top-status span {
  color: var(--green);
}

.top-status a {
  color: var(--muted);
}

.chat-workspace {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 77, 0, 0.08), transparent 24%),
    radial-gradient(circle at 68% 30%, rgba(68, 233, 255, 0.055), transparent 26%),
    #090807;
}

.landing {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 100%;
  padding: 42px 28px;
  text-align: center;
}

.landing[hidden] {
  display: none;
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--cyan);
}

.landing h1 {
  max-width: 860px;
  margin: 0;
  font-size: clamp(38px, 5vw, 72px);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 0.98;
}

.landing-copy {
  max-width: 680px;
  margin: 20px 0 26px;
  color: var(--muted);
  font-size: 16px;
}

.prompt-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
  width: min(760px, 100%);
}

.prompt-chip {
  display: grid;
  gap: 6px;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 10, 8, 0.82);
  color: var(--muted);
  text-align: left;
}

.prompt-chip:hover {
  border-color: var(--orange);
  color: var(--text);
}

.prompt-chip span {
  color: var(--orange-2);
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
}

.run-list {
  display: grid;
  gap: 18px;
  height: 100%;
  overflow-y: auto;
  padding: 24px;
}

.run-list:empty {
  display: none;
}

.run-card {
  display: grid;
  gap: 16px;
}

.user-prompt {
  justify-self: center;
  width: min(720px, 100%);
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #332b28;
}

.user-prompt p {
  margin: 4px 0 0;
  color: var(--text);
  white-space: pre-wrap;
}

.lane-grid {
  display: grid;
  gap: 16px;
}

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

.lane-grid.multi {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.lane-grid.single {
  grid-template-columns: minmax(0, 780px);
  justify-content: center;
}

.lane-card {
  display: grid;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent),
    var(--panel);
}

.lane-card.qorinix {
  border-color: rgba(255, 77, 0, 0.62);
  box-shadow: inset 0 3px 0 var(--orange);
}

.lane-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.lane-card header strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.metric-row span {
  display: grid;
  gap: 3px;
  padding: 10px;
  background: var(--panel-2);
}

.metric-row b {
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
}

.lane-card p {
  margin: 0;
  padding: 18px;
  color: var(--text);
  font-size: 16px;
  white-space: pre-wrap;
}

.lane-card footer {
  align-self: end;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  color: var(--green);
}

.vote-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 6, 4, 0.92);
  backdrop-filter: blur(12px);
}

.composer-shell {
  border-top: 1px solid var(--line);
  background: rgba(7, 6, 4, 0.96);
}

.model-panel {
  border-bottom: 1px solid var(--line);
}

.model-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
}

.ghost-btn {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.model-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 14px 12px;
}

.select-wrap {
  display: grid;
  gap: 5px;
  min-width: min(260px, 100%);
}

.select-wrap select {
  min-height: 38px;
  padding: 0 10px;
}

.model-check {
  display: inline-grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  max-width: 260px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
}

.model-check.selected {
  border-color: var(--orange);
  color: var(--text);
}

.model-check.disabled {
  opacity: 0.55;
}

.model-check span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
}

.composer textarea {
  min-height: 74px;
  max-height: 180px;
  padding: 13px 14px;
  resize: vertical;
}

.composer-actions {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 8px;
  width: 186px;
}

.hint-row {
  display: grid;
  align-content: start;
  gap: 6px;
}

.send-btn {
  min-height: 44px;
  padding: 0 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.72);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(520px, 100%);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 77, 0, 0.12), transparent 46%),
    var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-head .eyebrow {
  margin: 0;
}

.modal-panel h2 {
  margin: 0;
  padding: 18px 18px 0;
  font-size: 30px;
  line-height: 1.05;
}

.modal-panel p:not(.eyebrow) {
  margin: 0;
  padding: 14px 18px 4px;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  gap: 10px;
  padding: 18px;
}

.modal-primary,
.modal-secondary {
  display: inline-grid;
  place-items: center;
  min-width: 140px;
  padding: 0 14px;
  cursor: pointer;
}

.sidebar-scrim {
  display: none;
}

.pricing-panel {
  width: min(860px, 100%);
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 18px;
}

.pricing-card {
  display: grid;
  gap: 12px;
  min-height: 230px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent),
    var(--panel-2);
}

.pricing-card.featured {
  border-color: var(--orange);
  box-shadow: inset 0 3px 0 var(--orange);
}

.pricing-card h3 {
  margin: 0;
  font-size: 24px;
  line-height: 1;
}

.pricing-card strong {
  color: var(--orange-2);
}

.pricing-card p {
  margin: 0;
  color: var(--muted);
}

.pricing-card button {
  align-self: end;
  min-height: 40px;
  border: 1px solid var(--orange);
  border-radius: 6px;
  background: linear-gradient(135deg, var(--orange), var(--orange-2));
  color: #130701;
  font-weight: 700;
}

.checkout-note {
  margin: 0;
  padding: 0 18px 18px;
  color: var(--amber);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
}

@media (max-width: 1120px) {
  .chat-app {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .lane-grid.battle {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  body {
    overflow: hidden;
  }

  .chat-app {
    grid-template-columns: 1fr;
  }

  .chat-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(86vw, 320px);
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

  body.sidebar-open .chat-sidebar {
    transform: translateX(0);
  }

  .sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 45;
    display: block;
    pointer-events: none;
    background: rgba(0, 0, 0, 0);
    transition: background 180ms ease;
  }

  body.sidebar-open .sidebar-scrim {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.58);
  }

  .sidebar-close,
  .mobile-menu {
    display: inline-grid;
  }

  .chat-topbar {
    min-width: 0;
  }

  .chat-workspace {
    overflow-y: auto;
  }

  .mode-switch {
    flex: 1;
  }

  .mode-btn {
    padding: 0 10px;
    font-size: 12px;
  }

  .top-status {
    gap: 8px;
    padding-right: 10px;
  }

  .top-status span {
    display: none;
  }

  .landing {
    align-content: start;
    padding: 30px 16px;
    min-height: auto;
  }

  .landing h1 {
    font-size: 38px;
  }

  .prompt-row {
    grid-template-columns: 1fr;
    padding-bottom: 18px;
  }

  .run-list {
    padding: 14px;
  }

  .metric-row {
    grid-template-columns: 1fr;
  }

  .vote-bar {
    grid-template-columns: 1fr 1fr;
  }

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

  .composer-actions {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto;
    width: auto;
    align-items: end;
  }

  .send-btn {
    min-width: 118px;
  }
}

@media (max-width: 540px) {
  .chat-main {
    grid-template-rows: 54px minmax(0, 1fr) auto;
  }

  .mode-btn {
    min-height: 54px;
  }

  .model-panel-head,
  .model-controls,
  .composer {
    padding-left: 10px;
    padding-right: 10px;
  }

  .model-panel-head {
    align-items: start;
    flex-direction: column;
  }

  .model-controls {
    display: grid;
    max-height: 132px;
    overflow-y: auto;
  }

  .select-wrap,
  .model-check {
    max-width: none;
    width: 100%;
  }

  .modal-actions {
    flex-direction: column;
  }

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