/* ==========================================================================
   Epsilon AI — Hub
   Hand-written CSS, no build step and no external requests, so the app works
   on shared hosting exactly as it does locally.
   ========================================================================== */

:root {
    /* --- Surfaces -------------------------------------------------------
       Three of them, not two. A page that is one flat colour with boxes
       drawn on it reads as a form; giving the page, the panel and the
       inset each their own tone lets depth do the work borders used to. */
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f2f4f7;
    --surface-3: #e9edf2;

    --border: #e4e8ee;
    --border-strong: #cfd6e0;

    --text: #101828;
    --muted: #667085;
    --faint: #98a2b3;

    --brand: #1f4fd8;
    --brand-dark: #1a3fb0;
    --brand-soft: #eef3ff;

    --ok: #067a55;
    --ok-soft: #e6f6f0;
    --warn: #b54708;
    --warn-soft: #fef4e6;
    --danger: #b42318;
    --danger-soft: #fef3f2;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;

    /* --- Shadows ---------------------------------------------------------
       Layered rather than single: a tight dark line for the edge and a
       wider soft one for the lift. One shadow at one blur always looks
       like a sticker. */
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-md: 0 2px 4px rgba(16, 24, 40, .04), 0 4px 12px rgba(16, 24, 40, .07);
    --shadow-lg: 0 4px 8px rgba(16, 24, 40, .04), 0 12px 28px rgba(16, 24, 40, .10);

    --sidebar-w: 248px;

    /* Inter where the machine has it — every Apple and most Windows
       installs do now — falling back to the system stack rather than to a
       download, because a webfont request is a dependency this app does
       not otherwise have. */
    --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
            "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}


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

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0 0 .75rem; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: 12px; }

/* --- Environment ribbon --------------------------------------------------- */
.env-ribbon {
    /* Loud enough that nobody mistakes staging for production, quiet enough
       to sit above every screen all day. The old version was diagonal stripes
       at full saturation, which on a dark theme was the brightest thing on the
       page by a distance. */
    background: var(--warn-soft);
    color: var(--warn);
    border-bottom: 1px solid var(--warn);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .1em;
    text-align: center;
    padding: 4px 8px;
}

/* --- Shell ---------------------------------------------------------------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1rem; border-bottom: 1px solid var(--border); }
.brand-mark {
    width: 32px; height: 32px; flex: 0 0 32px;
    display: grid; place-items: center;
    background: var(--brand); color: #fff;
    border-radius: 8px; font-weight: 700; font-size: 18px;
}
.brand-mark-lg { width: 48px; height: 48px; font-size: 26px; margin: 0 auto .75rem; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { flex: 1; overflow-y: auto; padding: .6rem .5rem; }
.nav-link {
    display: flex; align-items: center; gap: .6rem;
    padding: .5rem .65rem; margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: var(--text); font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-link.is-active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-link svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-divider { padding: 1rem .65rem .3rem; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }

.sidebar-foot { padding: .75rem; border-top: 1px solid var(--border); display: grid; gap: .5rem; min-width: 0; }

/* min-width: 0 on every one of these, and it is not decoration.
   A flex item defaults to min-width: auto, which means "never shrink below
   your own content" — so text-overflow: ellipsis below can never fire, and a
   long name pushes the chip wider than the sidebar holding it instead of
   truncating. "Karim Yahia (Hub administrator)" made a 253px chip inside a
   248px sidebar. The ellipsis was already written; this is what lets it run. */
.user-chip { display: flex; align-items: center; gap: .55rem; color: var(--text); padding: .3rem; border-radius: var(--radius-sm); min-width: 0; }
.user-chip:hover { background: var(--surface-2); text-decoration: none; }
.user-chip span { display: flex; flex-direction: column; line-height: 1.25; overflow: hidden; min-width: 0; }
.user-chip strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The job title underneath needs the same treatment — "Head of Learning and
   Development" is no shorter than the name above it. */
.user-chip small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
    width: 30px; height: 30px; flex: 0 0 30px;
    display: grid !important; place-items: center;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 50%; font-weight: 700; font-size: 13px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; gap: .75rem;
    padding: .85rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; flex: 1; min-width: 0; }
