/* Shared chrome for the in-product theme picker and the light/dark switch.
 *
 * Deliberately theme-neutral: it relies on the CSS custom properties each theme
 * defines, with plain fallbacks for the older designs. Keeping this out of every
 * theme stylesheet means a new theme cannot forget the picker or the switch.
 *
 * The trigger inherits the surrounding bar's colour and tints itself with that
 * same colour, so it stays legible on light and inverted bars alike. The open
 * menu is a surface of its own: it must paint *both* its background and its
 * text from the page palette. Inheriting the bar colour here breaks themes
 * whose bar is inverted against the page (Swiss) or whose page has no
 * `--surface` alias (Aurora, Paper), producing text on the same colour as the
 * menu. */
:where(.cleanup-rules) {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    padding: .55rem .9rem;
    border: 1px solid var(--accent, currentColor);
    border-radius: var(--radius-xs, .35rem);
    background: var(--surface, Canvas);
    color: var(--ink, CanvasText);
    font-family: inherit;
    font-size: .85rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
}
.skip-link:focus,
.skip-link:focus-visible {
    left: .75rem;
    top: .75rem;
    outline: 2px solid var(--accent, currentColor);
    outline-offset: 2px;
}

/* Marks decorative panels on the landing pages.
 *
 * Every design draws its own instrument chrome, and some of it sits next to the
 * real server readouts. This label is the one piece of that chrome shared by
 * all designs: it says the panel is a drawing, so a visitor does not read the
 * bars and contour lines as measurements. Inherits the surrounding colour and
 * only drops its opacity, because the designs disagree on palette names. */
.decorative-note {
    margin: .6rem 0 0;
    font-family: var(--mono, ui-monospace, monospace);
    font-size: .62rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    opacity: .55;
}

.theme-switcher {
    position: relative;
    display: inline-flex;
    color: inherit;
    font: inherit;
}
.theme-trigger {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .34rem .6rem;
    border: 1px solid currentColor;
    border-radius: var(--radius-pill, 999px);
    /* Tint from the inherited bar colour, never from a page surface token:
       the bar may be inverted against the page (Swiss telemetry strip). */
    background: transparent;
    background: color-mix(in srgb, currentColor 8%, transparent);
    color: inherit;
    cursor: pointer;
    font: inherit;
    line-height: 1.2;
    list-style: none;
}
.theme-trigger::-webkit-details-marker { display: none; }
.theme-trigger:hover {
    border-color: var(--accent, currentColor);
    background: color-mix(in srgb, currentColor 14%, transparent);
}
.theme-caret { display: inline-flex; opacity: .7; }
.theme-switcher[open] .theme-caret { transform: rotate(180deg); }
.theme-swatch {
    width: .62rem;
    height: .62rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent, #8c8c8c), var(--accent-2, #c4c4c4));
    box-shadow: 0 0 0 1px currentColor inset;
}
.theme-current { font-size: .82em; }
.theme-menu {
    position: absolute;
    z-index: 40;
    top: calc(100% + .4rem);
    right: 0;
    min-width: 11rem;
    display: grid;
    gap: .15rem;
    padding: .35rem;
    border: 1px solid var(--line, currentColor);
    border-radius: var(--radius-sm, .55rem);
    /* Pair the menu's own background with its own text. The fallbacks are
       system colours, which follow `color-scheme`; that covers the designs
       that predate `--surface` (Aurora, Paper) in both light and dark. */
    background: var(--surface, Canvas);
    color: var(--ink, CanvasText);
    box-shadow: 0 .6rem 1.6rem rgba(0, 0, 0, .18);
}
/* A picker that sits in the page footer has no room below the fold, so its menu
   opens upward — the same reason `footer.site .lang-menu` does. Paper calls its
   footer `colophon`; every other design uses `site`. */
