/* ==========================================================================
   DarkWeb Monitor — components
   --------------------------------------------------------------------------
   Every reusable piece of the interface. Classes are flat and BEM-ish with no
   prefix. Nothing here hard-codes a colour: shades are derived from the
   tokens with color-mix() so both themes track automatically.

   A site's condition is expressed as data-state="alive|blocked|broken|dead|
   waiting" on the element. The block immediately below turns that attribute
   into two local custom properties, --state and --state-soft, and every
   component that shows condition reads those. No component ever selects on a
   status class name, and no template ever picks a colour.
   ========================================================================== */

/* ------------------------------------------------------------- state ------ */

[data-state] {
    --state: var(--state-waiting);
    --state-soft: color-mix(in srgb, var(--state) 15%, transparent);
    --state-line: color-mix(in srgb, var(--state) 45%, transparent);
}
[data-state='alive']   { --state: var(--state-alive); }
[data-state='blocked'] { --state: var(--state-blocked); }
[data-state='broken']  { --state: var(--state-broken); }
[data-state='dead']    { --state: var(--state-dead); }
[data-state='waiting'] { --state: var(--state-waiting); }

/* state-dot ---------------------------------------------------------------- */

.state-dot {
    position: relative;
    display: inline-block;
    flex: none;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--state, var(--text-faint));
    box-shadow: 0 0 0 3px var(--state-soft);
    vertical-align: baseline;
}

/* Only a reachable service pulses. A dead one sitting there blinking would
   read as activity it does not have. */
.state-dot[data-state='alive']::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 1px solid var(--state);
    animation: state-pulse 2.4s var(--ease) infinite;
}
@keyframes state-pulse {
    0%   { transform: scale(.6); opacity: .9; }
    70%  { transform: scale(1.9); opacity: 0; }
    100% { transform: scale(1.9); opacity: 0; }
}
.state-dot--lg { width: 12px; height: 12px; box-shadow: 0 0 0 4px var(--state-soft); }

/* state-badge -------------------------------------------------------------- */

.state-badge {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .18rem .55rem .18rem .5rem;
    border: 1px solid var(--state-line);
    border-radius: var(--radius-pill);
    background: var(--state-soft);
    color: var(--state);
    font-family: var(--font-mono);
    font-size: .66rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    white-space: nowrap;
}
.state-badge .state-dot { box-shadow: none; width: 7px; height: 7px; }
.state-badge--block { display: flex; justify-content: center; width: 100%; }
.state-badge--solid {
    background: var(--state);
    border-color: transparent;
    color: var(--ink);
}
.state-badge--solid .state-dot { background: var(--ink); }

/* A left rail of state colour, for rows and cards. */
.state-rail { box-shadow: inset 3px 0 0 var(--state, var(--border-strong)); }

/* ------------------------------------------------------------- masthead --- */

.masthead {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--bg) 84%, transparent);
    backdrop-filter: blur(14px) saturate(150%);
    -webkit-backdrop-filter: blur(14px) saturate(150%);
    border-bottom: 1px solid var(--border);
}
.masthead::after {
    /* hairline of accent under the bar: the one piece of chrome that says the
       page is a live monitor rather than a document */
    content: '';
    display: block;
    height: 1px;
    background: linear-gradient(90deg,
        transparent,
        color-mix(in srgb, var(--accent) 60%, transparent),
        color-mix(in srgb, var(--accent-2) 60%, transparent),
        transparent);
    opacity: .65;
}
.masthead__inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: var(--header-h);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    flex: none;
    color: var(--text);
    text-decoration: none;
}
.brand:hover { color: var(--text); text-decoration: none; }
.brand__mark {
    width: 34px;
    height: 34px;
    object-fit: contain;
    filter: drop-shadow(0 0 10px color-mix(in srgb, var(--accent-2) 55%, transparent));
    transition: filter var(--speed) var(--ease), transform var(--speed) var(--ease);
}
.brand:hover .brand__mark {
    filter: drop-shadow(0 0 16px color-mix(in srgb, var(--accent) 80%, transparent));
    transform: translateY(-1px);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.05; }
.brand__eyebrow {
    font-family: var(--font-mono);
    font-size: .52rem;
    font-weight: 600;
    letter-spacing: .34em;
    text-transform: uppercase;
    color: var(--accent);
}
.brand__name {
    font-family: var(--font-display);
    font-size: 1.06rem;
    letter-spacing: .06em;
    white-space: nowrap;
}
.brand__name em { font-style: normal; color: var(--brand-red); }
.brand__bracket { color: var(--text-faint); }
/* The caret is the only thing on the page allowed to blink. */
.brand__caret {
    color: var(--accent);
    animation: caret-blink 1.15s steps(2, start) infinite;
}
@keyframes caret-blink { to { visibility: hidden; } }

/* ------------------------------------------------------------------ nav --- */

.nav { margin-left: auto; }
.nav__list {
    display: flex;
    align-items: center;
    gap: .1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
.nav__link {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .38rem .6rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: .76rem;
    letter-spacing: .04em;
    text-decoration: none;
    white-space: nowrap;
    transition: color var(--speed) var(--ease), background var(--speed) var(--ease),
                border-color var(--speed) var(--ease);
}
/* The path slash is the nerd tell, and it also makes the nav read as routes. */
.nav__link::before { content: '/'; color: var(--text-faint); }
.nav__link:hover {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--border);
    text-decoration: none;
}
.nav__link.is-active {
    color: var(--text);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    border-color: color-mix(in srgb, var(--accent) 34%, transparent);
}
.nav__link.is-active::before { color: var(--accent); }

.nav__sep {
    width: 1px;
    height: 20px;
    margin-inline: .4rem;
    background: var(--border);
}

