/* ═══════════════════════════════════════════════════════════════════════════
   Yellow Help Web — tokens lifted from the design bundle.
   Light is the default; [data-theme="dark"] on <html> flips everything.
═══════════════════════════════════════════════════════════════════════════ */

:root, [data-theme="light"] {
    --accent:           #FFCD00;
    --accent-bold:      #E0B400;
    --accent-soft:      #FFF3B8;
    --accent-soft-fg:   #7A5C00;
    --on-accent:        #161513;

    --btn-ink-bg:       #161513;
    --btn-ink-fg:       #FFCD00;
    --btn-ink-tag:      #FFE066;
    --btn-ink-sub:      #E8E4D8;

    --surface:          #FFFFFF;
    --surface-2:        #FAFAF7;
    --rail-bg:          #EFECE3;
    --rail-border:      #E3DFD3;
    --rail-icon:        #7A766C;
    --avatar-ring:      #FFFFFF;
    --scroll-hover:     rgba(22,21,19,0.06);

    --line:             #ECEAE2;
    --line-soft:        #F2F1EC;

    --text-ink:         #161513;
    --text-body:        #3D3B36;
    --text-muted:       #5F5C55;
    --text-muted-2:     #8C8A82;
    --text-muted-3:     #A19E97;
    --text-faint:       #B8B5AD;
    --text-faint-2:     #D6D4CC;
    --link:             #B58A00;

    --warm-bg:          #FFFBEA;
    --warm-card-bg:     #FFFFFF;
    --warm-line:        #FFE066;
    --warm-text:        #7A5C00;

    --hero-highlight:           linear-gradient(180deg, transparent 60%, var(--accent) 60%);
    --hero-highlight-radius:    0;
    --hero-highlight-pad-x:     4px;

    --chip-blue-bg:     #EEF2FF;
    --chip-blue-fg:     #3D52BF;
    --chip-purple-bg:   #F3EBFF;
    --chip-purple-fg:   #6E2EB6;

    --danger:           #C8331C;
    --danger-soft:      #FBE7E2;

    --shadow:           0 1px 0 rgba(0,0,0,0.02), 0 30px 60px -30px rgba(22,21,19,0.18);

    --page-bg:          #F4F2EC;
}

[data-theme="dark"] {
    --accent:           #FFCD00;
    --accent-bold:      #FFE066;
    --accent-soft:      #2F2710;
    --accent-soft-fg:   #FFE066;
    --on-accent:        #161513;

    --btn-ink-bg:       #161513;
    --btn-ink-fg:       #FFCD00;
    --btn-ink-tag:      #FFE066;
    --btn-ink-sub:      #B8B5AD;

    --surface:          #1B1916;
    --surface-2:        #141310;
    --rail-bg:          #0F0E0C;
    --rail-border:      #26231F;
    --rail-icon:        #7C7972;
    --avatar-ring:      #0F0E0C;
    --scroll-hover:     rgba(255,205,0,0.10);

    --line:             #2A2724;
    --line-soft:        #23211E;

    --text-ink:         #F4F1E8;
    --text-body:        #DCD8CC;
    --text-muted:       #A19E97;
    --text-muted-2:     #8C8A82;
    --text-muted-3:     #7C7972;
    --text-faint:       #5C5950;
    --text-faint-2:     #3D3B36;
    --link:             #FFD43B;

    --warm-bg:          #1F1A0B;
    --warm-card-bg:     #19150A;
    --warm-line:        #5C4900;
    --warm-text:        #FFE066;

    --hero-highlight:   var(--accent);
    --hero-highlight-radius: 8px;
    --hero-highlight-pad-x:  14px;

    --chip-blue-bg:     #1B2540;
    --chip-blue-fg:     #9DB1FF;
    --chip-purple-bg:   #2A1F40;
    --chip-purple-fg:   #CCA7FF;

    --danger:           #FFA694;
    --danger-soft:      #3A1814;

    --shadow:           0 0 0 1px rgba(0,0,0,0.4), 0 30px 60px -30px rgba(0,0,0,0.85);

    --page-bg:          #0A0908;
}

/* ── Base ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--page-bg); }
body {
    font-family: Inter, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    color: var(--text-ink);
    background: var(--page-bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, kbd { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace; }

/* ── Shell layout ────────────────────────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
    background: var(--surface);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
    width: 280px;
    background: var(--surface-2);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
}
.sidebar-brand:hover { text-decoration: none; }

.brand-mark {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: #161513;
    display: grid; place-items: center;
    box-shadow: 0 1px 0 rgba(0,0,0,0.04), 0 8px 24px -10px rgba(22,21,19,0.35);
    flex-shrink: 0;
}
.brand-mark svg { width: 20px; height: 20px; }

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name {
    font-size: 14px; font-weight: 700;
    color: var(--text-ink); letter-spacing: -0.005em;
}
.brand-tag {
    font-size: 9.5px; color: var(--text-muted-3);
    letter-spacing: 0.14em; text-transform: uppercase;
    font-weight: 600; margin-top: 1px;
}

.sidebar-nav {
    padding: 18px 8px;
    overflow-y: auto;
    flex: 1;
}
/* Embedded mode (inside yellow-client iframe): no brand header, so give the
   nav a bit more breathing room at the top. */
.sidebar-embedded .sidebar-nav { padding-top: 24px; }

.nav-section { margin-bottom: 22px; }
.nav-section-header {
    display: flex; align-items: center; gap: 6px;
    padding: 0 12px; margin-bottom: 8px;
}
.nav-section-label {
    font-size: 10.5px; font-weight: 700;
    letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--text-muted-3);
}
.nav-section-count {
    margin-left: auto;
    font-family: "JetBrains Mono", monospace;
    font-size: 10px; color: var(--text-faint);
    padding: 1px 6px;
    background: var(--line-soft);
    border-radius: 999px;
}

.nav-list { list-style: none; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border-radius: 8px; margin-bottom: 2px;
    font-size: 13.5px; font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    position: relative;
    transition: background .12s, color .12s;
}
.nav-link:hover {
    background: var(--scroll-hover);
    color: var(--text-ink);
    text-decoration: none;
}
.nav-link.active {
    background: var(--accent-soft);
    color: var(--text-ink);
    font-weight: 600;
}
.nav-link.active::before {
    content: "";
    position: absolute;
    left: 0; top: 8px; bottom: 8px;
    width: 3px;
    background: var(--accent-bold);
    border-radius: 0 3px 3px 0;
}
.nav-link-icon { font-size: 14px; line-height: 1; }
.nav-empty { padding: 1rem 12px; font-size: 12px; color: var(--text-muted-3); }

