
:root {
  color-scheme: light;
  /* The page width and its horizontal inset, shared by the content grid and the
     full-bleed topbar so the brand sits above the rail and the account controls
     above the content's right edge — one source of truth for that alignment. */
  --page-w: 1360px;
  --page-x: 24px;
  /* A documentation-site palette: white ground, hairline rules, one accent.
     The page used to sit on grey with white cards; on white the cards were
     invisible, so the structure is carried by rules and spacing instead. */
  --bg: #ffffff;
  --fg: #111827;
  --muted: #6b7280;
  --line: #e8eaed;
  --line-strong: #d8dce3;
  --card: #ffffff;
  --accent: #1f2937;
  /* Used only for the selected nav item and for links — the one place the UI
     is allowed colour, so "where am I" reads at a glance. */
  --pick: #4f46e5;
  --pick-bg: #eef2ff;
  --subtle: #f6f7f9;
  --danger-bg: #fef2f2;
  --danger-line: #fecaca;
  --danger-fg: #991b1b;
  --ok-bg: #f0fdf4;
  --ok-line: #bbf7d0;
  --ok-fg: #166534;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app[data-loading] { color: var(--muted); padding: 32px 24px; }
h1 { font-size: 28px; font-weight: 650; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* Chrome. Full-bleed so its rule spans the window, but its CONTENT is inset to
   the same centred column as .shell: the horizontal padding grows to whatever
   the shell's left/right margin is, plus the shared inset, so the brand lines up
   with the rail and the account controls with the content's right edge. */
header.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px max(var(--page-x), calc((100% - var(--page-w)) / 2 + var(--page-x)));
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
header.topbar .brand { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
header.topbar .who { margin-left: auto; color: var(--muted); font-size: 13px;
                     display: flex; align-items: center; gap: 10px; }

/* Rail | content | contents-of-this-page. The rail and the aside hold their
   width; the middle takes what is left and may shrink (min-width:0), or a wide
   table would push the aside off the screen instead of scrolling itself. */
.shell {
  display: grid; grid-template-columns: 240px minmax(0, 1fr) 200px;
  gap: 40px; max-width: var(--page-w); margin: 0 auto; padding: 36px var(--page-x) 96px;
  align-items: start;
}
.shell > main { min-width: 0; }
/* No contents list to show: two columns, so the table gets the width instead
   of a reserved-but-empty track. */
.shell.no-toc { grid-template-columns: 240px minmax(0, 1fr); }

nav.side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: block; width: 100%; text-align: left; background: none;
            border: 0; color: var(--fg); padding: 8px 12px; border-radius: 8px;
            cursor: pointer; font: inherit; font-size: 14px; font-weight: 550; }
.nav-item:hover { background: var(--subtle); }
/* The selected item is a tinted pill rather than a bordered box: it marks a
   place in a list, and a border would read as a control. */
.nav-item.active { background: var(--pick-bg); color: var(--pick); }

.page-head { margin: 0 0 32px; }
.page-head .lede { color: var(--muted); font-size: 16px; line-height: 1.7; margin: 10px 0 0; }
/* The first h2 of the guide sits right under the head, so it does not need the
   rule and the 44px of air the ones between sections do. */
.guide > h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

aside.toc { position: sticky; top: 76px; font-size: 13px; }
.toc-title { color: var(--muted); font-weight: 600; margin-bottom: 10px; }
aside.toc nav { display: flex; flex-direction: column; gap: 8px; }
aside.toc a { color: var(--pick); text-decoration: none; line-height: 1.45; }
aside.toc a:hover { text-decoration: underline; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 220px minmax(0, 1fr); }
  aside.toc { display: none; }
}
@media (max-width: 720px) {
  /* Narrower gutter on phones; the topbar reads the same var, so the two stay
     aligned. */
  :root { --page-x: 16px; }
  .shell { grid-template-columns: 1fr; gap: 20px; padding-top: 20px; padding-bottom: 64px; }
  nav.side { position: static; flex-direction: row; flex-wrap: wrap; }
  .nav-item { flex: 1 1 0; text-align: center; }
  h1 { font-size: 22px; }
}

/* The sign-in and error cards are the only boxes left; everything else sits
   directly on the page. */
section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  margin: 48px auto;
  max-width: 30rem;
  box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 14px 34px -18px rgba(16,24,40,.22);
}
section h1 { font-size: 20px; margin-bottom: 8px; }
/* The sign-in card is the whole page, so centre it in the viewport instead of
   letting it hang from the top over a wall of empty white. */
.signin-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.signin-wrap > section { margin: 0; width: 100%; }

input, select, button {
  font: inherit; border-radius: 8px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--fg);
  padding: 8px 10px;
}
input:focus-visible, select:focus-visible { outline: 2px solid var(--pick); outline-offset: -1px; }
button { cursor: pointer; background: var(--accent); color: #fff; border-color: var(--accent);
         font-weight: 550; }
