:root {
    color-scheme: light dark;
    --bg: #f3f5fa; --card: #ffffff; --text: #171a21; --muted: #65707f; --line: #e1e5ee;
    --accent: #4f6df5; --accent-2: #8a5cf6; --accent-text: #fff; --danger: #d23f3f; --ok: #25965a;
    --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 8px 24px rgba(20, 30, 60, .07);
    --glow-1: rgba(79, 109, 245, .18); --glow-2: rgba(138, 92, 246, .16);
}
/* data-theme is set from the hub_theme cookie before the page draws: system follows the device, light/dark force it. */
:root[data-theme=light] { color-scheme: light; }
:root[data-theme=dark] { color-scheme: dark; }
:root[data-theme=dark] {
    --bg: #0e1015; --card: #171a21; --text: #eceef3; --muted: #8e98a8; --line: #272c36;
    --accent: #7088ff; --accent-2: #a37bff; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
    --glow-1: rgba(112, 136, 255, .16); --glow-2: rgba(163, 123, 255, .14); --ok: #4cc585;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme=light]) {
        --bg: #0e1015; --card: #171a21; --text: #eceef3; --muted: #8e98a8; --line: #272c36;
        --accent: #7088ff; --accent-2: #a37bff; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
        --glow-1: rgba(112, 136, 255, .16); --glow-2: rgba(163, 123, 255, .14); --ok: #4cc585;
    }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
    margin: 0; min-height: 100vh; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--text);
    background: radial-gradient(60rem 30rem at 10% -10%, var(--glow-1), transparent 60%),
                radial-gradient(50rem 28rem at 100% 0%, var(--glow-2), transparent 60%), var(--bg);
    background-attachment: fixed;
}
a { color: var(--accent); }

