/* imbrada site: landing, sign-in, registration and the admin pages.
   One loud thing: the brand mark doubles as the progress indicator. Everything
   else stays quiet - one typeface, cool paper, teal for structure, orange only
   for the center of the mark and the primary action. */

:root {
    --paper: #f3f7f6;
    --surface: #ffffff;
    --ink: #17302f;
    --muted: #4f6c6a;
    --line: #d2dfdd;
    --teal: #168a86;
    --teal-strong: #0f6e6b;
    --teal-soft: #d6ecea;
    --orange: #ee7623;
    --orange-strong: #c95c10;
    --orange-soft: #fbe3d0;
    --error: #b42318;
    --error-soft: #fdecea;
    --warning-soft: #fdf3dc;
    --warning-ink: #6b4a00;
    --focus: #168a86;

    --font: "Lexend", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

    /* Modular scale, ratio 1.25 from 16px */
    --step--1: 0.8rem;
    --step-0: 1rem;
    --step-1: 1.25rem;
    --step-2: 1.5625rem;
    --step-3: 1.953rem;
    --step-4: 2.441rem;

    --radius-control: 10px;
    --radius-panel: 18px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #0e1c1b;
        --surface: #142624;
        --ink: #e5efed;
        --muted: #9cb4b1;
        --line: #284240;
        --teal: #3fbdb6;
        --teal-strong: #6fd3cd;
        --teal-soft: #1b3735;
        --orange: #f48a3e;
        --orange-strong: #f7a266;
        --orange-soft: #3a2616;
        --error: #ff8a80;
        --error-soft: #3a1714;
        --warning-soft: #33290f;
        --warning-ink: #f3d58b;
        --focus: #6fd3cd;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --paper: #0e1c1b;
    --surface: #142624;
    --ink: #e5efed;
    --muted: #9cb4b1;
    --line: #284240;
    --teal: #3fbdb6;
    --teal-strong: #6fd3cd;
    --teal-soft: #1b3735;
    --orange: #f48a3e;
    --orange-strong: #f7a266;
    --orange-soft: #3a2616;
    --error: #ff8a80;
    --error-soft: #3a1714;
    --warning-soft: #33290f;
    --warning-ink: #f3d58b;
    --focus: #6fd3cd;
    color-scheme: dark;
}

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

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

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font);
    font-size: var(--step-0);
    font-weight: 300;
    line-height: 1.55;
}

h1 {
    margin: 0 0 0.5rem;
    font-size: var(--step-3);
    font-weight: 500;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

h1:focus {
    outline: none;
}

h2[tabindex="-1"]:focus {
    outline: none;
}

p {
    margin: 0 0 1rem;
    max-width: 62ch;
}

strong {
    font-weight: 500;
}

code {
    font-family: var(--mono);
    font-size: 0.85em;
    overflow-wrap: anywhere;
}

a {
    color: var(--teal-strong);
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

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

/* ---------- Shell ---------- */

.shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0 16px;
}

.masthead,
.stage,
.colophon {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
}

.masthead {
    padding: 1.25rem 0;
}

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

.wordmark {
    font-size: var(--step-1);
    font-weight: 500;
    letter-spacing: -0.02em;
}

.stage {
    flex: 1;
    padding: 1.5rem 0 3rem;
}

.colophon {
    padding: 1.5rem 0 2rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: var(--step--1);
}

/* ---------- Brand mark ---------- */

.brand-mark-lines line {
    stroke: var(--teal);
    stroke-width: 6;
    stroke-linecap: round;
}

.brand-mark-node {
    fill: var(--teal);
}

.brand-mark-center {
    fill: var(--orange);
}

/* ---------- Signup layout ---------- */

.signup {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 4rem;
    align-items: start;
}

.signup-rail {
    position: sticky;
    top: 2rem;
}

.panel {
    max-width: 34rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-panel);
    padding: 2.25rem 2.25rem 2rem;
}

.lede {
    color: var(--muted);
    font-size: var(--step-1);
    line-height: 1.45;
    margin-bottom: 1.75rem;
}

.signed-in {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    margin-bottom: 1.5rem;
    color: var(--muted);
    font-size: var(--step--1);
}

/* ---------- Progress mark ---------- */