/* ── Sidebar footer (theme + lang) ───────────────────────────────────────── */
.sidebar-footer {
    border-top: 1px solid var(--line);
    padding: 12px 12px 14px;
    display: flex; align-items: center; gap: 8px;
}
.theme-toggle, .lang-pill {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text-muted);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.04em;
    text-decoration: none;
    display: inline-flex; align-items: center; gap: 6px;
    font-family: inherit;
}
.theme-toggle:hover, .lang-pill:hover {
    background: var(--scroll-hover);
    color: var(--text-ink);
    text-decoration: none;
}
.lang-pill.active {
    background: var(--btn-ink-bg);
    color: var(--btn-ink-fg);
    border-color: var(--btn-ink-bg);
}
.lang-pill.disabled {
    opacity: .4; cursor: not-allowed; pointer-events: none;
}
.lang-group { display: inline-flex; gap: 2px; margin-left: auto; }
.lang-group .lang-pill {
    padding: 6px 9px;
    border-radius: 7px;
    font-family: "JetBrains Mono", monospace;
    font-size: 10.5px;
    letter-spacing: 0.06em;
}

/* ── Main / article ──────────────────────────────────────────────────────── */
.app-main {
    flex: 1;
    background: var(--surface);
    min-width: 0;
}

.article-wrap {
    max-width: 920px;
    margin: 0 auto;
    padding: 40px 56px 80px;
    position: relative;
}

/* When the page has a TOC, widen the wrap and use a two-column grid so the
   TOC sits in its own column to the right of the article. */
.article-wrap.has-toc {
    max-width: 1260px;
    display: grid;
    grid-template-columns: minmax(0, 800px) 220px;
    column-gap: 60px;
    align-items: start;
}
.article-wrap .article-content { min-width: 0; }

/* ── On-this-page TOC ───────────────────────────────────────────────────── */
.page-toc {
    position: sticky;
    top: 24px;
    align-self: start;
    padding-top: 48px;
    font-size: 13px;
    line-height: 1.5;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
}
.page-toc-title {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 10.5px;
    color: var(--text-muted-2);
    font-weight: 700;
    margin-bottom: 12px;
}
.page-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border-left: 1px solid var(--line);
}
.page-toc-list li { margin: 0; }
.page-toc-list a {
    display: block;
    padding: 5px 12px;
    color: var(--text-muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    margin-left: -1px;
    line-height: 1.4;
    transition: color 0.1s ease, border-color 0.1s ease;
}
.page-toc-list a:hover { color: var(--text-ink); }
.page-toc-list a.active {
    color: var(--text-ink);
    border-left-color: var(--accent, #FFCD00);
    font-weight: 500;
}
.page-toc-list .toc-level-3 a {
    padding-left: 24px;
    font-size: 12.5px;
}
.page-toc::-webkit-scrollbar { width: 4px; }
.page-toc::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

@media (max-width: 1180px) {
    .article-wrap.has-toc {
        display: block;
        max-width: 920px;
    }
    .page-toc { display: none; }
}

/* Meta row above hero */
.article-meta {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 18px;
    font-size: 11.5px;
    color: var(--text-muted-2);
}
.eyebrow {
    padding: 3px 9px;
    border-radius: 4px;
    background: var(--accent-soft);
    color: var(--accent-soft-fg);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 10px;
}
.meta-dot { color: var(--text-faint-2); }
.meta-mono { font-family: "JetBrains Mono", monospace; }

/* Hero */
.hero-title {
    font-family: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
    font-size: 56px;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.02;
    color: var(--text-ink);
    margin: 0;
}
.hero-highlight {
    background: var(--hero-highlight);
    padding: 0 var(--hero-highlight-pad-x);
    border-radius: var(--hero-highlight-radius);
    color: var(--on-accent);
}
.hero-lead {
    font-size: 19px;
    line-height: 1.55;
    color: var(--text-body);
    max-width: 620px;
    margin: 20px 0 0;
    text-wrap: pretty;
}

/* ── Markdown body ───────────────────────────────────────────────────────── */
.article-body { margin-top: 8px; }

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4 {
    color: var(--text-ink);
    letter-spacing: -0.012em;
}
.article-body h1 {
    font-family: "Bricolage Grotesque", system-ui, sans-serif;
    font-size: 32px; font-weight: 600;
    margin: 48px 0 12px;
}
.article-body h2 {
    font-size: 24px; font-weight: 600;
    margin: 44px 0 12px;
}
.article-body h3 {
    font-size: 18px; font-weight: 600;
    margin: 32px 0 10px;
}

.article-body p {
    font-size: 16px;
    line-height: 1.65;
    color: var(--text-body);
    margin: 12px 0 0;
    text-wrap: pretty;
}
.article-body p + p { margin-top: 16px; }

.article-body ul,
.article-body ol {
    margin: 12px 0 0;
    padding-left: 22px;
}
.article-body li {
    font-size: 15.5px;
    line-height: 1.65;
    color: var(--text-body);
    margin-bottom: 6px;
}
.article-body li > strong { color: var(--text-ink); }

.article-body code {
    font-size: 0.88em;
    padding: 1px 6px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--text-body);
}
.article-body pre {
    margin: 16px 0 0;
    padding: 16px;
    border-radius: 10px;
    background: #161513;
    color: #E8E4D8;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.6;
    border: 1px solid #26231F;
}
.article-body pre code {
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.article-body blockquote {
    margin: 20px 0 0;
    padding: 16px 20px;
    border-radius: 10px;
    background: var(--warm-bg);
    border: 1px solid var(--warm-line);
    color: var(--text-body);
}
.article-body blockquote p { margin: 0; color: var(--warm-text); }
.article-body blockquote p + p { margin-top: 8px; }

.article-body a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-color: var(--text-faint-2);
    text-underline-offset: 3px;
}
.article-body a:hover { text-decoration-color: var(--link); }

.article-body hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 32px 0;
}

.article-body img {
    max-width: 100%;
    border-radius: 10px;
    border: 1px solid var(--line);
}

/* Tables — Inter for names, mono for values */
.article-body table {
    width: 100%;
    margin-top: 16px;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    font-size: 13.5px;
}
.article-body thead th {
    text-align: left;
    padding: 10px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted-3);
}
.article-body tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--text-body);
    line-height: 1.55;
}
.article-body tbody tr:last-child td { border-bottom: none; }
.article-body tbody td:nth-child(n+2) { font-family: "JetBrains Mono", monospace; font-size: 12.5px; }
.article-body tbody td:first-child { color: var(--text-ink); font-weight: 500; }

