:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --ink: #16181d;
    --muted: #61656e;
    --line: #dfe2e8;
    --accent: #1f6f4a;
    --accent-soft: #e5f2eb;
    --danger: #b3261e;
    --danger-soft: #fbeceb;
    --field-line: #cdd2da;
    --radius: 10px;
    accent-color: var(--accent);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14161a;
        --surface: #1c1f25;
        --ink: #e9eaee;
        --muted: #9aa0ab;
        --line: #2c3038;
        --accent: #5fc493;
        --accent-soft: #1b2d24;
        --danger: #f2857c;
        --danger-soft: #2e1d1c;
        --field-line: #3a3f48;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.shell {
    flex: 1;
    width: 100%;
    max-width: 33rem;
    margin: 0 auto;
    padding: 2rem 1rem 3rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.75rem;
}

h1 { margin: 0 0 .35rem; font-size: 1.4rem; letter-spacing: -0.01em; }

.error-code { font-size: 2.5rem; margin-bottom: .25rem; }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .875em;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: .1em .4em;
}

.facts {
    margin: 1.25rem 0;
    padding: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .4rem 1rem;
    align-items: baseline;
}

.facts dt { color: var(--muted); font-size: .875rem; }
.facts dd { margin: 0; }

a { color: var(--accent); }

.stack { display: grid; gap: 1.1rem; margin-top: 1.5rem; }

.field { display: grid; gap: .35rem; }

.field label,
.field .label { font-size: .875rem; font-weight: 600; }

.field input:not([type="radio"], [type="checkbox"]),
.field textarea,
.field select {
    width: 100%;
    padding: .55rem .75rem;
    font: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--field-line);
    border-radius: 6px;
    box-shadow: inset 0 1px 2px rgba(16, 24, 40, .04);
    transition: border-color .12s, box-shadow .12s;
}

.field input::placeholder,
.field textarea::placeholder { color: var(--muted); opacity: .7; }

.field input:not([type="radio"], [type="checkbox"]):hover,
.field textarea:hover,
.field select:hover { border-color: var(--muted); }

.field textarea {
    /* Redirect URIs go one per line, so wrapping must not look like a line break. */
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .875rem;
    line-height: 1.6;
    resize: vertical;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}

.field input:not([type="radio"], [type="checkbox"]):focus-visible,
.field textarea:focus-visible,
.field select:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field .optional { font-weight: 400; color: var(--muted); }

/* A field's legend lines up with the labels of the fields around it. */
.field legend { padding: 0; margin-bottom: .35rem; }

/* Checkbox groups: scopes, grant types, and the standalone toggles. */
.checks { margin: 0; padding: 0; list-style: none; display: grid; gap: .5rem; }

.checks > li { display: grid; gap: .2rem; }

.checks label {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    font-weight: 400;
}

.checks input[type="checkbox"] {
    width: auto;
    flex: none;
    margin: 0;
    padding: 0;
}

.checks .hint { margin-left: 1.5rem; }

.hint { margin: 0; font-size: .8125rem; color: var(--muted); }

.button {
    /* So a link styled as a button takes up its padding, as a <button> does. */
    display: inline-block;
    padding: .65rem 1.1rem;
    font: inherit;
    font-weight: 600;
    line-height: 1.25;
    color: #fff;
    background: var(--accent);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
}

.button:hover { filter: brightness(1.08); }

.button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.button-quiet {
    margin-top: 1rem;
    color: var(--ink);
    background: transparent;
    border-color: var(--line);
}

.scopes {
    margin: 1.25rem 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: .6rem;
}

.scopes li {
    padding: .7rem .85rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
}

.scope-name { flex: none; color: var(--muted); }

.actions { display: flex; gap: .6rem; margin-top: 1.5rem; }

.actions .button-quiet { margin-top: 0; }

.alert {
    margin: 1.25rem 0 1rem;
    padding: .8rem 1rem;
    border: 1px solid var(--danger);
    border-left-width: 3px;
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--danger);
    font-size: .9375rem;
}

.notice {
    margin: 1.25rem 0 1rem;
    padding: .8rem 1rem;
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--bg);
    font-size: .9375rem;
}

.alert:last-child,
.notice:last-child { margin-bottom: 0; }

.footer {
    padding: 1.25rem;
    text-align: center;
    color: var(--muted);
    font-size: .8125rem;
}

.footer-links { display: flex; justify-content: center; gap: 1rem; margin-top: .5rem; }
.footer-links a { color: inherit; }

