/* /css/pages/construct.css — /<slug> UIs + dashboard Construct Shell (morphed into #dash).
 * Colors: --craft-* tokens only; do NOT reintroduce standalone :root palette.
 * Scope: .shell or .page--construct — prevents .card/.topbar/.live-pill collisions.
 *
 *     ┌──────────┬───────────────────────────────────────────┐
 *     │ sidebar  │ topbar  (route crumb · title · Live pill)  │
 *     │ (Shared, ├───────────────────────────────────────────┤
 *     │  Mine,   │ content   (#content-area — active           │
 *     │  New…)   │            construct's body morphs in)      │
 *     │  footer  ├───────────────────────────────────────────┤
 *     │  status  │ input-bar  (intent → POST /…/intent)        │
 *     └──────────┴───────────────────────────────────────────┘ */

/* ── Local vars: radius + fonts only; colors from craft.css ── */
.shell, .page--construct {
    --shell-radius:    10px;
    --shell-radius-sm: 7px;
    --shell-font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --shell-font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
}

/* ── /<slug> ui page wrapper — contains #construct-view morph target (brain DO snapshots-on-connect) ── */

.page--construct {
    min-height: calc(100svh - var(--space-2xl));
    padding: var(--space-l) var(--space-s);
    max-width: 760px;
    margin: 0 auto;
}
.page--construct .construct-body {
    background: var(--craft-surface);
    border: 1px solid var(--craft-line);
    border-radius: var(--shell-radius);
    padding: var(--space-l) var(--space-m);
    min-height: 200px;
}
/* Editor renders a fixed full-viewport .shell — the flow wrapper must reserve no space, else its padding/min-height create a phantom scroll behind the shell. */
.page--construct:has(.shell) { min-height: 0; padding: 0; }
.page--construct:has(.shell) .construct-body { min-height: 0; padding: 0; border: 0; background: none; }
.page--construct .content-empty {
    color: var(--craft-text-muted);
    font-size: var(--step-0);
    text-align: center;
    padding: var(--space-l) 0;
}

/* ── Quarantined notice (craft#21) — replaces ui in #construct-view; TOS link to readable terms ── */
.page--construct .construct-disabled {
    text-align: center;
    padding: var(--space-m) var(--space-s);
}
.page--construct .construct-disabled-headline {
    margin: 0 0 var(--space-s);
    font-size: var(--step-1);
    font-weight: 700;
    line-height: 1.45;
    text-wrap: balance;
}
.page--construct .construct-disabled-headline a {
    color: var(--craft-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.page--construct .construct-disabled-headline a:hover {
    color: var(--craft-accent-hover);
}
.page--construct .construct-disabled-body {
    margin: 0;
    color: var(--craft-text-muted);
    font-size: var(--step-0);
}
/* Copy-paste diagnostic block for a Broken (undecodable) construct — link/slug/reason, monospace + selectable (craft#53). */
.page--construct .construct-disabled-diag {
    display: inline-block;
    margin: var(--space-s) auto;
    padding: var(--space-s);
    text-align: left;
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: var(--step--1);
    white-space: pre-wrap;
    word-break: break-all;
    background: var(--craft-surface-sunken, rgba(127, 127, 127, 0.12));
    border-radius: var(--radius-s, 6px);
    user-select: all;
}

/* ── Composed system diagnostics (/health parity) ── reuses health.css shell (38rem column).
 * Neutralize editor .shell rules (position:fixed + 248/1fr grid) so it stacks inline like /health;
 * drop the standalone-page min-height. */
.construct-diagnostics.page--health {
    min-height: 0;
    margin-block-start: var(--space-l);
    background-image: none; /* the construct page owns the backdrop */
}
.construct-diagnostics .shell {
    position: static;
    display: block;
    overflow: visible;
}

/* ── Construct Shell (dashboard's member view) ─────────────────────────── */

.shell {
    /* Escape .page--dashboard 480px centering; construct surface fills viewport.
     * top: --craft-toolbar-h clears sticky toolbar; internal grid owns height. */
    position: fixed;
    top: var(--craft-toolbar-h, 44px);
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    /* minmax(0,1fr): the content column must shrink below its content's min-content, else a wide child (the edit toolbar) clips against `overflow:hidden`. */
    grid-template-columns: 240px minmax(0, 1fr);
    overflow: hidden;
    background: var(--craft-bg);
}

/* ── LEFT SIDEBAR ────────────────────────────────────────────────────────── */

.shell .sidebar {
    display: flex;
    flex-direction: column;
    background: var(--craft-surface);
    border-right: 1px solid var(--craft-line);
    min-height: 0;
}
.shell .sidebar-head {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--craft-line);
    flex: 0 0 auto;
}
.shell .sidebar-head .logo { font-size: 20px; line-height: 1; }
.shell .sidebar-head .wordmark {
    font-family: var(--shell-font-mono);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.02em;
    color: var(--craft-text);
}

.shell .sidebar-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 8px 0;
}

