/* =====================================================
   ChannelGrave — clinical morgue document
   Palette: near-black page, parchment certificate,
   one accent (surgical red) reserved for cause of
   death, severity, and the flatline.
   ===================================================== */

:root {
    /* page */
    --bg: #0E0F0D;
    --bg-deep: #090A08;
    --chrome: #9A968A;        /* UI text on dark */
    --chrome-dim: #5E5C52;
    --bone: #D8D3C3;
    --line: #262722;

    /* certificate */
    --parchment: #EAE3CF;
    --parchment-deep: #DFD6BD;
    --card-ink: #221F18;
    --card-faint: #6E6852;
    --card-line: #B7AD92;

    /* accents */
    --red: #B3322B;
    --amber: #B98A2E;
    --green: #4E7D58;

    /* type */
    --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    --sans: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --mono: 'Courier New', Courier, monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    overflow-x: clip;
}

body {
    background:
        radial-gradient(110% 70% at 50% 0%, #14151200 0%, transparent 60%),
        var(--bg);
    color: var(--bone);
    font-family: var(--sans);
    font-size: 16px;
    min-height: 100vh;
    line-height: 1.6;
}

body.is-loading {
    overflow: hidden;
}

.container {
    max-width: 820px;
    margin: 0 auto;
    padding: clamp(1.25rem, 4vw, 2.5rem) 1rem 4rem;
}

/* ===================== Header ===================== */
header {
    text-align: center;
    margin-bottom: clamp(1.5rem, 5vw, 3rem);
}

h1 {
    font-family: var(--serif);
    font-size: clamp(1.6rem, 0.8rem + 4vw, 3.4rem);
    letter-spacing: clamp(0.1em, 0.02em + 1.1vw, 0.28em);
    font-weight: 600;
    color: var(--bone);
    text-indent: clamp(0.1em, 0.02em + 1.1vw, 0.28em); /* optically recenter letterspaced caps */
}

h1 .accent {
    font-weight: 700;
}

.subtitle {
    font-family: var(--mono);
    font-size: 0.78rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--chrome-dim);
    margin-top: 0.6rem;
}

.hero-headline {
    font-family: var(--serif);
    font-weight: 600;
    font-size: clamp(1.45rem, 1rem + 2.4vw, 2.3rem);
    line-height: 1.22;
    color: var(--bone);
    max-width: 30ch;
    margin: 1.1rem auto 0;
}

.hero-headline-accent {
    color: var(--chrome);
    font-style: italic;
    font-weight: 500;
}

.hero-pitch {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--chrome);
    margin-top: 0.8rem;
}

.header-rule {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--chrome-dim), transparent);
    margin: 1.4rem auto 0;
    width: 60%;
    opacity: 0.5;
}

/* ===================== Intake form ===================== */
.input-group {
    display: flex;
    gap: 0;
    border: 1px solid var(--line);
    background: #131410;
}

#channel-url {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    padding: 0.9rem 1rem;
    min-height: 48px;
    color: var(--bone);
    font-family: var(--mono);
    font-size: 1rem;
}

#channel-url::placeholder {
    color: #5A584E;
}

#channel-url:focus {
    outline: none;
    background: #181913;
}

#submit-btn {
    background: #1B1C17;
    border: none;
    border-left: 1px solid var(--line);
    color: var(--bone);
    padding: 0.9rem 2rem;
    min-height: 48px;
    font-family: var(--sans);
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.18em;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

#submit-btn:hover {
    background: var(--bone);
    color: var(--bg);
}

#submit-btn:disabled {
    color: #4A483E;
    background: #15160F;
    cursor: not-allowed;
}

/* ===================== Hero diagnostic band ===================== */
.hero-ekg {
    margin-top: clamp(1.5rem, 4vw, 2.25rem);
}

.ekg-hero {
    display: block;
    width: 100%;
    height: 90px;
}

.hero-tagline {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    text-align: center;
    color: #9aa080;
    opacity: 0.75;
    margin-top: 0.85rem;
}

.severity-scale {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1px;                                  /* faint olive grid shows through */
    background: rgba(154, 160, 128, 0.18);
    border: 1px solid rgba(154, 160, 128, 0.18);
    margin-top: 0.75rem;
}

