:root {
  --bg: #1f1e1c;
  --surface: #2a2926;
  --surface-2: #33312d;
  --border: #3d3b37;
  --border-strong: #4d4a45;
  --text: #ecebe6;
  --text-dim: #a8a59c;
  --text-faint: #75726b;
  --accent: #d97757;
  --accent-soft: rgba(217, 119, 87, 0.14);
  --danger: #e5776b;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: Inter, system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --radius: 22px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spark {
  fill: var(--accent);
  stroke: none;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(var(--bg) 70%, transparent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.01em;
  padding: 6px 10px;
  border-radius: 10px;
}

.brand:hover {
  background: var(--surface);
}

.brand .spark {
  width: 20px;
  height: 20px;
}

.model-pill {
  font-size: 12.5px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  text-decoration: none;
}

a.model-pill:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.hero-how {
  flex-basis: 100%;
  text-align: center;
  margin-top: -8px;
  font-size: 13px;
  color: var(--text-dim);
}

.hero-how:hover {
  color: var(--accent);
}

.cost-meter {
  margin-left: auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cost-meter b {
  color: var(--text);
  font-weight: 500;
}

.cost-meter + .icon-btn {
  margin-left: 0;
}

.cost-meter[hidden] + .icon-btn {
  margin-left: auto;
}

.icon-btn {
  margin-left: auto;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--text-dim);
}

.icon-btn:hover {
  background: var(--surface);
  color: var(--text);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Layout */
main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
}

main.empty {
  justify-content: center;
  padding-bottom: 12vh;
}

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 28px;
}

.hero-spark {
  width: 36px;
  height: 36px;
  animation: spin-in 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.hero h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(28px, 5vw, 40px);
  letter-spacing: -0.02em;
}

main:not(.empty) .hero,
main:not(.empty) .suggestions {
  display: none;
}

/* Thread */
.thread {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 16px 0 24px;
}

main.empty .thread {
  display: none;
}

.msg-user {
  align-self: flex-end;
  max-width: 85%;
  background: var(--surface-2);
  border-radius: 18px 18px 4px 18px;
  padding: 10px 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: rise 0.25s ease-out;
}

.msg-jev {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 14px;
  animation: rise 0.25s ease-out;
}

.msg-jev .avatar {
  width: 28px;
  height: 28px;
  margin-top: 2px;
}

.msg-jev.typing .avatar {
  animation: pulse 1.4s ease-in-out infinite;
}

.answer {
  white-space: pre-wrap;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.65;
  min-height: 1.65em;
  overflow-wrap: anywhere;
}

.answer .ch {
  border-radius: 3px;
  transition: background 0.15s;
}

.answer .ch.new {
  animation: ink 0.35s ease-out;
}

.answer .ch.tied {
  text-decoration: underline dotted var(--accent);
  text-underline-offset: 4px;
}

.answer .ch:hover,
.answer .ch.active {
  background: var(--accent-soft);
  cursor: help;
}

.thinking {
  color: var(--text-faint);
  font-family: var(--sans);
  font-size: 14px;
}

.caret {
  display: inline-block;
  width: 9px;
  height: 1.05em;
  margin-left: 1px;
  vertical-align: -0.15em;
  background: var(--accent);
  border-radius: 2px;
  animation: blink 1s steps(1) infinite;
}

.meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.meta .bar {
  position: relative;
  width: 72px;
  height: 4px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}

.meta .bar i {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.2s;
}

.meta .act {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  margin: -4px -4px;
  border-radius: 8px;
  color: var(--text-dim);
}

.meta .act:hover {
  background: var(--surface);
  color: var(--text);
}

.meta .act svg {
  width: 14px;
  height: 14px;
}

.rating {
  display: inline-flex;
  align-items: center;
  padding: 1px 9px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  cursor: help;
}

.rating.pending {
  color: var(--text-faint);
  border-style: dashed;
  animation: blink 1.4s ease-in-out infinite;
}

.rating-terrible {
  color: #e5776b;
}

.rating-bad {
  color: #e0a35c;
}