/* ── Schema page ─────────────────────────────────────────────────────────── */
.breadcrumb {
    display: flex; align-items: center; gap: 4px;
    font-size: 12.5px;
    color: var(--text-muted-2);
    margin-bottom: 16px;
}
.breadcrumb a { color: var(--link); font-weight: 500; }
.breadcrumb .crumb-sep { color: var(--text-faint-2); }
.breadcrumb .crumb-current { color: var(--text-ink); font-weight: 500; }

.schema-hero { display: flex; align-items: flex-start; gap: 20px; margin-bottom: 32px; }
.schema-mark {
    width: 68px; height: 68px;
    border-radius: 16px;
    background: var(--accent);
    flex-shrink: 0;
    display: grid; place-items: center;
    font-family: "Bricolage Grotesque", system-ui, sans-serif;
    font-size: 32px; font-weight: 700;
    color: var(--on-accent);
    box-shadow: inset 0 -2px 0 rgba(0,0,0,0.08);
}
.schema-title {
    font-family: "Bricolage Grotesque", system-ui, sans-serif;
    font-size: 40px; font-weight: 600;
    letter-spacing: -0.025em;
    margin: 0; line-height: 1.05;
    color: var(--text-ink);
}
.schema-sub {
    font-size: 14px; color: var(--text-muted);
    margin: 6px 0 0; max-width: 540px;
}

.model-list { display: flex; flex-direction: column; gap: 8px; }
.model-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 24px;
    padding: 14px 18px;
    border-radius: 11px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text-ink);
    text-decoration: none;
}
.model-row:hover { border-color: var(--accent-bold); text-decoration: none; }
.model-name {
    display: flex; align-items: center; gap: 8px;
    font-size: 15px; font-weight: 600;
}
.model-desc {
    font-size: 12.5px; color: var(--text-muted);
    margin-top: 2px;
}
.model-meta {
    text-align: right;
    font-family: "JetBrains Mono", monospace;
}
.model-meta-label {
    font-size: 11px;
    color: var(--text-muted-3);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.model-meta-value {
    font-size: 14px; color: var(--text-ink); font-weight: 500;
}
.model-arrow { color: var(--link); display: inline-flex; }

/* ── Schemas list (catalogue) ────────────────────────────────────────────── */
.schema-row {
    display: flex;
    align-items: stretch;
    gap: 16px;
    padding: 16px 18px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text-ink);
    text-decoration: none;
    transition: border-color .15s, background .15s;
}
.schema-row:hover {
    border-color: var(--accent-bold);
    background: var(--surface-2);
    text-decoration: none;
}
.schema-row-accent {
    width: 4px;
    border-radius: 4px;
    flex-shrink: 0;
    align-self: stretch;
}
.schema-row-body { flex: 1; min-width: 0; }
.schema-row-name { font-size: 16px; font-weight: 600; color: var(--text-ink); }
.schema-row-uid {
    margin-top: 2px;
    font-size: 11.5px;
    color: var(--text-muted-2);
    font-family: "JetBrains Mono", monospace;
}
.schema-row-cta {
    align-self: center;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--link);
    white-space: nowrap;
}

/* ── Model detail ────────────────────────────────────────────────────────── */
.stat-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 24px;
    margin-bottom: 32px;
}
.stat-cell {
    padding: 14px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface-2);
}
.stat-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted-3);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}
.stat-value {
    font-size: 22px;
    font-weight: 600;
    margin-top: 4px;
    letter-spacing: -0.01em;
    color: var(--text-ink);
}
.stat-mono { font-family: "JetBrains Mono", monospace; letter-spacing: 0; }
.stat-hint {
    font-size: 11px;
    color: var(--text-muted-2);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.props-table {
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    overflow: hidden;
}
.props-head {
    display: grid;
    grid-template-columns: 1.2fr 0.7fr 1.6fr;
    padding: 10px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-muted-3);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}
.props-row {
    display: grid;
    grid-template-columns: 1.2fr 0.7fr 1.6fr;
    padding: 14px 16px;
    align-items: center;
    border-bottom: 1px solid var(--line-soft);
}
.props-row:last-child { border-bottom: none; }
.props-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-ink);
}
.props-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

.type-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 5px;
    font-family: "JetBrains Mono", monospace;
    font-size: 11.5px;
    font-weight: 500;
}
.type-chip-scalar     { background: var(--chip-blue-bg);   color: var(--chip-blue-fg);   }
.type-chip-reference  { background: var(--chip-purple-bg); color: var(--chip-purple-fg); }
.type-chip-collection { background: var(--accent-soft);    color: var(--accent-soft-fg); }

.primary-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: var(--accent-soft);
    color: var(--accent-soft-fg);
}
.virtual-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: var(--chip-purple-bg);
    color: var(--chip-purple-fg);
}

/* ── Status / error pages ────────────────────────────────────────────────── */
.state-block {
    padding-top: 40px;
    max-width: 580px;
}
.state-block h1 {
    font-family: "Bricolage Grotesque", system-ui, sans-serif;
    font-size: 36px; font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
}
.state-block p {
    font-size: 16px; line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* ── Unauthorized standalone page ────────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: var(--page-bg);
    padding: 24px;
}
.auth-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 36px;
    max-width: 460px; width: 100%;
}
.auth-card .brand-mark { margin-bottom: 18px; }
.auth-card h1 {
    font-family: "Bricolage Grotesque", system-ui, sans-serif;
    font-size: 28px; font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-ink);
    margin-bottom: 8px;
}
.auth-card p { color: var(--text-muted); margin-bottom: 12px; font-size: 14px; line-height: 1.55; }
.auth-card code {
    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
    padding: 1px 6px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--text-body);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .sidebar { display: none; }
    .article-wrap { padding: 24px 20px 60px; }
    .hero-title { font-size: 38px; }
    .hero-lead { font-size: 17px; }
}

/* ── Scrollbars in sidebar ───────────────────────────────────────────────── */
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }

/* ── Public form pages ───────────────────────────────────────────────────── */
.form-page {
    min-height: 100vh;
    background: var(--page-bg);
    padding: 40px 24px;
    display: flex;
    justify-content: center;
}

.form-shell {
    width: 100%;
    max-width: 1600px;
}

.form-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 36px;
    /* Enable container queries so .form-grid below reacts to the card width
       instead of the viewport — important for iframe embeds. */
    container-type: inline-size;
    container-name: form-card;
}