/* Below the breakpoint the nav becomes a sheet under the bar. */
@media (max-width: 900px) {
    .nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        display: none;
        padding: .7rem clamp(1rem, 3vw, 2rem) 1rem;
        background: color-mix(in srgb, var(--bg) 96%, transparent);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow);
    }
    .nav.is-open { display: block; }
    .nav__list { flex-direction: column; align-items: stretch; gap: .15rem; }
    .nav__link { padding: .6rem .7rem; font-size: .86rem; }
    .nav__sep { width: auto; height: 1px; margin: .4rem 0; }
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .55rem 1.05rem;
    font-family: var(--font-body);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: transform var(--speed) var(--ease), background var(--speed) var(--ease),
                border-color var(--speed) var(--ease), color var(--speed) var(--ease),
                box-shadow var(--speed) var(--ease);
}
.btn:hover {
    color: var(--text);
    background: var(--surface-hover);
    border-color: var(--border-strong);
    transform: translateY(-1px);
    text-decoration: none;
}
.btn:active { transform: translateY(0); }
.btn[disabled], .btn.is-disabled, .btn[aria-disabled='true'] {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
    pointer-events: none;
}
.btn .icon { width: 15px; height: 15px; flex: none; }

.btn--primary {
    color: var(--light);
    background: linear-gradient(135deg, var(--accent-2), color-mix(in srgb, var(--accent-2) 60%, var(--ink)));
    border-color: transparent;
    box-shadow: 0 6px 20px color-mix(in srgb, var(--accent-2) 34%, transparent);
}
.btn--primary:hover {
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent-2) 82%, var(--light)), var(--accent-2));
    box-shadow: 0 10px 28px color-mix(in srgb, var(--accent-2) 46%, transparent);
}

.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--surface-2); }

.btn--icon {
    width: 36px;
    height: 36px;
    padding: 0;
    flex: none;
}
.btn--icon.btn--sm { width: 28px; height: 28px; }

.btn--danger { color: var(--bad-ink); border-color: color-mix(in srgb, var(--bad) 34%, var(--border)); }
.btn--danger:hover {
    color: var(--light);
    background: var(--bad);
    border-color: transparent;
    box-shadow: 0 8px 24px color-mix(in srgb, var(--bad) 40%, transparent);
}

.btn--sm { padding: .34rem .65rem; font-size: .66rem; gap: .35rem; }
.btn--lg { padding: .75rem 1.5rem; font-size: .86rem; }
.btn--block { width: 100%; }
.btn--accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.btn--accent:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* A button waiting on the network. Set aria-busy="true" from JS. */
.btn[aria-busy='true'] { pointer-events: none; opacity: .7; }
.btn[aria-busy='true']::before {
    content: '';
    width: 13px; height: 13px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-group {
    display: inline-flex;
    align-items: stretch;
}
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn:hover { transform: none; z-index: 1; }

/* Declared after .btn deliberately: the nav toggle is itself a .btn, and at
   equal specificity whichever display comes last wins. Moved back up with the
   rest of the nav, the toggle reappears on the desktop layout. */
.nav-toggle { display: none; }
@media (max-width: 900px) {
    .nav-toggle { display: inline-flex; }
}

/* --------------------------------------------------------- card & panel --- */

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform var(--speed) var(--ease), border-color var(--speed) var(--ease),
                box-shadow var(--speed) var(--ease);
}
.card__head {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: .9rem 1.1rem;
    border-bottom: 1px solid var(--border);
}
.card__head > :last-child { margin-bottom: 0; }
.card__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1rem;
    letter-spacing: .05em;
}
.card__sub { margin: .15rem 0 0; font-size: .76rem; color: var(--text-faint); }
.card__actions { margin-left: auto; display: flex; align-items: center; gap: .4rem; flex: none; }
.card__body { padding: 1.1rem; }
.card__body > :last-child { margin-bottom: 0; }
.card__foot {
    margin-top: auto;
    padding: .7rem 1.1rem;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    font-size: .74rem;
    color: var(--text-faint);
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
a.card, .card--link { color: inherit; text-decoration: none; }
a.card:hover, .card--link:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
    box-shadow: var(--shadow-lift);
    text-decoration: none;
}
.card--flat { box-shadow: none; }
.card--accent { border-color: color-mix(in srgb, var(--accent) 34%, var(--border)); }
.card--state { border-color: var(--state-line); }
.card--state::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--state);
}

/*
 * .panel is the terminal window: a titled chrome bar over a body. It is the
 * heavier sibling of .card and carries the nerd texture for a whole section.
 */
.panel {
    background: linear-gradient(180deg,
        color-mix(in srgb, var(--surface) 96%, transparent),
        color-mix(in srgb, var(--surface-2) 96%, transparent));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.panel__bar {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .45rem .8rem;
    background: var(--surface-3);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: .74rem;
    color: var(--text-dim);
}
.panel__dots { display: inline-flex; gap: .3rem; flex: none; }
.panel__dots i {
    display: block;
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--border-strong);
}
.panel__dots i:nth-child(1) { background: color-mix(in srgb, var(--bad) 80%, transparent); }
.panel__dots i:nth-child(2) { background: color-mix(in srgb, var(--warn) 80%, transparent); }
.panel__dots i:nth-child(3) { background: color-mix(in srgb, var(--ok) 80%, transparent); }
.panel__title {
    letter-spacing: .04em;
    /* The bar is a .74rem monospace strip. A heading element dropped into it
       brings its own document-level size -- h2 is ~1.6rem -- which blows the
       bar open and pushes .panel__actions out of the row. Pinning the size,
       weight and margin here makes .panel__title render identically whether
       the markup reaches for <h2>, <span> or <summary>, which the admin
       templates all do. */
    font-size: inherit;
    font-weight: 600;
    line-height: 1.4;
    margin: 0;
    min-width: 0;

    /* Laid out as a flex row so the '~/' pseudo-element, an optional leading
       icon and the label are three items on ONE line. As inline content they
       formed separate line boxes -- the icon's line-height pushed the text to a
       second row and stranded '~/' above it -- which is what broke the GitHub
       panel on /admin/settings. */
    display: flex;
    align-items: center;
    gap: .4rem;
}
.panel__title::before { flex: none; }
.panel__title > .icon { flex: none; }
.panel__title::before { content: '~/'; color: var(--text-faint); }
.panel__actions { margin-left: auto; display: flex; align-items: center; gap: .4rem; }
.panel__body { padding: clamp(.9rem, 2.2vw, 1.4rem); }
.panel__body > :last-child { margin-bottom: 0; }
.panel__body--flush { padding: 0; }
.panel__foot {
    padding: .6rem .9rem;
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: .72rem;
    color: var(--text-faint);
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
}

