/* Ferrite: the one stylesheet of every page. No web fonts. */

:root {
  color-scheme: light dark;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f5f6f8;
  --bg-tint: #fbeee6;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --sunken: #f1f3f6;
  --border: #e3e6eb;
  --border-strong: #cdd2da;
  --text: #14171c;
  --text-2: #4b5360;
  --text-3: #5f6875;
  --accent: #b4461b;
  --accent-strong: #933812;
  --accent-soft: #fdf1ea;
  --accent-ring: rgba(180, 70, 27, .35);
  --primary: #15181d;
  --primary-hover: #2b3039;
  --on-primary: #ffffff;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --danger-border: #f5c2bd;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --ok-border: #abefc6;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px -6px rgba(16, 24, 40, .10);
  --shadow-lg: 0 1px 3px rgba(16, 24, 40, .06), 0 24px 48px -12px rgba(16, 24, 40, .18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0e12;
    --bg-tint: #24140c;
    --surface: #15181e;
    --surface-2: #1a1e25;
    --sunken: #11141a;
    --border: #272c35;
    --border-strong: #363c47;
    --text: #eef0f3;
    --text-2: #b4bac4;
    --text-3: #98a0ac;
    --accent: #f2945f;
    --accent-strong: #f7b089;
    --accent-soft: #2a1a12;
    --accent-ring: rgba(242, 148, 95, .45);
    --primary: #eef0f3;
    --primary-hover: #ffffff;
    --on-primary: #12151a;
    --danger: #ff8a80;
    --danger-soft: #2a1513;
    --danger-border: #5c2a25;
    --ok: #6ee7a8;
    --ok-soft: #0f241a;
    --ok-border: #1e4d36;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px -6px rgba(0, 0, 0, .5);
    --shadow-lg: 0 1px 3px rgba(0, 0, 0, .4), 0 24px 48px -12px rgba(0, 0, 0, .65);
  }
}

/* --- base ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: anywhere;
}

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; letter-spacing: -.015em; color: var(--text); }
h1 { font-size: 1.6rem; font-weight: 650; }
h2 { font-size: 1.05rem; font-weight: 620; }
p { margin: 0 0 1rem; }
small { font-size: .82rem; color: var(--text-3); }
strong { font-weight: 620; }

a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); text-decoration: underline; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

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

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 10;
  padding: .5rem .9rem;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}
.skip:focus, .skip:focus-visible { top: 12px; color: var(--on-primary); text-decoration: none; }

.muted { color: var(--text-2); }
.nowrap { white-space: nowrap; }
.card .fine { margin-top: 1.25rem; }
.fine { font-size: .85rem; color: var(--text-3); }
.mono { font-family: var(--mono); font-size: .85em; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }

/* --- brand --------------------------------------------------------------- */

.brand, .auth-brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  color: var(--text);
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: -.01em;
}
.brand:hover { color: var(--text); text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; box-shadow: 0 2px 6px -1px rgba(154, 52, 18, .45); }

/* --- the sign-in card ---------------------------------------------------- */

body:has(> .auth) {
  background:
    radial-gradient(900px 500px at 50% -10%, var(--bg-tint), transparent 70%),
    var(--bg);
}

.auth {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 3rem 1rem;
}

.card {
  width: 100%;
  max-width: 440px;
  padding: 2.25rem 2.25rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.card.wide { max-width: 520px; }
.card > :last-child { margin-bottom: 0; }

.card-head { margin-bottom: 1.5rem; }
.card-head h1 { margin-bottom: .35rem; }
.card-head p { margin: 0; color: var(--text-2); }

.auth-foot { text-align: center; }
.auth-foot p { margin: 0; font-size: .82rem; color: var(--text-3); }

.icon-badge {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 1.1rem;
  border-radius: 12px;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--border);
}
.icon-badge.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.icon-badge.wait { background: var(--sunken); color: var(--text-2); }

/* --- buttons ------------------------------------------------------------- */

.button, button {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  min-height: 40px;
  padding: .55rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 560;
  font-size: .95rem;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .05s ease;
}
.button:hover, button:hover {
  background: var(--surface-2);
  border-color: var(--text-3);
  color: var(--text);
  text-decoration: none;
}
.button:active, button:active { transform: translateY(1px); }
.button:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.button.primary, button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}
.button.primary:hover, button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }

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

button.small, .button.small { min-height: 32px; padding: .3rem .7rem; font-size: .85rem; }

button.link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--text-2);
  font-weight: 500;
}
button.link:hover { background: none; color: var(--text); text-decoration: underline; }

