/* AI Transfer Station — Ollama-inspired design system (getdesign.md/ollama/design-md)
   Paper-white canvas, pill geometry, hairline borders, no shadows, no gradients. */

:root {
  color-scheme: light;
  --ink: #000000;
  --ink-deep: #090909;
  --charcoal: #525252;
  --body: #737373;
  --mute: #a3a3a3;
  --canvas: #ffffff;
  --surface-soft: #fafafa;
  --surface-dark: #171717;
  --hairline: #e5e5e5;
  --hairline-strong: #d4d4d4;
  --on-dark: #ffffff;
  --on-dark-mute: rgba(255, 255, 255, 0.7);
  --focus-ring: rgba(59, 130, 246, 0.5);
  --danger: #b42318;
  --warn: #8a5200;
  --terminal-red: #ff5f56;
  --terminal-yellow: #ffbd2e;
  --terminal-green: #27c93f;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-full: 9999px;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "SF Pro Rounded", ui-rounded, "Nunito", var(--sans);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --topnav-height: 57px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

html {
  min-height: 100%;
  background: var(--canvas);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

p {
  color: var(--body);
}

/* ---------- Controls ---------- */

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

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  max-width: 100%;
  padding: 8px 20px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-full);
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

button:hover {
  border-color: var(--charcoal);
}

button:active {
  background: var(--surface-soft);
}

button.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-dark);
}

button.primary:hover {
  background: var(--ink-deep);
  border-color: var(--ink-deep);
}

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

button.danger:hover {
  border-color: var(--danger);
}

button:disabled {
  background: var(--surface-soft);
  border-color: var(--hairline);
  color: var(--mute);
  cursor: not-allowed;
}

input,
select {
  width: 100%;
  height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-full);
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
}

/* Compact controls must not inherit text-field geometry. Keeping this global
   prevents schema-driven boolean fields from expanding into oversized boxes. */
input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--ink);
  cursor: pointer;
}

input[type="checkbox"] {
  border-radius: 4px;
}

input[type="file"] {
  height: 42px;
  padding: 4px;
  border-radius: var(--r-md);
  color: var(--body);
  font-size: 13px;
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  height: 32px;
  margin-right: 10px;
  padding: 5px 14px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-full);
  background: var(--canvas);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
  border-color: var(--charcoal);
}

textarea {
  width: 100%;
  min-height: 96px;
  padding: 12px 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--mute);
}

input:hover,
textarea:hover,
select:hover {
  border-color: var(--hairline-strong);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--ink);
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23525252' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 1px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--charcoal);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.43;
}

label.checkline {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

label.checkline input {
  width: 15px;
  height: 15px;
  min-width: 15px;
  margin: 0;
  padding: 0;
  accent-color: var(--ink);
}

.muted {
  color: var(--body);
  font-size: 14px;
}

/* ---------- Top navigation ---------- */

.topnav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 56px;
  padding: 8px 32px;
  border-bottom: 1px solid var(--hairline);
  background: var(--canvas);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-family: var(--display);
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
}

.mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: var(--r-full);
  background: var(--ink);
  color: var(--on-dark);
  font: 600 12px/1 var(--sans);
}