.sev-cell {
    background: var(--bg);                      /* lets the 1px gap read as a divider */
    padding: 0.55rem 0.4rem;
    text-align: center;
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1.3;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #9aa080;
}

/* Future hook: brighten the cell matching the live diagnosis severity_band.
   Intentionally unused until the results page wires it up. */
.sev-cell.is-active {
    color: #e8ecc8;
    background: rgba(154, 160, 128, 0.10);
}

@media (max-width: 520px) {
    /* tidy 2-row x 3-col grid instead of a ragged wrap */
    .severity-scale {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ===================== Rerun bar ===================== */
.rerun-bar {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    font-family: var(--mono);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    color: var(--chrome-dim);
    margin-bottom: 1.1rem;
}

.rerun-bar a {
    color: var(--chrome);
    text-decoration: underline dotted;
    text-underline-offset: 3px;
}

.rerun-bar a:hover {
    color: var(--bone);
}

/* ===================== Error ===================== */
#error {
    background: #170E0D;
    border: 1px solid #5B2722;
    padding: 1rem;
    margin-top: 1.5rem;
    color: #C97D77;
    font-family: var(--mono);
    font-size: 0.85rem;
    overflow-wrap: break-word;
}

/* ===================== State accents ===================== */
#result {
    --state-accent: var(--red);
}

#result.state-wellness {
    --state-accent: var(--amber);
}

#result.state-discharge {
    --state-accent: var(--green);
}

/* ===================== Death certificate ===================== */
.death-certificate {
    margin-top: 0.5rem;
    filter: drop-shadow(0 18px 32px rgba(0, 0, 0, 0.55));
}

/* perforated / torn edges */
.cert-edge {
    height: 11px;
    background-size: 15px 11px;
    background-repeat: repeat-x;
}

.cert-edge--top {
    background-image:
        linear-gradient(45deg, var(--parchment) 50%, transparent 50%),
        linear-gradient(315deg, var(--parchment) 50%, transparent 50%);
}

.cert-edge--bottom {
    background-image:
        linear-gradient(135deg, var(--parchment) 50%, transparent 50%),
        linear-gradient(225deg, var(--parchment) 50%, transparent 50%);
}

.cert-paper {
    background-color: var(--parchment);
    background-image:
        radial-gradient(ellipse at 15% 6%, rgba(110, 100, 75, 0.10), transparent 50%),
        radial-gradient(ellipse at 88% 95%, rgba(110, 100, 75, 0.12), transparent 50%),
        repeating-linear-gradient(0deg, rgba(95, 85, 60, 0.03) 0 2px, transparent 2px 5px);
    color: var(--card-ink);
    padding: clamp(1rem, 3.5vw, 2rem) clamp(1rem, 4vw, 2.25rem);
}

/* letterhead */
.certificate-letterhead {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.16em;
    color: var(--card-faint);
    border-bottom: 1px solid var(--card-line);
    padding-bottom: 0.6rem;
    margin-bottom: 1.25rem;
}

.case-number {
    white-space: nowrap;
}

/* header: channel identity + stamp */
.certificate-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.channel-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

#channel-thumb {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid var(--card-ink);
    filter: grayscale(55%) contrast(1.05) sepia(12%);
    flex-shrink: 0;
}

#channel-name {
    font-family: var(--serif);
    font-size: clamp(1.25rem, 1rem + 1.5vw, 1.7rem);
    font-weight: 700;
    line-height: 1.2;
    overflow-wrap: break-word;
}

.badge {
    font-family: var(--mono);
    font-size: 0.65rem;
    border: 1px solid var(--card-line);
    padding: 0.12rem 0.5rem;
    color: var(--card-faint);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: inline-block;
    margin-top: 0.35rem;
}

/* rubber stamp */
.stamp {
    font-family: var(--sans);
    font-size: clamp(0.95rem, 0.7rem + 1.4vw, 1.4rem);
    font-weight: 800;
    color: var(--state-accent, var(--red));
    letter-spacing: 0.18em;
    text-transform: uppercase;
    border: 3px double currentColor;
    border-radius: 3px;
    padding: 0.3rem 0.8rem;
    transform: rotate(-4deg);
    opacity: 0.82;
    white-space: nowrap;
    mix-blend-mode: multiply;
}