.form-header { margin-bottom: 24px; }

.form-eyebrow {
    display: inline-block;
    padding: 3px 9px;
    background: var(--accent-soft);
    color: var(--accent-soft-fg);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.form-title {
    font-family: "Bricolage Grotesque", system-ui, sans-serif;
    font-size: 32px;
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.1;
    color: var(--text-ink);
    margin: 0 0 8px;
}

.form-description {
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-muted);
    margin: 0;
}

/* Outer stack of groups: each group is a labelled section. */
.form-groups {
    display: flex;
    flex-direction: column;
    gap: 28px;
    margin-top: 8px;
}

.form-group { display: flex; flex-direction: column; gap: 12px; }

.form-group-title {
    font-family: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-ink);
    margin: 0;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
}

/*
 * Responsive 12-col-ish grid that mirrors yellow-client's _flexForWidth():
 * fewer columns at narrower form widths so fields with a high flex still
 * occupy a sensible share of the row. Each field carries `--field-flex`
 * inline; the span is clamped to the current --cols via min().
 *
 * Uses container queries on .form-card so the grid reacts to the FORM's own
 * width (important when embedded in a narrow iframe) rather than the viewport.
 * Modern browsers (Chrome/Safari/Firefox 2024+) evaluate min()/var() inside
 * the grid-column-end integer position.
 */
.form-grid {
    --cols: 1;
    display: grid;
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
    gap: 14px 16px;
    align-items: start;
}

@container form-card (min-width: 720px)  { .form-grid { --cols: 2;  } }
@container form-card (min-width: 900px)  { .form-grid { --cols: 3;  } }
@container form-card (min-width: 1080px) { .form-grid { --cols: 4;  } }
@container form-card (min-width: 1260px) { .form-grid { --cols: 5;  } }
@container form-card (min-width: 1440px) { .form-grid { --cols: 6;  } }

.form-field {
    display: flex;
    flex-direction: column;
    /* Span is clamped between 1 and the current column count. */
    grid-column: span min(var(--field-flex, 12), var(--cols));
    min-width: 0;
}

.form-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-ink);
    margin-bottom: 6px;
}

.form-input {
    font-family: inherit;
    font-size: 14.5px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-ink);
    transition: border-color .12s, box-shadow .12s;
}
.form-input:focus {
    outline: none;
    border-color: var(--accent-bold);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-input[readonly],
.form-input:disabled { background: var(--surface-2); color: var(--text-muted); }
.form-input:disabled { cursor: not-allowed; opacity: 1; }
.form-input-mono { font-family: "JetBrains Mono", monospace; font-size: 13px; }

.form-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 14.5px;
    color: var(--text-ink);
    cursor: pointer;
}
.form-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

/*
 * Pseudo-input wrapper for the lone checkbox of a Boolean field. Matches the
 * vertical metrics of .form-input (padding + border) so booleans share the
 * same baseline as text inputs in the same grid row. No horizontal padding so
 * the checkbox stays flush-left with the label and help text above/below.
 */
.form-checkbox-input {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border: 1px solid transparent; /* same total height as .form-input */
    min-height: calc(14.5px + 20px + 2px); /* font-size + padding + borders */
    box-sizing: border-box;
}
.form-checkbox-input input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-bold);
    cursor: pointer;
    margin: 0;
}
.form-checkbox-input input[type="checkbox"]:disabled { cursor: not-allowed; opacity: 0.6; }

/* File & signature fields ------------------------------------------------- */
.is-hidden { display: none !important; }

.form-btn-secondary {
    font-family: inherit;
    font-size: 13.5px;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-ink);
    cursor: pointer;
    transition: border-color .12s, background .12s;
}
.form-btn-secondary:hover { border-color: var(--accent-bold); }
.form-btn-secondary:disabled { opacity: 0.6; cursor: not-allowed; }

.form-file-row {
    display: flex;
    align-items: center;
    gap: 10px;
    /* Single line, never wrap: the filename truncates (ellipsis) so the
       download link and action button stay inline. No vertical padding —
       min-height + border-box make the bordered box exactly as tall as
       .form-input (font + its 10px*2 padding + 2px borders), the same trick
       as .form-checkbox-input. */
    padding: 0 12px;
    min-height: calc(14.5px + 20px + 2px);
    box-sizing: border-box;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}
.form-file-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13.5px;
    color: var(--text-ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.form-file-download {
    flex: 0 0 auto;
    font-size: 13px;
    color: var(--accent-bold);
    text-decoration: none;
}
.form-file-download:hover { text-decoration: underline; }

/* Compact, integrated action button inside the file row — sits within the
   input-height box without inflating it. */
.form-file-row .form-btn-secondary {
    flex: 0 0 auto;
    padding: 4px 10px;
    font-size: 13px;
}

.form-signature-pad {
    display: block;
    width: 100%;
    height: 180px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: #fff;
    touch-action: none;
    cursor: crosshair;
}
.form-signature-preview {
    display: block;
    max-width: 100%;
    height: auto;
    max-height: 180px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    margin-bottom: 8px;
}
.form-signature-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.form-help {
    font-size: 12.5px;
    color: var(--text-muted-2);
    margin: 6px 0 0;
    line-height: 1.45;
}

/* Language badge shown next to a LocalizedString field, marking which
   rendition (the active view language) the input edits. */
.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.form-submit {
    padding: 11px 22px;
    background: var(--btn-ink-bg);
    color: var(--btn-ink-fg);
    border: none;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: opacity .12s;
}
.form-submit:hover { opacity: 0.92; }
.form-submit:active { opacity: 0.85; }

/* Error card */
.form-error-card { border-color: var(--danger); }
.form-error-card h1 {
    font-family: "Bricolage Grotesque", system-ui, sans-serif;
    font-size: 24px;
    color: var(--danger);
    margin: 0 0 8px;
}
.form-error-detail {
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
    color: var(--text-muted);
    white-space: pre-wrap;
    overflow-x: auto;
}

/* Success card */
.form-done-card { text-align: center; }
.form-done-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 32px;
    font-weight: 700;
    display: grid;
    place-items: center;
    margin: 0 auto 16px;
}
.form-done-uid {
    margin: 16px 0;
    font-size: 12.5px;
    color: var(--text-muted-2);
}
.form-done-uid code {
    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 4px 8px;
}
.form-secondary-link {
    display: inline-block;
    margin-top: 12px;
    color: var(--link);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}
.form-secondary-link:hover { text-decoration: underline; }

@media (max-width: 640px) {
    .form-card { padding: 24px; border-radius: 10px; }
    .form-title { font-size: 26px; }
}