/* --------------------------------------------------- chip, tag, badge ----- */

.chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .22rem .6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--text-dim);
    font-size: .72rem;
    line-height: 1.5;
    white-space: nowrap;
    text-decoration: none;
    transition: color var(--speed) var(--ease), border-color var(--speed) var(--ease),
                background var(--speed) var(--ease);
}
a.chip:hover, button.chip:hover {
    color: var(--text);
    border-color: color-mix(in srgb, var(--accent) 50%, transparent);
    background: var(--surface-hover);
    text-decoration: none;
}
.chip.is-active, .chip[aria-pressed='true'] {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 50%, transparent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.chip__count {
    font-family: var(--font-mono);
    font-size: .66rem;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
}
.chip__icon { font-size: .9em; line-height: 1; }
.chip--sm { padding: .1rem .45rem; font-size: .66rem; }
.chip--state { border-color: var(--state-line); background: var(--state-soft); color: var(--state); }
/*
 * Category colour arrives as data-colour on the element and app.js copies it
 * into --cat after validating it. Templates never write a style attribute.
 */
.chip--cat {
    border-color: color-mix(in srgb, var(--cat, var(--accent)) 42%, transparent);
    background: color-mix(in srgb, var(--cat, var(--accent)) 12%, transparent);
    color: color-mix(in srgb, var(--cat, var(--accent)) 82%, var(--text));
}
.chip--cat:hover { border-color: var(--cat, var(--accent)); }

.chip-row { display: flex; flex-wrap: wrap; gap: .35rem; }

.tag {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .05rem .4rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface-2);
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: .64rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
    text-decoration: none;
}
a.tag:hover { color: var(--text); border-color: color-mix(in srgb, var(--accent) 50%, transparent); text-decoration: none; }
.tag--accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.tag--ok    { color: var(--ok-ink);    border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.tag--warn  { color: var(--warn-ink);  border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.tag--bad   { color: var(--bad-ink);   border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.tag--info  { color: var(--info-ink);  border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.tag--violet{ color: var(--violet-ink);border-color: color-mix(in srgb, var(--violet) 35%, transparent); }
.tag--state { color: var(--state); border-color: var(--state-line); background: var(--state-soft); }

/* .badge is a count bubble, not a label — .tag is the label. */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 .35rem;
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: .66rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.badge--accent { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.badge--bad { background: var(--bad); color: var(--light); }
.badge--dot { min-width: 8px; width: 8px; height: 8px; padding: 0; }

/* Role badge: colour arrives as data-colour, same contract as .chip--cat. */
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .1rem .45rem;
    border: 1px solid color-mix(in srgb, var(--cat, var(--accent)) 40%, transparent);
    border-radius: 4px;
    background: color-mix(in srgb, var(--cat, var(--accent)) 12%, transparent);
    color: color-mix(in srgb, var(--cat, var(--accent)) 85%, var(--text));
    font-family: var(--font-mono);
    font-size: .64rem;
    letter-spacing: .08em;
    text-transform: uppercase;
}

/* ---------------------------------------------------------------- table --- */

.table-wrap {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    border-radius: var(--radius);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
}
.table th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: .55rem .7rem;
    text-align: left;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-faint);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-strong);
}
.table td {
    padding: .55rem .7rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr { transition: background var(--speed) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.is-selected { background: var(--surface-3); box-shadow: inset 3px 0 0 var(--accent); }
.table tfoot td {
    padding: .55rem .7rem;
    border-top: 1px solid var(--border-strong);
    font-family: var(--font-mono);
    font-size: .72rem;
    color: var(--text-faint);
}
.table caption {
    caption-side: bottom;
    padding-top: .6rem;
    font-size: .74rem;
    color: var(--text-faint);
    text-align: left;
}

.table--zebra tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.table--zebra tbody tr:hover { background: var(--surface-2); }
.table--compact th, .table--compact td { padding: .35rem .5rem; font-size: .76rem; }
.table--fixed { table-layout: fixed; }

/* Numeric columns line up; that is the whole point of tabular figures. */
.table .num, .table [data-num] {
    text-align: right;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}
.table .cell-shrink { width: 1%; white-space: nowrap; }
.table .cell-mono { font-family: var(--font-mono); font-size: .76rem; }

/* Sortable heads carry aria-sort; the arrow is generated from it, so the
   markup never has to ship a direction glyph. */
.table th[aria-sort] { cursor: pointer; user-select: none; }
.table th[aria-sort]:hover { color: var(--text); }
.table th[aria-sort]::after { content: ' \2195'; opacity: .35; }
.table th[aria-sort='ascending']::after { content: ' \2191'; color: var(--accent); opacity: 1; }
.table th[aria-sort='descending']::after { content: ' \2193'; color: var(--accent); opacity: 1; }

/* On narrow screens a data table becomes a stack of labelled rows. The label
   comes from data-label on each cell. */
@media (max-width: 720px) {
    .table--stack thead { display: none; }
    .table--stack tbody tr {
        display: block;
        margin-bottom: .6rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        background: var(--surface);
    }
    .table--stack tbody td {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        padding: .4rem .6rem;
        border-bottom: 1px solid var(--border);
        text-align: right;
    }
    .table--stack tbody td::before {
        content: attr(data-label);
        font-family: var(--font-mono);
        font-size: .62rem;
        letter-spacing: .1em;
        text-transform: uppercase;
        color: var(--text-faint);
        text-align: left;
    }
}

/* ----------------------------------------------------------------- stat --- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr));
    gap: .8rem;
}
.stat {
    position: relative;
    padding: .9rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.stat::after {
    /* a quiet corner glow, the same device the Valhalla tiles use */
    content: '';
    position: absolute;
    inset: auto -30% -70% auto;
    width: 180px; height: 180px;
    background: radial-gradient(circle, color-mix(in srgb, var(--accent) 14%, transparent), transparent 65%);
    pointer-events: none;
}
.stat__label {
    display: block;
    font-family: var(--font-mono);
    font-size: .6rem;
    font-weight: 600;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--text-faint);
}
.stat__value {
    display: block;
    margin-top: .3rem;
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 1.2rem + 1vw, 2.1rem);
    line-height: 1;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.stat__unit { font-size: .5em; color: var(--text-faint); margin-left: .15em; }
.stat__foot {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin-top: .4rem;
    font-size: .7rem;
    color: var(--text-dim);
}
.stat__delta { font-family: var(--font-mono); font-size: .68rem; font-weight: 600; }
.stat__delta[data-dir='up'] { color: var(--ok-ink); }
.stat__delta[data-dir='up']::before { content: '\25B2 '; }
.stat__delta[data-dir='down'] { color: var(--bad-ink); }
.stat__delta[data-dir='down']::before { content: '\25BC '; }
.stat__delta[data-dir='flat'] { color: var(--text-faint); }
.stat__delta[data-dir='flat']::before { content: '\2192 '; }
.stat[data-state] { border-color: var(--state-line); }
.stat[data-state] .stat__value { color: var(--state); }
a.stat { text-decoration: none; transition: transform var(--speed) var(--ease), border-color var(--speed) var(--ease); }
a.stat:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }

/* ------------------------------------------------------------ site-card --- */

.site-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
    gap: 1rem;
}

.site-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform var(--speed) var(--ease), border-color var(--speed) var(--ease),
                box-shadow var(--speed) var(--ease);
}
.site-card::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--state, var(--border-strong));
    z-index: 2;
}
.site-card:hover, .site-card:focus-within {
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
    box-shadow: var(--shadow-lift);
}
.site-card__media { position: relative; display: block; }
.site-card__state {
    position: absolute;
    top: .5rem;
    left: .65rem;
    z-index: 2;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.site-card__body { display: flex; flex-direction: column; gap: .4rem; padding: .8rem .9rem; }
.site-card__title {
    margin: 0;
    font-family: var(--font-body);
    font-size: .96rem;
    font-weight: 700;
    line-height: 1.3;
}
.site-card__title a { color: var(--text); text-decoration: none; }
.site-card__title a:hover { color: var(--accent); }
/* The whole card is clickable via a stretched link, but the chips and the
   copy button inside it still need their own hit areas. */
.site-card__title a::after { content: ''; position: absolute; inset: 0; z-index: 1; }
.site-card__onion {
    /* Above the stretched link that covers the card, so the copy button and
       the address itself stay selectable. */
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: .35rem;
    font-family: var(--font-mono);
    font-size: .68rem;
    color: var(--text-faint);
    overflow: hidden;
}
.site-card__onion code {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: ltr;
}
.site-card__desc {
    margin: 0;
    font-size: .78rem;
    color: var(--text-dim);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
}
.site-card__meta {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    margin-top: auto;
    padding: .55rem .9rem;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    font-family: var(--font-mono);
    font-size: .66rem;
    color: var(--text-faint);
    position: relative;
    z-index: 2;
}
.site-card--row {
    flex-direction: row;
    align-items: stretch;
}
.site-card--row .site-card__media { flex: 0 0 clamp(7rem, 22%, 12rem); }
.site-card--row .thumb { height: 100%; }
.site-card--row .site-card__body { flex: 1; }

/* ---------------------------------------------------------------- thumb --- */

.thumb {
    position: relative;
    display: block;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background:
        linear-gradient(135deg, var(--surface-2), var(--surface-3));
    border-bottom: 1px solid var(--border);
}
.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    transition: transform 400ms var(--ease), filter 400ms var(--ease);
}
/*
 * Screenshots of onion sites are unvetted content. They are desaturated and
 * dimmed until hover so a page of them is scannable rather than lurid.
 */
.thumb img { filter: saturate(.75) brightness(.9); }
.site-card:hover .thumb img, .thumb:hover img { transform: scale(1.04); filter: none; }
.thumb::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 55%, color-mix(in srgb, var(--ink) 55%, transparent));
    pointer-events: none;
}
.thumb--sm { aspect-ratio: 16 / 10; width: 7rem; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.thumb--wide { aspect-ratio: 21 / 9; }
.thumb--square { aspect-ratio: 1; }
/* No screenshot: the placeholder says so in the terminal face, and it loses
   the bottom scrim that exists to keep a badge legible over a real capture. */
.thumb--empty { display: grid; place-items: center; }
.thumb--empty::after { content: none; }
.thumb--empty::before {
    content: 'no capture';
    font-family: var(--font-mono);
    font-size: .66rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--text-faint);
}
/* Sensitive captures stay blurred until the visitor asks. */
.thumb--blur img { filter: blur(14px) saturate(.5); }
.thumb--blur:hover img { filter: blur(14px) saturate(.5); transform: none; }
.thumb--blur.is-revealed img { filter: none; }