footer.site .theme-menu,
footer.colophon .theme-menu {
    top: auto;
    bottom: calc(100% + .45rem);
}
.theme-option {
    display: block;
    padding: .38rem .55rem;
    border-radius: var(--radius-xs, .35rem);
    color: inherit;
    font-size: .86em;
    text-decoration: none;
    white-space: nowrap;
}
.theme-option:hover {
    background: rgba(127, 127, 127, .14);
    background: color-mix(in srgb, currentColor 12%, transparent);
}
.theme-option.active { font-weight: 600; text-decoration: underline; text-underline-offset: .18em; }
@media (max-width: 480px) {
    .theme-current { max-width: 6.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .theme-menu { right: 0; left: auto; max-width: calc(100vw - 1.5rem); }
}

/* Language dropdown, drawn like the theme picker that sits beside it. The
   designs were written for a row of language links; without these rules the
   menu stayed in the flow and pushed the bar apart when it opened. Wrapped in
   `:where()` so Verdant's own dropdown in app.css, which loads first, and any
   rule a design adds still win. */
:where(.lang-switcher) {
    position: relative;
    display: inline-flex;
    flex: none;
    color: inherit;
    font: inherit;
}
:where(.lang-trigger) {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .34rem .6rem;
    border: 1px solid currentColor;
    border-radius: var(--radius-pill, 999px);
    background: transparent;
    background: color-mix(in srgb, currentColor 8%, transparent);
    color: inherit;
    cursor: pointer;
    font: inherit;
    line-height: 1.2;
    white-space: nowrap;
    list-style: none;
}
:where(.lang-trigger)::-webkit-details-marker { display: none; }
:where(.lang-trigger)::marker { content: ""; }
:where(.lang-trigger:hover) {
    border-color: var(--accent, currentColor);
    background: color-mix(in srgb, currentColor 14%, transparent);
}
:where(.lang-current) { font-size: .82em; }
:where(.lang-caret) { display: inline-flex; opacity: .7; }
:where(.lang-switcher[open] .lang-caret) { transform: rotate(180deg); }
:where(.lang-menu) {
    position: absolute;
    z-index: 40;
    top: calc(100% + .4rem);
    right: 0;
    min-width: 10rem;
    display: grid;
    gap: .15rem;
    padding: .35rem;
    border: 1px solid var(--line, currentColor);
    border-radius: var(--radius-sm, .55rem);
    background: var(--surface, Canvas);
    color: var(--ink, CanvasText);
    box-shadow: 0 .6rem 1.6rem rgba(0, 0, 0, .18);
}
:where(footer.site .lang-menu, footer.colophon .lang-menu) {
    top: auto;
    bottom: calc(100% + .45rem);
}
/* `a` stays outside `:where()` so the links outrank a design's bare `a` rule. */
:where(.lang-menu) a {
    display: block;
    padding: .38rem .55rem;
    border-radius: var(--radius-xs, .35rem);
    color: inherit;
    font-size: .86em;
    text-decoration: none;
    white-space: nowrap;
}
:where(.lang-menu) a:hover {
    background: rgba(127, 127, 127, .14);
    background: color-mix(in srgb, currentColor 12%, transparent);
}
:where(.lang-menu) a.active { font-weight: 600; text-decoration: underline; text-underline-offset: .18em; }
@media (max-width: 480px) {
    :where(.lang-menu) { right: 0; left: auto; max-width: calc(100vw - 1.5rem); }
}

/* Light/dark switch, shared like the picker so a new design cannot forget it.
   It inherits the surrounding bar's colour and tints itself with that same
   colour, so it stays legible on light and inverted bars alike. theme.js keeps
   it hidden until the mode is resolved, and hides it for a forced palette. */
.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 2.05rem;
    height: 2.05rem;
    padding: 0;
    border-radius: 50%;
    border: 1px solid currentColor;
    background: transparent;
    background: color-mix(in srgb, currentColor 8%, transparent);
    color: inherit;
    cursor: pointer;
    flex: none;
    transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
}
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover {
    border-color: var(--accent, currentColor);
    background: color-mix(in srgb, currentColor 14%, transparent);
    transform: translateY(-1px);
}
.theme-toggle:active { transform: none; }
.theme-toggle-icon {
    display: none;
    align-items: center;
    justify-content: center;
}
.theme-toggle-icon svg { display: block; }
.theme-toggle[data-mode="light"] .theme-toggle-moon { display: inline-flex; }
.theme-toggle[data-mode="dark"] .theme-toggle-sun { display: inline-flex; }

/* Long explanatory notes wrap instead of widening the page on phones. */
:where(.page-note-wrap) { white-space: normal; max-width: 42rem; }

/* Admin theme catalogue. Shared by every theme, so the management page stays
 * usable even while previewing a design that predates the feature. */