.rating-solid {
  color: #c9c3b5;
}

.rating-good {
  color: #8fc37e;
}

.rating-perfect {
  color: #6fd3b0;
  background: rgba(111, 211, 176, 0.1);
}

.error {
  color: var(--danger);
  font-family: var(--sans);
  font-size: 14px;
  margin-top: 6px;
}

.notice {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  padding: 12px 14px;
  border: 1px solid rgba(217, 119, 87, 0.35);
  background: var(--accent-soft);
  border-radius: 14px;
  font-family: var(--sans);
  font-size: 14px;
}

.notice svg {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  color: var(--accent);
}

.notice strong {
  font-weight: 600;
}

.notice.spicy {
  border-color: rgba(229, 119, 107, 0.45);
  background: rgba(229, 119, 107, 0.1);
}

.notice.spicy svg {
  color: var(--danger);
}

.notice p {
  margin: 2px 0 0;
  color: var(--text-dim);
}

/* Composer */
.composer-wrap {
  position: sticky;
  bottom: 0;
  padding: 8px 0 max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 22%);
}

main:not(.empty) .composer-wrap {
  margin-top: auto;
}

.composer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 10px 18px;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.25);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer:focus-within {
  border-color: var(--border-strong);
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.35), 0 0 0 4px rgba(217, 119, 87, 0.06);
}

.composer textarea {
  width: 100%;
  resize: none;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text);
  font: 16px/1.5 var(--sans);
  max-height: 220px;
  padding: 0;
}

.composer textarea::placeholder {
  color: var(--text-faint);
}

.composer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.hint {
  font-size: 12.5px;
  color: var(--text-faint);
}

.composer-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.levels {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.level-option,
.memory-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text-dim);
  transition: background 0.15s, color 0.15s;
}

.level-option:hover:not(:disabled),
.memory-toggle:hover:not(:disabled) {
  color: var(--text);
}

.level-option[aria-checked="true"] {
  background: var(--surface-2);
  color: var(--text);
}

.level-option:disabled {
  color: var(--text-faint);
  cursor: not-allowed;
}

.level-option svg,
.memory-toggle svg {
  width: 12px;
  height: 12px;
}

.memory-toggle {
  border: 1px solid var(--border);
}

.memory-toggle[aria-pressed="true"] {
  border-color: rgba(217, 119, 87, 0.45);
  background: var(--accent-soft);
  color: var(--text);
}

.memory-toggle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.preview-banner {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 7px 16px;
  background: var(--accent-soft);
  border-bottom: 1px solid rgba(217, 119, 87, 0.45);
  font-size: 13px;
  color: var(--text);
  text-align: center;
}

.preview-banner[hidden] {
  display: none;
}

.preview-banner button {
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 12.5px;
}

.preview-banner button:hover {
  background: var(--accent);
  color: #1f1e1c;
}

.lab-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px dashed var(--border-strong);
  font-size: 12.5px;
  color: var(--text-dim);
}

.lab-toggle[hidden] {
  display: none;
}

.lab-toggle:hover,
.lab-toggle[aria-expanded="true"] {
  color: var(--text);
  border-style: solid;
}

.lab-toggle.edited {
  border-color: var(--accent);
  color: var(--accent);
}

.lab-toggle svg {
  width: 12px;
  height: 12px;
}

.lab {
  margin-bottom: 8px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 16px;
}

.lab[hidden] {
  display: none;
}

.lab-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lab-head .icon-btn {
  margin-left: auto;
  width: 28px;
  height: 28px;
}

.lab-levels {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.lab-level {
  padding: 2px 10px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text-dim);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.lab-level[aria-selected="true"] {
  background: var(--surface-2);
  color: var(--text);
}

.lab-badge {
  font-size: 12px;
  color: var(--text-faint);
}

.lab-help {
  margin: 4px 0 8px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.lab textarea {
  width: 100%;
  min-height: 84px;
  max-height: 30vh;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 var(--mono);
}

.lab-head {
  flex-wrap: wrap;
}

.lab textarea[hidden],
.lab-request[hidden] {
  display: none;
}

.lab-request pre {
  margin: 0;
  max-height: 40vh;
  overflow: auto;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-dim);
  font: 12px/1.45 var(--mono);
  white-space: pre;
}

.lab-request p {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-faint);
}

