/*
 * Keeper dashboard stylesheet (A7.1, A7.2, A7.4). Our own design. The CSP allows no inline styles, so every
 * rule lives here, including the htmx indicator rules htmx would otherwise inject (layout.eta turns that off).
 * Light and dark themes follow prefers-color-scheme. Sides are logical (margin-inline-start and the like), so a
 * right-to-left page mirrors (B26 rule 17).
 */

:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-muted: #eef0f4;
  --text: #1a1d23;
  --text-muted: #5b6270;
  --border: #d8dce3;
  --accent: #4157e0;
  --accent-hover: #3045c8;
  --accent-soft: #e6eafc;
  --on-accent: #ffffff;
  /* p3polish item 1: a solid primary button's fill and its hover fill. In light they equal --accent and --accent-hover,
     so light mode is unchanged; the dark block gives the button its own saturated blue. */
  --accent-fill: #4157e0;
  --accent-fill-hover: #3045c8;
  --danger: #c42f3c;
  --danger-soft: #fbe9eb;
  /* p2polish item 2: text on a solid danger button (5.50:1 on --danger) and the darker red a solid danger button turns
     on hover (7.03:1 under --on-danger). */
  --on-danger: #ffffff;
  --danger-hover: #a82632;
  --warning: #8a5a00;
  --warning-soft: #fdf3dc;
  --success: #1c7c46;
  --success-soft: #e3f4ea;
  --focus: #6d82ff;
  /* An off switch's track (polish0 item 4): 3:1 or more on --bg, --surface, --surface-muted and the white knob. */
  --switch-off: #767e8c;
  /* A text control's edge (p1polish item 2): 3:1 or more on --surface, --surface-muted and --bg, so an input, select or
     textarea shows where it is. Decorative lines keep --border. */
  --border-control: #808897;
  /* p3polish item 1: a text control's fill. In light it equals --surface, so light mode is unchanged; in dark it is a
     recessed well, darker than the card it sits on. */
  --control-bg: #ffffff;
  /* p2polish item 8: a sidebar entry's hover fill, 1.19:1 on --bg so it shows, with --text, the on and off marks and
     the issue count still readable on it. */
  --nav-hover: #dfe3ea;
  --radius: 10px;
  --radius-small: 6px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 2px 6px rgb(16 24 40 / 8%);
  /* The save bar's upward shadow (p1polish item 3), so fields visibly slide under it. Its x offset is 0, so it is the
     same in right-to-left. */
  --shadow-up: 0 -6px 16px -8px rgb(16 24 40 / 18%);
  /* A hovered overview card or link tile (p1polish item 10), lifted off the page. Every layer's x offset is 0, so it is
     the same in right-to-left. */
  --shadow-raised: 0 2px 4px rgb(16 24 40 / 6%), 0 8px 20px rgb(16 24 40 / 8%);
  /* p2polish item 11: the soft shadow a scrolling table wrap shows on a side with more to scroll. */
  --scroll-edge: rgb(16 24 40 / 16%);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  --page-width: 72rem;
  /* Type sizes and weights (u7.md item 1). They do not change with the theme, so the dark block has none. Headings and
     legends are bold, labels and buttons medium, and help, error and count text share one small size. */
  --text-xs: 0.8rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.3rem;
  --text-2xl: 1.85rem;
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-strong: 600;
  --weight-bold: 700;
  /* One control height per row (u7.md item 3): 42 px for inputs, single selects and regular buttons. It does not change
     with the theme, so the dark block has none. */
  --control-block-size: 2.625rem;
  /* The single select's chevron (u7.md item 4), stroked in --text-muted. An SVG background cannot read page variables
     or currentColor, so the color is written into the image and the dark block holds its own copy: the theme switch
     stays in that one block. */
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235b6270' stroke-width='1.5'/%3E%3C/svg%3E");
  /* Overview chart series (B27 rule 23). */
  --chart-members: #4157e0;
  --chart-messages: #0f7b8a;
  --chart-joins: #1c7c46;
  --chart-leaves: #c2410c;
  --chart-voice: #8b3fc7;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --surface: #1a1d24;
    /* p3polish item 1: a muted band (1.17:1 on --surface) and a decorative line (1.48:1 on --surface) that show on a
       dark card. --bg and --surface stay, so layout.eta's two theme-color metas stay too. */
    --surface-muted: #252a33;
    --text: #e7e9ee;
    --text-muted: #a0a7b4;
    --border: #343a47;
    --accent: #7b8cff;
    --accent-hover: #95a3ff;
    --accent-soft: #252c4d;
    /* p3polish item 1: white text on a saturated primary fill (5.35:1, and 4.88:1 on its hover fill), not near-black
       text on a pastel slab. The fill's edge is 3.15:1 on --surface and 3.47:1 on --bg. --accent stays the lighter blue
       for links, tabs, switches and focus. */
    --on-accent: #ffffff;
    --accent-fill: #4d5ce0;
    --accent-fill-hover: #5463e6;
    --danger: #ff7a85;
    --danger-soft: #3a1d22;
    /* p2polish item 2: dark text on the light dark-mode red (7.56:1 on --danger), and a lighter red on hover (9.14:1). */
    --on-danger: #1f0a0d;
    --danger-hover: #ff96a0;
    --warning: #f2c063;
    --warning-soft: #33290f;
    --success: #6fd49a;
    --success-soft: #16301f;
    --focus: #95a3ff;
    --switch-off: #717a8c;
    /* p1polish item 2: the dark control edge, 3:1 or more on the dark --surface, --surface-muted and --bg. */
    --border-control: #737b8c;
    /* p3polish item 1: the dark field well, darker than the card (--text 14.75:1 and --border-control 4.22:1 on it). */
    --control-bg: #15171d;
    /* p2polish item 8: the dark hover fill, 1.39:1 on the dark --bg. */
    --nav-hover: #2a2f3a;
    /* u7.md item 4: the chevron stroked in the dark --text-muted. */
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23a0a7b4' stroke-width='1.5'/%3E%3C/svg%3E");
    /* p3polish item 1: a faint top-edge highlight and a tight drop, the way a dark page shows a raised card. Every
       layer's x offset is 0, so it is the same in right-to-left. */
    --shadow: inset 0 1px 0 rgb(255 255 255 / 4%), 0 1px 2px rgb(0 0 0 / 45%);
    /* p1polish item 3: the save bar's upward shadow, darker to show on the dark page. */
    --shadow-up: 0 -6px 16px -8px rgb(0 0 0 / 55%);
    /* p1polish item 10: the hovered card and tile shadow, darker to show on the dark page. */
    --shadow-raised: 0 2px 4px rgb(0 0 0 / 40%), 0 8px 20px rgb(0 0 0 / 35%);
    /* p2polish item 11: the scroll shadow, darker to show on the dark page. */
    --scroll-edge: rgb(0 0 0 / 55%);
    --chart-members: #7b8cff;
    --chart-messages: #4fc3d1;
    --chart-joins: #6fd49a;
    --chart-leaves: #ff9a5c;
    --chart-voice: #c79bff;
  }
}

/* Base */

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  margin: 1.6em 0 0.6em;
  font-weight: var(--weight-bold);
}

h1 {
  font-size: var(--text-2xl);
  margin-top: 0;
  /* p2polish item 3: tighter tracking, so a bold heading no longer looks wide. */
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--text-xl);
  /* p2polish item 3: tighter tracking for card and section titles. */
  letter-spacing: -0.01em;
}

h3 {
  font-size: var(--text-lg);
  /* p2polish item 3: tighter tracking for card and section titles. */
  letter-spacing: -0.01em;
}

p,
ul,
ol {
  margin: 0 0 1em;
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--accent-hover);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

code,
pre {
  font-family: var(--mono);
  font-size: 0.92em;
}

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

[x-cloak] {
  display: none !important;
}

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

.muted {
  color: var(--text-muted);
}

.lead {
  /* p2polish item 3: the type scale's large size and a calmer line height, so the lead takes less of the first screen. */
  font-size: var(--text-lg);
  line-height: 1.5;
  color: var(--text-muted);
  /* p1polish item 4: a readable line length on a wide screen. */
  max-inline-size: 48rem;
}

/* Layout */

.skip-link {
  position: absolute;
  inset-inline-start: 1rem;
  top: -3rem;
  padding: 0.5rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  z-index: 10;
}

.skip-link:focus {
  top: 1rem;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 0.45rem;
  background: linear-gradient(135deg, var(--accent), #9b5de5);
  box-shadow: inset 0 0 0 2px rgb(255 255 255 / 25%);
}

.site-header-slot {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* The logged-in user (A7.3): avatar, name and the logout button. */
.user-menu {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-inline-start: auto;
}

.user-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--surface-muted);
}

.user-name {
  font-weight: 600;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-form {
  margin: 0;
}

.page {
  flex: 1;
  width: 100%;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 1rem 1.25rem;
}

.site-footer p {
  margin: 0;
}

.stack > * + * {
  margin-top: 1rem;
}

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
}

/* A plain list of page links, such as the module pages on the guild overview (A7.5). */
.link-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
}

/* p1polish item 10: each item is the tile, so its help text sits inside the box and tiles in a row share a height (the
   grid keeps align-items: stretch). The link's ::after covers the tile, so the whole tile is the link, as U9's overview
   card is; every item holds exactly one link and no other control. The tile draws the link's focus ring around itself,
   and the link keeps its own. */
.link-list > li {
  position: relative;
  display: grid;
  align-content: start;
  gap: 0.25rem;
  padding-block: 0.75rem;
  padding-inline: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
}

.link-list a {
  color: var(--text);
  font-weight: var(--weight-strong);
  text-decoration: none;
}

.link-list a::after {
  content: '';
  position: absolute;
  inset: 0;
}

.link-list > li:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-raised);
}

.link-list > li:hover a {
  color: var(--accent);
  text-decoration: underline;
}