/* ===================== Certificate body ===================== */
.certificate-body section {
    margin-bottom: 1.75rem;
}

.certificate-body h3 {
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--card-faint);
    letter-spacing: 0.2em;
    margin-bottom: 0.7rem;
    border-bottom: 1px solid var(--card-line);
    padding-bottom: 0.3rem;
}

/* epitaph — the screenshot line */
.epitaph {
    font-family: var(--serif);
    font-size: clamp(1.15rem, 1rem + 1.2vw, 1.5rem);
    font-style: italic;
    font-weight: 500;
    line-height: 1.4;
    margin: 0.25rem 0 1.5rem;
    padding: 0.6rem 1.1rem;
    border-left: 3px solid var(--card-ink);
    color: var(--card-ink);
}

/* YouTube API compliance disclosure — on every report, below the channel/
   verdict row and above the epitaph. Muted to match the coroner letterhead
   color (var(--card-faint)), never the orange accent. */
.report-disclosure {
    font-family: var(--mono);
    font-size: 0.66rem;
    line-height: 1.5;
    letter-spacing: 0.03em;
    color: var(--card-faint);
    text-align: left;
    margin: 0.6rem 0 1.4rem;
}

/* document fields with dotted leaders */
.certificate-fields {
    margin-bottom: 0.9rem;
}

.field-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.3rem 0.6rem;
    padding: 0.45rem 0;
}

.field-label {
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--card-faint);
    flex-shrink: 0;
}

.leader {
    flex: 1;
    min-width: 1.5rem;
    border-bottom: 2px dotted var(--card-line);
    transform: translateY(-0.3em);
}

.field-value {
    font-family: var(--serif);
    font-size: clamp(1.05rem, 0.95rem + 0.8vw, 1.3rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-left: auto;
    text-align: right;
    overflow-wrap: break-word;
}

.accent-value {
    color: var(--state-accent, var(--red));
}

/* severity bar */
.severity-bar-row {
    padding: 0.1rem 0 0.45rem;
}

.severity-bar {
    display: block;
    width: 100%;
    height: 8px;
    background: rgba(34, 31, 24, 0.08);
    border: 1px solid var(--card-line);
}

.severity-bar span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--state-accent, var(--red));
    transition: width 0.6s ease;
}

.tagline {
    font-family: var(--serif);
    font-style: italic;
    font-size: 1.05rem;
    color: #4A463A;
    margin: 0.4rem 0 1.6rem;
}

/* contributing factors */
.contributing-factor {
    padding: 0.5rem 0;
    border-bottom: 1px dotted var(--card-line);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.2rem 1rem;
}

.contributing-factor .name {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 1.05rem;
}

.contributing-factor .score {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--card-faint);
}

/* coroner's report narrative */
#autopsy-narrative {
    font-family: var(--serif);
    font-size: 1.12rem;
    font-weight: 500;
    line-height: 1.75;
    color: #2C2920;
    white-space: pre-line;
}

/* certificate footer / signature */
.certificate-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 1rem;
    border-top: 1px solid var(--card-line);
    padding-top: 1.1rem;
    margin-top: 0.5rem;
}

.signature {
    display: flex;
    flex-direction: column;
}

.signature-name {
    font-family: var(--serif);
    font-style: italic;
    font-weight: 600;
    font-size: 1.5rem;
    line-height: 1.1;
    color: var(--card-ink);
}

.signature-title {
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.2em;
    color: var(--card-faint);
    border-top: 1px solid var(--card-line);
    padding-top: 0.25rem;
    margin-top: 0.3rem;
}

.footer-brand {
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.2em;
    color: var(--card-faint);
}

/* ===================== Certificate share / download (dark, under the card) ===================== */
.cert-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 0.75rem;
    margin-top: 1.1rem;
}