.progress {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.progress-mark {
    width: 100%;
    max-width: 200px;
    height: auto;
    overflow: visible;
}

.progress-track {
    stroke: var(--line);
    stroke-width: 4;
    stroke-linecap: round;
}

.progress-line {
    stroke: var(--teal);
    stroke-width: 5;
    stroke-linecap: round;
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    transition: stroke-dashoffset 700ms cubic-bezier(0.65, 0, 0.35, 1);
}

.progress-line.is-drawn {
    stroke-dashoffset: 0;
}

.progress-node,
.progress-center {
    stroke-width: 4;
    transition: fill 300ms ease, stroke 300ms ease;
}

.progress-node.is-upcoming {
    fill: var(--surface);
    stroke: var(--line);
}

.progress-node.is-current {
    fill: var(--surface);
    stroke: var(--teal);
    animation: node-pulse 2.4s ease-in-out infinite;
    transform-box: fill-box;
    transform-origin: center;
}

.progress-node.is-done {
    fill: var(--teal);
    stroke: var(--teal);
}

.progress-center.is-upcoming {
    fill: var(--surface);
    stroke: var(--orange-soft);
}

.progress-center.is-current,
.progress-center.is-done {
    fill: var(--orange);
    stroke: var(--orange);
}

@keyframes node-pulse {
    0%, 100% { stroke-width: 4; }
    50% { stroke-width: 7; }
}

.progress-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.6rem;
    font-size: var(--step-0);
}

.progress-steps li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--muted);
}

.progress-steps li::before {
    content: "";
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--line);
}

.progress-steps li.is-current {
    color: var(--ink);
    font-weight: 500;
}

.progress-steps li.is-current::before {
    border-color: var(--teal);
}

.progress-steps li.is-done::before {
    background: var(--teal);
    border-color: var(--teal);
}

.progress-steps li:last-child.is-current::before,
.progress-steps li:last-child.is-done::before {
    background: var(--orange);
    border-color: var(--orange);
}

/* ---------- Forms ---------- */

.form {
    display: grid;
    gap: 1.25rem;
}

.field {
    display: grid;
    gap: 0.4rem;
    min-width: 0;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

label,
legend {
    font-weight: 500;
    font-size: var(--step--1);
}

.optional {
    color: var(--muted);
    font-weight: 300;
    margin-left: 0.35rem;
}

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

input[type="text"],
input[type="email"],
input[type="tel"] {
    width: 100%;
    font: inherit;
    font-weight: 400;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    padding: 0.7rem 0.85rem;
}

input:focus-visible {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-soft);
}

input:disabled {
    opacity: 0.6;
}

.code-input {
    font-family: var(--mono);
    font-size: var(--step-2);
    letter-spacing: 0.4em;
    max-width: 12ch;
}

fieldset {
    border: 0;
    padding: 0;
    margin: 0;
}

.choice-group {
    gap: 0.5rem;
}

.choice {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    cursor: pointer;
    font-size: var(--step-0);
    font-weight: 400;
}

.choice.is-selected {
    border-color: var(--teal);
    background: var(--teal-soft);
}

.choice input {
    accent-color: var(--teal);
    width: 1.1rem;
    height: 1.1rem;
    margin: 0;
}

.confirm {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: var(--step-0);
    font-weight: 400;
    cursor: pointer;
}

.confirm input {
    accent-color: var(--teal);
    width: 1.1rem;
    height: 1.1rem;
    margin: 0;
}

/* ---------- Buttons ---------- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.9rem;
    padding: 0 1.4rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 150ms ease;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.button-primary {
    background: var(--orange);
    color: #1f1206;
    justify-self: start;
}

.button-primary:hover:not(:disabled) {
    background: var(--orange-strong);
    color: #fff;
}

.button-secondary {
    background: transparent;
    color: var(--teal-strong);
    border-color: var(--teal);
}

.button-secondary:hover:not(:disabled) {
    background: var(--teal-soft);
}

.button-apple {
    width: 100%;
    max-width: 400px;
    background: #000;
    color: #fff;
}

.link-button {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    font-size: var(--step--1);
    color: var(--teal-strong);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.link-button:disabled {
    color: var(--muted);
    text-decoration: none;
    cursor: default;
}

.aside-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    margin-top: 1.5rem;
}

/* ---------- Providers ---------- */