/* ---------------------------------------------------------------- meter --- */

/*
 * The fill is driven by --meter-value (0..100). Templates put the number in
 * data-value and app.js copies it into the custom property, because the CSP
 * rules out a style attribute. The accessible value comes from the ARIA
 * attributes on the element, so the bar degrades to an empty track without
 * losing the number.
 */
.meter {
    --meter-value: 0;
    position: relative;
    display: block;
    width: 100%;
    height: 6px;
    border-radius: var(--radius-pill);
    background: color-mix(in srgb, var(--text-faint) 22%, transparent);
    overflow: hidden;
}
.meter__fill {
    display: block;
    height: 100%;
    width: calc(var(--meter-value) * 1%);
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent-2), var(--accent));
    transition: width 600ms var(--ease);
}
.meter[data-state] .meter__fill { background: var(--state); }
.meter--lg { height: 10px; }
.meter--sm { height: 4px; }
.meter-row { display: flex; align-items: center; gap: .5rem; }
.meter-row .meter { flex: 1; }
.meter__label {
    font-family: var(--font-mono);
    font-size: .68rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-dim);
    white-space: nowrap;
}

/*
 * Segmented uptime strip: one cell per day, coloured by its own data-state and
 * sized from data-value, which app.js copies into --bar-value for the same
 * reason .meter does it.
 */
.spark { display: flex; gap: 2px; align-items: flex-end; height: 22px; }
.spark__bar {
    --bar-value: 100;
    flex: 1;
    min-width: 2px;
    height: max(2px, calc(var(--bar-value) * 1%));
    border-radius: 1px;
    background: var(--state, var(--text-faint));
    opacity: .85;
}
.spark__bar:hover { opacity: 1; }

/* -------------------------------------------------------- toast & flash --- */

.toasts {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 120;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    width: min(24rem, calc(100vw - 2rem));
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .7rem .85rem;
    background: var(--surface-3);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lift);
    font-size: .82rem;
    pointer-events: auto;
    animation: toast-in 240ms var(--ease);
}
.toast--ok    { border-left-color: var(--ok); }
.toast--error { border-left-color: var(--bad); }
.toast--warn  { border-left-color: var(--warn); }
.toast--info  { border-left-color: var(--info); }
.toast__body { flex: 1; }
.toast__close { flex: none; color: var(--text-faint); line-height: 1; }
.toast__close:hover { color: var(--text); }
.toast.is-leaving { animation: toast-out 200ms var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }

/* .flash is the server-rendered sibling of .toast: it is part of the document
   rather than an overlay, and app.js retires it after a while. */
.flash {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .7rem .9rem;
    margin-bottom: .6rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: .84rem;
    color: var(--text);
    transition: opacity var(--speed) var(--ease), transform var(--speed) var(--ease);
}
.flash__icon { flex: none; font-family: var(--font-mono); color: var(--accent); }
.flash__body { flex: 1; }
.flash__body > :last-child { margin-bottom: 0; }
.flash__close { flex: none; color: var(--text-faint); line-height: 1; }
.flash__close:hover { color: var(--text); }
.flash.is-leaving { opacity: 0; transform: translateY(-4px); }
.flash--ok    { border-left-color: var(--ok);   background: color-mix(in srgb, var(--ok) 8%, var(--surface-2)); }
.flash--ok .flash__icon { color: var(--ok-ink); }
.flash--error { border-left-color: var(--bad);  background: color-mix(in srgb, var(--bad) 8%, var(--surface-2)); }
.flash--error .flash__icon { color: var(--bad-ink); }
.flash--warn  { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn) 8%, var(--surface-2)); }
.flash--warn .flash__icon { color: var(--warn-ink); }
.flash--info  { border-left-color: var(--info); background: color-mix(in srgb, var(--info) 8%, var(--surface-2)); }
.flash--info .flash__icon { color: var(--info-ink); }

/* ----------------------------------------------------------- pagination --- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: .25rem;
    margin: 1.6rem 0 0;
    padding: 0;
    list-style: none;
}
.pagination__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 .55rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: .76rem;
    font-variant-numeric: tabular-nums;
    text-decoration: none;
    transition: color var(--speed) var(--ease), background var(--speed) var(--ease),
                border-color var(--speed) var(--ease);
}
.pagination__link:hover {
    color: var(--text);
    background: var(--surface-hover);
    border-color: var(--border-strong);
    text-decoration: none;
}
.pagination__link[aria-current='page'] {
    color: var(--light);
    background: var(--accent-2);
    border-color: transparent;
    box-shadow: 0 4px 14px color-mix(in srgb, var(--accent-2) 40%, transparent);
}
.pagination__link.is-disabled, .pagination__link[aria-disabled='true'] {
    opacity: .4;
    pointer-events: none;
}
.pagination__gap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 34px;
    color: var(--text-faint);
    font-family: var(--font-mono);
}
.pagination__info {
    width: 100%;
    text-align: center;
    margin-top: .5rem;
    font-family: var(--font-mono);
    font-size: .7rem;
    color: var(--text-faint);
}

/* ----------------------------------------------------------------- form --- */

.form { display: grid; gap: 1rem; }
.form-row {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
}
.form-actions {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    padding-top: .3rem;
}

.field { display: grid; gap: .35rem; }
.field__label {
    font-family: var(--font-mono);
    font-size: .66rem;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--text-dim);
}
.field__label .req { color: var(--bad-ink); margin-left: .2em; }
.field__hint { margin: 0; font-size: .72rem; line-height: 1.5; color: var(--text-faint); }
.field__error {
    margin: 0;
    font-size: .72rem;
    color: var(--bad-ink);
    font-family: var(--font-mono);
}
.field--inline { grid-template-columns: auto 1fr; align-items: center; gap: .5rem; }
.field.is-invalid .input, .field.is-invalid .select select, .input[aria-invalid='true'] {
    border-color: var(--bad);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent);
}