.cert-action-btn {
    background: #1B1C17;
    border: 1px solid var(--line);
    color: var(--bone);
    padding: 0.7rem 1.25rem;
    min-height: 44px;
    font-family: var(--sans);
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.cert-action-btn:hover {
    background: var(--bone);
    color: var(--bg);
    border-color: var(--bone);
}

/* Ghost variant for the secondary "Share" action. */
.cert-action-btn--ghost {
    background: transparent;
    color: var(--chrome);
    border-color: var(--chrome-dim);
}

.cert-action-btn--ghost:hover {
    background: var(--chrome);
    color: var(--bg);
    border-color: var(--chrome);
}

.cert-action-btn:disabled {
    color: #4A483E;
    background: #15160F;
    border-color: var(--line);
    cursor: default;
}

/* Small text link — "Post to X". */
.cert-post-x {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    color: var(--chrome-dim);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.cert-post-x:hover {
    color: var(--bone);
    border-bottom-color: var(--chrome-dim);
}

/* ===================== Revival gate (dark, outside the card) ===================== */
/* Unboxed container — the blocks below are the boxes, separated on the
   page background. */
.revival-gate {
    margin: 2rem 0 0;
    border: none;
    background: transparent;
    padding: 0;
}

/* Block 1 — mono caps label, sits above the blocks (not boxed). */
.revival-gate h3 {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: #9a8f82;
    letter-spacing: 0.2em;
    margin-bottom: 0.85rem;
}

/* Block 2 — STEP 1 raised card. */
.step-preview {
    background: #1a1511;
    border: 0.5px solid #4a4138;
    border-radius: 6px;
    padding: 1rem 1.1rem;
    margin-bottom: 0.85rem;
}

/* STEP 1 label + internal hairline divider separating it from the body copy. */
.step-label {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: #9a8f82;
    letter-spacing: 0.2em;
    display: block;
    padding-bottom: 0.55rem;
    margin-bottom: 0.7rem;
    border-bottom: 0.5px solid #3a322b;
}

.step-preview p {
    font-size: 0.95rem;
    color: #e8e0d6;
    line-height: 1.55;
}

/* Block 3 — flatter dashed teaser, lighter weight than the cards. */
.steps-locked {
    text-align: center;
    padding: 0.8rem;
    border: 0.5px dashed #3a322b;
    border-radius: 6px;
    background: #16120f;
    color: #b0a498;
    font-family: var(--mono);
    font-size: 0.8rem;
    font-style: italic;
}

/* Block 4 — gate card (raised). */
.revival-cta {
    margin-top: 1.5rem;
    text-align: center;
    background: #1a1511;
    border: 0.5px solid #4a4138;
    border-radius: 6px;
    padding: clamp(1.1rem, 3vw, 1.6rem);
}

.revival-cta h4 {
    font-family: var(--serif);
    font-size: 1.35rem;
    color: #f3ece2;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.revival-cta > p {
    color: #c4b9ac;
    font-size: 0.9rem;
    font-style: italic;
    margin-bottom: 1rem;
}

.revival-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

/* Merged input + button — one rounded bordered unit, no gap between them. */
.revival-input-group {
    display: flex;
    width: 100%;
    max-width: 420px;
    border: 0.5px solid #5a5048;
    border-radius: 6px;
    background: #0d0b0a;
    overflow: hidden;        /* clip the children to the rounded corners */
}

#revival-email {
    flex: 1;
    min-width: 0;
    background: #0d0b0a;
    border: none;
    padding: 0.8rem;
    min-height: 48px;
    color: #e8e0d6;
    font-family: var(--mono);
    font-size: 1rem;
}

#revival-email::placeholder {
    color: #6f6557;
}

#revival-email:focus {
    outline: none;
    background: #161210;
}

/* Clearly-enabled CTA: orange fill, white text, flush against the input. */
#revival-submit {
    background: #b8472c;
    border: none;
    color: #fff;
    padding: 0.8rem 1.25rem;
    min-height: 48px;
    font-family: var(--sans);
    font-weight: 500;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    white-space: nowrap;
}

#revival-submit:hover:not(:disabled) {
    background: #c95535;
}

/* Disabled (pre-consent) stays the same orange CTA, just faded — no longer
   the old grey that read as permanently dead. */
#revival-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Hairline divider between the merged input unit and the consent row. */
.revival-consent {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    width: 100%;
    max-width: 420px;
    margin: 0.3rem auto 0;
    padding-top: 0.9rem;
    border-top: 0.5px solid #3a322b;
    text-align: left;
    cursor: pointer;
}