.providers {
    display: grid;
    gap: 0.75rem;
    justify-items: start;
}

.google-slot {
    width: 100%;
    max-width: 400px;
    min-height: 44px;
}

.divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.75rem 0 1.25rem;
    color: var(--muted);
    font-size: var(--step--1);
    max-width: none;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--line);
}

/* ---------- Notices ---------- */

.notice {
    margin: 0 0 1.5rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-control);
    border-left: 4px solid;
    font-size: var(--step--1);
    font-weight: 400;
}

.notice-info {
    background: var(--teal-soft);
    border-color: var(--teal);
}

.notice-warning {
    background: var(--warning-soft);
    border-color: var(--orange);
    color: var(--warning-ink);
}

.notice-error {
    background: var(--error-soft);
    border-color: var(--error);
    color: var(--error);
}

/* ---------- API key ---------- */

.key-box {
    display: grid;
    gap: 0.6rem;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    border: 2px solid var(--orange);
    border-radius: var(--radius-control);
    background: var(--orange-soft);
}

.key-value {
    display: block;
    font-family: var(--mono);
    font-size: var(--step--1);
    line-height: 1.6;
    overflow-wrap: anywhere;
    user-select: all;
}

.key-box .button {
    justify-self: start;
}

.facts {
    display: grid;
    gap: 0.75rem;
    margin: 0 0 1.75rem;
}

.facts div {
    display: grid;
    gap: 0.1rem;
}

.facts dt {
    color: var(--muted);
    font-size: var(--step--1);
}

.facts dd {
    margin: 0;
}

/* ---------- Boot + error ---------- */

.boot {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.boot-mark {
    animation: boot-breathe 1.6s ease-in-out infinite;
}

@keyframes boot-breathe {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 1; }
}

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    padding: 0.9rem 16px;
    background: var(--error-soft);
    color: var(--error);
    border-top: 1px solid var(--error);
    z-index: 10;
}

#blazor-error-ui .dismiss {
    float: right;
    background: none;
    border: 0;
    font-size: 1.25rem;
    color: inherit;
    cursor: pointer;
}

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

.masthead {
    display: flex;
    align-items: center;
    gap: 1rem 2rem;
    flex-wrap: wrap;
}

.app-nav,
.guest-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: var(--step--1);
}

.app-nav {
    flex: 1;
}

.guest-nav {
    margin-left: auto;
}

.app-nav a,
.guest-nav a:not(.button) {
    color: var(--muted);
    text-decoration: none;
    padding: 0.35rem 0;
    border-bottom: 2px solid transparent;
}

.app-nav a:hover,
.guest-nav a:not(.button):hover {
    color: var(--ink);
}

.app-nav a.active,
.guest-nav a.active {
    color: var(--ink);
    font-weight: 500;
    border-bottom-color: var(--orange);
}

.account {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
    min-width: 0;
}

.account-who {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    color: var(--ink);
    text-decoration: none;
    font-size: var(--step--1);
}

.account-name {
    max-width: 16ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar {
    flex: none;
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--teal-soft);
    color: var(--teal-strong);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.button-small {
    min-height: 2.25rem;
    padding: 0 1rem;
    font-size: var(--step--1);
}

.button-ghost {
    background: transparent;
    color: var(--muted);
    border-color: var(--line);
}

.button-ghost:hover:not(:disabled) {
    color: var(--ink);
    border-color: var(--muted);
}

/* ---------- Landing ---------- */

.landing {
    display: grid;
    gap: 3rem;
    padding-top: 1.5rem;
}

.landing-hero {
    display: grid;
    gap: 1rem;
    justify-items: start;
}

.landing-hero h1 {
    font-size: var(--step-4);
    max-width: 16ch;
    margin: 0.5rem 0 0;
}

.landing-hero .lede {
    margin: 0;
}

.landing-choices {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
}

.choice-card {
    display: grid;
    align-content: start;
    justify-items: start;
    gap: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-panel);
    padding: 1.75rem;
}

.choice-card-primary {
    border-top: 4px solid var(--orange);
}