.topbar-actions { display: flex; gap: .5rem; margin-left: auto; align-items: center; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    background: none; border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: .35rem; cursor: pointer; color: var(--text);
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.content { flex: 1; padding: 1.5rem; max-width: 1400px; width: 100%; }

.footer {
    display: flex; justify-content: space-between; gap: 1rem;
    padding: 1rem 1.5rem; color: var(--muted); font-size: 12px;
    border-top: 1px solid var(--border);
}

/* --- Buttons -------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .5rem .85rem;
    font: inherit; font-weight: 550; font-size: 13.5px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
    cursor: pointer; white-space: nowrap;
    transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.link { color: var(--brand); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.link:hover { text-decoration: underline; }
.link-danger { color: var(--danger); }

/* --- Alerts --------------------------------------------------------------- */
.alert {
    padding: .75rem 1rem; margin-bottom: 1rem;
    border: 1px solid var(--border); border-left-width: 3px;
    border-radius: var(--radius-sm);
    background: var(--surface);
}
.alert-success { border-left-color: var(--ok); background: var(--ok-soft); }
.alert-error   { border-left-color: var(--danger); background: var(--danger-soft); }
.alert-warning { border-left-color: var(--warn); background: var(--warn-soft); }
.alert-info    { border-left-color: var(--brand); background: var(--brand-soft); }
.alert ul { margin: .5rem 0 .25rem; padding-left: 1.2rem; }
.alert ul.tight li { margin-bottom: .2rem; }

/* --- Panels & layout ------------------------------------------------------ */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.15rem 1.15rem;
    margin-bottom: 1.25rem;
}
.panel-head {
    display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
    padding-bottom: .7rem; margin-bottom: .9rem;
    border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 14.5px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 1.25rem; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.toolbar p { margin: 0; max-width: 60ch; }

/* --- Stats ---------------------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat {
    display: flex; flex-direction: column; gap: .15rem;
    padding: 1rem 1.1rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    color: var(--text);
}
a.stat:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 680; line-height: 1.15; letter-spacing: -.02em; }
.stat-value-sm { font-size: 17px; }
.stat-note { font-size: 12px; color: var(--muted); }
.stat-ok .stat-value { color: var(--ok); }
.stat-danger .stat-value { color: var(--danger); }
.stat-warn .stat-value { color: var(--warn); }
.stat-static { cursor: default; }

/* --- Tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel .table-wrap { border: 0; box-shadow: none; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
    text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); font-weight: 650;
    padding: .6rem .85rem; border-bottom: 1px solid var(--border);
    background: var(--surface-2); white-space: nowrap;
}
.table td { padding: .65rem .85rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table td small { display: block; color: var(--muted); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .num small { text-align: right; }
.table-compact td, .table-compact th { padding: .45rem .7rem; }
.nowrap { white-space: nowrap; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions form { display: inline; margin-left: .5rem; }
.row-warn { background: var(--warn-soft); }

.result-count { color: var(--muted); font-size: 12.5px; margin-bottom: .5rem; }

/* --- Badges --------------------------------------------------------------- */
.badge {
    display: inline-block; padding: .1rem .45rem;
    font-size: 11px; font-weight: 650; text-transform: capitalize;
    border-radius: 4px; border: 1px solid var(--border-strong);
    background: var(--surface-2); color: var(--muted);
}
.badge-confirmed, .badge-active { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.badge-draft { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.badge-cancelled, .badge-inactive { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.badge-completed, .badge-archived { background: var(--surface-2); color: var(--muted); }

/* --- Forms ---------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; border: 0; padding: 0; }
.field > span, .field legend { font-size: 12.5px; font-weight: 600; color: var(--text); padding: 0; }
.field input, .field select, .field textarea, .filters input, .filters select {
    font: inherit; font-size: 13.5px;
    padding: .5rem .6rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
    width: 100%;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus,
.filters input:focus, .filters select:focus {
    outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand);
}
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 0 1rem; }
.hint { color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.field-error { color: var(--danger); font-size: 12px; margin: 0; font-weight: 550; }

.check-inline { display: flex; align-items: center; gap: .4rem; font-size: 13.5px; white-space: nowrap; }
.check-inline input { width: auto; }

.stack { display: grid; gap: 0; }

.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
.form-main { min-width: 0; }
.form-aside { min-width: 0; }
.sticky { position: sticky; top: 5rem; }
.form-narrow { max-width: 780px; }
.form-actions { display: flex; gap: .6rem; margin-bottom: 1.5rem; }

.filters {
    display: flex; flex-wrap: wrap; gap: .55rem; align-items: center;
    margin-bottom: 1.25rem; padding: .85rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.filters input[type="search"] { flex: 1 1 220px; width: auto; }
.filters select { width: auto; flex: 0 1 190px; }
.push-right { margin-left: auto; }

.inline-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; padding-top: 1rem; border-top: 1px solid var(--border); margin-top: 1rem; }
.inline-form .field { margin-bottom: 0; flex: 0 1 150px; }

.danger-zone {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    padding: 1rem 1.15rem; margin-bottom: 2rem;
    border: 1px solid var(--danger); border-radius: var(--radius);
    background: var(--danger-soft);
}
.danger-zone small { display: block; color: var(--muted); }

/* --- Lists ---------------------------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: .1rem; }
.timeline li { display: grid; grid-template-columns: 62px 1fr auto; gap: .75rem; align-items: start; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.timeline .time { font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
.timeline .time small { font-weight: 400; color: var(--muted); }
.timeline .body { display: flex; flex-direction: column; min-width: 0; }
.timeline .body small { color: var(--muted); }

.load-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.load-list li { display: grid; grid-template-columns: minmax(min(90px, 30%), 1.2fr) 2fr auto; gap: .7rem; align-items: center; font-size: 13px; }
.load-num { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.bar { height: 7px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--brand); }
.bar span.warn { background: var(--warn); }
.bar span.over { background: var(--danger); }
.bar-cell { min-width: 130px; }

.date-list { list-style: none; margin: 0; padding: 0; max-height: 380px; overflow-y: auto; display: grid; gap: 1px; }
.date-list li { display: flex; align-items: center; gap: .6rem; padding: .3rem .4rem; border-radius: 4px; font-size: 13px; }
.date-list li:nth-child(odd) { background: var(--surface-2); }
.date-list li.past { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.date-list li.today { background: var(--brand-soft); font-weight: 600; }
.date-list .n { width: 26px; color: var(--muted); font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; }
.date-list em { color: var(--brand); font-style: normal; font-size: 11px; font-weight: 700; }

.definition { display: grid; grid-template-columns: minmax(min(110px, 35%), auto) 1fr; gap: .35rem 1rem; margin: 0; font-size: 13.5px; }
.definition dt { color: var(--muted); font-size: 12.5px; }
.definition dd { margin: 0; }

.notes { white-space: pre-wrap; font-size: 13.5px; color: var(--text); background: var(--surface-2); padding: .75rem; border-radius: var(--radius-sm); }

/* --- Detail header -------------------------------------------------------- */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.detail-head h2 { font-size: 20px; margin: .3rem 0 .15rem; }
.detail-actions { display: flex; gap: .5rem; }

/* --- Empty states --------------------------------------------------------- */
.empty-state {
    text-align: center; padding: 3rem 1.5rem;
    background: var(--surface); border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
}
.empty-state h2 { font-size: 17px; margin-bottom: .4rem; }
.empty-state p { color: var(--muted); max-width: 48ch; margin: 0 auto 1rem; }
.empty-ok h2 { color: var(--ok); }
.empty { color: var(--muted); text-align: center; padding: 1.25rem 0; margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.quick-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }

/* --- Centered pages (login, setup) --------------------------------------- */
body.centered { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; align-content: center; }
body.centered .env-ribbon { position: fixed; top: 0; left: 0; right: 0; }
.card-centered { width: 100%; max-width: 420px; }
.login { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 2rem 1.75rem; }
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand h1 { font-size: 19px; }
.login-brand p { color: var(--muted); font-size: 12.5px; margin: .2rem 0 0; }
.login-foot { text-align: center; color: var(--muted); font-size: 11.5px; margin: 1rem 0 0; }

.setup { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 1.75rem; }
.card-centered:has(.setup) { max-width: 620px; }
.setup h1 { font-size: 19px; margin-bottom: .6rem; }
.setup-steps { padding-left: 1.2rem; display: grid; gap: .5rem; margin: 1rem 0; }
.setup code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: .05rem .3rem; font-size: 12.5px; }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 1080px) {
    .form-layout { grid-template-columns: minmax(0, 1fr); }
    .sticky { position: static; }
}

/* The hamburger is the one icon button that only exists on a narrow window;
   it is hidden by default and revealed here, rather than the whole class
   being hidden and every other user of it having to opt back in. */
#sidebar-toggle { display: none; }

@media (max-width: 860px) {
    #sidebar-toggle { display: inline-grid; }
    .sidebar {
        position: fixed; z-index: 40; left: 0; top: 0;
        transform: translateX(-100%); transition: transform .2s ease;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.is-open { transform: translateX(0); }
    .content { padding: 1rem; }
    .topbar { padding: .75rem 1rem; }
    .cal-week { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); }
    .cal-month { font-size: 10px; }
    .cal-cell { min-height: 72px; }
}

@media print {
    .sidebar, .topbar, .filters, .site-foot, .footer, .form-actions, .danger-zone, .quick-actions, .env-ribbon { display: none !important; }
    body { background: #fff; }
    .panel, .table-wrap { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}

/* --- Releases -------------------------------------------------------------- */
.env-card .definition { font-size: 13px; }
.version {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 4px; padding: .05rem .35rem;
}
.text-danger { color: var(--danger); font-weight: 600; }
.rollback-form { display: flex; gap: .3rem; align-items: center; justify-content: flex-end; }
.rollback-form input[type="text"] {
    font: inherit; font-size: 11px; padding: .2rem .35rem;
    border: 1px solid var(--border-strong); border-radius: 4px;
    background: var(--surface); color: var(--text);
}
/* The pre-flight checklist. Each row carries its state in the colour of the
   mark and in a word for screen readers, never in colour alone. */
.preflight { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .1rem; }
.preflight li {
    display: grid; grid-template-columns: 1.4rem 1fr; gap: .55rem;
    align-items: start; padding: .5rem .6rem; border-radius: 6px;
}
.preflight-mark {
    display: grid; place-items: center; width: 1.4rem; height: 1.4rem;
    border-radius: 50%; font-size: 12px; font-weight: 700; line-height: 1;
}
.preflight-body { display: grid; gap: .1rem; font-size: 13px; }
.preflight-body strong { font-weight: 600; }
.preflight-fix { font-size: 12.5px; color: var(--text); opacity: .85; }

.preflight-pass .preflight-mark { background: var(--ok-soft); color: var(--ok); }
.preflight-warn { background: var(--warn-soft); }
.preflight-warn .preflight-mark { background: var(--warn); color: #fff; }
.preflight-fail { background: var(--danger-soft); }
.preflight-fail .preflight-mark { background: var(--danger); color: #fff; }

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

/* Releasing is a deliberate act, so its form is laid out to be read rather
   than skimmed past: fields stacked, confirmation last, button after it. */
.release-form { display: grid; gap: .7rem; max-width: 26rem; margin-top: 1rem; }
.release-form .field { display: grid; gap: .25rem; }
.release-form input[type="text"] {
    font: inherit; padding: .45rem .55rem;
    border: 1px solid var(--border-strong); border-radius: 5px;
    background: var(--surface); color: var(--text);
}
.release-form button { justify-self: start; }
.release-alt { margin-top: 1.4rem; border-top: 1px solid var(--border); padding-top: .8rem; }
.release-alt summary { cursor: pointer; font-size: 13px; }
.release-alt p { margin: .5rem 0 .7rem; }

.config-problem {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
    background: var(--danger-soft); border-left: 3px solid var(--danger);
    padding: .6rem .75rem; border-radius: var(--radius-sm); overflow-wrap: anywhere;
}

/* --- App tiles ------------------------------------------------------------- */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
    gap: .9rem;
    margin-bottom: 1.6rem;
}

.tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .95rem 1rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    position: relative;
}
.tile:hover { box-shadow: var(--shadow-lg); border-color: var(--border-strong); }

.tile-head { display: flex; align-items: flex-start; gap: .7rem; }
.tile-mark {
    width: 38px; height: 38px; flex: 0 0 38px;
    display: grid; place-items: center;
    border-radius: 9px;
    color: #fff; font-weight: 700; font-size: 14px; letter-spacing: -.02em;
}
.tile-title { display: flex; flex-direction: column; min-width: 0; }
.tile-title a { color: var(--text); font-weight: 650; font-size: 14.5px; }
.tile-title a:hover { color: var(--brand); text-decoration: none; }
.tile-title small { color: var(--muted); line-height: 1.4; }

.tile-links { display: flex; flex-wrap: wrap; gap: .35rem; }
.tile-link {
    font-size: 11.5px; font-weight: 600;
    padding: .2rem .5rem;
    border: 1px solid var(--border); border-radius: 999px;
    color: var(--muted);
}
.tile-link:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.tile-link.is-primary { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

.tile-foot {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: .55rem;
    display: grid;
    gap: .4rem;
}

/* --- One stored login, wherever it appears -------------------------------- */
.cred {
    display: flex; align-items: center; gap: .5rem;
    padding: .35rem .1rem;
    font-size: 12.5px;
}
.cred + .cred { border-top: 1px dashed var(--border); }
.cred-who { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.35; }
.cred-user { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cred-label { color: var(--muted); font-size: 11px; }
.cred-actions { display: flex; gap: .25rem; flex: 0 0 auto; flex-wrap: wrap; }

/*
 * Inside a tile there is no room for the buttons beside the username: four of
 * them and an email address do not fit in 280px, and the row clipped rather
 * than wrapped. Stack them under it there, and keep the side-by-side layout
 * for the vault list, which has the whole width to play with.
 */
.tile .cred { flex-direction: column; align-items: stretch; gap: .35rem; }
.tile .cred-actions { justify-content: flex-start; }

.mini {
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    border-radius: var(--radius-sm);
    font: 600 11.5px/1 var(--font);
    padding: .38rem .5rem;
    cursor: pointer;
    display: inline-flex; align-items: center; gap: .3rem;
}
.mini:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.mini[disabled] { opacity: .5; cursor: not-allowed; }
.mini.is-done { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
.mini svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* The revealed secret. Monospace because it will be read character by
   character, and selectable because it will also be dragged into a field. */
.secret {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    background: var(--warn-soft);
    border: 1px solid var(--warn);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: .3rem .45rem;
    word-break: break-all;
    user-select: all;
}
.secret-timer { font-size: 11px; color: var(--warn); font-weight: 600; }

/* --- Vault lock state ------------------------------------------------------ */
.lockbar {
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    padding: .55rem .8rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    margin-bottom: 1rem;
    font-size: 12.5px;
}
.lockbar.is-locked { border-color: var(--border-strong); background: var(--surface-2); }
.lockbar.is-open { border-color: var(--ok); background: var(--ok-soft); }
.lockbar strong { font-size: 13px; }
.lockbar .spacer { margin-left: auto; }
.lock-icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* --- Access matrix --------------------------------------------------------- */
.matrix-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.matrix { border-collapse: separate; border-spacing: 0; font-size: 12.5px; min-width: 100%; }
.matrix th, .matrix td { padding: .4rem .55rem; border-bottom: 1px solid var(--border); text-align: center; }
.matrix thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--surface-2);
    font-size: 11px; font-weight: 700;
    white-space: nowrap;
    /* Column headers are app names, which are long and numerous; turning them
       keeps the grid readable without a horizontal scroll per app. */
    writing-mode: vertical-rl; transform: rotate(180deg);
    height: 11rem; vertical-align: bottom;
    /* A long app name still has to end somewhere; the full one is on the
       cell's title attribute. */
    max-height: 11rem; overflow: hidden; text-overflow: ellipsis;
}
.matrix tbody th {
    position: sticky; left: 0; z-index: 1;
    background: var(--surface);
    text-align: left; white-space: nowrap;
    border-right: 1px solid var(--border);
    font-weight: 600;
}
.matrix tbody tr:hover th, .matrix tbody tr:hover td { background: var(--surface-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--border-strong); }
.dot.is-use { background: var(--brand); }
.dot.is-manage { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.is-expired { background: var(--warn); }

/* A cell can carry three facts at once: the level, the environment when it is
   not both, and whether it came from a role. Stacked rather than spelled out,
   because the matrix's whole value is being readable at a glance. */
.cell-grant { display: inline-flex; align-items: center; gap: 2px; }
.env-flag {
    font-size: 8.5px; font-weight: 800; letter-spacing: .02em;
    color: var(--warn); line-height: 1;
}
.via-role { font-size: 6px; color: var(--muted); line-height: 1; align-self: flex-start; }

/* --- The launch page ------------------------------------------------------- */
.launching { text-align: center; padding: 4rem 1rem; }
.launching .spinner {
    width: 34px; height: 34px; margin: 0 auto 1rem;
    border: 3px solid var(--border); border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Token, shown exactly once --------------------------------------------- */
.token-box {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    background: var(--surface-2);
    border: 1px dashed var(--brand);
    border-radius: var(--radius-sm);
    padding: .6rem .7rem;
    word-break: break-all;
    user-select: all;
}

/* --- Strength meter -------------------------------------------------------- */
.strength { display: flex; gap: 3px; margin-top: .35rem; }
.strength span { height: 4px; flex: 1; border-radius: 2px; background: var(--border); }
.strength[data-score="1"] span:nth-child(-n+1) { background: var(--danger); }
.strength[data-score="2"] span:nth-child(-n+2) { background: var(--warn); }
.strength[data-score="3"] span:nth-child(-n+3) { background: var(--brand); }
.strength[data-score="4"] span { background: var(--ok); }

/* --- Small print ----------------------------------------------------------- */
.hint { color: var(--muted); font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.row-actions { display: flex; gap: .35rem; justify-content: flex-end; flex-wrap: wrap; }
.section-title {
    font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
    color: var(--muted); font-weight: 700; margin: 0 0 .5rem;
}

/* --- Detail header, with a mark ------------------------------------------- */
.detail-header {
    display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.detail-header h2 { font-size: 20px; }
.detail-header .push-right { display: flex; gap: .5rem; margin-left: auto; }
.detail-header p { margin: .1rem 0 0; }
/* The name, what it is, and nothing fighting them for the width. */
.detail-about { min-width: 0; flex: 1 1 22rem; }
.detail-description { margin-top: .5rem !important; max-width: 60ch; line-height: 1.5; }
/* An app's own page is where its logo is the subject rather than a label, so
   it gets room to be seen rather than squeezed into a tile's corner. */
.tile-mark.mark-lg { border-radius: 14px; }
.tile-mark.mark-lg:has(img) { padding: 7px; }

dt { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }

/* --- Passkeys -------------------------------------------------------------- */
.login-or {
    display: flex; align-items: center; gap: .6rem;
    margin: .9rem 0 .7rem; color: var(--muted); font-size: 11.5px;
}
.login-or::before, .login-or::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}

/* One line of feedback for a flow that happens in a browser dialog we cannot
   see. Without it a dismissed prompt is indistinguishable from a broken
   button. */
.tt-status {
    margin-top: .75rem;
    padding: .45rem .6rem;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
}
.tt-status.is-ok    { border-color: var(--ok);     background: var(--ok-soft);     color: var(--ok); }
.tt-status.is-error { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.tt-status.is-warn  { border-color: var(--warn);   background: var(--warn-soft);   color: var(--warn); }

#passkey-add { padding-top: .75rem; }

.passkey-list { list-style: none; margin: .6rem 0 0; padding: 0; }
.passkey-list li {
    display: flex; align-items: center; gap: .5rem;
    padding: .45rem 0;
    border-top: 1px solid var(--border);
    font-size: 12.5px;
}
.passkey-list li span { flex: 1; }
.passkey-list small { color: var(--muted); }

/* ==========================================================================
   Refinements
   --------------------------------------------------------------------------
   Appended rather than woven in, so what changed in the visual pass stays
   readable as one thing and can be argued with as one thing.
   ========================================================================== */

/* --- Type ------------------------------------------------------------------
   One scale, and a tighter tracking on headings. Most of what makes an
   interface look unconsidered is text set at whatever size the browser
   happened to give it. */
body { font-size: 14px; line-height: 1.55; letter-spacing: -0.006em; }

h1, h2, h3 { letter-spacing: -0.021em; font-weight: 600; }
h1 { font-size: 19px; }
.panel-head h2 { font-size: 14px; letter-spacing: -0.011em; }
.detail-header h2 { font-size: 22px; }

.hint, small { font-size: 12.5px; line-height: 1.5; }
.mono, code { font-family: var(--mono); font-size: 12.5px; }

/* --- Shell -----------------------------------------------------------------
   The sidebar sits on the page colour rather than on white: it is
   navigation, not content, and letting the content area be the brightest
   surface is what tells you where to look. */
.sidebar { background: var(--bg); border-right: 1px solid var(--border); }
.brand { border-bottom: none; padding: 1.1rem 1rem .9rem; }
.brand-mark { border-radius: 9px; box-shadow: var(--shadow); }

.nav { padding: .35rem .55rem; }
.nav-link {
    border-radius: var(--radius-sm);
    padding: .48rem .6rem;
    font-size: 13.5px;
    color: var(--muted);
    transition: background .12s ease, color .12s ease;
}
.nav-link:hover { background: var(--surface-3); color: var(--text); }
.nav-link.is-active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
.nav-link svg { opacity: .85; }
.nav-divider { padding: 1.05rem .6rem .3rem; font-size: 10px; color: var(--faint); }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    backdrop-filter: saturate(180%) blur(8px);
}
.content { padding: 1.4rem 1.5rem 3rem; }

/* --- Panels ----------------------------------------------------------------
   Rounder, softer, and separated by shadow rather than by a hard line. */
.panel {
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border-color: var(--border);
    overflow: hidden;
}
.panel-head {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .85rem .95rem;
}

/* --- Buttons ---------------------------------------------------------------
   A button should look pressable and then look pressed. The 1px lift on
   hover and its removal on click is most of that feeling. */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 550;
    letter-spacing: -0.006em;
    transition: transform .08s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--brand-dark); box-shadow: var(--shadow-md); }
.btn-ghost:hover { border-color: var(--border-strong); background: var(--surface-2); }

.mini { border-radius: 7px; transition: border-color .12s ease, color .12s ease, background .12s ease; }

/* Keyboard focus that is visible without being shouted. */
:where(a, button, input, select, textarea, summary):focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* --- Tiles -----------------------------------------------------------------
   The screen people actually live on. Slightly larger targets, a mark that
   carries its own colour as a soft wash rather than a solid block, and a
   lift on hover so the whole card reads as one clickable thing. */
.tile-grid { grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 1rem; }

.tile {
    border-radius: var(--radius);
    padding: 1.05rem 1.1rem .9rem;
    box-shadow: var(--shadow);
    transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.tile-mark {
    width: 40px; height: 40px; flex-basis: 40px;
    border-radius: 10px;
    font-size: 14px;
    box-shadow: var(--shadow);
}
.tile-title a { font-size: 15px; letter-spacing: -0.011em; }
.tile-title small { color: var(--muted); }

.tile-link {
    padding: .26rem .58rem;
    background: var(--surface-2);
    border-color: transparent;
    font-weight: 550;
}
.tile-link:hover { background: var(--surface-3); border-color: var(--border-strong); }
.tile-link.is-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.tile-link.is-primary:hover { background: var(--brand-dark); color: #fff; }

/* --- Tables ----------------------------------------------------------------
   Zebra striping removed in favour of a hover row: on a table people scan
   rather than read across, the pointer is the thing that needs to be
   obvious, not every other line. */
.table thead th {
    background: var(--surface-2);
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
}
.table tbody tr { transition: background .1s ease; }
.table tbody tr:hover { background: var(--surface-2); }
.table td, .table th { padding: .62rem .8rem; }

/* --- Forms -----------------------------------------------------------------
   A field should say where it is before it says what is wrong with it. */
.field input, .field select, .field textarea,
.filters input, .filters select {
    border-radius: var(--radius-sm);
    padding: .5rem .65rem;
    transition: border-color .12s ease, box-shadow .12s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
    outline: none;
}
.field > span, .field legend { font-size: 12.5px; font-weight: 550; color: var(--text); }

/* --- Badges ----------------------------------------------------------------
   Tinted rather than filled: at this size a solid badge is a blot. */
.badge {
    border-radius: 999px;
    padding: .12rem .5rem;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
}

/* --- Alerts ----------------------------------------------------------------
   A left rule instead of a full tint, so a page carrying three of them is
   still a page rather than a traffic light. */
.alert {
    border-radius: var(--radius-sm);
    border-left-width: 3px;
    padding: .7rem .85rem;
    box-shadow: var(--shadow);
}

/* --- Empty states ----------------------------------------------------------
   The screen somebody sees first, on their first day. Worth more than a
   centred sentence in grey. */
.empty {
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface);
    padding: 2.6rem 1.5rem;
}
.empty h3 { font-size: 16px; margin-bottom: .4rem; }
.empty p { color: var(--muted); max-width: 34rem; margin-inline: auto; }

/* --- Sign-in ---------------------------------------------------------------
   One card on a plain field. The only screen a stranger sees. */
.card-centered {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}
.login-brand h1 { font-size: 20px; }
.brand-mark-lg { border-radius: 13px; box-shadow: var(--shadow-md); }

/* --- Lock bar --------------------------------------------------------------
   Status, not decoration: it should read at a glance from across a desk. */
.lockbar { border-radius: var(--radius); box-shadow: var(--shadow); padding: .65rem .9rem; }
.lockbar.is-open { border-left: 3px solid var(--ok); }
.lockbar.is-locked { border-left: 3px solid var(--border-strong); }

/* --- Row actions -----------------------------------------------------------
   Kept on one line. Wrapping them stacked three buttons per row and turned a
   scannable table into a column of tall blocks — the actions are secondary,
   and secondary things should not set the height of the row. */
.row-actions { flex-wrap: nowrap; gap: .3rem; }
.row-actions .mini { white-space: nowrap; }

/* --- Section headings ------------------------------------------------------ */
.section-title { font-size: 11px; letter-spacing: .06em; color: var(--faint); margin: 1.5rem 0 .6rem; }
.section-title:first-child { margin-top: 0; }

/* --- Motion ----------------------------------------------------------------
   Everything above animates. Somebody who has asked their machine not to
   should get none of it. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
    }
    .btn:hover, .tile:hover { transform: none; }
}

/* ==========================================================================
   Themes
   --------------------------------------------------------------------------
   Each theme redefines the same tokens and nothing else. No component knows
   which one is on, which is why adding a seventh is a block of colours here
   and no change anywhere else.

   The default theme follows the device between light and dark; the others
   commit, because somebody choosing "Midnight" has already said what they
   want and having it turn white at 7am would be a bug rather than a courtesy.
   ========================================================================== */

/* --- Midnight --------------------------------------------------------------
   Dark whatever the device says. Indigo on deep navy. */
[data-theme="midnight"] {
    --bg: #080b13;
    --surface: #101625;
    --surface-2: #161d30;
    --surface-3: #1e263c;
    --border: #222c45;
    --border-strong: #35415e;
    --text: #e7eaf6;
    --muted: #98a2c0;
    --faint: #6b7597;
    --brand: #7c8cff;
    --brand-dark: #99a5ff;
    --brand-soft: #1a2145;
    --ok: #3fd39c;         --ok-soft: #0d2a20;
    --warn: #f0b166;       --warn-soft: #2c2113;
    --danger: #ff8b84;     --danger-soft: #2e1719;
    --shadow: 0 1px 2px rgba(0,0,0,.5);
    --shadow-md: 0 2px 10px rgba(0,0,0,.55);
    --shadow-lg: 0 10px 34px rgba(0,0,0,.6);
    color-scheme: dark;
}

/* --- Slate -----------------------------------------------------------------
   Almost no colour. The content is the only thing with any. */
[data-theme="slate"] {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --surface-3: #e6ebf1;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --muted: #64748b;
    --faint: #94a3b8;
    --brand: #475569;
    --brand-dark: #334155;
    --brand-soft: #eef2f6;
    --ok: #15803d;         --ok-soft: #edf7ef;
    --warn: #a16207;       --warn-soft: #fdf6e7;
    --danger: #b91c1c;     --danger-soft: #fdeeee;
    color-scheme: light;
}
[data-theme="slate"] .tile-mark,
[data-theme="slate"] .brand-mark { border-radius: 8px; }

/* --- Emerald ---------------------------------------------------------------
   Green on warm neutrals. Calm rather than corporate. */
[data-theme="emerald"] {
    --bg: #f6f8f6;
    --surface: #ffffff;
    --surface-2: #eef3ef;
    --surface-3: #e2eae4;
    --border: #dfe7e1;
    --border-strong: #c3d1c8;
    --text: #12211b;
    --muted: #5c6f65;
    --faint: #8a9d92;
    --brand: #047857;
    --brand-dark: #036049;
    --brand-soft: #e6f4ee;
    --ok: #047857;         --ok-soft: #e6f4ee;
    --warn: #a45c12;       --warn-soft: #fbf1e6;
    --danger: #a92c22;     --danger-soft: #fbecea;
    color-scheme: light;
}

/* --- Sand ------------------------------------------------------------------
   Paper and ink with an amber accent. Reads as a document, not an app. */
[data-theme="sand"] {
    --bg: #faf7f2;
    --surface: #ffffff;
    --surface-2: #f4efe6;
    --surface-3: #ebe4d7;
    --border: #e8e1d4;
    --border-strong: #d3c8b4;
    --text: #241d15;
    --muted: #6f6152;
    --faint: #9c8d7c;
    --brand: #b45309;
    --brand-dark: #92400e;
    --brand-soft: #fbf0e0;
    --ok: #4d7c0f;         --ok-soft: #f2f7e8;
    --warn: #b45309;       --warn-soft: #fbf0e0;
    --danger: #b42318;     --danger-soft: #fcece9;
    color-scheme: light;
}
[data-theme="sand"] { --radius: 8px; --radius-sm: 6px; --radius-lg: 10px; }

/* --- High contrast ---------------------------------------------------------
   Not a style. Heavier borders, no tinted surfaces, and colours that keep
   their distance on a bad screen in bad light. */
[data-theme="contrast"] {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #f2f2f2;
    --surface-3: #e6e6e6;
    --border: #767676;
    --border-strong: #000000;
    --text: #000000;
    --muted: #3d3d3d;
    --faint: #565656;
    --brand: #0000ee;
    --brand-dark: #0000b3;
    --brand-soft: #e8e8ff;
    --ok: #006325;         --ok-soft: #e6f2ea;
    --warn: #8a4b00;       --warn-soft: #fbf0e3;
    --danger: #b00000;     --danger-soft: #fceaea;
    --shadow: none; --shadow-md: none; --shadow-lg: none;
    color-scheme: light;
}
[data-theme="contrast"] .panel,
[data-theme="contrast"] .tile,
[data-theme="contrast"] .card-centered { border-width: 2px; }
[data-theme="contrast"] .btn { border-width: 2px; font-weight: 650; }
[data-theme="contrast"] .tile:hover,
[data-theme="contrast"] .btn:hover { transform: none; outline: 2px solid var(--text); }

/* --- The brand colour, when one is set ------------------------------------
   Applied as an inline custom property on <html>, so it overrides whichever
   theme is on without either knowing about the other. */
[style*="--brand-set"] { --brand: var(--brand-set); }

/* --- The mark --------------------------------------------------------------
   Text or an uploaded image, sized from the settings screen. */
.brand-mark img,
.tile-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
.brand-mark:has(img) { background: transparent !important; box-shadow: none; }
.tile-mark:has(img) { background: var(--surface-2) !important; padding: 5px; }

/* The drawn marks. One stroke width in grid units rather than pixels, so the
   22px square in a list and the 54px one in the gallery look like the same
   hand drew them. */
.tile-mark .mark-glyph {
    width: 62%; height: 62%;
    fill: none; stroke: currentColor;
    stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}

/* --- What an app is, on hover ----------------------------------------------
   Above the tile rather than inside it: a panel that opens over the tile's own
   buttons is a panel you have to wait out before you can click anything.

   It still floats over the row above, so three things keep it out of the way.
   It answers to the name and the mark rather than the whole tile, so pointing
   at a button never raises it. It waits a moment, so sweeping the pointer
   across the grid does not set off a trail of them. And it does not take the
   pointer, so whatever is underneath stays clickable even while it shows. */
.tile-about {
    position: absolute;
    left: .5rem; right: .5rem; bottom: calc(100% - .35rem);
    /* A tile is narrow enough to wrap this on its own; a full-width row in the
       list layout is not, and a single 1100px line is not a sentence anybody
       reads. */
    max-width: 48ch;
    z-index: 20;
    margin: 0;
    padding: .55rem .7rem;
    /* The surface colour painted over the page's own, rather than straight on
       to whatever is behind. The glass theme's surfaces are deliberately
       see-through, and a tooltip you can read the tile through is not a
       tooltip. */
    background: linear-gradient(var(--surface), var(--surface)) var(--bg);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 12.5px; line-height: 1.45;
    pointer-events: none;
    opacity: 0; visibility: hidden;
    transform: translateY(4px);
    transition: opacity .14s ease, transform .14s ease, visibility .14s;
}
/* Only where a pointer can actually hover. On a touch screen the tile would
   either flash this on every tap or keep it open over the row below. */
@media (hover: hover) {
    .tile:has(.tile-head:hover) > .tile-about {
        opacity: 1; visibility: visible; transform: translateY(0);
        transition-delay: .35s;
    }
}
/* A keyboard gets it too, on any device, and without the wait: somebody who
   has tabbed to the name has already chosen to look at it. */
.tile:has(.tile-title a:focus-visible) > .tile-about {
    opacity: 1; visibility: visible; transform: translateY(0);
}

/* --- Choosing a theme ------------------------------------------------------
   A list of names would make somebody pick one, save, look, and pick again.
   Three colours from each is enough to choose by. */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr));
    gap: .7rem;
}

.theme-card {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    padding: .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    transition: border-color .12s ease, box-shadow .12s ease, transform .1s ease;
}
.theme-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.theme-card.is-chosen { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.theme-card input { margin-top: .2rem; flex: 0 0 auto; }

.theme-swatch {
    display: flex;
    flex: 0 0 auto;
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid var(--border);
    height: 34px;
}
.theme-swatch span { width: 13px; height: 100%; display: block; }

.theme-meta { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.theme-meta strong { font-size: 13px; }
.theme-meta small { color: var(--muted); font-size: 11.5px; }

input[type="range"] { accent-color: var(--brand); }
input[type="color"] {
    padding: 2px; height: 34px; cursor: pointer;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface);
}

/* ==========================================================================
   Theme personality
   --------------------------------------------------------------------------
   A palette is not a theme. These give each one its own shape language,
   density, type and weight of shadow — so Slate reads as a utility, Sand as a
   document, Midnight as something you would leave open at night, and the
   difference is obvious at a glance rather than on inspection.

   Everything here is a token or a component rule, never a template change.
   ========================================================================== */

/* --- Structural tokens the themes reach for -------------------------------- */
:root {
    --font-heading: var(--font);
    --panel-pad: .9rem;
    --tile-pad: 1.05rem;
    --row-pad: .62rem .8rem;
    --panel-border: 1px solid var(--border);
    --tile-border: 1px solid var(--border);
    --tile-shadow: var(--shadow);
    --tile-lift: -2px;
    --btn-radius: var(--radius-sm);
    --nav-radius: var(--radius-sm);
    --heading-weight: 600;
    --surface-blur: none;
}

h1, h2, h3 { font-family: var(--font-heading); font-weight: var(--heading-weight); }
.panel { border: var(--panel-border); }
.panel-head { padding: var(--panel-pad); }
.tile { padding: var(--tile-pad); border: var(--tile-border); box-shadow: var(--tile-shadow); }
.tile:hover { transform: translateY(var(--tile-lift)); }
.table td, .table th { padding: var(--row-pad); }
.btn, .field input, .field select, .field textarea { border-radius: var(--btn-radius); }
.nav-link { border-radius: var(--nav-radius); }

/* --- Slate · flat utility --------------------------------------------------
   No shadows at all, hairline borders, tighter rows, smaller type. The look
   of a tool somebody uses for six hours rather than admires for one. */
[data-theme="slate"] {
    --radius: 6px; --radius-sm: 5px; --radius-lg: 8px;
    --shadow: none; --shadow-md: none; --shadow-lg: none;
    --tile-shadow: none;
    --tile-lift: 0;
    --tile-pad: .85rem;
    --panel-pad: .7rem .8rem;
    --row-pad: .48rem .7rem;
    --heading-weight: 600;
}
[data-theme="slate"] body { font-size: 13.5px; }
[data-theme="slate"] .tile:hover { border-color: var(--text); }
[data-theme="slate"] .btn:hover { transform: none; }
[data-theme="slate"] .panel { box-shadow: none; }
[data-theme="slate"] .tile-mark,
[data-theme="slate"] .brand-mark { box-shadow: none; }
[data-theme="slate"] .badge { border-radius: 4px; }
[data-theme="slate"] .nav-link.is-active { box-shadow: none; border: 1px solid var(--border); }

/* --- Emerald · soft and open -----------------------------------------------
   Large radii, pill buttons, generous padding, no borders — depth comes only
   from shadow. Reads as calm; costs vertical space, which is the trade. */
[data-theme="emerald"] {
    --radius: 18px; --radius-sm: 12px; --radius-lg: 22px;
    --btn-radius: 999px;
    --nav-radius: 999px;
    --tile-border: 1px solid transparent;
    --tile-shadow: var(--shadow-md);
    --tile-pad: 1.25rem;
    --panel-pad: 1.05rem 1.15rem;
    --row-pad: .72rem .95rem;
    --panel-border: 1px solid transparent;
}
[data-theme="emerald"] .panel { box-shadow: var(--shadow-md); }
[data-theme="emerald"] .tile-mark { border-radius: 14px; }
[data-theme="emerald"] .brand-mark { border-radius: 14px; }
[data-theme="emerald"] .tile-link { border-radius: 999px; }
[data-theme="emerald"] .content { padding: 1.7rem 1.8rem 3rem; }

/* --- Sand · editorial ------------------------------------------------------
   Serif headings, hairline rules instead of cards, wider leading. Reads as a
   document rather than an application — which suits a hub that is mostly
   lists of things with names. */
[data-theme="sand"] {
    --font-heading: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
    --heading-weight: 600;
    --radius: 8px; --radius-sm: 6px; --radius-lg: 10px;
    --tile-shadow: none;
    --tile-border: 1px solid var(--border);
    --tile-lift: 0;
    --tile-pad: 1.1rem;
    --row-pad: .7rem .85rem;
}
[data-theme="sand"] body { line-height: 1.62; }
[data-theme="sand"] .panel { box-shadow: none; }
[data-theme="sand"] .panel-head { background: transparent; border-bottom: 1px solid var(--border-strong); }
[data-theme="sand"] .panel-head h2 { font-size: 15px; letter-spacing: -0.005em; }
[data-theme="sand"] .detail-header h2 { font-size: 26px; }
[data-theme="sand"] .tile:hover { border-color: var(--brand); }
[data-theme="sand"] .table thead th { background: transparent; border-bottom: 1px solid var(--border-strong); }
[data-theme="sand"] .section-title { font-family: var(--font-heading); font-style: italic;
    font-size: 13px; letter-spacing: 0; text-transform: none; color: var(--muted); }

/* --- Midnight · glass ------------------------------------------------------
   Translucent surfaces over a dark ground, a faint glow where the accent
   lands. The blur is behind a support query: without it the surfaces would
   simply be flat, which is fine, rather than transparent, which is not. */
[data-theme="midnight"] {
    --radius: 14px; --radius-sm: 10px; --radius-lg: 18px;
    --tile-pad: 1.15rem;
    --tile-border: 1px solid var(--border);
}
@supports (backdrop-filter: blur(12px)) {
    [data-theme="midnight"] .panel,
    [data-theme="midnight"] .tile,
    [data-theme="midnight"] .card-centered {
        background: color-mix(in srgb, var(--surface) 78%, transparent);
        backdrop-filter: blur(14px) saturate(150%);
    }
    [data-theme="midnight"] .topbar {
        background: color-mix(in srgb, var(--surface) 70%, transparent);
    }
}
[data-theme="midnight"] .tile:hover {
    border-color: color-mix(in srgb, var(--brand) 55%, transparent);
    box-shadow: var(--shadow-lg), 0 0 0 1px color-mix(in srgb, var(--brand) 30%, transparent);
}
[data-theme="midnight"] .btn-primary {
    box-shadow: 0 2px 14px color-mix(in srgb, var(--brand) 35%, transparent);
}
[data-theme="midnight"] .nav-link.is-active {
    background: color-mix(in srgb, var(--brand) 16%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 30%, transparent);
}
[data-theme="midnight"] .brand-mark,
[data-theme="midnight"] .tile-mark {
    box-shadow: 0 2px 12px color-mix(in srgb, var(--brand) 30%, transparent);
}

/* --- High contrast · square and heavy -------------------------------------- */
[data-theme="contrast"] {
    --radius: 0; --radius-sm: 0; --radius-lg: 0;
    --btn-radius: 0; --nav-radius: 0;
    --panel-border: 2px solid var(--border-strong);
    --tile-border: 2px solid var(--border-strong);
    --tile-shadow: none;
    --tile-lift: 0;
    --heading-weight: 700;
}
[data-theme="contrast"] body { font-size: 15px; }
[data-theme="contrast"] .badge { border-radius: 0; border: 1px solid currentColor; }
[data-theme="contrast"] .tile-mark, [data-theme="contrast"] .brand-mark { border-radius: 0; }
[data-theme="contrast"] .nav-link.is-active { border: 2px solid var(--text); }

/* ==========================================================================
   Layouts
   --------------------------------------------------------------------------
   Three arrangements of the page, not three skins. Each is its own template;
   this is only what makes them sit correctly.
   ========================================================================== */

/* --- Top bar ---------------------------------------------------------------
   No sidebar. Navigation in a row, content in a bounded centre column —
   long lines of text stay readable and the page reads like a website
   rather than a console. */
.masthead {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}
.masthead-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: .7rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
}
.masthead-brand { display: flex; align-items: center; gap: .6rem; color: var(--text); }
.masthead-brand:hover { text-decoration: none; }

.masthead-nav {
    display: flex;
    align-items: center;
    gap: .15rem;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}
.masthead-nav::-webkit-scrollbar { display: none; }

.masthead-link {
    padding: .42rem .7rem;
    border-radius: var(--nav-radius);
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 550;
    white-space: nowrap;
}
.masthead-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.masthead-link.is-active { background: var(--brand-soft); color: var(--brand); }

.masthead-side { display: flex; align-items: center; gap: .45rem; flex: 0 0 auto; }
.masthead-side .avatar { width: 30px; height: 30px; flex: 0 0 30px; }

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.6rem 1.5rem 3rem;
}
.page-title { font-size: 24px; margin-bottom: 1.1rem; }
.page-foot {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    color: var(--faint);
    font-size: 12px;
}

/* On a phone the row becomes the only navigation there is, so it keeps its
   place at the top and scrolls sideways rather than collapsing behind a
   button nobody finds. */
@media (max-width: 760px) {
    .masthead-inner { flex-wrap: wrap; padding: .6rem .9rem; }
    .masthead-nav { order: 3; width: 100%; padding-top: .4rem; }
    .page, .page-foot { padding-inline: .9rem; }
}

/* --- Icon rail -------------------------------------------------------------
   Sixty pixels instead of two hundred and fifty. On the matrix screens that
   is a column and a half of extra room, which is the entire point. */
.rail {
    width: 60px;
    flex: 0 0 60px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .2rem;
    padding: .7rem .4rem;
    position: sticky;
    top: 0;
    height: 100vh;
}
.rail-brand { display: block; margin-bottom: .5rem; }

.rail-nav { flex: 1; display: flex; flex-direction: column; gap: .15rem; width: 100%; }
.rail-foot { display: flex; flex-direction: column; gap: .15rem; width: 100%;
             border-top: 1px solid var(--border); padding-top: .5rem; }

.rail-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--muted);
    border-radius: var(--nav-radius);
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}
.rail-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.rail-link.is-active { background: var(--brand-soft); color: var(--brand); }
.rail-link svg { width: 18px; height: 18px; fill: none; stroke: currentColor;
                 stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rail-link .avatar { width: 26px; height: 26px; flex: 0 0 26px; }

/* The label is present for a screen reader and for the tooltip; it only
   takes space once the rail widens. */
.rail-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* Narrow windows have no hover, so a tooltip is no help — widen it and show
   the words. */
@media (max-width: 900px) and (min-width: 641px) {
    .rail { width: 190px; flex-basis: 190px; align-items: stretch; }
    .rail-link { justify-content: flex-start; gap: .6rem; padding: 0 .7rem; min-width: 0; }
    /* Truncated for the same reason as the sidebar chip: this label is a
       person's name once it reaches the account row, and names are as long as
       they like. */
    .rail-label { position: static; width: auto; height: auto; clip-path: none;
                  font-size: 13.5px; font-weight: 550;
                  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* --- Anything the sidebar owned that the other two do not ----------------- */
.layout-topbar .content, .layout-rail .sidebar { display: revert; }
.layout-topbar .shell { display: block; }


/* ==========================================================================
   Light and dark
   --------------------------------------------------------------------------
   The theme is the organisation's decision; light or dark is the reader's.
   They are separate attributes on <html> for that reason — an administrator
   picking Sand should not also be deciding whether somebody working at
   eleven at night gets a white screen.

   Three states, not two. 'system' is the default and follows the device,
   because most people never open a setting and the one they already gave
   their operating system is the best guess available.

   Two themes do not take part. Midnight is dark by definition — a light
   Midnight is just Epsilon with worse contrast — and High contrast specifies
   black on white as an accessibility claim, not a preference. Appearance.php
   knows this and hides the toggle for both.

   Each palette below appears twice: once for "I chose dark", once for "I
   chose nothing and the device says dark". CSS has no way to share one
   declaration block between a plain selector and a media query, so the two
   are kept identical by hand. Change one, change the other.
   ========================================================================== */


/* --- the default theme, dark ---------------------------------------------------- */
:root[data-theme="epsilon"][data-appearance="dark"] {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1c2230;
    --surface-3: #232a38;
    --border: #262d3a;
    --border-strong: #39414f;
    --text: #e6edf3;
    --muted: #9aa5b1;
    --faint: #6e7681;
    --brand: #6b9bff;
    --brand-dark: #8fb4ff;
    --brand-soft: #172144;
    --ok: #3fbf92;         --ok-soft: #11291f;
    --warn: #e0a35a;       --warn-soft: #2a2013;
    --danger: #ff8580;     --danger-soft: #2c1616;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 2px 8px rgba(0,0,0,.45);
    --shadow-lg: 0 8px 28px rgba(0,0,0,.55);
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root[data-theme="epsilon"][data-appearance="system"] {
        --bg: #0d1117;
        --surface: #161b22;
        --surface-2: #1c2230;
        --surface-3: #232a38;
        --border: #262d3a;
        --border-strong: #39414f;
        --text: #e6edf3;
        --muted: #9aa5b1;
        --faint: #6e7681;
        --brand: #6b9bff;
        --brand-dark: #8fb4ff;
        --brand-soft: #172144;
        --ok: #3fbf92;         --ok-soft: #11291f;
        --warn: #e0a35a;       --warn-soft: #2a2013;
        --danger: #ff8580;     --danger-soft: #2c1616;
        --shadow: 0 1px 2px rgba(0,0,0,.4);
        --shadow-md: 0 2px 8px rgba(0,0,0,.45);
        --shadow-lg: 0 8px 28px rgba(0,0,0,.55);
        color-scheme: dark;
    }
}

/* --- Slate, dark ---------------------------------------------------- */
:root[data-theme="slate"][data-appearance="dark"] {
    --bg: #0f1318;
    --surface: #161b22;
    --surface-2: #1b2029;
    --surface-3: #222833;
    --border: #252b35;
    --border-strong: #3a4250;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --faint: #64748b;
    --brand: #9fb2c8;
    --brand-dark: #c2d1e2;
    --brand-soft: #1d242e;
    --ok: #4ade80;         --ok-soft: #13251a;
    --warn: #eab308;       --warn-soft: #262013;
    --danger: #f87171;     --danger-soft: #2a1717;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root[data-appearance="system"][data-theme="slate"] {
        --bg: #0f1318;
        --surface: #161b22;
        --surface-2: #1b2029;
        --surface-3: #222833;
        --border: #252b35;
        --border-strong: #3a4250;
        --text: #e2e8f0;
        --muted: #94a3b8;
        --faint: #64748b;
        --brand: #9fb2c8;
        --brand-dark: #c2d1e2;
        --brand-soft: #1d242e;
        --ok: #4ade80;         --ok-soft: #13251a;
        --warn: #eab308;       --warn-soft: #262013;
        --danger: #f87171;     --danger-soft: #2a1717;
        color-scheme: dark;
    }
}

/* --- Emerald, dark ---------------------------------------------------- */
:root[data-theme="emerald"][data-appearance="dark"] {
    --bg: #0b1210;
    --surface: #111a17;
    --surface-2: #16211d;
    --surface-3: #1d2b25;
    --border: #1f2d28;
    --border-strong: #32463e;
    --text: #e4efe9;
    --muted: #94aca2;
    --faint: #6b8279;
    --brand: #34d399;
    --brand-dark: #6ee7b7;
    --brand-soft: #0f2a21;
    --ok: #34d399;         --ok-soft: #0f2a21;
    --warn: #fbbf24;       --warn-soft: #2a2313;
    --danger: #fb7185;     --danger-soft: #2c1619;
    --shadow: 0 1px 2px rgba(0,0,0,.45);
    --shadow-md: 0 4px 14px rgba(0,0,0,.5);
    --shadow-lg: 0 12px 36px rgba(0,0,0,.6);
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root[data-appearance="system"][data-theme="emerald"] {
        --bg: #0b1210;
        --surface: #111a17;
        --surface-2: #16211d;
        --surface-3: #1d2b25;
        --border: #1f2d28;
        --border-strong: #32463e;
        --text: #e4efe9;
        --muted: #94aca2;
        --faint: #6b8279;
        --brand: #34d399;
        --brand-dark: #6ee7b7;
        --brand-soft: #0f2a21;
        --ok: #34d399;         --ok-soft: #0f2a21;
        --warn: #fbbf24;       --warn-soft: #2a2313;
        --danger: #fb7185;     --danger-soft: #2c1619;
        --shadow: 0 1px 2px rgba(0,0,0,.45);
        --shadow-md: 0 4px 14px rgba(0,0,0,.5);
        --shadow-lg: 0 12px 36px rgba(0,0,0,.6);
        color-scheme: dark;
    }
}

/* --- Sand, dark ---------------------------------------------------- */
:root[data-theme="sand"][data-appearance="dark"] {
    --bg: #14100c;
    --surface: #1b1611;
    --surface-2: #221c16;
    --surface-3: #2b241c;
    --border: #2c251d;
    --border-strong: #463b2e;
    --text: #f0e7db;
    --muted: #b3a493;
    --faint: #8a7c6c;
    --brand: #f0a441;
    --brand-dark: #f7bf72;
    --brand-soft: #2e2214;
    --ok: #86c06c;         --ok-soft: #1c2617;
    --warn: #e3b341;       --warn-soft: #2a2313;
    --danger: #ef7d72;     --danger-soft: #2e1a17;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root[data-appearance="system"][data-theme="sand"] {
        --bg: #14100c;
        --surface: #1b1611;
        --surface-2: #221c16;
        --surface-3: #2b241c;
        --border: #2c251d;
        --border-strong: #463b2e;
        --text: #f0e7db;
        --muted: #b3a493;
        --faint: #8a7c6c;
        --brand: #f0a441;
        --brand-dark: #f7bf72;
        --brand-soft: #2e2214;
        --ok: #86c06c;         --ok-soft: #1c2617;
        --warn: #e3b341;       --warn-soft: #2a2313;
        --danger: #ef7d72;     --danger-soft: #2e1a17;
        color-scheme: dark;
    }
}

/* ==========================================================================
   The landing page
   --------------------------------------------------------------------------
   The hero, the search row, the category headings and the tiles themselves.
   Everything here is drawn from tokens, so all six themes get it without a
   single theme-specific rule below.
   ========================================================================== */

/* --- Hero ------------------------------------------------------------------
   One band that says where you are. The illustration is inline SVG painted
   with var(--brand) rather than an image file, because an image would be
   right in one palette and wrong in the other five. */
.hero {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 2rem 2.2rem;
    margin-bottom: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background:
        radial-gradient(120% 140% at 100% 0%, var(--brand-soft) 0%, transparent 60%),
        linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    overflow: hidden;
}

.hero-text { flex: 1 1 auto; min-width: 0; }

.hero-text h1 {
    margin: 0 0 .4rem;
    font-size: clamp(24px, 3.4vw, 34px);
    line-height: 1.15;
    letter-spacing: -0.022em;
}

.hero-text p {
    margin: 0;
    color: var(--muted);
    font-size: 15px;
    max-width: 46ch;
}

.hero-art {
    flex: 0 0 auto;
    width: 240px;
    max-width: 40%;
}
.hero-art svg { display: block; width: 100%; height: auto; }
.hero-stack { transform-origin: center; }

/* --- The vault line --------------------------------------------------------
   Its own card rather than a strip, because "your passwords are locked" is
   the one sentence on this page somebody needs to read before the tiles make
   sense. */
.lockbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .9rem 1.1rem;
    margin-bottom: 1.2rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.lockbar.is-open { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); background: var(--ok-soft); }

.lock-badge {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--muted);
}
.lockbar.is-open .lock-badge { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.lock-badge svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.lock-text { display: flex; flex-direction: column; gap: .1rem; margin-right: auto; min-width: 0; }
.lock-text strong { font-size: 14px; }
.lock-text small { color: var(--muted); font-size: 12.5px; }

/* --- Count, search, add ----------------------------------------------------
   The search is a real field with the icon inside it rather than beside it;
   at a glance that is the difference between a page that was designed and a
   page that was assembled. */
.toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.4rem;
}
.toolbar-count { margin: 0; color: var(--muted); font-size: 13.5px; }
.toolbar-count strong { color: var(--text); font-weight: 650; }
.toolbar-tools { display: flex; align-items: center; gap: .6rem; margin-left: auto; }