.link-list > li:has(a:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* A generated module page: the form, with the preview beside it on wide screens (A7.6). */
.split {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 68rem) {
  .split {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    align-items: start;
  }

  .split > .preview-pane {
    position: sticky;
    top: 1rem;
    /* p3polish item 4: a preview taller than the screen scrolls inside its sticky pane (the aside takes Tab, so a
       keyboard can scroll it too), and a scroll that reaches its end does not move the page. */
    max-block-size: calc(100dvh - 2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  /* p3polish item 3: on a page with the preview beside the form, the save bar ends under the form column (the 3fr and
     2fr columns and the 1.5rem gap leave the preview 40% plus 0.9rem), so it never runs under the preview. */
  .split + .save-bar {
    margin-inline-end: calc(40% + 0.9rem);
  }
}

/* Surfaces */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.card > :last-child {
  margin-bottom: 0;
}

/* p1polish item 3: no empty band above a card that opens with a heading (the headings' 1.6em top margin), and no
   bottom margin under the preview placeholder, whose card ends with the visually hidden live region. */
.card > :first-child {
  margin-block-start: 0;
}

.preview-slot > :last-child {
  margin-block-end: 0;
}

/* p2polish item 3: the Preview pane's heading is a small muted label, so the eye goes to the form first. It stays an
   h2, so the aside's aria-labelledby name is unchanged. --text-muted is 4.5:1 or more on --surface in both themes. */
.preview-pane > h2 {
  margin-block-end: 0.5rem;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-strong);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hero {
  max-width: 40rem;
  margin: 3rem auto;
  text-align: center;
}

.hero h1 {
  font-size: 2.4rem;
}

.prose {
  max-width: 44rem;
  margin: 0 auto;
}

.prose li + li {
  margin-top: 0.5rem;
}

.notice {
  border: 1px solid var(--border);
  border-inline-start-width: 4px;
  border-radius: var(--radius-small);
  background: var(--surface-muted);
  padding: 0.75rem 1rem;
}

.notice-warning {
  border-color: var(--warning);
  background: var(--warning-soft);
}

.notice-error {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.notice-success {
  border-color: var(--success);
  background: var(--success-soft);
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

/* The overview's state chips (u9.md item 6) share the badge colors: active is success, doing nothing is warning and
   needs attention is danger. Their shape is .module-state, in the overview's status section. */
.badge-warning,
.module-state-idle {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-danger,
.module-state-attention {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-success,
.module-state-active {
  background: var(--success-soft);
  color: var(--success);
}

/* Buttons */

/* The 0.65rem block padding (u7.md item 3): with the 1.2 line height and the border a button is 42 px, the height of an
   input and a single select. No block size here: the card designer's handles are <button>s that reset only their
   padding. */
.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: var(--weight-medium);
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.button:hover,
button:hover {
  background: var(--surface-muted);
  color: var(--text);
}

/* p3polish item 2: press feedback. Each :active rule comes right after its hover rule with the same reach, so the
   later or more specific switch, quiet and Copy ID buttons keep their own look when pressed, as they do on hover. The
   press fill is p2polish item 8's --nav-hover (--text is 13.11:1 on it in light and 11.04:1 in dark). No transition. */
.button:active,
button:active {
  background: var(--nav-hover);
  color: var(--text);
}

.button-primary,
button.button-primary {
  /* p3polish item 1: the fill and edge come from their own tokens, a saturated blue in dark; light keeps --accent. */
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--on-accent);
  font-weight: var(--weight-strong);
}

.button-primary:hover,
button.button-primary:hover {
  /* p3polish item 1: the hover fill and edge from their own tokens; light keeps --accent-hover. */
  background: var(--accent-fill-hover);
  border-color: var(--accent-fill-hover);
  color: var(--on-accent);
}

/* p3polish item 2: a pressed primary takes its hover fill. */
.button-primary:active,
button.button-primary:active {
  background: var(--accent-fill-hover);
  border-color: var(--accent-fill-hover);
  color: var(--on-accent);
}

.button-danger,
button.button-danger {
  background: var(--danger);
  border-color: var(--danger);
  /* p2polish item 2: the theme's text on danger, so the label reads in dark mode too. */
  color: var(--on-danger);
}

/* p2polish item 2: a solid danger button answers hover with a darker red, never the gray of .button:hover. It ties
   .button:hover and comes after it, and beats button:hover, so a danger <button> gets a hover at all. */
.button-danger:hover,
button.button-danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  color: var(--on-danger);
}

/* p3polish item 2: a pressed solid danger button takes its hover red. */
.button-danger:active,
button.button-danger:active {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  color: var(--on-danger);
}

/* p2polish item 2: row-size danger buttons and the danger link are outlined red (red edge, red text), so they mark
   danger without shouting in a row; the full-size button on a confirm page stays solid. --danger is 4.5:1 or more on
   --surface and --danger-soft in both themes. */
.button-small.button-danger,
a.button.button-danger {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
}

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

/* p3polish item 2: a pressed outlined danger button or danger link takes its hover tint. */
.button-small.button-danger:active,
a.button.button-danger:active {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.button-large {
  padding: 0.75rem 1.4rem;
  font-size: 1.05rem;
}

.button-small,
button.button-small {
  padding: 0.35rem 0.7rem;
  font-size: var(--text-sm);
}

button:disabled,
.button[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Switch view (u7.md item 7): one underline tab look for every control that switches between views of one place. The
   ticket and case page bars and the two range pickers are plain links in a labelled nav (partials/tabs.eta), the
   current one marked aria-current="page"; the message editor's Fields and JSON tabs are a radiogroup that posts _tab.
   The bar wraps rather than scrolls on a phone. Its 1rem keeps the space the Fields panel had under the tabs; no margin
   shorthand and no margin-block-start, so .stack > * + * still spaces it from what comes before. */
.tabs,
.message-tabs {
  display: flex;
  flex-wrap: wrap;
  /* p1polish item 9: no gap between tabs, since each tab's own padding spaces it, so a phone's bar fits one row. */
  gap: 0;
  margin-block-end: 1rem;
  border-block-end: 1px solid var(--border);
}

/* In the overview's and the tickets overview's stats header (a flex row) the range bar sits level with the heading,
   as .stats-head h2 and .stats-head .field-help do. */
.stats-head > .tabs {
  margin-block-end: 0;
}

/* At least 2.75rem tall, so every tab is an easy target on a phone. The -1px puts the current tab's bar over the bar's
   own line. */
.tab,
.tab-label {
  display: inline-flex;
  align-items: center;
  min-block-size: 2.75rem;
  padding-block: 0.5rem;
  /* p1polish item 9: 0.9rem from about 576 px up and about 0.6rem at 390 px, so a phone's tab bar fits one row. It
     still wraps rather than scrolls on a narrower screen. */
  padding-inline: min(0.9rem, 2.5vw);
  margin-block-end: -1px;
  color: var(--text-muted);
  font-weight: var(--weight-medium);
  text-decoration: none;
  cursor: pointer;
}

.tab:hover,
.tab-label:hover {
  color: var(--text);
}

/* The current tab: a bar under it and a heavier weight, so it never rests on color alone (U2's nav pattern). The
   padding gives back the bar's width. Under forced colors the bar is Highlight (in the one forced-colors block). */
.tab[aria-current='page'],
.tab-radio:checked + .tab-label {
  border-block-end: 3px solid var(--accent);
  padding-block-end: calc(0.5rem - 3px);
  color: var(--text);
  font-weight: var(--weight-bold);
}

/* The focus ring is drawn inside the link, as .nav-link's is, so the bar's edge never clips it. */
.tab:focus-visible {
  outline-offset: -3px;
}

.tab-radio:focus-visible + .tab-label {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Filter chips (u6.md item 10): plain links that set one filter, such as My changes on the change log; the one in
   effect carries aria-current="true", which the accent shows (its forced-colors rule is in the one forced-colors
   block). u7.md item 7 moved these rules here, before that block, so the chip's forced Highlight border applies. */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-block: 0 0.75rem;
}

.filter-chip[aria-current='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Copy ID (u6.md item 8; u7.md item 12): a quiet text control at rest in the identity group, muted and regular weight,
   with an underline on hover and the global focus ring. Smaller text than .button-small inside a row, but the same
   padding as before and a transparent 1px border, so the target never shrinks; under forced colors the border shows
   (in the one forced-colors block, which this precedes). It sets no display, so html:not(.js) .js-only still hides it. */
.identity .identity-copy {
  padding: 0.1rem 0.45rem;
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: var(--weight-normal);
}

.identity .identity-copy:hover {
  color: var(--text);
  text-decoration: underline;
}

.identity .identity-copy:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Forms */

/* min-inline-size: 0 (polish0 item 1): a fieldset defaults to min-content, so a wide child pushed a phone page wider
   than the screen. Now the child scrolls inside its own box. */
fieldset {
  min-inline-size: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 0 0 1.25rem;
}

legend {
  padding: 0 0.4rem;
  font-weight: var(--weight-bold);
}

/* align-content: start (polish0 item 2): in a filter grid a short field no longer spreads its row's height over its
   label and select. */
.field {
  display: grid;
  align-content: start;
  gap: 0.35rem;
  /* p2polish item 3: one even 20 px step between fields (the two resets after .field-help close a field's own end). */
  margin-block-end: 1.25rem;
}

label {
  font-weight: var(--weight-medium);
}

.field-help {
  color: var(--text-muted);
  font-size: var(--text-sm);
  /* p1polish item 4: help stops at a readable length instead of running far past its own 36rem control.
     p3polish item 9: it stops at the control's own 36rem, so help and controls share one right edge. */
  max-inline-size: 36rem;
}

/* p2polish item 3: no dead band after a field's last line (the p rule's 1em under help, (0,0,1), loses to (0,2,0)) and
   none after a box's last field, so the box's own padding closes it. The .array-row-body > .field and
   .limit-table .field resets tie these and come later, so they stay as they are. */
.field > :last-child {
  margin-block-end: 0;
}

.field:last-child {
  margin-block-end: 0;
}

/* p2polish item 3: the last dependent of a gated group ends .depends, not a box, so it keeps the step that spaces the
   field after the group (.gated and .depends add no margin or padding of their own). A group that ends its box gives way
   to the box's padding like any last field. (0,5,0) beats the reset above. A stated departure from item 3's two rules
   (review round 2): it names .gated and .depends, so U8's exact list of rules naming them gains this one. */
.gated:not(:last-child) > .depends > .field:last-child {
  margin-block-end: 1.25rem;
}

/* A heavier weight, so an error or a warning never rests on color alone (u7.md item 1). */
.field-error {
  color: var(--danger);
  font-size: var(--text-sm);
  font-weight: var(--weight-strong);
}

input[type='text'],
input[type='number'],
input[type='search'],
input[type='url'],
input[type='date'],
input[type='color'],
select,
textarea {
  width: 100%;
  max-width: 36rem;
  padding: 0.5rem 0.65rem;
  /* p1polish item 2: an edge you can see (3:1), not the 1.38:1 decorative --border. */
  border: 1px solid var(--border-control);
  border-radius: var(--radius-small);
  /* p3polish item 1: a field is a well. In light --control-bg equals --surface; in dark it is darker than the card. */
  background: var(--control-bg);
  color: var(--text);
  font: inherit;
}

/* Number inputs (polish0 item 3): about 10 to 12 digits wide. Same specificity as the rule above and later, so this
   beats its max-width. */
input[type='number'] {
  max-inline-size: 9rem;
}

/* Numbers sized to their digits (u7.md item 5): a whole number bounded by at most 999 either way (7, 20, 50) carries
   number-short from numberWidget. More specific than the 9rem rule above, so order does not matter. */
input[type='number'].number-short {
  max-inline-size: 5.5rem;
}

input[type='color'] {
  width: 4rem;
  padding: 0.2rem;
}

/* One control height per row (u7.md item 3). Inputs and single selects are 42 px, as a regular button is (its 0.65rem
   padding, 1.2 line height and 2 px of border). The :is() form keeps input[type='text'] in one top-level rule. Left out
   on purpose: textareas, multiple and sized selects (they keep the native list box), checkboxes, radios, ranges and
   file inputs. */
input:is([type='text'], [type='number'], [type='search'], [type='url'], [type='date'], [type='color']),
select:not([multiple], [size]) {
  block-size: var(--control-block-size);
}

/* Our own select chevron (u7.md item 4), from --select-chevron, on the inline end. More specific than the shared input
   rule, so its background shorthand does not wipe the image. Multiple and sized selects keep the native list box. Its
   forced-colors rule (the native arrow back) is in the one forced-colors block. */
select:not([multiple], [size]) {
  appearance: none;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-size: 0.75rem;
  background-position: right 0.65rem center;
  padding-inline-end: 2rem;
}

/* B26 rule 17: background-position has no logical keyword, so in a right-to-left page the chevron moves to the left. */
[dir='rtl'] select:not([multiple], [size]) {
  background-position: left 0.65rem center;
}

/* The file input's button (u7.md item 4) looks like our secondary button, at the body font. Its words stay the
   browser's own ("Choose File"). */
input[type='file'] {
  max-inline-size: 100%;
  /* p2polish item 1: the input no longer forces its .field column wider than the box on a narrow phone; the browser
     clips its own "No file chosen" text. */
  min-inline-size: 0;
  color: var(--text-muted);
  font: inherit;
}

input[type='file']::file-selector-button {
  margin-inline-end: 0.75rem;
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: var(--weight-medium);
  cursor: pointer;
}

input[type='file']:hover::file-selector-button {
  background: var(--surface-muted);
}

/* Hover and focus on text controls (p1polish item 2): the edge darkens to --text-muted on hover and turns --accent on
   keyboard focus, as well as the global focus ring. An invalid control is left out with :not(), so it keeps its
   --danger edge while the user fixes it; without that these rules would beat the (0,1,1) aria-invalid rule. Buttons,
   the file input's button, checkboxes, radios, the range and the switch are not named: they keep their own look. */
input:is([type='text'], [type='number'], [type='search'], [type='url'], [type='date']):hover:not(
    :disabled,
    [aria-invalid='true']
  ),
select:hover:not(:disabled, [aria-invalid='true']),
textarea:hover:not(:disabled, [aria-invalid='true']) {
  border-color: var(--text-muted);
}

input:is([type='text'], [type='number'], [type='search'], [type='url'], [type='date']):focus-visible:not(
    [aria-invalid='true']
  ),
select:focus-visible:not([aria-invalid='true']),
textarea:focus-visible:not([aria-invalid='true']) {
  border-color: var(--accent);
}

/* The small buttons that share a row with a control match it (u7.md item 3): Send test, the embeds Send row, the
   embeds and auto-responder searches, a union's Switch without JavaScript and the store filters. Every other small
   button keeps its size, and .button itself sets no height, so the card designer's handles do not grow. */
.send-test-row > .button-small,
.union-select > .button-small,
.store-filters .form-actions > .button-small {
  min-block-size: var(--control-block-size);
}

textarea {
  min-height: 7rem;
  resize: vertical;
}

input[aria-invalid='true'],
select[aria-invalid='true'],
textarea[aria-invalid='true'] {
  border-color: var(--danger);
}

/* A checkbox drawn as a switch (boolean fields and module switches). */
.switch {
  appearance: none;
  position: relative;
  width: 2.6rem;
  height: 1.5rem;
  margin: 0;
  border-radius: 999px;
  background: var(--switch-off);
  cursor: pointer;
  transition: background 150ms ease;
}

.switch::after {
  content: '';
  position: absolute;
  top: 0.2rem;
  inset-inline-start: 0.2rem;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 150ms ease;
}

.switch:checked {
  background: var(--accent);
}

.switch:checked::after {
  transform: translateX(1.1rem);
}

/* B26 rule 17: in a right-to-left page the knob starts on the right, so it moves left. */
[dir='rtl'] .switch:checked::after {
  transform: translateX(-1.1rem);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.5rem;
}

/* p3polish item 9: actions right after a field sit on the field's own 1.25rem end margin, with no second gap on top. */
.field + .form-actions {
  margin-block-start: 0;
}

/* The save bar (U1 item 1; a stated addition to A7.6's page layout, owed to Matt): Save after the form on the module
   pages, the settings page and the shared editor page, pinned to the bottom of the viewport while its section or form
   is in view, with or without JavaScript. Above the card designer's sticky box (z-index 2). Its unsaved text and
   Discard carry the hidden attribute until app.js shows them, and .button sets display: inline-flex, which beats the
   attribute, hence the [hidden] rule (as .card-designer-stage[hidden]). A long status scrolls inside the bar. */
.save-bar {
  position: sticky;
  /* p3polish item 3: from 40rem up the bar floats a little above the viewport's bottom edge as a finished panel. */
  inset-block-end: 0.75rem;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-block-start: 1.5rem;
  padding-block: 0.75rem;
  padding-inline: 1rem;
  border-block-start: 1px solid var(--border);
  /* p2polish item 8: side edges and rounded top corners that match the cards, so the bar reads as a finished panel,
     not a clipped strip. The phone bar runs edge to edge and drops them. */
  border-inline: 1px solid var(--border);
  border-start-start-radius: var(--radius);
  border-start-end-radius: var(--radius);
  /* p3polish item 3: a bottom edge and rounded bottom corners close the panel, so it no longer reads as a clipped card
     when it is not stuck. The phone bar drops the bottom edge again. */
  border-block-end: 1px solid var(--border);
  border-end-start-radius: var(--radius);
  border-end-end-radius: var(--radius);
  background: var(--surface);
  /* p1polish item 3: a shadow, so the bar reads as lifted over the fields that slide under it. p3polish item 3: the
     floating panel takes the raised card shadow; the phone rule keeps the soft upward one. Forced colors drop it and
     keep the edges. */
  box-shadow: var(--shadow-raised);
}

.save-bar [hidden] {
  display: none;
}

.save-bar-status {
  flex: 1 1 auto;
  max-block-size: 3em;
  overflow-y: auto;
  margin: 0;
}

.save-bar-unsaved {
  margin: 0;
  font-weight: 600;
}

/* p3polish item 3: while app.js shows the unsaved line the bar takes the accent edge and its soft fill, so a dirty form
   reads at a glance. Without JavaScript the line stays hidden and the bar looks as before; forced colors drop the
   tint and keep the text. */
.save-bar:has(> .save-bar-unsaved:not([hidden])) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* A field reached by Tab or by an anchor link scrolls clear of the bar. */
html:has(.save-bar) {
  /* p3polish item 3: the floating bar sits 0.75rem higher, so the padding grows to match. */
  scroll-padding-block-end: 6.75rem;
}

/* The restore offer (U1 item 6; part of a stated addition to A7.1, owed to Matt): after a login ended during a save,
   the page offers the edits back above its form. The offer and its "some changes" and "changed since" lines render
   hidden until app.js shows them, so without JavaScript nothing of it shows (A7.2). Its own class names, never
   .notice ones. The texts take full rows and the two buttons share the next. */
.restore-offer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding-block: 0.75rem;
  padding-inline: 1rem;
  border: 1px solid var(--accent);
  border-inline-start-width: 4px;
  border-radius: var(--radius-small);
  background: var(--accent-soft);
}

.restore-offer > p {
  flex: 1 1 100%;
  margin: 0;
}

/* The offer's display: flex and the buttons' display: inline-flex (.button, button) beat the hidden attribute, so this
   rule comes after every other .restore-offer rule, as .card-designer-stage[hidden] does. */
.restore-offer[hidden],
.restore-offer [hidden] {
  display: none;
}

/* The failure alert (U1 item 10; part of a stated addition to A7.1, owed to Matt): one per page, after <main> in
   layout.eta, where app.js shows a text when an htmx request fails. Fixed at the top of the viewport on the inline-end
   side, so it mirrors in a right-to-left page, above the save bar (z-index 3) and never over it: the bar sits at the
   bottom and the alert's height is capped. Its role="alert" paragraph is in the page, empty and never hidden at load, so
   a text set later is announced; the alert has a box (padding, border, background) only while it shows a text
   (keeper-alert-shown), so an empty one draws nothing. Dismiss carries the hidden attribute until then, and
   button-small sets display: inline-flex, which beats the attribute, hence the [hidden] rule (as .save-bar [hidden]).
   No animation. */
.keeper-alert {
  position: fixed;
  inset-block-start: 1rem;
  inset-inline-end: 1rem;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  max-inline-size: min(28rem, calc(100vw - 2rem));
  max-block-size: 40vh;
  overflow-y: auto;
}

.keeper-alert [hidden] {
  display: none;
}

.keeper-alert-text {
  flex: 1 1 auto;
  margin: 0;
}

.keeper-alert.keeper-alert-shown {
  padding-block: 0.75rem;
  padding-inline: 1rem;
  border: 1px solid var(--danger);
  border-inline-start-width: 4px;
  border-radius: var(--radius-small);
  background: var(--danger-soft);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* The navigation spine (U2 item 4; phase 1 of docs/UX-IDEAS.md idea 1; part of a stated addition to A7.6's page
   layout, SPEC 1774, owed to Matt). partials/nav.eta prints one <nav id="site-nav" popover> right before <main>, with no
   wrapper around main. Below 80rem it is the browser's own popover: while closed the user agent's rule keeps it
   display: none (no rule outside the 80rem block sets display on the closed nav), and the header's Menu button opens
   it as a sheet from the inline start, in the top layer over the save bar and the failure alert, narrower than the
   screen so a tap outside closes it. From 80rem the closed nav is a sticky sidebar column of a grid on
   body:has(> #site-nav), and Menu and Close hide. 80rem is a departure from idea 1's 68rem, not from SPEC (Matt's call,
   owed): .split, .stats-charts and .logs-events-layout go two columns at 68rem of viewport, so a 16rem column from
   there would squeeze the form and its preview; from 80rem main keeps at least 64rem, and its full width from 88rem. No
   icon rail between the two (it needs idea 5b's sprite). No ancestor of main gets overflow, so the save bar keeps
   sticking, and nothing here animates. The forced-colors rules are in the one forced-colors block below. */

/* The open sheet. The browser's popover style centers it with an auto margin, a border on every side and fit-content
   sizes, so this undoes those: full height, the border on the inline end only, scrolling inside itself. */
#site-nav:popover-open {
  margin: 0;
  border: 0;
  border-inline-end: 1px solid var(--border);
  inset-block: 0;
  inset-inline-start: 0;
  inset-inline-end: auto;
  block-size: 100dvh;
  inline-size: min(20rem, 85vw);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-block: 1rem;
  padding-inline: 0.75rem;
  color: var(--text);
  background: var(--surface);
  /* p2polish item 9: the sheet lifts off the dimmed page with the raised shadow, an x offset of 0 in every layer. */
  box-shadow: var(--shadow-raised);
}

/* p1polish item 5: a scrim dims the page behind the open sheet in both themes; a tap on it still closes the sheet
   (the popover's own light dismiss). No display and no transition. The one literal color of the pass, a stated
   exception to the token rule: before Chrome 122 and Safari 17.4 ::backdrop did not inherit custom properties from
   its element, so a var() here would compute to nothing and the scrim would vanish. Forced colors need no rule.
   p2polish item 9: the scrim is plain black at 50%, so it still darkens the dark page background, where the old
   blue-gray 45% barely showed. It stays the one literal color, for the reason above. */
#site-nav::backdrop {
  background: rgb(0 0 0 / 50%);
}

/* .button, button set display: inline-flex, which beats the hidden attribute, so the nav hides its own (as
   .save-bar [hidden]): the "No pages match." line and whatever the filter hides. */
#site-nav [hidden] {
  display: none;
}

/* p2polish item 9: Menu takes the small button's metrics, so the phone header is one 48 px row on every page, and
   shows a three-line glyph before its label: the two borders and a centered gradient line, no image and no new text.
   The button is inline-flex, so the glyph is a flex item that takes its sizes. Neither rule sets display, so the
   80rem rule still hides Menu. Forced colors drop the gradient and keep the two borders, which still read as a menu. */
.nav-menu-button {
  padding-block: 0.35rem;
  padding-inline: 0.7rem;
  font-size: var(--text-sm);
}

.nav-menu-button::before {
  content: '';
  inline-size: 0.9rem;
  block-size: 0.6rem;
  border-block: 2px solid currentColor;
  background: linear-gradient(currentColor 0 0) 0 50% / 100% 2px no-repeat;
}

/* p2polish item 9: Close is small too and floats to the inline end of the server name row, so the sheet opens with no
   row of its own for it. A browser without float: inline-end keeps it on a row above the name. */
.nav-close-button {
  float: inline-end;
  margin-inline-start: 0.5rem;
  padding-block: 0.35rem;
  padding-inline: 0.7rem;
  font-size: var(--text-sm);
}

.nav-guild {
  margin-block: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.nav-servers {
  display: inline-flex;
  align-items: center;
  min-block-size: 2.75rem;
}

/* The filter needs JavaScript, so it sits in .js-only. Its display stays less specific than html:not(.js) .js-only,
   so without JavaScript it stays hidden. */
.nav-filter {
  display: grid;
  gap: 0.35rem;
  margin-block: 0.25rem 0.75rem;
}

.nav-filter-none {
  margin-block: 0.75rem 0;
  padding-inline: 0.75rem;
  color: var(--text-muted);
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-sub {
  list-style: none;
  margin: 0;
  padding: 0;
  padding-inline-start: 1.25rem;
}

.nav-group-name {
  margin-block: 1rem 0.25rem;
  padding-inline: 0.75rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.nav-list-owner {
  margin-block-start: 0.75rem;
  padding-block-start: 0.75rem;
  border-block-start: 1px solid var(--border);
}

/* At least 2.75rem tall, so every entry is an easy target on a phone. The focus ring is drawn inside the link, so the
   nav's scroll box never cuts it off. */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-block-size: 2.75rem;
  padding-block: 0.3rem;
  padding-inline: 0.75rem;
  border-radius: var(--radius-small);
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.nav-link:hover {
  /* p2polish item 8: a fill that shows on the rail's --bg and the sheet's --surface in both themes. */
  background: var(--nav-hover);
  color: var(--text);
}

.nav-link:focus-visible {
  outline-offset: -3px;
}

/* The current page: a bar on the inline start and a heavier weight, so it never rests on color alone. The padding
   gives back the bar's width, so the text does not move. */
.nav-link[aria-current] {
  border-inline-start: 3px solid var(--accent);
  padding-inline-start: calc(0.75rem - 3px);
  font-weight: 700;
  /* p1polish item 11: a tint as well, on the rail and the phone sheet. This rule ties .nav-link:hover and comes after
     it, so the current entry keeps its tint on hover. */
  background: var(--accent-soft);
}

.nav-text {
  flex: 1 1 auto;
  min-inline-size: 0;
}

/* A module's state: filled while on, a hollow ring while off (with the hidden core.web.nav.off text), so it never rests
   on color alone. Both colors reach 3:1 on --surface, --surface-muted and --bg in both themes (WCAG 1.4.11, as
   guidance). */
.nav-state {
  flex: none;
  inline-size: 0.65rem;
  block-size: 0.65rem;
  border: 2px solid;
  border-radius: 50%;
}

.nav-state-on {
  border-color: var(--success);
  background: var(--success);
}

.nav-state-off {
  border-color: var(--switch-off);
  background: transparent;
}

/* A module's count of setup problems: a number, read through its hidden core.web.overview.issues text. */
.nav-issues {
  flex: none;
  min-inline-size: 1.5rem;
  padding-inline: 0.35rem;
  border: 1px solid var(--warning);
  border-radius: 999px;
  color: var(--warning);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

/* From 80rem: four columns (two flexible gutters around the 16rem sidebar and main), so the sidebar and main stay
   centered together. The skip link and #keeper-live are absolute and .keeper-alert is fixed, so they take no cell; the
   header and the footer span every column. The grid placement of the nav is a rule of its own with no :popover-open:
   a browser that knows :has but not popover drops every rule naming :popover-open, and this one still puts the nav in
   the sidebar column there. #site-nav:not(:popover-open) undoes everything the browser's popover style sets, even on a
   closed popover; an open one sits in the top layer and ignores the grid. Menu and Close hide, by rules as specific as
   .button and later. */
@media (min-width: 80rem) {
  body:has(> #site-nav) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 16rem minmax(0, var(--page-width)) minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
  }

  body:has(> #site-nav) > .site-header {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  body:has(> #site-nav) > .site-footer {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  body:has(> #site-nav) > .page {
    grid-column: 3;
    grid-row: 2;
    margin-inline: 0;
    max-inline-size: none;
  }

  body:has(> #site-nav) .site-header-inner {
    max-inline-size: calc(var(--page-width) + 16rem);
  }

  body:has(> #site-nav) > #site-nav {
    grid-column: 2;
    grid-row: 2;
  }

  #site-nav:not(:popover-open) {
    display: block;
    position: sticky;
    inset: auto;
    inset-block-start: 0;
    align-self: start;
    margin: 0;
    inline-size: auto;
    block-size: auto;
    max-block-size: 100dvh;
    overflow-y: auto;
    border: 0;
    padding-block: 1.25rem;
    padding-inline: 0.75rem;
    color: inherit;
    /* p1polish item 11: a flat rail on the page background with no edge line, so no short panel ends partway down a
       long page and no gray strip shows beside it. */
    background: transparent;
  }

  .nav-menu-button,
  .nav-close-button {
    display: none;
  }

  /* p1polish item 11: denser rows on the rail, so more entries fit the first screen. 2.25rem stays above WCAG 2.5.8's
     24 px; the top-level 2.75rem holds for the phone sheet. */
  .nav-link {
    min-block-size: 2.25rem;
    padding-block: 0.2rem;
    font-size: var(--text-sm);
  }

  /* p2polish item 8: a quieter rail head. "Your servers" takes the breadcrumb's muted look, and the filter's label and
     box shrink to the rows they filter. None sets display, so the filter's js-only hide still wins, and the input
     uses a literal size, so only the two paired control-height rules use var(--control-block-size). The phone sheet
     keeps its 2.75rem targets. */
  .nav-servers {
    min-block-size: 2rem;
    color: var(--text-muted);
    font-size: var(--text-sm);
    text-decoration-color: var(--border-control);
  }

  .nav-filter label {
    color: var(--text-muted);
    font-size: var(--text-sm);
  }

  .nav-filter input {
    block-size: 2.25rem;
    font-size: var(--text-sm);
  }

  /* p2polish item 4: on a module page without a preview and on Server settings, a labelled field reads as a settings
     row, the label in a 13rem column on the inline start and the control, help, errors and warnings beside it. Only
     module.eta's no-preview wrapper and settings.eta's form match, so the network, editor and split pages keep the
     stacked look; switch rows, list row fields and limit table cells stay out through :not(), and a field with a
     visually hidden label through :has(). The label spans the control's rows, its top padding puts it on the
     control's text line, and with no row gap the empty rows the span creates cost nothing, so help keeps its
     0.35rem under the control. Choice groups keep their stacked legend: in the spike a floated legend did not line
     up with its list, while these rules alone read cleanly beside them. Grid columns follow the writing direction,
     so right-to-left needs no rule, and label, control and help keep their markup order (A7.6). */
  :is(.module-body, .settings-page)
    > .module-form
    > .form-fields
    .field:not(.field-switch, .array-row-body .field, .limit-table .field):has(> label:not(.visually-hidden)) {
    grid-template-columns: minmax(0, 13rem) minmax(0, 1fr);
    column-gap: 2rem;
    row-gap: 0;
  }

  :is(.module-body, .settings-page)
    > .module-form
    > .form-fields
    .field:not(.field-switch, .array-row-body .field, .limit-table .field):has(> label:not(.visually-hidden))
    > * {
    grid-column: 2;
  }

  :is(.module-body, .settings-page)
    > .module-form
    > .form-fields
    .field:not(.field-switch, .array-row-body .field, .limit-table .field):has(> label:not(.visually-hidden))
    > label {
    grid-column: 1;
    grid-row: 1 / span 4;
    padding-block-start: 0.55rem;
  }

  :is(.module-body, .settings-page)
    > .module-form
    > .form-fields
    .field:not(.field-switch, .array-row-body .field, .limit-table .field):has(> label:not(.visually-hidden))
    > :not(label)
    + * {
    margin-block-start: 0.35rem;
  }

  /* p2polish item 6: with the sidebar shown, the overview header's Cases, Server settings, Change log and Images
     buttons repeat its first entries, so they hide. Only the overview's header nav matches: the images and command
     settings jump links share .overview-nav but sit outside .overview-header. The links stay in the markup (A7.5),
     and below 80rem, where the sidebar is a Menu sheet, the buttons show as before. */
  body:has(> #site-nav) .overview-header > .overview-nav {
    display: none;
  }

  /* p3polish item 10: the case page reads as a detail view. The details sit in a 20rem column beside the reason,
     evidence, related cases and forms, and dense flow puts the reason on the details' first row. The breadcrumb, h1
     and notices span both columns, and the grid gap replaces .stack's margin. The details span the six column-one
     sections, which always render (each has a fallback line), and list their fields one to a row. Revoke stays last
     in the markup, so the visual order is the DOM order. */
  .warnings-case-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 20rem;
    grid-auto-flow: row dense;
    gap: 1rem 1.5rem;
    align-items: start;
  }

  .warnings-case-page > :not(.card) {
    grid-column: 1 / -1;
  }

  .warnings-case-page > * + * {
    margin-block-start: 0;
  }

  .warnings-case-page > #details {
    grid-column: 2;
    grid-row: span 6;
  }

  .warnings-case-page > #details .system-fields {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Generated forms (A7.6): widgets, repeatable rows, union choices and the member search. */

.form-fields {
  display: grid;
  /* p1polish item 1: one column no wider than the form, so no field's max-content can push the form past its
     surface. */
  grid-template-columns: minmax(0, 1fr);
}

/* One surface per form (u7.md item 2 (a)): a generated form sits on one card-like surface, and its groups lose their
   own boxes below. Inside a card (the network pages, the bot-identity guild page) it adds no second box. The global
   fieldset and legend rules keep their look for every fieldset outside a generated form. */
.module-form > .form-fields {
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.module-form > .form-fields > :last-child {
  margin-block-end: 0;
}

.card .module-form > .form-fields {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  /* p1polish item 6: more specific than the phone rule's margin-inline: -1rem, so a form inside a card stays inset. */
  margin-inline: 0;
}

/* p2polish item 7: a module with nothing to set (Store, Credits) shows no empty box and no lone Save. Its form holds
   only the visually hidden default submit; any field, notice, section index or Basics is a second child, so the box
   and the bar stay. The bar's own rules are untouched (its subject here is the wrapper's next sibling), and without
   :has() both rules drop and the page looks as before. Skipping the form on the server is owed to pass 4. */
.module-form > .form-fields:has(> button.visually-hidden:only-child) {
  display: none;
}

/* p2polish item 7, review round 2: the bar stays when it carries a save result. Reset to defaults and Import answer
   with ?saved=1, and the bar's status line is where "Settings saved" shows and where app.js moves focus so a screen
   reader announces it; hiding the bar would hide both. The :has() in :not() sits beside the first one, not inside it. */
:is(.module-body, .split):has(> .module-form > .form-fields > button.visually-hidden:only-child)
  + .save-bar:not(:has(> [data-save-result])) {
  display: none;
}

/* p2polish item 7, review round 2: when the bar is there only to confirm a save, its lone Save has nothing to save. */
:is(.module-body, .split):has(> .module-form > .form-fields > button.visually-hidden:only-child) + .save-bar > button {
  display: none;
}

/* Top-level groups read as sections (u7.md item 2 (b)): no box, a line between them and a heading-sized title. These
   rules are retargeted by U8: sections use the .form-section rules below (u8.md item 7), and these stay for the
   unsectioned top-level groups (every page without hints, and loose groups on a structured page). A choice group (item
   2 (e)) reads like a field, so the line treats it as one: a group that is not a choice group gets the line when any field or group
   comes before it, and a field or a choice group gets it right after such a group, so it does not read as part of the
   section above. The first group gets none. Both line selectors are (0,4,0), above the choice rule's (0,3,0), so its
   border: 0 never removes a line. The float takes the legend off the border line and into the content. */
.form-fields > .field-group {
  border: 0;
  border-radius: 0;
  padding: 0;
  margin-block: 0 1.5rem;
}

.form-fields > :is(.field, .field-group) ~ .field-group:not(:has(> .radio-list, > .check-list, > .asset-choices)),
.form-fields > .field-group:not(:has(> .radio-list, > .check-list, > .asset-choices)) + :is(.field, .field-group) {
  border-block-start: 1px solid var(--border);
  padding-block-start: 1.25rem;
}

.form-fields > .field-group > legend {
  float: inline-start;
  inline-size: 100%;
  padding: 0;
  margin-block-end: 0.75rem;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

/* Nested groups (u7.md item 2 (c)): no box, only a thin rule on the inline-start side, so a level costs about 1rem.
   The bottom gap is its own weaker rule, (0,1,0) through :where(), so the resets on .array-row-body > .field-group,
   .union-body > :last-child and .logs-event-options-group still win. */
.form-fields .field-group .field-group {
  border: 0;
  border-inline-start: 2px solid var(--border);
  border-radius: 0;
  padding: 0;
  padding-inline-start: 1rem;
}

.form-fields :where(.field-group .field-group) {
  margin-block: 0 1rem;
}

.form-fields .field-group .field-group > legend {
  float: inline-start;
  inline-size: 100%;
  padding: 0;
  margin-block-end: 0.5rem;
  font-size: var(--text-md);
  font-weight: var(--weight-strong);
}

.form-fields .field-group > legend + * {
  clear: both;
}

/* Array items (u7.md item 2 (d)): the row (.array-row) stays the only box, and the item's legend ("Item 1",
   "Embed 1") becomes a muted caption. These tie the nested rules on specificity, so they come after them. */
.form-fields .array-row-body > .field-group {
  border: 0;
  padding: 0;
}

.form-fields .array-row-body > .field-group > legend {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
}

/* Choice groups read like a field (u7.md item 2 (e)): radio groups, checkbox lists and asset choices get no box or
   rule, and a legend with the look of a field's label. They tie the nested and array item rules, so they come after
   them, and stay below the section line's (0,4,0). */
.form-fields .field-group:has(> .radio-list, > .check-list, > .asset-choices) {
  border: 0;
  padding: 0;
}

.form-fields .field-group:has(> .radio-list, > .check-list, > .asset-choices) > legend {
  font-size: inherit;
  font-weight: var(--weight-medium);
  margin-block-end: 0.35rem;
}

/* Folding sections (u8.md item 7): a field with a section hint is a details.form-section whose summary holds its title
   as a heading and a one-line summary of its values, and whose fieldset draws no legend. The section takes over (b)'s
   look: no box, a line between sections and the groups or fields around them, and a heading-sized title. The line's
   second and third selectors beat the choice rule's (0,3,0), and the first and third come after it, so a choice group's
   border: 0 never removes a line. Basics is a box of its own, so the first thing after it gets no line. */
.form-fields > .form-section {
  margin-block: 0 1.25rem;
}

.form-fields > :is(.field, .field-group, .form-section) ~ .form-section,
.form-fields > .form-section ~ .field-group:not(:has(> .radio-list, > .check-list, > .asset-choices)),
.form-fields > details.form-section + :is(.field, .field-group) {
  border-block-start: 1px solid var(--border);
  padding-block-start: 1.25rem;
}

/* The section's fieldset: no box of its own. It ties the nested rule (c) and comes after it, so a nested section's
   fieldset loses (c)'s inline-start rule to the section's own, below. */
.form-fields .form-section > .field-group {
  border: 0;
  border-radius: 0;
  padding: 0;
  margin-block: 0;
}

/* A section inside a group reads like a nested group (c). */
.form-fields .field-group .form-section {
  border-inline-start: 2px solid var(--border);
  padding-inline-start: 1rem;
  margin-block: 0 0.75rem;
}

/* The summary keeps its display: list-item, so the native marker stays (it mirrors in right-to-left and shows under
   forced colors). The global :focus-visible ring covers it. */
.form-section > summary {
  cursor: pointer;
  /* p3polish item 2: a taller tap target (about 44 px with the title's line) with a matching negative margin, so no
     row moves. U8 bars @media rules naming .form-section, so this applies at every width. */
  padding-block: 0.5rem;
  margin-block: -0.5rem;
}

.form-section[open] > summary {
  /* p3polish item 2: 0.25rem after the summary's 0.5rem padding, so the open gap still reads 0.75rem. */
  margin-block-end: 0.25rem;
}

/* p3polish item 8: a folded section answers hover, not only with the pointer: its title takes the accent color (5.73:1
   light and 5.65:1 dark on --surface). */
.form-section > summary:hover .form-section-title {
  color: var(--accent);
}

/* p3polish item 8: one muted, small marker for every folded section and footer tool, whatever its title's size and
   color. It stays the native marker (above), so it still mirrors in right-to-left and shows under forced colors. */
:is(.form-section, .module-tool) > summary::marker {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* The title has (b)'s legend look; a section inside a section has (c)'s, matching its heading level. */
.form-section-title {
  display: inline;
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

.form-section .form-section .form-section-title {
  font-size: var(--text-md);
  font-weight: var(--weight-strong);
}

/* p3polish item 8: in a form inside a card (the network pages and the bot-identity guild page) a section title steps
   below the card's h2. Command settings is not a .module-form, so its module titles keep --text-lg. */
.card .module-form .form-section-title {
  font-size: var(--text-md);
}

/* The summary line shows only while the section is closed, so an open section never shows one that unsaved edits may
   have made stale. */
.form-section-state {
  margin-inline-start: 0.5rem;
  color: var(--text-muted);
  font-size: var(--text-sm);
  /* p2polish item 12: the state moves as one piece. A short one stays on the title line or moves under it whole,
     and a long one becomes its own block under the title, never wrapping word by word after the title. */
  display: inline-block;
}

.form-section[open] > summary > .form-section-state {
  display: none;
}

/* Basics (u8.md item 7): the one to three fields that make a module do anything, on a muted box before the sections.
   The transparent border shows under forced colors. A group in Basics (welcome's message editor) reads like a field:
   neither (b) nor (c) reaches it, so without these the global fieldset box and legend would apply. */
.form-basics {
  padding: 1rem 1.25rem;
  margin-block-end: 1.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.form-basics > :is(h2, h3) {
  margin-block: 0 0.75rem;
  font-size: var(--text-lg);
}

.form-fields .form-basics > .field-group {
  border: 0;
  border-radius: 0;
  padding: 0;
  margin-block: 0 1rem;
}

.form-fields .form-basics > .field-group > legend {
  float: inline-start;
  inline-size: 100%;
  padding: 0;
  margin-block-end: 0.5rem;
  font-weight: var(--weight-medium);
}

/* The On this page index (u8.md item 7): plain links in one wrapping row. */
.section-index {
  margin-block-end: 1rem;
}

.section-index ul {
  display: flex;
  flex-wrap: wrap;
  /* p1polish item 9: one gap both ways between the chips. */
  gap: 0.4rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

/* On this page chips (p1polish item 9): each link is a rounded chip, one 2.25rem size at every width, which is above
   WCAG 2.5.8's 24 px target. They stay plain anchors with the global focus ring, and the edge darkens on hover. No
   @media rule names .section-index (U8), and under forced colors the border takes the system color. */
.section-index a {
  display: inline-flex;
  align-items: center;
  min-block-size: 2.25rem;
  padding-inline: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-decoration: none;
}

.section-index a:hover {
  background: var(--surface-muted);
  border-color: var(--border-control);
}

/* Sub-settings hidden while their switch is off (u8.md item 7). Only the gate's switch is a direct-child .field-switch
   of .gated, since a dependent switch sits inside .depends. The values still post: display: none never removes a
   control from the form. The reveal rule is later and more specific, so an invalid, refused or warned dependent, or the
   :target of a setup-check link, shows while the switch is off and never blocks Save; groupShell carries no
   aria-invalid, so .field-errors and .field-warnings stand for a refused fieldset. .gated and .depends set no display of
   their own, so revert lands on the browser's block. */
.gated:has(> .field-switch .switch:not(:checked)) > .depends {
  display: none;
}

.gated:has(> .field-switch .switch:checked) > .depends-note {
  display: none;
}

.gated:has(> .field-switch .switch:not(:checked))
  > .depends:has(:invalid, [aria-invalid='true'], .field-errors, .field-warnings, :target) {
  display: revert;
}

.form-errors ul {
  margin: 0.5rem 0 0;
}

.form-errors {
  margin-bottom: 1.25rem;
}

.field-errors > .field-error {
  margin: 0;
}

/* A5.1 "Validation": save-time warnings under a field and in one notice at the top of the form; they never block. */
.field-warning {
  color: var(--warning);
  font-size: var(--text-sm);
  font-weight: var(--weight-strong);
}

.field-warnings > .field-warning {
  margin: 0;
}

.form-warnings ul {
  margin: 0.5rem 0 0;
}

.form-warnings {
  margin-bottom: 1.25rem;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.radio-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
}

.radio,
.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: var(--weight-medium);
}

.slider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 36rem;
}

.slider input[type='range'] {
  flex: 1;
}

.slider output {
  min-width: 2.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.duration-input,
.color-input,
.union-select {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.duration-input input[type='number'] {
  max-width: 9rem;
}

.duration-input select {
  width: auto;
}

.union-select select {
  flex: 1 1 14rem;
}

.union-body > :last-child {
  margin-bottom: 0;
}

.array-rows {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

/* An empty list's slot (p1polish item 3): a dashed box where the rows will go, so "Nothing added yet." no longer floats
   between the help and the Add button. The border is decorative, so it keeps --border; forced colors draw it. */
.array-empty {
  margin-block: 0 0.75rem;
  padding-block: 0.75rem;
  padding-inline: 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-small);
  text-align: center;
  font-size: var(--text-sm);
}

/* p3polish item 9: a generated form's list rows and empty slot stop near the controls instead of spanning a wide card,
   so a row's muted band ends with its fields. Page-level empty slots keep their width. */
.form-fields :is(.array-rows, .array-empty) {
  max-inline-size: 46rem;
}

/* p3polish item 12: page-level empty lists and tables use the same dashed slot. One that ends a card drops the slot's
   own bottom margin ((0,2,0) beats .array-empty, which beats .card > :last-child), and one in a .stack keeps the
   stack's 1rem gap above it ((0,2,0) beats .array-empty's later margin-block), so it never touches the filter card or
   summary line above it. */
.card > .array-empty:last-child {
  margin-block-end: 0;
}

.stack > * + .array-empty {
  margin-block-start: 1rem;
}

.array-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface-muted);
}

.array-row-body {
  flex: 1 1 18rem;
  min-width: 0;
  /* p2polish item 5: the body stops just past the 36rem control, so the row actions sit next to it instead of at the
     far edge of a wide card. */
  max-inline-size: 37rem;
}

.array-row-body > .field,
.array-row-body > .field-group {
  margin-bottom: 0;
}

/* p2polish item 5: a row with one control centers its actions on that control, with no third control-height rule. */
.array-row:has(> .array-row-body > .field:only-child) {
  align-items: center;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* p2polish item 5: a one-item list shows no dead Move buttons. Remove (.button-quiet) stays, disabled or not. The
   child combinator before .row-actions keeps a list nested in a lone row (a starboard board's channels) whole. The
   server renders the rows again after every Add, Remove and Move, so the disabled state is always fresh, and a
   disabled button cannot take focus, so no focus marker can point at a hidden one. */
.array-rows > .array-row:only-child > .row-actions > button:disabled:not(.button-quiet) {
  display: none;
}

/* p3polish item 6: a toolbar printed straight in a card (the ticket panels' Create a panel and its count) centers its
   items on one line and sits clear of the table under it. List rows hold their actions in an li, never a card. */
.card > .row-actions {
  align-items: center;
  gap: 0.75rem;
  margin-block-end: 1rem;
}

.array-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.array-count {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.button-quiet,
button.button-quiet {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
}

/* p2polish item 2: an enabled Remove tints red on hover; a disabled one (view-only) gets no tint, so a dead control
   never looks live. */
button.button-quiet:hover:not(:disabled) {
  background: var(--danger-soft);
  color: var(--danger);
}

.json-input {
  font-family: var(--mono);
  font-size: 0.9rem;
}

.user-current {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.member-search {
  display: grid;
  gap: 0.4rem;
  max-width: 36rem;
}

.member-result-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

.member-result,
button.member-result {
  width: 100%;
  justify-content: flex-start;
  font-weight: 500;
}

/* Module pages (A7.6, B27 rules 4 to 6): header with the switch, setup-check results, footer tools. */

.breadcrumb {
  margin: 0;
  font-size: 0.9rem;
}

/* A quieter breadcrumb (p1polish item 4), so it no longer competes with the h1. It keeps its underline, so it still
   reads as a link (--text-muted is 6.13:1 on --surface and 5.67:1 on --bg), and turns accent on hover. */
.breadcrumb a {
  color: var(--text-muted);
  text-decoration-color: var(--border-control);
}

.breadcrumb a:hover {
  color: var(--accent);
}

.module-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}

.module-heading {
  flex: 1 1 20rem;
  min-width: 0;
}

.module-heading > :last-child {
  margin-bottom: 0;
}

.module-switch {
  display: grid;
  gap: 0.6rem;
  max-width: 36rem;
}

.module-switch-form {
  display: flex;
  align-items: center;
}

/* The module switch: a submit button drawn like the .switch checkbox, with its state as text beside it. */
.switch-button,
button.switch-button {
  gap: 0.6rem;
  padding: 0.35rem 0.6rem;
  background: transparent;
  border-color: transparent;
}

.switch-track {
  position: relative;
  display: inline-block;
  width: 2.6rem;
  height: 1.5rem;
  border-radius: 999px;
  background: var(--switch-off);
  transition: background 150ms ease;
}

.switch-track::after {
  content: '';
  position: absolute;
  top: 0.2rem;
  inset-inline-start: 0.2rem;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 150ms ease;
}

.switch-button[aria-checked='true'] .switch-track {
  background: var(--accent);
}

.switch-button[aria-checked='true'] .switch-track::after {
  transform: translateX(1.1rem);
}

[dir='rtl'] .switch-button[aria-checked='true'] .switch-track::after {
  transform: translateX(-1.1rem);
}

/* p3polish item 7: a smaller, quieter switch on the overview's module cards, so the module names lead. The knob keeps
   its 0.2rem offsets and travels 0.9rem, so the forced-colors offsets below still center it and need no rule of their
   own. The state keeps its On or Off text in muted small type, and the button keeps its padding, so the target stays
   about 32 px. The module page header's switch keeps its size. The right-to-left mirror is more specific, so it beats
   the card's own on rule as well as the generic mirror above. */
.module-card .switch-track {
  inline-size: 2.2rem;
  block-size: 1.3rem;
}

.module-card .switch-track::after {
  inline-size: 0.9rem;
  block-size: 0.9rem;
}

.module-card .switch-button[aria-checked='true'] .switch-track::after {
  transform: translateX(0.9rem);
}

[dir='rtl'] .module-card .switch-button[aria-checked='true'] .switch-track::after {
  transform: translateX(-0.9rem);
}

.module-card .switch-state {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* Forced colors (polish0 item 4), for both switches. Without forced-color-adjust: none the track and the knob both
   become Canvas and the switch disappears. The knob's offsets drop by the 1px border, so it stays centered. The module
   switch is a button (partials/module-switch.eta), so its on state is aria-checked, never :checked.
   forced-color-adjust: none also stops forcing the form switch's outline, so its focus ring takes the text color;
   the module switch's ring is on its button, which stays forced. */
@media (forced-colors: active) {
  .switch,
  .switch-track {
    forced-color-adjust: none;
    border: 1px solid ButtonText;
    background: Canvas;
  }

  .switch::after,
  .switch-track::after {
    top: calc(0.2rem - 1px);
    inset-inline-start: calc(0.2rem - 1px);
    background: ButtonText;
  }

  .switch:checked,
  .switch-button[aria-checked='true'] .switch-track {
    border-color: Highlight;
    background: Highlight;
  }

  .switch:checked::after,
  .switch-button[aria-checked='true'] .switch-track::after {
    background: HighlightText;
  }

  .switch:focus-visible {
    outline-color: CanvasText;
  }

  /* U1 item 1: the bar and the page are both Canvas here, so its top border is what shows where it starts. */
  .save-bar {
    border-block-start-color: CanvasText;
  }

  /* U1 item 10: the shown alert's background becomes Canvas like the page, so its border is what outlines it. */
  .keeper-alert.keeper-alert-shown {
    border-color: CanvasText;
  }

  /* U2 item 4: the module marks and the problem count take system colors. The on mark keeps its fill with
     forced-color-adjust: none (otherwise it would become Canvas, a ring like the off one), and the current entry's bar
     stays visible. */
  .nav-state-on {
    forced-color-adjust: none;
    border-color: Highlight;
    background: Highlight;
  }

  .nav-state-off {
    border-color: CanvasText;
  }

  .nav-issues {
    border-color: CanvasText;
    color: CanvasText;
  }

  .nav-link[aria-current] {
    border-inline-start-color: Highlight;
  }

  /* U6 item 8: a role's dot keeps its fill and draws its ring (stroke currentColor) in the text color, so it shows on
     Canvas whatever the role's color; a role without a color is the ring alone. */
  .identity-dot {
    forced-color-adjust: none;
    color: CanvasText;
  }

  /* U6 item 10: the filter chip in effect keeps a border of its own color, since its accent background is forced away. */
  .filter-chip[aria-current='true'] {
    border-color: Highlight;
  }

  /* u7.md item 12: Copy ID has a transparent border at rest; here it shows, so the control reads as a button. */
  .identity .identity-copy {
    border-color: ButtonText;
  }

  /* u7.md item 7: the current tab's bar keeps a system color of its own. */
  .tab[aria-current='page'],
  .tab-radio:checked + .tab-label {
    border-block-end-color: Highlight;
  }

  /* u7.md item 4: forced colors leave a url() image alone, so the chevron's fixed stroke could vanish on the forced
     background; the native arrow comes back instead. */
  select:not([multiple], [size]) {
    appearance: auto;
    background-image: none;
  }
}

.switch-state {
  min-width: 2rem;
  text-align: start;
}

.switch-prompt > :last-child,
.conflict-notice > :last-child,
.setup-issues > :last-child {
  margin-bottom: 0;
}

.switch-prompt .form-actions {
  margin-top: 0.5rem;
}

.setup-issues ul {
  margin: 0.25rem 0 0;
  padding-inline-start: 1.25rem;
}

.module-footer {
  display: grid;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.module-footer > .form-actions {
  margin-top: 0;
}

/* p3polish item 12: Export reads like the quiet tool rows under it: no fill, no visible edge and the muted title color
   (5.67:1 on --bg light, 7.68:1 dark), turning to the text color with an underline on hover. It keeps its 42 px
   height. */
.module-footer > .form-actions > .button {
  padding-inline: 0;
  border-color: transparent;
  background: none;
  color: var(--text-muted);
}

.module-footer > .form-actions > .button:hover {
  background: none;
  color: var(--text);
  text-decoration: underline;
}

.module-tool {
  /* p2polish item 7: the footer tools read as a quiet list at every width (p1polish item 6 gave this look only on a
     phone): each tool is a row under a line, not a bordered box as heavy as a form section. */
  padding-block: 0.25rem;
  padding-inline: 0;
  border: 0;
  border-block-start: 1px solid var(--border);
  border-radius: 0;
  background: none;
}

.module-tool > summary {
  cursor: pointer;
  font-weight: var(--weight-medium);
  /* p2polish item 7: a muted title that turns to the text color on hover. The footer sits on the page --bg (5.67:1
     light, 7.68:1 dark). */
  color: var(--text-muted);
  /* p3polish item 2: a taller tap target; the footer's quiet rows grow 16 px. */
  padding-block: 0.5rem;
}

/* p2polish item 7: the hovered tool's title reads as the text color (15.61:1 on --bg light, 15.3:1 dark). */
.module-tool > summary:hover {
  color: var(--text);
}

.module-tool[open] > summary {
  margin-bottom: 0.75rem;
}

/* A module's own boxes, after the footer or, with placement top, above the form (dashboard.panels; B2, B3 and B4
   Dashboard). */
.module-panels {
  display: grid;
  gap: 1rem;
  /* p1polish item 1: one column no wider than the page. The implicit auto column grew to the widest table's
     min-content and pushed every panel, and the page, sideways; now a wide table scrolls in its .table-wrap. */
  grid-template-columns: minmax(0, 1fr);
}

.module-panel > h2 {
  margin-top: 0;
}

/* The guild picker (A7.5): one card per server, with its icon, name, the viewer's level and a setup badge. */

.guild-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
}

.guild-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  height: 100%;
  color: inherit;
  text-decoration: none;
}

.guild-card:hover,
.guild-card:focus-visible {
  border-color: var(--accent);
  text-decoration: none;
  /* p3polish item 11: the card lifts with the raised shadow, as module cards and link tiles do, instead of moving with
     a transition. */
  box-shadow: var(--shadow-raised);
}

/* p3polish item 11: a chevron at the inline end, drawn with two borders (no data: URL), so forced colors draw it too.
   In right-to-left border-inline-end is the left edge, so -45deg points it to the inline end. */
.guild-card::after {
  content: '';
  flex: none;
  margin-inline-start: auto;
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border-block-start: 2px solid var(--text-muted);
  border-inline-end: 2px solid var(--text-muted);
  transform: rotate(45deg);
}

[dir='rtl'] .guild-card::after {
  transform: rotate(-45deg);
}

.guild-icon {
  flex: none;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  object-fit: cover;
}

.guild-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  overflow: hidden;
}

.guild-card-body {
  display: grid;
  gap: 0.2rem;
  justify-items: start;
  min-width: 0;
}

.guild-name {
  max-width: 100%;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guild-level {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* The server overview (A7.5, B27 rules 4, 5 and 7): setup check, modules by group, recent changes. */

.overview-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}

.overview-header h1,
.overview-header .lead {
  margin-bottom: 0;
}

.overview-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.overview-setup > h2,
.overview-changes > h2 {
  margin-top: 0;
}

.module-group + .module-group {
  margin-top: 1.5rem;
}

.module-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
}

.module-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.module-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
}

/* u10.md item 2: with a zero basis the row breaks at the title's min-content width, so a long title wraps by words and
   the switch stays on the title row, never squeezed. The head still wraps, so an open switch prompt drops below. */
.module-card-head h4 {
  margin: 0;
  /* p3polish item 7: the module name leads the card, a step above body text, beside the smaller switch. */
  font-size: var(--text-lg);
  flex: 1 1 0;
}

.module-card-head .module-switch {
  max-width: 100%;
  flex-shrink: 0;
}

/* u9.md item 6: the one-line summary (B27 rule 5). --text-muted keeps 4.5:1 on --surface-muted too, so an off card's
   summary needs no rule of its own. */
.module-card-summary {
  margin: 0;
  color: var(--text-muted);
}

.module-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: auto;
}

.recent-changes {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

.recent-change {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.recent-change:first-child {
  padding-top: 0;
}

.recent-meta,
.recent-summary {
  margin: 0;
}

.recent-meta {
  font-size: 0.85rem;
}

/* The overview's status (u9.md item 6; B27 rule 5, A7.5 row 1731). The whole card is its h4 link: the link's ::after
   covers the card, and the switch (with its dependency prompt, refusal and conflict) sits above it, so a click there
   never opens the page. Tab order stays the link, then the switch. The card draws the link's focus ring around itself;
   the link keeps its own. */
.module-card {
  position: relative;
}

.module-card h4 a::after {
  content: '';
  position: absolute;
  inset: 0;
}

.module-card .module-switch {
  position: relative;
  z-index: 1;
}

.module-card:has(h4 a:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* p1polish item 10: a calm card title in --text that turns accent and underlined, with an accent edge and a raised
   shadow, while the pointer is over the card. The card stays a link (B27 rule 5). */
.module-card h4 a {
  color: var(--text);
  text-decoration: none;
}

.module-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-raised);
}

.module-card:hover h4 a {
  color: var(--accent);
  text-decoration: underline;
}

/* An off card is muted by its background only, never by opacity, so its text keeps its contrast. The module switch is
   a button, so its off state is aria-checked='false', never :checked. */
.module-card:has(.switch-button[aria-checked='false']) {
  background: var(--surface-muted);
}

/* The state chip: the badge's shape, with a transparent border that forced colors draw, so the chip keeps an edge
   there. Its colors are in the badge rules (.module-state-active, -idle and -attention). */
.module-state {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: var(--weight-strong);
}

.module-status {
  /* p2polish item 6: a plain block, so the inline-block chip and the sentence share a line (the template prints a
     space between them) and the sentence wraps under the chip, instead of the chip taking a line of its own. */
  display: block;
  margin: 0;
}

/* A card, group or status line the filter or the state leaves out keeps its markup with the hidden attribute (item 4).
   .module-card's display: flex and .module-status's would otherwise beat the browser's own [hidden] rule. */
.module-card[hidden],
.module-group[hidden],
.module-status[hidden] {
  display: none;
}

/* The setup section: with nothing to report, the heading and the All set chip share one row. */
.overview-setup-pass {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  /* p2polish item 6: a slim row with no shadow, since it only says nothing is wrong. The card and its chip stay, as
     the switch route swaps #overview-setup out of band. On a phone the later phone .card padding of 1rem ties and
     wins over this one, so p3polish item 7's .card.overview-setup-pass rule below keeps the row slim there too. */
  padding-block: 0.75rem;
  box-shadow: none;
}

.overview-setup-pass > h2,
.overview-setup-pass > .setup-pass {
  margin: 0;
}

/* p3polish item 7: All set is a slim row at every width. At (0,2,0) this beats the phone .card padding, so no @media
   rule has to name the row. */
.card.overview-setup-pass {
  padding-block: 0.75rem;
}

.overview-auto > h2 {
  margin-block-start: 0;
}

.idle-list,
.auto-list {
  margin-block: 0 1rem;
  padding-inline-start: 1.1rem;
}

.idle-list > li + li,
.auto-list > li + li {
  margin-block-start: 0.35rem;
}

/* The All, On and Needs attention filters (item 4) sit under the modules heading; the first group's heading keeps its
   own space above it. */
.overview-modules > .tabs {
  margin-block-end: 0.5rem;
}

/* The overview's activity section (B27 rules 22 and 23): range links, totals, server-rendered SVG charts colored
   only through these classes (the CSP refuses style attributes), and the table with the same numbers. */

.stats-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}

.stats-head h2,
.stats-head .field-help {
  margin: 0;
}

.stats-totals-heading {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
}

.stats-totals {
  display: grid;
  /* p1polish item 10: auto-fit tracks, so a short row of tiles fills the row; rows stay stretched, so tiles in a row
     keep one height. */
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
  margin: 0;
}

/* p1polish item 10: tiles right under the range tabs (the tickets overview) keep a space above them. */
.stats-head + .stats-totals {
  margin-block-start: 1rem;
}

.stats-total {
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  /* p3polish item 9: the tiles sit on the card's own white, framed by their border, instead of gray boxes in a card. */
  background: var(--surface);
}

.stats-total dt {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.stats-total dd {
  margin: 0;
}

.stats-total-value {
  font-size: 1.35rem;
  font-weight: 700;
  /* p1polish item 10: a long duration wraps in even lines, and figures line up across tiles. */
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  text-wrap: balance;
}

.stats-total-change {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.stats-charts {
  display: grid;
  gap: 1rem;
  margin-top: 1.25rem;
}

@media (min-width: 68rem) {
  .stats-charts {
    grid-template-columns: 1fr 1fr;
  }
}

.stats-chart {
  margin: 0;
  min-width: 0;
}

/* p3polish item 9: a lone chart (the tickets overview's) fills its card instead of half of it. */
.stats-charts > .stats-chart:only-child {
  grid-column: 1 / -1;
}

.stats-chart figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 0.35rem;
}

.stats-chart-title {
  font-weight: 600;
}

.chart {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-baseline {
  stroke: var(--text-muted);
  stroke-width: 1;
}

/* viewBox units: a chart half the page wide shows them at about three quarters of their size. */
.chart-axis,
.chart-empty {
  fill: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
}

.chart-empty {
  font-size: 15px;
}

.chart-anchor-start {
  text-anchor: start;
}

.chart-anchor-middle {
  text-anchor: middle;
}

.chart-anchor-end {
  text-anchor: end;
}

.chart-series-members {
  color: var(--chart-members);
}

.chart-series-messages {
  color: var(--chart-messages);
}

.chart-series-joins {
  color: var(--chart-joins);
}

.chart-series-leaves {
  color: var(--chart-leaves);
}

.chart-series-voice {
  color: var(--chart-voice);
}

/* B20 rule 41: tickets opened per day, in the members color (no color of its own). */
.chart-series-tickets {
  color: var(--chart-members);
}

.chart-bar,
.chart-point {
  fill: currentColor;
}

.chart-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-bar:hover,
.chart-point:hover {
  opacity: 0.7;
}

.chart-legend {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.85rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.chart-swatch {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 2px;
  background: currentColor;
}

.stats-details {
  margin-top: 1rem;
}

.stats-details > summary {
  cursor: pointer;
}

.stats-details .table-wrap {
  max-height: 28rem;
  margin-top: 0.5rem;
  overflow: auto;
}

.stats-table th[scope='row'] {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 400;
  white-space: nowrap;
}

.stats-table td {
  font-variant-numeric: tabular-nums;
}

.stats-csv {
  margin: 1rem 0 0;
}

/* Server settings (B27 rule 13): the access list's module checklist. */
.check-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.35rem 1.25rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.field-access-modules:has(input[value='all']:checked) .check-list {
  opacity: 0.6;
}

.patch-table code {
  word-break: break-all;
}

/* app.js adds .js to <html>: buttons that stand in for JavaScript hide, parts that need it show. */
.js .noscript-only,
html:not(.js) .js-only {
  display: none;
}

/* The shared message editor (A7.6, A7.7): tabs and the layout switch are CSS, so they work without JavaScript. */

.field-message > .message-none {
  margin-bottom: 0.75rem;
}

.field-message:has(> .message-none input:checked) > .message-editor,
.field-message:not(.message-has-default):has(> .message-none input:checked) > .send-test {
  display: none;
}

/* The Fields and JSON tabs (.message-tabs, .tab-label) share the Switch view look (u7.md item 7); the panel swap stays
   here. */
.message-editor:has(> .message-tabs .tab-radio[value='json']:checked) > .message-tab-fields,
.message-editor:not(:has(> .message-tabs .tab-radio[value='json']:checked)) > .message-tab-json {
  display: none;
}

.message-tab-fields:has(> .message-layout input[value='components']:checked) > .message-classic,
.message-tab-fields:not(:has(> .message-layout input[value='components']:checked)) > .message-components {
  display: none;
}

.message-tab-json textarea {
  max-width: none;
  min-height: 16rem;
}

.field-roles select[multiple] {
  min-height: 6rem;
}

.message-card-notice {
  margin-bottom: 1rem;
}

/* The card controls of welcome and goodbye messages (P2-D item 3): the placement shows once the switch is on. */
.message-card {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.message-card:not(:has(.message-card-switch input:checked)) > .message-card-placement {
  display: none;
}

.send-test {
  display: grid;
  gap: 0.4rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.send-test-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.send-test-row select {
  flex: 1 1 14rem;
}

.send-test-notice > :last-child,
.preview-issues > :last-child {
  margin-bottom: 0;
}

.send-test-notice ul,
.preview-issues ul {
  margin: 0.25rem 0 0;
  padding-inline-start: 1.25rem;
}

/* The variable picker of template fields and the message editor (A5.1). */

.variable-picker {
  max-width: 36rem;
  font-size: 0.9rem;
}

.variable-picker > summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: var(--weight-medium);
}

.variable-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
  max-height: 16rem;
  overflow-y: auto;
}

.variable-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.6rem;
}

.variable-button,
button.variable-button {
  padding: 0.15rem 0.45rem;
  font-weight: 500;
}

.variable-description {
  color: var(--text-muted);
}

/* The message preview (A7.7): a Discord-like message in our own CSS, dark like Discord's default theme. */

.message-preview {
  display: grid;
  gap: 0.75rem;
}

.preview-field {
  margin: 0;
  color: var(--text-muted);
  /* p3polish item 4: the subject reads as the Preview label's subtitle, not as a second bold label. */
  font-size: var(--text-sm);
  font-weight: var(--weight-normal);
}

.message-preview-inline:not(:empty) {
  margin-top: 1rem;
}

/* The Preview toggle under a message editor (u6.md item 6; a stated addition to A7.6's page layout, SPEC 1774, owed to
   Matt): below the .split breakpoint the pane sits under the whole form, so each editor offers its preview right under
   it, in the toggle's own .message-preview-inline slot. It needs JavaScript and sits in .js-only, so its display stays
   less specific than html:not(.js) .js-only. From the breakpoint the pane is beside the form again and the block after
   it hides the toggle, by a rule as specific that comes later. */
.message-preview-toggle {
  display: block;
  margin-block-start: 0.75rem;
}

.message-preview-toggle > summary {
  padding-block: 0.6rem;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

@media (min-width: 68rem) {
  .message-preview-toggle {
    display: none;
  }
}

/* The card preview box (A7.7): the field's controls, then the rendered card and its contrast warnings. */

.card-preview-field {
  display: grid;
  gap: 1rem;
}

.card-preview-box {
  display: grid;
  gap: 0.6rem;
  align-content: start;
}

.card-preview-slot:empty {
  min-height: 6rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-small);
}

.card-preview-result {
  display: grid;
  gap: 0.6rem;
}

.card-preview-image {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-small);
  background: repeating-conic-gradient(#3a3d44 0% 25%, #2b2d31 0% 50%) 50% / 1rem 1rem;
}

.card-preview-notice,
.card-preview-over-black {
  margin: 0;
}

.card-preview-over-black {
  margin-top: 0.4rem;
}

/*
 * B1's card designer (B1 Dashboard): the preview first, above the layout's long list of controls, and the drag
 * layer on the card image. app.js (cardDesigner) moves the layer into the preview box and sets its place, and each
 * handle's, through element.style. On a screen tall enough the preview stays in view while the controls scroll.
 */
.card-designer {
  display: grid;
  gap: 0.6rem;
}

.card-designer .card-preview-box {
  position: relative;
  order: -1;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
}

.card-designer-stage {
  /* Physical sides on purpose: app.js measures the image's place in px from the left, on either page direction. */
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}

.card-designer-stage[hidden],
.card-handle[hidden] {
  display: none;
}

.card-handle {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 0 0.45rem;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: rgb(17 19 24 / 78%);
  color: #ffffff;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  cursor: grab;
  touch-action: none;
  pointer-events: auto;
}

.card-handle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.card-handle-dragging {
  cursor: grabbing;
}

@media (min-height: 40rem) {
  .card-designer .card-preview-box {
    position: sticky;
    /* p2polish item 9: the offset reads --designer-sticky-offset, which the phone block sets to clear its sticky
       header. Only this rule reads it, so a box that is not sticky (a short screen) ignores the phone value instead
       of shifting down over the controls under it. */
    inset-block-start: var(--designer-sticky-offset, 0.5rem);
    z-index: 2;
    box-shadow: var(--shadow);
  }
}

/* B1's status strip (B1 Dashboard). */
.welcome-status h3 {
  margin-bottom: 0.25rem;
}

.welcome-status ul {
  margin: 0;
  padding-inline-start: 1.25rem;
}

/* B6's panels (B6 Dashboard): the built-in sets with their swatches, and the current color roles. */
.color-roles-set-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.color-roles-set-form {
  display: grid;
  gap: 0.5rem;
  align-content: start;
  height: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}

.color-roles-set-name {
  margin: 0;
}

.color-roles-swatches {
  max-width: 100%;
  height: auto;
}

.color-roles-color {
  white-space: nowrap;
}

.color-roles-swatch {
  vertical-align: middle;
  margin-inline-end: 0.35rem;
}

.color-roles-swatch-none {
  stroke: var(--text-muted);
  stroke-width: 1.5;
  stroke-dasharray: 3 2;
}

.color-roles-current ul {
  margin: 0;
  padding-inline-start: 1.25rem;
}

.dc-message {
  --dc-bg: #313338;
  --dc-text: #dbdee1;
  --dc-muted: #949ba4;
  --dc-heading: #f2f3f5;
  --dc-embed-bg: #2b2d31;
  --dc-border: #1e1f22;
  --dc-link: #00a8fc;
  --dc-mention-bg: rgb(88 101 242 / 30%);
  --dc-mention-text: #c9cdfb;
  --dc-code-bg: #1e1f22;
  --dc-button: #4e5058;
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  gap: 0 0.9rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-small);
  background: var(--dc-bg);
  color: var(--dc-text);
  font-size: 0.95rem;
  line-height: 1.375;
  overflow-wrap: anywhere;
}

.dc-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: #5865f2;
}

.dc-message-body {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.dc-message-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
}

.dc-author-name {
  color: var(--dc-heading);
  font-weight: 600;
}

.dc-app-tag {
  padding: 0 0.3rem;
  border-radius: 3px;
  background: #5865f2;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.4;
}

.dc-message-time {
  color: var(--dc-muted);
  font-size: 0.75rem;
}

.dc-empty,
.dc-silent {
  margin: 0;
  color: var(--dc-muted);
  font-size: 0.85rem;
  font-style: italic;
}

/* Discord markdown */

.md-p,
.md-h1,
.md-h2,
.md-h3,
.md-subtext {
  margin: 0;
}

.md-h1,
.md-h2,
.md-h3 {
  color: var(--dc-heading);
  font-weight: 700;
  line-height: 1.25;
  margin: 0.5rem 0 0.25rem;
}

.md-h1 {
  font-size: 1.5rem;
}

.md-h2 {
  font-size: 1.25rem;
}

.md-h3 {
  font-size: 1rem;
}

.md-subtext {
  color: var(--dc-muted);
  font-size: 0.8rem;
}

.md-list {
  margin: 0.25rem 0;
  padding-inline-start: 1.5rem;
}

.md-quote {
  margin: 0.25rem 0;
  padding-block: 0;
  padding-inline: 0.75rem 0;
  border-inline-start: 4px solid #4e5058;
}

.md-code {
  padding: 0.1em 0.3em;
  border-radius: 4px;
  background: var(--dc-code-bg);
  font-size: 0.85em;
}

.md-codeblock {
  margin: 0.4rem 0;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--dc-border);
  border-radius: 4px;
  background: #2b2d31;
  white-space: pre-wrap;
  overflow-x: auto;
}

.md-spoiler {
  border-radius: 3px;
  background: #1e1f22;
  color: transparent;
}

.md-spoiler:hover,
.md-spoiler:focus {
  background: rgb(255 255 255 / 10%);
  color: inherit;
}

.md-mention {
  padding: 0 0.15rem;
  border-radius: 3px;
  background: var(--dc-mention-bg);
  color: var(--dc-mention-text);
  font-weight: 500;
}

.md-link,
.dc-embed-title-link,
.dc-embed-author-name[href],
.dc-image-link {
  color: var(--dc-link);
}

.md-emoji {
  width: 1.375em;
  height: 1.375em;
  vertical-align: bottom;
}

.md-time {
  padding: 0 0.15rem;
  border-radius: 3px;
  background: rgb(255 255 255 / 6%);
}

/* Embeds */

.dc-embeds {
  display: grid;
  gap: 0.25rem;
}

.dc-embed {
  display: flex;
  gap: 1rem;
  max-width: 32rem;
  padding-block: 0.5rem 1rem;
  padding-inline: 0.75rem 1rem;
  border-inline-start: 4px solid var(--dc-accent, var(--dc-border));
  border-radius: 4px;
  background: var(--dc-embed-bg);
}

.dc-embed-main {
  display: grid;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  padding-top: 0.25rem;
}

.dc-embed-author,
.dc-embed-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.dc-embed-author {
  color: var(--dc-heading);
  font-weight: 600;
}

.dc-embed-footer {
  color: var(--dc-muted);
  font-size: 0.75rem;
}

.dc-embed-author-icon,
.dc-embed-footer-icon {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
}

.dc-embed-footer-icon {
  width: 1.25rem;
  height: 1.25rem;
}

.dc-embed-title {
  color: var(--dc-heading);
  font-weight: 600;
}

.dc-embed-description {
  font-size: 0.875rem;
}

.dc-embed-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.dc-embed-field {
  grid-column: 1 / -1;
  font-size: 0.875rem;
}

.dc-embed-field-inline {
  grid-column: auto;
}

.dc-embed-field-name {
  color: var(--dc-heading);
  font-weight: 600;
  /* p3polish item 4: a name breaks only when a whole word cannot fit (.dc-message's anywhere split "Duratio / n"). */
  overflow-wrap: break-word;
}

.dc-embed-image-img,
.dc-gallery-img {
  display: block;
  max-height: 18rem;
  border-radius: 4px;
  object-fit: cover;
}

.dc-embed-thumbnail {
  flex: 0 0 auto;
  padding-top: 0.5rem;
}

.dc-embed-thumbnail-img,
.dc-thumbnail {
  width: 5rem;
  height: 5rem;
  border-radius: 4px;
  object-fit: cover;
}

.dc-image-link {
  display: inline-block;
  padding: 0.5rem 0.75rem;
  border: 1px dashed var(--dc-muted);
  border-radius: 4px;
  font-size: 0.8rem;
}

.dc-card-placeholder {
  display: grid;
  place-items: center;
  max-width: 32rem;
  min-height: 7rem;
  padding: 1rem;
  border: 2px dashed var(--dc-muted);
  border-radius: 8px;
  background: rgb(255 255 255 / 4%);
  color: var(--dc-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* The rendered image card in the message preview (u6.md item 5): it shrinks to the pane and keeps its proportions. */
.dc-card-image {
  display: block;
  max-inline-size: 100%;
  block-size: auto;
  border-radius: 8px;
}

/* Buttons, rows and Components V2 */

.dc-components {
  display: grid;
  gap: 0.5rem;
}

.dc-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.dc-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2rem;
  padding: 0.2rem 1rem;
  border-radius: 4px;
  background: var(--dc-button);
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}

.dc-button:hover {
  color: #ffffff;
}

.dc-button-style-1 {
  background: #5865f2;
}

.dc-button-style-3 {
  background: #248046;
}

.dc-button-style-4 {
  background: #da373c;
}

.dc-button-external {
  font-size: 0.8em;
  opacity: 0.8;
}

.dc-select {
  display: block;
  min-width: 14rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--dc-border);
  border-radius: 4px;
  background: #1e1f22;
  color: var(--dc-muted);
}

.dc-container {
  display: grid;
  gap: 0.5rem;
  max-width: 40rem;
  padding: 1rem;
  border-inline-start: 4px solid var(--dc-accent, transparent);
  border-radius: 8px;
  background: var(--dc-embed-bg);
}

.dc-container.dc-accent-none {
  border-inline-start-color: transparent;
}

.dc-section {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.dc-section-texts {
  display: grid;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}

.dc-gallery {
  display: grid;
  gap: 0.25rem;
  max-width: 32rem;
}

.dc-gallery-2,
.dc-gallery-4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dc-gallery-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dc-gallery-img {
  width: 100%;
}

.dc-separator {
  width: 100%;
  margin: 0.25rem 0;
  border: 0;
  border-top: 1px solid #3f4147;
}

.dc-separator-large {
  margin: 0.75rem 0;
}

.dc-spacer-small {
  height: 0.25rem;
}

.dc-spacer-large {
  height: 1rem;
}

.dc-spoilered {
  filter: blur(6px);
}

.dc-spoilered:hover {
  filter: none;
}

/* Reactions a module's message editor draws under the message (B5 reaction menus). */

.dc-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.dc-reaction {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.125rem 0.4rem;
  border: 1px solid #5865f2;
  border-radius: 8px;
  background: rgb(88 101 242 / 15%);
  font-size: 0.875rem;
}

.dc-reaction .md-emoji {
  width: 1.125rem;
  height: 1.125rem;
}

.dc-reaction-count {
  color: var(--dc-text);
  font-weight: 600;
}

/* The limit counters under a message editor's preview (A5.2; B13's saved messages). */

.preview-counters {
  font-size: 0.88rem;
}

.preview-counters-title {
  margin: 0;
  color: var(--text-muted);
  font-weight: 600;
}

.preview-counters ul {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.2rem;
}

.preview-counter {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
}

.preview-counter-value {
  font-variant-numeric: tabular-nums;
}

.preview-counter-over {
  color: var(--danger);
}

.preview-counter-flag {
  font-weight: 700;
}

/* B13 saved messages: the list's search and New button, and the builder's Send and Sent copies sections, which sit
   in the editor form's actions row and take a whole line after its buttons. */

.embeds-saved-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.embeds-saved-search {
  flex: 1 1 18rem;
}

.embeds-saved-search input[type='search'] {
  flex: 1 1 14rem;
}

.embeds-editor-section {
  flex: 1 1 100%;
  order: 1;
  margin-top: 1rem;
}

.embeds-editor-section > h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.embeds-copies-actions {
  margin-top: 0.75rem;
}

/* B5 role menus: the menus panel with its one-button forms, and the builder's status line, Onboarding note and existing
   message pickers. */

.self-roles-menus-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.self-roles-problems {
  margin: 0;
  padding-inline-start: 1.1rem;
  font-size: 0.9rem;
}

.self-roles-menu-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.self-roles-inline-form {
  display: inline-flex;
  margin: 0;
}

.self-roles-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.self-roles-onboarding {
  margin: 0;
}

.self-roles-anchor-show {
  margin-bottom: 0.75rem;
}

.self-roles-delete-line {
  margin: 0 0 0.5rem;
}

/* B12 auto-responder: the rule table's tools, rows, warnings and page links, Test a message and the import diff. */

.autoresponder-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.autoresponder-search {
  flex: 1 1 18rem;
}

.autoresponder-search input[type='search'] {
  flex: 1 1 14rem;
}

.autoresponder-tool-buttons,
.autoresponder-rule-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.autoresponder-trigger {
  display: block;
  margin: 0.15rem 0 0;
}

.autoresponder-rule-uses {
  font-variant-numeric: tabular-nums;
}

.autoresponder-warnings {
  margin: 0;
  padding-inline-start: 1.1rem;
  color: var(--warning);
  font-size: 0.9rem;
}

.autoresponder-pages {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.autoresponder-test-result:empty {
  display: none;
}

.autoresponder-test-answer {
  margin-top: 0.75rem;
}

.autoresponder-test-line {
  margin: 0 0 0.35rem;
}

.autoresponder-test-preview {
  margin-top: 0.75rem;
}

.autoresponder-import-list {
  margin: 0 0 0.75rem;
  padding-inline-start: 1.1rem;
}

/* Drag to reorder (app.js, data-sortable): with JavaScript, a list's own rows can be grabbed; the row being dragged
   fades. Fields and buttons inside a row keep their usual cursor. */

.js [data-sortable] > .field-array > .array-rows > .array-row,
.js tbody[data-sortable] > tr {
  cursor: grab;
}

.js [data-sortable] input,
.js [data-sortable] select,
.js [data-sortable] textarea,
.js [data-sortable] button,
.js [data-sortable] a {
  cursor: auto;
}

.js [data-sortable] button,
.js [data-sortable] a {
  cursor: pointer;
}

.sortable-dragging {
  opacity: 0.55;
}

/* The fixed palette embed and container colors snap to (preview-html.ts PREVIEW_PALETTE). */

.dc-accent-none {
  --dc-accent: #1e1f22;
}

.dc-accent-blurple {
  --dc-accent: #5865f2;
}

.dc-accent-blue {
  --dc-accent: #3498db;
}

.dc-accent-navy {
  --dc-accent: #206694;
}

.dc-accent-teal {
  --dc-accent: #1abc9c;
}

.dc-accent-green {
  --dc-accent: #57f287;
}

.dc-accent-darkgreen {
  --dc-accent: #1f8b4c;
}

.dc-accent-yellow {
  --dc-accent: #fee75c;
}

.dc-accent-gold {
  --dc-accent: #c27c0e;
}

.dc-accent-orange {
  --dc-accent: #e67e22;
}

.dc-accent-red {
  --dc-accent: #ed4245;
}

.dc-accent-darkred {
  --dc-accent: #992d22;
}

.dc-accent-pink {
  --dc-accent: #eb459e;
}

.dc-accent-purple {
  --dc-accent: #9b59b6;
}

.dc-accent-white {
  --dc-accent: #ffffff;
}

.dc-accent-grey {
  --dc-accent: #95a5a6;
}

.dc-accent-black {
  --dc-accent: #23272a;
}

/* Tables */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  /* p1polish item 1: the containing block of the cells' visually hidden labels, so they stay inside the scrollport
     instead of widening the page. No z-index, so no stacking context: the limit tables' sticky role column still sticks
     here, below the save bar and the card designer box. */
  position: relative;
}

/* p2polish item 11: a wide table shows it scrolls. The two local covers move with the content and hide each scroll
   shadow until there is more to scroll on that side; the to right and to left pair is symmetric, so right-to-left needs
   no rule. The limit tables are left out because their sticky role column would cover the start shadow. Forced colors
   drop the gradients, and without :has() the rule drops and the wrap stays flat on --surface. */
.table-wrap:not(:has(.limit-table)) {
  background:
    linear-gradient(to right, var(--surface) 40%, transparent) 0 0 / 1.5rem 100% no-repeat local,
    linear-gradient(to left, var(--surface) 40%, transparent) 100% 0 / 1.5rem 100% no-repeat local,
    linear-gradient(to right, var(--scroll-edge), transparent) 0 0 / 0.6rem 100% no-repeat scroll,
    linear-gradient(to left, var(--scroll-edge), transparent) 100% 0 / 0.6rem 100% no-repeat scroll,
    var(--surface);
}

/* p3polish item 9: a list footer or a line under a table (Add a role under a limit table) keeps a small gap above it
   instead of touching the table. */
.table-wrap + :is(.array-footer, p) {
  margin-block-start: 0.75rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  text-align: start;
  vertical-align: top;
}

th {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Row headers (polish0 item 6): names read as normal text, not as muted column labels. */
th[scope='row'],
th[scope='rowgroup'] {
  color: var(--text);
  font-size: inherit;
}

/* Header bands (p1polish item 8): column headers sit on a muted band, so the header reads as one row above the data.
   Muted text on --surface-muted keeps 4.5:1 in both themes, and .table-wrap's overflow clips the band to its radius.
   The limit tables' sticky role cell paints --surface over the band, so a more specific rule puts the header's role
   cell back on it, with no box-shadow. */
thead th {
  background: var(--surface-muted);
  font-size: var(--text-xs);
  letter-spacing: 0.02em;
  /* p3polish item 6: a column header never breaks mid-word ("Shown / as", "Posted / messages"). A wide table already
     scrolls inside .table-wrap with p2polish item 11's cue, so a longer header costs nothing. */
  white-space: nowrap;
}

.limit-table thead tr > :first-child {
  background: var(--surface-muted);
}

/* Only the table's last row loses its line, header cells included, so it does not double .table-wrap's border.
   Rows that end a tbody group above it keep theirs, and thead keeps its underline. */
tbody:last-child > tr:last-child > th,
tbody:last-child > tr:last-child > td {
  border-bottom: 0;
}

/* Tables people read (u6.md item 8; idea 8 of docs/UX-IDEAS.md): .data-table sets the cell size once and lines up the
   number columns at the inline end with digits of one width, never wrapped. .audit-table and .system-table keep their
   own rules below as aliases. */
.data-table td,
.data-table th[scope='row'] {
  font-size: 0.92rem;
}

.data-table .number {
  text-align: end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* p2polish item 10: rows with a thumbnail line up. The store items, profile uploads and image tables center their cells
   on the 48 px art, so the item link no longer sits below Kind, Status and Price. */
:is(.store-items-table, .profile-uploads-table, .assets-table) :is(td, th[scope='row']) {
  vertical-align: middle;
}

/* People, roles and channels as Discord shows them (u6.md item 8), drawn by src/dashboard/identity.ts: the 20 px round
   avatar, the name, the muted @username, Copy ID and the id, on one line that wraps as a group in a narrow cell. A
   role's dot is an SVG whose fill and stroke are attributes; its forced-colors rule is in the one forced-colors block.
   Logical properties only, so right-to-left pages mirror (B26 rule 17). */
.identity {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.4rem;
  max-inline-size: 100%;
  vertical-align: middle;
}

.identity-avatar {
  flex: none;
  inline-size: 20px;
  block-size: 20px;
  border-radius: 50%;
  object-fit: cover;
}

/* A name keeps its words whole (u7.md item 12): break-word breaks only a word too long for a line of its own and, unlike
   anywhere, does not shrink the cell's min-content, so a table column is at least as wide as its longest name word.
   The id keeps anywhere: it shows only when no name is known, and a long digit run must not widen the table. */
.identity-name {
  overflow-wrap: break-word;
}

.identity-handle {
  font-size: 0.85em;
  overflow-wrap: break-word;
}

.identity-dot {
  flex: none;
  inline-size: 0.75rem;
  block-size: 0.75rem;
}

.identity-id {
  font-family: var(--mono);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

/* Copy ID's own rules are in the Copy ID section after Switch view, before the forced-colors block (u7.md item 12). */

/* Copy ID could not reach the clipboard (app.js adds identity-id-shown): the id shows, ready to copy by hand. More
   specific than .js .noscript-only, which hides it while JavaScript runs. */
.js .identity-id-shown .identity-id {
  display: inline;
}

/* p2polish item 10: an identity in a table cell is at least 9rem wide, so the avatar and the name share a line instead
   of a tall stack, and a row drops to about one line on a phone. 9rem, the item's fallback: 11rem made the Cases and
   tickets tables scroll inside their box at 1440 px, where they did not before. No nowrap or break-all (u7.md item 12),
   and top level, as every base identity rule is (u6.md item 8). */
td .identity {
  min-inline-size: 9rem;
}

/* The panel audit log (A7.8): filters, rows that expand to their JSON Patch, and the pager. */

/* No box inside the box (p1polish item 7): the filter card is the one box, so its fieldset draws no border or padding
   of its own, and the legend reads as the card's heading, floated like a form section's legend (u7.md item 2) so it
   sits in the content instead of on a border. The global legend rule keeps its bold weight. */
.audit-filters fieldset {
  margin: 0;
  border: 0;
  padding: 0;
}

.audit-filters legend {
  float: inline-start;
  inline-size: 100%;
  padding: 0;
  margin-block-end: 0.75rem;
  font-size: var(--text-lg);
}

.audit-filters legend + * {
  clear: both;
}

.audit-filter-grid {
  display: grid;
  gap: 0 1rem;
  /* auto-fit with 11rem (p1polish item 7): the change log's five fields fit one row at 1440, and a short last row
     stretches its fields instead of leaving empty tracks. */
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
}

/* p2polish item 10: the filters' help is the smallest size, so a long help line under Member or Moderator wraps less
   and the grid's rows stay even. */
.audit-filter-grid .field-help {
  font-size: var(--text-xs);
}

.audit-filters .form-actions {
  margin-top: 0.75rem;
}

/* p3polish item 5: the Cases and tickets list summary line under the filter card is small type, not a body-size run-on. */
.audit-filters + p.muted {
  font-size: var(--text-sm);
}

.audit-table td {
  font-size: 0.92rem;
}

.audit-time {
  white-space: nowrap;
  /* p1polish item 8: digits of one width, so times line up down the column. */
  font-variant-numeric: tabular-nums;
}

.audit-id {
  display: block;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.audit-change {
  min-width: 16rem;
}

.audit-patch > summary {
  cursor: pointer;
}

/* The change log's table (u6.md item 10): one tbody per day under its heading row, and each change as two rows, the
   cells and then the summary across every column, that read as one entry: the cells' row drops its line and the
   summary sits close under them. Every rule is scoped under .change-log-table: .audit-table, .audit-row,
   .audit-change and even .audit-page are shared with the cases, tickets and invite joins tables and antiraid, which
   keep their row lines. The cases table narrows its own cells and Reason column through the .cases-table rules
   below, never through the shared classes. Logical properties only (B26 rule 17). */
.change-log-table .audit-row > td {
  border-block-end: 0;
}

.change-log-table .audit-detail-row > td {
  padding-block-start: 0;
}

.change-log-table .audit-day > th {
  background: var(--surface-muted);
  font-weight: 600;
}

/* p3polish item 5: a change's summary, or its patch, is one block that wraps at the visible width and stays in view
   while the cells above it scroll sideways inside .table-wrap; on a phone the colspan=6 cell is as wide as the table,
   so the bare text wrapped at about 900 px and ran off the screen. On desktop the table fits, so nothing moves. The
   open patch's pre keeps its own overflow. Logical properties only (B26 rule 17). */
.change-log-table .audit-detail-row > td > :is(.audit-patch, .change-log-text) {
  display: block;
  position: sticky;
  inset-inline-start: 0.75rem;
  max-inline-size: min(48rem, calc(100vw - 4.5rem));
}

/* The Cases table fits its card beside the sidebar at 1280 and 1440 px (u8.md item 11): tighter cells, the date over
   the clock (each kept whole), and a narrower Reason column whose free text may break anywhere, so a long URL does
   not widen the table. Names keep their words whole (u7.md item 12). Scoped to the cases-* classes, so the shared
   audit rules and the tickets and change log tables are untouched. .cases-table .cases-reason (0,2,0) beats
   .audit-change, and min-inline-size and min-width resolve as one property. Logical properties only (B26 rule 17). */
.cases-table :is(th, td) {
  padding-inline: 0.6rem;
}

.cases-table .cases-time {
  white-space: normal;
  /* p1polish item 8: digits of one width, so dates and clocks line up down the column. */
  font-variant-numeric: tabular-nums;
}

.cases-date,
.cases-clock {
  white-space: nowrap;
}

.cases-table .cases-reason {
  min-inline-size: 12rem;
  overflow-wrap: anywhere;
}

/* Tables people scan (p1polish item 8): the case number ("Case #21") stays on one line, and a row under the pointer
   takes a muted band so the eye can follow it across the Cases and system tables. The limit tables (an editing grid),
   the change log (two rows per entry), the tickets list and invite joins keep still rows: the last three share only
   .audit-table and .data-table, and no new rule may name the shared audit classes (u6.md item 10). */
.cases-table td:first-child {
  white-space: nowrap;
}

:is(.cases-table, .system-table:not(.limit-table)) tbody tr:hover > :is(td, th) {
  background: var(--surface-muted);
}

/* p2polish item 10: quieter case links. The case number keeps its accent color, focus ring and "Case #" text but drops
   its underline and takes a medium weight with digits of one width; the underline comes back while its row is under
   the pointer. */
.cases-table td:first-child a {
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}

.cases-table tbody tr:hover td:first-child a {
  text-decoration: underline;
}

.patch-json {
  margin: 0.5rem 0 0;
  padding: 0.6rem 0.75rem;
  max-height: 20rem;
  overflow: auto;
  border-radius: var(--radius-small);
  background: var(--surface-muted);
  white-space: pre-wrap;
  word-break: break-all;
}

.change-summary {
  margin: 0;
  padding-inline-start: 1.25rem;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

/* The owner's system page (B27 rules 26 and 27): health fields, queues, failed jobs, errors, servers and backups. */

.system-section > h2 {
  margin-top: 0;
}

.system-fields {
  display: grid;
  gap: 0.75rem 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  margin: 0;
}

.system-field dt {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.system-field dd {
  margin: 0.15rem 0 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.system-field-warn dd,
.system-warn {
  color: var(--danger);
}

.system-table td,
.system-table th[scope='row'] {
  font-size: 0.92rem;
}

.system-table .number {
  text-align: end;
  white-space: nowrap;
}

/* p2polish item 10: a job queue's name (its row header) stays on one line, so the Job queues table is one line a row
   and scrolls inside its .table-wrap on a phone. */
.queue-row > th > code {
  white-space: nowrap;
}

/* The anti-nuke limit tables' own layout (u7.md item 6; B18 Dashboard, "Role limits table" and "Command limits
   table"): an editing grid, not a .data-table. The table keeps its content width, so .table-wrap scrolls on a narrow
   screen instead of crushing the cells. Only the role select widens: the window cell's unit select keeps
   .duration-input select's width: auto. A value cell's size="9" fits "unlimited", and a window's number and unit stay
   on one line. The role column stays in view while the table scrolls, below the card designer's sticky box (z-index
   2) and the save bar (3); no box-shadow separator, whose x offset is physical. */
.limit-table {
  min-inline-size: max-content;
}

.limit-table th,
.limit-table td {
  padding-inline: 0.4rem;
}

.limit-table .field {
  margin-block-end: 0;
}

.limit-table .field-role select {
  min-inline-size: 12rem;
}

.limit-table input[type='text'] {
  inline-size: auto;
}

.limit-table .duration-input {
  flex-wrap: nowrap;
}

.limit-table .duration-input input[type='number'] {
  max-inline-size: 5rem;
}

.limit-table tr > :first-child {
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
  background: var(--surface);
}

.system-time {
  white-space: nowrap;
}

.system-id {
  font-family: var(--mono);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.system-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.system-actions form {
  margin: 0;
}

/* p3polish item 10: Revoke closes the case page as a danger zone, its card edged in the danger color. The full-size
   danger button inside stays solid, and the card keeps its surface and shadow. */
.warnings-case-page > #revoke {
  border-color: var(--danger);
}

.leave-server > summary {
  cursor: pointer;
  color: var(--danger);
}

.leave-form {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.5rem;
  min-width: 14rem;
}

/* The guild's images (A7.5, A5.3): upload form, review list, uploaded list, and the asset widget's picker (A7.6). */

.assets-section > h2 {
  margin-top: 0;
}

.asset-upload {
  display: grid;
  /* p2polish item 1: one column no wider than the card, so the upload controls stay inside it on a phone. */
  grid-template-columns: minmax(0, 1fr);
  gap: 0.25rem;
  max-width: 34rem;
}

.assets-table td {
  font-size: 0.92rem;
}

.asset-thumb {
  display: block;
  width: 8rem;
  max-width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-small);
  background: var(--surface-muted);
}

.asset-name {
  display: block;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.asset-meta {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.asset-time {
  white-space: nowrap;
}

.asset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
}

.asset-delete > summary {
  cursor: pointer;
  color: var(--danger);
}

.asset-delete form {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.5rem;
  min-width: 12rem;
}

.asset-choices {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  margin-bottom: 0.5rem;
}

.asset-choice {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

.asset-choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.asset-choice:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.asset-choice .asset-thumb {
  width: 100%;
}

.asset-choice-name {
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.asset-choice-gone .asset-choice-name {
  color: var(--text-muted);
}

.asset-manage {
  margin: 0;
  font-size: 0.9rem;
}

/* Error and standby pages */

.error-page {
  max-width: 34rem;
  margin: 3rem auto;
  text-align: center;
}

.error-code {
  margin: 0;
  font-size: 3rem;
  font-weight: 800;
  color: var(--text-muted);
}

.error-id {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-small);
  background: var(--surface-muted);
  font-family: var(--mono);
}

/* The event logs page (B19 Dashboard): the events table grouped by kind, a sample entry beside it on wide screens,
   and each event's options under it. */

.logs-events-layout {
  display: grid;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 68rem) {
  .logs-events-layout {
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 20rem);
    align-items: start;
  }

  .logs-events-layout > .logs-preview {
    position: sticky;
    top: 1rem;
  }
}

.logs-events th,
.logs-events td {
  vertical-align: middle;
}

.logs-events .field {
  margin-bottom: 0;
}

.logs-events select {
  min-width: 11rem;
}

.logs-group-heading th {
  background: var(--surface-muted);
  color: var(--text);
  font-size: 0.9rem;
}

.logs-event-name {
  color: var(--text);
  font-size: inherit;
}

.logs-event:focus-within,
.logs-event:target {
  background: var(--accent-soft);
}

.logs-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.logs-test-slot:empty {
  display: none;
}

.logs-test-slot {
  margin-top: 0.4rem;
}

.logs-test-notice {
  padding: 0.4rem 0.6rem;
  font-size: 0.88rem;
}

.logs-test-notice > p {
  margin: 0;
}

.logs-preview > h3 {
  margin-top: 0;
}

/* u11.md item 10: the Event options block sits inside its own details.form-section under the table, titled by the
   section's heading, so U8's section rules style the fold (the nested-section rule gives it the inline-start line) and
   the block no longer holds a heading of its own. */
.logs-event-options {
  display: grid;
  gap: 1rem;
}

.logs-event-options-group {
  margin: 0;
}

.logs-retention {
  margin: 0;
}

/* The command settings page (B28 Dashboard): commands by module with a switch, badges and a settings panel that
   htmx loads under the row; lists of roles and channels with a Remove button per entry and a picker to add more.
   u10.md item 13: each module's heading and rows fold into a details.form-section whose title is a
   .form-section-title, so U8's unscoped section rules style it and no rule of this section names the heading. */

.cs-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* p2polish item 7: the module cards read as one grouped list instead of a stack of tiles. No card has a shadow; each
   card after the first shares the line above it ((0,3,0) beats .stack > * + *), and corners square off where two cards
   meet. The jump links are the p1polish pill chips, about 36 px tall from the padding, the 0.875rem font, the 1.2 line
   height and the border, with no size property (U7's small-button pin). The Bypass roles list draws no box inside its
   card; the Mod and Admin lists sit in .cs-list-pair and keep theirs. */
.cs-module {
  box-shadow: none;
}

.command-settings-page > .cs-module + .cs-module {
  margin-block-start: -1px;
  border-start-start-radius: 0;
  border-start-end-radius: 0;
}

.command-settings-page > .cs-module:has(+ .cs-module) {
  border-end-start-radius: 0;
  border-end-end-radius: 0;
}

.cs-nav .button-small {
  padding-block: 0.55rem;
  border-radius: 999px;
}

.cs-section > form > .cs-list {
  border: 0;
  padding: 0;
}

.cs-commands,
.cs-badges,
.cs-entries,
.cs-switches,
.cs-alias-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cs-command {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.cs-command:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.cs-command:target {
  background: var(--accent-soft);
}

.cs-command-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem 1rem;
}

.cs-switch-form {
  display: flex;
  align-items: center;
}

.cs-command-text {
  flex: 1 1 18rem;
  min-width: 0;
}

.cs-command-name,
.cs-command-description {
  margin: 0;
}

.cs-command-description,
.cs-module-off {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.cs-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.cs-panel-slot:empty {
  display: none;
}

.cs-panel-slot {
  margin-top: 0.75rem;
}

.cs-panel {
  display: grid;
  gap: 1rem;
}

.cs-panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.cs-panel-header > h2 {
  margin: 0;
}

.cs-facts {
  margin: 0;
}

.cs-fact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
}

.cs-fact > dt {
  font-weight: 700;
}

.cs-fact > dd {
  margin: 0;
}

.cs-switches {
  display: grid;
  gap: 0.5rem;
}

.cs-list-pair {
  display: grid;
  gap: 1rem;
}

@media (min-width: 52rem) {
  .cs-list-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.cs-list {
  margin: 0 0 1rem;
}

.cs-entries {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.cs-entry {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding-block: 0.2rem;
  padding-inline: 0.6rem 0.25rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
}

.cs-deleted {
  border-color: var(--warning);
  background: var(--warning-soft);
}

.cs-list-empty {
  margin: 0 0 0.75rem;
}

.cs-list-add {
  margin-bottom: 0;
}

.cs-list-add select[multiple] {
  min-height: 7rem;
}

.cs-read-only {
  margin-bottom: 0.75rem;
}

.cs-limit {
  margin-bottom: 1rem;
}

.cs-panel-aliases > h3 {
  margin-top: 0;
}

.cs-alias-add {
  margin-top: 1rem;
}

.cs-inline-form {
  display: inline;
}

/* Bot identity (B25 Dashboard): the owner page /network/identity and the per-server page. */

.bot-identity-images {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}

.bot-identity-image {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.bot-identity-image > h3 {
  margin: 0;
}

/* The avatar shows as Discord crops it: round. The banner keeps Discord's 5:2. */
.bot-identity-avatar,
.bot-identity-thumb-avatar {
  width: 8rem;
  height: 8rem;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  background: var(--surface-muted);
}

.asset-choice .bot-identity-thumb-avatar {
  width: 6rem;
  height: 6rem;
}

.bot-identity-banner {
  display: block;
  width: 100%;
  max-width: 30rem;
  height: auto;
  aspect-ratio: 5 / 2;
  object-fit: cover;
  border-radius: var(--radius-small);
  background: var(--surface-muted);
}

.bot-identity-image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.bot-identity-image-actions form {
  flex: 1 1 12rem;
}

.bot-identity-lines,
.bot-identity-people {
  margin: 0;
  padding-inline-start: 1.25rem;
}

.bot-identity-team dt {
  font-weight: 600;
  margin-top: 0.5rem;
}

.bot-identity-team dd {
  margin-inline-start: 0;
}

.bot-identity-steps li + li {
  margin-top: 0.35rem;
}

.bot-identity-presence-preview > :first-child {
  margin-top: 0;
}

.bot-identity-activities {
  margin: 0.5rem 0;
  padding-inline-start: 1.25rem;
}

.bot-identity-activity + .bot-identity-activity {
  margin-top: 0.4rem;
}

.bot-identity-activity .badge,
.bot-identity-activity .asset-meta {
  margin-inline-start: 0.5rem;
}

.bot-identity-invite {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

/* p3polish item 9: the flex gap spaces the Server select and Make link, so neither keeps a margin of its own. */
.bot-identity-invite > :is(.field, .form-actions) {
  margin: 0;
}

.bot-identity-link {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.bot-identity-guild-layout {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr);
  align-items: start;
}

/* The member card preview: banner, an avatar over its lower edge, the name and the bio. */
.bot-identity-card {
  max-width: 20rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.bot-identity-card-banner {
  display: block;
  width: 100%;
  aspect-ratio: 5 / 2;
  object-fit: cover;
}

.bot-identity-card-banner-empty {
  background: var(--accent-soft);
}

.bot-identity-card-avatar {
  display: block;
  width: 5.5rem;
  height: 5.5rem;
  margin-block-start: -2.75rem;
  margin-inline-start: 1rem;
  object-fit: cover;
  border: 4px solid var(--surface-muted);
  border-radius: 50%;
  background: var(--surface);
}

.bot-identity-card-body {
  padding: 0.5rem 1rem 1rem;
}

.bot-identity-card-body h3 {
  margin: 0.75rem 0 0.25rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bot-identity-card-body p {
  margin: 0;
}

.bot-identity-card-name {
  font-size: 1.2rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.bot-identity-card-bio {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 48rem) {
  .bot-identity-guild-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* B10 store catalog (B10 Dashboard): the owner page's filters and create links, the item rows with their art and Up
   and Down, the item page's stored art and live preview, and its retire and delete forms. */

.store-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.store-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.store-filters .field,
.store-filters .form-actions {
  margin: 0;
}

.store-create-links,
.store-item-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.store-item-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  /* p2polish item 10: break-word keeps a name's words whole; anywhere shrank the cell's min-content to one letter. */
  overflow-wrap: break-word;
}

.store-item-thumb {
  flex: none;
  width: 3rem;
  height: 3rem;
  object-fit: cover;
  border-radius: var(--radius-small);
  background: var(--surface-muted);
}

.store-art {
  margin: 0;
  display: grid;
  gap: 0.4rem;
}

.store-art-image {
  display: block;
  max-width: min(100%, 40rem);
  height: auto;
  border-radius: var(--radius-small);
  background: var(--surface-muted);
}

.store-preview:empty,
.store-preview > .muted {
  min-height: 6rem;
}

.store-item-action {
  margin-bottom: 0.75rem;
}

.store-item-action .field-help {
  margin: 0.35rem 0 0;
}

/* The item page's owner list with its Refund buttons, and the Grant to user form. */

.store-owner-user {
  overflow-wrap: anywhere;
}

.store-refund-form {
  margin: 0;
}

.store-grant-form {
  display: grid;
  gap: 0.25rem;
  max-width: 34rem;
}

/* htmx loading indicators (htmx's own rules, which includeIndicatorStyles false stops it injecting). */

.htmx-indicator {
  opacity: 0;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
  transition: opacity 200ms ease-in;
}

/* Small screens */

@media (max-width: 40rem) {
  h1 {
    font-size: 1.55rem;
  }

  /* p2polish item 3: card titles step down below the 1.55rem phone h1 (a 1.38 ratio). */
  h2 {
    font-size: var(--text-lg);
  }

  /* p3polish item 8: h3 steps down below the phone h2, so a group or section heading reads under its card title.
     .form-basics > :is(h2, h3) stays more specific and keeps its own size. */
  h3 {
    font-size: var(--text-md);
  }

  .hero {
    margin: 1.5rem auto;
  }

  .hero h1 {
    font-size: 1.9rem;
  }

  .page {
    padding: 1.25rem 1rem 2rem;
  }

  .card {
    padding: 1rem;
  }

  /* u7.md item 2 (a): the form's one surface narrows its padding as a card does. p1polish item 6: it also runs edge to
     edge, pulling back over the page's 1rem inline padding and dropping its side lines, corners and shadow, so the
     fields get the width the stacked padding took. It keeps its top and bottom lines from the top-level rule. A form
     inside a card gets no negative margin: the card reset is more specific and sets margin-inline: 0. */
  .module-form > .form-fields {
    padding: 1rem;
    margin-inline: -1rem;
    border-inline: 0;
    border-radius: 0;
    box-shadow: none;
  }

  /* p1polish item 6: the save bar lines up with the edge-to-edge form. Every save bar starts at the page content edge
     (the module and settings page sections, the editor's form), never inside a card. */
  .save-bar {
    margin-inline: -1rem;
    /* p2polish item 8: the phone keeps a square, edgeless bar. */
    border-inline: 0;
    border-radius: 0;
    /* p3polish item 3: the phone bar stays docked to the bottom edge with no bottom edge of its own, keeps the soft
       upward shadow, and trims its block padding, for a bar about 61 px tall. */
    inset-block-end: 0;
    border-block-end: 0;
    box-shadow: var(--shadow-up);
    padding-block: 0.6rem;
  }

  .form-actions > * {
    /* p2polish item 12: an action takes its own width and grows to share a row, so a filter's Clear and Download, or
       Copy and Open the link, sit side by side instead of each taking a full row. */
    flex: 1 1 auto;
  }

  /* p2polish item 12: the primary action of a filter or form is a full-width bar, and the others share the row below
     it. (0,2,1) beats the (0,1,0) rule above; the save bar's buttons and the module footer have rules of their own. */
  .form-actions > :is(.button-primary, button.button-primary) {
    flex-basis: 100%;
  }

  /* p1polish item 6: the footer tools read as a quiet list. Export keeps its own size ((0,2,0) beats the (0,1,0) rule
     above); the tools' quiet rows are top level since p2polish item 7, so they read the same at every width. */
  .module-footer > .form-actions > * {
    flex: 0 1 auto;
  }

  /* U1 item 1: the texts take full rows and Discard and Save share the next, so the bar stays short on a phone. */
  .save-bar > .save-bar-status,
  .save-bar > .save-bar-unsaved {
    flex: 1 1 100%;
  }

  .save-bar > .button,
  .save-bar > button {
    flex: 1 1 0;
  }

  /* p3polish item 3: the status line prints empty (zero height) until a save result shows, so its row gap would leave
     a dead band above Save. The status stays in the tree and in place (role=status and app.js's focus move are
     untouched), and the unsaved line keeps its gap above Save when it shows. */
  .save-bar:has(> .save-bar-status:empty) {
    row-gap: 0;
  }

  .save-bar:has(> .save-bar-status:empty) > .save-bar-unsaved {
    margin-block-end: 0.6rem;
  }

  /* p1polish item 4: on a phone the lead is body size, so it no longer rivals the 1.55rem h1, and the module switch,
     which wraps under the title here, lines its track up with the h1 by pulling back its own 0.6rem inline padding.
     Its target keeps its size, and the logical margin mirrors in right-to-left. */
  .lead {
    font-size: var(--text-md);
    line-height: 1.5;
  }

  .module-header .switch-button {
    margin-inline-start: -0.6rem;
  }

  /* p1polish item 5: a one-row header on a phone. The signed-in name is visually hidden (the visually-hidden pattern
     with logical sizes), so it stays in the accessibility tree while the avatar and Log out still show who is signed
     in, and brand, Menu, avatar and Log out fit one row at 390 px. The top-level flex-wrap: wrap stays, so a narrower
     screen, 200% zoom or a longer label wraps the header rather than scroll sideways. */
  .site-header-inner {
    gap: 0.5rem;
    padding-block: 0.5rem;
    padding-inline: 1rem;
  }

  .user-menu {
    gap: 0.4rem;
  }

  .user-name {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  html:has(.save-bar) {
    scroll-padding-block-end: 8rem;
  }

  /* p2polish item 6: even phone grids. The overview's four page buttons are a 2 by 2 grid of equal cells (scoped to
     its header, so the images and command settings jump links keep their wrapping row), and the stat tiles go two
     columns with an odd last tile (the fifth) spanning its row, on the overview and the tickets overview alike. The
     system page's health, MCP and storage lists go two columns too. They are named by their section ids, because the
     case, store item and lookup pages also open with .system-page and their lists keep their auto-fill tracks.
     p3polish item 7 replaced the module cards' closer gap: on a phone each group's cards read as one grouped list,
     framed like a card, whose rows are the cards (the row rules are with item 7's other phone rules, before this
     block's last rule). The clip rounds the first and last rows' bands; the list is not an ancestor of main, so the
     save bar still sticks. */
  .overview-header > .overview-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    inline-size: 100%;
  }

  .module-list {
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: clip;
  }

  .stats-totals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-total:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .system-page > :is(#health, #mcp, #storage) > .system-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 1rem;
  }

  /* p2polish item 9: the one-row header stays at the top while the page scrolls, so another page is one tap away on a
     long page. It is not an ancestor of main, so the save bar still sticks; the failure alert (fixed, z-index 4) stays
     above it and the open Menu sheet sits in the top layer. Anchor and focus scrolling land below it, and the card
     designer's sticky preview box sits under it: the phone rule sets only --designer-sticky-offset, which the
     (min-height: 40rem) rule reads as its offset, so on a short phone screen, where the box is not sticky, it stays
     in its slot instead of moving down over the controls under it. */
  .site-header {
    position: sticky;
    inset-block-start: 0;
    z-index: 3;
  }

  html {
    scroll-padding-block-start: 4rem;
  }

  .card-designer .card-preview-box {
    --designer-sticky-offset: 3.5rem;
  }

  /* p2polish item 12: the store filters share a row, Kind and Status at equal widths with Show after them. */
  .store-filters > .field {
    flex: 1 1 9rem;
  }

  /* p3polish item 2: about 44 px tap targets on a phone. A small button grows to about 41 px by its block padding only,
     so no size property is set. The (0,2,0) .identity .identity-copy (Copy ID) and .cs-nav .button-small keep their
     own padding, and Log out keeps the small padding so the header stays one 48 px row. */
  .button-small,
  button.button-small {
    padding-block: 0.7rem;
  }

  .logout-form > .button-small {
    padding-block: 0.35rem;
  }

  /* p3polish item 2: Menu and Log out reach about 44 px through an invisible hit area that spills 0.45rem above and
     below, with no visual change (Menu's ::before is its glyph). Neither rule sets display, so the 80rem rule still
     hides Menu. */
  :is(.nav-menu-button, .logout-form > .button-small) {
    position: relative;
  }

  :is(.nav-menu-button, .logout-form > .button-small)::after {
    content: '';
    position: absolute;
    inset-block: -0.45rem;
    inset-inline: 0;
  }

  /* p3polish item 2: the breadcrumb link is about 43 px to tap, and the negative margin keeps the line where it was. */
  .breadcrumb a {
    display: inline-block;
    padding-block: 0.7rem;
    margin-block: -0.7rem;
  }

  /* p3polish item 4: the Discord message gives its text about 30 px more per line on a phone: a 2rem avatar column, a
     narrower gap and narrower side padding. Each rule ties its top-level rule and comes later, so it wins, and the
     logical sizes win over .dc-avatar's physical width and height the same way. */
  .dc-message {
    grid-template-columns: 2rem minmax(0, 1fr);
    column-gap: 0.6rem;
    padding-inline: 0.75rem;
  }

  .dc-avatar {
    inline-size: 2rem;
    block-size: 2rem;
  }

  /* p3polish item 5: filters pair up two to a row on a phone, so the first result is closer to the first screen. An ID
     field (a text input) keeps a full row and its help; selects and dates share a row. */
  .audit-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 0.75rem;
  }

  .audit-filter-grid > .field:has(> input[type='text']) {
    grid-column: 1 / -1;
  }

  /* p3polish item 6: table rows with actions or a name stay one line tall on a phone. The actions no longer wrap into a
     stack, and a name keeps a floor on its width, so a row grows wider instead of taller; the tables already scroll
     inside .table-wrap with p2polish item 11's cue. The ticket panels row, whose actions also hold the Post form,
     becomes one long line that scrolls. */
  td > :is(.row-actions, .logs-row-actions),
  td.autoresponder-rule-actions {
    flex-wrap: nowrap;
  }

  .tickets-panel-list-row > th[scope='row'],
  .autoresponder-rule-name {
    min-inline-size: 9rem;
  }

  .store-item-label {
    min-inline-size: 11rem;
  }

  /* p3polish item 7: the module cards are the grouped list's rows, with no edge, radius or shadow of their own. A line
     divides each row from the visible row before it, so a card the filter hides leaves no double line; an off card
     keeps its muted band, and its hover adds no shadow. The card's focus ring sits inside the row, so the list's clip
     does not cut it. */
  .module-list > li {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding-block: 0.875rem;
    padding-inline: 1rem;
  }

  .module-list > li:not([hidden]) ~ li {
    border-block-start: 1px solid var(--border);
  }

  .module-list > li:hover {
    box-shadow: none;
  }

  .module-list > li:has(h4 a:focus-visible) {
    outline-offset: -3px;
  }

  /* p3polish item 9: chart labels are viewBox units, and a phone shows a chart at about half its 720-unit width, so
     the day labels double to read at about 12 px; a long duration in a half-width tile wraps in two lines, not three.
     The y-axis labels keep 13px: charts.ts ends them 48 units from the viewBox's left edge, which the inline svg clips
     to, so "10,000" at 26px would lose its first digits, and the top tick's would lose their tops. A wider gutter
     is a charts.ts change, outside this pass. */
  .chart-days .chart-axis {
    font-size: 26px;
  }

  .chart-empty {
    font-size: 30px;
  }

  .stats-total-value {
    font-size: var(--text-lg);
  }

  /* p3polish item 10: on a phone the case page's details go two columns, named by the page's own class so p2polish
     item 6's system rule keeps its exact selector; the target, moderator and log link keep a full row each, so an
     identity with its Copy ID and id is never squeezed into half the width. */
  .warnings-case-page > #details > .system-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 1rem;
  }

  .warnings-case-page #details :is(#field-target, #field-moderator, #field-log) {
    grid-column: 1 / -1;
  }

  /* p1polish item 6: no control makes iOS zoom the page on focus, which it does for text under 16 px. The shared input
     rule's font: inherit lets controls in 0.92rem table cells inherit a smaller size, and .json-input sets 0.9rem. This
     ties the shared rule's specificity and comes after it, names .json-input to win over it by coming later, and keeps
     input[type='text'] in one top-level rule through :is(). The block's last rule. */
  input:is([type='text'], [type='number'], [type='search'], [type='url'], [type='date']),
  select,
  textarea,
  .json-input {
    font-size: var(--text-md);
  }
}

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