/* ---------------------------------------------------------------- admin */

body.admin .shell,
.shell.wide { max-width: 52rem; }


.shell > .card + .card { margin-top: 1.25rem; }

h2 { margin: 0 0 .5rem; font-size: 1.05rem; }
.card h2:not(:first-child) { margin-top: 1.75rem; }

/* A list heading with its "add" button on the same line. */
.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: .75rem 1rem;
}

.card-header h1,
.card-header h2 { margin-bottom: 0; }

/* The margin that separates a mid-card h2 from what precedes it belongs to the
   wrapper once the heading is inside one. */
.card > .card-header:not(:first-child) { margin-top: 1.75rem; }
.card-header h2:not(:first-child) { margin-top: 0; }

.card-header .button { flex: none; }

.rows { margin: 1rem 0; padding: 0; list-style: none; display: grid; gap: .5rem; }

.rows > li {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    justify-content: space-between;
    padding: .65rem .8rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.rows-block > li { display: block; }
.rows-quiet > li { background: transparent; border-style: dashed; }

.tags { display: flex; flex-wrap: wrap; gap: .35rem; margin: .4rem 0; }

.tag {
    padding: .1rem .45rem;
    font-size: .75rem;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
}

.tag-warn { color: var(--danger); border-color: var(--danger); }

.button-small { padding: .3rem .6rem; font-size: .8125rem; }

.button-danger { background: var(--danger); }

.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }

.inline-form select {
    flex: 1 1 14rem;
    padding: .5rem;
    font: inherit;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.check { display: flex; gap: .5rem; align-items: center; font-size: .9375rem; }

.facts-tight { margin: .5rem 0 0; font-size: .875rem; }

.wrap { word-break: break-all; }

[hidden] { display: none !important; }

.secret { padding-left: .75rem; border-left: 3px solid var(--accent); }

.secret-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }

.secret-value { display: inline-block; padding: .2rem .45rem; user-select: all; }

.copy-button { margin: 0; min-width: 5.5rem; }

.secret-once { margin: .4rem 0 0; font-size: .875rem; color: var(--accent); }

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

.divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 1.5rem 0 1rem;
    color: var(--muted);
    font-size: .8125rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
}

/* -------------------------------------------------------------- sidebar */

/*
 * One menu for the whole site: a sidebar beside the page on wide screens,
 * and a bar with a menu button on narrow ones.
 */
.frame { flex: 1; display: flex; flex-direction: column; }
.page { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.sidebar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem 1rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;
}

.menu-toggle {
    display: none;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
}

/* Three bars, drawn with a box and its two shadows. */
.menu-icon,
.menu-icon::before,
.menu-icon::after {
    display: block;
    width: 1.125rem;
    height: 2px;
    margin: 0 auto;
    background: currentColor;
    border-radius: 1px;
}
.menu-icon { position: relative; }
.menu-icon::before,
.menu-icon::after { content: ''; position: absolute; left: 0; }
.menu-icon::before { top: -6px; }
.menu-icon::after { top: 6px; }
.menu-open .menu-icon { background: transparent; }
.menu-open .menu-icon::before { top: 0; transform: rotate(45deg); }
.menu-open .menu-icon::after { top: 0; transform: rotate(-45deg); }

.sidenav { padding: 0 .5rem 1rem; }
.sidenav-section + .sidenav-section { margin-top: 1rem; }

.sidenav-title {
    margin: 0 0 .25rem;
    padding: 0 .75rem;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}

.sidenav ul { list-style: none; margin: 0; padding: 0; }