button:hover { background: #111827; }
button.secondary { background: #fff; color: var(--fg); border-color: var(--line-strong); }
button.secondary:hover { background: var(--subtle); }
button.danger { background: #fff; color: var(--danger-fg); border-color: var(--danger-line); }
button.danger:hover { background: var(--danger-bg); }
button:disabled { opacity: .45; cursor: default; }
button:disabled:hover { background: #fff; }
input[type=checkbox] { width: auto; padding: 0; }
label.check { display: flex; align-items: center; gap: 8px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > div { flex: 1 1 180px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
/* A toolbar sits above content, not below a form: no top gap, and a clear gap
   below so the table header does not crowd the buttons. */
.actions.toolbar { margin-top: 0; margin-bottom: 16px; }
/* Actions that live inside a table cell, not under a heading: no top margin (it
   would push them below the row's centre line), kept on one line, and a size
   down so a row of them does not tower over the text beside it. */
.row-actions { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; }
.row-actions button { padding: 6px 10px; font-size: 13px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600;
     padding: 0 10px 10px; white-space: nowrap; border-bottom: 1px solid var(--line); }
td { padding: 14px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.name { min-width: 200px; }
tr.disabled td { color: var(--muted); }

.tag { display: inline-block; vertical-align: middle; padding: 2px 8px; border-radius: 999px;
       font-size: 12px; line-height: 1.5; border: 1px solid var(--line-strong); white-space: nowrap; }
.tag.superadmin { background: var(--pick-bg); border-color: #c7d2fe; color: #3730a3; }
.tag.admin { background: #ecfeff; border-color: #a5f3fc; color: #155e75; }
.tag.warn { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger-fg); }
.tag.pending { background: #fffbeb; border-color: #fde68a; color: #92400e; }
/* Named good, not ok: the success-toast box (.note, .error, .ok) also matches a
   bare .ok, and its larger padding/font/margin would win by source order and
   swell the pill. */
.tag.good { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-fg); }

.note, .error, .ok { border-radius: 10px; padding: 10px 12px; margin: 0 0 16px; font-size: 14px; }
.note { background: var(--subtle); border: 1px solid var(--line); }
.error { background: var(--danger-bg); border: 1px solid var(--danger-line); color: var(--danger-fg); }
.ok { background: var(--ok-bg); border: 1px solid var(--ok-line); color: var(--ok-fg); }

.muted { color: var(--muted); font-size: 13px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
        color: var(--muted); word-break: break-all; }

/* The install guide, rendered from the same blocks the standalone page uses.
   Sized for reading: a wider measure and larger type than the table pane. */
.guide-pane { max-width: 46rem; }
.guide h2 { font-size: 19px; font-weight: 650; letter-spacing: -.01em;
            margin: 44px 0 10px; padding-top: 20px; border-top: 1px solid var(--line);
            scroll-margin-top: 90px; }
.guide h3 { font-size: 15px; font-weight: 650; margin: 24px 0 6px; }
.guide .lede { color: var(--muted); font-size: 16px; line-height: 1.7; margin: 0 0 8px; }
.guide p { font-size: 15px; line-height: 1.8; margin: 12px 0; }
.guide a { color: var(--pick); }
.guide code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .875em;
              background: var(--subtle); border: 1px solid var(--line);
              padding: .1rem .35rem; border-radius: 5px; }
/* Light, bordered, and selectable whole on one click — there is no clipboard
   call in play, so user-select is the entire copy affordance, and it only
   behaves if the block holds a single line. */
.guide pre.cmd { user-select: all; overflow-x: auto; white-space: pre; margin: 14px 0;
                 background: var(--subtle); border: 1px solid var(--line);
                 color: var(--fg); padding: 14px 16px; border-radius: 10px;
                 font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.guide pre.cmd code { background: none; border: 0; padding: 0; font-size: 1em; }
.guide .warn { background: #fffbeb; border: 1px solid #fde68a; color: #78350f;
               padding: 14px 16px; border-radius: 10px; margin: 16px 0; font-size: 14px; }
.guide .warn code { background: #fef3c7; border-color: #fde68a; }
.guide .note { margin: 16px 0; padding: 14px 16px; }
.guide dl { margin: 16px 0; }
.guide dt { font-weight: 600; font-size: 14px; margin-top: 20px; }
.guide dd { margin: 5px 0 0; color: #374151; font-size: 14px; line-height: 1.8; }
.guide table { margin: 16px 0; font-size: 13px; }
.guide td { padding: 10px; }
.guide td.sum { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px;
                word-break: break-all; color: var(--muted); }

/* The workspace editor takes the ENTIRE viewport -- no chrome, no toolbar. It
   is rendered OUTSIDE .shell (see main.ts); fixed inset:0 pins it edge to edge
   over everything regardless of the page's own box, so the iframe gets every
   pixel of the screen. */
.ws-full { position: fixed; inset: 0; z-index: 50; }
.ws-frame { display: block; width: 100%; height: 100%; border: 0; }

dialog {
  border: 0; border-radius: 14px; padding: 20px; max-width: 460px; width: calc(100% - 32px);
  box-shadow: 0 24px 60px -20px rgba(16,24,40,.4);
}
dialog::backdrop { background: rgba(17,24,39,.35); }
dialog .field { margin-bottom: 14px; }
dialog input:not([type=checkbox]), dialog select { width: 100%; }
.field label { display: block; font-size: 13px; font-weight: 550; margin-bottom: 5px; }