.topnav nav {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.topnav nav::-webkit-scrollbar {
  display: none;
}

.topnav nav button {
  height: 36px;
  padding: 8px 14px;
  border: 0;
  background: none;
  color: var(--body);
  font-weight: 500;
}

.topnav nav button:hover {
  color: var(--ink);
}

.topnav nav button.active {
  color: var(--ink);
}

.topnav-right {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}

.topnav-right .account {
  color: var(--body);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.topnav-right button {
  height: 32px;
  padding: 6px 16px;
  font-size: 14px;
}

.pref-toggle {
  height: 32px;
  padding: 6px 12px;
  border-color: transparent;
  background: var(--surface-soft);
  color: var(--charcoal);
  font-size: 13px;
  white-space: nowrap;
}

.pref-toggle:hover {
  border-color: var(--hairline-strong);
}

.topup-grid .topup-block {
  display: grid;
  gap: 12px;
  align-content: start;
}

.topup-grid .topup-block button {
  justify-self: start;
}

.pay-pending {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pay-pending button {
  height: 30px;
  padding: 4px 12px;
  font-size: 13px;
}

.new-codes {
  margin-bottom: 24px;
}

.codes-list {
  margin: 12px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--surface-soft);
  font: 13px/1.7 var(--mono);
  user-select: all;
  overflow-x: auto;
}

.multiplier-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.multiplier-control label {
  color: var(--charcoal);
  font-size: 13px;
  white-space: nowrap;
}

.multiplier-control input {
  width: 84px;
  height: 36px;
}

.multiplier-note {
  margin: -18px 0 16px;
  color: var(--warn);
  font-size: 13px;
}

.price-adjusted {
  margin-top: 4px;
  color: var(--warn);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.credit-pill {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.auth-prefs {
  position: absolute;
  top: 16px;
  right: 20px;
  display: flex;
  gap: 8px;
}

.auth-page {
  position: relative;
}

/* ---------- Footer ---------- */

.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 32px 24px;
  border-top: 1px solid var(--hairline);
  color: var(--body);
  font-size: 12px;
  line-height: 1.33;
}

.footer .code {
  font-size: 12px;
}

/* ---------- Page scaffold ---------- */

.page {
  width: min(100%, 1024px);
  margin: 0 auto;
  padding: 48px 24px 88px;
}

.page-head {
  max-width: 720px;
  margin-bottom: 40px;
}

.page-head h2 {
  color: var(--ink);
  font-family: var(--display);
  font-size: 30px;
  font-weight: 500;
  line-height: 1.2;
}

.page-head p {
  margin-top: 8px;
  font-size: 16px;
  line-height: 1.5;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.section {
  margin-top: 56px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-head h3 {
  color: var(--ink);
  font-family: var(--display);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.33;
}

.panel .section-head h3 {
  font-family: var(--sans);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.4;
}

.section-head p {
  margin-top: 4px;
  font-size: 14px;
  max-width: 620px;
}

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

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
}

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

.full-span {
  grid-column: 1 / -1;
}

/* ---------- API documentation ---------- */

.page.page-docs {
  width: min(100%, 1200px);
}

.docs-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
  gap: 56px;
  align-items: end;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--hairline);
}

.docs-kicker {
  display: block;
  margin-bottom: 12px;
  color: var(--body);
  font: 600 12px/1.2 var(--mono);
  text-transform: uppercase;
}

.docs-hero h2 {
  font-family: var(--display);
  font-size: 40px;
  font-weight: 500;
  line-height: 1.1;
}

.docs-hero p {
  max-width: 680px;
  margin-top: 14px;
  font-size: 17px;
  line-height: 1.6;
}

.docs-base {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding-left: 24px;
  border-left: 1px solid var(--hairline);
}

.docs-base span,
.docs-base small {
  color: var(--body);
  font-size: 12px;
}

.docs-base strong {
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 600;
}

.docs-layout {
  display: grid;
  grid-template-columns: 184px minmax(0, 1fr);
  gap: 56px;
  align-items: start;
  margin-top: 40px;
}

.docs-toc {
  position: sticky;
  top: calc(var(--topnav-height) + 24px);
  min-width: 0;
  padding-right: 24px;
  border-right: 1px solid var(--hairline);
}

.docs-toc > strong {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
}

.docs-toc nav {
  display: grid;
  gap: 2px;
}

.docs-toc a {
  padding: 6px 0;
  color: var(--body);
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
}

.docs-toc a:hover {
  color: var(--ink);
}

.docs-content {
  min-width: 0;
}

.doc-section {
  scroll-margin-top: calc(var(--topnav-height) + 24px);
}

.doc-section + .doc-section {
  margin-top: 64px;
  padding-top: 56px;
  border-top: 1px solid var(--hairline);
}

.doc-section h3 {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.25;
}

.doc-section h4 {
  margin-top: 36px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
}

.doc-section > p,
.doc-section > h4 + p {
  max-width: 760px;
  margin-top: 10px;
  font-size: 15px;
  line-height: 1.7;
}

.doc-code {
  min-width: 0;
  margin-top: 20px;
  overflow: hidden;
  border: 1px solid var(--ink-deep);
  border-radius: var(--r-md);
  background: var(--surface-dark);
  color: var(--on-dark);
}

.doc-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 40px;
  padding: 7px 10px 7px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--on-dark-mute);
  font: 500 12px/1.3 var(--mono);
}

.doc-code-head button {
  height: 26px;
  padding: 4px 10px;
  border-color: rgba(255, 255, 255, 0.22);
  background: transparent;
  color: var(--on-dark);
  font-size: 12px;
}

.doc-code-head button:hover {
  border-color: rgba(255, 255, 255, 0.7);
}

.doc-code pre {
  margin: 0;
  padding: 18px;
  overflow-x: auto;
  color: var(--on-dark);
  font: 13px/1.65 var(--mono);
  tab-size: 2;
}

.doc-code code {
  font: inherit;
  white-space: pre;
}

.doc-code-grid,
.doc-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.doc-split {
  margin-top: 24px;
}

.doc-split h4 {
  margin-top: 0;
}

.doc-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 24px;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}

.doc-facts > div {
  min-width: 0;
  padding: 20px 24px 20px 0;
}

.doc-facts > div + div {
  padding-left: 24px;
  border-left: 1px solid var(--hairline);
}