.block { width: 100%; }

.providers { display: grid; gap: .65rem; margin: 0; }
.provider {
  width: 100%;
  min-height: 48px;
  justify-content: center;
  font-size: 1rem;
  border-radius: 10px;
}
.provider img { width: 20px; height: 20px; flex: none; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  margin-top: 1.5rem;
}
.actions.stack { flex-direction: column; }
.actions.stack > * { width: 100%; }
.actions.end { justify-content: flex-end; }

/* --- forms --------------------------------------------------------------- */

form { margin: 0; }
label { font-weight: 560; font-size: .9rem; }

input[type="text"], input[type="email"], input[type="url"], input[type="search"], input[type="password"], input[type="number"], input[type="date"], input[type="datetime-local"], input:not([type]), select, textarea {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  min-height: 40px;
  padding: .5rem .75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .95rem;
  box-shadow: var(--shadow-sm) inset;
}
select {
  padding-right: 2.2rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
  border-radius: var(--radius-sm);
}
input[readonly] { background: var(--sunken); font-family: var(--mono); font-size: .85rem; }
/* Dates and numbers: as narrow as their content, and the native picker
   drawn in the page's colour scheme (dark mode included). */
input[type="date"], input[type="datetime-local"], input[type="number"] { width: auto; min-width: 12rem; max-width: 100%; color-scheme: light dark; }
/* Space between a form's fields and its button, and before a folded part. */
form > .field + .field { margin-top: .75rem; }
form > .field + button, form > .field + .actions, form > .table-wrap + .field { margin-top: .9rem; }
form + details, details > form { margin-top: .9rem; }

.field { display: grid; gap: .35rem; }
.field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: .75rem;
}
.field-row .field { flex: 1 1 200px; }
.field-row .field.narrow { flex: 0 1 160px; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.inline-form select { width: auto; min-height: 32px; padding-top: .25rem; padding-bottom: .25rem; font-size: .85rem; }

fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: .6rem; font-weight: 620; font-size: .9rem; }

/* Choice cards: a radio button and its label as one tappable card. */
.choices { display: grid; gap: .5rem; }
.choice {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .8rem .95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-weight: 500;
  font-size: .95rem;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.choice:hover { border-color: var(--border-strong); background: var(--surface-2); }
.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice input {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  display: grid;
  place-items: center;
}
.choice input::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transform: scale(0);
  background: var(--accent);
  transition: transform .12s ease;
}
.choice input:checked { border-color: var(--accent); }
.choice input:checked::before { transform: scale(1); }
.choice input:focus-visible { outline: none; }
.choice-name { flex: 1; min-width: 0; }

/* --- notices ------------------------------------------------------------- */

.notice {
  display: flex;
  gap: .6rem;
  align-items: flex-start;
  padding: .75rem .95rem;
  margin: 0 0 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: .92rem;
}
.notice::before { font-weight: 700; flex: none; }
.notice.error { border-color: var(--danger-border); background: var(--danger-soft); color: var(--danger); }
.notice.error::before { content: "!"; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid currentColor; font-size: .75rem; }
.notice.ok { border-color: var(--ok-border); background: var(--ok-soft); color: var(--ok); }
.notice.ok::before { content: "\2713"; }

/* --- consent ------------------------------------------------------------- */

.requester {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .9rem 1rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 1.05rem;
  text-transform: uppercase;
}
.avatar.round { border-radius: 50%; width: 32px; height: 32px; font-size: .85rem; }
.requester-text { min-width: 0; }
.requester-text strong { display: block; font-size: 1rem; }
.requester-text span { display: block; font-size: .85rem; color: var(--text-2); }

.section-label {
  margin: 1.25rem 0 .6rem;
  font-size: .78rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
}

.scopes {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
  display: grid;
  gap: .1rem;
}
.scopes li {
  position: relative;
  padding: .5rem 0 .5rem 1.9rem;
  border-bottom: 1px solid var(--border);
}
.scopes li:last-child { border-bottom: 0; }
/* An API's own words for a scope, and CodeWarden's count (design §34.4.3):
   on their own lines, line breaks kept, nothing more. */
.scopes li small { display: block; }
.api-says { white-space: pre-wrap; overflow-wrap: anywhere; }
.scopes li::before {
  content: "\2713";
  position: absolute;
  left: 0;
  top: .55rem;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: .72rem;
  font-weight: 700;
}