/* Outline checkbox with a clearly-visible CHECKED state (orange checkmark). */
.revival-consent input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1.05rem;
    height: 1.05rem;
    margin: 0.15rem 0 0;
    border: 1.5px solid #9a8f82;
    border-radius: 3px;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    display: inline-grid;
    place-content: center;
    transition: border-color 0.15s, background 0.15s;
}

.revival-consent input[type="checkbox"]::before {
    content: "";
    width: 0.62rem;
    height: 0.62rem;
    transform: scale(0);
    transition: transform 0.12s ease-in-out;
    background: #b8472c;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.revival-consent input[type="checkbox"]:checked {
    border-color: #b8472c;
}

.revival-consent input[type="checkbox"]:checked::before {
    transform: scale(1);
}

.revival-consent span {
    font-size: 0.74rem;
    color: #cabfb2;
    line-height: 1.4;
}

/* Optional marketing opt-in — a visually distinct, colored box so it doesn't
   read as a second copy of the required consent checkbox above. Green accent
   (vs. the consent's red) signals "optional extra," not legal agreement.
   Has its own checkbox styling — does NOT reuse .revival-consent. */
.revival-marketing-optin {
    width: 100%;
    max-width: 420px;
    margin: 1rem auto 0;
    padding: 0.85rem 1rem 0.95rem;
    text-align: left;
    background: rgba(78, 125, 88, 0.07);
    border: 1px solid rgba(78, 125, 88, 0.35);
    border-left: 3px solid var(--green);
    border-radius: 5px;
}

.revival-optin-heading {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--green);
    margin: 0 0 0.55rem;
}

.revival-optin-check {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    cursor: pointer;
}

.revival-optin-check input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1.05rem;
    height: 1.05rem;
    margin: 0.15rem 0 0;
    border: 1.5px solid #9a8f82;
    border-radius: 3px;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    display: inline-grid;
    place-content: center;
    transition: border-color 0.15s, background 0.15s;
}