.doc-facts code {
  overflow-wrap: anywhere;
  font: 600 13px/1.5 var(--mono);
}

.doc-facts p {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.55;
}

.doc-note {
  margin-top: 20px !important;
  padding-left: 14px;
  border-left: 2px solid var(--ink);
  color: var(--charcoal);
  font-size: 13px !important;
}

.doc-table-wrap {
  margin-top: 22px;
  overflow-x: auto;
  border-top: 1px solid var(--hairline-strong);
  border-bottom: 1px solid var(--hairline-strong);
}

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

.doc-table th,
.doc-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  vertical-align: top;
}

.doc-table th {
  color: var(--body);
  font-size: 12px;
  font-weight: 600;
}

.doc-table tr:last-child td {
  border-bottom: 0;
}

.doc-table td.code {
  font-family: var(--mono);
  white-space: nowrap;
}

.doc-list {
  display: grid;
  gap: 10px;
  max-width: 800px;
  margin: 20px 0 0;
  padding-left: 20px;
  color: var(--charcoal);
  font-size: 14px;
  line-height: 1.6;
}

@media (max-width: 820px) {
  .docs-hero {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .docs-base {
    padding: 20px 0 0;
    border-top: 1px solid var(--hairline);
    border-left: 0;
  }

  .docs-layout {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .docs-toc {
    position: static;
    padding: 0 0 16px;
    border-right: 0;
    border-bottom: 1px solid var(--hairline);
  }

  .docs-toc nav {
    display: flex;
    gap: 8px 18px;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .docs-toc a {
    flex: none;
  }

  .doc-code-grid,
  .doc-split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .docs-hero h2 {
    font-size: 32px;
  }

  .doc-section + .doc-section {
    margin-top: 48px;
    padding-top: 40px;
  }

  .doc-facts {
    grid-template-columns: 1fr;
  }

  .doc-facts > div {
    padding: 18px 0;
  }

  .doc-facts > div + div {
    padding-left: 0;
    border-top: 1px solid var(--hairline);
    border-left: 0;
  }

  .doc-code pre {
    padding: 16px;
    font-size: 12px;
  }
}

/* ---------- Stat strip (no boxes, hairline dividers) ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  row-gap: 32px;
  margin: 40px 0 8px;
}

.stat {
  min-width: 0;
  padding: 4px 28px;
  border-left: 1px solid var(--hairline);
}

.stat:nth-child(3n + 1) {
  padding-left: 0;
  border-left: 0;
}

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

.stats-4 .stat {
  border-left: 1px solid var(--hairline);
  padding-left: 28px;
}

.stats-4 .stat:nth-child(4n + 1) {
  border-left: 0;
  padding-left: 0;
}

/* dates and composite prices are longer than plain numbers — especially in
   Chinese (2026年7月8日) — so detail tiles use a smaller value size */
.stats-4 .stat strong {
  font-size: 22px;
}

@media (max-width: 1080px) {
  .stats-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 24px;
  }

  .stats-4 .stat {
    border-left: 1px solid var(--hairline);
    padding-left: 24px;
  }

  .stats-4 .stat:nth-child(2n + 1) {
    border-left: 0;
    padding-left: 0;
  }
}

.stat strong {
  display: block;
  color: var(--ink);
  font-family: var(--display);
  font-size: 30px;
  font-weight: 500;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.stat-total {
  color: var(--body);
  font-size: 0.6em;
  font-weight: 500;
}

.stat span {
  display: block;
  margin-bottom: 6px;
  color: var(--body);
  font-size: 14px;
  font-weight: 500;
}

.stat small {
  display: block;
  margin-top: 4px;
  color: var(--body);
  font-size: 12px;
  line-height: 1.33;
  overflow-wrap: anywhere;
}

/* ---------- Cards (rare, flat, hairline) ---------- */

.panel {
  min-width: 0;
  padding: 32px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--canvas);
}

.form-panel {
  max-width: 640px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.client-card {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 24px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--canvas);
}

.client-card h3 {
  color: var(--ink);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.56;
}

.client-card .tag {
  justify-self: start;
}

.client-card p {
  font-size: 14px;
  line-height: 1.5;
}

.notice {
  padding: 14px 18px;
  border-radius: var(--r-lg);
  background: var(--surface-soft);
  color: var(--charcoal);
  font-size: 14px;
  line-height: 1.5;
}

.notice p {
  color: var(--charcoal);
  font-size: 14px;
}

/* ---------- Chips, pills, code ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 4px 12px;
  border-radius: var(--r-full);
  background: var(--surface-soft);
  color: var(--charcoal);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.33;
  white-space: nowrap;
}

.pill.warn {
  color: var(--warn);
}

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

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--r-full);
  background: var(--surface-soft);
  color: var(--ink);
  font: 400 12px/1.4 var(--mono);
}

.code {
  display: inline-block;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  background: var(--surface-soft);
  color: var(--ink);
  font: 400 12px/1.5 var(--mono);
  overflow-wrap: anywhere;
}

/* ---------- Install snippet (signature pill) ---------- */

.snippet {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  padding: 12px 20px;
  border-radius: var(--r-full);
  background: var(--surface-soft);
  color: var(--ink);
  font: 400 14px/1.4 var(--mono);
  overflow-wrap: anywhere;
}

.snippet .prompt {
  color: var(--body);
}

/* ---------- Terminal card (white, traffic lights) ---------- */

.terminal-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--canvas);
}