/* Field errors (public form and /flow) ------------------------------------- */
.form-field.has-error .form-input,
.form-field.has-error .form-file-row,
.form-field.has-error .form-checkbox-input { border-color: var(--danger); }
.form-field-error {
    font-size: 12.5px;
    color: var(--danger);
    margin: 6px 0 0;
    line-height: 1.45;
}

/* State-machine runner (/flow, specs/wizard-forms.md W5) ------------------- */
.flow-stepper {
    list-style: none;
    display: flex;
    gap: 8px;
    margin: 0 0 24px;
    padding: 0;
    overflow-x: auto;
}
.flow-step {
    flex: 1 1 0;
    min-width: 96px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding-top: 10px;
    border-top: 3px solid var(--line);
    color: var(--text-muted-2);
    font-size: 13px;
}
.flow-step.is-done { border-top-color: var(--accent-bold); color: var(--text-muted); }
.flow-step.is-current { border-top-color: var(--accent); color: var(--text-ink); font-weight: 600; }
.flow-step-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 600;
    background: var(--surface-2);
    border: 1px solid var(--line);
}
.flow-step.is-done .flow-step-dot { background: var(--accent-soft); border-color: transparent; color: var(--accent-soft-fg); }
.flow-step.is-current .flow-step-dot { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.flow-step-label { line-height: 1.3; }

.flow-banner,
.flow-notice {
    margin: 0 0 16px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13.5px;
    line-height: 1.45;
    background: var(--warm-bg);
    border: 1px solid var(--warm-line);
    color: var(--warm-text);
}
.flow-notice.is-error {
    background: var(--danger-soft);
    border-color: var(--danger);
    color: var(--danger);
}
.flow-notice ul { margin: 6px 0 0; padding-left: 18px; }

.flow-help {
    margin: 0 0 20px;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-body);
}
.flow-help > :first-child { margin-top: 0; }
.flow-help > :last-child { margin-bottom: 0; }

.flow-readonly {
    margin: 0 0 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.flow-waiting {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    margin: 0 0 20px;
    padding: 14px 16px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    font-size: 14px;
    color: var(--text-ink);
}
.flow-waiting p { margin: 4px 0 0; font-size: 13px; color: var(--text-muted); }
.flow-spinner {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    border-radius: 50%;
    border: 2px solid var(--line);
    border-top-color: var(--accent-bold);
    animation: flow-spin 0.9s linear infinite;
}
@keyframes flow-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .flow-spinner { animation-duration: 3s; } }

.flow-actions { flex-wrap: wrap; gap: 10px; align-items: center; }
.flow-btn { padding: 10px 16px; border-radius: 999px; font-size: 14px; }
/* A transition's parameters (a rejection's reason): its own form below the step. */
.flow-params {
    margin: 20px 0 0;
    padding: 18px 20px;
    border: 1px solid var(--warm-line);
    border-radius: 12px;
    background: var(--warm-bg);
    min-width: 0;
}
.flow-params[hidden] { display: none; }
.flow-params-title {
    padding: 0;
    margin-bottom: 14px;
    font-weight: 600;
    font-size: 15px;
    color: var(--text-ink);
    float: left;
    width: 100%;
}
.flow-params-title + * { clear: both; }
.flow-params-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 18px;
    padding-top: 14px;
}

/* Back sits on the left; it comes last in the DOM so Enter never presses it. */
.flow-btn-back { order: -1; margin-right: auto; }
.form-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.flow-params-note { text-align: right; }

.flow-resume {
    margin-top: 24px;
    padding: 14px 16px;
    border-radius: 10px;
    background: var(--warm-bg);
    border: 1px solid var(--warm-line);
    font-size: 13.5px;
    color: var(--text-body);
    text-align: left;
}
.flow-resume p { margin: 4px 0 10px; color: var(--text-muted); }
.flow-resume-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.flow-resume-link { color: var(--link); font-weight: 500; text-decoration: none; word-break: break-all; }
.flow-resume-link:hover { text-decoration: underline; }

@media (max-width: 640px) {
    .flow-step-label { font-size: 12px; }
    .flow-actions { justify-content: stretch; }
    .flow-actions > button { flex: 1 1 auto; }
    .flow-btn-back { margin-right: 0; }
}

/* Portals (/{lang}/p/{slug}, specs/portals.md) --------------------------------
   The built-in shell themes these through PortalThemes (custom properties in the page's
   <style>); a tenant wrapper that places {{PORTAL_NAV}} gets the defaults below. */
:root {
    --p-head: "Bricolage Grotesque", system-ui, sans-serif;
    --p-text: Inter, system-ui, sans-serif;
    --p-radius: 14px;
    --p-radius-sm: 10px;
    --p-pill: 999px;
}
.form-page.portal-page {
    display: flex; flex-direction: column; padding: 0; min-height: 100vh;
    background: var(--page-bg); color: var(--text-body); font-family: var(--p-text);
}
.portal-skip { position: absolute; left: -9999px; }
.portal-skip:focus { left: 16px; top: 16px; z-index: 10; background: var(--surface); color: var(--text-ink); padding: 8px 12px; border-radius: 8px; }

