@font-face {
  font-family: "DM Sans Fallback";
  src: local("Hiragino Sans"), local(".AppleSystemUIFont"), local("Segoe UI"), local("Arial");
  size-adjust: 94%;
  ascent-override: 95%;
  descent-override: 24%;
  line-gap-override: 0%;
}

:root {
  --bg: #f6f4f6;
  --surface: #ffffff;
  --ink: #1a1216;
  --muted: #6e5d66;
  --line: #eadfe4;
  --line-strong: #dbc8d1;
  --accent: #db2777;
  --accent-hover: #be185d;
  --accent-soft: #fdf2f8;
  --accent-ring: rgba(219, 39, 119, 0.28);
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --info: #2563eb;
  --info-soft: #eff6ff;
  --sidebar: #ffffff;
  --shadow: 0 1px 2px rgba(26, 18, 22, 0.06), 0 8px 24px rgba(26, 18, 22, 0.06);
  --shadow-lg: 0 8px 32px rgba(26, 18, 22, 0.12);
  --radius: 12px;
  --font: "DM Sans", "DM Sans Fallback", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --sidebar-w: 232px;
  --sheet-w: 440px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; overflow-x: clip; }
.hidden, [hidden] { display: none !important; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100%;
}

/* —— Sidebar —— */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.brand-name { font-weight: 650; font-size: 13.5px; letter-spacing: -0.02em; line-height: 1.2; }
.brand-sub { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.mobile-nav-toggle { display: none; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 550;
  text-decoration: none;
}
.nav-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-btn:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); }
.nav-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.sidebar-foot a,
.sidebar-foot button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.sidebar-foot a:hover,
.sidebar-foot button:hover { background: var(--bg); color: var(--ink); text-decoration: none; }

/* —— Main —— */
.main { min-width: 0; width: 100%; max-width: 1600px; padding: 32px 40px 56px; }
.page-head { margin-bottom: 20px; }
.page-head h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.03em;
}
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }

.view.hidden { display: none; }