.sidenav a {
    display: block;
    padding: .4rem .75rem;
    border-radius: 6px;
    color: var(--ink);
    text-decoration: none;
    font-size: .9375rem;
}
.sidenav a:hover { background: var(--bg); }
.sidenav a[aria-current="page"] {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.sidenav-search { display: flex; gap: .375rem; margin: .5rem .75rem 0; }
.sidenav-search input,
.sidenav-search .button { height: 2rem; margin: 0; font-size: .8125rem; }
.sidenav-search input {
    flex: 1;
    min-width: 0;
    padding: 0 .5rem;
    font-family: inherit;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    -webkit-appearance: none;
    appearance: none;
}
.sidenav-search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.sidenav-search .button { flex: none; padding: 0 .65rem; }

.sidenav-signout {
    margin: 1.25rem .75rem 0;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}
.sidenav-signout p { margin-bottom: .25rem; overflow-wrap: anywhere; }

@media (max-width: 47.99rem) {
    /* With JavaScript the menu folds behind the button; without, it stays open. */
    .js .menu-toggle { display: block; }
    .js .sidenav { display: none; }
    .js .menu-open .sidenav { display: block; }
}

@media (min-width: 48rem) {
    .frame { flex-direction: row; }

    .sidebar {
        flex: none;
        width: 15rem;
        border-bottom: 0;
        border-right: 1px solid var(--line);
        position: sticky;
        top: 0;
        height: 100vh;
        overflow-y: auto;
    }

    .sidebar-top { padding: 1.25rem 1.25rem 1rem; }
    .sidenav { padding: 0 .5rem 1.5rem; }
}

/* ----------------------------------------------------------------- home */

.hero { padding: 1rem 0 2rem; }
.hero h1 { font-size: 1.9rem; line-height: 1.2; margin-bottom: .75rem; }
.lede { font-size: 1.0625rem; color: var(--muted); }
.hero .actions { margin-top: 1.25rem; flex-wrap: wrap; }

.steps { margin: .75rem 0 1rem; padding-left: 1.25rem; display: grid; gap: .5rem; }

.shell > .hero + .card { margin-top: 0; }

/* ---------------------------------------------------------- verification */

.callsign-panel {
    margin: 1rem 0 1.25rem;
    padding: 1rem;
    border-radius: var(--radius);
    background: var(--accent-soft);
}

.callsign-badge {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: .03em;
    margin-right: .5rem;
}

.callsign-input,
.code-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace !important;
    font-size: 1.25rem !important;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.address {
    padding: .75rem 1rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .9375rem;
}

.progress {
    display: flex;
    gap: .25rem;
    margin: 1rem 0 1.25rem;
    padding: 0;
    list-style: none;
    font-size: .8125rem;
    counter-reset: step;
}

.progress li {
    flex: 1;
    padding: .4rem .5rem;
    text-align: center;
    color: var(--muted);
    border-bottom: 3px solid var(--line);
}

.progress li.done { color: var(--accent); border-color: var(--accent); }
.progress li.current { color: var(--ink); font-weight: 600; border-color: var(--accent); }

.button-block { display: block; width: 100%; }

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

.inline-form p { margin: 0; }

@media (max-width: 30rem) {
    .card { padding: 1.25rem; }
    .actions { flex-wrap: wrap; }
    .facts { grid-template-columns: 1fr; gap: .1rem; }
    .facts dd { margin-bottom: .5rem; }
}

/* ----------------------------------------------------------------- docs */

.prose h2 { margin-top: 2rem; }
.prose ul { padding-left: 1.25rem; }
.prose li { margin-bottom: .35rem; }

pre {
    margin: 0 0 1rem;
    padding: .85rem 1rem;
    overflow-x: auto;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: .8125rem;
    line-height: 1.5;
}

pre code { padding: 0; border: 0; background: none; font-size: inherit; }

.table { width: 100%; border-collapse: collapse; margin: .5rem 0 1rem; font-size: .9rem; }
.table th, .table td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .8125rem; }

fieldset { margin: 0; padding: 0; border: 0; }
.checks input[type="radio"] { width: auto; flex: none; margin: 0; }

.inline-form input[type="text"],
.inline-form input[type="email"] {
    padding: .35rem .5rem;
    font: inherit;
    font-size: .875rem;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
}
.nowrap { white-space: nowrap; }

/* Unconfirmed email prompt, on the account and verification pages. */
.confirm-email { border-left: 3px solid var(--accent); }
.confirm-email h2 { margin-top: 0; }
.inline-code { display: flex; flex-wrap: wrap; gap: .5rem; align-items: stretch; }
.inline-code .code-input { flex: 1 1 9rem; max-width: 12rem; }
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Backup codes: shown once after signup, and when a new set is made. */
.backup-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .5rem 1.5rem;
    margin: 1rem 0;
    padding: 1rem 1rem 1rem 2.5rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.125rem;
    letter-spacing: .04em;
}
.checkbox { display: flex; gap: .5rem; align-items: flex-start; }
.checkbox input { margin-top: .25rem; }
.backup-signin { margin-top: 1rem; }
.backup-signin summary { cursor: pointer; color: var(--muted); }
.backup-signin form { margin-top: 1rem; }