.search { position: relative; display: flex; align-items: center; }
.search svg {
    position: absolute; left: .8rem;
    width: 16px; height: 16px;
    fill: none; stroke: var(--faint); stroke-width: 1.9;
    stroke-linecap: round; pointer-events: none;
}
.search input[type="search"] {
    width: 260px; max-width: 100%;
    padding: .55rem .9rem .55rem 2.3rem;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font: inherit; font-size: 13.5px;
}
.search input[type="search"]:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

/* --- Category headings -----------------------------------------------------
   The icon is looked up from the category name and falls back to a folder,
   so an administrator inventing a seventh category still gets something
   deliberate rather than a gap. */
.section-title {
    display: flex;
    align-items: center;
    gap: .55rem;
    margin: 2rem 0 .9rem;
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--muted);
}
.section-title svg {
    width: 15px; height: 15px;
    fill: none; stroke: currentColor; stroke-width: 1.7;
    stroke-linecap: round; stroke-linejoin: round;
}
.section-count {
    display: inline-grid; place-items: center;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--faint);
    font-size: 10.5px; letter-spacing: 0;
}

/* --- The dot menu ----------------------------------------------------------
   Everything that is not the one obvious action. <details> rather than a
   scripted popover: it opens without JavaScript, closes on Escape by itself,
   and app.js only has to close the others when one opens. */
