/* The builder's own chrome. Deliberately separate from the host's stylesheets: those are what a
   theme is previewed on, and the editor around the preview must not change as the theme does.

   It is also deliberately colourless. A colour is judged by what surrounds it, so the builder is
   greys and graphite only, and the theme being made is the one colourful thing on the screen.
   Colour in the chrome is kept for status: connected, saved, failing. */
:root {
    --tb-bg: #eceef1;
    --tb-panel: #ffffff;
    --tb-sunken: #f4f5f7;
    --tb-ink: #22262c;
    --tb-muted: #626973;
    --tb-line: #e1e4e8;
    --tb-field: #8d939c;
    --tb-accent: #2b3038;
    --tb-accent-hover: #15181d;
    --tb-on-accent: #ffffff;
    --tb-good: #1d7a3a;
    --tb-warn: #8a5a00;
    --tb-bad: #b3261e;
    --tb-radius: 12px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --tb-bg: #15171a;
        --tb-panel: #1f2226;
        --tb-sunken: #191b1e;
        --tb-ink: #e7e9ec;
        --tb-muted: #a2a8b1;
        --tb-line: #2e3237;
        --tb-field: #6c727b;
        --tb-accent: #e7e9ec;
        --tb-accent-hover: #ffffff;
        --tb-on-accent: #15171a;
        --tb-good: #7fd39a;
        --tb-warn: #e8bf6a;
        --tb-bad: #ff8f86;
        color-scheme: dark;
    }
}

/* the builder's root. The tenant app's root is #app too, and its app.css - which the Templates
   page loads for the designer - pins that to the window with its overflow hidden, which would stop
   the whole builder scrolling there */
#app {
    position: static;
    overflow: visible;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    background: var(--tb-bg);
    color: var(--tb-ink);
    font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* the Templates and Pages pages load the host's stylesheets for chx4-web's designer, so what they
   set on plain elements - links, labels, code, checkboxes - is set again here, for the builder's own
   parts. And only for those: :where() keeps these out of the designer (.tb-designer), which is drawn
   as a site draws it, without making them any harder for its own rules to beat */
a:where(:not(.tb-designer *)) {
    color: var(--tb-ink);
    text-decoration: underline;
    text-decoration-color: var(--tb-field);
    text-underline-offset: 0.18em;
}

a:where(:not(.tb-designer *)):hover {
    text-decoration-color: currentColor;
}

:focus-visible {
    outline: 2px solid var(--tb-accent);
    outline-offset: 2px;
}

h1:where(:not(.tb-designer *)) {
    font-size: 1.5rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    line-height: 1.25;
    margin: 0 0 0.5rem;
}

h2:where(:not(.tb-designer *)) {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.75rem;
}

code:where(:not(.tb-designer *)) {
    font-size: 0.9em;
    color: inherit;
}

input:where([type="checkbox"], [type="radio"]):where(:not(.tb-designer *)) {
    accent-color: var(--tb-accent);
}

/* the masthead: the steps of making a theme on the left, the builder's housekeeping on the right */
.tb-masthead {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0 2rem;
    padding: 0 1.25rem;
    background: var(--tb-panel);
    border-bottom: 1px solid var(--tb-line);
}

.tb-brand {
    display: flex;
    align-items: center;
    font-weight: 650;
    color: var(--tb-ink);
    text-decoration: none;
}

.tb-nav,
.tb-nav-aside {
    display: flex;
    align-items: stretch;
    gap: 1.25rem;
}

