Dough Git

clove/pkviewer

web/src/app.css

back to web/src

/*
 * pkviewer's one stylesheet.
 *
 * Loaded once at the root and used by every page. There is no second sheet and
 * no per-page import, so "which styles does this page get" is never a question.
 *
 * It contains two visual languages that deliberately do not mix:
 *
 *   PUBLIC pages  (/, /s/...)  are drawn from the system's own theme, through
 *                              `--pkv-*` properties the theme vocabulary emits.
 *                              Every value here is a fallback matching the
 *                              platform default, so an unthemed page is still
 *                              correct.
 *
 *   APP pages     (/login, /manage/...) are drawn from pkviewer's own fixed
 *                              palette, through `--mg-*`, scoped under `.mg`.
 *                              The control plane must look the same whichever
 *                              system you are editing, so it never inherits a
 *                              user's theme (M6).
 *
 * The two prefixes are what keep them apart: a theme can never reach `--mg-*`,
 * and the app UI never reads `--pkv-*`.
 */

:root {
  /* Platform defaults, duplicated as fallbacks only. The authoritative copy is
   * the vocabulary; these keep an unthemed page correct. */
  --pkv-color-page: #FAF8FB;
  --pkv-color-surface: #FFFFFF;
  --pkv-color-text: #1C1721;
  --pkv-color-muted: #6B6478;
  --pkv-color-accent: #A23B72;
  --pkv-color-border: #E6E1EC;
  --pkv-font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --pkv-font-heading: "Newsreader", Georgia, serif;
  --pkv-font-size: 16.5px;
  --pkv-radius: 10px;
  --pkv-density: 1;
  --pkv-avatar-radius: var(--pkv-radius);
  --pkv-avatar-size: 88px;
  --pkv-surface-bg: var(--pkv-color-surface);
  --pkv-surface-border: var(--pkv-color-border);
  --pkv-surface-pad: 1;
  --pkv-directory-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --pkv-color-page: #151219;
    --pkv-color-surface: #1E1A24;
    --pkv-color-text: #EEEAF2;
    --pkv-color-muted: #9A93A6;
    --pkv-color-accent: #F58FC2;
    --pkv-color-border: #302938;
  }
}

/* Spacing scale. Density multiplies the whole scale, so one choice retunes the
 * page coherently rather than leaving the user to nudge individual gaps. */
:root {
  --sp-1: calc(0.25rem * var(--pkv-density));
  --sp-2: calc(0.5rem * var(--pkv-density));
  --sp-3: calc(0.75rem * var(--pkv-density));
  --sp-4: calc(1rem * var(--pkv-density));
  --sp-6: calc(1.5rem * var(--pkv-density));
  --sp-8: calc(2rem * var(--pkv-density));
  --sp-12: calc(3rem * var(--pkv-density));
  --measure: 68ch;
  --page-width: 60rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--pkv-color-page);
  color: var(--pkv-color-text);
  font-family: var(--pkv-font-body);
  font-size: var(--pkv-font-size);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--pkv-font-heading);
  font-weight: 600;
  line-height: 1.18;
  text-wrap: balance;
  margin: 0;
}
h1 { font-size: 1.95em; letter-spacing: -0.015em; }
h2 { font-size: 1.3em; }

a { color: var(--pkv-color-accent); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--pkv-color-accent);
  outline-offset: 2px;
}

img { max-width: 100%; height: auto; display: block; }

code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.88em; }

/* The logo mark.
 *
 * It carries no themed colour and no palette of its own, so ONE rule serves the
 * public pages and the control plane alike — only the size differs, and that
 * comes from `--brand-mark-size` on whatever the mark sits in. Overriding the
 * global `height: auto` above is the point: the height is what gets chosen, and
 * the width follows from the artwork's own ratio.
 */
.brand-mark {
  height: var(--brand-mark-size, 24px);
  width: auto;
  flex: none;
}

.page {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-4) var(--sp-12);
}

.stack > * + * { margin-top: var(--sp-6); }
.stack-tight > * + * { margin-top: var(--sp-2); }
.prose { max-width: var(--measure); }

/* The landing page's masthead: mark and wordmark on one line. Baselines do not
 * help here — the mark is a picture, not a glyph — so the two are centred on
 * each other instead. */