.input {
    width: 100%;
    padding: .55rem .7rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-body);
    font-size: .85rem;
    line-height: 1.5;
    transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease),
                box-shadow var(--speed) var(--ease);
}
.input:hover { border-color: var(--border-strong); }
.input:focus { outline: none; border-color: var(--accent); }
.input[disabled], .input[readonly] { opacity: .6; cursor: not-allowed; }
.input--mono { font-family: var(--font-mono); font-size: .8rem; letter-spacing: .01em; }
.input--sm { padding: .35rem .5rem; font-size: .78rem; }
textarea.input { min-height: 7rem; line-height: 1.6; }

.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -1px; }

.select { position: relative; display: block; }
.select select {
    width: 100%;
    padding: .55rem 2rem .55rem .7rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-body);
    font-size: .85rem;
    line-height: 1.5;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease);
}
.select select:hover { border-color: var(--border-strong); }
.select select:focus { outline: none; border-color: var(--accent); }
.select select option { background: var(--surface); color: var(--text); }
/* The chevron is drawn, not an image: one less request and it inherits the
   theme's text colour. */
.select::after {
    content: '';
    position: absolute;
    top: 50%;
    right: .75rem;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid var(--text-faint);
    border-bottom: 1.5px solid var(--text-faint);
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
}
.select--sm select { padding: .35rem 1.8rem .35rem .5rem; font-size: .78rem; }

/* checkbox & radio --------------------------------------------------------- */

.checkbox {
    display: inline-flex;
    align-items: flex-start;
    gap: .55rem;
    cursor: pointer;
    font-size: .84rem;
    line-height: 1.45;
    user-select: none;
}
.checkbox input {
    appearance: none;
    -webkit-appearance: none;
    flex: none;
    width: 17px;
    height: 17px;
    margin: .1rem 0 0;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    cursor: pointer;
    display: grid;
    place-content: center;
    transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease);
}
.checkbox input[type='radio'] { border-radius: 50%; }
.checkbox input::after {
    content: '';
    width: 9px;
    height: 5px;
    border-left: 2px solid var(--light);
    border-bottom: 2px solid var(--light);
    transform: rotate(-45deg) translate(1px, -1px) scale(0);
    transition: transform 140ms var(--ease);
}
.checkbox input[type='radio']::after {
    width: 7px; height: 7px; border: 0; border-radius: 50%;
    background: var(--light);
    transform: scale(0);
}
.checkbox input:checked { background: var(--accent-2); border-color: var(--accent-2); }
.checkbox input:checked::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); }
.checkbox input[type='radio']:checked::after { transform: scale(1); }
.checkbox input:indeterminate { background: var(--accent-2); border-color: var(--accent-2); }
.checkbox input:indeterminate::after {
    width: 9px; height: 0;
    border-left: 0;
    border-bottom: 2px solid var(--light);
    transform: none;
}
.checkbox input[disabled] { opacity: .5; cursor: not-allowed; }
.checkbox__text { color: var(--text-dim); }
.checkbox:hover .checkbox__text { color: var(--text); }

/* switch ------------------------------------------------------------------- */

.switch {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    cursor: pointer;
    font-size: .82rem;
    user-select: none;
}
.switch input {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    flex: none;
    width: 38px;
    height: 21px;
    background: color-mix(in srgb, var(--text-faint) 35%, transparent);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease);
}
.switch input::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--light);
    transition: transform var(--speed) var(--ease);
}
.switch input:checked { background: var(--accent-2); border-color: transparent; }
.switch input:checked::after { transform: translateX(17px); }
.switch input[disabled] { opacity: .5; cursor: not-allowed; }
.switch__text { color: var(--text-dim); }

/* segmented ---------------------------------------------------------------- */

.segmented {
    display: inline-flex;
    padding: 3px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    gap: 2px;
}
.segmented__item {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .7rem;
    border: 0;
    border-radius: calc(var(--radius-sm) - 3px);
    background: transparent;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: .7rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--speed) var(--ease), background var(--speed) var(--ease);
}
.segmented__item:hover { color: var(--text); background: var(--surface-3); text-decoration: none; }
.segmented__item.is-active, .segmented__item[aria-pressed='true'], .segmented__item[aria-current='true'] {
    color: var(--text);
    background: var(--surface-hover);
    box-shadow: inset 0 0 0 1px var(--border-strong);
}
/* The radio flavour: a real input, visually hidden, label carries the look. */
.segmented input {
    position: absolute;
    width: 1px; height: 1px;
    opacity: 0;
    pointer-events: none;
}
.segmented input:checked + .segmented__item {
    color: var(--text);
    background: var(--surface-hover);
    box-shadow: inset 0 0 0 1px var(--border-strong);
}
.segmented input:focus-visible + .segmented__item {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* search-box --------------------------------------------------------------- */

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}
.search-box__icon {
    position: absolute;
    left: .7rem;
    width: 14px;
    height: 14px;
    color: var(--text-faint);
    pointer-events: none;
}
.search-box .input {
    padding-left: 2.1rem;
    padding-right: 4.2rem;
    font-family: var(--font-mono);
    font-size: .82rem;
}
.search-box .input::-webkit-search-cancel-button { display: none; }
.search-box__clear {
    position: absolute;
    right: 2.6rem;
    display: none;
    color: var(--text-faint);
    font-size: 1rem;
    line-height: 1;
}
.search-box.has-value .search-box__clear { display: inline-flex; }
.search-box__clear:hover { color: var(--text); }
.search-box__hint {
    position: absolute;
    right: .55rem;
    pointer-events: none;
}
.search-box--lg .input { padding-block: .8rem; font-size: .95rem; }
.search-box--lg .search-box__icon { left: 1rem; width: 17px; height: 17px; }
.search-box--lg .input { padding-left: 2.7rem; }