.tb-nav {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.tb-nav a,
.tb-nav-aside a {
    display: flex;
    align-items: center;
    padding: 0.85rem 0;
    white-space: nowrap;
    color: var(--tb-muted);
    text-decoration: none;
    box-shadow: inset 0 -2px 0 transparent;
}

.tb-nav-aside a {
    font-size: 0.875rem;
}

.tb-nav a:hover,
.tb-nav-aside a:hover {
    color: var(--tb-ink);
}

.tb-nav a.active,
.tb-nav-aside a.active {
    color: var(--tb-ink);
    box-shadow: inset 0 -2px 0 var(--tb-ink);
}

.tb-hub {
    font-size: 0.8125rem;
    color: var(--tb-muted);
}

/* the masthead's status, which links to About */
a.tb-hub {
    display: flex;
    align-items: center;
    text-decoration: none;
}

a.tb-hub:hover {
    text-decoration: underline;
}

.tb-hub::before {
    content: "";
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    margin-right: 0.4rem;
    border-radius: 50%;
    background: currentColor;
}

/* doubled, to stay ahead of the masthead's link colours */
.tb-hub.tb-hub-connected { color: var(--tb-muted); }
.tb-hub.tb-hub-connected::before { background: var(--tb-good); }
.tb-hub.tb-hub-connecting { color: var(--tb-warn); }
.tb-hub.tb-hub-offline { color: var(--tb-bad); }

@media (max-width: 720px) {
    .tb-masthead {
        gap: 0 1.25rem;
    }

    .tb-nav {
        order: 3;
        flex-basis: 100%;
        border-top: 1px solid var(--tb-line);
    }
}

main {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
}

main:focus {
    outline: none;
}

/* panels are set apart by the page around them, not by outlines */
.tb-card {
    background: var(--tb-panel);
    border: 1px solid transparent;
    border-radius: var(--tb-radius);
    padding: 1.5rem;
    margin: 0 0 1rem;
}

.tb-card label {
    display: block;
    font-weight: 400;
    margin-bottom: 1rem;
    color: var(--tb-muted);
    font-size: 0.875rem;
}

.tb-card input {
    display: block;
    width: 100%;
    max-width: 24rem;
    margin-top: 0.3rem;
    padding: 0.45rem 0.6rem;
    font: inherit;
    font-size: 0.9375rem;
    color: var(--tb-ink);
    background: var(--tb-panel);
    border: 1px solid var(--tb-field);
    border-radius: 6px;
}

.tb-button {
    font: inherit;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: 6px;
    background: var(--tb-accent);
    color: var(--tb-on-accent);
    cursor: pointer;
}

.tb-button:hover {
    background: var(--tb-accent-hover);
}

.tb-button:disabled {
    opacity: 0.4;
    cursor: default;
}

.tb-button:disabled:hover {
    background: var(--tb-accent);
}

/* tabs: the chosen one underlined, the rest plain text */
.tb-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    border-bottom: 1px solid var(--tb-line);
}

.tb-tabs button {
    font: inherit;
    font-size: 0.875rem;
    padding: 0.4rem 0;
    margin-bottom: -1px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--tb-muted);
    cursor: pointer;
}

.tb-tabs button:hover {
    color: var(--tb-ink);
}

.tb-tabs button[aria-selected="true"] {
    color: var(--tb-ink);
    border-bottom-color: var(--tb-ink);
}

.tb-error { color: var(--tb-bad); }
.tb-notice { color: var(--tb-muted); }

/* a warning worth stopping for, without shouting it */
.tb-caution {
    padding: 0.1rem 0 0.1rem 0.85rem;
    border-left: 3px solid var(--tb-warn);
}

.tb-loading {
    display: grid;
    place-items: center;
    min-height: 100vh;
    color: var(--tb-muted);
}

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    padding: 0.75rem 1rem;
    background: #ffe9a8;
    color: #1d2128;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    float: right;
}

/* ---- The colour scheme editor ---- */

main:has(.tb-editor) {
    max-width: 1400px;
}

/* the builder's group headings: only in its own panels, so chx4-web's designer, which has h3s of
   its own (its column headings, its blocks' titles), keeps the host's */
.tb-card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--tb-muted);
    margin: 1.5rem 0 0.4rem;
}

.tb-editor {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0 1rem;
    margin-top: 1.5rem;
}

@media (min-width: 1100px) {
    .tb-editor {
        grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
        align-items: start;
    }

    .tb-editor-preview {
        position: sticky;
        top: 1rem;
    }
}

.tb-card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.tb-card-heading h1,
.tb-card-heading h2 {
    margin: 0;
}

.tb-row {
    display: inline-flex;
    gap: 0.5rem;
}

.tb-hint {
    color: var(--tb-muted);
    font-size: 0.8125rem;
}

.tb-good { color: var(--tb-good); }
.tb-bad { color: var(--tb-bad); }

/* secondary actions read as text until pointed at */
.tb-button-quiet {
    background: transparent;
    color: var(--tb-ink);
    padding: 0.35rem 0.6rem;
    text-decoration: underline;
    text-decoration-color: var(--tb-field);
    text-underline-offset: 0.18em;
}