.site-brand {
  --brand-mark-size: 52px;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.site-brand > h1 { margin: 0; }
.muted { color: var(--pkv-color-muted); }

/* Card treatment is one token expanding into three properties, so `plain`
 * genuinely removes the card rather than making it invisible-but-padded. */
.surface {
  background: var(--pkv-surface-bg);
  border: 1px solid var(--pkv-surface-border);
  border-radius: var(--pkv-radius);
  padding: calc(var(--sp-4) * var(--pkv-surface-pad));
}

.notice {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  border: 1px solid var(--pkv-color-border);
  border-radius: var(--pkv-radius);
  padding: var(--sp-3) var(--sp-4);
  font-size: 0.875em;
}
.notice svg { flex: none; margin-top: 0.2em; }

.identity { display: flex; gap: var(--sp-4); align-items: center; flex-wrap: wrap; }

.avatar {
  width: var(--pkv-avatar-size);
  height: var(--pkv-avatar-size);
  border-radius: var(--pkv-avatar-radius);
  object-fit: cover;
  border: 1px solid var(--pkv-color-border);
  flex: none;
}
.avatar-sm {
  width: calc(var(--pkv-avatar-size) * 0.5);
  height: calc(var(--pkv-avatar-size) * 0.5);
}

.banner {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: var(--pkv-radius);
  border: 1px solid var(--pkv-color-border);
}

.meta-list {
  display: flex; flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  padding: 0; margin: 0; list-style: none;
  font-size: 0.9em;
}
.meta-list li { display: inline-flex; align-items: center; gap: var(--sp-2); }

.directory {
  display: grid;
  grid-template-columns: var(--pkv-directory-columns);
  gap: var(--sp-3);
  padding: 0; margin: 0; list-style: none;
}

.member-card {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  background: var(--pkv-surface-bg);
  border: 1px solid var(--pkv-surface-border);
  border-radius: var(--pkv-radius);
  padding: calc(var(--sp-3) * var(--pkv-surface-pad) + var(--sp-1));
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.member-card:hover { border-color: var(--pkv-color-accent); }
.member-card .name { font-weight: 600; overflow-wrap: anywhere; }

.socials { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); padding: 0; margin: 0; list-style: none; }
.socials a { display: inline-flex; align-items: center; gap: var(--sp-2); }

/* The third-party disclosure is not the author's to remove. Same mechanism as
 * the badges: locked with !important, which author CSS cannot use. */
.site-footer {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  margin-top: var(--sp-12);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--pkv-color-border);
  font-size: 0.875em;
}

.site-footer-links { display: flex; flex-wrap: wrap; gap: var(--sp-4); }

.breadcrumb { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: 0.9em; text-decoration: none; }

/* ==========================================================================
 * BADGES  —  a third visual language, and the only one a system cannot touch.
 *
 * A badge is platform-issued recognition. It is worth something precisely
 * because the system it describes cannot produce one, so its appearance must
 * not be reachable from the theme vocabulary:
 *
 *   * every value below is a literal or a `--pkvb-*` property. NOTHING here
 *     reads `--pkv-*`, which is what a theme emits. A badge that inherited
 *     `--pkv-color-accent` could be recoloured to look like a different badge,
 *     or set to the page background to hide one.
 *   * font-family, font-size, weight and radius are all stated outright rather
 *     than inherited, so a theme's typeface cannot make a badge look like the
 *     surrounding text — or make surrounding text look like a badge.
 *
 * A test asserts this block contains no `--pkv-` reference. Adding one would
 * hand a system control over how pkviewer describes it.
 * ========================================================================== */

/* The identity properties carry !important, and custom CSS may not use it.
 *
 * Scoping author CSS under #pkv-user is not enough on its own: badges live
 * inside that root, so `* { display: none }` reaches them without ever naming
 * a badge class. Specificity is the wrong tool — an author can always write a
 * longer selector — but !important sits above specificity entirely, and the
 * compiler refuses !important in author CSS. Only what a badge IS is locked;
 * everything else stays ordinary. */