header {
    position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: .9rem; padding: .7rem clamp(1rem, 4vw, 2rem);
    background: color-mix(in srgb, var(--card) 80%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
header h1 { font-size: 1.05rem; margin: 0; flex: 1; font-weight: 650; display: flex; align-items: baseline; gap: .55rem; min-width: 0; }
header a.brand { color: var(--text); font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
header a.brand:hover { text-decoration: none; color: var(--accent); }
header .crumb { color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header .crumb:empty { display: none; }
header .crumb::before { content: "/"; margin-right: .55rem; opacity: .5; }
header a { text-decoration: none; font-weight: 500; }
header a:hover { text-decoration: underline; }
.user-chip { display: inline-flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .92rem; text-decoration: none; }
header a.user-chip:hover { text-decoration: none; color: var(--text); }
.avatar {
    display: inline-grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 50%; font-weight: 650; font-size: .85rem;
    background: color-mix(in srgb, var(--accent) 18%, var(--card)); color: var(--accent); overflow: hidden; flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.has-picture { background: var(--line); }
.avatar.generated { color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .25); letter-spacing: .02em; }
.avatar.has-picture { color: inherit; text-shadow: none; }
dialog.crop-dialog { width: min(24rem, calc(100vw - 2rem)); }
.crop-help { margin-top: 0; font-size: .9rem; }
.crop-stage { width: min(20rem, 100%); aspect-ratio: 1; margin: .5rem auto 0; border-radius: 12px; overflow: hidden; background:
    repeating-conic-gradient(var(--line) 0 25%, transparent 0 50%) 0 0 / 16px 16px; }
#cropCanvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#cropCanvas:active { cursor: grabbing; }
#cropCanvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.crop-zoom { display: flex; align-items: center; gap: .6rem; width: min(20rem, 100%); margin: .9rem auto 0; color: var(--muted); font-weight: 600; }
.crop-zoom input { flex: 1; accent-color: var(--accent); }
.avatar-large { width: 4.5rem; height: 4.5rem; font-size: 1.8rem; }
.picture-row { display: flex; align-items: center; gap: 1.1rem; margin-top: .9rem; }
.picture-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.menu-wrap { position: relative; }
button.icon-only { display: inline-grid; place-items: center; padding: .4rem; border-color: transparent; background: transparent; color: var(--muted); }
button.icon-only:hover:not(:disabled) { color: var(--text); border-color: var(--line); }
button.icon-only svg { width: 1.25rem; height: 1.25rem; display: block; }
button.icon-only[aria-expanded=true] { color: var(--text); border-color: var(--line); background: var(--card); }
.menu {
    position: absolute; right: 0; top: calc(100% + .45rem); min-width: 12.5rem; padding: .35rem; z-index: 20;
    display: grid; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
    animation: menu-in .12s ease-out;
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } }
.menu a, .menu button { display: block; width: 100%; text-align: left; padding: .55rem .75rem; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; font-weight: 500; text-decoration: none; }
.menu a:hover, .menu button:hover:not(:disabled), .menu a:focus-visible, .menu button:focus-visible { background: color-mix(in srgb, var(--accent) 10%, transparent); text-decoration: none; outline: none; }
.menu a[aria-current=page] { color: var(--accent); }
header a.user-chip[aria-current=page] .name { color: var(--text); }
.menu button { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: .3rem .2rem; }

main { max-width: 60rem; margin: 0 auto; padding: 2.5rem clamp(1rem, 4vw, 2rem) 4rem; }
.hero { margin-bottom: 2rem; }
.hero h2 { font-size: clamp(1.6rem, 4vw, 2.1rem); line-height: 1.2; margin: 0 0 .35rem; letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 1.4rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card h2 { margin-top: 0; font-size: 1.05rem; }

/* sign-in: one centred column */
.auth-main { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 23rem); justify-content: center; align-content: center; padding: 2rem clamp(1rem, 5vw, 3rem); }
.auth-card { width: 100%; text-align: center; animation: rise .35s ease-out both; }
.auth-card form { text-align: left; }
.auth-card h1 { margin: 0; font-size: 1.75rem; letter-spacing: -.025em; line-height: 1.2; }
.auth-card .sub { margin: .4rem 0 1.6rem; color: var(--muted); overflow-wrap: anywhere; }
.auth-card .sub strong { color: var(--text); font-weight: 600; }
.auth-card form label:first-of-type { margin-top: 0; }
.auth-card .foot { margin-top: 1.75rem; font-size: .85rem; color: var(--muted); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 40rem) { .auth-main { align-content: start; padding-top: clamp(3rem, 14vh, 7rem); } }

.field { position: relative; }
.field input { padding-right: 2.9rem; }
.reveal {
    position: absolute; top: 50%; right: .35rem; transform: translateY(-50%); display: grid; place-items: center;
    width: 2.2rem; height: 2.2rem; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--muted);
}
.reveal:hover:not(:disabled) { color: var(--text); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.reveal:active:not(:disabled) { transform: translateY(-50%); }
.reveal .slash { display: none; }
.reveal[aria-pressed=true] .slash { display: inline; }
.hint { margin: .45rem 0 0; font-size: .85rem; color: var(--muted); }
.alert { margin: .75rem 0 .1rem; font-size: .9rem; color: var(--danger); }
.alert:empty { margin: .4rem 0 0; }
.alert:not(:empty) {
    padding: .55rem .75rem; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
    background: color-mix(in srgb, var(--danger) 9%, var(--card));
}
.shake { animation: shake .3s ease-in-out; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.passkey-btn { display: inline-flex; align-items: center; justify-content: center; gap: .55rem; }
button[aria-busy=true] { cursor: progress; }

label { display: block; margin: .9rem 0 .3rem; font-size: .85rem; font-weight: 550; color: var(--muted); }
input[type=text], input[type=password], input[type=url], input[type=email], input[type=date], input[type=number], input[type=datetime-local], select, textarea {
    width: 100%; min-height: 2.9rem; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text);
    font: inherit; transition: border-color .15s, box-shadow .15s;
}
select {
    appearance: none; -webkit-appearance: none; padding-right: 2.4rem; cursor: pointer;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 1.25rem) 52%, calc(100% - .9rem) 52%; background-size: .36rem .36rem, .36rem .36rem; background-repeat: no-repeat;
}
select option { background: var(--card); color: var(--text); }
textarea { resize: vertical; font-family: ui-monospace, monospace; font-size: .88rem; }
input[type=text]:focus, input[type=password]:focus, input[type=url]:focus, input[type=email]:focus, input[type=date]:focus, input[type=number]:focus, input[type=datetime-local]:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow-1); }
button {
    padding: .55rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text);
    font: inherit; font-weight: 500; cursor: pointer; transition: transform .1s, border-color .15s, background .15s;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:active:not(:disabled) { transform: translateY(1px); }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: var(--accent-text); font-weight: 600; }