/* filter bar: the search box, the selects and the chips over a listing */
.filter-bar {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    padding: .7rem .8rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}
.filter-bar .search-box { flex: 1 1 16rem; }
.filter-bar .select { flex: 0 1 11rem; }
.filter-bar__count {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: .7rem;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
}
/* app.js sets this while a debounced auto-submit is pending. */
.filter-bar.is-busy { opacity: .75; }

/* ---------------------------------------------------------------- modal --- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 140;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: color-mix(in srgb, var(--ink) 68%, transparent);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--speed) var(--ease);
}
.modal.is-open { opacity: 1; pointer-events: auto; }
.modal__panel {
    width: min(34rem, 100%);
    max-height: min(80vh, 44rem);
    overflow-y: auto;
    padding: 1.2rem 1.3rem;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lift);
    transform: translateY(10px) scale(.985);
    transition: transform var(--speed) var(--ease);
}
.modal.is-open .modal__panel { transform: none; }
.modal--wide .modal__panel { width: min(56rem, 100%); }
.modal__head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: .6rem; }
.modal__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.1rem;
    letter-spacing: .05em;
}
.modal__close {
    margin-left: auto;
    flex: none;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-faint);
    line-height: 1;
}
.modal__close:hover { color: var(--text); border-color: var(--border-strong); }
.modal__body { font-size: .88rem; color: var(--text-dim); }
.modal__body > :last-child { margin-bottom: 0; }
.modal__subject {
    display: block;
    margin: .4rem 0 .8rem;
    padding: .5rem .65rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: .76rem;
    color: var(--text);
    overflow-wrap: anywhere;
}
.modal__actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.2rem; }

/* The page must not scroll behind an open modal. */
body.is-modal-open { overflow: hidden; }

/* ----------------------------------------------------------------- tabs --- */

.tabs {
    display: flex;
    gap: .15rem;
    margin-bottom: 1.1rem;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs__tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem .85rem;
    border: 0;
    background: none;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: .76rem;
    letter-spacing: .06em;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: color var(--speed) var(--ease);
}
.tabs__tab:hover { color: var(--text); text-decoration: none; }
.tabs__tab::after {
    content: '';
    position: absolute;
    left: .5rem;
    right: .5rem;
    bottom: -1px;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: var(--accent);
    transform: scaleX(0);
    transition: transform var(--speed) var(--ease);
}
.tabs__tab[aria-selected='true'], .tabs__tab.is-active { color: var(--text); }
.tabs__tab[aria-selected='true']::after, .tabs__tab.is-active::after { transform: scaleX(1); }
.tabs__tab .badge { margin-left: .1rem; }
.tab-panel[hidden] { display: none; }

/* ---------------------------------------------------------- breadcrumb ---- */

.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .3rem;
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
    font-family: var(--font-mono);
    font-size: .72rem;
    color: var(--text-faint);
}
.breadcrumb li { display: inline-flex; align-items: center; gap: .3rem; margin: 0; }
.breadcrumb li + li::before { content: '/'; color: var(--border-strong); }
.breadcrumb a { color: var(--text-dim); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb [aria-current='page'] { color: var(--text); }

/* ------------------------------------------------------------ dropdown ---- */

.dropdown { position: relative; display: inline-flex; }
.dropdown__menu {
    position: absolute;
    top: calc(100% + .4rem);
    right: 0;
    z-index: 60;
    min-width: 12rem;
    padding: .3rem;
    margin: 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lift);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity var(--speed) var(--ease), transform var(--speed) var(--ease),
                visibility var(--speed);
}
.dropdown.is-open .dropdown__menu { opacity: 1; visibility: visible; transform: none; }
.dropdown__menu--left { right: auto; left: 0; }
.dropdown__item {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    padding: .45rem .6rem;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-size: .82rem;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
}
.dropdown__item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.dropdown__item--danger { color: var(--bad-ink); }
.dropdown__item--danger:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad-ink); }
.dropdown__sep { height: 1px; margin: .3rem .2rem; background: var(--border); }
.dropdown__label {
    padding: .35rem .6rem .2rem;
    font-family: var(--font-mono);
    font-size: .6rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--text-faint);
}

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

.empty {
    display: grid;
    justify-items: center;
    gap: .5rem;
    padding: clamp(2rem, 6vw, 4rem) 1.5rem;
    text-align: center;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.empty__mark {
    font-family: var(--font-mono);
    font-size: .8rem;
    letter-spacing: .3em;
    text-transform: uppercase;
    color: var(--accent);
}
.empty__title { margin: 0; font-family: var(--font-display); font-size: 1.15rem; letter-spacing: .04em; }
.empty__text { margin: 0; max-width: 44ch; font-size: .85rem; color: var(--text-dim); }
.empty__actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; margin-top: .4rem; }

/* ------------------------------------------------------------ skeleton ---- */

.skeleton {
    position: relative;
    /* Inline by default would collapse the width/height the variants set. */
    display: block;
    overflow: hidden;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--text-faint) 16%, transparent);
    color: transparent !important;
    user-select: none;
    pointer-events: none;
}
.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg,
        transparent,
        color-mix(in srgb, var(--light) 10%, transparent),
        transparent);
    animation: skeleton-sweep 1.4s var(--ease) infinite;
}
@keyframes skeleton-sweep { to { transform: translateX(100%); } }
.skeleton--text { height: .8em; margin: .25em 0; }
.skeleton--title { height: 1.2em; width: 60%; }
.skeleton--line { height: .8em; width: 100%; }
.skeleton--line-sm { height: .8em; width: 40%; }
.skeleton--thumb { aspect-ratio: 16 / 10; width: 100%; border-radius: 0; }
.skeleton--circle { border-radius: 50%; }