.terminal-dots {
  display: flex;
  gap: 6px;
}

.terminal-dots span {
  width: 11px;
  height: 11px;
  border-radius: var(--r-full);
  background: var(--terminal-red);
}

.terminal-dots span:nth-child(2) {
  background: var(--terminal-yellow);
}

.terminal-dots span:nth-child(3) {
  background: var(--terminal-green);
}

.terminal-card pre {
  margin: 0;
  overflow-x: auto;
  color: var(--charcoal);
  font: 400 14px/1.7 var(--mono);
}

/* ---------- Tables: row hairlines only ---------- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  color: var(--charcoal);
  font-size: 14px;
  line-height: 1.45;
}

.table th {
  padding: 10px 14px 10px 0;
  border-bottom: 1px solid var(--hairline-strong);
  color: var(--body);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: 14px 14px 14px 0;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  vertical-align: middle;
}

.table td:last-child,
.table th:last-child {
  padding-right: 0;
}

.table strong {
  color: var(--ink);
  font-weight: 500;
}

.table button {
  height: 32px;
  padding: 5px 14px;
  font-size: 14px;
}

.control-table input,
.control-table select {
  height: 34px;
  min-width: 110px;
  padding: 5px 12px;
  font-size: 14px;
}

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

.admin-user-email {
  min-width: 190px;
  overflow-wrap: anywhere;
}

.user-actions {
  min-width: 146px;
  flex-wrap: nowrap;
}

.price-edit {
  display: flex;
  align-items: center;
  gap: 6px;
}

.price-edit input {
  width: 100px;
  min-width: 0;
}

.price-edit-meta {
  margin-top: 6px;
}

.price-edit-meta select {
  min-width: 0;
  width: 113px;
  padding-right: 28px;
  background-position: right 10px center;
}

.model-group-row td {
  padding: 8px 12px 8px 0;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--hairline);
  color: var(--charcoal);
  font-size: 13px;
}

.control-table select {
  padding-right: 32px;
  background-position: right 12px center;
}

.log-body {
  max-height: 360px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  border-radius: var(--r-lg);
  background: var(--surface-soft);
  color: var(--charcoal);
  font: 400 12px/1.6 var(--mono);
  white-space: pre-wrap;
}

/* ---------- Auth (README hero) ---------- */

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 48px 24px;
  background: var(--canvas);
}

.auth-inner {
  width: min(100%, 430px);
  display: grid;
  gap: 24px;
  justify-items: center;
  text-align: center;
}

.auth-inner .mark {
  width: 52px;
  height: 52px;
  font-size: 18px;
}

.auth-inner h1 {
  color: var(--ink);
  font-family: var(--display);
  font-size: 36px;
  font-weight: 500;
  line-height: 1.11;
}

.auth-inner .lede {
  max-width: 400px;
  font-size: 16px;
  line-height: 1.5;
}

.auth-card {
  width: 100%;
  display: grid;
  gap: 14px;
  margin-top: 8px;
  padding: 28px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  text-align: left;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 8px;
  background: var(--surface-soft);
  border-radius: var(--r-full);
}

.auth-tabs button {
  flex: 1;
  height: 34px;
  border-color: transparent;
  background: none;
  color: var(--body);
}

.auth-tabs button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-dark);
}

.auth-actions {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.auth-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.code-box {
  display: grid;
  gap: 14px;
  margin-top: 6px;
  padding-top: 20px;
  border-top: 1px solid var(--hairline);
}

.auth-note {
  max-width: 380px;
  color: var(--body);
  font-size: 12px;
  line-height: 1.5;
}

.auth-message {
  min-height: 20px;
  font-size: 14px;
  color: var(--charcoal);
}

/* ---------- Chat ---------- */

.page-chat {
  width: min(100%, 1080px);
  height: calc(100dvh - var(--topnav-height));
  margin: 0 auto;
  padding: 24px 24px 20px;
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 40px;
  height: 100%;
  min-height: 0;
}

.chat-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  min-height: 0;
  min-width: 0;
}

.chat-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex: none;
}