button.primary:hover:not(:disabled) { filter: brightness(1.06); border-color: transparent; }
button.primary.danger-primary { background: var(--danger); color: #fff; }
button.danger { color: var(--danger); }
button.danger:hover:not(:disabled) { border-color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wide { width: 100%; margin-top: .5rem; padding: .75rem 1rem; }
.error { color: var(--danger); min-height: 1.5em; margin: .6rem 0 0; font-size: .92rem; }
.error.ok { color: var(--ok); }

/* hub */
.apps { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
.apps a { display: block; text-decoration: none; color: inherit; }
.apps .card { display: flex; gap: 1rem; align-items: flex-start; height: 100%; margin: 0; transition: transform .15s, border-color .15s, box-shadow .15s; }
.apps a:hover .card { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow), 0 12px 30px var(--glow-1); }
.apps .tile {
    flex: none; display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 14px; font-size: 1.5rem;
    background: color-mix(in srgb, var(--accent) 14%, var(--card));
}
.apps h3 { margin: 0 0 .15rem; font-size: 1.05rem; }
.apps .go { margin-left: auto; color: var(--muted); transition: transform .15s, color .15s; }
.apps a:hover .go { transform: translateX(3px); color: var(--accent); }
.muted { color: var(--muted); font-size: .92rem; margin: 0; }
.empty { text-align: center; padding: 2.5rem 1.5rem; }
.empty .big { font-size: 2.2rem; }
.skeleton { height: 5.5rem; border-radius: 16px; background: linear-gradient(90deg, var(--line), transparent, var(--line)); background-size: 200% 100%; animation: shimmer 1.2s infinite; opacity: .6; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* admin */
table { width: 100%; border-collapse: collapse; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
th, td { text-align: left; padding: .75rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button { margin-left: .3rem; padding: .4rem .75rem; font-size: .9rem; }
.checks label { display: inline-flex; align-items: center; gap: .35rem; margin: 0 .85rem 0 0; color: var(--text); font-weight: 400; font-size: .95rem; white-space: nowrap; }
.summary { display: inline-flex; align-items: center; gap: .45rem; max-width: 15rem; min-width: 0; vertical-align: middle; }
.summary .badge { margin-left: 0; flex: none; }
.summary .names { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker { display: grid; gap: .5rem; }
.pick-head { display: flex; align-items: center; gap: .75rem; }
.pick-head .muted { flex: none; font-size: .85rem; }
input.pick-search {
    flex: 1; min-width: 0; min-height: 2.4rem; padding: .45rem .75rem; border: 1px solid var(--line); border-radius: 10px;
    background: var(--bg); color: var(--text); font: inherit; font-size: .95rem;
}
input.pick-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow-1); }
.pick-list {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: .1rem .75rem; max-height: 15rem; overflow-y: auto;
    padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 10px;
}
.pick-list label { display: flex; align-items: center; gap: .45rem; min-width: 0; margin: 0; padding: .3rem .25rem; border-radius: 6px; color: var(--text); font-weight: 400; font-size: .95rem; cursor: pointer; }
.pick-list label:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.pick-list label span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline { display: inline-flex; align-items: center; gap: .5rem; white-space: nowrap; }
.inline button.small { margin-left: 0; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
.row > div { flex: 1 1 12rem; }
.badge {
    display: inline-block; white-space: nowrap; vertical-align: middle; line-height: 1.5; font-size: .7rem; padding: .05rem .5rem; border-radius: 99px;
    background: color-mix(in srgb, var(--accent) 16%, var(--card)); color: var(--accent); margin-left: .45rem; font-weight: 600;
}
.inline .badge, .tags .badge { margin-left: 0; }
.tags { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .3rem .4rem; }
.username { white-space: nowrap; }
main.admin-main { max-width: 72rem; }
.uri { font-size: .9rem; overflow-wrap: break-word; }
.nowrap { white-space: nowrap; }
.health { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .45rem; vertical-align: .05em; background: var(--muted); }
.health.up { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.health.down { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent); }
.apps .card.down .tile { filter: grayscale(1); opacity: .6; }
.apps .card.down h3 .badge { vertical-align: .1em; }
.input-row { display: flex; gap: .5rem; align-items: stretch; flex-wrap: wrap; }
.input-row input { flex: 1 1 14rem; min-width: 0; }
input.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .02em; }
#askText { white-space: pre-line; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.filters select { width: auto; min-height: 2.4rem; padding: .4rem 2.2rem .4rem .7rem; font-size: .95rem; }
.filters input.pick-search { flex: 1 1 14rem; }
#panel-activity td { font-size: .9rem; }
#panel-activity .badge { margin-left: 0; }
/* Accounts have four actions: let them wrap onto two lines rather than push the table out of its card. */
#users td.actions { white-space: normal; min-width: 15rem; }
#users td.actions button { margin: .15rem 0 .15rem .3rem; }
@media (max-width: 40rem) { td:empty { display: none; } }
#panel-activity td.wrap { max-width: 18rem; }
@media (max-width: 40rem) {
    .user-chip span.name { display: none; }
    /* phones: each table row becomes a stacked block, labelled from the table header */
    table thead { display: none; }
    table, tbody, tr, td { display: block; width: 100%; }
    tr { padding: .6rem 0; border-bottom: 1px solid var(--line); }
    tbody tr:last-child { border-bottom: 0; }
    td, tr:last-child td { border: 0; padding: .3rem 0; }
    td.wrap { max-width: none; }
    td[data-label]::before {
        content: attr(data-label); display: block; margin-bottom: .1rem; font-size: .72rem; font-weight: 600;
        text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
    }
    td.actions { display: flex; flex-wrap: wrap; gap: .4rem; text-align: left; white-space: normal; padding-top: .5rem; }
    td.actions button { margin: 0; }
}

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--text); box-shadow: var(--shadow); padding: 1.5rem; width: min(34rem, calc(100vw - 2rem)); }
dialog::backdrop { background: rgba(10, 12, 18, .55); backdrop-filter: blur(3px); }
code { background: color-mix(in srgb, var(--accent) 10%, var(--card)); padding: .05rem .35rem; border-radius: 6px; font-size: .88em; }
input:disabled { opacity: .6; cursor: not-allowed; }

/* passkeys */
.passkey { margin-top: 1rem; }
.or { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.passkey-list { list-style: none; padding: 0; margin: .5rem 0 1rem; }
.passkey-list li { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.passkey-list li:last-child { border-bottom: 0; }
.passkey-list .info { flex: 1; min-width: 0; }
.passkey-list strong { display: block; overflow-wrap: anywhere; }

/* admin tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs button {
    border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted);
    padding: .6rem 1rem; margin-bottom: -1px; font-weight: 550; white-space: nowrap; flex: none;
}
.tabs button:hover:not(:disabled) { color: var(--text); border-color: transparent; border-bottom-color: var(--line); }
.tabs button[aria-selected=true] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .count { font-size: .75rem; color: var(--muted); margin-left: .2rem; }
.tabs .count:empty { display: none; }
.panel-head { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; margin-bottom: .75rem; }
.panel-head .muted { max-width: 40rem; }
.panel-head button { flex: none; }
.dialog-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .5rem; }
button.small { margin-left: .5rem; padding: .3rem .6rem; font-size: .85rem; }
td.wrap { overflow-wrap: anywhere; max-width: 22rem; }
.badge.public { background: color-mix(in srgb, var(--ok) 16%, var(--card)); color: var(--ok); }
#msg { margin: 0 0 .75rem; }
#msg:empty, .card .error:empty { min-height: 0; margin: 0; }
@media (max-width: 40rem) { .panel-head { flex-direction: column; } }

/* two-step verification */
.step-text { display: flex; gap: .6rem; align-items: flex-start; margin: 0 0 .8rem; text-align: left; }
.step-num {
    flex: none; display: grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; font-size: .8rem; font-weight: 700;
    background: color-mix(in srgb, var(--accent) 16%, var(--card)); color: var(--accent);
}
.qr { display: block; margin: 0 auto .75rem; padding: .5rem; background: #fff; border-radius: 12px; border: 1px solid var(--line); }
.manual { margin: 0 0 1.1rem; font-size: .88rem; color: var(--muted); text-align: center; }
.manual summary { cursor: pointer; }
.manual code { display: inline-block; margin-top: .5rem; font-size: .95rem; letter-spacing: .04em; user-select: all; overflow-wrap: anywhere; }
.code-input { font-size: 1.35rem; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
button.linkish { display: block; margin: 1rem auto 0; padding: .25rem .5rem; border: 0; background: none; color: var(--muted); font-size: .88rem; }
button.linkish:hover:not(:disabled) { color: var(--text); text-decoration: underline; }
.recovery-codes {
    display: grid; grid-template-columns: 1fr 1fr; gap: .45rem 1rem; margin: 0 0 1rem; padding: .9rem 1rem .9rem 2.4rem;
    border: 1px solid var(--line); border-radius: 12px; background: var(--card);
    font: 600 1rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-align: left;
}
.recovery-codes li::marker { color: var(--muted); font-weight: 400; font-size: .8em; }
.button-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
#twofa .qr { margin-top: .25rem; }
#twofa .step-text { margin-top: .25rem; }
.badge.warn { background: color-mix(in srgb, #d98a00 18%, var(--card)); color: #b06d00; }
tr.expired td:not(.actions) { color: var(--muted); }
tr.expired td:not(.actions) a { color: inherit; }
tr.expired td .badge.warn { margin-left: .35rem; }
#tfaStatus { margin-bottom: .75rem; }
#tfaMsg:empty { min-height: 0; margin: 0; }

.secret-box { border: 1px solid color-mix(in srgb, var(--ok) 45%, var(--line)); background: color-mix(in srgb, var(--ok) 7%, var(--card)); border-radius: 12px; padding: .9rem 1rem; margin-bottom: 1rem; }
.secret-box p { margin: 0 0 .6rem; }
.secret-box pre { margin: 0; padding: .75rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; font-size: .82rem; user-select: all; }
#theme { display: inline-grid; place-items: center; padding: .4rem; border-color: transparent; background: transparent; color: var(--muted); }
#theme:hover { color: var(--text); border-color: var(--line); }
#theme svg { width: 1.15rem; height: 1.15rem; display: block; }
button.icon-button { padding: .35rem .55rem; min-width: 2.1rem; line-height: 1; }
button.icon-button:disabled { opacity: .35; }
button.icon-button:not(.on) { filter: grayscale(1); }
button.icon-button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
/* Below the tiles, centered: arranging is occasional, the pages come first. */
.arrange-bar { display: flex; gap: .5rem; align-items: center; justify-content: center; flex-wrap: wrap; margin: 1.5rem 0 0; text-align: center; }
.arrange-bar p { margin: 0; flex: 1 0 100%; }
.arrange-bar p:empty { display: none; }
#arrange:not([aria-pressed=true]) { background: transparent; border-color: transparent; color: var(--muted); }
#arrange:not([aria-pressed=true]):hover { color: var(--text); border-color: var(--line); }
.apps.arranging .go { visibility: hidden; }
.apps.arranging { position: relative; }
.arrange-tile { display: flex; flex-direction: column; gap: .5rem; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.arrange-tile .card { flex: 1; border-style: dashed; cursor: grab; }
.arrange-tile.is-hidden .card { opacity: .5; }
.arrange-tile.dragging { position: relative; z-index: 10; pointer-events: none; }
.arrange-tile.dragging .card { cursor: grabbing; border-style: solid; border-color: var(--accent); box-shadow: var(--shadow), 0 18px 40px var(--glow-1); transform: scale(1.03); }
.arrange-tile.dragging .tile-tools { visibility: hidden; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }
.tile-tools .icon-button svg { display: block; margin: auto; }
.tile-tools { display: flex; gap: .4rem; justify-content: flex-end; }
.pin-mark { font-size: .8em; margin-right: .35rem; }
/* My account: a grid of blocks, two columns when there is room. */
main.account-main { max-width: 66rem; padding-top: 1.75rem; }
.account-main .hero { margin-bottom: 1.25rem; }
/* Account page: two columns that fill independently, so a tall card never leaves a gap beside it. */
.account-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.account-column { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.account-column > .card { margin: 0; }
@media (max-width: 52rem) { .account-columns { grid-template-columns: minmax(0, 1fr); } }
.account-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); align-items: start; }
.account-grid > .card { margin: 0; }
.account-grid .card > p.muted:first-of-type, .account-column .card > p.muted:first-of-type { margin-top: 0; }
.account-grid .card > h2 + p.muted, .account-column .card > h2 + p.muted { margin-bottom: .25rem; }
.account-grid form > button.primary, .account-column form > button.primary { margin-top: .9rem; }
.account-grid .row, .account-column .row { gap: 0 .75rem; }

/* Consent for an unregistered app: the site's name stands out, the facts are easy to scan. */
.consent h1 .site { color: var(--accent); overflow-wrap: anywhere; }
.consent-facts { text-align: left; margin: 0 0 1rem; padding-left: 1.2rem; display: grid; gap: .4rem; }
.consent-return { font-size: .85rem; overflow-wrap: anywhere; }
.consent-actions { justify-content: center; }
.consent-actions button { flex: 1 1 10rem; }

/* Hub: shorten a link */
.shorten { margin-top: 2rem; }
.shorten h2 { margin: 0 0 .75rem; font-size: 1.1rem; }
.shorten-form { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; }
.shorten-form input[type=url] { flex: 1 1 18rem; margin: 0; }
.shorten-private { display: flex; align-items: center; gap: .35rem; margin: 0; font-weight: 400; font-size: .9rem; color: var(--muted); white-space: nowrap; }
.short-list li .info { min-width: 0; display: grid; gap: .1rem; }
.short-list li .info > * { display: block; min-width: 0; }
.short-list .short-code { font-weight: 600; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.short-list .short-target { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.short-list li.expired { opacity: .6; }
.shorten-foot { margin: .5rem 0 0; font-size: .85rem; }
/* Admin: a second table in a panel */
.section-head { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.section-head h2 { margin: 0 0 .25rem; font-size: 1.05rem; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
/* API page */
.api-main { max-width: 60rem; margin: 0 auto; padding: 1.5rem clamp(1rem, 4vw, 2rem) 3rem; display: grid; gap: 1.25rem; }
.api-route { border: 1px solid var(--line); border-radius: 12px; margin: .55rem 0; overflow: hidden; }
.api-route > summary { cursor: pointer; list-style: none; padding: .65rem .8rem; }
.api-route > summary::-webkit-details-marker { display: none; }
.api-route > summary::after { content: "▸"; margin-left: auto; color: var(--muted); transition: transform .15s; }
.api-route[open] > summary::after { transform: rotate(90deg); }
.api-route > summary:hover { background: color-mix(in srgb, var(--line) 45%, transparent); }
.api-route[open] > summary { border-bottom: 1px solid var(--line); }
.api-summary { color: var(--text); font-size: .92rem; }
.lock-note { font-size: .8rem; }
.api-body { padding: .2rem .9rem .9rem; display: grid; gap: .5rem; }
.api-body > p { margin: .5rem 0 0; }
.api-body h3 { margin: .7rem 0 0; font-size: .9rem; display: flex; align-items: center; gap: .3rem; }
.api-body h3 .muted { font-weight: 400; font-size: .8rem; }
.api-body h3 button.small { margin-left: auto; }
.api-fields { width: 100%; border-collapse: collapse; font-size: .88rem; }
.api-fields th { text-align: left; font-weight: 600; font-size: .78rem; color: var(--muted); padding: .3rem .5rem .3rem 0; border-bottom: 1px solid var(--line); }
.api-fields td { padding: .4rem .5rem .4rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.api-fields td:first-child { white-space: nowrap; }
.api-fields .required { color: var(--danger); font-weight: 700; }
.api-response { display: grid; gap: .35rem; }
.api-response-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; font-size: .9rem; }
.status { font: 700 .78rem/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; padding: .3rem .45rem; border-radius: 6px; }
.status.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.status.err { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.status-text { font-size: .8rem; min-width: 5.5rem; }
.small-note { font-size: .8rem; margin: 0; }
.api-toolbar { display: flex; justify-content: flex-end; margin-top: .75rem; }
.api-common { margin-top: .9rem; }
.api-common > summary { cursor: pointer; font-weight: 600; padding: .3rem 0; }
.api-common .api-response { margin-top: .6rem; }
#keyForm > button.primary { margin-top: .9rem; }
.api-route .head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.api-route code.path { font-weight: 600; overflow-wrap: anywhere; }
.method { font: 700 .72rem/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; padding: .3rem .45rem; border-radius: 6px; background: var(--line); letter-spacing: .03em; }
.method.get { color: #1a7f37; } .method.post { color: #0969da; } .method.patch { color: #9a6700; } .method.delete { color: #cf222e; }
:root[data-theme=dark] .method.get { color: #56d364; } :root[data-theme=dark] .method.post { color: #79c0ff; } :root[data-theme=dark] .method.patch { color: #e3b341; } :root[data-theme=dark] .method.delete { color: #ff7b72; }
@media (prefers-color-scheme: dark) { :root[data-theme=system] .method.get { color: #56d364; } :root[data-theme=system] .method.post { color: #79c0ff; } :root[data-theme=system] .method.patch { color: #e3b341; } :root[data-theme=system] .method.delete { color: #ff7b72; } }
.api-route.locked > summary { opacity: .6; }
.api-route .badge { margin-left: 0; }
pre.example { margin: 0; padding: .6rem .75rem; border-radius: 10px; background: var(--line); overflow-x: auto; font-size: .8rem; line-height: 1.45; }
.token-box { display: grid; gap: .5rem; padding: .9rem; border-radius: 12px; border: 1px solid var(--accent); margin-top: .75rem; }
.short-line { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.short-line .badge { margin-left: 0; }
.short-actions { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: flex-end; }
.links-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.links-head h2 { margin: 0; }
.links-head input[type=search] { flex: 0 1 14rem; margin: 0; }
.links-grid { grid-template-columns: minmax(0, 24rem) minmax(0, 1fr); }
@media (max-width: 52rem) { .links-grid { grid-template-columns: minmax(0, 1fr); } }
#shortenForm .token-box { margin-top: 1rem; }
.links-count { font-size: .85rem; font-weight: 500; }
.short-list li { flex-wrap: wrap; }
.short-list li .info { flex: 1 1 16rem; }
.links-grid .checks { row-gap: .35rem; }
#editTarget { margin: 0 0 .75rem; }
#authExample { margin-top: .6rem; }

/* Status page */
main.status-main { max-width: 52rem; }
.status-banner {
    display: flex; align-items: center; gap: .2rem; padding: .9rem 1.1rem; margin-bottom: 1rem; border-radius: 14px; font-weight: 600;
    border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow);
}
.status-banner.up { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); background: color-mix(in srgb, var(--ok) 9%, var(--card)); }
.status-banner.down { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); background: color-mix(in srgb, var(--danger) 9%, var(--card)); }
.status-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.status-head .tile {
    flex: none; display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 12px; font-size: 1.2rem;
    background: color-mix(in srgb, var(--accent) 14%, var(--card));
}
.status-card.down .status-head .tile { filter: grayscale(1); opacity: .6; }
.status-name { font-weight: 600; font-size: 1.05rem; color: var(--text); text-decoration: none; }
.status-name:hover { text-decoration: underline; }
.status-pill { margin-left: auto; display: inline-flex; align-items: center; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.status-pill.up { color: var(--ok); }
.status-pill.down { color: var(--danger); font-weight: 600; }
.status-bars { display: flex; gap: 2px; height: 2.1rem; align-items: stretch; }
.status-bars .bar { flex: 1 1 0; min-width: 2px; border-radius: 2px; background: var(--line); transition: transform .1s; }
.status-bars .bar:hover { transform: scaleY(1.12); }
.status-bars .bar.good { background: var(--ok); }
.status-bars .bar.minor { background: #c9b52c; }
.status-bars .bar.major { background: #e08a1e; }
.status-bars .bar.bad { background: var(--danger); }
.status-axis { display: flex; justify-content: space-between; font-size: .75rem; margin-top: .35rem; }
.status-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin: 1.1rem 0 0; }
.status-stats > div { padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 10px; }
.status-stats dt { font-size: .78rem; }
.status-stats dd { margin: .1rem 0 0; font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.status-outages h3 { font-size: .9rem; margin: 1.1rem 0 .4rem; }
.status-outages ul { list-style: none; margin: 0; padding: 0; }
.status-outages li { display: flex; align-items: center; flex-wrap: wrap; gap: .1rem .6rem; padding: .4rem 0; border-top: 1px solid var(--line); font-size: .9rem; }
.status-outages li .health { margin-right: 0; }
.status-foot { margin-top: .5rem; font-size: .8rem; }
@media (max-width: 34rem) {
    .status-pill { margin-left: 0; width: 100%; }
    .status-bars { gap: 1px; height: 1.8rem; }
    .status-stats dd { font-size: 1rem; }
}

/* Maintenance (admin panel, hub tiles, status page) */
:root { --maint: #3d7fe0; }
:root[data-theme=dark] { --maint: #6ea4ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme=light]) { --maint: #6ea4ff; } }
.badge.maint { background: color-mix(in srgb, var(--maint) 16%, var(--card)); color: var(--maint); }
.apps .card.maint .tile { filter: saturate(.4); opacity: .75; }
.health.maint { background: var(--maint); box-shadow: 0 0 0 3px color-mix(in srgb, var(--maint) 20%, transparent); }
.status-pill.maint { color: var(--maint); font-weight: 600; }
.status-banner.maint { border-color: color-mix(in srgb, var(--maint) 40%, var(--line)); background: color-mix(in srgb, var(--maint) 9%, var(--card)); }
.status-bars .bar.maint { background: var(--maint); }
.status-outages .health.planned { background: transparent; box-shadow: inset 0 0 0 2px var(--maint); }
.status-outages li .health.down-past { background: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.status-outages li .health.maint-past { background: color-mix(in srgb, var(--maint) 55%, var(--line)); }
.status-outages li.down > span:nth-child(2) { color: var(--danger); font-weight: 600; }
.status-outages li.maint > span:nth-child(2) { color: var(--maint); font-weight: 600; }
.status-note { flex-basis: 100%; padding-left: 1.05rem; font-size: .85rem; color: var(--text); opacity: .85; overflow-wrap: anywhere; }
.link-button { border: 0; background: none; padding: .4rem 0; color: var(--accent); font-size: .85rem; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.maint-list { list-style: none; margin: 0 0 .5rem; padding: 0; }
.maint-list li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; margin-bottom: .4rem; font-size: .9rem; }
.maint-list li.current { border-color: color-mix(in srgb, var(--maint) 45%, var(--line)); background: color-mix(in srgb, var(--maint) 7%, var(--card)); }
.maint-list li .badge { margin-left: 0; }
.maint-list li button { flex: none; padding: .35rem .7rem; font-size: .85rem; }
.maint-sub { font-size: .95rem; margin: 1rem 0 .25rem; }

/* Mail (the Mail page and the admin Mail tab). */
.mail-ui .card > h2 { margin: 0 0 .3rem; }
.mail-ui .card > .muted { margin: 0 0 1.1rem; max-width: 46rem; }
.mail-ui h3 { margin: 1.6rem 0 .6rem; font-size: .95rem; }
.sub-head { margin: 1.4rem 0 .55rem; font-size: .75rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: 1rem 1.1rem; align-items: end; }
.form-grid label { margin: 0 0 .35rem; }
.form-grid > div { min-width: 0; }
.form-grid .wide-field { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin-top: 1.2rem; }
.form-actions .error { margin: 0; min-height: 0; flex: 1 1 14rem; }
.addon { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.addon:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow-1); }
.addon input[type=text] { flex: 1; min-width: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.addon input[type=text]:focus { box-shadow: none; }
.addon > span { display: flex; align-items: center; padding: 0 .9rem; border-left: 1px solid var(--line); color: var(--muted); white-space: nowrap; background: color-mix(in srgb, var(--line) 35%, transparent); }
.item-list { list-style: none; margin: 0 0 1.4rem; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.item-list li { display: flex; align-items: center; gap: 1rem; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.item-list li:last-child { border-bottom: 0; }
.item-list .info { flex: 1; min-width: 0; display: grid; gap: .1rem; }
.item-list .info strong { overflow-wrap: anywhere; font-weight: 600; }
.item-list .none { color: var(--muted); justify-content: center; padding: 1.1rem 1rem; }
.item-list li.off .info strong { color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .6rem; flex: none; }
.row-actions button:not(.switch) { padding: .4rem .8rem; font-size: .9rem; }
.toggle { display: inline-flex; align-items: center; vertical-align: middle; gap: .55rem; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.toggle .state { min-width: 1.6rem; }
button.switch { position: relative; flex: none; width: 2.6rem; height: 1.5rem; padding: 0; border-radius: 99px; background: color-mix(in srgb, var(--muted) 35%, var(--card)); border-color: transparent; transition: background .15s; }
button.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: calc(1.5rem - 4px); height: calc(1.5rem - 4px); border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); transition: transform .15s; }
button.switch[aria-checked=true] { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
button.switch[aria-checked=true]::after { transform: translateX(1.1rem); }
button.switch:hover:not(:disabled) { border-color: transparent; filter: brightness(1.08); }
.mailbox { padding: 1.1rem 1.2rem 1.3rem; margin-bottom: 1.1rem; border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--bg) 55%, var(--card)); }
.mailbox-head { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .7rem; }
.mailbox-head strong { font-size: 1.05rem; overflow-wrap: anywhere; }
.mailbox-head .badge { margin-left: 0; }
.mailbox .usage { margin: .25rem 0 0; font-size: .88rem; }
.meter { height: .45rem; margin: .6rem 0 .35rem; border-radius: 99px; background: var(--line); overflow: hidden; }
.meter > span { display: block; height: 100%; min-width: 3px; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.meter.high > span { background: #d98a00; }
.meter.full > span { background: var(--danger); }
.mail-ui .token-box .input-row { align-items: center; }
.mail-ui table.plain th { width: 12rem; text-align: left; vertical-align: top; }
.mail-ui .section-head { margin-top: 2.4rem; }
.mail-ui .panel-head + table, .mail-ui .panel-head + .item-list { margin-top: 0; }
.mail-ui td.actions .row-actions { justify-content: flex-end; }
.mail-ui td.actions select { width: auto; min-height: 2.1rem; padding: .25rem 2rem .25rem .6rem; font-size: .9rem; }
@media (max-width: 34rem) { .item-list li { flex-wrap: wrap; } .row-actions { width: 100%; justify-content: flex-start; } }
.mailbox-head .push { margin-left: auto; }

/* The Mail page: a way back to the webmail and between sections */
.hero-actions { margin-bottom: .6rem; }
a.button-link { display: inline-block; padding: .5rem 1rem; border-radius: 10px; font-weight: 600; text-decoration: none; border: 1px solid var(--line); background: var(--card); color: var(--text); }
a.button-link.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: var(--accent-text); }
a.button-link:hover { filter: brightness(1.06); }
.section-nav { display: flex; flex-wrap: wrap; gap: .4rem; position: sticky; top: 3.6rem; z-index: 4; padding: .5rem 0; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); }
.section-nav a { padding: .35rem .8rem; border-radius: 99px; border: 1px solid var(--line); background: var(--card); text-decoration: none; font-size: .9rem; color: var(--text); }
.section-nav a:hover { border-color: var(--accent); color: var(--accent); }
.mail-ui .card { scroll-margin-top: 7rem; }
details.encryption { margin: .8rem 0; padding: .6rem .9rem; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--card) 70%, transparent); }
details.encryption > summary { cursor: pointer; font-weight: 600; }
details.encryption textarea { width: 100%; font-size: .8rem; }
details.encryption code { overflow-wrap: anywhere; }
label.check-row { display: flex; gap: .6rem; align-items: flex-start; margin: .8rem 0; font-weight: 400; }
details.encryption p { margin: .6rem 0; }
details.api-keys .check-grid { display: grid; gap: .3rem; margin: .6rem 0; }
details.api-keys pre { overflow-x: auto; padding: .6rem; border: 1px solid var(--line); border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
