:root {
    color-scheme: dark;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    color: #edf0fe;
    background: #111524;
    --panel: #191f32;
    --raised: #212940;
    --field: #121827;
    --ink: #edf0fe;
    --muted: #b0bdd9;
    --line: #35415f;
    --field-line: #697696;
    --accent: #a5b6ff;
    --action: linear-gradient(110deg, #3157c5, #693bb7);
    --ok: #93e0c2;
    --warn: #f6ca90;
    --bad: #ffa6b9;
    --radius: 1rem;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    font-size: 1rem;
    line-height: 1.5;
    background: radial-gradient(ellipse at 10% 0, #202b4d, transparent 40rem),
        radial-gradient(ellipse at 94% 12%, #2f2144, transparent 39rem), #111524;
    background-attachment: fixed;
}
h1, h2, h3, p, dl { margin: 0; }
h1, h2, h3 { line-height: 1.18; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: -.035em; }
h2 { font-size: 1.2rem; letter-spacing: -.015em; }
h3 { font-size: 1rem; }
button, input, select { font: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid #b9c5ff; outline-offset: 3px; }
.muted { color: var(--muted); }
.container { width: min(100% - 2rem, 72rem); margin-inline: auto; }

.topbar { background: #131728; border-bottom: 1px solid var(--line); }
.topbar-content, .brand, .account-nav { display: flex; align-items: center; gap: .65rem; }
.topbar-content { justify-content: space-between; min-height: 4.5rem; }
.brand { color: var(--ink); text-decoration: none; min-width: 0; }
.brand-mark {
    flex: none;
    width: 2.5rem;
    height: 2.5rem;
    object-fit: contain;
}
.brand strong, .brand small { display: block; line-height: 1.3; }
.brand small { color: var(--muted); font-size: .8rem; }

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 2.75rem;
    padding: .55rem .85rem;
    border: 1px solid var(--line);
    border-radius: .65rem;
    color: var(--ink);
    background: var(--raised);
    font-size: .875rem;
    font-weight: 720;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}
.button:hover { border-color: var(--field-line); background: #2b3652; }
.button.primary { color: #fff; background: var(--action); border-color: transparent; }
.button.primary:hover { border-color: #a6b3ff; }
.button.quiet { background: transparent; border-color: transparent; color: var(--accent); }
.button.quiet:hover, .button[aria-current="page"] { background: #293355; }
.button.danger { color: var(--bad); border-color: #a94f6b; background: #402538; }
.button.danger:hover { background: #552e44; }

.auth { width: min(100% - 2rem, 29rem); margin: clamp(2rem, 8vh, 5rem) auto; }
.card {
    min-width: 0;
    padding: clamp(1rem, 2.3vw, 1.5rem);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: 0 .8rem 2rem #080b1680;
}
.auth-card { border-top: 3px solid #8d9fff; }
.auth-card h1 + p, .card > h2 + p { margin-top: .65rem; }
.auth-card > .stack, .creation > .stack { margin-top: 1.15rem; }
.auth-card > .message { margin-top: .85rem; }
.setup-link { display: inline-block; margin-top: 1rem; }
.hint { margin-top: .85rem; color: var(--accent); }

.stack { display: grid; gap: .85rem; }
label { display: grid; gap: .35rem; min-width: 0; color: var(--muted); font-size: .9rem; font-weight: 650; }
input, select {
    width: 100%;
    min-width: 0;
    min-height: 2.75rem;
    padding: .55rem .7rem;
    border: 1px solid var(--field-line);
    border-radius: .6rem;
    color: var(--ink);
    background: var(--field);
    font-size: 1rem;
}
select {
    appearance: none;
    padding-right: 1.7rem;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: right 1rem center, right .71rem center;
    background-size: .3rem .3rem;
    background-repeat: no-repeat;
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }

.dashboard { display: grid; gap: 1rem; padding-block: 1.5rem 3rem; }
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: clamp(1.1rem, 3vw, 2rem);
    border: 1px solid #435079;
    border-radius: var(--radius);
    background: linear-gradient(117deg, #213969, #29284f 58%, #3d2955);
}
.member-head p { margin-top: .45rem; color: #d3ddfa; overflow-wrap: anywhere; }
.tabs { display: flex; gap: .25rem; padding: .25rem; border: 1px solid #556084; border-radius: .75rem; background: #191f38; }
.tabs a {
    display: inline-flex;
    align-items: center;
    min-height: 2.5rem;
    padding: .4rem .85rem;
    border-radius: .5rem;
    color: var(--muted);
    font-size: .9rem;
    font-weight: 700;
    text-decoration: none;
}
.tabs a:hover { color: var(--ink); background: var(--raised); }
.tabs a[aria-current="page"] { color: #fff; background: var(--action); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
.stats dt { color: var(--muted); font-size: .875rem; font-weight: 650; }
.stats dd { margin: .15rem 0 0; font-size: clamp(1.55rem, 4vw, 2.3rem); line-height: 1.18; font-weight: 760; }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.bad-text { color: var(--bad); }

.workspace { display: grid; grid-template-columns: minmax(17.5rem, .8fr) minmax(0, 1.6fr); gap: 1rem; align-items: start; }
.creation { scroll-margin-top: 1rem; }
.creation > a.button { margin-top: .85rem; }
.filters {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: .55rem;
    margin-top: .9rem;
    padding-bottom: .9rem;
    border-bottom: 1px solid var(--line);
}
.filters > label:first-of-type { flex: 1 1 10rem; }
.filters > label:has(select) { flex: 0 1 8.75rem; }
.empty {
    margin-top: .9rem;
    padding: 1.25rem;
    border: 1px dashed var(--field-line);
    border-radius: .75rem;
    color: var(--muted);
    text-align: center;
}
.records { display: grid; gap: .65rem; margin-top: .9rem; }
.records:empty { display: none; }
.record { display: grid; gap: .7rem; min-width: 0; padding: .9rem; border-radius: .75rem; border: 1px solid var(--line); background: var(--raised); }
.record-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .65rem; }
.identity { min-width: 0; overflow-wrap: anywhere; }
.identity p, .record > p { margin-top: .2rem; color: var(--muted); font-size: .875rem; }
.status {
    display: inline-block;
    flex: none;
    padding: .18rem .5rem;
    border-radius: 2rem;
    font-size: .875rem;
    font-weight: 740;
    line-height: 1.5;
}
.status.active { background: #203b34; color: var(--ok); }
.status.expired { background: #493729; color: var(--warn); }
.status.revoked { background: #472837; color: var(--bad); }
.record-meta { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: .65rem; }
.record-meta dt { color: var(--muted); font-size: .875rem; }
.record-meta dd { margin: .12rem 0 0; font-size: .9rem; font-weight: 670; }
.manage { padding-top: .5rem; border-top: 1px solid var(--line); }
.manage > summary { padding-block: .15rem; color: var(--accent); font-size: .9rem; font-weight: 700; cursor: pointer; }
.manage > :not(summary) { margin-top: .65rem; }
.inline-form, .record-actions, .pagination { display: flex; flex-wrap: wrap; align-items: end; gap: .55rem; }
.inline-form label { width: min(9rem, 100%); }
.pagination { margin-top: .9rem; }
.devices { display: grid; gap: .45rem; padding-left: 1rem; color: var(--muted); font-size: .9rem; }
.devices strong, .devices span { display: block; overflow-wrap: anywhere; }
.devices strong { color: var(--ink); }

.copy-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .35rem;
    padding: .25rem .35rem .25rem .7rem;
    border: 1px solid var(--line);
    border-radius: .7rem;
    background: var(--field);
}
.copy-box code { color: #d6dfff; min-width: 0; overflow-wrap: anywhere; font-size: .875rem; }
.copy-box > .button { flex: none; }
.message { padding: .7rem .85rem; border-radius: .65rem; border: 1px solid #477d6b; color: var(--ok); background: #1f372f; }
.message.error { border-color: #a6536e; color: var(--bad); background: #402638; }
.credential > p { margin: .45rem 0 .65rem; color: var(--muted); }
.resource-form { margin-top: 1rem; max-width: 42rem; }
.install-steps { padding-inline-start: 1.5rem; }
.install-steps li + li { margin-top: .5rem; }
.member-tabs { flex-wrap: wrap; justify-self: start; }
.member-stack { display: grid; gap: .85rem; align-content: start; min-width: 0; }
.member-stack > .button { justify-self: start; }
.member-prose { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.member-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: 1rem; }
.template-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 23rem), 1fr)); }
.member-stack .copy-box code { white-space: pre-wrap; }
.release-version { color: var(--muted); }
.release-version strong { color: var(--ink); }
.lesson-progress-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .8rem; }
.lesson-progress-head h2 + p { margin-top: .25rem; }
.member-stack progress { appearance: none; width: 100%; height: .65rem; border: 0; border-radius: 1rem; overflow: hidden; background: var(--field); accent-color: var(--accent); }
.member-stack progress::-webkit-progress-bar { background: var(--field); }
.member-stack progress::-webkit-progress-value { background: var(--action); }
.lesson-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .65rem;
    min-width: 0;
    padding: .75rem;
    border: 1px solid var(--line);
    border-radius: .65rem;
    background: var(--field);
    color: var(--ink);
    text-decoration: none;
}
.lesson-item:hover, .lesson-item[aria-current="page"] { background: var(--raised); border-color: var(--field-line); }
.lesson-item strong, .lesson-reading h1 { overflow-wrap: anywhere; }
.lesson-state { display: inline-block; flex: none; color: var(--muted); font-size: .85rem; }
.lesson-state.is-complete { color: var(--ok); }
.lesson-reading .member-prose { max-width: 78ch; }
.lesson-action { padding-top: .85rem; border-top: 1px solid var(--line); }
@media (max-width: 29rem) {
    .lesson-item { align-items: start; flex-direction: column; }
}

@media (max-width: 50rem) {
    .workspace { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 29rem) {
    .container { width: calc(100% - 1.25rem); }
    .topbar-content { gap: .4rem; }
    .account-nav { gap: .2rem; }
    .account-nav > .button, .account-nav form > .button { padding-inline: .55rem; }
    .stats { gap: .4rem; }
    .stats .card { padding: .65rem .45rem; }
    .stats dt { overflow-wrap: anywhere; }
    .record-meta { grid-template-columns: minmax(0, 1fr); gap: .35rem; }
    .filters > label:has(select) { flex: 1 1 7.75rem; }
}