.tile-menu { position: relative; margin-left: auto; flex: 0 0 auto; }
.tile-menu > summary {
    display: grid; place-items: center;
    width: 28px; height: 28px;
    border-radius: var(--radius-sm);
    color: var(--faint);
    cursor: pointer;
    list-style: none;
}
.tile-menu > summary::-webkit-details-marker { display: none; }
.tile-menu > summary:hover { background: var(--surface-2); color: var(--text); }
.tile-menu > summary svg { width: 16px; height: 16px; fill: currentColor; }

.tile-menu-list {
    position: absolute; right: 0; top: 32px; z-index: 30;
    min-width: 190px;
    display: flex; flex-direction: column;
    padding: .3rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}
.tile-menu-list a {
    padding: .45rem .6rem;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
}
.tile-menu-list a:hover { background: var(--surface-2); }

/* --- Tile details ----------------------------------------------------------
   The little arrow on an outbound link is not decoration: these open in a new
   tab, and saying so before the click is cheaper than explaining afterwards. */
.i-out {
    width: 12px; height: 12px;
    margin-left: .35rem;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
    opacity: .65;
}

.tile-add {
    display: flex; align-items: center; gap: .3rem;
    width: 100%;
    color: var(--muted);
    font-size: 12.5px;
    text-decoration: none;
}
.tile-add svg {
    width: 14px; height: 14px; margin-left: auto;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}