.shell .ws-section { padding: 10px 0 4px; }
.shell .ws-section > .ws-label {
    display: block;
    padding: 4px 18px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--craft-text-dim);
}

/* Active: accent left rail + glow tint. */
.shell .ws-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    border-left: 2px solid transparent;
    padding: 8px 18px;
    cursor: pointer;
    color: inherit;
    text-decoration: none;
}
.shell .ws-item:hover { background: var(--craft-hover-tint); }
/* Owner-only delete affordance (#70) — reveals on row hover/focus; the dispatch is in editor_sidebar.html. */
.shell .ws-del {
    flex: none;
    opacity: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 6px;
}
.shell .ws-item:hover .ws-del,
.shell .ws-del:focus-visible { opacity: 0.6; }
.shell .ws-del:hover { opacity: 1; background: color-mix(in srgb, var(--craft-err, #e5484d) 22%, transparent); }
.shell .ws-item.is-active {
    background: var(--craft-accent-glow);
    border-left-color: var(--craft-accent);
}
.shell .ws-item .ws-name {
    flex: 1;
    min-width: 0;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--craft-text);
}
.shell .ws-item .ws-route {
    display: block;
    font-family: var(--shell-font-mono);
    font-size: 11.5px;
    color: var(--craft-text-dim);
    margin-top: 1px;
}
.shell .ws-item .ws-meta {
    display: block;
    font-size: 11px;
    color: var(--craft-text-dim);
    margin-top: 2px;
}

/* Dashed "New Construct…" affordance. */
.shell .ws-new {
    display: block;
    width: calc(100% - 24px);
    margin: 12px 12px 4px;
    padding: 9px 12px;
    border: 1px dashed var(--craft-line);
    border-radius: var(--shell-radius-sm);
    background: none;
    color: var(--craft-text-muted);
    font-family: var(--shell-font-mono);
    font-size: 12.5px;
    cursor: pointer;
    transition: border-color 0.12s ease, color 0.12s ease;
}
.shell .ws-new:hover {
    border-color: var(--craft-accent);
    color: var(--craft-accent);
}

.shell .sidebar-foot {
    flex: 0 0 auto;
    padding: 10px 18px;
    border-top: 1px solid var(--craft-line);
    font-family: var(--shell-font-mono);
    font-size: 11px;
    color: var(--craft-text-dim);
    display: flex;
    align-items: center;
    gap: 6px;
}
.shell .sidebar-foot .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--craft-ok);
}

/* ── MAIN COLUMN — topbar / content / input-bar ────────────────────────── */

.shell .main {
    display: grid;
    /* content fills, input-bar sits at its natural height. No shell .topbar is rendered, so there is no third row. */
    grid-template-rows: 1fr auto;
    min-width: 0;
    min-height: 0;
}

/* Shell-local topbar (distinct from page .app-toolbar) — route crumb + title + live pill. */
.shell .topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 22px;
    background: var(--craft-surface);
    border-bottom: 1px solid var(--craft-line);
}
.shell .topbar .crumb {
    font-family: var(--shell-font-mono);
    font-size: 12px;
    color: var(--craft-text-dim);
}
.shell .topbar .crumb .sep   { margin: 0 5px; opacity: 0.6; }
.shell .topbar .crumb .route { color: var(--craft-text-muted); }
.shell .topbar .title {
    font-size: 15px;
    font-weight: 600;
    color: var(--craft-text);
}
.shell .topbar .live-pill {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--craft-ok) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--craft-ok) 34%, transparent);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--craft-ok);
}
.shell .topbar .live-pill .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--craft-ok);
}