.tb-button-quiet:hover,
.tb-button-quiet:disabled:hover {
    background: var(--tb-sunken);
}

.tb-presets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
    gap: 0.25rem;
    margin: 0 -0.4rem 1.25rem;
}

/* tiles to choose from: the swatch or sample carries them, so no box of their own */
.tb-preset {
    font: inherit;
    font-size: 0.8125rem;
    color: var(--tb-ink);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.4rem;
    cursor: pointer;
    text-align: left;
}

.tb-preset:hover {
    background: var(--tb-sunken);
}

.tb-preset-swatches {
    display: flex;
    height: 2rem;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 0.35rem;
    box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08);
}

.tb-preset-swatches span {
    flex: 1;
}

.tb-generate {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.75rem 1rem;
}

.tb-card .tb-generate label {
    margin: 0;
}

.tb-card select {
    display: block;
    margin-top: 0.3rem;
    padding: 0.45rem 0.5rem;
    font: inherit;
    font-size: 0.9375rem;
    color: var(--tb-ink);
    background: var(--tb-panel);
    border: 1px solid var(--tb-field);
    border-radius: 6px;
}

/* its own line under its label, like a select's */
.tb-colour-input {
    display: flex;
    width: fit-content;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.3rem;
}

.tb-card .tb-colour-input input[type="color"] {
    width: 2.5rem;
    height: 2.25rem;
    padding: 0.15rem;
    margin: 0;
    cursor: pointer;
}

.tb-card .tb-colour-input input.tb-hex {
    width: 6.5rem;
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.8125rem;
}

.tb-colour-row {
    padding: 0.75rem 0;
    border-top: 1px solid var(--tb-line);
}

.tb-colour-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.tb-colour-head .tb-colour-input {
    margin: 0;
}

.tb-colour-text {
    display: flex;
    flex: 1 1 12rem;
    flex-direction: column;
    min-width: 0;
}

.tb-colour-text code {
    font-size: 0.8125rem;
}

.tb-shades {
    display: flex;
    height: 0.75rem;
    margin-top: 0.6rem;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08);
}

.tb-shades span {
    flex: 1;
}

.tb-checks {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tb-check {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--tb-line);
}

.tb-check-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tb-check-text code {
    font-size: 0.75rem;
}

.tb-sample {
    display: inline-grid;
    place-items: center;
    width: 2.75rem;
    height: 2rem;
    border-radius: 6px;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.1);
}

.tb-ratio {
    font-variant-numeric: tabular-nums;
    text-align: right;
    font-size: 0.875rem;
}

.tb-verdict {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
}

.tb-check-pass .tb-verdict { color: var(--tb-good); }
.tb-check-fail .tb-verdict { color: var(--tb-bad); }

.tb-preview-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 1rem;
}

.tb-card .tb-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.tb-card .tb-inline input {
    margin: 0;
    width: 12rem;
}

/* a Site Header or Site Footer beside its editor; a phone's width shows the header's menu opening */
.tb-chrome-frame {
    display: grid;
    gap: 0.5rem;
}

.tb-chrome-frame-holder {
    overflow: hidden;
}

.tb-chrome-frame iframe {
    display: block;
    width: 100%;
    height: 200px;
    border: 1px solid var(--tb-line);
    border-radius: 8px;
    background: #fff;
}

.tb-chrome-frame iframe.tb-chrome-frame-phone {
    width: 390px;
    max-width: 100%;
    height: 640px;
}

/* the theme itself: the one framed thing on the page */
.tb-preview iframe {
    display: block;
    width: 100%;
    height: 70vh;
    min-height: 420px;
    border: 1px solid var(--tb-line);
    border-radius: 8px;
    background: #fff;
}

.tb-css {
    margin: 0 0 0.5rem;
    padding: 0.85rem 1rem;
    max-height: 18rem;
    overflow: auto;
    background: var(--tb-sunken);
    border-radius: 8px;
    font-size: 0.8125rem;
}

a.tb-button {
    display: inline-block;
    text-decoration: none;
}

/* ---- Projects, fonts and the account's saved copy ---- */

:root {
    --tb-system-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.tb-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.tb-project-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 1rem;
    margin: 0;
    font-size: 0.875rem;
    color: var(--tb-muted);
}

.tb-project-bar strong {
    color: var(--tb-ink);
    font-weight: 600;
}