.tile-add:hover { color: var(--brand); }

.tile-env { flex: 0 0 auto; align-self: flex-start; }

/* --- "Something missing?" --------------------------------------------------
   The last thing on the page, for the person who read the whole thing and did
   not find what they came for. */
.cta {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    margin-top: 2.4rem;
    padding: 1.3rem 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border-strong);
    background: var(--surface-2);
}
.cta-icon {
    display: grid; place-items: center;
    flex: 0 0 auto;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
}
.cta-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cta-text { min-width: 0; margin-right: auto; }
.cta-text strong { display: block; font-size: 14.5px; }
.cta-text p { margin: .15rem 0 0; color: var(--muted); font-size: 13px; }
.cta-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.cta-quiet { border-style: solid; }

/* ==========================================================================
   Tile arrangements
   --------------------------------------------------------------------------
   Four shapes, one set of markup. The template does not know which is on —
   it writes the same article every time and this reads the attribute on the
   container. That is the whole reason a fifth arrangement would be a block
   of CSS rather than a fifth copy of the tile.
   ========================================================================== */

/* --- Cards: the default. Room for the description and both sign-in buttons. */
[data-tiles="cards"] .tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr));
    gap: 1rem;
}

/* --- Compact: same tile, less of it. For a dozen or so apps. */
[data-tiles="compact"] .tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(215px, 100%), 1fr));
    gap: .7rem;
}
[data-tiles="compact"] .tile { padding: .85rem; gap: .55rem; }
[data-tiles="compact"] .tile-mark { width: 32px; height: 32px; font-size: 15px; }
[data-tiles="compact"] .tile-title a { font-size: 13.5px; }
/* One line of description, cut with an ellipsis rather than wrapped: the
   point of this arrangement is that every tile is the same height. */