.choice-card h2 {
    margin: 0;
    font-size: var(--step-1);
    font-weight: 500;
}

.choice-card p {
    margin: 0 0 0.5rem;
    color: var(--muted);
}

.switch-prompt {
    margin: 1.75rem 0 0;
    padding-top: 1.25rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: var(--step--1);
}

/* ---------- Profile ---------- */

.value-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
}

.value {
    font-weight: 400;
    overflow-wrap: anywhere;
}

/* ---------- Usage ---------- */

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem 2rem;
    margin-bottom: 1.5rem;
}

.page-head .lede {
    margin: 0;
}

.section-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.4rem;
}

.console-section .section-head h2 {
    margin: 0;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 0;
}

.stat {
    display: grid;
    gap: 0.15rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
}

.stat dt {
    color: var(--muted);
    font-size: var(--step--1);
}

.stat dd {
    margin: 0;
}

.stat-value {
    font-size: var(--step-3);
    font-weight: 500;
    line-height: 1.2;
    color: var(--muted);
}

.stat-note {
    color: var(--muted);
    font-size: 0.72rem;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
}

.log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--step--1);
}

.log-table th {
    text-align: left;
    font-weight: 500;
    color: var(--muted);
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.log-table td {
    padding: 0.7rem 1rem;
}

.table-empty {
    text-align: center;
    color: var(--muted);
    padding: 2.5rem 1rem !important;
}

.tag.tag-muted {
    background: var(--teal-soft);
    color: var(--teal-strong);
}

/* ---------- Console ---------- */

.panel-narrow {
    max-width: 34rem;
}

.panel-wide {
    max-width: 46rem;
}

.console {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 3rem;
    align-items: start;
}

.console-rail {
    position: sticky;
    top: 2rem;
    display: grid;
    gap: 0.75rem;
    justify-items: start;
}

.rail-heading {
    margin: 0;
    color: var(--muted);
    font-size: var(--step--1);
}

.sub-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.25rem;
    width: 100%;
}

.sub-item {
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    border-left: 3px solid var(--line);
    padding: 0.5rem 0.75rem;
    font: inherit;
    color: var(--muted);
    cursor: pointer;
}

.sub-item:hover {
    color: var(--ink);
}

.sub-item.is-selected {
    border-left-color: var(--teal);
    color: var(--ink);
    font-weight: 500;
}

.rail-link {
    font-size: var(--step--1);
    margin-top: 0.75rem;
}

.console-section {
    border-top: 1px solid var(--line);
    padding-top: 1.75rem;
    margin-top: 1.75rem;
}

.console-section h2 {
    margin: 0 0 0.4rem;
    font-size: var(--step-1);
    font-weight: 500;
    letter-spacing: -0.01em;
}

.section-lede {
    color: var(--muted);
    margin-bottom: 1.25rem;
}

.muted {
    color: var(--muted);
}

.facts-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 2rem;
    margin-bottom: 0;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
}

.form-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: end;
    margin-top: 1.25rem;
}

select {
    font: inherit;
    font-weight: 400;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    padding: 0.7rem 0.85rem;
}

input[type="url"] {
    width: 100%;
    font: inherit;
    font-weight: 400;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    padding: 0.7rem 0.85rem;
}

select:focus-visible {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-soft);
}

.org-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
}

.org-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    padding: 0.75rem 1rem;
}

.org-row + .org-row {
    border-top: 1px solid var(--line);
}

/* Each org is two rows: name (+ Home tag), then region / id / actions. */
.org-main {
    display: flex;
    flex-basis: 100%;
    align-items: center;
    gap: 0.6rem;
}

.org-name {
    font-weight: 400;
}

.org-meta {
    display: flex;
    flex-basis: 100%;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 1rem;
    color: var(--muted);
    font-size: var(--step--1);
}

.tag {
    font-size: 0.72rem;
    font-weight: 500;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: var(--orange-soft);
    color: var(--orange-strong);
}

.confirm-box {
    border: 1px solid var(--error);
    background: var(--error-soft);
    border-radius: var(--radius-control);
    padding: 1rem 1.25rem;
}

.confirm-box p {
    margin-bottom: 1rem;
}

.button-danger {
    background: var(--error);
    color: #fff;
}