/* —— Filters —— */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.grow { flex: 1; min-width: 180px; }
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.field input,
.field select,
.input, .select {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  min-width: 0;
}
.field input:focus,
.field select:focus,
.input:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.btn {
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 13.5px;
}
.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.btn-link:hover { text-decoration: none; }
.btn:hover { background: var(--accent-hover); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}
.btn-secondary:hover { background: var(--bg); }
.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid transparent;
}
.btn-danger:hover { background: #fee2e2; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 0;
  height: 32px;
  padding: 0 8px;
}
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* —— Table card —— */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table-wrap { overflow: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data th {
  text-align: left;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 14px;
  background: #faf8fa;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
#rows tr { cursor: pointer; transition: background 160ms ease; }
#rows tr:hover { background: var(--accent-soft); }
#rows tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#key-rows tr:hover { background: transparent; }
.cell-id { font-weight: 600; letter-spacing: -0.02em; }
.cell-muted { color: var(--muted); }
.cell-ellipsis {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}
.empty strong, .empty span { display: block; }
.empty strong { color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.loading-row, .loading-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 120px;
  color: var(--muted);
}
.loading-row span, .loading-card span {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* —— Status —— */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--bg);
  color: var(--muted);
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill-pending { background: #f4f4f5; color: #52525b; }
.pill-in_progress { background: var(--info-soft); color: var(--info); }
.pill-generate_complete { background: #ecfeff; color: #0e7490; }
.pill-awaiting_domain { background: var(--warn-soft); color: var(--warn); }
.pill-domain_configured { background: #f5f3ff; color: #6d28d9; }
.pill-active { background: var(--ok-soft); color: var(--ok); }
.pill-failed { background: var(--danger-soft); color: var(--danger); }
.pill-blocked { background: var(--accent-soft); color: var(--accent); }

/* The stored gate reading, in the sites list. `unchecked` is deliberately the
   dullest of the four: it is an absence of evidence, not a pass. */
.pill-error { background: var(--danger-soft); color: var(--danger); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-muted { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

.link-quiet { color: var(--ink); font-weight: 550; }
.link-quiet:hover { color: var(--accent); }

/* —— Keys —— */
.keys-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}
#key-form { display: flex; gap: 8px; align-items: end; }
#key-form .field { min-width: 240px; }
.flash {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  background: var(--accent-soft);
  border: 1px solid #f9c2d8;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.flash:empty,
.flash.hidden,
.flash[hidden] { display: none !important; }
.flash code {
  display: block;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 12.5px;
  word-break: break-all;
  color: var(--ink);
}
.mono { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* —— Overlay + sheet —— */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 18, 22, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 40;
}
.overlay.open { opacity: 1; pointer-events: auto; display: block; }
.overlay[hidden] { display: none !important; }

.sheet {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(var(--sheet-w), 100%);
  max-width: 100vw;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
.sheet.open { transform: translateX(0); }
.sheet.sheet-wide { width: min(720px, 100%); }
.copy-frame {
  width: 100%;
  height: 420px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.repeat-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.repeat-row:last-child { border-bottom: 0; }
.details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 640px) {
  .details-grid { grid-template-columns: 1fr; }
}
.sheet[hidden] { display: none !important; }

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.sheet-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.3;
}
.sheet-kicker {
  margin: 4px 0 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--line); }
.icon-btn svg { width: 16px; height: 16px; }

.sheet-body {
  flex: 1;
  overflow: auto;
  padding: 16px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.sheet-foot {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.sheet-foot .btn { flex: 1; }

.section-title {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.stack { display: flex; flex-direction: column; gap: 10px; }
.dns-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
  font-size: 12.5px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 8px;
}
.dns-row dt { color: var(--muted); font-weight: 600; }
.dns-row dd { margin: 0; font-family: var(--mono); font-size: 12px; word-break: break-all; }
.dns-row--primary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-2, #f8fafc);
}
.dns-row--primary dt { color: var(--ink, inherit); }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}
.switch-row span { font-weight: 550; }
.switch {
  position: relative;
  width: 40px;
  height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i {
  position: absolute;
  inset: 0;
  background: #d6ccd1;
  border-radius: 999px;
  transition: background 160ms ease;
}
.switch i::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  transition: transform 160ms ease;
}
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px var(--accent-ring); }

.qa { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.qa + .qa { margin-top: 8px; }
.qa summary {
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.qa summary::-webkit-details-marker { display: none; }
.qa p { margin: 0; padding: 0 12px 12px; color: var(--muted); font-size: 13px; }

.review {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.review + .review { margin-top: 8px; }
.review-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.review p { margin: 0; }

.event-list { list-style: none; margin: 0; padding: 0; }
.event-list li {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.event-list li:last-child { border-bottom: 0; }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
  margin-top: 5px;
}
.dot-error { background: var(--danger); }
.dot-success { background: var(--ok); }
.dot-warn { background: var(--warn); }
.event-time { color: var(--muted); font-size: 11px; }

.links-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* —— Login —— */
.login-body {
  min-height: 100%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 15% 15%, rgba(219, 39, 119, 0.12), transparent 32rem),
    linear-gradient(145deg, #fff 0%, var(--bg) 62%);
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 36px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 { margin: 0; font-size: 20px; letter-spacing: -0.03em; }
.login-brand { padding: 0; }
.login-card .lede { margin: 0; color: var(--muted); }
.login-card .field { width: 100%; }
.login-card .btn { width: 100%; }
.login-foot { margin: 4px 0 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; text-align: center; }
.login-card::before {
  content: "Operations";
  align-self: flex-start;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.err { color: var(--danger); margin: 0; font-size: 13px; }

body.sheet-open { overflow: hidden; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 8px 10px;
    gap: 4px;
  }
  .brand { padding: 0; flex-shrink: 0; }
  .brand > div:last-child { display: none; }
  .mobile-nav-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
  }
  .mobile-nav-toggle svg { width: 18px; height: 18px; }
  .nav {
    display: none;
    flex: 1 0 100%;
    order: 3;
    padding-top: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sidebar.nav-open .nav { display: grid; }
  .nav-btn { width: 100%; padding: 10px; }
  .nav-btn span { display: inline; }
  .sidebar-foot {
    flex-direction: row;
    border: 0;
    padding: 0;
    flex-shrink: 0;
  }
  .sidebar-foot a span,
  .sidebar-foot button span { display: none; }
  .main { padding: 20px 14px 40px; }
  .page-head h1 { font-size: 18px; }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .field.grow { min-width: 0; }
  .toolbar .btn { width: 100%; }
  #key-form {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  #key-form .field { min-width: 0; width: 100%; }
  .flash { flex-direction: column; }
  .sheet { width: 100%; }
  .sheet-foot { flex-wrap: wrap; }
  .sheet-foot .btn { flex: 1 1 calc(50% - 8px); }
  .cell-ellipsis { max-width: 42vw; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet, .overlay, table.data tbody tr { transition: none; }
}

/* —— Pager —— */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.pager-summary { display: flex; align-items: center; gap: 14px; }
.pager-info { color: var(--muted); font-size: 12.5px; }
.pager-size { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.pager-size select {
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
}
.pager-buttons, .pager-pages { display: flex; align-items: center; gap: 6px; }
.pager-page {
  min-width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
}
.pager-page:hover { background: var(--accent-soft); border-color: var(--accent); }
.pager-page.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager-gap { color: var(--muted); padding: 0 2px; }
.pager-edge { width: 34px; padding: 0; }
.pager .btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* —— Site workspace —— */
.site-detail { display: flex; flex-direction: column; gap: 16px; }
.site-detail-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.back-link { align-self: flex-start; color: var(--muted); font-size: 13px; font-weight: 600; }
.site-detail-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
.site-kicker { color: var(--muted); font-family: var(--mono); font-size: 12px; margin-bottom: 7px; }
.site-status-row { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.site-tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 6px;
  background: rgba(246, 244, 246, .94);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(12px);
}
.site-tabs button {
  flex: 0 0 auto;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
}
.site-tabs button:hover { color: var(--ink); background: var(--surface); }
.site-tabs button.active { color: var(--accent); background: var(--surface); box-shadow: var(--shadow); }
.site-tab-panel { display: flex; flex-direction: column; gap: 16px; }
.site-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.detail-card { padding: 20px; overflow: visible; }
.detail-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.detail-card-head h2 { margin: 0; font-size: 16px; letter-spacing: -.02em; }
.detail-card-head p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.detail-note { margin: 6px 0 0; }
.metric-card {
  flex: 1 1 180px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.metric-card span { color: var(--muted); font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.metric-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.copy-frame { height: min(72vh, 850px); min-height: 580px; }
.detail-card .repeat-row {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px;
  margin-bottom: 8px;
  background: var(--bg);
}
.detail-card .repeat-row:last-child { border-bottom: 1px solid var(--line); }
.switch-row > span:first-child { display: flex; flex-direction: column; gap: 2px; }
.switch-row small { color: var(--muted); font-weight: 400; font-size: 11.5px; }

@media (max-width: 900px) {
  .site-grid { grid-template-columns: 1fr; }
  .site-detail-title { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 640px) {
  .pager { align-items: stretch; flex-direction: column; }
  .pager-summary { justify-content: space-between; }
  .pager-buttons { justify-content: space-between; }
  .pager-pages { overflow-x: auto; }
  .detail-card { padding: 14px; }
  .detail-card-head { flex-direction: column; }
  .copy-frame { min-height: 480px; }
}

/* —— Toasts —— */
.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 40px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast::before {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--info);
}
.toast-error { border-color: #f3b6b6; background: var(--danger-soft); }
.toast-error::before { background: var(--danger); }
.toast-ok { border-color: #a7e3c9; background: var(--ok-soft); }
.toast-ok::before { background: var(--ok); }
.toast-msg { flex: 1; word-break: break-word; }

.btn[aria-busy="true"] { opacity: 0.6; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

.flash-error {
  background: var(--danger-soft);
  border-color: #f3b6b6;
}

/* ——————————————————————————————————————————————————————————————
   Hearing form
   Two columns: a sticky rail that reports what the build will do,
   and the questions themselves in the order they get asked.
   —————————————————————————————————————————————————————————————— */

.hearing {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.rail {
  position: sticky;
  top: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rail-modes { display: flex; flex-direction: column; gap: 6px; }
.mode {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}
.mode:hover { border-color: var(--accent); }
.mode input { margin-top: 2px; accent-color: var(--accent); flex-shrink: 0; }
.mode:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.mode:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.mode-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mode-title { font-size: 13px; font-weight: 600; line-height: 1.25; }
.mode-note { font-size: 11.5px; color: var(--muted); line-height: 1.35; }

.rail-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}
.rail-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.rail-item:last-child { border-bottom: 0; }
.rail-item:hover { background: var(--bg); text-decoration: none; }
.rail-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.rail-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.rail-text b { font-size: 12.5px; font-weight: 600; letter-spacing: -0.01em; }
.rail-text i { font-style: normal; font-size: 11px; color: var(--muted); }

/* The dot is the state: filled = captured, ring = the agent will fill it,
   hollow = staying off the site. */
.rail-dot {
  width: 8px; height: 8px; border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  flex-shrink: 0;
}
.rail-item[data-state="done"] .rail-dot { background: var(--ok); border-color: var(--ok); }
.rail-item[data-state="auto"] .rail-dot { border-color: var(--info); border-style: dashed; }
.rail-item[data-state="todo"] .rail-dot { border-color: var(--warn); background: var(--warn-soft); }
.rail-count {
  font-size: 11px;
  font-weight: 650;
  color: var(--muted);
  background: var(--bg);
  border-radius: 999px;
  padding: 1px 7px;
}

.outlook {
  border: 1px solid var(--line-strong);
  border-left-width: 3px;
  border-radius: 10px;
  padding: 11px 13px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.outlook-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
.outlook-title { font-size: 12.5px; font-weight: 650; letter-spacing: -0.01em; }
.outlook-body { margin: 0; font-size: 11.5px; line-height: 1.45; color: var(--muted); }
.outlook[data-tone="browse"] { border-left-color: var(--info); background: var(--info-soft); }
.outlook[data-tone="direct"] { border-left-color: var(--ok); background: var(--ok-soft); }
.outlook[data-tone="blocked"] { border-left-color: var(--warn); background: var(--warn-soft); }

.rail-actions { display: flex; gap: 8px; }
.rail-actions .btn { flex: 1; }
.rail-actions .btn[disabled] { opacity: 0.5; pointer-events: none; }

/* —— the questions —— */
.hearing-panel { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.hcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  scroll-margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hcard-title { margin: 0; font-size: 14.5px; font-weight: 650; letter-spacing: -0.02em; }
.hcard-note { margin: -6px 0 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.hgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hgrid-3 { grid-template-columns: repeat(3, 1fr); }
.color-preset-swatches {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.color-swatch-label {
  font-size: 12px;
  color: var(--muted);
}
.field-help { font-size: 11px; color: var(--muted); }
.textarea { height: auto; padding: 9px 12px; line-height: 1.5; resize: vertical; font: inherit; }
.req { color: var(--warn); font-weight: 600; }

/* Maps-link mode: the shop details become optional, the link becomes required. */
.only-maps { display: none; }
#h-panel[data-mode="maps_link"] .only-maps { display: inline; }
#h-panel[data-mode="maps_link"] .hcard-note.only-maps { display: block; }

.repeat { display: flex; flex-direction: column; gap: 10px; }
.repeat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.repeat-head h3 { margin: 0; font-size: 12px; font-weight: 650; color: var(--muted); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.repeat-list { display: flex; flex-direction: column; gap: 10px; }
.repeat-list:empty { display: none; }
.hearing .repeat-row {
  position: relative;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
}
.hearing .repeat-body { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.hearing .repeat-grid { display: grid; gap: 10px; }
.hearing .repeat-grid-review { grid-template-columns: 1fr 90px 130px; }
.hearing .repeat-grid-social { grid-template-columns: 140px 1fr; }
.hearing .repeat-grid-photo { grid-template-columns: 1fr 140px; }
.hearing .repeat-remove { flex-shrink: 0; }

@media (max-width: 1080px) {
  .hearing { grid-template-columns: 1fr; }
  .rail { position: static; }
  .rail-list { order: -1; }
}
@media (max-width: 720px) {
  .hgrid, .hgrid-3, .repeat-grid-review, .repeat-grid-social, .repeat-grid-photo {
    grid-template-columns: 1fr;
  }
}

/* ——————————————————————————————————————————————————————————————
   Google Sheet panel
   —————————————————————————————————————————————————————————————— */

.sheet-panel { padding: 0; }
.sheet-status { padding: 20px; color: var(--muted); font-size: 13.5px; }
.conn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }
.conn[data-state="down"] .conn-dot { background: var(--danger); }
.conn-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.conn-title { font-size: 13.5px; font-weight: 600; }
.conn-sub { font-size: 12px; color: var(--muted); }
.conn-link { margin-left: auto; font-size: 12.5px; font-weight: 600; }

.sync-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.sync-cell { background: var(--surface); padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; }
.sync-cell h3 { margin: 0; font-size: 13.5px; font-weight: 650; letter-spacing: -0.02em; }
.sync-cell p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; flex: 1; }
.sync-cell .btn { align-self: flex-start; }
.sync-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
}
.sync-meta b { color: var(--ink); font-weight: 600; }
.auto-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  font-size: 12.5px;
  color: var(--muted);
}
.auto-pill {
  font-size: 11px;
  font-weight: 650;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok);
}
.auto-pill[data-state="off"] { background: var(--bg); color: var(--muted); }
.auto-pill[data-state="error"] { background: var(--danger-soft); color: var(--danger); }

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

/* ------------------------------------------------------------- AI models */

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

.model-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
}

.model-card { padding: 18px 20px 16px; display: flex; flex-direction: column; gap: 16px; }

.model-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 24px;
}
.model-head h3 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: -0.02em; }
.model-blurb {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  max-width: 62ch;
}

.model-grid { display: grid; gap: 14px; }
.field-hint {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.45;
  min-height: 1.45em;
}
.model-warn { color: var(--accent); font-weight: 600; }

.model-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.model-foot .mono { word-break: break-all; }
.model-actions { display: flex; gap: 8px; }

/* Key state, at a glance: saved here, inherited from .env, or missing. */
.key-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  background: var(--bg);
}
.key-pill[data-state="on"] { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.key-pill[data-state="env"] { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.key-pill[data-state="error"] { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }

.probe {
  font-size: 12.5px;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
}
.probe[data-state="ok"] { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.probe[data-state="error"] { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }

.keys-table td { vertical-align: middle; }
.keys-table .input { max-width: 320px; }
.keys-table .base-url { margin-top: 6px; }
.key-mask { display: block; margin-top: 4px; }
.key-cell-actions { display: flex; gap: 8px; white-space: nowrap; }
.row-link { display: block; font-size: 11.5px; margin-top: 2px; }

.flash-warn { background: #fffbeb; border-color: #fde68a; }

/* ----------------------------------------------------------------- usage */

.usage-panel { display: flex; flex-direction: column; gap: 16px; }
.usage-panel .card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line);
}
.usage-panel .card-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.usage-panel .card-head .cell-muted { font-size: 11.5px; }
.usage-panel .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.usage-panel .cell-strong { font-weight: 600; letter-spacing: -0.01em; }
.usage-panel .cell-muted { color: var(--muted); font-size: 11.5px; }
/* A low cache-hit rate is the one number on this page that should nag. */
.usage-panel .cell-warn { color: var(--warn); font-weight: 650; }
.usage-window-note { flex: 1; min-width: 200px; align-self: end; padding-bottom: 8px; }

.usage-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(184px, 1fr));
  gap: 12px;
}
.usage-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.usage-tile-warn { border-color: #fde68a; background: var(--warn-soft); }
.usage-tile-label {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.usage-tile-value {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.usage-tile-hint { font-size: 11.5px; color: var(--muted); line-height: 1.45; }

.usage-table tbody tr.usage-row { cursor: pointer; transition: background 160ms ease; }
.usage-table tbody tr.usage-row:hover { background: var(--accent-soft); }

.usage-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.usage-bar-cell { width: 40%; min-width: 90px; }
.usage-bar {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  opacity: 0.85;
}

/* ---------------------------------------------------------------- agent live view
   The only part of the site panel that changes while you are looking at it, so it
   sits at the top and carries its own state colour. A build has no wall clock —
   "no activity for 4m" is the signal, not elapsed time. */

.agent-live {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  background: var(--surface);
  margin-bottom: 18px;
}

.agent-live-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.agent-live-head .section-title { margin: 0; }

.agent-state {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--info-soft);
  color: var(--info);
  white-space: nowrap;
}
.agent-state-live { background: var(--ok-soft); color: var(--ok); }
.agent-state-warn { background: var(--warn-soft); color: var(--warn); }
.agent-state-stalled { background: var(--danger-soft); color: var(--danger); }
.agent-state-idle { background: var(--bg); color: var(--muted); }

/* A live run pulses; a stalled or finished one deliberately does not. */
.agent-state-live::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: agent-pulse 1.6s ease-in-out infinite;
}
@keyframes agent-pulse { 0%, 100% { opacity: 1 } 50% { opacity: 0.25 } }
@media (prefers-reduced-motion: reduce) {
  .agent-state-live::before { animation: none; }
}

.agent-now {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  word-break: break-word;
}

.agent-stream {
  margin: 8px 0 0;
  padding: 8px 10px;
  /* Tall enough to read: the pane holds the whole run's words now, not the
     last 2,000 characters of the call in flight. */
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* The reasoning pane, held apart from the output pane. Dimmer and italic:
   it is the model talking to itself, not the site being written. */
.agent-think-wrap {
  margin-top: 8px;
}

.agent-stream-label {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: .75;
}

.agent-think {
  margin-top: 4px;
  font-style: italic;
  opacity: .8;
}

.agent-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.agent-log {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
}

.agent-row {
  display: flex;
  gap: 10px;
  padding: 5px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
}
.agent-row:last-child { border-bottom: 0; }
.agent-row-time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.agent-row-text { color: var(--ink); word-break: break-word; }
.agent-row-text code {
  font-family: var(--mono);
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 5px;
}
.agent-row-error .agent-row-text { color: var(--danger); }

.agent-actions { margin-top: 12px; }

/* A provider the active engine cannot drive means this phase silently ships a
   template site. Said here, before a build, rather than only in its log. */
.model-incompatible {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

/* ---------------------------------------------------------------- templates */
/* The design catalogue, and a shuffle an operator can trust. Previews are real
   renderer output in a sandboxed iframe, scaled down — not a mock-up. */
.templates-panel { display: grid; gap: 16px; }

.tpl-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.tpl-stats > div { display: grid; gap: 2px; }
.tpl-stats strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.tpl-stats span { font-size: 12px; color: var(--muted, #64748b); }
.tpl-note { margin: 12px 0 0; font-size: 12px; line-height: 1.6; }

.tpl-controls { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; }
.tpl-controls label { display: grid; gap: 4px; font-size: 12px; }
.tpl-controls input, .tpl-controls select { min-height: 34px; }
.tpl-controls input[data-f="count"] { width: 84px; }
.tpl-controls input[data-f="seed"] { width: 130px; }
.tpl-verdict { margin: 12px 0 0; font-size: 13px; }
.tpl-verdict.is-ok { color: #15803d; }
.tpl-verdict.is-warn { color: #b45309; }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.tpl-card { border: 1px solid var(--line, #e2e8f0); border-radius: 10px; overflow: hidden; background: #fff; }
.tpl-card__head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--line, #e2e8f0); }
.tpl-card__n { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted, #64748b); }
/* The frame is a 1440px page shown at a third of its size, so the layout is
   judged at the width it was designed for rather than at card width. */
/*
   The preview frame is a real 1440px page, scaled by an exact ratio.

   The card width is FIXED at 432px for that reason: 1440 x 0.3 = 432, so the
   whole page fits with nothing clipped. A responsive column width cannot work
   here — `transform: scale()` needs a unitless ratio, and `calc(100cqw / 1440)`
   is a length, so the declaration is simply dropped and the preview renders at
   1:1. (It did, and every card showed a 40px wordmark.) Fixing the width is the
   honest fix; the grid centres instead of stretching.
*/
.tpl-card__frame {
  position: relative; overflow: hidden;
  background: #f6f7f9;
  block-size: 330px;
}
.tpl-frame {
  inline-size: 1440px; block-size: 1100px; border: 0;
  transform: scale(.3);
  transform-origin: top left;
  position: absolute; inset-block-start: 0; inset-inline-start: 0;
  pointer-events: none;
}
.tpl-card__recipe { display: flex; flex-wrap: wrap; gap: 4px 8px; padding: 9px 10px; border-top: 1px solid var(--line, #e2e8f0); }
.tpl-kv { font-size: 11px; color: #334155; }
.tpl-kv em { color: var(--muted, #94a3b8); font-style: normal; margin-inline-end: 3px; }

.tpl-pals { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; margin: 8px 0 20px; }
.tpl-pal { display: grid; gap: 4px; }
.tpl-pal__bg { display: flex; gap: 3px; align-items: center; justify-content: center; block-size: 34px; border: 1px solid var(--line, #e2e8f0); border-radius: 6px; }
.tpl-pal__ink, .tpl-pal__acc { inline-size: 13px; block-size: 13px; border-radius: 50%; }
.tpl-pal__name { font-size: 10px; color: var(--muted, #64748b); text-align: center; }

.tpl-axes { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.tpl-axis { border: 1px solid var(--line, #e2e8f0); border-radius: 8px; padding: 9px 10px; }
.tpl-axis.is-heavy { border-color: #cbd5e1; background: #f8fafc; }
.tpl-axis__head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12px; margin-bottom: 6px; }
.tpl-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.tpl-chip { font-size: 11px; padding: 2px 7px; border: 1px solid var(--line, #e2e8f0); border-radius: 999px; color: #334155; }
.tpl-chip.is-base { border-style: dashed; color: var(--muted, #94a3b8); }
.tpl-chip em { font-style: normal; color: #b45309; }

/* ---- Templates: the design gallery -------------------------------------- */
.tpl-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tpl-tabs button {
  min-height: 34px; padding: 0 14px;
  border: 1px solid var(--line, #e2e8f0); border-radius: 999px;
  background: #fff; color: #334155; font-size: 13px; cursor: pointer;
}
.tpl-tabs button.is-on { background: #0f172a; border-color: #0f172a; color: #fff; }

/* The card grid runs wider for the gallery: a design is judged at a size where
   its composition is legible, and 300px is a thumbnail. */
.tpl-grid { grid-template-columns: repeat(auto-fill, 432px); justify-content: center; }
.tpl-card--template .tpl-card__frame { block-size: 330px; }
.tpl-card__id { display: grid; gap: 1px; min-width: 0; }
.tpl-card__id strong { font-size: 14px; }
.tpl-card__id span { font-size: 11px; }
.tpl-card__tags { display: flex; gap: 4px; flex: 0 0 auto; }
.tpl-tag {
  font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px;
  border: 1px solid var(--line, #e2e8f0); color: var(--muted, #64748b);
}
.tpl-tag.is-safe { border-color: #15803d; color: #15803d; }
.tpl-card__note {
  margin: 0; padding: 9px 10px 0;
  font-size: 11.5px; line-height: 1.65; color: #475569;
}
.tpl-card__meta {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex-wrap: wrap; padding: 9px 10px;
}
.tpl-scene { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted, #64748b); }
.tpl-scene select { min-height: 30px; font-size: 11px; max-width: 130px; }
.tpl-ref { font-size: 10px; }
.tpl-card__pins { border-top: 1px solid var(--line, #e2e8f0); }
.tpl-card__pins summary { padding: 7px 10px; font-size: 11px; color: var(--muted, #64748b); cursor: pointer; }
.tpl-card__pins .tpl-card__recipe { border-top: 0; padding-top: 0; }


/* ------------------------------------------------------------------ prompts */
/*
 * `.card` in this panel carries a border and a radius and *no padding* — the
 * tables fill it edge to edge — so every prompt card supplies its own, the way
 * `.model-card` does. Getting that wrong is what put the annotation text flush
 * against the border and running past it.
 */

.prompt-stack { display: flex; flex-direction: column; gap: 16px; }
.prompt-sections { display: flex; flex-direction: column; gap: 10px; }

.prompt-panel { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.prompt-panel h3 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: -0.02em; }

.prompt-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.prompt-tab__dot { font-size: 9px; vertical-align: middle; opacity: 0.85; }

.prompt-summary {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.prompt-summary__id { min-width: 0; flex: 1 1 22rem; }
.prompt-summary__tags { display: flex; flex-wrap: wrap; gap: 6px; }
.prompt-summary__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

/* ---- the collapsed row: a real button, so it looks and behaves clickable ---- */

.prompt-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto 1.25rem;
  align-items: start;
  gap: 14px;
  width: 100%;
  padding: 14px 18px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: background 160ms ease;
}
.prompt-row:hover { background: var(--accent-soft); }
.prompt-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.prompt-row__no {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.7;
  color: var(--muted);
}
.prompt-row__main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.prompt-row__title { font-size: 13.5px; font-weight: 650; letter-spacing: -0.01em; }
.prompt-row__parent {
  margin-left: 8px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
}
/* The annotation is the point of the row, so it wraps rather than truncating —
   but it is measured, because a 120-character line is not a label. */
.prompt-row__about {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
  max-width: 78ch;
}
.prompt-row__tags { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.prompt-row__bytes { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.prompt-row__chev { color: var(--muted); font-size: 11px; line-height: 1.9; text-align: right; }

.prompt-card--open .prompt-row { border-bottom: 1px solid var(--line); }
.prompt-card--off { background: var(--bg); }
.prompt-card--off .prompt-row__title { text-decoration: line-through; text-decoration-color: var(--line-strong); }

/* ---- the open editor ---- */

.prompt-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 14px; }

.prompt-editor {
  width: 100%;
  /* `.input` is sized for a single line and its fixed height wins over `rows`,
     which collapsed the editor to one row showing only the heading. */
  height: auto;
  min-height: 18rem;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.65;
  padding: 12px 14px;
  tab-size: 2;
}

.prompt-body__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.prompt-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.pill-edited { background: var(--accent-soft); color: var(--accent); }
.pill-off { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.pill-unsaved { background: #fffbeb; color: #92400e; }

@media (max-width: 46rem) {
  .prompt-row { grid-template-columns: minmax(0, 1fr) 1.25rem; gap: 8px; }
  .prompt-row__no { display: none; }
  .prompt-row__tags { grid-column: 1 / -1; }
}

/* ------------------------------------------------------- gate screenshots */
/* Three viewports × every page. Sized so a row of them is scannable and a click
   opens the full-page PNG, which is where a layout problem is actually visible. */
.gate-shots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.gate-shot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  color: var(--muted);
  font-size: 12px;
}
.gate-shot img {
  width: 100%;
  /* Full-page screenshots are very tall; show the top and clip the rest. */
  height: 170px;
  object-fit: cover;
  object-position: top;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
.gate-shot:hover img { border-color: var(--accent); }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Build mode card: one-shot vs the agent loop. Two radio rows and a Save. */
.model-body { padding: 14px 16px 16px; display: grid; gap: 12px; }
.radio-row {
  display: grid; grid-template-columns: auto 1fr; gap: 10px;
  align-items: start; cursor: pointer; line-height: 1.55;
}
.radio-row input { margin-top: 4px; }
.radio-row span { font-size: 13px; color: var(--muted, #556); }
.radio-row strong { color: var(--ink, #111); }
.radio-row code {
  font-size: 12px; padding: 1px 4px; border-radius: 3px;
  background: rgba(0, 0, 0, .06);
}