[data-tiles="compact"] .tile-title small {
    display: -webkit-box; -webkit-line-clamp: 1; line-clamp: 1;
    -webkit-box-orient: vertical; overflow: hidden;
}
[data-tiles="compact"] .tile-link { font-size: 12px; padding: .3rem .55rem; }
[data-tiles="compact"] .tile-foot { font-size: 12px; }

/* --- List: one app per row. Scans fastest when there are many. */
[data-tiles="list"] .tile-grid { display: flex; flex-direction: column; gap: 0; }
[data-tiles="list"] .tile {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0 1rem;
    padding: .7rem .9rem;
    border-radius: 0;
    border-width: 0 0 1px;
    box-shadow: none;
}
[data-tiles="list"] .tile:first-child { border-top: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
[data-tiles="list"] .tile:last-child  { border-radius: 0 0 var(--radius) var(--radius); }
[data-tiles="list"] .tile:hover { transform: none; background: var(--surface-2); }
[data-tiles="list"] .tile-head { display: contents; }
[data-tiles="list"] .tile-mark { width: 30px; height: 30px; font-size: 14px; }
[data-tiles="list"] .tile-title small { display: none; }
[data-tiles="list"] .tile-env { grid-row: 1; }
[data-tiles="list"] .tile-links { grid-column: 3; grid-row: 1; margin: 0; }
[data-tiles="list"] .tile-menu { grid-column: 4; grid-row: 1; }
/* The stored password moves under the row rather than beside it — there is
   no horizontal room left once the name and the buttons have had theirs. */
[data-tiles="list"] .tile-foot { grid-column: 2 / -1; padding-top: .4rem; border: 0; }
[data-tiles="list"] .tile-foot:empty { display: none; }

/* --- Gallery: recognition by sight. Logo first, name underneath. */
[data-tiles="gallery"] .tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr));
    gap: .9rem;
}
[data-tiles="gallery"] .tile { align-items: center; text-align: center; padding: 1.2rem .8rem; }
[data-tiles="gallery"] .tile-head { flex-direction: column; align-items: center; gap: .6rem; width: 100%; }
[data-tiles="gallery"] .tile-mark { width: 54px; height: 54px; font-size: 24px; border-radius: var(--radius-lg); }
[data-tiles="gallery"] .tile-title { text-align: center; }
[data-tiles="gallery"] .tile-title small { display: none; }
[data-tiles="gallery"] .tile-links { justify-content: center; }
[data-tiles="gallery"] .tile-foot { justify-content: center; }
[data-tiles="gallery"] .tile-add svg { display: none; }
/* The dot menu would sit on top of the logo in a centred column, so it goes
   to the corner where there is nothing else. */
[data-tiles="gallery"] .tile { position: relative; }
[data-tiles="gallery"] .tile-menu { position: absolute; top: .4rem; right: .4rem; margin: 0; }

/* ==========================================================================
   Light/dark toggle, dialogs, and the footer
   ========================================================================== */

.appearance { display: inline-flex; }
.appearance-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
/* One button, two icons, and the one drawn is the destination: a moon means
   pressing this makes it dark. Driven by data-next on the button rather than
   by the appearance on <html>, because a switch should show where it goes and
   a status light shows where it is — this is a switch. */
.appearance-btn .i-sun,
.appearance-btn .i-moon { display: none; }
.appearance-btn[data-next="light"] .i-sun  { display: block; }
.appearance-btn[data-next="dark"]  .i-moon { display: block; }

.report-btn svg {
    width: 17px; height: 17px;
    fill: none; stroke: currentColor; stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round;
}
.report-btn:hover { color: var(--warn); border-color: var(--warn); }

.dialog {
    width: min(540px, calc(100vw - 2rem));
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(8, 11, 19, .55); backdrop-filter: blur(2px); }
.dialog-form { display: flex; flex-direction: column; gap: .9rem; padding: 1.2rem 1.3rem 1.3rem; }
.dialog-head { display: flex; align-items: center; gap: 1rem; }
.dialog-head h2 { margin: 0; font-size: 16px; }
.dialog-head .icon-btn { margin-left: auto; }
.dialog-form textarea {
    width: 100%;
    padding: .6rem .7rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg);
    color: var(--text);
    font: inherit; font-size: 13.5px;
    resize: vertical;
}
.dialog-form textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.dialog-foot { display: flex; justify-content: flex-end; gap: .5rem; }

.site-foot {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1.1rem 1.8rem 1.6rem;
    border-top: 1px solid var(--border);
    color: var(--faint);
    font-size: 12.5px;
}
.site-foot-mark { display: inline-flex; align-items: center; gap: .4rem; }
.site-foot-mark svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.site-foot-meta { display: inline-flex; align-items: center; gap: .5rem; margin-left: auto; flex-wrap: wrap; }

.env-tag {
    padding: .1rem .45rem;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.env-staging { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.env-production { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }

/* A button that has to read as a link, because it sits in a run of text. */
.linkish {
    padding: 0; border: 0; background: none;
    color: inherit; font: inherit;
    text-decoration: underline; text-underline-offset: 2px;
    cursor: pointer;
}
.linkish:hover { color: var(--brand); }

.centered-corner { position: fixed; top: 1rem; right: 1rem; z-index: 10; }

/* Present for a screen reader, absent for everyone else. Used for the page
   title when the hero has already said it out loud. */
.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%);
    white-space: nowrap; border: 0;
}

/* ==========================================================================
   Phones
   --------------------------------------------------------------------------
   Everything above assumes a window. This section assumes a hand.

   The rules are the same three every time: nothing may sit side by side that
   needs more than half a small screen, nothing tappable may be smaller than
   about forty-four pixels, and nothing may push the page wider than the
   viewport — a hub you have to scroll sideways to read is a hub people open
   on a laptop instead, which defeats the point of it being a hub.
   ========================================================================== */

@media (max-width: 640px) {
    /* --- The page itself --- */
    body { font-size: 15px; }
    .content { padding: .9rem .9rem 2rem; }
    .page { padding-inline: .9rem; }
    .env-ribbon { font-size: 10.5px; padding: .3rem .6rem; }

    /* --- Hero: the illustration is the first thing to go. It is decoration,
           and decoration does not get a third of a phone screen. --- */
    .hero { flex-direction: column; align-items: flex-start; gap: 1rem; padding: 1.4rem 1.2rem; }
    .hero-art { display: none; }
    .hero-text p { font-size: 14px; }

    /* --- Vault line: the button drops under the words rather than squeezing
           them into two characters a line. --- */
    .lockbar { flex-wrap: wrap; }
    .lockbar .btn { width: 100%; }

    /* --- Search takes the full width; the count sits above it. --- */
    .toolbar { flex-direction: column; align-items: stretch; gap: .7rem; }
    .toolbar-tools { margin-left: 0; flex-direction: column; align-items: stretch; }
    .search input[type="search"] { width: 100%; }
    .toolbar .btn { justify-content: center; }

    /* --- Tiles: one column, whatever arrangement was chosen. Four across is
           a desktop decision and a phone does not have to honour it. --- */
    [data-tiles] .tile-grid { grid-template-columns: minmax(0, 1fr) !important; }
    [data-tiles="gallery"] .tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    [data-tiles="list"] .tile { grid-template-columns: auto 1fr auto; }
    [data-tiles="list"] .tile-links { grid-column: 1 / -1; grid-row: 2; margin-top: .4rem; }
    .tile-links { flex-wrap: wrap; }
    .tile-link { min-height: 36px; display: inline-flex; align-items: center; }

    /* The dot menu opens against the right edge on a phone; anchoring it to
       the summary would hang it off the screen. */
    .tile-menu-list { right: -.3rem; min-width: 210px; }
    .tile-menu > summary { width: 36px; height: 36px; }

    /* --- The call to action stacks. --- */
    .cta { flex-direction: column; align-items: flex-start; gap: .8rem; }
    .cta-actions { width: 100%; }
    .cta-actions .btn { flex: 1 1 auto; justify-content: center; }

    /* --- Footer --- */
    .site-foot { padding: 1rem .9rem 1.4rem; gap: .5rem; }
    .site-foot-meta { margin-left: 0; }

    /* --- The icon rail becomes a drawer, like the sidebar, rather than
           eating half the width. --- */
    .rail {
        position: fixed; z-index: 40; left: 0; top: 0;
        width: 210px; flex-basis: 210px;
        align-items: stretch;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: var(--shadow-lg);
    }
    .rail.is-open { transform: translateX(0); }
    .rail-link { justify-content: flex-start; gap: .6rem; padding: 0 .7rem; height: 44px; min-width: 0; }
    .rail-label { position: static; width: auto; height: auto; clip-path: none; font-size: 14px; font-weight: 550;
                  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .layout-rail .icon-btn { display: block; }

    /* --- Top-bar layout: the links scroll sideways in their own strip rather
           than wrapping into four rows of one. --- */
    .masthead-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: .2rem;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .masthead-nav::-webkit-scrollbar { display: none; }
    .masthead-link { white-space: nowrap; }
    .masthead-side { gap: .3rem; }
    /* "Sign out" is a word and an avatar too many at this width — the account
       page it links to has the button. */
    .masthead-side form:last-child { display: none; }

    /* --- Tables: the estate's matrices are wider than any phone. They keep
           their shape and scroll inside their own box, which is honest;
           collapsing a matrix into cards loses the comparison that is the
           only reason to draw a matrix. --- */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table { min-width: 560px; }

    /* --- Forms and dialogs --- */
    .form-layout { grid-template-columns: minmax(0, 1fr); }
    .form-actions { flex-direction: column-reverse; gap: .5rem; }
    .form-actions .btn { width: 100%; justify-content: center; }
    .dialog { width: calc(100vw - 1.4rem); }
    .dialog-foot { flex-direction: column-reverse; }
    .dialog-foot .btn { width: 100%; justify-content: center; }

    /* --- Anything tappable clears the forty-four pixel floor. --- */
    .btn { min-height: 40px; }
    .icon-btn { min-width: 40px; min-height: 40px; }

    /* Nothing may push the page wider than the phone. */
    .panel, .tile, .hero, .cta { max-width: 100%; }
    pre, code { overflow-x: auto; word-break: break-word; }
}

/* Very small phones — a 320px iPhone SE still has to work. */
@media (max-width: 380px) {
    [data-tiles="gallery"] .tile-grid { grid-template-columns: minmax(0, 1fr) !important; }
    .hero-text h1 { font-size: 22px; }
    .toolbar-count { font-size: 12.5px; }
}

/* --- Definition list used on the reported-issues screen ---------------------
   Label on the left, value on the right, wrapping to stacked rows on a phone
   because a 90px label column and a user agent string do not share 320px. */
.meta-list {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: .3rem .8rem;
    margin: 0;
    font-size: 13px;
}
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 640px) {
    .meta-list { grid-template-columns: minmax(0, 1fr); gap: .1rem; }
    .meta-list dd { margin-bottom: .4rem; }
}