.chat-toolbar select {
  width: auto;
  max-width: 300px;
  min-width: 0;
  flex: 0 1 auto;
  height: 36px;
  padding: 6px 38px 6px 16px;
}

#chat-vendor {
  max-width: 180px;
}

.chat-toolbar .spacer {
  flex: 1;
}

.chat-toolbar #new-chat {
  flex: none;
  white-space: nowrap;
}

.messages {
  flex: 1 1 auto;
  min-height: 0;
  padding: 8px 14px 8px 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.messages-end {
  width: 100%;
  height: 1px;
  pointer-events: none;
}

.chat-turn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 20px;
}

.chat-turn:last-child {
  margin-bottom: 4px;
}

.chat-turn.is-user {
  align-items: flex-end;
}

.turn-meta {
  color: var(--body);
  font-size: 12px;
  font-weight: 500;
}

.turn-body {
  max-width: min(680px, 100%);
  padding: 12px 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--canvas);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.turn-progress {
  display: inline-flex;
  margin-left: 8px;
  vertical-align: -2px;
}

.turn-progress .spinner {
  width: 12px;
  height: 12px;
}

/* Native media controls cannot establish a useful intrinsic width inside a
   shrink-wrapped, textless flex item. Give media-only replies a stable canvas
   so audio players do not collapse into a narrow vertical control. */
.turn-body.has-audio {
  width: 392px;
  max-width: 100%;
}

.turn-body.has-video {
  width: 520px;
  max-width: 100%;
}

.chat-turn.is-user .turn-body {
  max-width: min(520px, 82%);
  border-color: var(--surface-dark);
  background: var(--surface-dark);
  color: var(--on-dark);
  white-space: pre-wrap;
}

/* rendered Markdown inside assistant bubbles */
.turn-body p {
  color: inherit;
  margin: 0 0 10px;
}

.turn-body > *:last-child {
  margin-bottom: 0;
}

.turn-body h3,
.turn-body h4,
.turn-body h5,
.turn-body h6 {
  margin: 14px 0 6px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
}

.turn-body ul,
.turn-body ol {
  margin: 0 0 10px;
  padding-left: 22px;
}

.turn-body li {
  margin: 3px 0;
}

.turn-body .md-inline {
  padding: 1px 6px;
  border-radius: var(--r-sm);
  background: var(--surface-soft);
  font: 400 13px/1.5 var(--mono);
}

.turn-body pre.md-code {
  margin: 0 0 10px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface-soft);
  overflow-x: auto;
  font: 400 13px/1.6 var(--mono);
  white-space: pre;
}

.turn-body blockquote {
  margin: 0 0 10px;
  padding-left: 12px;
  border-left: 3px solid var(--hairline-strong);
  color: var(--body);
}

.turn-body hr {
  margin: 12px 0;
  border: 0;
  border-top: 1px solid var(--hairline);
}

.turn-body a {
  color: var(--ink);
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: none;
  padding: 10px 10px 10px 20px;
  border: 1px solid var(--hairline-strong);
  border-radius: 24px;
  background: var(--canvas);
}

.composer:focus-within {
  border-color: var(--ink);
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.composer textarea {
  flex: 1;
  min-height: 24px;
  max-height: 140px;
  padding: 6px 0;
  border: 0;
  border-radius: 0;
  background: none;
  font-size: 16px;
  resize: none;
}

.composer textarea:focus-visible {
  outline: none;
}

.composer button {
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--r-full);
}

.chat-hint {
  flex: none;
  margin: -6px 0 0;
  padding: 0 6px;
  color: var(--ink-muted);
  font-size: 13px;
}

.chat-required {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  flex: none;
  max-height: 170px;
  padding: 10px 6px;
  overflow-y: auto;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}

.chat-required-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.chat-required-field .req {
  margin-left: 3px;
  color: #d0453b;
}

.chat-required-field input,
.chat-required-field select,
.chat-required-field textarea {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-weight: 400;
}

.chat-required-field textarea {
  min-height: 58px;
  resize: vertical;
}

.chat-required-field.is-boolean {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.chat-required-field.is-boolean > span {
  grid-column: 2;
  grid-row: 1;
}

.chat-required-field.is-boolean input[type="checkbox"] {
  grid-column: 1;
  grid-row: 1;
  width: 16px;
  height: 16px;
  min-width: 16px;
}

.attach-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  padding: 4px 6px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--surface);
  font-size: 12px;
}

.attach-chip img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
}

.attach-chip .chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-chip .chip-remove {
  flex: none;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: var(--r-full);
  background: none;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.attach-chip .chip-remove:hover {
  color: var(--ink);
}

.turn-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.turn-thumb {
  max-width: 160px;
  max-height: 120px;
  border-radius: 10px;
  object-fit: cover;
}

.turn-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  font-size: 12px;
}