/* ── CONTENT AREA ────────────────────────────────────────────────────────── */

.shell .content {
    min-height: 0;
    overflow-y: auto;
    padding: 26px 28px;
}
/* Editor edit surface is its own tight full-bleed workspace — drop the content padding/scroll and let it own the viewport. */
.shell .content:has(.edit-surface) {
    padding: 0;
    overflow: hidden;
}

.shell .sc { max-width: 760px; }
.shell .sc > * + * { margin-top: 18px; }
.shell .section-head {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--craft-text-dim);
}
.shell .card {
    background: var(--craft-surface);
    border: 1px solid var(--craft-line);
    border-radius: var(--shell-radius);
    padding: 18px 20px;
}
.shell .card .card-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 6px;
    color: var(--craft-text);
}
.shell .card .card-body { color: var(--craft-text-muted); }

.shell .dtable {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.shell .dtable th, .shell .dtable td {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--craft-line);
}
.shell .dtable th {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--craft-text-dim);
    font-weight: 600;
}
.shell .dtable tr:last-child td { border-bottom: 0; }

.shell .verse-card {
    border-left: 3px solid var(--craft-accent);
    background: var(--craft-accent-glow);
}
.shell .verse-card blockquote {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    color: var(--craft-text);
}

.shell .content-empty {
    color: var(--craft-text-muted);
    font-size: 14px;
}
.shell .content-empty code {
    font-family: var(--shell-font-mono);
    background: var(--craft-surface-2);
    border: 1px solid var(--craft-line);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 12.5px;
}

/* ── BOTTOM INTENT BAR ───────────────────────────────────────────────────── */

.shell .input-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 22px;
    background: var(--craft-surface);
    border-top: 1px solid var(--craft-line);
}
.shell .input-bar form {
    display: flex;
    flex: 1 1 auto;
    gap: 10px;
}
.shell .input-bar input {
    flex: 1 1 auto;
    padding: 11px 14px;
    font-family: var(--shell-font-sans);
    font-size: 14px;
    color: var(--craft-text);
    background: var(--craft-bg);
    border: 1px solid var(--craft-line);
    border-radius: var(--shell-radius-sm);
}
.shell .input-bar input::placeholder { color: var(--craft-text-dim); }
.shell .input-bar input:focus-visible {
    outline: 2px solid var(--craft-accent);
    outline-offset: 1px;
    background: var(--craft-surface);
}
.shell .input-bar .send {
    flex: 0 0 auto;
    padding: 11px 18px;
    font-family: var(--shell-font-mono);
    font-weight: 700;
    font-size: 13px;
    color: var(--craft-accent-ink);
    background: var(--craft-accent);
    border: 0;
    border-radius: var(--shell-radius-sm);
    cursor: pointer;
    transition: filter 0.12s ease, transform 0.12s ease;
}
.shell .input-bar .send:hover  { filter: brightness(1.07); }
.shell .input-bar .send:active { transform: translateY(1px); }
.shell .input-bar .send:focus-visible {
    outline: 2px solid var(--craft-text);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .shell .ws-new, .shell .input-bar .send { transition: none; }
}