/* Top bar */
.portal-topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.portal-topbar-inner {
    max-width: 1120px; margin: 0 auto; padding: 12px 24px; box-sizing: border-box;
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px 28px;
}
.portal-brand {
    display: inline-flex; align-items: center; gap: 10px; text-decoration: none;
    font-family: var(--p-head); font-size: 19px; font-weight: 700; letter-spacing: -0.01em; color: var(--text-ink);
}
.portal-mark {
    width: 34px; height: 34px; border-radius: var(--p-radius-sm); flex-shrink: 0;
    background: var(--accent); color: var(--on-accent);
    display: inline-flex; align-items: center; justify-content: center;
    font-family: var(--p-head); font-size: 17px; font-weight: 700;
}
.portal-mark.is-large { width: 48px; height: 48px; font-size: 22px; }
.portal-logo { height: 34px; width: auto; max-width: 180px; object-fit: contain; }
.portal-logo.is-large { height: 48px; align-self: flex-start; }
.portal-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 22px; flex: 1 1 auto; font-size: 14.5px; }
.portal-nav-link {
    display: inline-flex; align-items: center; gap: 5px; padding: 8px 0;
    color: var(--text-muted); text-decoration: none;
}
.portal-nav-link:hover { color: var(--text-ink); }
.portal-nav-link.is-current { color: var(--text-ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.portal-lock { flex-shrink: 0; }
.portal-account { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.portal-avatar {
    width: 30px; height: 30px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-soft-fg);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0;
}
.portal-user { color: var(--text-muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-signout { margin: 0; }
.portal-signout-button { border: 0; background: none; padding: 6px 0; font: inherit; font-weight: 600; color: var(--text-ink); cursor: pointer; }
.portal-signout-button:hover { text-decoration: underline; }
.portal-signin-link {
    padding: 9px 16px; border-radius: var(--p-pill); background: var(--text-ink); color: var(--surface);
    font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.portal-langs { display: flex; padding: 2px; border: 1px solid var(--line); border-radius: var(--p-pill); }
.portal-lang { padding: 4px 9px; border-radius: var(--p-pill); font-size: 12px; font-weight: 600; color: var(--text-muted); text-decoration: none; }
.portal-lang.is-current { background: var(--accent-soft); color: var(--accent-soft-fg); }
.portal-lang:hover:not(.is-current) { color: var(--text-ink); }

/* Page frame */
.portal-main { flex: 1 0 auto; }
.portal-container { max-width: 1120px; margin: 0 auto; padding: 40px 24px 64px; box-sizing: border-box; }
/* A body that brings no container of its own (the wizard runner) still lines up. */
.portal-main > :not(.portal-container):not(.portal-hero):not(script) {
    max-width: 1072px; width: calc(100% - 48px); margin: 40px auto 64px; box-sizing: border-box;
}
.portal-crumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; font-size: 13.5px; color: var(--text-muted); }
.portal-crumbs a { color: var(--text-muted); text-decoration: none; }
.portal-crumbs a:hover { color: var(--text-ink); text-decoration: underline; }
.portal-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.portal-h1 {
    margin: 0; font-family: var(--p-head); font-size: clamp(28px, 4vw, 40px); font-weight: 700;
    line-height: 1.1; letter-spacing: -0.015em; color: var(--text-ink);
}
.portal-h2 { margin: 0 0 16px; font-family: var(--p-head); font-size: 18px; font-weight: 700; color: var(--text-ink); }
.portal-lead { margin: 8px 0 0; max-width: 680px; font-size: 16px; line-height: 1.55; color: var(--text-body); }
.portal-muted { margin: 0 0 12px; font-size: 14px; color: var(--text-muted); }
.portal-link { color: var(--link); font-weight: 500; text-decoration: none; }
.portal-link:hover { text-decoration: underline; }
.portal-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--p-radius); padding: 26px; }
.portal-panel.is-flush { padding: 0; overflow: hidden; }
.portal-notice { margin: 0 0 16px; padding: 12px 16px; border-radius: var(--p-radius-sm); background: var(--accent-soft); color: var(--accent-soft-fg); font-size: 14px; }
.portal-notice.is-error { background: var(--danger-soft); color: var(--danger); }
.portal-notice ul { margin: 6px 0 0; padding-left: 18px; }
.portal-button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px;
    border: 1px solid var(--line); border-radius: var(--p-pill); background: var(--surface); color: var(--text-ink);
    font: inherit; font-size: 14.5px; font-weight: 600; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.portal-button:hover { border-color: var(--accent-bold); }
.portal-button.is-primary { background: var(--btn-ink-bg); color: var(--btn-ink-fg); border-color: transparent; }
.portal-button.is-primary:hover { opacity: 0.92; }

/* Home */
.portal-hero .portal-container { padding: 72px 24px 32px; }
.portal-hero + .portal-container { padding-top: 8px; }
.portal-hero-title {
    margin: 0; max-width: 820px; font-family: var(--p-head); font-size: clamp(36px, 6vw, 56px); font-weight: 700;
    line-height: 1.05; letter-spacing: -0.02em; color: var(--text-ink);
}
.portal-hero-text { max-width: 680px; margin-top: 18px; font-size: 18px; line-height: 1.6; color: var(--text-body); }
.portal-hero-text > :first-child { margin-top: 0; }
.portal-hero-text a { color: var(--link); }
.portal-card-link {
    height: 100%; box-sizing: border-box; display: flex; flex-direction: column; gap: 12px; padding: 24px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--p-radius);
    color: var(--text-body); text-decoration: none; transition: border-color .12s;
}
.portal-card-link:hover { border-color: var(--accent-bold); }
.portal-card-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.portal-card-icon {
    flex-shrink: 0; width: 38px; height: 38px; border-radius: var(--p-radius-sm); background: var(--accent-soft); color: var(--accent-soft-fg);
    display: flex; align-items: center; justify-content: center;
}
.portal-card-link.is-locked .portal-card-icon { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--line); }
.portal-card-title, .portal-block-title {
    min-width: 0; font-family: var(--p-head); font-size: 19px; font-weight: 700; line-height: 1.25;
    letter-spacing: -0.01em; color: var(--text-ink);
}
.portal-card-text, .portal-block-text { font-size: 15px; line-height: 1.55; color: var(--text-muted); }
.portal-card-foot { margin-top: auto; display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; color: var(--text-muted); }
.portal-card-cta { color: var(--link); font-weight: 600; }

/* Home blocks (specs/portals.md § Section kinds): a six-column grid where a block takes two
   (a third), three (half) or six (the full width) columns, in the sections' order. A block with
   a height spans 1–4 row units and is at least that tall; what does not fit fades out above its
   «see more» link. A block without one is as tall as its content. */
.portal-blocks {
    --portal-row: 180px; --portal-gap: 20px;
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--portal-gap);
}
.portal-block { grid-column: span 2; min-width: 0; display: flex; }
.portal-block.is-half { grid-column: span 3; }
.portal-block.is-full { grid-column: span 6; }
.portal-block.is-h1 { --rows: 1; grid-row: span 1; }
.portal-block.is-h2 { --rows: 2; grid-row: span 2; }
.portal-block.is-h3 { --rows: 3; grid-row: span 3; }
.portal-block.is-h4 { --rows: 4; grid-row: span 4; }
.portal-block > * { flex: 1 1 auto; min-width: 0; }
.portal-block-panel {
    display: flex; flex-direction: column; box-sizing: border-box;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--p-radius); overflow: hidden;
}
.portal-block-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 12px; }
.portal-block-title { margin: 0; }
.portal-block-title a { color: var(--text-ink); text-decoration: none; }
.portal-block-title a:hover { text-decoration: underline; }
.portal-block-text { margin: 4px 0 0; }
.portal-block-body { flex: 1 1 auto; position: relative; }
.portal-block-inner > .md { padding: 0 22px 18px; }
/* Prose in a block and in a procedure's done text: the portal's text face, headings in its
   heading face a step below the page's; a block's leading h1 is its title, already shown. */