.tb-save {
    color: var(--tb-muted);
}

.tb-save::before {
    content: "";
    display: inline-block;
    width: 0.45rem;
    height: 0.45rem;
    margin-right: 0.4rem;
    border-radius: 50%;
    background: currentColor;
}

.tb-save-saved { color: var(--tb-muted); }
.tb-save-saved::before { background: var(--tb-good); }
.tb-save-saving { color: var(--tb-warn); }
.tb-save-notsaved { color: var(--tb-bad); }

.tb-button-danger,
.tb-button-danger:hover {
    background: var(--tb-bad);
    color: var(--tb-panel);
}

.tb-selected {
    border-color: var(--tb-accent) !important;
    box-shadow: 0 0 0 1px var(--tb-accent);
}

/* a whole panel chosen: its outline alone is enough */
.tb-card.tb-selected {
    box-shadow: none;
}

.tb-callout {
    border-color: var(--tb-field);
}

.tb-recovery-key {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 1.15rem;
    letter-spacing: 0.05em;
    padding: 0.75rem;
    background: var(--tb-sunken);
    border: 1px dashed var(--tb-field);
    border-radius: 6px;
    word-break: break-all;
}

.tb-card .tb-check-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0;
    color: var(--tb-ink);
}

.tb-card .tb-check-label input {
    display: inline;
    width: auto;
    margin: 0;
}

.tb-card input.tb-mono {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.tb-pairings {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
    gap: 0.25rem;
    margin: 0 -0.75rem;
}

.tb-pairing {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    text-align: left;
    font: inherit;
    color: var(--tb-ink);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    cursor: pointer;
}

.tb-pairing:hover {
    background: var(--tb-sunken);
}

.tb-pairing-heading {
    font-size: 1.3rem;
    line-height: 1.2;
}

.tb-pairing-body {
    font-size: 0.875rem;
}

.tb-font-picker {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.tb-card label.tb-font-option {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin: 0;
    padding: 0.4rem 0;
    border-top: 1px solid var(--tb-line);
    color: var(--tb-ink);
    cursor: pointer;
}

.tb-card label.tb-font-option input {
    display: inline;
    width: auto;
    margin: 0;
}

.tb-font-name {
    font-size: 1.15rem;
}

.tb-custom-font {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.tb-card .tb-custom-font input {
    flex: 1 1 14rem;
    margin: 0;
}

.tb-card .tb-custom-font select {
    margin: 0;
}

.tb-themes {
    list-style: none;
    margin: 1.5rem 0 0;
    padding: 0;
}

.tb-theme {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
}

.tb-theme-swatch {
    display: flex;
    gap: 3px;
    padding: 6px;
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.1);
}

.tb-theme-swatch span {
    width: 1.1rem;
    height: 2rem;
    border-radius: 3px;
}

.tb-theme-text {
    display: flex;
    flex-direction: column;
    flex: 1 1 14rem;
    min-width: 0;
}

.tb-theme-actions {
    flex-wrap: wrap;
    align-items: center;
}

.tb-card input.tb-rename {
    margin: 0;
}

.tb-card label.tb-inline-label {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    color: var(--tb-ink);
}

.tb-card label.tb-inline-label select {
    margin: 0;
}

/* ---- Packaging ---- */

.tb-card textarea {
    display: block;
    width: 100%;
    margin-top: 0.3rem;
    padding: 0.45rem 0.6rem;
    font: inherit;
    font-size: 0.9375rem;
    color: var(--tb-ink);
    background: var(--tb-panel);
    border: 1px solid var(--tb-field);
    border-radius: 6px;
    resize: vertical;
}

.tb-card label .tb-hint {
    display: block;
    margin-top: 0.3rem;
}

.tb-issues {
    list-style: none;
    margin: 0 0 1.25rem;
    padding: 0;
}

.tb-issue {
    padding: 0.5rem 0;
    border-top: 1px solid var(--tb-line);
}

.tb-issue .tb-verdict {
    display: inline;
    margin-right: 0.5rem;
}

.tb-issue-blocking .tb-verdict,
.tb-issue-willberefused .tb-verdict { color: var(--tb-bad); }
.tb-issue-advice .tb-verdict { color: var(--tb-muted); }

.tb-facts {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.35rem 1.25rem;
    margin: 0 0 1rem;
}

.tb-facts dt {
    color: var(--tb-muted);
}

.tb-facts dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.tb-steps {
    padding-left: 1.25rem;
}

.tb-steps li {
    margin-bottom: 0.5rem;
}

.tb-steps li::marker {
    color: var(--tb-muted);
}

.tb-steps .tb-button {
    margin-left: 0.25rem;
}

/* ---- Blocks ---- */

@media (min-width: 1100px) {
    .tb-editor.tb-blocks {
        grid-template-columns: minmax(0, 2fr) minmax(0, 5fr);
    }
}

.tb-block-list,
.tb-images {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.5rem;
}

.tb-block-list {
    gap: 0.125rem;
    margin: 0 -0.75rem;
}

.tb-block-choice {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font: inherit;
    text-align: left;
    color: var(--tb-ink);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
}

.tb-block-choice:hover {
    background: var(--tb-sunken);
}

.tb-upload {
    display: inline-block;
    margin-bottom: 0.75rem;
}

.tb-card label.tb-upload {
    color: var(--tb-on-accent);
    font-size: inherit;
}

.tb-images li {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.tb-images img {
    width: 5rem;
    height: 5rem;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--tb-line);
    flex: none;
}

.tb-image-text {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
    flex: 1;
    overflow-wrap: anywhere;
}

.tb-card .tb-image-text input {
    margin: 0;
}

.tb-field {
    margin-bottom: 1.25rem;
}

.tb-card .tb-field > label,
.tb-label {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--tb-muted);
    font-size: 0.875rem;
}

.tb-card .tb-field select {
    font: inherit;
    font-size: 0.9375rem;
    padding: 0.45rem 0.5rem;
    color: var(--tb-ink);
    background: var(--tb-panel);
    border: 1px solid var(--tb-field);
    border-radius: 6px;
}

.tb-card .tb-field .tb-hint {
    display: block;
    margin-top: 0.3rem;
}

.tb-block-editor .tb-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0 2rem;
}