/* --- A count beside a navigation link --------------------------------------
   Only "Reported issues" has one so far. It is a number rather than a dot
   because "there are things waiting" and "there are eleven things waiting"
   lead to different afternoons. */
.nav-count {
    display: inline-grid; place-items: center;
    min-width: 18px; height: 18px; padding: 0 5px;
    margin-left: auto;
    border-radius: 999px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 10.5px; font-weight: 650;
}
.masthead-link .nav-count { margin-left: .35rem; }

/* The rail has no room for a number, so it gets the fact and the tooltip
   carries the count. */
.rail-dot {
    position: absolute; top: 7px; right: 12px;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--danger);
}
.rail-link { position: relative; }
@media (max-width: 900px) { .rail-dot { right: 10px; } }

/* The prompt to store a password wraps to two lines in the tighter
   arrangements, which makes an even grid ragged. One line, cut with an
   ellipsis — the whole sentence is on the page it links to. */
[data-tiles="compact"] .tile-add,
[data-tiles="gallery"] .tile-add { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* An icon inside a button had never happened before, so nothing sized one.
   Left alone an SVG with a viewBox stretches to whatever the flex line gives
   it, which on a phone is the entire button with the label shoved to the end. */
.btn svg {
    width: 15px; height: 15px;
    flex: 0 0 auto;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }

/* The vault line keeps its badge beside its words on a phone; the button gets
   the row underneath. Wrapping put the icon on a line of its own, which read
   as a mistake rather than a layout. */
@media (max-width: 640px) {
    .lockbar { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .75rem 1rem; }
    .lockbar .btn { grid-column: 1 / -1; }
}

/* A URL has no spaces, so it has a minimum width equal to its whole length —
   which on an app's detail page is enough to push a 320px phone sideways.
   Letting it break anywhere costs nothing: nobody reads a hostname for its
   line breaks, and the alternative is scrolling the page to read the rest. */
.mono, .site-foot, dd { overflow-wrap: anywhere; }
.panel, .panel-head, .stack { min-width: 0; }

@media (max-width: 640px) {
    /* The row of actions in a panel header stops fighting for one line. */
    .push-right { flex-wrap: wrap; }
}

/* Eleven navigation items and a row of controls do not fit a laptop once
   "Reported issues" joins them — the flex line was shrinking the links until
   "Publish" read "Put". The links keep their width and the strip scrolls
   instead, which is honest about there being more of them. */
.masthead-nav { min-width: 0; overflow-x: auto; scrollbar-width: none; }
.masthead-nav::-webkit-scrollbar { display: none; }
.masthead-link { flex: 0 0 auto; white-space: nowrap; }
.masthead-side { flex: 0 0 auto; }

/* --- Profile pictures -------------------------------------------------------
   The circle was initials-only until people could upload one. An img inside
   it has to fill the circle and be cropped by it, not letterboxed into it —
   object-fit: cover rather than contain, because a face off-centre in a band
   of white is worse than a face with its ears trimmed. */
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.avatar:has(img) { background: transparent; }

.avatar-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
/* Name, job title and email beside the circle rather than under it. */
.person-cell { display: flex; align-items: flex-start; gap: .65rem; }
.person-cell > span { min-width: 0; }

/* ==========================================================================
   The command palette
   --------------------------------------------------------------------------
   Anchored near the top rather than centred: the list grows downwards, and a
   box that stays still while its contents change is far easier to aim at than
   one that recentres itself on every keystroke.
   ========================================================================== */

.palette {
    width: min(560px, calc(100vw - 2rem));
    max-height: 70vh;
    margin: 12vh auto auto;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.palette::backdrop { background: rgba(8, 11, 19, .5); backdrop-filter: blur(3px); }
.palette-box { display: flex; flex-direction: column; max-height: 70vh; }

.palette-field {
    display: flex; align-items: center; gap: .6rem;
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--border);
}
.palette-field svg {
    width: 17px; height: 17px; flex: 0 0 17px;
    fill: none; stroke: var(--faint); stroke-width: 1.9; stroke-linecap: round;
}
.palette-field input {
    flex: 1; min-width: 0;
    border: 0; background: none; color: var(--text);
    font: inherit; font-size: 15px;
}
/* The field is the dialog's whole purpose, so the box gets the focus ring
   rather than the input drawing a second one inside it. */
.palette-field input:focus { outline: none; }

.palette-results { list-style: none; margin: 0; padding: .3rem; overflow-y: auto; }
.palette-row {
    display: flex; align-items: center; gap: .7rem;
    padding: .5rem .6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
/* Highlighted by arrow keys as well as the mouse, so it cannot be :hover. */
.palette-row.is-at { background: var(--brand-soft); }

.palette-mark {
    display: grid; place-items: center;
    width: 26px; height: 26px; flex: 0 0 26px;
    border-radius: 7px;
    color: #fff; font-size: 11px; font-weight: 700;
}
.palette-mark.is-page { background: var(--surface-2); color: var(--muted); }

.palette-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 550;
                overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-hint { color: var(--faint); font-size: 11.5px; white-space: nowrap; }

.palette-empty { margin: 0; padding: 1.4rem 1rem; text-align: center; color: var(--muted); font-size: 13px; }

.palette-foot {
    display: flex; gap: 1rem;
    padding: .55rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--faint); font-size: 11.5px;
}
.palette-foot span { display: inline-flex; align-items: center; gap: .3rem; }

kbd {
    display: inline-block;
    min-width: 18px; padding: .1rem .3rem;
    border: 1px solid var(--border-strong); border-bottom-width: 2px;
    border-radius: 5px;
    background: var(--surface);
    color: var(--muted);
    font: inherit; font-size: 10.5px; font-family: var(--mono); text-align: center;
}

/* The shortcut badge inside the search field. */
.search-key { padding: 0; border: 0; background: none; cursor: pointer; line-height: 1; }
.search-key kbd { pointer-events: none; }
.search { padding-right: .35rem; }
.search:has(.search-key) input[type="search"] { padding-right: 3.2rem; }
.search-key { position: absolute; right: .55rem; top: 50%; transform: translateY(-50%); }

@media (max-width: 640px) {
    .palette { margin-top: 6vh; max-height: 80vh; }
    .palette-box { max-height: 80vh; }
    /* No physical keyboard to advertise a shortcut to. */
    .palette-foot, .search-key { display: none; }
    .search:has(.search-key) input[type="search"] { padding-right: .9rem; }
}

/* ==========================================================================
   Focus, visibly
   --------------------------------------------------------------------------
   WCAG 2.2 asks that the focused state differ from the unfocused one by at
   least 3:1. A ring in the brand colour clears that on every palette here
   except one — High contrast, where the accent IS the text colour, so it gets
   the text colour and a thicker ring below.

   :focus-visible rather than :focus, so a mouse click does not leave a ring
   behind on a button somebody has already finished with, while every keyboard
   arrival is unmistakable.
   ========================================================================== */

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* The palette's box takes the ring on behalf of its input. */
.palette:focus-within { outline: 2px solid var(--brand); outline-offset: -1px; }

[data-theme="contrast"] :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--text);
    outline-offset: 2px;
}

/* Skipping the navigation is the first thing a keyboard user wants and the
   last thing anybody remembers to build. Off-screen until focused. */
.skip-link {
    position: absolute; left: .5rem; top: -3rem; z-index: 60;
    padding: .5rem .9rem;
    border-radius: var(--radius-sm);
    background: var(--brand); color: #fff;
    font-size: 13px; font-weight: 600;
    transition: top .15s ease;
}
.skip-link:focus { top: .5rem; text-decoration: none; }

/* ==========================================================================
   Liquid Glass
   --------------------------------------------------------------------------
   Apple's design language from 2025, taken as far as a browser honestly can.

   What it is made of, per Apple's own description and the implementations that
   followed: a translucent fill, a heavy backdrop blur with the saturation
   pushed up, and a three-part shadow — a lit inset along the top edge, a
   hairline rim, and a soft drop beneath. Panels float rather than sitting
   against the edges of the window. Corners are large and concentric.

   Two decisions worth writing down.

   First, no SVG filter. Real refraction needs feTurbulence and
   feSpecularLighting fed into backdrop-filter, and only Chrome supports an SVG
   filter there. On anything else that route degrades to plain glass — so this
   uses the plain-glass technique everywhere instead of a trick that looks
   right for some of the people some of the time.

   Second, glass needs something behind it. On a flat background it is
   invisible: the whole effect is refracting what it sits over. So the page
   itself carries a soft field of colour, and every surface is a layer above
   it. That is why this theme sets a background image where the others set a
   colour.
   ========================================================================== */

[data-theme="vision"] {
    --bg: #eef1f8;
    --surface: rgba(255, 255, 255, .62);
    --surface-2: rgba(255, 255, 255, .44);
    --surface-3: rgba(255, 255, 255, .74);
    --border: rgba(255, 255, 255, .55);
    --border-strong: rgba(120, 130, 160, .32);
    --text: #10131c;
    --muted: #545c70;
    --faint: #7d8598;
    --brand: #0a84ff;
    --brand-dark: #0060df;
    --brand-soft: rgba(10, 132, 255, .14);
    --ok: #14804a;        --ok-soft: rgba(20, 128, 74, .13);
    --warn: #9a6700;      --warn-soft: rgba(154, 103, 0, .13);
    --danger: #c4314b;    --danger-soft: rgba(196, 49, 75, .13);

    /* Bigger and concentric — the outer radius of a card, the inner radius of
       what sits inside it, kept in proportion. */
    --radius: 18px;
    --radius-sm: 12px;
    --radius-lg: 26px;
    --nav-radius: 12px;

    /* The three parts: lit top edge, hairline rim, soft drop. */
    --glass-lip: inset 0 1px 0 rgba(255, 255, 255, .75);
    --glass-rim: 0 0 0 .5px rgba(255, 255, 255, .5);
    --shadow: var(--glass-lip), var(--glass-rim), 0 2px 10px rgba(16, 22, 44, .07);
    --shadow-md: var(--glass-lip), var(--glass-rim), 0 8px 26px rgba(16, 22, 44, .11);
    --shadow-lg: var(--glass-lip), var(--glass-rim), 0 22px 60px rgba(16, 22, 44, .18);

    color-scheme: light;
}