.lab-request code {
  font-family: var(--mono);
}

.lab-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.lab-status {
  margin: 6px 0 0;
  min-height: 1em;
  font-size: 12.5px;
  color: var(--text-dim);
}

.stopped-tag {
  font-size: 11.5px;
  padding: 0 7px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
}

.level-tag {
  font-size: 11.5px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-dim);
}

.send {
  margin-left: auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #1f1e1c;
  transition: transform 0.1s, opacity 0.15s, background 0.15s;
}

.send:hover:not(:disabled) {
  background: #e3876a;
}

.send:active:not(:disabled) {
  transform: scale(0.94);
}

.send:disabled {
  opacity: 0.35;
  cursor: default;
}

.send svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.4;
}

.send .i-stop {
  display: none;
  fill: currentColor;
  stroke: none;
}

.send.stop {
  background: var(--text);
}

.send.stop .i-send {
  display: none;
}

.send.stop .i-stop {
  display: block;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.suggestions button {
  font-size: 13.5px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.suggestions button:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.disclaimer {
  margin: 10px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
}

/* Probability tooltip */
.tooltip {
  position: fixed;
  z-index: 20;
  width: 220px;
  padding: 10px 12px;
  background: #151413;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  font-size: 12.5px;
  pointer-events: none;
}

.tooltip h4 {
  margin: 0 0 8px;
  font-weight: 500;
  color: var(--text-dim);
}

.tooltip .screen-note {
  margin: -4px 0 8px;
  font-size: 11.5px;
  color: var(--text-faint);
}

.tooltip .round-name {
  margin: 10px 0 4px;
  font-size: 11.5px;
  color: var(--text-faint);
}

.tooltip h4 + .round-name {
  margin-top: 0;
}

.tooltip .row {
  display: grid;
  grid-template-columns: 52px 1fr 44px;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
}

.tooltip .row + .row {
  margin-top: 4px;
}

.tooltip .row.picked {
  color: var(--accent);
}

.tooltip .row span:last-child {
  text-align: right;
  color: var(--text-dim);
}

.tooltip .track {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}

.tooltip .track i {
  display: block;
  height: 100%;
  background: currentColor;
  opacity: 0.8;
}

.tooltip .row:not(.picked) .track i {
  background: var(--text-faint);
}

/* Accounts: sign-in card */
.signin-card {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 26px 24px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.25);
  animation: rise 0.25s ease-out;
}

.signin-card[hidden],
main:not(.empty) .signin-card {
  display: none;
}

.signin-card h2 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.signin-card > p {
  margin: 0 0 18px;
  color: var(--text-dim);
  font-size: 14px;
}

.signin-google {
  display: flex;
  justify-content: center;
  min-height: 44px;
  /* Google's button is an iframe; under the page's dark color-scheme the browser paints its
     transparent background white. A light scheme here keeps it transparent. */
  color-scheme: light;
}

.signin-google iframe {
  color-scheme: light;
  background: transparent;
}

.signin-google:empty {
  display: none;
}

.signin-dev {
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  font-size: 14px;
}

.signin-dev:hover {
  background: var(--surface-2);
}

.signin-dev[hidden] {
  display: none;
}

.signin-message {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(217, 119, 87, 0.35);
  background: var(--accent-soft);
  border-radius: 14px;
  font-size: 14px;
  text-align: left;
}

.signin-message strong {
  font-weight: 600;
}

.signin-message p {
  margin: 2px 0 0;
  color: var(--text-dim);
}

body.signed-out .composer-wrap {
  display: none;
}

/* Accounts: avatar menu */
.account {
  position: relative;
  flex: none;
}

.account-avatar {
  width: 32px;
  height: 32px;
  padding: 0; /* buttons have default padding, which left a ring around the photo */
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #1f1e1c;
  font-weight: 600;
  font-size: 14px;
}

.account-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.account-avatar:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 25;
  width: 260px;
  max-width: calc(100vw - 32px);
  padding: 8px;
  background: #151413;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  font-size: 14px;
}