/* ── UGC-origin chrome (.io standalone page) — platform chrome is ONE floating ☰ layer top-right; the construct owns the whole viewport (no bar, zero layout effect on the untrusted body). */
body.page--ui { margin: 0; }
.page--ui .ugc-fab {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 70;
    font-family: var(--shell-font-mono, ui-monospace, monospace);
    font-size: 12px;
    color: var(--craft-text, #e8e8ea);
}
.page--ui .ugc-brand {
    font-weight: 700;
    text-decoration: none;
    color: var(--craft-accent, #6ea8fe);
}
.page--ui .ugc-slug { opacity: 0.75; }
.page--ui .ugc-id { opacity: 0.7; }
.page--ui .ugc-chip {
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.02em;
    border: 1px solid transparent;
}
.page--ui .ugc-chip--ok {
    color: light-dark(#0a6b3d, #7ee2b0);
    background: light-dark(#e3f6ec, #16352a);
    border-color: light-dark(#9bd9b6, #2c6b4d);
}
.page--ui .ugc-chip--warn {
    color: light-dark(#8a5a00, #f0c674);
    background: light-dark(#fdf2dc, #3a2f17);
    border-color: light-dark(#e6c585, #6b542c);
}
/* ── Consent gate — the premiere cover. Not a warning: a poster with one inviting door in. ── */
.page--ui .ugc-gate {
    min-height: 100svh;
    display: grid;
    place-items: center;
    padding: var(--space-l) var(--space-s);
    background:
        radial-gradient(44rem 28rem at 50% 24%, var(--craft-accent-glow, light-dark(rgba(184,138,0,0.10), rgba(255,210,63,0.14))), transparent 70%),
        radial-gradient(light-dark(rgba(26, 29, 34, 0.06), rgba(232, 237, 242, 0.05)) 1px, transparent 1.4px);
    background-size: auto, 26px 26px;
}
.page--ui .ugc-gate-card {
    width: min(34rem, 100%);
    background: var(--craft-surface, light-dark(#ffffff, #14181d));
    border: 1px solid var(--craft-line, light-dark(#e1e5ea, #232a31));
    border-radius: 18px;
    overflow: hidden;
    box-shadow:
        0 1px 0 light-dark(rgba(255,255,255,0.6), rgba(255,255,255,0.04)) inset,
        0 30px 80px light-dark(rgba(0,0,0,0.14), rgba(0,0,0,0.55));
    animation: ugc-gate-rise 0.55s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}
@keyframes ugc-gate-rise {
    from { opacity: 0; transform: translateY(16px) scale(0.985); }
}
.page--ui .ugc-gate-screen {
    margin: 0;
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-bottom: 1px solid var(--craft-line, light-dark(#e1e5ea, #232a31));
    background: var(--craft-surface-2, light-dark(#f1f3f5, #0e1216));
}
.page--ui .ugc-gate-fallback {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background:
        radial-gradient(26rem 16rem at 50% 110%, var(--craft-accent-glow, light-dark(rgba(184,138,0,0.10), rgba(255,210,63,0.14))), transparent 72%),
        radial-gradient(light-dark(rgba(26, 29, 34, 0.07), rgba(232, 237, 242, 0.06)) 1px, transparent 1.4px);
    background-size: auto, 18px 18px;
}
.page--ui .ugc-gate-monogram {
    font-family: var(--shell-font-mono, ui-monospace, monospace);
    font-weight: 700;
    font-size: var(--step-2);
    letter-spacing: 0.06em;
    color: var(--craft-accent, light-dark(#b88a00, #ffd23f));
    opacity: 0.85;
}
.page--ui .ugc-gate-shot {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.6s ease;
}
.page--ui .ugc-gate-screen.has-shot .ugc-gate-shot { opacity: 1; }
.page--ui .ugc-gate-sheen {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(115deg, transparent 38%, light-dark(rgba(255,255,255,0.35), rgba(255,255,255,0.07)) 50%, transparent 62%);
    transform: translateX(-120%);
    animation: ugc-gate-sheen 3.6s cubic-bezier(0.5, 0, 0.3, 1) 0.7s infinite;
}
@keyframes ugc-gate-sheen {
    0% { transform: translateX(-120%); }
    45%, 100% { transform: translateX(120%); }
}
.page--ui .ugc-gate-meta {
    padding: var(--space-m) var(--space-m) var(--space-m);
    display: grid;
    justify-items: center;
    gap: var(--space-3xs);
    text-align: center;
}
.page--ui .ugc-gate-meta > * {
    animation: ugc-gate-rise 0.5s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}
.page--ui .ugc-gate-meta > :nth-child(2) { animation-delay: 0.06s; }
.page--ui .ugc-gate-meta > :nth-child(3) { animation-delay: 0.12s; }
.page--ui .ugc-gate-meta > :nth-child(4) { animation-delay: 0.18s; }
.page--ui .ugc-gate-meta > :nth-child(5) { animation-delay: 0.24s; }
.page--ui .ugc-gate-meta > :nth-child(6) { animation-delay: 0.3s; }
.page--ui .ugc-gate-kicker {
    margin: 0;
    font-family: var(--shell-font-mono, ui-monospace, monospace);
    font-size: var(--step--2);
    font-weight: 600;
    letter-spacing: 0.34em;
    text-transform: uppercase;
    color: var(--craft-accent, light-dark(#b88a00, #ffd23f));
}
.page--ui .ugc-gate-title {
    margin: 0;
    font-size: var(--step-3);
    font-weight: 750;
    line-height: 1.12;
    text-wrap: balance;
    color: var(--craft-text, light-dark(#1a1d22, #e8edf2));
}
.page--ui .ugc-gate-addr {
    margin: 0;
    font-family: var(--shell-font-mono, ui-monospace, monospace);
    font-size: var(--step--2);
    color: var(--craft-text-dim, light-dark(#7a8590, #6b7280));
}
.page--ui .ugc-gate-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-3xs);
    margin-block: var(--space-3xs) var(--space-2xs);
}
.page--ui .ugc-chip--sandbox {
    color: var(--craft-text-muted, light-dark(#4a5560, #8a97a3));
    background: var(--craft-surface-2, light-dark(#f1f3f5, #0e1216));
    border-color: var(--craft-line, light-dark(#e1e5ea, #232a31));
}
.page--ui .ugc-gate-enter {
    display: inline-flex;
    align-items: center;
    gap: 0.6em;
    font-family: var(--shell-font-mono, ui-monospace, monospace);
    font-weight: 700;
    font-size: var(--step-0);
    color: var(--craft-accent-ink, #1a1205);
    background: var(--craft-accent, light-dark(#b88a00, #ffd23f));
    border: 0;
    border-radius: 999px;
    padding: 0.7em 1.9em;
    cursor: pointer;
    box-shadow: 0 10px 30px var(--craft-accent-glow, light-dark(rgba(184,138,0,0.10), rgba(255,210,63,0.14))), 0 2px 8px light-dark(rgba(0,0,0,0.15), rgba(0,0,0,0.5));
    transition: filter 0.15s ease, transform 0.15s ease, box-shadow 0.25s ease;
}
.page--ui .ugc-gate-enter:hover {
    filter: brightness(1.07);
    transform: translateY(-1px);
    box-shadow: 0 14px 38px var(--craft-accent-glow, light-dark(rgba(184,138,0,0.10), rgba(255,210,63,0.14))), 0 3px 10px light-dark(rgba(0,0,0,0.18), rgba(0,0,0,0.55));
}
.page--ui .ugc-gate-enter:active { transform: translateY(0); filter: brightness(0.97); }
.page--ui .ugc-gate-enter-arrow { transition: transform 0.15s ease; }
.page--ui .ugc-gate-enter:hover .ugc-gate-enter-arrow { transform: translateX(3px); }
.page--ui .ugc-gate-fine {
    margin: var(--space-2xs) 0 0;
    max-width: 42ch;
    font-size: var(--step--2);
    line-height: 1.55;
    color: var(--craft-text-dim, light-dark(#7a8590, #6b7280));
}
.page--ui .ugc-gate-fine a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.page--ui .ugc-gate-fine a:hover { color: var(--craft-text-muted, light-dark(#4a5560, #8a97a3)); }
@media (prefers-reduced-motion: reduce) {
    .page--ui .ugc-gate-card,
    .page--ui .ugc-gate-meta > * { animation: none; }
    .page--ui .ugc-gate-sheen { display: none; }
}

/* ── Friendly name + header action buttons (Share / Copy / visibility). */
.page--ui .ugc-name {
    font-weight: 700;
    color: var(--craft-text, #e8e8ea);
    max-width: 22ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.page--ui .ugc-btn {
    font-family: var(--shell-font-mono, ui-monospace, monospace);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--craft-line, #39393f);
    background: var(--craft-surface, #1b1b1f);
    color: var(--craft-text, #e8e8ea);
    cursor: pointer;
    text-decoration: none;
    line-height: 1.4;
    transition: border-color 0.12s ease, color 0.12s ease;
}
.page--ui .ugc-btn:hover {
    border-color: var(--craft-accent, #6ea8fe);
    color: var(--craft-accent, #6ea8fe);
}
.page--ui .ugc-btn:disabled { opacity: 0.55; cursor: default; }
.page--ui .ugc-btn--copy-construct {
    color: var(--craft-accent, #6ea8fe);
    border-color: color-mix(in srgb, var(--craft-accent, #6ea8fe) 45%, transparent);
}

/* Share popover — expands inside the ☰ panel (see .ugc-panel .ugc-popover override). */
.page--ui .ugc-popover {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    min-width: 220px;
    background: var(--craft-surface, #1b1b1f);
    border: 1px solid var(--craft-line, #39393f);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.page--ui .ugc-popover-row { display: flex; gap: 6px; }
.page--ui .ugc-popover-url {
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--shell-font-mono, ui-monospace, monospace);
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--craft-line, #39393f);
    background: var(--craft-bg, #111114);
    color: var(--craft-text, #e8e8ea);
}
.page--ui .ugc-popover-copied {
    font-size: 11px;
    font-weight: 700;
    color: light-dark(#0a6b3d, #7ee2b0);
}
/* Explicit light bg so the QR scans in dark theme. */
.page--ui #share-qr {
    align-self: center;
    width: 100%;
    max-width: 180px;
    padding: 8px;
    border-radius: 6px;
    background: #fff;
}
.page--ui #share-qr svg { display: block; width: 100%; height: auto; }

/* Owner visibility toggle + inline status. */
.page--ui .ugc-visibility { display: inline-flex; align-items: center; gap: 8px; }
.page--ui .ugc-btn--visibility { padding: 4px 8px; }
.page--ui .ugc-edit-status { font-size: 11px; color: var(--craft-text-muted, #8a8f98); }

/* Facet loading view — shown in #construct-view until the live frame is derived and morphed in. */
.facet-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    min-height: 60vh;
    color: var(--craft-text-muted, #8a8f98);
}
.facet-loading__marks {
    display: flex;
    gap: 0.5rem;
}
.facet-loading__marks span {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: var(--craft-accent, currentColor);
    opacity: 0.35;
    animation: facet-loading-pulse 1.1s ease-in-out infinite;
}
.facet-loading__marks span:nth-child(2) { animation-delay: 0.18s; }
.facet-loading__marks span:nth-child(3) { animation-delay: 0.36s; }
.facet-loading__text {
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    margin: 0;
}
@keyframes facet-loading-pulse {
    0%, 100% { opacity: 0.35; transform: translateY(0); }
    50%      { opacity: 1;    transform: translateY(-0.25rem); }
}
@media (prefers-reduced-motion: reduce) {
    .facet-loading__marks span { animation: none; opacity: 0.7; }
}

/* Facet boot/runtime error — the real exception, shown in place of an endless loading stub. */
.facet-error {
    max-width: 640px;
    margin: 8vh auto;
    padding: var(--space-m, 1.2rem);
    border: 1px solid color-mix(in srgb, var(--craft-err, #c44545) 45%, transparent);
    border-radius: 8px;
    background: color-mix(in srgb, var(--craft-err, #c44545) 8%, transparent);
}
.facet-error__title { margin: 0 0 .6rem; font-weight: 600; color: var(--craft-err, #c44545); }
.facet-error__detail {
    margin: 0;
    padding: .7rem .8rem;
    overflow-x: auto;
    font-family: ui-monospace, "JetBrains Mono", monospace;
    font-size: .82rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--craft-surface-2, rgba(0,0,0,.25));
    border-radius: 6px;
}
.facet-error__hint { margin: .6rem 0 0; font-size: .82rem; color: var(--craft-text-muted, #8a8f98); }

/* Boot reveal: loading→live swap fades in. Idiomorph patches moves in place (no re-trigger), so only the initial reveal animates. Pure CSS (View Transition API throws on hidden tabs). Opacity-only: a translate on a full-viewport (min-height:100dvh) facet root pushes its bottom past the fold → a transient scrollbar that snaps away when the animation settles. A construct starts at its natural size and builds out — never oversized-then-shrunk. */
#construct-view > * {
    animation: construct-reveal 0.4s ease-out both;
}
@keyframes construct-reveal {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    #construct-view > * { animation: none; }
}

/* ☰ dropdown panel: EVERYTHING lives here — name, trust, share, economy actions, visibility, display name, theme, auth, brand. One click-dropdown at every width, never loose chrome over the construct. */
.page--ui .ugc-burger {
    display: inline-flex;
    border: 1px solid var(--craft-border, #39393f);
    border-radius: 8px;
    padding: 5px 11px;
    cursor: pointer;
    color: inherit;
    font: inherit;
    /* Translucent surface + blur so the lone control reads over ANY construct background without claiming layout. */
    background: color-mix(in srgb, var(--craft-surface, #1b1b1f) 78%, transparent);
    backdrop-filter: blur(6px);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.25);
}
.page--ui .ugc-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 70;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--craft-border, #39393f);
    border-radius: 12px;
    background: var(--craft-surface, #1b1b1f);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
    width: max-content;
    min-width: 230px;
    max-width: min(320px, calc(100vw - 24px));
}
.page--ui .ugc-panel-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.page--ui .ugc-panel-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.page--ui .ugc-panel-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 4px; border-top: 1px solid var(--craft-border, #39393f); }
/* Share expands IN the panel flow, not as a floating popover. */
.page--ui .ugc-panel .ugc-popover { position: static; box-shadow: none; padding: 0; border: 0; min-width: 0; }
.page--ui .ugc-name-main { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page--ui .ugc-panel .ugc-brand { font-weight: 700; }

/* UGC-origin sign-in (/auth on .io): the OTP card — same visual language as the app-origin claim card. `.btn` here also styles the shared #auth-panel fragments POST /auth morphs in. Scoped to `main.ugc-auth` (the full-page auth card): the ugc-bar reuses the `.ugc-auth` class for its small toolbar controls (theme toggle, Sign in/out links), which must NOT inherit the 100vh-centered card layout — that ballooned the toolbar "Sign in" link to full height on a signed-out construct view, shoving the facet below the fold. */
.page--ui main.ugc-auth { display: grid; place-items: center; min-height: calc(100vh - 120px); padding: var(--space-l, 1.5rem); }
.page--ui #auth-panel { width: min(26rem, 92vw); background: var(--craft-surface); border: 1px solid var(--craft-line); border-radius: 14px; padding: var(--space-l, 1.6rem); }
.page--ui #auth-panel form { display: flex; flex-direction: column; gap: var(--space-2xs, 0.7rem); }
.page--ui #auth-panel p { margin: 0 0 0.3rem; color: var(--craft-text); }
.page--ui #auth-panel .sub { color: var(--craft-text-muted); font-size: 0.85em; }
.page--ui #auth-panel .error { color: var(--craft-err); font-size: 0.9em; margin: 0; }
.page--ui #auth-panel input { background: var(--craft-bg); border: 1px solid var(--craft-line); border-radius: 10px; color: var(--craft-text); font-family: var(--shell-font-mono, ui-monospace, monospace); font-size: 1rem; padding: 0.65rem 0.9rem; }
.page--ui #auth-panel input:focus-visible { outline: 2px solid var(--craft-accent); outline-offset: 1px; }
.page--ui #auth-panel .btn { display: inline-flex; align-items: center; justify-content: center; width: 100%; background: var(--craft-accent); color: var(--craft-accent-ink); font-family: var(--shell-font-mono, ui-monospace, monospace); font-weight: 700; border: none; border-radius: 10px; padding: 0.6rem 1rem; cursor: pointer; transition: transform 0.12s ease, filter 0.12s ease; }
.page--ui #auth-panel .btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.page--ui #auth-panel .btn:disabled { opacity: 0.6; cursor: default; transform: none; }

/* Co-editor presence strip — fixed top rail inside the editor's ?bare=1&coedit=1 preview pane. Bound to the target's co-presence fold ($_viewers/$_roster); hidden when solo. */
.craft-coedit { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 4px 10px; font: 600 11px/1 var(--shell-font-mono, ui-monospace, monospace); letter-spacing: 0.03em; color: var(--craft-text-dim); background: var(--craft-surface); border-bottom: 1px solid var(--craft-line); pointer-events: none; }
.craft-coedit-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--craft-accent); box-shadow: 0 0 0 3px var(--craft-accent-glow, rgba(127, 127, 127, 0.18)); }
.craft-coedit-names { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: 4px; }
.craft-coedit-chip { padding: 1px 7px; border-radius: 999px; background: var(--craft-hover-tint, rgba(127, 127, 127, 0.12)); color: var(--craft-text); }