.pkvb-row {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.pkvb {
  --pkvb-ink: #FFFFFF;
  --pkvb-bg: #5B6472;
  --pkvb-edge: rgba(0, 0, 0, 0.18);

  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 8px;
  border: 1px solid var(--pkvb-edge);
  border-radius: 999px !important;
  background: var(--pkvb-bg) !important;
  color: var(--pkvb-ink) !important;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  line-height: 1.4;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
}

a.pkvb:hover { border-color: rgba(0, 0, 0, 0.35); text-decoration: none; }
a.pkvb:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

.pkvb svg { width: 12px; height: 12px; flex: none; }

/* A closed palette. An admin picks a tone NAME; what it looks like is decided
 * here, so no stored value ever becomes a colour. */
.pkvb[data-tone="gold"]   { --pkvb-bg: #9A6B0E; }
.pkvb[data-tone="rose"]   { --pkvb-bg: #A8336B; }
.pkvb[data-tone="violet"] { --pkvb-bg: #6B4BA8; }
.pkvb[data-tone="amber"]  { --pkvb-bg: #94591A; }
.pkvb[data-tone="teal"]   { --pkvb-bg: #14706B; }
.pkvb[data-tone="blue"]   { --pkvb-bg: #2A5CA8; }
.pkvb[data-tone="green"]  { --pkvb-bg: #2C6B42; }
.pkvb[data-tone="slate"]  { --pkvb-bg: #4A5261; }

.badge-glossary { display: grid; gap: var(--sp-4); padding: 0; margin: 0; list-style: none; }
.badge-glossary > li { display: flex; flex-direction: column; gap: var(--sp-1); align-items: flex-start; }
.badge-glossary p { margin: 0; }

.credit-list { display: grid; gap: var(--sp-2); padding: 0; margin: 0; list-style: none; }
.credit-name { font-weight: 600; }

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

/* Detailed member cards carry a description line, clamped so one long entry
 * cannot set the height of an entire row. */
.member-card .card-blurb {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.85em;
  margin-top: var(--sp-1);
}

/* ==========================================================================
   Application UI — /login and /manage.
   ==========================================================================

   Scoped under `.mg` so it cannot touch public pages, and so a system's own
   theme can never touch it: the control plane must stay readable and navigable
   whatever colours somebody picks for their public page.

   It borrows the product's palette — the same rose-plum accent and warm
   near-black the platform default uses — so the two halves read as one product
   without the app inheriting anything user-controlled. Page titles use the
   product's heading face; everything operational stays in the system stack,
   which is faster and more familiar for forms.

   The vocabulary below is deliberately small. Prefer composing these primitives
   over adding page-specific CSS.
   ========================================================================== */

.mg {
  /* Near-neutral greys with only a trace of warmth. The accent is the one
   * colour in this interface; text and surfaces stay out of its way. An earlier
   * palette carried a strong violet cast and every line of description read as
   * tinted rather than quiet. */
  --mg-bg: #F7F6F9;
  --mg-panel: #FFFFFF;
  --mg-panel-sunken: #FAFAFC;
  --mg-ink: #1B1A1F;
  --mg-ink-soft: #48464F;
  --mg-muted: #66626E;
  --mg-line: #E5E3EA;
  --mg-line-strong: #CBC8D2;
  --mg-accent: #A23B72;
  --mg-accent-hover: #8C2F61;
  --mg-accent-soft: #FBEFF5;
  --mg-danger: #B3261E;
  --mg-danger-soft: #FDEDEC;
  --mg-ok: #1F7A4D;
  --mg-warn: #8A5B00;

  --mg-radius: 10px;
  --mg-radius-sm: 7px;
  --mg-shadow: 0 1px 2px rgba(28, 23, 33, 0.05);

  --mg-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mg-font-title: "Newsreader", Georgia, "Iowan Old Style", serif;

  /* One spacing scale. Every gap below comes from it. */
  --mg-1: 4px;
  --mg-2: 8px;
  --mg-3: 12px;
  --mg-4: 16px;
  --mg-5: 24px;
  --mg-6: 32px;
  --mg-7: 48px;

  color-scheme: light;
  background: var(--mg-bg);
  color: var(--mg-ink);
  font-family: var(--mg-font);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

@media (prefers-color-scheme: dark) {
  .mg {
    --mg-bg: #131317;
    --mg-panel: #1B1B21;
    --mg-panel-sunken: #17171C;
    --mg-ink: #ECEBEF;
    --mg-ink-soft: #C2C0C8;
    --mg-muted: #93919C;
    --mg-line: #2C2B33;
    --mg-line-strong: #45434E;
    --mg-accent: #F58FC2;
    --mg-accent-hover: #FFA9D2;
    --mg-accent-soft: #2A1D24;
    --mg-danger: #FF8F84;
    --mg-danger-soft: #2C1A1A;
    --mg-ok: #6FD3A0;
    --mg-warn: #E3B341;
    --mg-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

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

/* `:where()` contributes no specificity, so this is the DEFAULT link colour
 * rather than a rule every component then has to fight. Written as `.mg a` it
 * would score (0,1,1) and beat every single-class rule below — the nav, the
 * brand, the back link and every list row would all come out accent-coloured. */
.mg :where(a) { color: var(--mg-accent); text-underline-offset: 2px; }

/* One focus treatment everywhere, strong enough to find at a glance. */
.mg :focus-visible {
  outline: 2px solid var(--mg-accent);
  outline-offset: 2px;
  border-radius: var(--mg-radius-sm);
}

.mg h1, .mg h2, .mg h3 { margin: 0; }

/* ------------------------------------------------------------------ chrome */

.mg-bar {
  display: flex; align-items: center; gap: var(--mg-3);
  padding: var(--mg-3) var(--mg-4);
  background: var(--mg-panel);
  border-bottom: 1px solid var(--mg-line);
  position: sticky; top: 0; z-index: 30;
  flex-wrap: wrap;
}
.mg-brand {
  --brand-mark-size: 22px;
  display: inline-flex; align-items: center; gap: var(--mg-2);
  font-family: var(--mg-font-title);
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
  text-decoration: none; color: var(--mg-ink);
}
.mg-bar-note {
  font-size: 12px; color: var(--mg-muted);
  border-left: 1px solid var(--mg-line); padding-left: var(--mg-3);
}
.mg-bar .spacer { flex: 1; }

.mg-shell { max-width: 68rem; margin: 0 auto; padding: var(--mg-5) var(--mg-4) var(--mg-7); }
.mg-shell--narrow { max-width: 46rem; }

/* Vertical rhythm for stacked blocks.
 *
 * ONE rule, applied to whatever a page stacks, rather than a margin per pair of
 * neighbours. The pairwise approach only spaced the combinations it happened to
 * name: a save bar followed by the next section had no rule at all and the two
 * sat flush against each other.
 *
 * Components therefore carry no outer margin of their own — spacing belongs to
 * the container, so any two blocks are separated no matter what they are. */
.mg-shell > * + *,
.mg-column > * + * { margin-top: var(--mg-4); }

/* A page header stands a little further from the content it introduces. */
.mg-shell > .mg-pagehead + *,
.mg-column > .mg-pagehead + * { margin-top: var(--mg-5); }

/* Consecutive notes read as one group, so they sit closer together. */
.mg-shell > .mg-note + .mg-note,
.mg-column > .mg-note + .mg-note { margin-top: var(--mg-2); }

.mg-layout { display: grid; grid-template-columns: 1fr; gap: var(--mg-5); }
@media (min-width: 900px) {
  .mg-layout { grid-template-columns: 216px minmax(0, 1fr); gap: var(--mg-6); align-items: flex-start; }
}

/* Section nav. A column on wide screens, a horizontal rail on narrow ones —
 * shrinking a sidebar until it is unusable is worse than changing its shape. */
.mg-nav {
  display: flex; gap: var(--mg-1);
  overflow-x: auto; padding-bottom: var(--mg-1);
  scrollbar-width: thin;
}
.mg-nav a {
  display: flex; align-items: center; gap: var(--mg-2);
  padding: var(--mg-2) var(--mg-3);
  border-radius: var(--mg-radius-sm);
  text-decoration: none; color: var(--mg-ink-soft);
  white-space: nowrap; font-size: 14px;
  border: 1px solid transparent;
}
.mg-nav a:hover { background: var(--mg-panel); color: var(--mg-ink); }
.mg-nav a svg { color: var(--mg-muted); flex: none; }
/* Current page carries weight and a rule as well as colour. */
.mg-nav a[aria-current="page"] {
  background: var(--mg-accent-soft);
  color: var(--mg-accent);
  font-weight: 600;
  border-color: color-mix(in srgb, var(--mg-accent) 25%, transparent);
}
.mg-nav a[aria-current="page"] svg { color: inherit; }
@media (min-width: 900px) {
  .mg-nav { flex-direction: column; overflow: visible; position: sticky; top: 72px; }
}

/* ------------------------------------------------------------- page header */

.mg-pagehead {
  display: flex; align-items: flex-start; gap: var(--mg-4);
  flex-wrap: wrap;
}
.mg-pagehead .grow { flex: 1 1 18rem; min-width: 0; }
.mg-pagehead h1 {
  font-family: var(--mg-font-title);
  font-size: 26px; font-weight: 600; letter-spacing: -0.015em;
  line-height: 1.2; text-wrap: balance;
  overflow-wrap: anywhere;
}
.mg-pagehead p { margin: var(--mg-2) 0 0; color: var(--mg-muted); font-size: 14px; max-width: 60ch; }
.mg-pagehead .mg-actions { flex: none; }

.mg-actions { display: flex; gap: var(--mg-2); flex-wrap: wrap; align-items: center; }

/* Breadcrumb: a quiet way back, not a navigation system. */
.mg-back {
  display: inline-flex; align-items: center; gap: var(--mg-2);
  font-size: 13.5px; text-decoration: none; color: var(--mg-muted);
  margin-bottom: var(--mg-3);
}
.mg-back:hover { color: var(--mg-accent); }

/* --------------------------------------------------------------- sections */

.mg-section {
  background: var(--mg-panel);
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-radius);
  box-shadow: var(--mg-shadow);
  padding: var(--mg-5);
}

.mg-section-head { margin-bottom: var(--mg-4); }
.mg-section-head h2 { font-size: 15.5px; font-weight: 650; letter-spacing: -0.005em; }
.mg-section-head p { margin: var(--mg-1) 0 0; color: var(--mg-muted); font-size: 13.5px; max-width: 62ch; }
.mg-section-head--bare { margin-bottom: 0; }

/* Kept as an alias so existing markup keeps working while pages migrate. */
.mg-panel {
  background: var(--mg-panel);
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-radius);
  box-shadow: var(--mg-shadow);
  padding: var(--mg-5);
}
.mg-panel h2 { font-size: 15.5px; font-weight: 650; }
.mg-panel .hint { color: var(--mg-muted); font-size: 13.5px; margin: var(--mg-1) 0 var(--mg-4); max-width: 62ch; }

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

.mg-fields { display: grid; gap: var(--mg-4); }
.mg-grid {
  display: grid; gap: var(--mg-4);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}

.mg-field { display: grid; gap: var(--mg-2); align-content: start; }
.mg-field > label, .mg-field-label { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.mg-field .desc { font-size: 12.5px; color: var(--mg-muted); line-height: 1.45; }
.mg-field .err { font-size: 12.5px; color: var(--mg-danger); font-weight: 500; }
.mg-field-head { display: flex; align-items: center; gap: var(--mg-2); flex-wrap: wrap; }
.mg-field-head .spacer { flex: 1; }

.mg input[type="text"], .mg input[type="url"], .mg input[type="email"], .mg select, .mg textarea {
  font: inherit; font-size: 14px;
  padding: var(--mg-2) var(--mg-3);
  border: 1px solid var(--mg-line-strong);
  border-radius: var(--mg-radius-sm);
  background: var(--mg-panel);
  color: var(--mg-ink);
  width: 100%; min-width: 0;
}
.mg select {
  appearance: none;
  padding-right: var(--mg-6);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right var(--mg-4) center, calc(100% - 11px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
.mg input:hover:not(:disabled), .mg select:hover:not(:disabled) { border-color: var(--mg-muted); }
.mg input[aria-invalid="true"] { border-color: var(--mg-danger); }
.mg input:disabled, .mg select:disabled { opacity: 0.6; cursor: not-allowed; background: var(--mg-panel-sunken); }

.mg-colour { display: flex; align-items: center; gap: var(--mg-2); }
.mg-colour input[type="color"] {
  inline-size: 40px; block-size: 36px; padding: 3px; flex: none;
  border: 1px solid var(--mg-line-strong); border-radius: var(--mg-radius-sm);
  background: var(--mg-panel); cursor: pointer;
}
.mg-colour input[type="text"] {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px; text-transform: uppercase;
}

/* -------------------------------------------------------------- inheritance */

/* Inherited vs overridden is shown by a word AND a rule, never by colour alone:
 * the state has to survive colour blindness and a greyscale screenshot. */
.mg-inherit {
  display: inline-flex; align-items: center; gap: var(--mg-1);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px var(--mg-2); border-radius: 999px;
  border: 1px solid var(--mg-line-strong);
  color: var(--mg-muted); background: transparent;
  white-space: nowrap;
}
.mg-inherit[data-state="override"] {
  border-color: color-mix(in srgb, var(--mg-accent) 40%, transparent);
  color: var(--mg-accent);
  background: var(--mg-accent-soft);
}
.mg-field[data-state="override"] {
  border-left: 3px solid var(--mg-accent);
  padding-left: var(--mg-3);
  margin-left: 0;
}

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

/* Four weights, and they must look different at a glance:
 *   primary   the one thing this screen is for
 *   secondary a real alternative
 *   quiet     available but not competing
 *   danger    destructive, and never the default
 */
.mg button, .mg .btn {
  font: inherit; font-size: 13.5px; font-weight: 550;
  padding: var(--mg-2) var(--mg-3);
  border-radius: var(--mg-radius-sm);
  border: 1px solid var(--mg-line-strong);
  background: var(--mg-panel); color: var(--mg-ink);
  cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--mg-2);
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.mg button:hover:not(:disabled), .mg .btn:hover { border-color: var(--mg-muted); background: var(--mg-panel-sunken); }

/* A disabled control states that it is inactive rather than fading out.
 * Halving the opacity of a filled accent button produced a muddy block that
 * read as broken rather than unavailable. */
.mg button:disabled {
  cursor: not-allowed;
  background: var(--mg-panel-sunken);
  border-color: var(--mg-line);
  color: var(--mg-muted);
}

.mg button.primary:not(:disabled), .mg .btn.primary {
  background: var(--mg-accent); border-color: var(--mg-accent); color: #fff; font-weight: 600;
}
.mg button.primary:disabled { font-weight: 600; }
.mg button.primary:hover:not(:disabled), .mg .btn.primary:hover {
  background: var(--mg-accent-hover); border-color: var(--mg-accent-hover); color: #fff;
}

.mg button.quiet, .mg .btn.quiet {
  border-color: transparent; background: transparent; color: var(--mg-muted);
}
.mg button.quiet:hover:not(:disabled), .mg .btn.quiet:hover {
  background: var(--mg-panel-sunken); color: var(--mg-ink); border-color: transparent;
}
/* Older markup used .ghost for the same role. */
.mg button.ghost, .mg .btn.ghost { border-color: transparent; background: transparent; color: var(--mg-muted); }
.mg button.ghost:hover:not(:disabled) { background: var(--mg-panel-sunken); color: var(--mg-ink); }

.mg button.danger, .mg .btn.danger { color: var(--mg-danger); border-color: var(--mg-line-strong); }
.mg button.danger:hover:not(:disabled) { border-color: var(--mg-danger); background: var(--mg-danger-soft); }

.mg button.icon { padding: var(--mg-2); }
.mg button svg, .mg .btn svg { flex: none; }

/* ---------------------------------------------------------------- save bar */

.mg-savebar {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--mg-3); flex-wrap: wrap;
  padding: var(--mg-3) var(--mg-4);
  background: var(--mg-panel);
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-radius);
  box-shadow: 0 -2px 12px -8px rgba(28, 23, 33, 0.35), var(--mg-shadow);
}
.mg-savebar .spacer { flex: 1; }
/* Unsaved work is worth noticing, so the bar itself changes, not just a word. */
.mg-savebar[data-state="dirty"] { border-color: color-mix(in srgb, var(--mg-warn) 45%, var(--mg-line)); }
.mg-savebar[data-state="error"] { border-color: var(--mg-danger); }

.mg-status {
  font-size: 13px; display: inline-flex; align-items: center; gap: var(--mg-2);
  color: var(--mg-muted); min-width: 0;
}
.mg-status[data-tone="dirty"] { color: var(--mg-warn); font-weight: 550; }
.mg-status[data-tone="ok"] { color: var(--mg-ok); font-weight: 550; }
.mg-status[data-tone="error"] { color: var(--mg-danger); font-weight: 550; }
.mg-status svg { flex: none; }

/* ------------------------------------------------------------------- lists */

.mg-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--mg-2); }

.mg-item {
  display: flex; align-items: center; gap: var(--mg-3);
  padding: var(--mg-3);
  background: var(--mg-panel);
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-radius);
  text-decoration: none; color: inherit;
  min-width: 0;
}
a.mg-item { transition: border-color 120ms ease, background 120ms ease; }
a.mg-item:hover { border-color: var(--mg-accent); background: var(--mg-accent-soft); }

/* The identity block. A column with a real gap, so the name and its details are
 * separated by layout rather than by whitespace in the markup. */
.mg-identity { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mg-identity .name {
  font-weight: 600; line-height: 1.3;
  overflow-wrap: anywhere;
}
.mg-identity .meta {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 0 var(--mg-2);
  font-size: 12.5px; color: var(--mg-muted); line-height: 1.4;
  min-width: 0;
}
/* A middot between details, drawn by CSS so no text node carries spacing. */
.mg-identity .meta > * + *::before {
  content: "·";
  margin-right: var(--mg-2);
  color: var(--mg-line-strong);
}
.mg-identity .meta > * { overflow-wrap: anywhere; min-width: 0; }
.mg-identity .meta code { font-size: 0.95em; }

/* Older markup used .mg-card with .grow/.title/.sub. */
.mg-card {
  display: flex; align-items: center; gap: var(--mg-3);
  padding: var(--mg-3);
  background: var(--mg-panel);
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-radius);
  text-decoration: none; color: inherit; min-width: 0;
}
a.mg-card:hover { border-color: var(--mg-accent); background: var(--mg-accent-soft); }
.mg-card .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mg-card .title { font-weight: 600; overflow-wrap: anywhere; line-height: 1.3; }
.mg-card .sub { font-size: 12.5px; color: var(--mg-muted); overflow-wrap: anywhere; }

.mg-thumb {
  width: 42px; height: 42px; flex: none;
  border-radius: 9px; object-fit: cover;
  border: 1px solid var(--mg-line);
  background: var(--mg-panel-sunken);
  color: var(--mg-muted);
}
.mg-thumb--round { border-radius: 50%; }

.mg-tag {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px var(--mg-2); border-radius: 999px;
  border: 1px solid var(--mg-line-strong); color: var(--mg-muted);
  white-space: nowrap; flex: none;
}
.mg-tag[data-tone="ok"] { color: var(--mg-ok); border-color: color-mix(in srgb, var(--mg-ok) 40%, transparent); }
.mg-tag[data-tone="warn"] { color: var(--mg-warn); border-color: color-mix(in srgb, var(--mg-warn) 45%, transparent); }
.mg-tag[data-tone="accent"] { color: var(--mg-accent); border-color: color-mix(in srgb, var(--mg-accent) 40%, transparent); background: var(--mg-accent-soft); }

/* ------------------------------------------------------------------- notes */

.mg-note {
  display: flex; gap: var(--mg-3); align-items: flex-start;
  padding: var(--mg-3) var(--mg-4);
  border-radius: var(--mg-radius);
  border: 1px solid var(--mg-line-strong);
  background: var(--mg-panel-sunken);
  font-size: 13.5px; color: var(--mg-ink-soft);
  line-height: 1.5;
}
.mg-note svg { flex: none; margin-top: 2px; color: var(--mg-muted); }
.mg-note[data-tone="warn"] { border-color: color-mix(in srgb, var(--mg-warn) 50%, transparent); color: var(--mg-warn); }
.mg-note[data-tone="warn"] svg { color: inherit; }
.mg-note[data-tone="accent"] { border-color: color-mix(in srgb, var(--mg-accent) 35%, transparent); background: var(--mg-accent-soft); }
.mg-note p { margin: 0; }

/* ------------------------------------------------------------ empty states */

.mg-empty {
  text-align: left; max-width: 46rem;
  background: var(--mg-panel);
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-radius);
  padding: var(--mg-6);
  box-shadow: var(--mg-shadow);
}
.mg-empty h1 { font-family: var(--mg-font-title); font-size: 22px; font-weight: 600; margin-bottom: var(--mg-3); }
.mg-empty p { color: var(--mg-ink-soft); margin: 0 0 var(--mg-3); max-width: 56ch; }
.mg-empty ol, .mg-empty ul { color: var(--mg-ink-soft); padding-left: var(--mg-5); margin: 0 0 var(--mg-4); }
.mg-empty li { margin-bottom: var(--mg-2); }

/* --------------------------------------------------------------- presets */

.mg-presets {
  display: grid; gap: var(--mg-3);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
}
/* A preset card is a <button>, so it must out-specify the generic `.mg button`
 * rule above — that rule is `display: inline-flex` and would otherwise lay the
 * card out as a row, squeezing the description into a narrow column beside the
 * name. `.mg .mg-preset` (0,2,0) beats `.mg button` (0,1,1). */
.mg .mg-preset {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: start;
  align-content: start;
  gap: var(--mg-2);
  width: 100%;
  text-align: left;
  padding: var(--mg-4);
  border-radius: var(--mg-radius);
  border: 1px solid var(--mg-line-strong);
  background: var(--mg-panel);
  cursor: pointer;
  font-weight: 400;
}
.mg .mg-preset:hover { border-color: var(--mg-accent); background: var(--mg-accent-soft); }
.mg-preset .pname { font-weight: 650; font-size: 14.5px; line-height: 1.3; }
.mg-preset .pchar {
  font-size: 12.5px; color: var(--mg-muted); line-height: 1.5;
  text-wrap: pretty;
}
.mg-swatches { display: flex; gap: var(--mg-1); }
.mg-swatch { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.12); flex: none; }

/* --------------------------------------------------------------- skeletons */

/* A stable shape while data loads, not a spinner. */
.mg-skel {
  display: block;
  background: var(--mg-line);
  border-radius: var(--mg-radius-sm);
  animation: mg-pulse 1.4s ease-in-out infinite;
}
@keyframes mg-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* -------------------------------------------------------------- claim flow */

.mg-steps { padding-left: var(--mg-5); margin: 0 0 var(--mg-3); color: var(--mg-ink-soft); }
.mg-steps li { margin-bottom: var(--mg-3); }
.mg-code {
  display: block; margin-top: var(--mg-2);
  padding: var(--mg-3);
  border: 1px solid var(--mg-line-strong);
  border-radius: var(--mg-radius-sm);
  background: var(--mg-panel-sunken);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 14px; user-select: all; overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ misc */

.mg-url {
  display: flex; align-items: center; gap: var(--mg-2); flex-wrap: wrap;
}
.mg-url code {
  flex: 1 1 16rem; min-width: 0;
  font-size: 13.5px; overflow-wrap: anywhere;
  padding: var(--mg-2) var(--mg-3);
  background: var(--mg-panel-sunken);
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-radius-sm);
}

.mg-defs { margin: 0; display: grid; gap: var(--mg-3); }
.mg-def { display: grid; grid-template-columns: 1fr; gap: var(--mg-1); }
@media (min-width: 640px) {
  .mg-def { grid-template-columns: minmax(9rem, 12rem) 1fr; gap: var(--mg-4); align-items: baseline; }
}
.mg-def dt { color: var(--mg-muted); font-size: 13px; margin: 0; }
.mg-def dd { margin: 0; overflow-wrap: anywhere; }

.mg-hr { border: 0; border-top: 1px solid var(--mg-line); margin: var(--mg-5) 0; }

@media (prefers-reduced-motion: reduce) {
  .mg *, .mg *::before, .mg *::after { transition: none !important; animation: none !important; }
  .mg-skel { animation: none; opacity: 0.8; }
}

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

/* A quiet affordance that a list row leads somewhere. */
.mg-chevron { color: var(--mg-line-strong); flex: none; }
a.mg-item:hover .mg-chevron { color: var(--mg-accent); }

/* The system name, shown once above the section navigation rather than repeated
 * as every section's page title. */
.mg-syshead { margin-bottom: var(--mg-5); }
.mg-syshead h1 {
  font-family: var(--mg-font-title);
  font-size: 28px; font-weight: 600; letter-spacing: -0.02em;
  line-height: 1.15; overflow-wrap: anywhere; text-wrap: balance;
}
.mg-syshead p { margin: var(--mg-2) 0 0; color: var(--mg-muted); font-size: 14px; }

/* Within a section, the page header is a step down from the system name. */
.mg-column .mg-pagehead h1 { font-size: 20px; }
.mg-column { min-width: 0; }

/* ==========================================================================
 * ADMINISTRATION
 *
 * The admin area reuses the management vocabulary rather than inventing a
 * second one — it is the same application, seen by someone with a different
 * grant. These are the few shapes it needs that /manage did not.
 * ========================================================================== */

.mg-subnav {
  display: flex; flex-wrap: wrap; gap: var(--mg-1);
  padding: var(--mg-2) var(--mg-4) 0;
  border-bottom: 1px solid var(--mg-line);
}
.mg-subnav a {
  display: inline-flex; align-items: center; gap: var(--mg-2);
  padding: var(--mg-2) var(--mg-3);
  border-radius: var(--mg-radius) var(--mg-radius) 0 0;
  font-size: 13.5px; font-weight: 600;
  color: var(--mg-muted); text-decoration: none;
}
.mg-subnav a:hover { color: var(--mg-ink); background: var(--mg-accent-soft); }

.mg-stats { display: flex; flex-wrap: wrap; gap: var(--mg-4); padding: 0; margin: 0; list-style: none; }
.mg-stats li { color: var(--mg-muted); font-size: 13.5px; }
.mg-stats strong { display: block; font-size: 20px; color: var(--mg-ink); }

.mg-row { display: flex; flex-wrap: wrap; gap: var(--mg-3); align-items: flex-start; }
.mg-row > .grow { flex: 1 1 12rem; }

.mg-hint { margin: 0; font-size: 12.5px; color: var(--mg-muted); line-height: 1.45; }

.mg-check { display: flex; align-items: center; gap: var(--mg-2); font-size: 13.5px; }
.mg-check input { width: auto; }

.mg-item-stack { flex-direction: column; align-items: stretch; }
.mg-item-row { display: flex; align-items: center; gap: var(--mg-3); flex-wrap: wrap; }

.mg-item-meta {
  display: flex; flex-wrap: wrap; gap: var(--mg-1) var(--mg-3);
  margin-top: var(--mg-1); font-size: 12.5px;
}

.mg-panel-inset {
  display: grid; gap: var(--mg-3);
  padding: var(--mg-3);
  border: 1px dashed var(--mg-line);
  border-radius: var(--mg-radius);
}

/* Badge assignment state. Never colour alone: each state says what it is, and
 * the word is what carries the meaning (the audit found colour-only state to be
 * the recurring accessibility failure in this UI). */
.mg-state {
  display: inline-flex; align-items: center;
  font-size: 12.5px; font-weight: 600;
}
.mg-state[data-state="pending"]  { color: var(--mg-warn); }
.mg-state[data-state="accepted"] { color: var(--mg-ok); }
.mg-state[data-state="declined"] { color: var(--mg-muted); }
.mg-state[data-state="hidden"]   { color: var(--mg-muted); }
.mg-state[data-state="revoked"]  { color: var(--mg-danger); }

.mg-note[data-tone="error"] {
  border-color: color-mix(in srgb, var(--mg-danger) 50%, transparent);
  background: var(--mg-danger-soft);
  color: var(--mg-danger);
}
.mg-note[data-tone="ok"] { border-color: color-mix(in srgb, var(--mg-ok) 45%, transparent); }

/* The CSS editor. A code field is a different thing from a text field: it is
 * read as a grid, so it needs a monospaced face and a tab that means tab. */
.mg-code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  tab-size: 2;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  min-height: 20rem;
  resize: vertical;
}

.mg-plain { display: grid; gap: var(--mg-2); padding: 0; margin: 0; list-style: none; }
.mg-plain li { color: var(--mg-muted); font-size: 13.5px; line-height: 1.5; }
.mg-plain strong { color: var(--mg-ink); }
.mg-plain code, .mg-item-meta code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}