.button-danger:hover:not(:disabled) {
    filter: brightness(0.9);
}

/* ---------- Invitations ---------- */

.eyebrow {
    margin: 0 0 0.5rem;
    color: var(--orange-strong);
    font-size: var(--step--1);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.invite-meta {
    margin: 1.5rem 0 0;
    color: var(--muted);
    font-size: var(--step--1);
}

.field-grow {
    min-width: 0;
}

.org-row .org-panel {
    flex-basis: 100%;
    min-width: 0;
    margin-top: 0.75rem;
    padding-top: 0.25rem;
    border-top: 1px dashed var(--line);
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--line);
}

.tab {
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 0.6rem 0 0.5rem;
    font: inherit;
    font-size: var(--step--1);
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
    cursor: pointer;
}

.tab:hover {
    color: var(--ink);
}

.tab.is-selected {
    color: var(--ink);
    border-bottom-color: var(--orange);
}

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

.invite-form {
    margin-top: 0;
    gap: 0.75rem;
}

.invite-form .form-row {
    margin-top: 0;
    grid-template-columns: minmax(0, 1fr) auto;
}

.role-picker {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.role-picker legend {
    padding: 0;
    margin-bottom: 0.4rem;
    font-size: var(--step--1);
    font-weight: 500;
}

.role-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.5rem;
}

.role-option {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: var(--step--1);
    cursor: pointer;
}

.role-option:has(input:checked) {
    border-color: var(--teal);
    background: var(--teal-soft);
    color: var(--teal-strong);
}

.role-option input {
    accent-color: var(--teal);
    margin: 0;
}

.role-picker-empty {
    margin: 0;
}

.member-count {
    margin: 0 0 0.25rem;
    font-size: var(--step--1);
}