:root[data-theme="vision"][data-appearance="dark"] {
    --bg: #070a14;
    --surface: rgba(30, 38, 60, .58);
    --surface-2: rgba(30, 38, 60, .40);
    --surface-3: rgba(44, 54, 82, .66);
    --border: rgba(255, 255, 255, .12);
    --border-strong: rgba(255, 255, 255, .22);
    --text: #f2f5ff;
    --muted: #a8b2ca;
    --faint: #7b86a1;
    --brand: #4aa8ff;
    --brand-dark: #7cc2ff;
    --brand-soft: rgba(74, 168, 255, .18);
    --ok: #46d6a0;        --ok-soft: rgba(70, 214, 160, .15);
    --warn: #f0b45e;      --warn-soft: rgba(240, 180, 94, .15);
    --danger: #ff8a90;    --danger-soft: rgba(255, 138, 144, .15);

    --glass-lip: inset 0 1px 0 rgba(255, 255, 255, .16);
    --glass-rim: 0 0 0 .5px rgba(255, 255, 255, .10);
    --shadow: var(--glass-lip), var(--glass-rim), 0 2px 12px rgba(0, 0, 0, .45);
    --shadow-md: var(--glass-lip), var(--glass-rim), 0 10px 30px rgba(0, 0, 0, .5);
    --shadow-lg: var(--glass-lip), var(--glass-rim), 0 24px 64px rgba(0, 0, 0, .6);

    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root[data-theme="vision"][data-appearance="system"] {
        --bg: #070a14;
        --surface: rgba(30, 38, 60, .58);
        --surface-2: rgba(30, 38, 60, .40);
        --surface-3: rgba(44, 54, 82, .66);
        --border: rgba(255, 255, 255, .12);
        --border-strong: rgba(255, 255, 255, .22);
        --text: #f2f5ff;
        --muted: #a8b2ca;
        --faint: #7b86a1;
        --brand: #4aa8ff;
        --brand-dark: #7cc2ff;
        --brand-soft: rgba(74, 168, 255, .18);
        --ok: #46d6a0;        --ok-soft: rgba(70, 214, 160, .15);
        --warn: #f0b45e;      --warn-soft: rgba(240, 180, 94, .15);
        --danger: #ff8a90;    --danger-soft: rgba(255, 138, 144, .15);
        --glass-lip: inset 0 1px 0 rgba(255, 255, 255, .16);
        --glass-rim: 0 0 0 .5px rgba(255, 255, 255, .10);
        --shadow: var(--glass-lip), var(--glass-rim), 0 2px 12px rgba(0, 0, 0, .45);
        --shadow-md: var(--glass-lip), var(--glass-rim), 0 10px 30px rgba(0, 0, 0, .5);
        --shadow-lg: var(--glass-lip), var(--glass-rim), 0 24px 64px rgba(0, 0, 0, .6);
        color-scheme: dark;
    }
}

/* --- The field the glass sits over -----------------------------------------
   Three soft colour blooms on a plain ground. Fixed, so scrolling moves the
   content across the light rather than dragging the light with it — which is
   what makes the panels read as glass over a scene rather than as tinted
   boxes. */
[data-theme="vision"] body {
    background-color: #e3e9f7;
    /* Strong on purpose. Tuned in the browser: at half these values the
       panels read as flat white cards, because there was nothing behind them
       worth refracting. Glass is only visible when something is. */
    background-image:
        radial-gradient(52% 42% at 8% 0%,   rgba(10, 132, 255, .55), transparent 60%),
        radial-gradient(44% 38% at 96% 4%,  rgba(175, 82, 222, .48), transparent 58%),
        radial-gradient(60% 50% at 50% 104%, rgba(48, 209, 190, .40), transparent 62%),
        radial-gradient(40% 34% at 78% 62%, rgba(255, 159, 10, .22), transparent 60%);
    background-attachment: fixed;
}

:root[data-theme="vision"][data-appearance="dark"] body,
[data-theme="vision"] body { background-repeat: no-repeat; }

:root[data-theme="vision"][data-appearance="dark"] body {
    background-color: #070a14;
    background-image:
        radial-gradient(52% 42% at 8% 0%,   rgba(10, 132, 255, .55), transparent 60%),
        radial-gradient(44% 38% at 96% 4%,  rgba(175, 82, 222, .48), transparent 58%),
        radial-gradient(60% 50% at 50% 104%, rgba(48, 209, 190, .34), transparent 62%),
        radial-gradient(40% 34% at 78% 62%, rgba(255, 159, 10, .18), transparent 60%);
}
@media (prefers-color-scheme: dark) {
    :root[data-theme="vision"][data-appearance="system"] body {
        background-image:
            radial-gradient(52% 42% at 8% 0%,   rgba(10, 132, 255, .55), transparent 60%),
            radial-gradient(44% 38% at 96% 4%,  rgba(175, 82, 222, .48), transparent 58%),
            radial-gradient(60% 50% at 50% 104%, rgba(48, 209, 190, .34), transparent 62%),
            radial-gradient(40% 34% at 78% 62%, rgba(255, 159, 10, .18), transparent 60%);
    }
}

/* --- The glass itself ------------------------------------------------------
   One rule for every surface. -webkit- included because Safari is the browser
   whose users will most expect this to look right. */
[data-theme="vision"] :is(.panel, .tile, .hero, .lockbar, .cta, .card-centered,
                          .masthead, .sidebar, .rail, .palette, .dialog,
                          .tile-menu-list, .table-wrap) {
    background: var(--surface);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    backdrop-filter: blur(22px) saturate(180%);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}

/* Floating rather than pinned to the edges — Apple moved toolbars off the
   bezel into their own bubble, and that separation is most of what makes the
   language read as glass rather than as frosted chrome. */
[data-theme="vision"] .masthead {
    position: sticky;
    top: .7rem;
    z-index: 30;
    /* calc rather than a fixed inset, so this cannot exceed the viewport on a
       narrow screen the way the sidebar rule did. */
    width: min(1200px, calc(100% - 1.4rem));
    margin: .7rem auto 0;
    border-radius: var(--radius-lg);
}
[data-theme="vision"] .masthead-inner { padding: .55rem .9rem; }

/* Wide screens only, and the media query is the whole point.
   [data-theme="vision"] .sidebar is more specific than the .sidebar rule that
   turns the sidebar into a drawer below 860px, and a media query adds no
   specificity of its own — so without this bound, the theme quietly cancelled
   the drawer and left a 248px sidebar in the flow of a 320px screen, pushing
   the header off the right edge. Every floating-panel rule below has to be
   scoped the same way for the same reason. */
@media (min-width: 861px) {
    [data-theme="vision"] .sidebar {
        margin: .7rem 0 .7rem .7rem;
        height: calc(100vh - 1.4rem);
        border-radius: var(--radius-lg);
        position: sticky;
        top: .7rem;
    }
}
[data-theme="vision"] .topbar { background: transparent; border: 0; }
[data-theme="vision"] .site-foot { border: 0; }

/* The specular sheen: a bright band across the top of each panel, brightest at
   the upper-left where the light is coming from. */
[data-theme="vision"] :is(.panel, .tile, .hero, .cta, .card-centered, .palette)::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 42%;
    border-radius: inherit;
    background: linear-gradient(160deg, rgba(255, 255, 255, .30), rgba(255, 255, 255, 0) 70%);
    pointer-events: none;
}
[data-theme="vision"] :is(.panel, .tile, .hero, .cta, .card-centered, .palette) { position: relative; }
:root[data-theme="vision"][data-appearance="dark"] :is(.panel, .tile, .hero, .cta, .card-centered, .palette)::before {
    background: linear-gradient(160deg, rgba(255, 255, 255, .10), rgba(255, 255, 255, 0) 70%);
}

/* Capsules, the way Apple's controls are shaped. */
[data-theme="vision"] .btn { border-radius: 999px; padding-inline: 1.05rem; font-weight: 590; }
[data-theme="vision"] .btn-primary {
    background-image: linear-gradient(180deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0));
    box-shadow: var(--glass-lip), 0 4px 14px rgba(10, 132, 255, .35);
}
[data-theme="vision"] .btn-ghost {
    background: var(--surface-2);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    backdrop-filter: blur(14px) saturate(160%);
}
[data-theme="vision"] .tile-link { border-radius: 999px; }
[data-theme="vision"] .search input[type="search"] { background: var(--surface-2); border-color: var(--border); }
[data-theme="vision"] .badge { border-radius: 999px; }

/* Concentric: the mark inside a card echoes the card's own corner rather than
   using an unrelated one. */
[data-theme="vision"] .tile-mark   { border-radius: 13px; }
[data-theme="vision"] .brand-mark  { border-radius: 13px; }
[data-theme="vision"] .avatar      { border-radius: 50%; }

[data-theme="vision"] .nav-link.is-active,
[data-theme="vision"] .masthead-link.is-active {
    background: var(--surface-3);
    box-shadow: var(--glass-lip), var(--glass-rim);
}

/* Glass lifts towards you rather than growing a darker shadow. */
[data-theme="vision"] .tile { transition: transform .18s ease, box-shadow .18s ease; }
[data-theme="vision"] .tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

/* --- When somebody has asked for less of this -----------------------------
   Translucency is genuinely difficult for some people to read, and both Apple
   and the platforms expose a setting for it. Honour it the same way the
   reduced-motion block above does: keep the shapes and the palette, drop the
   blur and make every surface opaque. */
@media (prefers-reduced-transparency: reduce) {
    [data-theme="vision"] :is(.panel, .tile, .hero, .lockbar, .cta, .card-centered,
                              .masthead, .sidebar, .rail, .palette, .dialog,
                              .tile-menu-list, .table-wrap) {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
    [data-theme="vision"] { --surface: #ffffff; --surface-2: #f2f4fa; --surface-3: #ffffff; }
    :root[data-theme="vision"][data-appearance="dark"] { --surface: #141a2a; --surface-2: #1b2233; --surface-3: #232c42; }
    [data-theme="vision"] body { background-image: none; }
    [data-theme="vision"] :is(.panel, .tile, .hero, .cta, .card-centered, .palette)::before { display: none; }
}

/* --- "Use one login on all your apps" --------------------------------------
   A <details> rather than a permanent panel: it is a thing somebody does once
   when they arrive and then rarely again, so it should be reachable without
   taking a screen's worth of room from the passwords themselves. */
.same-login > summary {
    display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap;
    padding: .75rem .9rem;
    cursor: pointer;
    list-style: none;
}
.same-login > summary::-webkit-details-marker { display: none; }
.same-login > summary::before {
    content: "+";
    display: inline-grid; place-items: center;
    width: 20px; height: 20px; flex: 0 0 20px;
    border-radius: 50%;
    background: var(--brand-soft); color: var(--brand);
    font-weight: 700; font-size: 13px; line-height: 1;
}
.same-login[open] > summary::before { content: "−"; }
.same-login > summary:hover { background: var(--surface-2); }
.same-login[open] > summary { border-bottom: 1px solid var(--border); }
.same-login { margin-bottom: 1rem; }

/* Words worth having on a laptop and not worth 21px of overflow on a phone. */
@media (max-width: 640px) {
    .at-wide { display: none; }
    /* And the header row gives up before the page does. */
    .topbar-actions { flex-wrap: wrap; justify-content: flex-end; row-gap: .35rem; }
}