.revival-optin-check input[type="checkbox"]::before {
    content: "";
    width: 0.62rem;
    height: 0.62rem;
    transform: scale(0);
    transition: transform 0.12s ease-in-out;
    background: var(--green);
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.revival-optin-check input[type="checkbox"]:checked {
    border-color: var(--green);
}

.revival-optin-check input[type="checkbox"]:checked::before {
    transform: scale(1);
}

.revival-optin-check span {
    font-size: 0.74rem;
    color: #cabfb2;
    line-height: 1.4;
}

.revival-optin-note {
    font-family: var(--serif);
    font-style: italic;
    font-size: 0.8rem;
    color: #9a8f82;
    margin: 0.55rem 0 0;
}

/* Reassurance line — serif italic. */
.revival-microcopy {
    font-family: var(--serif);
    font-size: 0.85rem;
    color: #9a8f82;
    font-style: italic;
}

.revival-success {
    color: var(--bone);
    font-family: var(--mono);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* ===================== Vital signs (raw numbers) ===================== */
/* Block 5 — flat block, lightest weight, at the bottom. */
.vital-signs-toggle {
    margin-top: 1.25rem;
    border: 0.5px solid #3a322b;
    border-radius: 6px;
    background: #16120f;
}

.vital-signs-toggle summary {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: #9a8f82;
    letter-spacing: 0.12em;
    padding: 0.7rem 0.9rem;
    cursor: pointer;
    user-select: none;
}

.vital-signs-toggle summary:hover {
    color: #b0a498;
}

.vital-signs-toggle[open] summary {
    border-bottom: 0.5px solid #3a322b;
    margin-bottom: 0.5rem;
}

.vital-signs-toggle .vital-signs {
    padding: 0.5rem 0.9rem 0.9rem;
}

.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    font-family: var(--mono);
    font-size: 0.8rem;
}

.metric {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: #15160F;
    border: 1px solid var(--line);
    overflow-wrap: anywhere;
}

.metric .label {
    color: var(--chrome-dim);
}

.metric .value {
    color: var(--bone);
    text-align: right;
}

/* ===================== Flatline timeline ===================== */
.flatline-chart {
    position: relative;
    margin-bottom: 0.3rem;
}

.flatline-svg {
    width: 100%;
    height: 80px;
    display: block;
}

.flatline-track {
    fill: none;
    stroke: var(--card-line);
    stroke-width: 1.5;
    opacity: 0.55;
}

.flatline-flat {
    fill: none;
    stroke: var(--red);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* PREMATURE / never-launched: no pulse, so no spike — a desaturated, dashed
   flat line instead of the live red trace. */
.flatline-premature .flatline-flat {
    stroke: var(--card-faint);
    stroke-width: 1.5;
    stroke-dasharray: 4 6;
}

/* Interactive markers overlaid on the SVG (positioned in % by app.js). */
.flatline-dot {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    padding: 0;
    border: 2px solid var(--parchment);
    border-radius: 50%;
    background: var(--card-faint);
    box-shadow: 0 0 0 1px var(--card-line);
    cursor: pointer;
}

.flatline-dot--spike {
    background: var(--red);
    animation: flatline-pulse 2.4s ease-out infinite;
}

.flatline-dot--now {
    background: var(--card-ink);
}

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

@keyframes flatline-pulse {
    0%   { box-shadow: 0 0 0 1px var(--card-line), 0 0 0 0 rgba(179, 50, 43, 0.5); }
    70%  { box-shadow: 0 0 0 1px var(--card-line), 0 0 0 9px rgba(179, 50, 43, 0); }
    100% { box-shadow: 0 0 0 1px var(--card-line), 0 0 0 0 rgba(179, 50, 43, 0); }
}

/* Plain-English tooltip — drops down below the dot on hover / focus / tap. */
.flatline-tip {
    position: absolute;
    top: calc(100% + 9px);
    z-index: 6;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    width: max-content;
    max-width: 230px;
    padding: 0.6rem 0.75rem;
    background: var(--parchment);
    border: 1px solid var(--card-line);
    border-radius: 5px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
    text-align: left;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.14s ease;
    pointer-events: none;
}

.flatline-tip--center { left: 50%; transform: translateX(-50%); }
.flatline-tip--left   { left: 0; }
.flatline-tip--right  { right: 0; }

.flatline-dot:hover .flatline-tip,
.flatline-dot:focus-visible .flatline-tip,
.flatline-dot.is-open .flatline-tip {
    opacity: 1;
    visibility: visible;
}

.flatline-tip-title {
    font-family: var(--sans);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--card-ink);
}

.flatline-tip-line {
    font-family: var(--sans);
    font-size: 0.82rem;
    line-height: 1.35;
    color: #4A463A;
}

.flatline-caption {
    font-family: var(--serif);
    font-style: italic;
    font-size: 0.95rem;
    color: #4A463A;
    margin-top: 0.6rem;
}

/* ============== Receipts (Cause of Death, Documented) ============== */
#receipts-list {
    display: grid;
    gap: 0.7rem;
}

/* Cream card on the parchment. The ONE surgical-red accent is reserved for the
   damning stat below — the card itself stays neutral. */
.receipt {
    background: rgba(255, 252, 244, 0.6);
    border: 1px solid var(--card-line);
    border-left: 3px solid var(--card-line);
    border-radius: 4px;
    padding: 0.8rem 1rem;
}

.receipt-stat {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 1.35rem;
    line-height: 1.2;
    color: var(--red);
    overflow-wrap: anywhere;
}

.receipt-context {
    font-family: var(--mono);
    font-size: 0.76rem;
    letter-spacing: 0.03em;
    color: var(--card-faint);
    margin-top: 0.3rem;
}

.receipt-verdict {
    font-family: var(--serif);
    font-style: italic;
    font-size: 1.02rem;
    color: var(--card-ink);
    margin-top: 0.4rem;
}

/* ===================== Loading overlay ===================== */
#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(120% 100% at 50% 18%, #16181380 0%, transparent 55%),
        var(--bg-deep);
}

.overlay-inner {
    width: min(560px, 92vw);
    text-align: center;
}

.ekg {
    width: 100%;
    height: auto;
    display: block;
}

.ekg-path {
    fill: none;
    stroke: var(--red);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 6px rgba(179, 50, 43, 0.55));
    stroke-dasharray: 1000;
    stroke-dashoffset: 0;
    animation: ekg-draw 9s linear infinite;
}

@keyframes ekg-draw {
    0% { stroke-dashoffset: 1000; }
    82% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: 0; }
}