.account-menu[hidden] {
  display: none;
}

.account-name {
  padding: 6px 8px 0;
  font-weight: 500;
}

.account-name:empty {
  display: none;
}

.account-email {
  padding: 2px 8px 6px;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}

.account-usage {
  margin: 4px 0 6px;
  padding: 8px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.usage-bar {
  display: block;
  margin-top: 6px;
  height: 4px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}

.usage-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 4px;
}

.usage-bar i.full {
  background: var(--danger);
}

.usage-bar[hidden] {
  display: none;
}

.account-menu-item {
  display: block;
  width: 100%;
  padding: 7px 8px;
  border-radius: 8px;
  text-align: left;
  color: var(--text);
  text-decoration: none;
}

.account-menu-item:hover {
  background: var(--surface);
}

.account-menu-item[hidden] {
  display: none;
}

/* Accounts: saved chats sidebar */
.sidebar {
  --w: 260px;
  position: fixed;
  z-index: 30;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--w);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 10px;
  background: #1a1918;
  border-right: 1px solid var(--border);
  transition: transform 0.2s ease, visibility 0.2s;
}

.sidebar[hidden] {
  display: none;
}

body.signed-in {
  padding-left: 260px;
  transition: padding-left 0.2s ease;
}

body.signed-in.sidebar-collapsed {
  padding-left: 0;
}

body.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
  visibility: hidden;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 2px 4px 8px;
}

.sidebar-title {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 500;
}

.chat-count {
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.sidebar-new-wrap {
  display: block;
}

.sidebar-new {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
}

.sidebar-new svg {
  width: 16px;
  height: 16px;
}

.sidebar-new:hover:not(:disabled) {
  background: var(--surface);
}

.sidebar-new:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chat-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 10px;
}

.chat-item:hover,
.chat-item.active {
  background: var(--surface);
}

.chat-item.active {
  background: var(--surface-2);
}

.chat-open {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 7px 4px 7px 10px;
  text-align: left;
}

.chat-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.chat-time {
  font-size: 12px;
  color: var(--text-faint);
}

.chat-delete {
  flex: none;
  width: 30px;
  height: 30px;
  margin-right: 4px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--text-faint);
  opacity: 0;
}

.chat-item:hover .chat-delete,
.chat-item.active .chat-delete,
.chat-delete:focus-visible {
  opacity: 1;
}

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

.chat-delete svg {
  width: 15px;
  height: 15px;
}

.chat-empty {
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-faint);
}

.sidebar-note {
  margin: 0;
  padding: 0 8px;
  font-size: 12px;
  color: var(--text-faint);
}

.sidebar-toggle {
  margin-left: 0;
  margin-right: -6px;
}

.sidebar-toggle[hidden] {
  display: none;
}

.sidebar-scrim {
  position: fixed;
  inset: 0;
  z-index: 29;
  background: rgba(0, 0, 0, 0.5);
}

.sidebar-scrim[hidden] {
  display: none;
}

@media (hover: none) {
  .chat-delete {
    opacity: 1;
  }
}