.tb-card .tb-colour-choice input[type="color"] {
    width: 3rem;
    height: 2.25rem;
    padding: 2px;
}

.tb-settings {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0.5rem;
}

.tb-settings th {
    text-align: left;
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--tb-muted);
    padding: 0 0.5rem 0.25rem 0;
}

.tb-settings td {
    padding: 0.25rem 0.5rem 0.25rem 0;
}

.tb-card .tb-settings input {
    margin: 0;
    max-width: none;
}

/* chx4-web's CSS editor: a textarea until CodeMirror takes it over */
.tb-card .tb-code {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.875rem;
}

.tb-card .CodeMirror {
    border: 1px solid var(--tb-line);
    border-radius: 8px;
}

/* its Format button, Bootstrap-classed, drawn as the builder's quiet buttons */
.css-editor-toolbar {
    margin-top: 0.4rem;
}

.css-editor-toolbar .btn {
    font: inherit;
    font-size: 0.8125rem;
    padding: 0.25rem 0.5rem;
    color: var(--tb-muted);
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

.css-editor-toolbar .btn:hover:not(:disabled) {
    color: var(--tb-ink);
    background: var(--tb-sunken);
}

.css-editor-toolbar .btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.css-editor-toolbar .text-muted {
    color: var(--tb-muted);
    font-size: 0.8125rem;
}

/* chx4-web's BlockContentEditor writes Bootstrap's form markup, and the builder has no Bootstrap:
   its fields are given the look of the builder's own */
.tb-block-editor .form-group {
    margin-bottom: 1.25rem;
}

.tb-card .tb-block-editor .form-group > label {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--tb-muted);
    font-size: 0.875rem;
}

.tb-block-editor .form-group > small,
.tb-block-editor .alert-warning {
    display: block;
    margin: 0.3rem 0;
}

.tb-block-editor .text-muted,
.tb-block-editor .alert-warning {
    color: var(--tb-muted);
    font-size: 0.8125rem;
}

/* chx4-web's EditorTabs, on the Blocks page where there's no Bootstrap to draw them: as the
   builder's own tabs */
/* a <menu> of <li>s, as the app draws its tabs: without a list's indent and margins */
.tb-block-editor .editor-tabs-list {
    display: flex;
    gap: 1.25rem;
    list-style: none;
    padding: 0;
    border-bottom: 1px solid var(--tb-line);
    margin: 0 0 1rem;
}