#loading-remark {
    font-family: var(--serif);
    font-style: italic;
    font-weight: 500;
    font-size: clamp(1.1rem, 1rem + 1.2vw, 1.55rem);
    color: #CFCBBC;
    min-height: 3em;
    margin-top: 1.1rem;
    overflow-wrap: break-word;
}

#loading-remark.typing::after {
    content: '▍';
    color: var(--red);
    animation: caret-blink 0.9s steps(1) infinite;
}

@keyframes caret-blink {
    50% { opacity: 0; }
}

@keyframes remark-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

#loading-remark.fade-in {
    animation: remark-fade 0.45s ease;
}

.stage-label {
    margin-top: 0.7rem;
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.3em;
    color: #6E6C60;
}

/* ===================== Utility ===================== */
.hidden {
    display: none !important;
}

/* ===================== Mobile ===================== */
@media (max-width: 768px) {
    .input-group {
        flex-direction: column;
        border: none;
        gap: 0.75rem;
        background: transparent;
    }

    #channel-url,
    #submit-btn {
        width: 100%;
        border: 1px solid var(--line);
        font-size: 1rem;
    }

    #channel-url {
        background: #131410;
    }

    .certificate-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .stamp {
        align-self: flex-end;
        margin-top: -0.25rem;
    }

    /* Keep the input + button as one merged row (matches the main intake
       form); only bump body/consent copy for legibility. */
    .step-preview p,
    .revival-consent span,
    .revival-optin-check span {
        font-size: 1rem;
    }

    #autopsy-narrative {
        font-size: 1.08rem;
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .certificate-letterhead {
        flex-direction: column;
        gap: 0.15rem;
    }

    .field-row {
        padding: 0.55rem 0;
    }
}

/* ===================== Site footer ===================== */
.site-footer {
    margin-top: 3rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--line);
    text-align: center;
}

.site-footer a {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    color: var(--chrome-dim);
    text-decoration: underline dotted;
    text-underline-offset: 3px;
}

.site-footer a:hover {
    color: var(--chrome);
}

/* ===================== Legal pages (privacy policy) ===================== */
.legal {
    max-width: 720px;
    margin: 0 auto;
    padding: clamp(1.25rem, 4vw, 2.5rem) 1rem 4rem;
}

.legal-back {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    color: var(--chrome-dim);
    text-decoration: none;
}

.legal-back:hover {
    color: var(--chrome);
}

.legal h1 {
    font-family: var(--serif);
    font-size: clamp(1.6rem, 1rem + 2.5vw, 2.4rem);
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--bone);
    margin: 1.5rem 0 0.4rem;
}

.legal .legal-updated {
    font-family: var(--mono);
    font-size: 0.74rem;
    letter-spacing: 0.08em;
    color: var(--chrome-dim);
    margin-bottom: 2rem;
}

.legal h2 {
    font-family: var(--serif);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--bone);
    margin: 2rem 0 0.6rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--line);
}

.legal p,
.legal li {
    color: var(--bone);
    font-size: 0.96rem;
    line-height: 1.65;
}

.legal p {
    margin-bottom: 0.9rem;
}

.legal ul {
    margin: 0 0 0.9rem 1.2rem;
}

.legal li {
    margin-bottom: 0.5rem;
}

.legal a {
    color: var(--chrome);
    text-decoration: underline dotted;
    text-underline-offset: 3px;
    overflow-wrap: anywhere;
}

.legal a:hover {
    color: var(--bone);
}

.legal table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0 1.2rem;
    font-size: 0.92rem;
}

.legal th,
.legal td {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--line);
    vertical-align: top;
    color: var(--bone);
}

.legal th {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--chrome);
    background: #16120f;
}

/* ===================== Reduced motion ===================== */
@media (prefers-reduced-motion: reduce) {
    .ekg-path {
        animation: none;
        stroke-dashoffset: 0;
    }

    #loading-remark.typing::after {
        animation: none;
        content: '';
    }

    .severity-bar span {
        transition: none;
    }

    #submit-btn,
    #revival-submit {
        transition: none;
    }

    .flatline-dot--spike {
        animation: none;
    }

    .flatline-tip {
        transition: none;
    }
}
