:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #15181d;
  --muted: #5b6573;
  --line: #d9dee6;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --danger: #b42318;
  --ok: #107c41;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216;
    --surface: #181c22;
    --text: #e8ebf0;
    --muted: #9aa4b2;
    --line: #2a313b;
    --accent: #6ea8ff;
    --accent-text: #0b1220;
    --danger: #ff8a80;
    --ok: #63d19a;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1216;
  --surface: #181c22;
  --text: #e8ebf0;
  --muted: #9aa4b2;
  --line: #2a313b;
  --accent: #6ea8ff;
  --accent-text: #0b1220;
  --danger: #ff8a80;
  --ok: #63d19a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.top .muted { margin-right: auto; }

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px;
}

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

/* A section the portal nav has switched away from. */
.stack[hidden] { display: none; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}

.panel h2 { margin: 0 0 12px; font-size: 17px; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 13px; color: var(--muted); }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  min-width: 0;
  max-width: 100%;
}

textarea { width: 100%; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

button, .tabs a {
  font: inherit;
  cursor: pointer;
  border-radius: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--danger); }
button.ghost { background: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* One pill-shaped bar that scrolls sideways, as in the hub's section nav. It never wraps to a second row. */
.tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  margin-bottom: 16px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.tabs a {
  border: 0;
  border-radius: 999px;
  padding: 6px 13px;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
}

.tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-text); }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.tag.ok { color: var(--ok); border-color: var(--ok); }
.tag.warn { color: var(--danger); border-color: var(--danger); }

.scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.stat strong { font-size: 20px; overflow-wrap: anywhere; }

code, .secret, .link { overflow-wrap: anywhere; word-break: break-all; font-size: 13px; }
.result { white-space: pre-wrap; overflow-x: auto; background: var(--bg); padding: 12px; border-radius: 6px; margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); }
.ok { color: var(--ok); }

@media (max-width: 480px) {
  .wrap { padding: 16px; }
  .top { padding: 12px 16px; }
  .row > * { flex: 1 1 100%; }
  .field { width: 100%; }
}

/* Assistant chat and asset library */
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow-y: auto; margin: 8px 0; }
.turn { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.turn.affiliate { background: var(--bg); }
.turn p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; min-width: 0; }
.asset { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-top: 1px solid var(--line); }
.asset:first-of-type { border-top: 0; }
.asset a { overflow-wrap: anywhere; }
.copy { margin: 0; padding: 8px; white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); font: inherit; }