.for-team {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .8rem .95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tag {
  display: inline-block;
  padding: .08rem .5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--sunken);
  color: var(--text-2);
  font-size: .75rem;
  font-weight: 560;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: middle;
}
.tag.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* --- account shell ------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
}
.topbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: .65rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.topbar .brand { margin-right: .5rem; }
.nav { display: flex; gap: .25rem; }
.nav a {
  padding: .4rem .7rem;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 540;
  font-size: .92rem;
}
.nav a:hover { background: var(--sunken); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--sunken); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }

.topbar-end { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.who { display: flex; align-items: center; gap: .55rem; font-size: .9rem; color: var(--text-2); min-width: 0; }
.who-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 18ch; }

/* The team switcher: a disclosure, so it works without scripts. */
.switcher { position: relative; }
.switcher summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 34px;
  padding: .3rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: .88rem;
  font-weight: 560;
  cursor: pointer;
  white-space: nowrap;
  max-width: 22ch;
}
.switcher summary::-webkit-details-marker { display: none; }
.switcher summary::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: .15rem;
  border-right: 1.5px solid var(--text-3);
  border-bottom: 1.5px solid var(--text-3);
  transform: translateY(-2px) rotate(45deg);
}
.switcher[open] summary::after { transform: translateY(1px) rotate(-135deg); }
.switcher summary:hover { border-color: var(--border-strong); background: var(--surface-2); }
.switcher summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.switcher-label { overflow: hidden; text-overflow: ellipsis; }
.switcher-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 240px;
  max-width: min(320px, calc(100vw - 2rem));
  padding: .35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.switcher-menu p {
  margin: .3rem .55rem .35rem;
  font-size: .72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
}
.switcher-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem .55rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .9rem;
}
.switcher-menu a:hover { background: var(--sunken); text-decoration: none; color: var(--text); }
.switcher-menu a[aria-current="page"] { background: var(--accent-soft); }
.switcher-menu hr { border: 0; border-top: 1px solid var(--border); margin: .35rem 0; }

.app {
  max-width: 1040px;
  margin: 0 auto;
  padding: 2.25rem 1.25rem 4rem;
}

.page-head { margin-bottom: 1.75rem; }
.page-head h1 { margin-bottom: .3rem; }
.page-head p { margin: 0; color: var(--text-2); }
.page-head .tag { margin-left: .4rem; }
.crumbs { margin-bottom: .6rem; font-size: .88rem; }
.crumbs a { color: var(--text-2); }
.crumbs a::before { content: "\2190\00a0"; }
.crumbs a:hover { color: var(--text); }