.tb-block-editor .editor-tabs-list .nav-link {
    font: inherit;
    font-size: 0.875rem;
    padding: 0.4rem 0;
    margin-bottom: -1px;
    color: var(--tb-muted);
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}

.tb-block-editor .editor-tabs-list .nav-link:hover {
    color: var(--tb-ink);
}

.tb-block-editor .editor-tabs-list .nav-link.active {
    color: var(--tb-ink);
    border-bottom-color: var(--tb-ink);
}

.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;
}

/* ---- Templates ---- */

.tb-template-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin: 0 -0.75rem;
}

.tb-template-list .tb-block-choice {
    width: auto;
    min-width: 12rem;
}

/* chx4-web's page designer, on the site's stylesheets: it brings its own look, so it sits on the
   site's light background rather than the builder's */
.tb-designer {
    margin: 0 0 1rem;
    padding: 1rem;
    border-radius: var(--tb-radius);
    background: #ffffff;
    color: var(--body, #1d2128);
    /* the text a site's page has: on a site it inherits the host's html font, which the builder's
       body would otherwise come between */
    font-family: var(--font-family-body, system-ui);
    font-size: 16px;
    line-height: 1.25rem;
}

main:has(.tb-designer) {
    max-width: 1600px;
}

main:has(.tb-designer) > .tb-card:first-of-type {
    margin-top: 1.5rem;
}

/* ---- A page's heading, and its notes ---- */

.tb-page-heading {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 0.5rem;
}

.tb-page-heading h1 {
    margin: 0;
}

/* a quiet ring until it's open */
.tb-help-toggle {
    display: inline-grid;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1;
    color: var(--tb-muted);
    background: transparent;
    border: 1px solid var(--tb-field);
    border-radius: 50%;
    cursor: pointer;
}

.tb-help-toggle:hover {
    color: var(--tb-ink);
    border-color: var(--tb-ink);
}

.tb-help-toggle[aria-expanded="true"] {
    color: var(--tb-on-accent);
    background: var(--tb-accent);
    border-color: var(--tb-accent);
}

.tb-help {
    max-width: 72ch;
    margin: 0.75rem 0 1.25rem;
    padding: 1rem 1.25rem;
    background: var(--tb-panel);
    border-radius: var(--tb-radius);
    font-size: 0.875rem;
}

.tb-help p,
.tb-help ul {
    margin: 0 0 0.6rem;
}

.tb-help ul {
    padding-left: 1.1rem;
}

.tb-help li + li {
    margin-top: 0.3rem;
}

.tb-help .tb-help-more {
    margin: 0.75rem 0 0;
    color: var(--tb-muted);
}

/* ---- Home: how a theme fits together ---- */

.tb-flows {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
    gap: 0.5rem 2rem;
}

.tb-card .tb-flows h3 {
    margin-top: 0;
}

/* a sequence, each step joined to the next by a short rule */
.tb-flow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0;
    margin: 0 0 0.5rem;
    padding: 0;
    list-style: none;
}

.tb-flow li {
    display: flex;
    align-items: center;
}

.tb-flow li + li::before {
    content: "";
    width: 1.25rem;
    height: 1px;
    margin: 0 0.4rem;
    background: var(--tb-field);
}

.tb-flow span {
    padding: 0.3rem 0.65rem;
    background: var(--tb-sunken);
    border-radius: 6px;
    font-size: 0.875rem;
}

/* ---- Pages ---- */

/* what a new page starts from, beside the button that adds it */
.tb-add-page {
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
}

.tb-card .tb-add-page label.tb-inline-label {
    margin: 0;
    font-size: 0.875rem;
    color: var(--tb-muted);
}


/* ---- Stylesheet ---- */

.tb-reference {
    margin-top: 1rem;
    font-size: 0.875rem;
}

.tb-reference summary {
    cursor: pointer;
    color: var(--tb-muted);
}

.tb-reference li {
    margin-bottom: 0.35rem;
}

.tb-settings td .tb-error,
.tb-settings td .tb-hint {
    display: block;
    font-size: 0.8125rem;
    margin-top: 0.2rem;
}

.tb-card label.tb-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--tb-ink);
}

.tb-card label.tb-checkbox input {
    width: auto;
    margin: 0;
}

/* a block's readability, under its colours */
.tb-block-check {
    margin: 0 0 1rem;
    padding: 0;
}