.turn-images {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.turn-image {
  max-width: min(360px, 100%);
  border-radius: 12px;
  display: block;
}

.turn-image-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.image-ref {
  padding: 3px 10px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-muted);
  font-size: 12px;
  cursor: pointer;
}

.image-ref:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.turn-audio {
  display: block;
  width: 100%;
  min-width: 0;
  margin-top: 0;
}

.turn-video {
  display: block;
  width: 100%;
  margin-top: 0;
  border-radius: 12px;
  background: #000;
}

.turn-body:not(:empty) > .turn-audio:not(:first-child),
.turn-body:not(:empty) > .turn-video:not(:first-child) {
  margin-top: 8px;
}

/* ===== Box console ===== */
.box-grid {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

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

.box-form-panel {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.box-result-panel {
  grid-column: 2;
  grid-row: 1;
}

.box-form-panel,
.box-result-panel,
.box-history-panel {
  min-width: 0;
}

.box-model-selectors {
  display: grid;
  grid-template-columns: minmax(0, 0.65fr) minmax(0, 1.35fr);
  gap: 10px;
  margin-bottom: 12px;
}

.box-model-select {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  font-weight: 600;
}

.box-model-select select {
  width: 100%;
  min-width: 0;
}

.box-model-description {
  margin: 0 0 4px;
}

.box-model-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.box-model-desc:not(.is-expanded) {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  overflow: hidden;
}

.box-model-desc.is-expandable {
  cursor: pointer;
}

.box-model-desc.is-expandable:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.box-model-desc-toggle {
  min-height: 0;
  margin: 3px 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--body);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.box-model-desc-toggle:hover {
  background: transparent;
  color: var(--ink);
}

.box-model-price {
  margin: 0 0 16px;
  font-size: 13px;
}

.box-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.box-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.box-field .req {
  color: #d0453b;
  margin-left: 3px;
}

.box-field input[type="text"],
.box-field input[type="number"],
.box-field select,
.box-field textarea {
  width: 100%;
}

.box-field textarea {
  resize: vertical;
  min-height: 64px;
  font: inherit;
}

.box-upload-control {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.box-file-native {
  position: absolute;
  width: 1px !important;
  height: 1px !important;
  min-width: 1px !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.box-file-trigger {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: auto;
  height: 36px;
  padding: 7px 14px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-full);
  background: var(--canvas);
  color: var(--ink);
  font-size: 13px !important;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.box-file-trigger:hover {
  border-color: var(--charcoal);
}

.box-upload-control:focus-within .box-file-trigger {
  outline: 3px solid var(--focus-ring);
  outline-offset: 1px;
}

.box-file-status {
  min-width: 0;
  overflow: hidden;
  color: var(--body);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.box-file-clear {
  height: 32px;
  padding: 5px 12px;
  color: var(--danger);
  font-size: 12px;
}

.box-field-boolean {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  column-gap: 10px;
  row-gap: 4px;
}

.box-field-boolean label {
  grid-column: 2;
  grid-row: 1;
  padding-top: 1px;
  cursor: pointer;
}

.box-field-boolean input[type="checkbox"] {
  grid-column: 1;
  grid-row: 1;
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin: 1px 0 0;
  padding: 0;
  border-radius: 4px;
  accent-color: var(--ink);
  cursor: pointer;
}

.box-field-boolean .box-field-desc {
  grid-column: 2;
  grid-row: 2;
}

.box-field-desc {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.4;
}

.box-file-preview {
  max-width: 120px;
  border-radius: 8px;
  margin-top: 6px;
}

.box-file-ready { font-size: 12px; }

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

.box-status {
  font-size: 13px;
  color: var(--ink-muted);
}

.box-placeholder {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 120px;
  justify-content: center;
  text-align: center;
  font-size: 14px;
}

.box-history-panel {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  padding-bottom: 12px;
}

.box-history-head h3 {
  margin: 0;
  font-size: 18px;
}

.box-history-head p {
  margin: 4px 0 14px;
  font-size: 13px;
}

.box-history-list {
  display: grid;
  max-height: 360px;
  overflow-y: auto;
  border-top: 1px solid var(--hairline);
  scrollbar-gutter: stable;
}

.box-history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  align-items: center;
  min-width: 0;
  border-bottom: 1px solid var(--hairline);
}

.box-history-item.active {
  background: var(--surface-soft);
}

.box-history-open {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: auto;
  min-width: 0;
  min-height: 62px;
  padding: 9px 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.box-history-open:hover {
  background: var(--surface-soft);
}

.box-history-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.box-history-copy strong,
.box-history-copy > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.box-history-copy strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.box-history-copy > span {
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 400;
}

.box-run-status {
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.box-run-status.failed {
  color: var(--danger);
}

.box-run-status.pending {
  color: var(--warn);
}

.box-history-delete {
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font-size: 18px;
  line-height: 1;
}

.box-history-delete:hover {
  color: var(--danger);
  background: var(--surface-soft);
}

.box-history-empty {
  margin: 0;
  padding: 16px 0 6px;
  border-top: 1px solid var(--hairline);
  font-size: 13px;
}

@media (max-width: 820px) {
  .box-form-panel,
  .box-result-panel,
  .box-history-panel {
    grid-column: 1;
    grid-row: auto;
  }

  .box-history-panel { order: -1; }
}

.box-media {
  max-width: 100%;
  border-radius: 12px;
  display: block;
  margin-bottom: 12px;
}

video.box-media { width: min(640px, 100%); background: #000; }
audio.box-media { width: 100%; }

.box-images {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.box-images .box-media { max-width: min(280px, 100%); margin-bottom: 0; }

.box-text {
  line-height: 1.6;
  margin-bottom: 12px;
}

.box-raw {
  margin-top: 10px;
  border-top: 1px solid var(--hairline);
  padding-top: 8px;
}

.box-raw summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-muted);
}

.box-raw pre {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  margin-top: 8px;
}

.notice.error,
.box-error {
  border-color: #d0453b;
  color: #b23a30;
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid var(--hairline);
  border-top-color: var(--ink);
  border-radius: 50%;
  display: inline-block;
  animation: box-spin 0.8s linear infinite;
}

@keyframes box-spin {
  to { transform: rotate(360deg); }
}

.chat-aside {
  display: grid;
  gap: 28px;
  align-content: start;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 2px;
}

.aside-block h4 {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.aside-block > p {
  font-size: 14px;
  line-height: 1.43;
}

.saved-list {
  display: grid;
}

.saved-item {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.saved-item > button:first-child {
  flex: 1;
  min-width: 0;
}

.saved-list button.saved-delete {
  flex: none;
  width: 26px;
  min-height: 26px;
  height: 26px;
  margin-left: 0;
  padding: 0;
  border: 0;
  background: none;
  border-radius: var(--r-full);
  color: var(--mute);
  font-size: 16px;
  line-height: 1;
  justify-content: center;
  text-align: center;
}

.saved-list button.saved-delete:hover {
  color: var(--danger);
  background: var(--surface-soft);
}

.saved-list button {
  justify-content: flex-start;
  width: 100%;
  height: auto;
  min-height: 34px;
  padding: 7px 12px;
  margin-left: -12px;
  border: 0;
  background: none;
  color: var(--body);
  font-size: 14px;
  font-weight: 400;
  text-align: left;
  white-space: nowrap;
}

.saved-list button span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-list button:hover {
  color: var(--ink);
}

.saved-list button.active {
  color: var(--ink);
  font-weight: 500;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 72px 20px;
  text-align: center;
}

.empty-state h3 {
  color: var(--ink);
  font-size: 20px;
  font-weight: 500;
}

.empty-state p {
  max-width: 360px;
  font-size: 14px;
}

/* ---------- Keys ---------- */

.key-create {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.secret-panel {
  display: grid;
  gap: 10px;
  margin-top: 20px;
  padding: 24px;
  border-radius: var(--r-lg);
  background: var(--surface-dark);
}

.secret-panel p {
  color: var(--on-dark-mute);
  font-size: 13px;
}

.secret {
  color: var(--on-dark);
  font: 400 13px/1.6 var(--mono);
  overflow-wrap: anywhere;
  user-select: all;
}

.api-base {
  margin-bottom: 16px;
}

/* ---------- Admin ---------- */

.admin-tabs,
.pill-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 40px;
}

.pill-tabs {
  margin-bottom: 24px;
}

.admin-tabs button,
.pill-tabs button {
  height: 34px;
  padding: 7px 18px;
  border-color: transparent;
  background: none;
  color: var(--body);
  font-size: 14px;
}

.admin-tabs button:hover,
.pill-tabs button:hover {
  color: var(--ink);
  border-color: var(--hairline-strong);
}

.admin-tabs button.active,
.pill-tabs button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-dark);
}

.tab-count {
  margin-left: 6px;
  font-size: 12px;
  opacity: 0.65;
}

.pill-tabs-main {
  margin-bottom: 10px;
}

.pill-tabs-sub {
  margin-bottom: 24px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
}

.pill-tabs-sub button {
  height: 30px;
  padding: 5px 14px;
  font-size: 13px;
}

/* ---------- Model catalog cards ---------- */

.model-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.model-toolbar input {
  flex: 1;
}

.model-toolbar select {
  width: auto;
  min-width: 170px;
}

.model-card {
  padding: 20px 24px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--canvas);
  margin-bottom: 12px;
  cursor: pointer;
}

.model-card:hover {
  border-color: var(--hairline-strong);
}

.model-card:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 1px;
}

.model-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.model-card-head h3 {
  color: var(--ink);
  font-family: var(--display);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
}

.model-card-tokens {
  margin-left: auto;
  color: var(--body);
  font-size: 13px;
  white-space: nowrap;
}

.model-card-desc {
  margin: 8px 0 10px;
  font-size: 14px;
  color: var(--body);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.model-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--charcoal);
}

.model-card-meta .sep {
  color: var(--hairline-strong);
}

#model-back {
  height: auto;
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--body);
}

#model-back:hover {
  color: var(--ink);
}