/* Panels: the sections of an account page. */
.panel {
  margin-bottom: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .25rem 1rem;
  padding: 1.1rem 1.35rem;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 { margin: 0; }
.panel-head p { margin: 0; font-size: .88rem; color: var(--text-2); flex-basis: 100%; }
.panel-body { padding: 1.25rem 1.35rem; }
.panel-body > :last-child { margin-bottom: 0; }
.panel-foot {
  padding: 1rem 1.35rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.empty { padding: 1.5rem 1.35rem; margin: 0; color: var(--text-2); font-size: .92rem; }

/* Tenant list as cards. */
.tenant-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tenant-list li + li { border-top: 1px solid var(--border); }
.tenant-list a {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .95rem 1.35rem;
  color: var(--text);
}
.tenant-list a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.tenant-list a::after {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--text-3);
  border-top: 1.5px solid var(--text-3);
  transform: rotate(45deg);
}
.tenant-name { flex: 1; min-width: 0; font-weight: 580; }
.tenant-meta { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }

/* Tables become stacked rows on a phone. */
.table-wrap { width: 100%; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
th {
  text-align: left;
  font-size: .75rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-3);
  background: var(--surface-2);
  padding: .6rem 1.35rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: .85rem 1.35rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.actions-cell { text-align: right; white-space: nowrap; }
td.actions-cell form { display: inline-flex; }
td small { display: block; margin-top: .1rem; font-family: var(--mono); font-size: .76rem; }
.cell-stack { display: grid; gap: .45rem; justify-items: start; }

.status { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--text-2); }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

.copy-link { display: grid; gap: .5rem; }

/* Settings: the person in the header links to them; facts as label and value. */
a.who:hover { color: var(--text); text-decoration: none; }
.facts {
  display: grid;
  grid-template-columns: minmax(9rem, max-content) 1fr;
  gap: .75rem 1.5rem;
  margin: 0;
}
.facts dt { color: var(--text-2); font-size: .9rem; padding-top: .1rem; }
.facts dd { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; min-width: 0; overflow-wrap: anywhere; }
.tenant-name small { display: block; margin-top: .1rem; font-weight: 400; color: var(--text-2); }
/* Two teams may share a name: a short ID, the member count and the
   person's role, in a quiet line under the name, tell them apart. */
small.team-hint, .tenant-name small.team-hint, .choice-text small.team-hint, td small.team-hint {
  display: block; margin-top: .1rem; color: var(--text-3); font-family: var(--font); font-size: .8rem; font-weight: 400;
}
.team-hint .mono { font-size: .95em; letter-spacing: .02em; }
.choice > .choice-text, .for-team > .choice-text { flex: 1; }
.team-id { color: var(--text-3); font-size: .8rem; }
/* Deleting a team: set apart, without shouting. */
.panel.danger-zone { border-color: var(--danger-border); }
.panel.danger-zone .panel-head h2 { color: var(--danger); }

/* Admin pages: longer forms, checkboxes, state tabs, one-time secrets. */
textarea { resize: vertical; min-height: 4.5rem; line-height: 1.45; }
textarea.mono { font-family: var(--mono); font-size: .82rem; }
.field small { color: var(--text-2); font-size: .8rem; }
.form-grid { display: grid; gap: 1rem; }
.form-grid h3 { margin: 0; font-size: 1rem; }
.form-grid .actions { margin: 0; }
.check { display: flex; align-items: center; gap: .55rem; font-weight: 500; }
.check input { width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--accent); }
.more summary { cursor: pointer; font-weight: 560; font-size: .9rem; color: var(--text-2); }
.more[open] summary { margin-bottom: .75rem; }
.more .field + .field { margin-top: .75rem; }
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; }
.tabs a { padding: .25rem .65rem; border-radius: 999px; font-size: .85rem; color: var(--text-2); border: 1px solid transparent; }
.tabs a:hover { background: var(--sunken); color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-border); }
.tag.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.tag-list { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0; }
.plain-list { list-style: none; margin: 0; padding: .4rem 1.35rem; }
.plain-list li { padding: .45rem 0; overflow-wrap: anywhere; }
.plain-list li + li { border-top: 1px solid var(--border); }
.panel.secret { border-color: var(--ok-border); }
.panel.secret .panel-head { background: var(--ok-soft); }
.panel-foot.actions { margin: 0; }
.panel-foot form + .actions { margin-top: .9rem; }
td.actions-cell form + form { margin-left: .35rem; }
td small.mono, td .mono { overflow-wrap: anywhere; }
.brand .tag { margin-left: .5rem; }
.brand, .nav a, .topbar-end .button { white-space: nowrap; }
td small.text { font-family: var(--font); font-size: .8rem; color: var(--text-2); }
/* The admin header has more sections: they get a row of their own. */
.topbar.wide .topbar-inner { flex-wrap: wrap; row-gap: .35rem; }
.topbar.wide .nav { order: 3; width: 100%; overflow-x: auto; margin-left: -.7rem; }

/* --- the new-app wizard ---------------------------------------------------- */