.member-who {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.member-email {
    color: var(--muted);
    font-size: var(--step--1);
    overflow-wrap: anywhere;
}

.member-edit {
    flex-basis: 100%;
    display: grid;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.member-edit .field {
    max-width: 12rem;
}

.invite-row .confirm-box {
    flex-basis: 100%;
}

.inline-edit {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
}

.inline-edit input {
    flex: 1 1 12rem;
    width: auto;
}

.roles-tab .section-lede {
    margin-top: 0;
}

.role-add {
    margin-top: 0;
    margin-bottom: 1rem;
    grid-template-columns: minmax(0, 1fr) auto;
}

.invites .hint {
    margin: 0.5rem 0 1rem;
}

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

.invite-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    padding: 0.6rem 0;
}

.invite-row + .invite-row {
    border-top: 1px solid var(--line);
}

.invite-main {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.invite-email {
    overflow-wrap: anywhere;
}

.invite-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 1rem;
    color: var(--muted);
    font-size: var(--step--1);
}

.invite-actions {
    display: inline-flex;
    gap: 1rem;
}

.tag.tag-ok {
    background: var(--teal-soft);
    color: var(--teal-strong);
}

.tag.tag-closed {
    background: transparent;
    color: var(--muted);
    box-shadow: inset 0 0 0 1px var(--line);
}

.link-button.link-button-danger:not(:disabled) {
    color: var(--error);
}

/* ---------- Small screens ---------- */

@media (max-width: 760px) {
    .signup {
        grid-template-columns: minmax(0, 1fr);
        gap: 1.5rem;
    }

    .signup-rail {
        position: static;
    }

    .progress {
        flex-direction: row;
        align-items: center;
        gap: 1.25rem;
    }

    .progress-mark {
        width: 76px;
        flex: none;
    }

    .progress-steps {
        gap: 0.25rem;
        font-size: var(--step--1);
    }

    .progress-steps li:not(.is-current) {
        display: none;
    }

    .panel {
        padding: 1.5rem 1.25rem;
    }

    h1 {
        font-size: var(--step-2);
    }

    .lede {
        font-size: var(--step-0);
    }

    .field-row {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 760px) {
    .masthead {
        gap: 0.75rem 1rem;
    }

    .app-nav {
        order: 3;
        flex-basis: 100%;
        gap: 1.25rem;
        border-top: 1px solid var(--line);
        padding-top: 0.5rem;
    }

    .account-name {
        display: none;
    }

    .landing-hero h1 {
        font-size: var(--step-3);
    }

    .landing-choices {
        grid-template-columns: minmax(0, 1fr);
    }

    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .console {
        grid-template-columns: minmax(0, 1fr);
        gap: 1.5rem;
    }

    .console-rail {
        position: static;
    }

    .form-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .member-edit .field {
        max-width: none;
    }

    .invite-form .form-row {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    .progress-line,
    .progress-node,
    .progress-center,
    .button {
        transition: none;
    }

    .progress-node.is-current,
    .boot-mark {
        animation: none;
    }
}

/* ---- Branding tab ---- */

.branding-tab .section-lede {
    margin-top: 0;
}

.branding-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 18rem);
    gap: 1.5rem;
    align-items: start;
}

.branding-form {
    margin-top: 0;
}

.branding-form textarea {
    width: 100%;
    font: inherit;
    resize: vertical;
}

.branding-colors {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.color-field {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.color-field input[type="color"] {
    flex: none;
    width: 2.75rem;
    height: 2.5rem;
    padding: 0.15rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    background: var(--surface);
    cursor: pointer;
}

.color-text {
    font-family: var(--mono);
    min-width: 0;
}

.logo-field {
    border: 1px dashed var(--line);
    border-radius: var(--radius-control);
    padding: 0.75rem 1rem 1rem;
    margin: 0;
    min-width: 0;
}

.logo-field legend {
    padding: 0 0.3rem;
    font-weight: 500;
}

.logo-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.file-button {
    cursor: pointer;
}

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

.branding-preview {
    position: sticky;
    top: 1rem;
    display: grid;
    gap: 0.4rem;
}

.preview-label {
    font-size: var(--step--1);
    font-weight: 500;
    color: var(--muted);
}

.preview-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-panel);
    background: var(--surface);
    overflow: hidden;
    padding: 0 1.1rem 1.1rem;
}

.preview-stripe {
    height: 5px;
    margin: 0 -1.1rem 0.9rem;
    background: var(--preview-accent);
}

.preview-brand {
    min-height: 2rem;
    display: flex;
    align-items: center;
    margin-bottom: 0.6rem;
}

.preview-logo {
    max-height: 40px;
    max-width: 100%;
}

.preview-name {
    font-weight: 600;
}

.preview-heading {
    margin: 0 0 0.3rem;
    font-weight: 500;
    font-size: 1.05rem;
}

.preview-welcome {
    margin: 0 0 0.7rem;
    color: var(--muted);
    font-size: var(--step--1);
    overflow-wrap: anywhere;
}

.preview-button {
    display: block;
    text-align: center;
    padding: 0.5rem;
    border-radius: 999px;
    background: var(--preview-primary);
    color: #fff;
    font-weight: 500;
    font-size: var(--step--1);
}

.preview-links {
    display: flex;
    gap: 0.75rem;
    margin: 0.7rem 0 0;
    font-size: 0.8rem;
}

.preview-links span {
    color: var(--preview-primary);
    text-decoration: underline;
}

.preview-footnote {
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted);
    text-align: center;
}

.preview-fake-link {
    text-decoration: underline;
}

@media (max-width: 720px) {
    .branding-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .branding-preview {
        position: static;
    }

    .branding-colors {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Cloudflare Turnstile. Empty unless Cloudflare wants a click. */
.turnstile-slot { display: flex; justify-content: center; }
.turnstile-slot:empty { display: none; }

/* ---------- Apps tab (OIDC clients) ---------- */

.apps-tab .section-lede {
    margin-top: 0;
}

.apps-tab > .actions {
    margin: 0 0 1rem;
}

.connect-details {
    margin: 0 0 1.25rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
}

.connect-details summary {
    cursor: pointer;
    font-weight: 500;
}

.connect-details .facts {
    margin: 0.85rem 0 0.25rem;
}

.app-form {
    flex-basis: 100%;
    margin: 0 0 1.25rem;
}

.app-form textarea {
    width: 100%;
    font-family: var(--mono);
    font-size: var(--step--1);
    line-height: 1.5;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    background: var(--paper);
    color: var(--ink);
    resize: vertical;
}

.app-form textarea:focus-visible {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-soft);
}

/* ---------- Integrations (subscription) ---------- */

.scope-choice {
    align-items: flex-start;
}

.scope-choice input {
    margin-top: 0.15rem;
}

.scope-choice .choice-title {
    display: block;
    font-weight: 500;
}

.scope-choice .hint {
    display: block;
}

.scope-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.app-row .invite-main {
    flex-basis: 100%;
    flex-wrap: wrap;
}

.app-facts {
    flex-basis: 100%;
    display: grid;
    gap: 0.4rem;
    margin: 0.35rem 0 0.25rem;
    font-size: var(--step--1);
}

.app-facts div {
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr);
    gap: 0.75rem;
}