/* ------------------------------------------------------- code, kbd, pre --- */

code {
    padding: .08em .38em;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: .86em;
    color: var(--accent);
    overflow-wrap: anywhere;
}
a code { color: inherit; }

/* .code is a block: a padded, accent-ruled slab for multi-line output. Used
   inline in a sentence it renders as a full-width box that breaks the line in
   half, which is exactly what it did in the /admin/settings intro. This is the
   in-a-sentence variant. */
.code--inline,
code.inline {
    display: inline;
    padding: .1em .4em;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-family: var(--font-mono);
    font-size: .88em;
    color: var(--text);
    white-space: nowrap;
}

.code {
    position: relative;
    display: block;
    padding: .9rem 1rem;
    /* One step below the surface it sits on, in both themes — a code block
       that stayed dark on the light theme read as a hole in the page. */
    background: color-mix(in srgb, var(--bg-2) 70%, var(--surface));
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: .78rem;
    line-height: 1.6;
    color: var(--text-dim);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    overflow-x: auto;
}
.code code { padding: 0; background: none; border: 0; color: inherit; font-size: inherit; }
.code__copy { position: absolute; top: .45rem; right: .45rem; }
.code--inline-copy { padding-right: 3rem; }
/* A prompt line inside a code block. */
.code .prompt { color: var(--ok-ink); user-select: none; }
.code .prompt::after { content: ' $ '; color: var(--text-faint); }

/* An onion address: long, unreadable, and copied more often than read. */
.onion {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    max-width: 100%;
    font-family: var(--font-mono);
    font-size: .78rem;
    color: var(--text-dim);
    overflow-wrap: anywhere;
}
.onion__value {
    padding: .1rem .35rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
}
.onion--trunc .onion__value {
    max-width: 22ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kbd, kbd {
    display: inline-block;
    min-width: 1.4em;
    padding: .05em .4em;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 5px;
    font-family: var(--font-mono);
    font-size: .72em;
    line-height: 1.5;
    color: var(--text-dim);
    text-align: center;
    white-space: nowrap;
}

/* --------------------------------------------------------------- avatar --- */

.avatar {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, var(--accent-2), var(--accent));
    border: 1px solid var(--border);
    color: var(--light);
    font-family: var(--font-display);
    font-size: .8rem;
    letter-spacing: .02em;
    text-transform: uppercase;
    user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 24px; height: 24px; font-size: .66rem; }
.avatar--lg { width: 56px; height: 56px; font-size: 1.3rem; }
.avatar--xl { width: 88px; height: 88px; font-size: 2rem; }
.avatar-group { display: inline-flex; }
.avatar-group .avatar + .avatar { margin-left: -.5rem; box-shadow: 0 0 0 2px var(--surface); }

/* -------------------------------------------------------------- tooltip --- */

/*
 * CSS-only: the text lives in data-tooltip, so there is no JS and nothing to
 * initialise. Interactive elements still need a real accessible name — the
 * tooltip is a supplement, never the only label.
 */
/* .tooltip is the same component under its class name; either way the text
   itself comes from the data-tooltip attribute. */
[data-tooltip], .tooltip { position: relative; }
.tooltip:not([data-tooltip])::after { content: none; }
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + .45rem);
    left: 50%;
    z-index: 80;
    transform: translateX(-50%) translateY(3px);
    padding: .3rem .5rem;
    width: max-content;
    max-width: 16rem;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    color: var(--text);
    font-family: var(--font-body);
    font-size: .7rem;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    line-height: 1.4;
    white-space: normal;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--speed) var(--ease), transform var(--speed) var(--ease),
                visibility var(--speed);
}
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%);
}
[data-tooltip][data-tooltip-pos='bottom']::after { bottom: auto; top: calc(100% + .45rem); }
[data-tooltip='']::after { display: none; }

/* ---------------------------------------------------------------- footer -- */

.site-foot {
    margin-top: auto;
    padding-block: 2rem 2.5rem;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg-2) 70%, transparent);
    font-size: .8rem;
    color: var(--text-dim);
}
.site-foot__grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
}
.site-foot h2, .site-foot h3 {
    font-family: var(--font-mono);
    font-size: .64rem;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: .6rem;
}
.site-foot ul { list-style: none; margin: 0; padding: 0; }
.site-foot li { margin: .25rem 0; }
.site-foot a { color: var(--text-dim); text-decoration: none; }
.site-foot a:hover { color: var(--accent); }
.site-foot__bar {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    margin-top: 1.6rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: .7rem;
    color: var(--text-faint);
}
.site-foot__prompt::before { content: 'thugs@red:~$ '; color: var(--ok-ink); }

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

/* A definition list rendered as an aligned key/value block. */
.kv {
    display: grid;
    grid-template-columns: minmax(6rem, auto) 1fr;
    gap: .35rem .9rem;
    margin: 0;
    font-size: .82rem;
}
.kv dt {
    font-family: var(--font-mono);
    font-size: .66rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-faint);
    font-weight: 400;
    padding-top: .15rem;
}
.kv dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }

/* Copy-to-clipboard buttons flash their confirmation through this class. */
.is-copied { color: var(--ok-ink) !important; border-color: color-mix(in srgb, var(--ok) 50%, transparent) !important; }

/* A live region that must occupy no space. */
.visually-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* The board shows one card per operator; this says how many addresses that card
   stands for. Muted rather than accented -- it is context, not a status. */
.site-card__mirrors {
    color: var(--text-faint);
    border-color: var(--border);
}
.site-card__mirrors:hover,
.site-card__mirrors:focus-visible {
    color: var(--accent);
    border-color: var(--accent);
}