.theme-admin-grid {
    display: grid;
    gap: .9rem;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    margin-top: 1rem;
}
.theme-admin-card {
    display: grid;
    gap: .55rem;
    padding: .9rem;
    border: 1px solid var(--line, rgba(127, 127, 127, .35));
    border-radius: var(--radius-sm, .6rem);
    background: var(--surface, transparent);
}
.theme-admin-card.is-default {
    border-color: var(--accent, currentColor);
    box-shadow: inset 0 0 0 1px var(--accent, currentColor);
}
.theme-admin-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .6rem;
}
.theme-admin-name { margin: 0; font-size: 1rem; }
.theme-admin-key {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .7rem;
    opacity: .65;
}
.theme-admin-swatch {
    flex: 0 0 auto;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 50%;
    border: 1px solid var(--line, rgba(127, 127, 127, .4));
    background: var(--surface-2, rgba(127, 127, 127, .12));
}
.theme-admin-swatch[data-theme-swatch="verdant"] { background: linear-gradient(135deg, #173b30, #a8c94a); }
.theme-admin-swatch[data-theme-swatch="aurora"] { background: linear-gradient(135deg, #05070f, #2dd4bf, #8b5cf6); }
.theme-admin-swatch[data-theme-swatch="paper"] { background: linear-gradient(135deg, #f3ecdd, #b08a3e); }
.theme-admin-swatch[data-theme-swatch="signal"] { background: linear-gradient(135deg, #f4f0e6 45%, #e6392e 45%); }
.theme-admin-swatch[data-theme-swatch="gilded"] { background: linear-gradient(135deg, #0e3b33, #d9b968); }
.theme-admin-swatch[data-theme-swatch="swiss"] { background: linear-gradient(135deg, #f4f0e6 45%, #111 45%); }
.theme-admin-swatch[data-theme-swatch="custom"] { background: linear-gradient(135deg, #3d4a63, #a8c9d9, #7d5c9e); }
.inline-form { display: inline; }

/* Two-column upload/edit form: metadata on the left, the drop target on the
   right. It collapses to one column before the labels get cramped. */
.theme-upload { display: grid; gap: .25rem; }
.theme-upload-grid {
    display: grid;
    grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
    gap: 1.1rem 1.5rem;
    align-items: start;
}
.theme-upload-fields {
    display: grid;
    gap: .65rem;
    align-content: start;
}
.theme-upload-fields .field { margin-bottom: 0; }
.theme-upload-file {
    display: grid;
    gap: .35rem;
    align-content: start;
}
.theme-upload .form-actions { margin-top: .25rem; }
@media (max-width: 760px) {
    .theme-upload-grid { grid-template-columns: 1fr; }
}

/* Segmented appearance control for uploaded themes. */
.theme-appearance {
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}
.theme-appearance legend { padding: 0; margin-bottom: .35rem; }
.theme-appearance-options {
    display: inline-flex;
    flex-wrap: wrap;
    gap: .25rem;
    padding: .25rem;
    border: 1px solid var(--line, rgba(127, 127, 127, .4));
    border-radius: 999px;
    background: var(--surface-2, rgba(127, 127, 127, .12));
}
.theme-appearance-option { position: relative; display: inline-flex; }
.theme-appearance-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}
.theme-appearance-option span {
    display: inline-flex;
    align-items: center;
    padding: .38rem .72rem;
    border-radius: 999px;
    font-size: .76rem;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
}
.theme-appearance-option span:hover {
    background: color-mix(in srgb, currentColor 7%, transparent);
}
.theme-appearance-option input:checked + span {
    /* Tint from the inherited text colour instead of inverting with --ink:
       several ported themes do not define --canvas/--surface, and an inverted
       pill would become white-on-white there. */
    background: color-mix(in srgb, currentColor 16%, transparent);
    box-shadow: inset 0 0 0 1px currentColor;
    color: inherit;
    font-weight: 600;
}
.theme-appearance-option input:focus-visible + span {
    outline: 2px solid var(--accent, currentColor);
    outline-offset: 2px;
}
.theme-appearance > .hint { display: block; margin-top: .35rem; }

/* ---------------------------------------------------------------------------
 * Theme upload drop zone.
 *
 * The native file input is visually hidden but still focusable, so the form
 * keeps working without JavaScript: the <label> opens the picker and browser
 * validation still rejects an empty upload. JavaScript only adds the drag
 * affordance, the selected-file chip and inline error text. */
.theme-drop {
    position: relative;
    display: grid;
    gap: .4rem;
}
.theme-drop-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}
.theme-drop-zone {
    display: grid;
    justify-items: center;
    gap: .2rem;
    padding: 1.3rem 1rem 1.15rem;
    border: 1.5px dashed var(--line, rgba(127, 127, 127, .45));
    border-radius: var(--radius-md, .9rem);
    background:
        radial-gradient(120% 90% at 50% 0%,
            color-mix(in srgb, var(--accent, currentColor) 8%, transparent),
            transparent 72%),
        var(--surface, transparent);
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.theme-drop-zone[hidden] { display: none; }
.theme-drop-zone:hover,
.theme-drop:focus-within .theme-drop-zone {
    border-color: var(--accent, currentColor);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, currentColor) 10%, transparent);
}
.theme-drop-input:focus-visible + .theme-drop-zone {
    outline: 2px solid var(--accent, currentColor);
    outline-offset: 2px;
}
.theme-drop.is-dragging .theme-drop-zone {
    border-color: var(--accent, currentColor);
    border-style: solid;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent, currentColor) 14%, transparent);
    transform: translateY(-1px);
}
.theme-drop.is-invalid .theme-drop-zone { border-color: var(--danger, #b3261e); }
.theme-drop.is-dragging .theme-drop-file {
    border-color: var(--accent, currentColor);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent, currentColor) 14%, transparent);
}
.theme-drop-icon {
    display: grid;
    place-items: center;
    width: 2.35rem;
    height: 2.35rem;
    margin-bottom: .15rem;
    border: 1px solid var(--line, rgba(127, 127, 127, .4));
    border-radius: 50%;
    background: var(--surface-2, rgba(127, 127, 127, .12));
    color: var(--accent, currentColor);
    transition: transform .15s ease;
}
.theme-drop.is-dragging .theme-drop-icon { transform: translateY(-2px); }
.theme-drop-title {
    font-size: .9rem;
    font-weight: 650;
    letter-spacing: -.005em;
}
.theme-drop-hint { font-size: .73rem; opacity: .64; }
.theme-drop-file {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .65rem .75rem;
    border: 1px solid var(--line, rgba(127, 127, 127, .4));
    border-radius: var(--radius-md, .9rem);
    background: var(--surface, transparent);
}
.theme-drop-file[hidden] { display: none; }
.theme-drop-file-icon {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius-sm, .55rem);
    background: color-mix(in srgb, var(--accent, currentColor) 15%, transparent);
    color: var(--accent, currentColor);
    font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: .06em;
}
.theme-drop-file-main { display: grid; flex: 1 1 auto; gap: .1rem; min-width: 0; }
.theme-drop-file-main strong {
    font-size: .84rem;
    font-weight: 650;
    overflow-wrap: anywhere;
}
.theme-drop-file-meta { font-size: .72rem; opacity: .62; }
.theme-drop-error {
    margin: 0;
    font-size: .75rem;
    color: var(--danger, #b3261e);
}
.theme-drop-error[hidden] { display: none; }
@media (max-width: 520px) {
    .theme-drop-zone { padding: 1.05rem .8rem .95rem; }
    .theme-drop-file { flex-wrap: wrap; }
    .theme-drop-file .btn { margin-left: auto; }
}
.custom-theme-list {
    display: grid;
    gap: .55rem;
}
.custom-theme-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .45rem 1rem;
    padding: .7rem .85rem;
    border: 1px solid var(--line, rgba(127, 127, 127, .35));
    border-radius: var(--radius-sm, .6rem);
    background: var(--surface, transparent);
}
.custom-theme-main { flex: 1 1 14rem; min-width: 0; }
.custom-theme-meta { font-size: .76rem; opacity: .68; }
.custom-theme-actions { display: flex; align-items: center; gap: .35rem; margin-left: auto; }
@media (max-width: 520px) {
    .custom-theme-actions { margin-left: 0; width: 100%; }
}
.theme-admin-meta { display: flex; flex-wrap: wrap; gap: .3rem; }
.theme-admin-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .7rem;
    margin-top: .2rem;
}
.theme-admin-controls .btn { margin-left: auto; }
.field-narrow { max-width: 28rem; }

/* ---------------------------------------------------------------------------
 * Shared app-content fallback.
 *
 * The five ported designs predate the v1.2 dashboard, account, detail and admin
 * pages. Their content markup is shared across themes so every feature keeps
 * working; these zero-specificity rules fill in classes a design stylesheet
 * never knew about. `:where()` deliberately loses to every theme rule, so the
 * original design wins wherever it has an opinion. */
:where(.page-head, .dash-head) {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin: 1.2rem 0 1rem;
}
:where(.page-head-main) { display: grid; gap: .25rem; }
:where(.page-head-side) { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
:where(.page-title) { margin: 0; font-size: clamp(1.35rem, 2.2vw, 2rem); line-height: 1.15; }
:where(.kicker) {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font: 600 .68rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: .12em;
    text-transform: uppercase;
    opacity: .75;
}
:where(.kicker-dot, .page-note .note-dot) {
    width: .45rem;
    height: .45rem;
    border-radius: 50%;
    background: var(--accent, currentColor);
}
:where(.page-note) { font-size: .82rem; opacity: .72; }
:where(.panel, .page, .landing) { box-sizing: border-box; }
:where(.panel) {
    margin: 1rem 0;
    padding: 1rem;
    border: 1px solid var(--line, rgba(127, 127, 127, .32));
    border-radius: var(--radius-sm, .65rem);
    background: var(--surface, transparent);
}
:where(.panel-flush) { padding: 0; overflow: hidden; }
:where(.panel-head, .table-toolbar) {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: .6rem;
    margin: 0 0 .7rem;
}
:where(.panel-head h2, .panel-head h3, .table-toolbar h2) { margin: 0; font-size: 1.05rem; }
:where(.panel-sub) {
    font: .68rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: .1em;
    opacity: .55;
}
:where(.vitals, .stat-grid, .stat-grid-lg) {
    display: grid;
    gap: .8rem;
    grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
    margin: 1rem 0;
}
:where(.stat) {
    display: grid;
    gap: .35rem;
    padding: .85rem;
    border: 1px solid var(--line, rgba(127, 127, 127, .28));
    border-radius: var(--radius-xs, .5rem);
    background: var(--surface-2, transparent);
}
:where(.stat-top) { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
:where(.stat-label) { font-size: .76rem; opacity: .72; }
:where(.stat-value) { font: 700 clamp(1.25rem, 2.4vw, 1.8rem)/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
:where(.stat-hint, .stat-foot) { font-size: .7rem; opacity: .6; }
:where(.stat-dot) { width: .4rem; height: .4rem; border-radius: 50%; background: var(--accent, currentColor); }
:where(.meter) { display: grid; gap: .25rem; min-width: 10rem; }
:where(.meter-track) { height: .35rem; border-radius: 999px; background: var(--line, rgba(127, 127, 127, .3)); overflow: hidden; }
:where(.meter-fill) { display: block; width: 0; height: 100%; background: var(--accent, currentColor); }
:where(.meter-label) { font-size: .72rem; opacity: .7; }
:where(.form-grid) { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
:where(.form-grid .span-2) { grid-column: 1 / -1; }
:where(.field) { display: grid; gap: .25rem; }
:where(.label) { font-size: .78rem; font-weight: 600; }
:where(.input, .select, textarea.input) {
    width: 100%;
    box-sizing: border-box;
    padding: .5rem .6rem;
    border: 1px solid var(--line, rgba(127, 127, 127, .45));
    border-radius: var(--radius-xs, .4rem);
    background: var(--surface, transparent);
    color: inherit;
    font: inherit;
}
:where(.hint) { font-size: .72rem; line-height: 1.45; opacity: .65; }
:where(.form-actions) { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .5rem; margin-top: .9rem; }
:where(.check-cluster) { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin: .6rem 0; }
:where(.checkbox) { display: inline-flex; align-items: center; gap: .4rem; font-size: .82rem; }
:where(.row) { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
:where(.row-tight) { gap: .3rem; }
:where(.row-end) { justify-content: flex-end; }
:where(.stack) { display: grid; gap: .6rem; }
:where(.mt) { margin-top: 1rem; }
:where(.muted) { opacity: .65; }
:where(.small) { font-size: .78rem; }
:where(.mono) { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
:where(.badge) {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .12rem .45rem;
    border: 1px solid var(--line, rgba(127, 127, 127, .4));
    border-radius: 999px;
    font-size: .68rem;
    line-height: 1.5;
    white-space: nowrap;
}
:where(.badge-accent) { border-color: var(--accent, currentColor); }
:where(.badge-ok) { border-color: #2f7d4f; color: #2f7d4f; }
:where(.badge-danger) { border-color: #a83a2c; color: #a83a2c; }
:where(.badge-warn) { border-color: #8a5a12; color: #8a5a12; }
:where(.table-wrap) { width: 100%; overflow-x: auto; }
:where(.table) { width: 100%; border-collapse: collapse; font-size: .82rem; }
:where(.table th, .table td) { padding: .5rem .55rem; border-bottom: 1px solid var(--line, rgba(127, 127, 127, .22)); text-align: left; vertical-align: top; }
:where(.table th) { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; opacity: .7; }
:where(.table .num, .num) { text-align: right; font-variant-numeric: tabular-nums; }
:where(.empty) { padding: 1rem; opacity: .65; }
:where(.pagination) { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .35rem; padding: .7rem .9rem; }
:where(.pagination .current) { font-weight: 700; }
:where(.seg) { display: inline-flex; flex-wrap: wrap; gap: .25rem; }
:where(.advanced) { margin-top: .9rem; border-top: 1px dashed var(--line, rgba(127, 127, 127, .3)); padding-top: .6rem; }
:where(.advanced summary) { cursor: pointer; font-size: .82rem; font-weight: 600; }
:where(.advanced-body, .drawer) { padding: .7rem 0; }
:where(.drawer) { display: grid; gap: .55rem; }
:where(.filters, .filters-users, .filters-invite) { display: flex; flex-wrap: wrap; align-items: end; gap: .55rem; }
:where(.filters .field, .filters-users .field, .filters-invite .field) { min-width: 9rem; flex: 1 1 9rem; }
:where(.copy-row, .slug-bar) { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
:where(.slug-value) { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; }
:where(.chart-panel) { padding: .4rem 0; }
:where(.chart-axis) { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; font-size: .72rem; opacity: .65; }
:where(.bar-list) { display: grid; gap: .5rem; }
:where(.bar-row) { display: grid; gap: .18rem; }
:where(.bar-label) { display: flex; justify-content: space-between; gap: .5rem; font-size: .76rem; }
:where(.bar-track) { height: .3rem; border-radius: 999px; background: var(--line, rgba(127, 127, 127, .28)); overflow: hidden; }
:where(.bar-fill) { display: block; height: 100%; background: var(--accent, currentColor); }
:where(.detail-grid, .account-grid) { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); margin: 1rem 0; }
:where(.settings-layout) { display: grid; gap: 1rem; grid-template-columns: minmax(12rem, 15rem) minmax(0, 1fr); align-items: start; }
:where(.settings-rail) { display: grid; gap: .5rem; position: sticky; top: 1rem; }
:where(.rail-title, .rail-index) { font: .68rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; opacity: .6; }
:where(.alert) { margin: 1rem 0; padding: .7rem .9rem; border: 1px solid var(--line, rgba(127, 127, 127, .4)); border-radius: var(--radius-xs, .45rem); }
:where(.alert-ok) { border-color: #2f7d4f; }
:where(.alert-warn) { border-color: #8a5a12; }
:where(.alert-info) { border-color: var(--accent, currentColor); }
:where(.alert-danger) { border-color: #a83a2c; }
@media (max-width: 760px) {
    :where(.settings-layout) { grid-template-columns: minmax(0, 1fr); }
    :where(.settings-rail) { position: static; }
}

/* Group capability board and domain policy. The ported designs predate these
 * controls; without a shared layout the capability groups and the allowlist
 * would read as one undifferentiated column. Colours stay in the theme's own
 * vocabulary through `--accent` and `--line`, and `:where()` keeps every
 * theme-specific rule in charge. */
:where(.cap-head, .policy-head) {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: .7rem 1.2rem;
    margin-bottom: .6rem;
}
:where(.cap-intro) { display: grid; gap: .15rem; min-width: 0; }
:where(.cap-tools) { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
:where(.cap-count) {
    font: .72rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    opacity: .65;
    white-space: nowrap;
}
:where(.cap-grid) {
    display: grid;
    gap: 0 1.2rem;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    margin-top: .5rem;
}
:where(.cap-group) { margin: 0; padding: 0; border: 0; min-width: 0; }
:where(.cap-group-title) {
    width: 100%;
    padding: 0 0 .35rem;
    border-bottom: 1px solid var(--line, rgba(127, 127, 127, .3));
    font-size: .78rem;
    font-weight: 600;
    opacity: .7;
}
:where(.cap-item) {
    display: flex;
    align-items: flex-start;
    gap: .45rem;
    margin: 0;
    padding: .4rem .2rem;
}
:where(.cap-text) { display: grid; gap: .1rem; min-width: 0; }
:where(.cap-name) { font-size: .84rem; line-height: 1.35; }
:where(.cap-desc) { font-size: .72rem; line-height: 1.4; opacity: .62; }
:where(.policy-block) {
    margin-top: 1.2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line, rgba(127, 127, 127, .3));
}
:where(.policy-default) { min-width: 13rem; max-width: 24rem; }
:where(.policy-grid) {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    align-items: start;
    margin-top: .6rem;
}
:where(.policy-group) { margin: 0; padding: 0; border: 0; min-width: 0; }
:where(.policy-option) {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    padding: .4rem .3rem;
    cursor: pointer;
}
:where(.policy-option input[type="radio"]) { margin: .2rem 0 0; accent-color: var(--accent, currentColor); }
:where(.policy-text) { display: grid; gap: .1rem; min-width: 0; }
:where(.policy-name) { font-size: .84rem; line-height: 1.35; }
:where(.policy-desc) { font-size: .72rem; line-height: 1.4; opacity: .62; }
:where(.policy-pane) {
    padding: .7rem .8rem;
    border: 1px solid var(--line, rgba(127, 127, 127, .3));
    border-radius: var(--radius-sm, .55rem);
    min-width: 0;
}
:where(.policy-pane.is-inactive) { opacity: .45; }
:where(.policy-pane-head) {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: .4rem .8rem;
}
:where(.chips) { display: flex; flex-wrap: wrap; gap: .4rem; margin: .55rem 0 .3rem; }
:where(.domain-chip) {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin: 0;
    padding: .25rem .55rem;
    border: 1px solid var(--line, rgba(127, 127, 127, .45));
    border-radius: 999px;
    font-size: .76rem;
    line-height: 1.4;
    cursor: pointer;
}
:where(.domain-chip input[type="checkbox"]) { margin: 0; accent-color: var(--accent, currentColor); }
:where(.domain-chip:has(input:checked)) {
    border-color: var(--accent, currentColor);
    box-shadow: inset 0 0 0 1px var(--accent, currentColor);
}
:where(.domain-chip.is-disabled) { opacity: .6; }

/* Extra-domain short landing. It is a tiny page with no signed-in shell, so the
 * older themes' stylesheets do not define these generic classes. */
:where(.wrap) {
    width: min(100% - 2rem, 72rem);
    margin-inline: auto;
}
:where(.short-hero) {
    display: grid;
    place-items: center;
    min-height: 70vh;
    padding: 2rem 0;
}
:where(.short-hero .hero-copy) {
    display: grid;
    gap: .7rem;
    max-width: 38rem;
    text-align: center;
}
:where(.hero-chip) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    font: .68rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: .12em;
    text-transform: uppercase;
    opacity: .75;
}
:where(.status-dot) {
    width: .45rem;
    height: .45rem;
    border-radius: 50%;
    background: var(--accent, currentColor);
}
:where(.short-hero h1) { margin: .2rem 0; font-size: clamp(2rem, 5vw, 3.4rem); }
:where(.hero-dot) {
    display: inline-block;
    width: .25em;
    height: .25em;
    margin-left: .08em;
    border-radius: 50%;
    background: var(--accent, currentColor);
}
:where(.landing-tagline) { margin: 0; font-size: 1.05rem; opacity: .8; }
:where(.landing-cta) { display: flex; justify-content: center; gap: .5rem; margin-top: .5rem; }

/* Splash / interstitial page ------------------------------------------------ */
.splash-message { white-space: pre-line; }

.splash-meter {
    position: relative;
    height: 3px;
    margin: 1.15rem 0 .55rem;
    border-radius: 999px;
    overflow: hidden;
    background: rgb(127 127 127 / .22);
}
.splash-meter > span {
    display: block;
    width: 100%;
    height: 100%;
    background: currentColor;
    transform-origin: left center;
    animation: splash-drain var(--splash-delay, 5s) linear forwards;
}
@keyframes splash-drain {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}
.splash-countdown { margin: 0; }
.splash-destination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .35rem .75rem;
    margin: 1.25rem 0 1rem;
    padding: .65rem .85rem;
    border: 1px solid rgb(127 127 127 / .28);
    border-radius: .65rem;
    text-align: left;
}
.splash-destination .label {
    margin: 0;
    opacity: .72;
    font-size: .68rem;
    letter-spacing: .12em;
    text-transform: uppercase;
}
.splash-host {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .9rem;
    overflow-wrap: anywhere;
}
.splash-destination + .status-actions,
.splash-destination + .btn { margin-top: 0; }
@media (prefers-reduced-motion: reduce) {
    .splash-meter > span { animation: none; }
}

/* Groups table: the shared markup has more columns than a phone can show.
 * Hide the secondary columns on narrow screens so the name, quota and edit
 * action stay visible; every theme receives the same behaviour here. */
@media (max-width: 760px) {
    table.table.groups-table { min-width: 0; }
    .groups-table .col-token-quota,
    .groups-table .col-invites,
    .groups-table .col-redirect,
    .groups-table .col-features,
    .groups-table .col-created { display: none; }
    .groups-table th,
    .groups-table td { padding: .6rem .55rem; }
    .groups-table .col-name { min-width: 9rem; }
    .groups-table .col-actions { text-align: right; white-space: nowrap; }
    .groups-table .col-actions .btn { padding: .28rem .5rem; }
}
@media (max-width: 480px) {
    .groups-table .col-members { display: none; }
}

/* Shared create/edit dialog for the group and theme forms. Both lists keep
 * ordinary links so the form pages are still the no-JavaScript path; this only
 * styles the enhanced floating window. Panels are flattened inside the dialog
 * so the form reads as one surface. */
.form-dialog {
    width: min(56rem, calc(100vw - 2rem));
    max-width: 56rem;
    max-height: min(90vh, 54rem);
    margin: auto;
    padding: 0;
    border: 1px solid var(--hairline, var(--line, rgb(127 127 127 / .28)));
    border-radius: var(--r-lg, 1rem);
    background: var(--surface, var(--paper-2, var(--bg-1, #fff)));
    color: var(--ink, #17221c);
    box-shadow: 0 2rem 5rem rgb(0 0 0 / .32);
    overflow: hidden;
}
.form-dialog[open] { display: flex; flex-direction: column; }
.form-dialog::backdrop {
    background: rgb(8 19 14 / .55);
    backdrop-filter: blur(3px);
}
.form-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex: none;
    padding: .95rem 1.3rem;
    border-bottom: 1px solid var(--hairline, var(--line, rgb(127 127 127 / .28)));
    background: var(--surface, var(--paper-2, var(--bg-1, #fff)));
}
.form-dialog-head h2 { margin: 0; font-size: 1.15rem; }
.form-dialog-close {
    flex: none;
    width: 2rem;
    height: 2rem;
    padding: 0;
    display: inline-grid;
    place-items: center;
    font-size: 1rem;
    line-height: 1;
}
.form-dialog-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1.2rem 1.3rem 1.4rem;
}
.form-dialog-body[aria-busy="true"] { cursor: progress; }
.form-dialog-loading { padding: 2rem 0; text-align: center; }
.form-dialog-body .panel {
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}
.form-dialog-body .panel + .panel {
    margin-top: 1.4rem;
    padding-top: 1.4rem;
    border-top: 1px solid var(--hairline, var(--line, rgb(127 127 127 / .28)));
}
.form-dialog-body > .alert { margin-top: 0; margin-bottom: 1rem; }
.form-dialog-body .form-actions { margin-top: 1.2rem; }
@media (max-width: 700px) {
    .form-dialog {
        width: 100vw;
        max-width: none;
        height: 100dvh;
        max-height: none;
        margin: 0;
        border: 0;
        border-radius: 0;
    }
    .form-dialog-head { padding: .85rem 1rem; }
    .form-dialog-body { padding: 1rem 1rem calc(1.25rem + env(safe-area-inset-bottom, 0px)); }
}

/* ---------------------------------------------------------------------------
   共用的短網址表單（新增、公開表單、編輯懸浮窗）。兩個展開區塊沿用各主題的
   details.advanced 外觀，這裡只補上標題、說明與摘要徽章的排版，並以主題變數
   搭配後備值，讓每個設計都能直接套用。 */
.link-form > .link-section { margin-top: .9rem; }
.link-form > .link-section + .link-section { margin-top: .6rem; }
.link-section > summary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .45rem .7rem;
}
.link-section-text {
    display: flex;
    flex-direction: column;
    gap: .12rem;
    flex: 1 1 14rem;
    min-width: 0;
}
.link-section-title { font-weight: 600; }
.link-section-sub {
    font-size: .8rem;
    font-weight: 400;
    opacity: .72;
}
.link-section-badges {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    justify-content: flex-end;
}
.link-form-splash {
    margin-top: .2rem;
    padding-top: .85rem;
    border-top: 1px dashed var(--hairline, var(--line, rgb(127 127 127 / .28)));
}
[data-splash-fields][hidden] { display: none; }
.link-form > .alert { margin-top: 0; margin-bottom: 1rem; }

/* 編輯懸浮窗比群組表單窄一些：欄位最多兩欄，太寬反而難讀。手機版維持滿版。 */
@media (min-width: 701px) {
    .link-dialog { width: min(46rem, calc(100vw - 2rem)); }
}

/* 編輯器底部的刪除區。 */
.danger-zone {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem 1rem;
    margin-top: 1.4rem;
    padding: .85rem 1rem;
    border: 1px solid color-mix(in srgb, var(--danger, #b4483c) 35%, transparent);
    border-radius: var(--r-md, .75rem);
    background: color-mix(in srgb, var(--danger, #b4483c) 6%, transparent);
}
.danger-zone-text {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    min-width: 0;
}
.danger-zone-text .hint { margin: 0; }
.danger-zone form { margin: 0; }

/* 統計頁的設定摘要。 */
.page-subtitle {
    margin: .15rem 0 .55rem;
    opacity: .78;
    overflow-wrap: anywhere;
}
/* 以 flex 換行而非 grid：最後一列的格子會自動撐滿，不會留下空白格。 */
.link-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    margin: 0 0 1.2rem;
    padding: 0;
    border: 1px solid var(--hairline, var(--line, rgb(127 127 127 / .28)));
    border-radius: var(--r-md, .75rem);
    background: var(--hairline, var(--line, rgb(127 127 127 / .28)));
    overflow: hidden;
}
.link-fact {
    flex: 1 1 9.5rem;
    display: flex;
    flex-direction: column;
    gap: .3rem;
    min-width: 0;
    margin: 0;
    padding: .7rem .9rem;
    background: var(--surface, var(--paper-2, var(--bg-1, #fff)));
}
.link-fact-wide { flex-basis: 100%; }
.link-fact dt { margin: 0; }
.link-fact dd {
    margin: 0;
    min-width: 0;
    font-size: .9rem;
    overflow-wrap: anywhere;
}
.link-fact dd a.truncate {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.link-fact-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
}

/* 主題的 .field display 不得蓋過預覽來源欄位的 hidden 狀態。 */
[data-preview-input][hidden] {
  display: none;
}

/* ---------------------------------------------------------------------------
   頁尾的連結（上游 repo 與 API 參考）。每個設計都納入同一份 partial，所以共用
   規則放在這裡，各主題只調整擺放位置與字級。連結繼承頁尾的顏色與字級：各設計的
   色盤差異太大（Verdant 的灰、Signal 的深色條、Swiss 的黑底），硬寫一組顏色
   無法都看得清楚。
   `.footer-repo` 與 `.footer-link` 並列：前者是既有類別名稱，已上傳的 CSS 主題
   可能針對它撰寫，所以保留為別名。 */
.footer-link,
.footer-repo {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    color: inherit;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
}
/* 用底線而非變色作為 hover 提示：在 Signal 深色條、Swiss 黑底與 Aurora 夜間模式
   上，--ink 會與背景糊在一起。 */
.footer-link:hover,
.footer-link:focus-visible,
.footer-repo:hover,
.footer-repo:focus-visible { text-decoration: underline; text-underline-offset: .18em; }
.footer-repo-icon { flex: none; opacity: .75; transition: opacity .18s ease; }
.footer-link:hover .footer-repo-icon,
.footer-link:focus-visible .footer-repo-icon,
.footer-repo:hover .footer-repo-icon,
.footer-repo:focus-visible .footer-repo-icon { opacity: 1; }