@media (max-width: 760px) {
  body.signed-in {
    padding-left: 0;
  }
  .sidebar,
  body.sidebar-collapsed .sidebar {
    width: min(86vw, 300px);
    transform: translateX(-100%);
    visibility: hidden;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.4);
  }
  body.drawer-open .sidebar {
    transform: none;
    visibility: visible;
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes ink {
  from {
    color: var(--accent);
    background: var(--accent-soft);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@keyframes pulse {
  50% {
    transform: scale(0.82) rotate(45deg);
    opacity: 0.7;
  }
}

@keyframes spin-in {
  from {
    transform: rotate(-120deg) scale(0.4);
    opacity: 0;
  }
}

@media (max-width: 560px) {
  .model-pill,
  .hint {
    display: none;
  }
  .answer {
    font-size: 17px;
  }
}

@media (max-width: 440px) {
  .cost-label {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* Admin page */
.admin-page .brand {
  color: inherit;
  text-decoration: none;
}

.admin {
  max-width: 1000px;
  padding-bottom: 48px;
}

.admin h1 {
  margin: 12px 0 4px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 32px;
  letter-spacing: -0.02em;
}

.admin h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.admin-lede {
  margin: 0 0 8px;
  color: var(--text-dim);
}

.admin-status {
  min-height: 1.6em;
  margin: 0 0 8px;
  font-size: 13.5px;
  color: #8fc37e;
}

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

.admin-section {
  margin-top: 22px;
}

.admin-section[hidden],
.admin-gate[hidden],
#panel[hidden] {
  display: none;
}

.admin-gate {
  margin-top: 24px;
}

.admin-gate a {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent);
}

.btn {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  font-size: 13.5px;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1f1e1c;
  font-weight: 500;
}

.btn.primary:hover {
  background: #e3876a;
}

.btn.danger {
  color: var(--danger);
}

.admin input,
.admin select {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  min-width: 0;
}

.admin input:focus,
.admin select:focus {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.12);
}

.admin-add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.admin-add-form input[type="email"] {
  flex: 1 1 240px;
}

.budget-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 14px;
}

.budget-field input {
  width: 90px;
}

.admin-requests {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-request {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(217, 119, 87, 0.35);
  background: var(--accent-soft);
  border-radius: 14px;
}

.request-actions {
  display: flex;
  gap: 8px;
}

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

.who-name {
  overflow-wrap: anywhere;
}

.who-email {
  font-size: 12.5px;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}

.admin-users {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-users th {
  text-align: left;
  font-weight: 500;
  font-size: 12.5px;
  color: var(--text-faint);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.admin-users td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.admin-users tr.blocked .who-name,
.admin-users tr.blocked .who-email-cell,
.admin-users tr.blocked .spend {
  opacity: 0.55;
}

.status-pill {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 12px;
  font-weight: 500;
}

.status-pill.allowed {
  color: #8fc37e;
}

.status-pill.blocked {
  color: var(--danger);
}

.spend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
}

.spend-line {
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.spent {
  margin-right: 4px;
}

.admin .budget-input {
  width: 80px;
  margin-left: 2px;
  padding: 3px 6px;
}

.no-limit {
  margin-left: 4px;
  color: var(--text-dim);
}

.who-email-cell {
  overflow-wrap: anywhere;
}

.spend .usage-bar {
  margin: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@media (max-width: 600px) {
  .admin-users thead {
    display: none;
  }
  .admin-users,
  .admin-users tbody,
  .admin-users tr,
  .admin-users td {
    display: block;
    width: 100%;
  }
  .admin-users tr {
    padding: 10px 14px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
  }
  .admin-users td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border: 0;
  }
  .admin-users td::before {
    content: attr(data-label);
    font-size: 12.5px;
    color: var(--text-faint);
  }
  .admin-users td:first-child::before,
  .admin-users td:last-child::before {
    content: none;
  }
  .spend {
    min-width: 0;
    align-items: flex-end;
  }
}

/* "How it works" page (public/how.html) */
.how-page .brand {
  color: inherit;
  text-decoration: none;
}

.how {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 16px 64px;
}

.how h1 {
  margin: 12px 0 8px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 34px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.how h2 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 24px;
  letter-spacing: -0.01em;
}

.how h3 {
  margin: 22px 0 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.how h4 {
  margin: 14px 0 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.how a {
  color: var(--accent);
}

.how code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 5px;
}

.how-lede {
  color: var(--text-dim);
  font-size: 16px;
  margin: 0 0 16px;
}

.how-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.how .how-toc a {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}

.how .how-toc a:hover {
  border-color: var(--border-strong);
  background: var(--surface);
}

.how-section {
  padding: 28px 0 8px;
  border-top: 1px solid var(--border);
  margin-top: 24px;
  scroll-margin-top: 64px;
}

.how-section .tag {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  vertical-align: middle;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.how-note,
.how-foot {
  color: var(--text-dim);
  font-size: 14px;
}

.how-foot {
  margin-top: 40px;
}

.how-list {
  padding-left: 20px;
  margin: 0;
}

.how-list li + li {
  margin-top: 4px;
}

.how-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.how-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 560px;
}

.how-table th,
.how-table td {
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.how-table tbody tr:last-child > * {
  border-bottom: 0;
}

.how-table thead th {
  color: var(--text-dim);
  font-weight: 600;
  background: var(--surface);
}

.how-table tbody th {
  font-weight: 500;
  color: var(--text-dim);
}

.how details {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--surface);
}

.how summary {
  cursor: pointer;
  font-weight: 500;
}

.how pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: 12.5px/1.55 var(--mono);
  color: var(--text-dim);
}

/* Flowcharts: a column of nodes joined by arrows. Decisions carry their "yes" exit on the right
   (below, on a phone); "no" carries on down. Colour says who does the step. */
.flow {
  --code: var(--border-strong);
  --jev: var(--accent);
  --stop: var(--danger);
  --go: #7fb685;
  --mask: #c9a85a;
  display: flex;
  flex-direction: column;
  gap: 26px;
  margin: 16px 0 8px;
}

.flow .node {
  position: relative;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--code);
  background: var(--surface);
  font-size: 14px;
  line-height: 1.45;
}

.flow > .node + .node::before,
.flow > .fork + .node::before,
.flow > .node + .fork::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -24px;
  height: 18px;
  border-left: 2px solid var(--text-faint);
}

.flow > .node + .node::after,
.flow > .fork + .node::after,
.flow > .node + .fork::after {
  content: "";
  position: absolute;
  left: calc(50% - 4px);
  top: -9px;
  border: 5px solid transparent;
  border-top: 6px solid var(--text-faint);
  border-bottom: 0;
}

.flow .node.jev {
  border-color: var(--jev);
  background: var(--accent-soft);
}

.flow .node.decision {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  justify-content: space-between;
  border-style: dashed;
}

.flow .node.decision .q::before {
  content: "◆";
  margin-right: 8px;
  color: var(--text-faint);
  font-size: 11px;
}

.flow .exit {
  font-size: 13px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
  white-space: normal;
}

.flow .exit.stop {
  color: var(--stop);
}

.flow .exit.go,
.flow .node.go {
  color: var(--go);
}

.flow .exit.mask {
  color: var(--mask);
}

.flow .node.go {
  border-color: var(--go);
}

.flow .node.loop {
  border-style: dotted;
  color: var(--text-dim);
}

.flow .node small,
.flow .fork small {
  color: var(--text-dim);
}

.flow .node ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.flow .node p {
  margin: 4px 0 0;
}

.flow .fork {
  position: relative;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
  padding: 22px 10px 10px;
  border: 1px dashed var(--border);
  border-radius: 12px;
}

.flow .fork-label {
  position: absolute;
  top: 4px;
  left: 12px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

@media (max-width: 560px) {
  .how h1 {
    font-size: 28px;
  }
  .flow .fork {
    grid-template-columns: 1fr;
  }
}

/* Admin prompt editors on the "How it works" page */
.notice.how-admin {
  display: block;
  margin: 0 0 16px;
}

.notice.how-admin[hidden] {
  display: none;
}

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

.prompt-text {
  width: 100%;
  min-height: 60px;
  resize: vertical;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font: 12.5px/1.55 var(--mono);
}

.prompt-text:focus {
  outline: none;
  border-color: var(--accent);
}

.prompt-editor.edited .prompt-text {
  border-color: #c9a85a;
}

.prompt-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.prompt-status {
  font-size: 12.5px;
  color: var(--text-dim);
}

.how details.has-edits > summary::after {
  content: "edited";
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  color: #c9a85a;
  border: 1px solid currentColor;
}