/* Archived postcard proofs, in the admin pages. */
.postcard-proof { display: flex; gap: .5rem; align-items: center; margin-top: .375rem; }
.postcard-proof img { display: block; height: 4.5rem; width: auto; border: 1px solid var(--line); border-radius: 3px; background: #fff; }

/* -------------------------------------------------------- app forms */

/* One choice of several, as a card that shows which is picked. */
.choices { margin: 0; padding: 0; list-style: none; display: grid; gap: .5rem; }

.field .choice {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .1rem .65rem;
    padding: .75rem .9rem;
    border: 1px solid var(--field-line);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 400;
    cursor: pointer;
    transition: border-color .12s, background-color .12s;
}

.choice:hover { border-color: var(--muted); }

.choice input { grid-row: span 2; align-self: start; width: auto; margin: .3rem 0 0; }

.choice-title { font-weight: 600; }

.choice-hint { font-size: .875rem; color: var(--muted); }

.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.choice:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--accent-soft); }

.fieldset-hint { margin-top: .5rem; }

/* Buttons at the end of a form, sized to their labels rather than the form. */
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; margin-top: .25rem; }

.form-actions .button { margin: 0; }

/* A card section after the first, separated by a rule. */
.card-section { margin-top: 1.75rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }

.card-section h2 { margin-top: 0; }

.card-danger { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }

.card-danger h2 { color: var(--danger); }

.danger-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; }

.danger-row p { margin: 0; }

.button-danger-quiet {
    color: var(--danger);
    background: transparent;
    border-color: var(--danger);
}

.button-danger-quiet:hover { background: var(--danger-soft); filter: none; }

/* --------------------------------------------- verified page and badge */

.profile-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.profile-callsign { font-size: 2rem; }
.verified-mark {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .2rem .6rem .2rem .45rem;
    font-size: .875rem; font-weight: 700;
    color: #fff; background: var(--accent); border-radius: 999px;
}
.profile h1 { font-size: 1.15rem; font-weight: 600; color: var(--muted); }
.profile-links { margin: 0 0 .5rem; padding: 0; list-style: none; display: grid; gap: .35rem; }
.profile-links a { word-break: break-all; }
.snippet code { white-space: pre-wrap; word-break: break-all; }

/* --------------------------------------------------------------- guides */

.guide-list, .prose .guide-list { margin: .5rem 0 1rem; padding: 0; list-style: none; display: grid; gap: .6rem; }
.guide-list li { display: grid; gap: .1rem; }
.guide pre { max-height: 32rem; }
.guide ol, .guide ul { padding-left: 1.25rem; }
.guide ol li, .guide ul li { margin-bottom: .35rem; }

/* ---------------------------------------------------------- button kit */

.button-preview { display: flex; align-items: center; justify-content: center; padding: 1.5rem; border: 1px solid var(--line); border-radius: 8px; background: #f6f7f9; }
.button-preview-white { background: #1c1f25; }
.prose h3 { margin: 1.25rem 0 .5rem; font-size: .9375rem; }

/* ----------------------------------------------------------- playground */

.playground-result h2:first-child { margin-top: 0; }

.prose a.button { color: #fff; text-decoration: none; }
.prose a.button-quiet { color: var(--ink); }

/* ------------------------------------------------------- app directory */

.app-list, .prose .app-list { margin: 1rem 0 0; padding: 0; list-style: none; display: grid; gap: .75rem; }
.app-list li { display: grid; gap: .15rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 8px; }

/* -------------------------------------------------- after verification */

.next-steps { margin: .5rem 0 1.25rem; padding-left: 1.25rem; }
.next-steps li { margin-bottom: .4rem; }
.share-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.share-actions .button { margin: 0; }

a.button { text-decoration: none; }

/* ------------------------------------------------------- admin accounts */

.directory-search { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .75rem; align-items: end; margin: 1rem 0 1.25rem; }
.directory-actions { display: flex; gap: .5rem; }
@media (max-width: 40rem) { .directory-search { grid-template-columns: 1fr; } }
.input-short { max-width: 12rem; }
.admin-panel { margin-top: 1rem; border: 1px solid var(--line); border-radius: 8px; padding: .75rem 1rem; }
.admin-panel summary { cursor: pointer; font-weight: 600; font-size: .9375rem; }
.admin-panel .stack { margin-top: 1rem; }
.table-scroll { overflow-x: auto; }
.table-scroll th { white-space: nowrap; }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: .5rem; }
.pager a[rel="next"] { margin-left: auto; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.selected td { background: var(--accent-soft); }