.portal-block-inner .md, .portal-done .md { font-size: 15.5px; line-height: 1.65; color: var(--text-body); }
.portal-block-inner .md > :first-child, .portal-done .md > :first-child { margin-top: 0; }
.portal-block-inner .md > h1:first-child { display: none; }
.portal-block-inner .md > h1:first-child + * { margin-top: 0; }
.portal-block-inner .md :is(p, ul, ol, blockquote), .portal-done .md :is(p, ul, ol, blockquote) { margin: 0 0 12px; }
.portal-block-inner .md :is(h1, h2, h3, h4), .portal-done .md :is(h1, h2, h3, h4) {
    margin: 20px 0 8px; font-family: var(--p-head); font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; color: var(--text-ink);
}
.portal-block-inner .md h1, .portal-done .md h1 { font-size: 22px; }
.portal-block-inner .md h2, .portal-done .md h2 { font-size: 18px; }
.portal-block-inner .md :is(h3, h4), .portal-done .md :is(h3, h4) { font-size: 16px; }
.portal-block-inner .md a, .portal-done .md a { color: var(--link); }
.portal-block-inner .md img { max-width: 100%; height: auto; border-radius: var(--p-radius-sm); }
.portal-block-inner > .portal-button { margin: 4px 22px 20px; }
.portal-block-inner > .portal-empty { padding: 24px 22px; }
.portal-block-inner .portal-rows { border-top: 1px solid var(--line); }
.portal-block-inner .portal-row { padding: 12px 22px; font-size: 15px; }
.portal-block-inner .portal-form.is-compact { margin: 0; border: 0; border-radius: 0; box-shadow: none; padding: 4px 22px 20px; background: transparent; }
.portal-block-foot { padding: 12px 22px 16px; border-top: 1px solid var(--line); font-size: 14px; }
/* A fixed height: the block's content never stretches its rows (size containment), the body takes
   what the head and foot leave, and what does not fit is cut under a fade. */
.portal-block.is-fixed {
    contain: size; min-height: calc(var(--portal-row) * var(--rows) + var(--portal-gap) * (var(--rows) - 1));
}
.portal-block.is-fixed > .portal-card-link { overflow: hidden; }
.portal-block.is-fixed .portal-block-body { flex: 1 1 0; min-height: 0; overflow: hidden; }
.portal-block.is-fixed .portal-block-inner { position: absolute; inset: 0; overflow: hidden; }
.portal-block.is-fixed .portal-block-body::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 44px; pointer-events: none;
    background: linear-gradient(to bottom, transparent, var(--surface));
}
.portal-button.is-small { padding: 6px 12px; font-size: 13.5px; }

/* A procedure's page: its form, its done text, the visitor's requests. */
.portal-form.is-compact .form-header { display: none; }
.portal-done { margin-bottom: 24px; }
.portal-requests { margin-top: 28px; }
.portal-requests .portal-h2 { margin: 0; padding: 18px 22px; border-bottom: 1px solid var(--line); }

