/* ==========================================================================
   MSD / MobileSkys portal — single stylesheet
   Brand: sky-blue + silver-grey. Vanilla CSS, no build step.

   Structure:
     1. Design tokens (light/dark via light-dark(), scales)
     2. Reset + base typography
     3. Accessibility primitives
     4. Shell (header, nav, admin nav, brand band, layout)
     5. Components
     6. Responsive
   ========================================================================== */

/* ---------- 1. Design tokens ------------------------------------------------ */
:root {
    color-scheme: light dark;

    /* Brand — day sky / night sky */
    --brand:   light-dark(#1f9fd8, #4db8e8);
    --brand-d: light-dark(#1782b4, #6fc6ee);   /* hover: deepens by day, brightens by night */
    --brand-l: light-dark(#e8f5fc, #132a3b);   /* pale sky tint — row hover, highlights */
    --sky-a:   light-dark(#7ec9ec, #0a1420);   /* gradient top */
    --sky-b:   light-dark(#1f9fd8, #173a52);   /* gradient bottom */
    --silver:  light-dark(#9aa0a6, #7b8794);

    /* Neutrals */
    --bg:      light-dark(#f4f7f9, #0d1620);
    --panel:   light-dark(#ffffff, #16222f);
    --panel-2: light-dark(#f8fafc, #1d2c3c);   /* raised / hover surface */
    --ink:     light-dark(#1f2a37, #dce7f0);
    --muted:   light-dark(#5d6b7a, #93a5b7);
    --line:    light-dark(#e3e9ef, #263647);

    /* Status */
    --ok-bg:   light-dark(#dcfce7, #10301d); --ok-fg:   light-dark(#166534, #7fe0a7);
    --err-bg:  light-dark(#fee2e2, #3a1a1d); --err-fg:  light-dark(#991b1b, #f2a0a0);
    --warn-bg: light-dark(#fef9c3, #33290e); --warn-fg: light-dark(#854d0e, #e8c26a);
    --info-bg: light-dark(#e0f2fe, #0f2a3d); --info-fg: light-dark(#075985, #86cef2);

    /* Code surfaces (dark in both themes, slightly deeper by night) */
    --code-bg:     light-dark(#1e293b, #0b1520);
    --code-head:   light-dark(#0f172a, #060d15);
    --code-ink:    #e2e8f0;
    --code-muted:  #94a3b8;
    --code-line:   #334155;

    /* Spacing scale */
    --space-1: .25rem;
    --space-2: .5rem;
    --space-3: .75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4rem;

    /* Type scale */
    --text-xs:   .75rem;
    --text-sm:   .875rem;
    --text-base: 1rem;
    --text-lg:   1.125rem;
    --text-xl:   1.375rem;
    --text-2xl:  1.75rem;

    /* Radii */
    --radius-sm: 8px;
    --radius:    12px;
    --radius-lg: 16px;

    /* Shadows / focus ring */
    --shadow-c:  light-dark(rgba(16, 42, 67, .06), rgba(0, 0, 0, .35));
    --shadow-1:  0 1px 2px var(--shadow-c);
    --shadow-2:  0 1px 2px var(--shadow-c), 0 4px 16px var(--shadow-c);
    --shadow:    var(--shadow-2); /* legacy alias */
    --ring-c:    light-dark(rgba(31, 159, 216, .35), rgba(77, 184, 232, .45));
    --ring:      0 0 0 3px var(--ring-c);

    /* Fonts */
    --font-body:    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-display: "Raleway", system-ui, sans-serif;
    --font-mono:    ui-monospace, "Cascadia Code", Consolas, monospace;

    /* Non-color theme switches (overridden in the dark blocks below) */
    --logo-filter: none;
    --show-sun:  none;          /* sun icon appears in dark mode (invites daylight) */
    --show-moon: inline-flex;
}

/* Explicit user choice beats the OS preference */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

/* Non-color switches — light-dark() only covers colors, so this one small
   block is duplicated for the two ways dark mode can be reached. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --logo-filter: brightness(0) invert(1);
        --show-sun:  inline-flex;
        --show-moon: none;
    }
}
:root[data-theme="dark"] {
    --logo-filter: brightness(0) invert(1);
    --show-sun:  inline-flex;
    --show-moon: none;
}

/* ---------- 2. Reset + base -------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--text-base);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

img, svg { vertical-align: middle; }
img { max-width: 100%; }

button, input, select, textarea {
    font-family: inherit;
    font-size: 100%;
    line-height: 1.15;
    margin: 0;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    color: var(--ink);
    line-height: 1.25;
    letter-spacing: -.01em;
}
h1 { font-size: var(--text-xl);   margin: 0 0 var(--space-4); font-weight: 700; }
h2 { font-size: var(--text-lg);   font-weight: 700; }
h3 { font-size: var(--text-base); font-weight: 700; }
h4 { font-size: var(--text-sm);   font-weight: 700; }

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

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: var(--space-5) 0;
}

/* ---------- 3. Accessibility primitives -------------------------------------- */
.skip-link {
    position: absolute;
    left: var(--space-4);
    top: -100px;
    z-index: 100;
    background: var(--panel);
    color: var(--brand-d);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-2);
    font-weight: 600;
    text-decoration: none;
}
.skip-link:focus { top: var(--space-2); }

.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;
}

:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

/* Anchor targets shouldn't hide under the sticky header */
main, h1, h2, h3, h4 { scroll-margin-top: 5rem; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }
}

/* Small layout utilities */
.mt-1 { margin-top: var(--space-1); }
.form-footer { margin-top: var(--space-4); }
.mt-4 { margin-top: var(--space-4); }
.section-title { margin-top: var(--space-5); }
.help { color: var(--muted); font-size: var(--text-sm); margin: .25rem 0 0; }
.toolbar-actions { display: inline-flex; gap: .6rem; }

/* ---------- 4. Shell ---------------------------------------------------------- */
header.portal {
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    padding: .6rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: var(--shadow-1);
}
header.portal .brand {
    display: flex;
    align-items: center;
}
header.portal .brand a {
    display: inline-flex;
    align-items: center;
    line-height: 0;
    border-radius: var(--radius-sm);
}
header.portal .brand img {
    display: block;
    height: 32px;
    width: auto;
    filter: var(--logo-filter);
}
header.portal nav {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    justify-content: flex-end;
}
header.portal nav a {
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
    font-size: var(--text-sm);
    padding: .4rem .65rem;
    border-radius: var(--radius-sm);
    transition: color .15s ease, background .15s ease;
}
header.portal nav a:hover {
    color: var(--brand-d);
    background: var(--brand-l);
}
header.portal nav span {
    color: var(--muted);
    font-size: var(--text-sm);
    margin-right: var(--space-2);
}
header.portal nav form { display: inline; margin: 0; }

/* Bordered icon-only button (theme toggle etc.) */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--muted);
    padding: .45rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.icon-btn:hover {
    background: var(--brand-l);
    border-color: var(--brand);
    color: var(--brand-d);
}
#theme-toggle { margin-left: var(--space-2); }
#theme-toggle .icon-sun  { display: var(--show-sun); }
#theme-toggle .icon-moon { display: var(--show-moon); }

/* Admin sub-navigation tab strip */
.admin-nav {
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}
.admin-nav-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.25rem;
    display: flex;
    gap: var(--space-1);
}
.admin-nav a {
    display: inline-block;
    padding: .55rem .9rem;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: var(--text-sm);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color .15s ease, border-color .15s ease;
}
.admin-nav a:hover { color: var(--ink); }
.admin-nav a.active {
    color: var(--brand-d);
    border-bottom-color: var(--brand);
}

/* Signature sky band: day sky by light, night sky by dark */
.brand-band {
    background: linear-gradient(160deg, var(--sky-a), var(--sky-b));
    color: #fff;
    border-radius: var(--radius);
    padding: var(--space-5) var(--space-6);
    margin-bottom: var(--space-5);
    box-shadow: var(--shadow-2);
}
.brand-band h1, .brand-band h2 { color: #fff; margin: 0; }
.brand-band p { color: rgba(255, 255, 255, .85); margin: var(--space-1) 0 0; }

/* Auth screens sit on the full sky gradient */
body.auth {
    min-height: 100vh;
    background: linear-gradient(180deg, var(--sky-a), var(--sky-b)) fixed;
}

main {
    max-width: 960px;
    margin: 2rem auto;
    padding: 0 1.25rem;
}

/* ---------- 5. Components ----------------------------------------------------- */

/* ----- Panels & cards ----- */
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: var(--shadow-2);
}
.panel.narrow {
    max-width: 420px;
    margin: 1.5rem auto 3rem;
}

/* Sign-in card + brand mark on the sky gradient */
.auth-logo {
    max-width: 420px;
    margin: 3rem auto 0;
    text-align: center;
}
.auth-logo img { height: 56px; width: auto; }
body.auth .auth-logo img { filter: brightness(0) invert(1); }
body.auth .panel.narrow {
    border: 0;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 40px rgba(4, 24, 40, .28);
}

.grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    margin-top: 1.25rem;
}
.card {
    border: 1px solid var(--line);
    border-top: 3px solid var(--brand);
    border-radius: var(--radius-sm);
    padding: 1.1rem;
    background: var(--panel);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: .75rem;
    transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-2);
}
.card h3 { margin: 0 0 .35rem; font-size: 1.05rem; }
.card-head {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .35rem;
}
.card-head h3 { margin: 0; }
.card-desc {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    margin: 0;
}

/* Multi-perspective project cards: full row, one .grant-row per grant */
.card-multi { grid-column: 1 / -1; }
.grant-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}
.grant-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .6rem 0;
    border-top: 1px solid var(--line);
}
.grant-info {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    min-width: 0;
}
.grant-label {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.grant-meta { font-size: .85rem; margin: 0; }

/* Project initials tile; --tile-h carries a per-project hue (data, not styling) */
.monogram {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: .95rem;
    letter-spacing: .02em;
    color: #fff;
    background: linear-gradient(145deg, hsl(var(--tile-h, 201) 62% 55%), hsl(var(--tile-h, 201) 62% 42%));
}

.empty {
    color: var(--muted);
    padding: 2.5rem;
    text-align: center;
}
.empty .icon, .table-empty .icon {
    display: block;
    margin: 0 auto var(--space-2);
    width: 28px;
    height: 28px;
    opacity: .5;
}
.table-empty {
    text-align: center;
    color: var(--muted);
    padding: var(--space-7) var(--space-4);
}

.icon { flex-shrink: 0; }

/* ----- Buttons ----- */
button, .btn,
input[type='submit'] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    background: var(--brand);
    color: #fff;
    border: 1px solid var(--brand);
    border-radius: var(--radius-sm);
    padding: .6rem 1.2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s ease, box-shadow .15s ease;
}
button:hover, .btn:hover, input[type='submit']:hover {
    background: var(--brand-d);
    border-color: var(--brand-d);
}
.btn.secondary, button.secondary {
    background: var(--panel);
    color: var(--ink);
    border: 1px solid var(--line);
}
.btn.secondary:hover, button.secondary:hover {
    background: var(--panel-2);
    border-color: var(--silver);
    color: var(--ink);
}
.btn.danger-quiet, button.danger-quiet {
    background: transparent;
    color: var(--err-fg);
    border-color: transparent;
}
.btn.danger-quiet:hover, button.danger-quiet:hover {
    background: var(--err-bg);
    border-color: var(--err-bg);
    color: var(--err-fg);
}
/* Launch CTA: arrow nudges toward the corner on hover */
.btn-launch .icon { transition: transform .15s ease; }
.btn-launch:hover .icon { transform: translate(2px, -2px); }
/* Spacing only when a button trails form fields */
form > button, form > .btn, form > input[type='submit'] { margin-top: 1rem; }
.form-actions {
    display: flex;
    gap: .6rem;
    align-items: center;
    margin-top: var(--space-4);
}
.form-actions > button, .form-actions > .btn, .form-actions > input[type='submit'] { margin-top: 0; }

/* ---------- Forms ----------------------------------------------------------- */
label {
    display: block;
    font-weight: 600;
    margin: .85rem 0 .3rem;
    font-size: .9rem;
}
.input { margin-bottom: 1.1rem; }

/* Inline GET filter bar above admin index tables */
.filter-row {
    display: flex;
    align-items: flex-end;
    gap: .75rem;
    flex-wrap: wrap;
    margin: .5rem 0 1rem;
}
.filter-row .input { margin-bottom: 0; }
.filter-row > button { margin-top: 0; }
.input:has(input[type='checkbox']) label,
.input:has(input[type='radio']) label {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-weight: 500;
}
input[type='text'], input[type='email'], input[type='password'],
input[type='url'], input[type='number'], select, textarea {
    width: 100%;
    padding: .6rem .7rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    color: var(--ink);
    background: var(--panel);
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--ring);
}
textarea { resize: vertical; }
.input.required > label::after { content: ' *'; color: var(--err-fg); }
.error-message, .error > .error-message {
    color: var(--err-fg);
    font-size: .85rem;
    margin-top: .3rem;
}
.input.error input, .input.error select, .input.error textarea {
    border-color: var(--err-fg);
}

/* MFA code entry */
input.code-input {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    letter-spacing: .35em;
    text-align: center;
}

/* QR codes stay on a white tile so they scan in dark mode */
.qr-wrap { text-align: center; margin: var(--space-4) 0; }
.qr-tile {
    display: inline-block;
    background: #fff;
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
}

/* ---------- Tables ---------------------------------------------------------- */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
table.list {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.25rem;
}
/* Safety net for column-heavy tables on narrow screens; normally inert */
.table-scroll { overflow-x: auto; }
/* Long unbreakable identifiers (backend UUIDs) truncate instead of forcing
   the table wide; the full value stays in the title tooltip. */
.cell-clip {
    display: inline-block;
    max-width: 18ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}
.table-note { font-size: .78rem; white-space: nowrap; margin-top: .15rem; }
table.list th, table.list td {
    text-align: left;
    padding: .65rem .7rem;
    border-bottom: 1px solid var(--line);
    font-size: .92rem;
    vertical-align: middle;
}
table.list td { font-variant-numeric: tabular-nums; }
table.list th {
    color: var(--muted);
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}
table.list tbody tr { transition: background .12s ease; }
table.list tbody tr:hover { background: var(--brand-l); }

/* ---------- Badges ---------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    line-height: 1.4;
}
.badge.on      { background: var(--ok-bg);   color: var(--ok-fg); }
.badge.off     { background: var(--err-bg);  color: var(--err-fg); }
.badge.neutral { background: var(--panel-2); color: var(--muted); }
.badge.warn    { background: var(--warn-bg); color: var(--warn-fg); }

/* ----- Actions / toolbar ----- */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
/* Keep td.actions a real table-cell (flex on a td breaks row layout once
   the table is column-heavy); icons sit inline, cell never wraps. */
.actions { white-space: nowrap; width: 1%; }
.actions a, .actions form { display: inline-flex; vertical-align: middle; margin: 0; }
.actions > * + * { margin-left: .25rem; }
.actions a {
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: .9rem;
    padding: .35rem .5rem;
    border-radius: 6px;
    transition: color .15s ease, background .15s ease;
}
.actions a:hover { color: var(--brand-d); background: var(--brand-l); }
.actions a.danger:hover { color: var(--err-fg); background: var(--err-bg); }
.actions form button {
    margin: 0;
    padding: .35rem .5rem;
    font-size: .85rem;
    background: transparent;
    color: var(--muted);
    border: 0;
    border-radius: 6px;
}
.actions form button:hover { background: var(--brand-l); color: var(--brand-d); }
.actions form button.danger:hover { background: var(--err-bg); color: var(--err-fg); }

/* ---------- Misc ------------------------------------------------------------ */
.muted { color: var(--muted); font-size: .92rem; }
code, code.secret {
    font-family: var(--font-mono);
    background: var(--panel-2);
    padding: .15rem .4rem;
    border-radius: 6px;
    font-size: .88em;
}
code.secret { display: inline-block; padding: .3rem .5rem; letter-spacing: .1em; }

/* ----- Flash messages ----- */
.flash, .message {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    border-left: 4px solid transparent;
    margin-bottom: 1rem;
    background: var(--panel-2);
    color: var(--ink);
    border-left-color: var(--muted);
}
.message.hidden { display: none; }
.message .flash-icon { margin-top: .15rem; }
.message .flash-text { flex: 1; }
.flash-dismiss {
    background: transparent;
    border: 0;
    color: inherit;
    opacity: .65;
    padding: .15rem;
    margin: 0;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
}
.flash-dismiss:hover { opacity: 1; background: transparent; border: 0; color: inherit; }
.flash.success, .message.success { background: var(--ok-bg);   color: var(--ok-fg);   border-left-color: var(--ok-fg); }
.flash.error,   .message.error   { background: var(--err-bg);  color: var(--err-fg);  border-left-color: var(--err-fg); }
.flash.warning, .message.warning { background: var(--warn-bg); color: var(--warn-fg); border-left-color: var(--warn-fg); }
.flash.info,    .message.info    { background: var(--info-bg); color: var(--info-fg); border-left-color: var(--info-fg); }

/* ---------- Setup kit ------------------------------------------------------- */
.kit-lede { font-size: 1rem; margin: 0 0 1rem; }

/* Callouts: static advice boxes (unlike .flash, not dismissable) */
.callout {
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    border-left: 4px solid transparent;
    margin: .75rem 0;
    font-size: .92rem;
}
.callout strong { display: block; margin-bottom: .15rem; }
.callout.info { background: var(--info-bg); color: var(--info-fg); border-left-color: var(--info-fg); }
.callout.warn { background: var(--warn-bg); color: var(--warn-fg); border-left-color: var(--warn-fg); }

/* Download cards */
.kit-files { margin-top: .75rem; }
.file-card h3 { font-size: .95rem; word-break: break-word; }
.file-card h3 code { font-size: .95em; }
.file-card .file-dest {
    display: block;
    font-family: var(--font-mono);
    font-size: .78rem;
    color: var(--muted);
    margin: .1rem 0 .4rem;
    word-break: break-word;
}
.file-card p { margin: 0; font-size: .85rem; }
.file-card .btn { align-self: flex-start; padding: .45rem .9rem; font-size: .9rem; }

/* Numbered vertical stepper */
.kit-steps-title { margin-top: 2rem; }
ol.steps { list-style: none; margin: 1.25rem 0 0; padding: 0; }
.step { position: relative; padding: 0 0 2.25rem 3.25rem; }
.step:last-child { padding-bottom: 0; }
.step::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 38px;
    bottom: 4px;
    width: 2px;
    background: var(--line);
}
.step:last-child::before { display: none; }
.step-marker {
    position: absolute;
    left: 0;
    top: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.step-head {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    min-height: 32px;
}
.step-head h3 { margin: 0; font-size: 1.08rem; }
.step-body h4 { margin: 1.25rem 0 .4rem; font-size: .95rem; }
.step-body > p, .step-body .callout { margin: .5rem 0 .65rem; }
.step-cta { display: flex; gap: .6rem; flex-wrap: wrap; }
.step-cta form { display: inline-block; }

/* Step-kind chips */
.chip {
    display: inline-block;
    padding: .15rem .6rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .02em;
    line-height: 1.4;
}
.chip.file   { background: var(--brand-l); color: var(--brand-d); }
.chip.code   { background: var(--panel-2); color: var(--muted); }
.chip.portal { background: var(--ok-bg);   color: var(--ok-fg); }

/* Dark code blocks with a location caption and copy button */
.codeblock {
    margin: .75rem 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.codeblock figcaption {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    background: var(--code-head);
    padding: .4rem .5rem .4rem .9rem;
}
.codeblock figcaption code {
    background: transparent;
    color: var(--code-muted);
    padding: 0;
    font-size: .78rem;
    overflow-wrap: anywhere;
}
/* Long paths/URLs in inline code must wrap, not widen the page */
.kit .step-body code, .kit .kit-lede code, .kit .file-card code { overflow-wrap: anywhere; }
.codeblock pre {
    margin: 0;
    background: var(--code-bg);
    color: var(--code-ink);
    padding: .9rem 1rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-variant-ligatures: none;
    font-size: .84rem;
    line-height: 1.55;
    tab-size: 4;
}
.codeblock pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    font-size: 1em;
    display: block;
}
.copy-btn {
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--code-line);
    color: #cbd5e1;
    border-radius: 6px;
    padding: .2rem .65rem;
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.copy-btn:hover { background: var(--code-line); color: #fff; border-color: var(--code-line); }
.copy-btn.copied, .copy-btn.copied:hover { background: transparent; color: #4ade80; border-color: #4ade80; }

/* Collapsible long files / optional alternatives */
details.snippet {
    margin: .75rem 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel-2);
}
details.snippet summary {
    cursor: pointer;
    padding: .55rem .9rem;
    font-weight: 600;
    font-size: .88rem;
    color: var(--brand-d);
    user-select: none;
}
details.snippet summary:hover { color: var(--brand); }
details.snippet[open] > summary { border-bottom: 1px solid var(--line); }
details.snippet > *:not(summary) { margin: .75rem .9rem; }

/* ---------- Responsive ------------------------------------------------------ */
@media screen and (max-width: 640px) {
    header.portal { padding: .6rem 1rem; }
    header.portal nav { gap: .75rem; }
    header.portal nav span { display: none; }          /* hide email, keep links */
    header.portal .brand img { height: 26px; }
    main { margin: 1.25rem auto; }
    .panel { padding: 1.25rem; }
    .grid { grid-template-columns: 1fr; }
    .card .btn, .card button { width: 100%; text-align: center; }
    .step { padding-left: 2.6rem; }
    .step-marker { width: 26px; height: 26px; font-size: .85rem; }
    .step::before { left: 12px; top: 32px; }
    .step-head { min-height: 26px; }
}
@media screen and (max-width: 480px) {
    form > button, form > .btn, form > input[type='submit'] { width: 100%; text-align: center; }
}