.model-detail-head h2 {
  margin-top: 8px;
  color: var(--ink);
  font: 500 30px/1.2 var(--display);
}

.model-detail-id {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 14px;
}

.model-detail-id .code {
  font-size: 13px;
}

.model-detail-id button {
  height: 28px;
  padding: 4px 14px;
  font-size: 12px;
}

.model-detail-head p {
  max-width: 720px;
  overflow-wrap: anywhere;
}

.check-list {
  display: grid;
  gap: 0;
  counter-reset: check;
}

.check-list div {
  display: flex;
  gap: 16px;
  align-items: baseline;
  padding: 14px 0;
  border-bottom: 1px solid var(--hairline);
}

.check-list div:last-child {
  border-bottom: 0;
}

.check-list div::before {
  counter-increment: check;
  content: counter(check);
  flex: none;
  color: var(--mute);
  font: 400 13px/1.4 var(--mono);
}

.check-list p {
  color: var(--charcoal);
  font-size: 14px;
}

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

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .page-chat {
    height: auto;
    min-height: calc(100dvh - var(--topnav-height));
  }

  .chat-layout {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }

  .chat-main {
    height: calc(100dvh - var(--topnav-height) - 44px);
  }

  .chat-aside {
    padding: 24px 2px 8px;
    border-top: 1px solid var(--hairline);
    overflow: visible;
  }

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

  .card-grid {
    gap: 12px;
  }
}