/* Lists: search, rows (list mode), table (table mode), pager */
.portal-search {
    display: flex; align-items: center; gap: 10px; margin: 16px; padding: 0 6px 0 16px; height: 50px;
    border-radius: var(--p-pill); background: var(--surface-2); border: 1.5px solid var(--line); color: var(--text-muted);
}
.portal-search:focus-within { border-color: var(--accent); }
.portal-search-input { flex: 1 1 auto; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 16px; color: var(--text-ink); }
.portal-search-count { font-size: 13px; white-space: nowrap; }
.portal-search-clear { padding: 0 4px; font-size: 20px; line-height: 1; color: var(--text-muted); text-decoration: none; }
.portal-search-button {
    border: 0; border-radius: var(--p-pill); padding: 9px 16px; background: var(--btn-ink-bg); color: var(--btn-ink-fg);
    font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.portal-empty { margin: 0; padding: 44px 24px; text-align: center; color: var(--text-muted); }
.portal-search + .portal-rows, .portal-search + .portal-table-wrap, .portal-search + .portal-empty { border-top: 1px solid var(--line); }
.portal-rows { list-style: none; margin: 0; padding: 0; }
.portal-rows li + li { border-top: 1px solid var(--line); }
.portal-row {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 22px;
    font-size: 16px; color: var(--text-ink); text-decoration: none;
}
.portal-row:hover { background: var(--surface-2); }
.portal-row svg { flex-shrink: 0; color: var(--text-muted); }
.portal-table-wrap { overflow-x: auto; }
.portal-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.portal-table th {
    text-align: left; padding: 12px 18px; background: var(--surface-2); color: var(--text-muted);
    font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.portal-table th.is-sorted { color: var(--text-ink); }
.portal-sort { display: inline-flex; align-items: center; gap: 6px; color: inherit; text-decoration: none; }
.portal-sort:hover { color: var(--text-ink); }
.portal-sort-arrow { font-size: 10px; opacity: 0.3; }
.portal-table th.is-sorted .portal-sort-arrow { opacity: 1; }
.portal-table td { padding: 13px 18px; border-bottom: 1px solid var(--line); color: var(--text-body); vertical-align: top; }
.portal-table tbody tr:last-child td { border-bottom: 0; }
.portal-table tbody tr:hover td { background: var(--surface-2); }
.portal-table td.is-primary a { color: var(--text-ink); font-weight: 600; text-decoration: none; }
.portal-table td.is-primary a:hover { text-decoration: underline; }
.portal-badge {
    display: inline-block; padding: 3px 10px; border-radius: var(--p-pill); background: var(--accent-soft); color: var(--accent-soft-fg);
    font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.portal-pager { display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-top: 1px solid var(--line); font-size: 13.5px; }
.portal-pager a { color: var(--link); font-weight: 500; text-decoration: none; }
.portal-count { margin-right: auto; color: var(--text-muted); }

/* Record */
.portal-detail { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 20px; }
.portal-detail-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.portal-detail-side { flex: 1 1 300px; min-width: 0; }
.portal-fields { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px 32px; }
.portal-field dt { margin-bottom: 5px; font-size: 13px; color: var(--text-muted); }
.portal-field dd { margin: 0; font-size: 16px; color: var(--text-ink); overflow-wrap: anywhere; }
.portal-field dd.is-multiline { white-space: pre-line; }
.portal-file-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.portal-file {
    display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line);
    border-radius: var(--p-radius-sm); background: var(--surface-2); color: var(--text-ink); text-decoration: none;
}
.portal-file:hover { border-color: var(--accent-bold); }
.portal-file svg { flex-shrink: 0; color: var(--text-muted); }
.portal-file-kind {
    width: 44px; height: 44px; flex-shrink: 0; border-radius: var(--p-radius-sm); background: var(--accent-soft); color: var(--accent-soft-fg);
    display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
}
.portal-file-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.portal-file-name { font-size: 14.5px; font-weight: 600; overflow-wrap: anywhere; }
.portal-file-meta { font-size: 12.5px; color: var(--text-muted); }
.portal-upload { display: flex; flex-direction: column; gap: 10px; }
.portal-drop {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 16px;
    border: 1.5px dashed var(--line); border-radius: var(--p-radius-sm); text-align: center; font-size: 14px; color: var(--text-body); cursor: pointer;
}
.portal-drop svg { color: var(--accent-soft-fg); }
.portal-drop strong { color: var(--text-ink); }
.portal-drop.is-over, .portal-drop:focus-within { border-color: var(--accent); background: var(--accent-soft); }
.portal-drop-name { font-size: 12.5px; color: var(--text-muted); overflow-wrap: anywhere; }
.portal-drop.has-file .portal-drop-name { color: var(--text-ink); font-weight: 600; }
.portal-drop-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

/* Sign-in */
.portal-signin-card {
    max-width: 900px; margin: 24px auto 0; display: flex; flex-wrap: wrap; overflow: hidden;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--p-radius);
}
.portal-signin-side { flex: 1 1 300px; padding: 40px; display: flex; flex-direction: column; gap: 16px; background: var(--accent-soft); color: var(--text-body); }
.portal-signin-side-title { margin: 0; font-family: var(--p-head); font-size: 26px; font-weight: 700; line-height: 1.2; color: var(--text-ink); }
.portal-signin-side-lead { margin: 0; font-size: 14.5px; }
.portal-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 15px; }
.portal-checks li { display: flex; align-items: flex-start; gap: 10px; }
.portal-checks svg { flex-shrink: 0; margin-top: 2px; color: var(--accent-soft-fg); }
.portal-signin-side-note { margin: auto 0 0; font-size: 13px; line-height: 1.5; color: var(--text-muted); }
.portal-signin-main { flex: 1 1 360px; padding: 40px; display: flex; flex-direction: column; gap: 14px; }
.portal-signin-main .portal-lead { margin: 0; }
.portal-signin-form { display: flex; flex-direction: column; gap: 12px; margin: 6px 0 0; }
.portal-signin-form .portal-button { height: 48px; }
.portal-label { font-size: 14px; font-weight: 600; color: var(--text-ink); }
.portal-input {
    width: 100%; height: 48px; box-sizing: border-box; padding: 0 16px; border: 1.5px solid var(--line); border-radius: var(--p-radius-sm);
    background: var(--surface-2); font: inherit; font-size: 16px; color: var(--text-ink);
}
.portal-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent); }
.portal-google { display: flex; justify-content: center; min-height: 44px; }
.portal-code { font-family: "JetBrains Mono", monospace; font-size: 22px; letter-spacing: 0.25em; }
.portal-or { display: flex; align-items: center; gap: 12px; margin: 4px 0; font-size: 13px; color: var(--text-muted); }
.portal-or::before, .portal-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Static pages, errors, forms in the portal's type */
.portal-page-content { color: var(--text-body); line-height: 1.65; }
.portal-page-content > :first-child { margin-top: 0; }
.portal-page-content h1 { font-family: var(--p-head); font-size: 32px; font-weight: 700; letter-spacing: -0.02em; color: var(--text-ink); margin: 0 0 16px; }
.portal-page-content h2 { font-family: var(--p-head); font-size: 20px; color: var(--text-ink); margin: 28px 0 10px; }
.portal-page-content a { color: var(--link); }
.portal-error { border-color: var(--danger); }
.portal-page .form-card { border-radius: var(--p-radius); box-shadow: none; }
.portal-page .form-title, .portal-page .form-group-title { font-family: var(--p-head); }
.portal-page .form-input { border-radius: var(--p-radius-sm); }
.portal-page .form-submit, .portal-page .form-btn-secondary { border-radius: var(--p-pill); }
.portal-cancel { text-decoration: none; margin-right: auto; }

/* Footer */
.portal-footer { border-top: 1px solid var(--line); background: var(--surface); }
.portal-footer-inner {
    max-width: 1120px; margin: 0 auto; padding: 20px 24px; box-sizing: border-box;
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; font-size: 13.5px; color: var(--text-muted);
}
.portal-pages { display: flex; flex-wrap: wrap; gap: 20px; }
.portal-page-link { color: var(--text-muted); text-decoration: none; }
.portal-page-link:hover { color: var(--text-ink); text-decoration: underline; }

@media (min-width: 721px) and (max-width: 960px) {
    .portal-block { grid-column: span 3; }
    .portal-block.is-full { grid-column: span 6; }
}

@media (max-width: 720px) {
    .portal-topbar-inner { padding: 10px 16px; gap: 6px 14px; }
    .portal-brand { flex: 1 1 auto; }
    .portal-nav { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; gap: 18px; }
    .portal-nav-link { white-space: nowrap; }
    .portal-user { display: none; }
    .portal-container { padding: 24px 16px 48px; }
    .portal-hero .portal-container { padding: 40px 16px 20px; }
    .portal-blocks { grid-template-columns: minmax(0, 1fr); }
    .portal-block, .portal-block.is-half, .portal-block.is-full { grid-column: auto; }
    .portal-main > :not(.portal-container):not(.portal-hero):not(script) { width: calc(100% - 32px); margin: 24px auto 48px; }
    .portal-signin-side, .portal-signin-main { padding: 28px 24px; }
    .portal-search { margin: 12px; }
    .portal-search-count { display: none; }
    /* The table turns into one card per record, each value under its column's name. */
    .portal-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .portal-table, .portal-table tbody, .portal-table tr, .portal-table td { display: block; width: auto; }
    .portal-table tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
    .portal-table tbody tr:last-child { border-bottom: 0; }
    .portal-table td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; text-align: right; }
    .portal-table td::before { content: attr(data-label); color: var(--text-muted); font-size: 13px; text-align: left; }
    .portal-table td.is-primary { padding-bottom: 6px; text-align: left; }
    .portal-table td.is-primary::before { content: none; }
    .portal-table td.is-primary a { font-size: 16px; }
    .portal-table tbody tr:hover td { background: none; }
}