.steps {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.25rem;
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
  counter-reset: step;
  font-size: .88rem;
  color: var(--text-3);
}
.steps li { display: flex; align-items: center; gap: .45rem; counter-increment: step; }
.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  font-weight: 650;
  font-size: .78rem;
}
.steps li[aria-current="step"] { color: var(--text); font-weight: 600; }
.steps li[aria-current="step"]::before { border-color: var(--accent); background: var(--accent); color: var(--on-primary); }
.steps li.done { color: var(--text-2); }
.steps li.done::before { content: "\2713"; border-color: var(--ok-border); background: var(--ok-soft); color: var(--ok); }
.choices.types { grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
.choice.rich { align-items: flex-start; }
.choice.rich input { margin-top: .15rem; }
.choice-text { display: grid; gap: .2rem; min-width: 0; }
.choice-text small { color: var(--text-2); font-weight: 400; font-size: .86rem; }
.choice-text small + small { color: var(--text-3); }
.field small.field-error { color: var(--danger); font-weight: 500; }
.field:has(.field-error) input, .field:has(.field-error) textarea, .field:has(.field-error) select { border-color: var(--danger-border); }
pre.code {
  margin: 0;
  padding: .85rem 1rem;
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: .8rem;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
}
.snippet + .snippet { margin-top: 1.1rem; }
.snippet h3 { font-size: .92rem; margin: 0 0 .45rem; }
.snippet p { margin: 0 0 .45rem; font-size: .88rem; color: var(--text-2); }
.facts + .snippet { margin-top: 1.25rem; }
.form-grid .check { align-items: flex-start; }
.form-grid .check input { margin-top: .2rem; flex: none; }
.result-ok { color: var(--ok); }
.result-fail { color: var(--danger); }

/* --- developer docs (/docs, /docs/api; internal/apidocs) ------------------ */

.docs { max-width: 880px; }
.docs h2 { font-size: 1.3rem; margin: 0 0 .8rem; }
.docs h3 { font-size: 1.02rem; margin: 1.4rem 0 .5rem; }
.docs h4 { font-size: .8rem; margin: 1rem 0 .45rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.docs ul, .docs ol { margin: 0 0 1rem; padding-left: 1.3rem; }
.docs li + li { margin-top: .3rem; }
.docs pre.code { margin: 0 0 1rem; }
.docs :not(pre) > code {
  font-family: var(--mono);
  font-size: .86em;
  padding: .08em .32em;
  background: var(--sunken);
  border-radius: 4px;
  overflow-wrap: anywhere;
}
.docs .table-wrap {
  margin: 0 0 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}
.docs th, .docs td { padding: .55rem .8rem; vertical-align: top; }
.docs-toc {
  margin: 0 0 2rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.docs-toc ol { margin: 0; columns: 2 16rem; }
.docs-section {
  padding-top: 1.75rem;
  margin-top: 1.75rem;
  border-top: 1px solid var(--border);
  scroll-margin-top: 4rem;
}
.op { scroll-margin-top: 4rem; }
.op + .op { margin-top: 2rem; }
.op h3 { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; }
.method {
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  padding: .15rem .45rem;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* --- phone width --------------------------------------------------------- */

@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; padding: .6rem 1rem; gap: .5rem .75rem; }
  .nav { order: 3; width: 100%; margin: 0 -.35rem; }
  .topbar .brand { margin-right: 0; }
  .who-name { display: none; }
  .switcher-menu { right: -3.5rem; }

  .app { padding: 1.5rem 1rem 3rem; }
  h1 { font-size: 1.4rem; }

  table, thead, tbody, tr, th, td { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  tbody tr { padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); }
  tbody tr:last-child { border-bottom: 0; }
  tbody tr:hover td { background: none; }
  td { padding: .2rem 0; border: 0; }
  td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: .7rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-3);
  }
  td.actions-cell { text-align: left; padding-top: .55rem; }
  td:empty { display: none; }

  .panel-head, .panel-body, .panel-foot, .empty { padding-left: 1.1rem; padding-right: 1.1rem; }
  .tenant-list a { padding: .9rem 1.1rem; }
  .facts { grid-template-columns: 1fr; gap: .2rem; }
  .facts dd + dt { margin-top: .6rem; }
  .nav { flex-wrap: wrap; }
  .plain-list { padding: .3rem 1.1rem; }
  td.actions-cell form + form { margin-left: 0; }
  td.actions-cell { display: flex; flex-wrap: wrap; gap: .35rem; }
}

@media (max-width: 480px) {
  .auth { justify-content: flex-start; padding: 1.5rem 1rem 2rem; gap: 1.25rem; }
  .card { padding: 1.6rem 1.25rem 1.4rem; border-radius: var(--radius); }
  .actions:not(.stack) > button, .actions:not(.stack) > .button { flex: 1 1 auto; }
}

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

@media (forced-colors: active) {
  .choice:has(input:checked) { outline: 2px solid Highlight; }
  .button, button { border: 1px solid ButtonText; }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- agent requests: the changes an AI app asks to make ------------------ */

.change-list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: change;
}
.change-list li {
  display: grid;
  grid-template-columns: 1.6rem 1fr;
  column-gap: .6rem;
  padding: .85rem 1.35rem;
  counter-increment: change;
}
.change-list li + li { border-top: 1px solid var(--border); }
.change-list li::before {
  content: counter(change);
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  font-size: .8rem;
  font-weight: 650;
  color: var(--text-2);
}
.change-list li > span:first-of-type { overflow-wrap: anywhere; }
.change-list li .tag { justify-self: start; margin-top: .3rem; }
.change-list small { grid-column: 2; color: var(--text-3); font-family: var(--mono); font-size: .78rem; }

/* The passkey script shows its error line by removing hidden. */
[hidden] { display: none !important; }

/* A QR code of a link (design §20.4, §20.5), drawn as inline SVG. */
.qr-wrap { margin: 1rem 0 0; }
.qr-wrap figcaption { margin-top: .4rem; font-size: .85rem; color: var(--text); }
.qr { display: block; width: min(240px, 100%); height: auto; background: #fff; border-radius: 4px; }