@media (max-width: 768px) {
  .topnav {
    flex-wrap: wrap;
    gap: 8px 20px;
    padding: 10px 20px;
  }

  .topnav nav {
    order: 3;
    flex-basis: 100%;
  }

  .topnav nav button {
    padding: 8px 12px;
  }

  .topnav-right .account {
    display: none;
  }

  .page {
    padding: 36px 20px 64px;
  }

  .page-chat {
    min-height: calc(100dvh - var(--topnav-height));
    padding: 16px 16px 14px;
  }

  .chat-main {
    height: calc(100dvh - var(--topnav-height) - 30px);
  }

  .page-head {
    margin-bottom: 28px;
  }

  .page-head h2 {
    font-size: 26px;
  }

  .section {
    margin-top: 44px;
  }

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

  .stats {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    margin: 28px 0 4px;
  }

  .stat,
  .stats-4 .stat {
    padding: 0;
    border-left: 0;
  }

  .panel {
    padding: 24px 20px;
  }

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

  .table {
    min-width: 560px;
  }

  .admin-users-table {
    min-width: 0;
  }

  .admin-users-table thead {
    display: none;
  }

  .admin-users-table,
  .admin-users-table tbody {
    display: block;
    width: 100%;
  }

  .admin-users-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 12px;
    padding: 18px 0;
    border-bottom: 1px solid var(--hairline);
  }

  .admin-users-table td {
    display: grid;
    gap: 6px;
    min-width: 0;
    padding: 0;
    border: 0;
  }

  .admin-users-table td::before {
    content: attr(data-label);
    color: var(--body);
    font-size: 12px;
    font-weight: 500;
  }

  .admin-users-table .admin-user-email,
  .admin-users-table .admin-user-actions-cell {
    grid-column: 1 / -1;
  }

  .admin-users-table .admin-user-email {
    min-width: 0;
  }

  .admin-users-table .user-actions {
    min-width: 0;
  }
}

@media (max-width: 560px) {
  button {
    height: 40px;
  }

  .topnav nav {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .topnav-right button,
  .table button {
    height: 32px;
  }

  .composer button {
    width: 40px;
    height: 40px;
  }

  .auth-inner h1 {
    font-size: 30px;
  }

  .auth-card {
    padding: 22px 18px;
  }

  .key-create {
    grid-template-columns: minmax(0, 1fr);
  }

  .chat-toolbar {
    flex-wrap: wrap;
  }

  .chat-toolbar select {
    max-width: 100%;
    flex: 1 1 100%;
  }

  .chat-required {
    grid-template-columns: minmax(0, 1fr);
  }
}