.app-facts dt {
    color: var(--muted);
}

.app-facts dd {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
}

.app-uri {
    display: block;
    flex-basis: 100%;
}

.app-client-id {
    user-select: all;
}

@media (max-width: 560px) {
    .app-facts div {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.1rem;
    }
}

/* ---------- Waiting on the API (ApiActivityIndicator + Hourglass) ---------- */

.api-wait {
    position: fixed;
    left: 50%;
    top: 50%;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: max-content;
    max-width: calc(100vw - 2rem);
    padding: 0.7rem 1.3rem 0.7rem 1rem;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.22);
    font-size: var(--step-0);
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.96);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

.api-wait.is-visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.api-wait-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hourglass {
    flex: none;
    overflow: visible;
}

.hourglass-turn {
    transform-box: fill-box;
    transform-origin: center;
    animation: hourglass-turn 2.4s ease-in-out infinite;
}

.hourglass-cap {
    fill: var(--teal);
}

.hourglass-glass {
    fill: var(--teal-soft);
    stroke: var(--teal);
    stroke-width: 1.6;
    stroke-linejoin: round;
}

.hourglass-sand {
    fill: var(--orange);
    transform-box: fill-box;
}

.hourglass-sand-top {
    transform-origin: 50% 100%;
    animation: hourglass-drain 2.4s linear infinite;
}

.hourglass-sand-bottom {
    transform-origin: 50% 100%;
    animation: hourglass-fill 2.4s linear infinite;
}

.hourglass-stream {
    stroke: var(--orange);
    stroke-width: 1.2;
    stroke-linecap: round;
    stroke-dasharray: 1.5 2;
    animation: hourglass-stream 2.4s linear infinite;
}

/* Sand runs for 80% of the cycle, then the glass turns over. Turned, the full
   bottom bulb sits on top - the same picture the cycle starts from. */
@keyframes hourglass-turn {
    0%, 80% { transform: rotate(0deg); }
    100% { transform: rotate(180deg); }
}

@keyframes hourglass-drain {
    0% { transform: scaleY(1); }
    80%, 100% { transform: scaleY(0); }
}

@keyframes hourglass-fill {
    0% { transform: scaleY(0); }
    80%, 100% { transform: scaleY(1); }
}

@keyframes hourglass-stream {
    0% { opacity: 1; stroke-dashoffset: 0; }
    76% { opacity: 1; stroke-dashoffset: -14; }
    80%, 100% { opacity: 0; stroke-dashoffset: -14; }
}

@keyframes hourglass-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

@media (max-width: 520px) {
    .api-wait {
        border-radius: var(--radius-panel);
    }

    .api-wait-text {
        white-space: normal;
    }
}

@media (prefers-reduced-motion: reduce) {
    .api-wait {
        transition: none;
    }

    .hourglass-turn,
    .hourglass-sand-top,
    .hourglass-sand-bottom,
    .hourglass-stream {
        animation: none;
    }

    .hourglass-sand-top,
    .hourglass-sand-bottom {
        transform: scaleY(0.5);
    }

    .hourglass {
        animation: hourglass-pulse 2s ease-in-out infinite;
    }
}

/* ---------- Role hosting (Apps tab) and role keys (Roles tab) ---------- */

.role-hosting {
    margin: 0 0 1.25rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    display: grid;
    gap: 0.5rem;
}

.role-hosting-title {
    margin: 0;
    font-size: var(--step-0);
    font-weight: 500;
}

.role-hosting .hint {
    margin: 0;
}

.role-key {
    color: var(--muted);
    font-size: var(--step--1);
}
