/*
 * Transfer Episode Tapestry — desktop clinical composition.
 *
 * This sheet is presentation-only and loads only when Loom AND Clinical
 * Canvas are effective. Every structural override is also marker-scoped so
 * removing data-tc-episode-tapestry restores the pre-existing stacked page.
 * The only other scope is data-tc-episode-fallback: a deliberately small
 * rescue that keeps canonical controls reachable if the Episode renderer
 * fails after the template has rendered.
 */

/* -------------------------------------------------------------------------
   Shared Episode language
   ------------------------------------------------------------------------- */

body.tc-page[data-tc-episode-tapestry="1"] .tc-capture-lede,
body.tc-page[data-tc-episode-tapestry="1"] .tc-captured-toggle {
    display: none;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-kicker {
    color: var(--term-gold);
    font-family: var(--term-font-mono);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now {
    min-width: 0;
    border: 1px solid var(--term-border-default);
    border-radius: 0.65rem;
    background:
        linear-gradient(135deg, var(--term-gold-ghost), transparent 42%),
        var(--term-bg-elevated);
    box-shadow:
        inset 0 1px 0 rgb(255 255 255 / 3%),
        0 0.55rem 1.6rem rgb(0 0 0 / 16%);
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now h2 {
    margin: 0.1rem 0 0;
    color: var(--term-fg-primary);
    font-family: var(--term-font-display);
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.015em;
}

/* Origin band internals (head/summary/patient/call/referrer/reason/labels/
   values/missing markers/source row/chart floor): DELETED slice 2
   (2026-08-02, owner ruling) — the band merged into the selected rail card;
   the surviving strip affordances are styled in transfer-unified.css. */

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__label {
    color: var(--term-fg-muted);
    font-family: var(--term-font-mono);
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now > header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.55rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--term-border-subtle);
}

body.tc-page[data-tc-episode-tapestry="1"] #tcEpisodeNowSummary {
    min-height: 0;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__status {
    margin: 0;
    padding: 0.7rem 0;
    color: var(--term-fg-secondary);
    font-size: 0.72rem;
    line-height: 1.45;
}

body.tc-page[data-tc-episode-tapestry="1"] [data-episode-now-state="listening"] .tc-episode-now__status,
body.tc-page[data-tc-episode-tapestry="1"] [data-episode-now-state="assembling"] .tc-episode-now__status {
    color: var(--term-live);
}

body.tc-page[data-tc-episode-tapestry="1"] [data-episode-now-state="starved"] .tc-episode-now__status {
    color: var(--term-status-warning, #e69a4c);
}

body.tc-page[data-tc-episode-tapestry="1"] [data-episode-now-state="settled"] > .tc-episode-now__status {
    display: none;
}

body.tc-page[data-tc-episode-tapestry="1"] [data-episode-now-live-projection="updating"] > .tc-episode-now__status {
    display: block;
    color: var(--term-live);
}

body.tc-page[data-tc-episode-tapestry="1"] [data-episode-now-live-projection="degraded"] > .tc-episode-now__status {
    display: block;
    color: var(--term-status-warning, #e69a4c);
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__content {
    display: grid;
    gap: 0.75rem;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__loom {
    position: sticky;
    z-index: 3;
    top: 0;
    display: grid;
    gap: 0.32rem;
    padding: 0.42rem;
    overflow: hidden;
    border: 1px solid var(--term-border-default);
    border-radius: 0.48rem;
    background:
        linear-gradient(90deg, transparent 0 12%, var(--term-live-ghost) 50%, transparent 88%),
        var(--term-bg-input);
    box-shadow: 0 0.42rem 0.9rem rgb(0 0 0 / 26%);
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__loom::after {
    position: absolute;
    right: 0.58rem;
    bottom: 0.34rem;
    left: 0.58rem;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        var(--term-live-dim) 18% 82%,
        transparent
    );
    content: "";
    pointer-events: none;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__loom-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__loom-counts {
    color: var(--term-fg-muted);
    font-family: var(--term-font-mono);
    font-size: 0.52rem;
    letter-spacing: 0.025em;
    white-space: nowrap;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__strands {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.3rem;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__strand {
    --tc-strand-color: var(--term-fg-muted);

    position: relative;
    display: grid;
    align-content: space-between;
    gap: 0.3rem;
    min-width: 0;
    min-height: 2.5rem;
    padding: 0.3rem 0.3rem 0.26rem;
    border: 1px solid var(--term-border-subtle);
    border-top: 2px solid var(--tc-strand-color);
    border-radius: 0.32rem;
    background: rgb(0 0 0 / 10%);
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__strand[data-strand-status="processing"],
body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__strand[data-strand-status="retry_wait"] {
    --tc-strand-color: var(--term-live);

    background: var(--term-live-subtle);
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__strand[data-strand-status="applied"] {
    --tc-strand-color: var(--term-live);
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__strand[data-strand-status="empty"] {
    --tc-strand-color: var(--term-gold-dim);
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__strand[data-strand-status="failed"] {
    --tc-strand-color: var(--term-status-warning, #e69a4c);

    background: color-mix(
        in srgb,
        var(--term-status-warning, #e69a4c) 8%,
        var(--term-bg-input)
    );
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__strand-label {
    overflow: hidden;
    color: var(--term-fg-secondary);
    font-size: 0.54rem;
    font-weight: 650;
    line-height: 1.15;
    text-overflow: ellipsis;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__strand-status {
    color: var(--tc-strand-color);
    font-family: var(--term-font-mono);
    font-size: 0.46rem;
    font-weight: 700;
    letter-spacing: 0.045em;
    line-height: 1.15;
    text-transform: uppercase;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__strand[data-strand-status="processing"]::after,
body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__strand[data-strand-status="retry_wait"]::after {
    position: absolute;
    right: 0.34rem;
    bottom: 0.32rem;
    width: 0.28rem;
    height: 0.28rem;
    border-radius: 50%;
    background: var(--term-live);
    box-shadow: 0 0 0.52rem var(--term-live);
    content: "";
    animation: tc-episode-strand-pulse 1.4s ease-in-out infinite;
}

@keyframes tc-episode-strand-pulse {
    0%,
    100% {
        opacity: 0.35;
        transform: scale(0.75);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__retry {
    min-height: 2rem;
    padding: 0.35rem 0.58rem;
    border: 1px solid var(--term-status-warning, #e69a4c);
    border-radius: 0.35rem;
    color: var(--term-status-warning, #e69a4c);
    background: transparent;
    font-family: var(--term-font-mono);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__retry:disabled {
    opacity: 0.55;
    cursor: wait;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__headline,
body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__movement,
body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__unresolved {
    display: grid;
    gap: 0.32rem;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__fact {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.48rem;
    width: 100%;
    min-height: 2.55rem;
    padding: 0.5rem 0.58rem;
    border: 1px solid var(--term-border-default);
    border-left: 3px solid var(--term-live);
    border-radius: 0.35rem;
    color: var(--term-fg-primary);
    background: var(--term-bg-input);
    font-family: var(--term-font-body);
    font-size: 0.76rem;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__fact-text {
    min-width: 0;
}

body.tc-page[data-tc-episode-tapestry="1"] [data-episode-now-live-projection-enabled="1"] .tc-episode-now__fact {
    flex-wrap: wrap;
}

body.tc-page[data-tc-episode-tapestry="1"] [data-episode-now-live-projection-enabled="1"] .tc-episode-now__fact-text {
    flex: 1 1 10rem;
}

body.tc-page[data-tc-episode-tapestry="1"] [data-episode-now-live-projection-enabled="1"] .tc-episode-now__change {
    flex: 1 0 100%;
    color: var(--term-fg-muted);
    font-family: var(--term-font-mono);
    font-size: 0.54rem;
    line-height: 1.3;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__provenance {
    flex: 0 0 auto;
    padding: 0.12rem 0.28rem;
    border: 1px solid currentColor;
    border-radius: 999px;
    color: var(--term-fg-muted);
    font-family: var(--term-font-mono);
    font-size: 0.47rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.2;
    text-transform: uppercase;
    white-space: nowrap;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__provenance.is-current_call {
    color: var(--term-live);
    background: var(--term-live-subtle);
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__provenance.is-chart {
    color: var(--term-gold);
    background: var(--term-gold-ghost);
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__provenance.is-earlier_call {
    border-style: dashed;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__fact--movement {
    border-left-color: var(--term-gold);
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__fact--unresolved {
    border-left-color: var(--term-status-warning, #e69a4c);
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__fact[aria-pressed="true"] {
    border-color: var(--term-live);
    background: var(--term-live-subtle);
    box-shadow: inset 0 0 0 1px var(--term-live-dim);
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__unresolved-list {
    display: grid;
    gap: 0.38rem;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__clarification {
    display: block;
    padding: 0.48rem 0.58rem;
    border: 1px dashed var(--term-border-strong);
    border-radius: 0.35rem;
    color: var(--term-fg-secondary);
    font-size: 0.72rem;
    line-height: 1.4;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__meta {
    margin: 0.1rem 0 0;
    color: var(--term-fg-muted);
    font-family: var(--term-font-mono);
    font-size: 0.56rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__fact:focus-visible,
body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__retry:focus-visible,
body.tc-page[data-tc-episode-tapestry="1"] .tc-clinical-canvas__switcher button:focus-visible {
    outline: 2px solid var(--term-live);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__strand::after {
        animation: none;
    }
}

body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now:focus-within,
body.tc-page[data-tc-episode-tapestry="1"] .tc-clinical-canvas__transcript-pane:focus-within,
body.tc-page[data-tc-episode-tapestry="1"] .tc-clinical-canvas__story-pane:focus-within {
    box-shadow: inset 0 0 0 2px var(--term-live-dim);
}

/* The legacy live layout hides form children with a high-specificity
   !important child sweep. Match that ownership edge with canonical IDs so
   these restores win by specificity at every width, not merely by load order. */
body.tc-page[data-tc-episode-tapestry="1"].tc-clinical-live .tc-list-panel {
    display: block !important;
}

/* Origin live restore: the strip's live rules live in transfer-unified.css
   (slice 2, 2026-08-02). */

body.tc-page[data-tc-episode-tapestry="1"].tc-clinical-live #tcWorkspaceForm > .tc-episode-now {
    display: block !important;
}

body.tc-page[data-tc-episode-tapestry="1"].tc-clinical-live #tcWorkspaceForm > .tc-decision-spine {
    display: block !important;
}

body.tc-page[data-tc-episode-tapestry="1"].tc-clinical-live #tcWorkspaceForm > .tc-workspace-footer {
    display: flex !important;
}

body.tc-page[data-tc-episode-tapestry="1"].tc-clinical-live #tcRecorderPanel > .tc-recorder-controls {
    display: flex !important;
}

body.tc-page[data-tc-episode-tapestry="1"].tc-clinical-live #tcRecorderPanel > .tc-clinical-canvas {
    display: grid !important;
}

/* -------------------------------------------------------------------------
   Desktop Episode: literal Origin above one clinical stage + NOW/Decision
   ------------------------------------------------------------------------- */

@media (min-width: 1200px) {
    body.tc-page[data-tc-episode-tapestry="1"] {
        grid-template-columns: clamp(20rem, 25vw, 22.5rem) minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-list-panel {
        min-width: 0;
        overflow-y: auto;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-workspace {
        grid-column: 2;
        box-sizing: border-box;
        min-width: 0;
        min-height: 0;
        height: 100%;
        padding: 0.65rem 0.75rem 0.75rem;
        overflow: hidden;
    }

    body.tc-page[data-tc-episode-tapestry="1"] #tcWorkspaceForm {
        position: relative;
        display: grid;
        /* FIX (2026-08-06, responsive audit Stage 2): col floors were
           minmax(40rem,1fr) + clamp(18rem,…) = 640+288px, which needed
           ~1282px viewport but the grid gates ON at 1200 — measured 9px of
           silent clip at exactly 1280x800 (formOv=9), the razor-thin usable
           band the owner reported. Adopted the seam block's proven floors
           (33rem/17rem): fits 1200 (~42px slack) and 1280 (~103px slack).
           The 1200–1279.98 seam block below was deleted — one regime now. */
        grid-template-columns: minmax(33rem, 1fr) clamp(17rem, 23vw, 23.5rem);
        grid-template-rows:
            auto
            auto /* origin strip (slice 2, 2026-08-02): band retired */
            minmax(7.5rem, 1fr)
            clamp(10rem, 20vh, 11.5rem)
            auto;
        gap: 0.55rem 0.65rem;
        min-width: 0;
        min-height: 0;
        height: 100%;
        /* FIX (2026-08-06, owner): at rest the bounded shell silently CLIPPED
           whatever didn't fit — only the post-call state let the doctor
           scroll past individual segments. overflow-y:auto keeps the bounded
           grid (rows still size to the box; nothing reflows when content
           fits) and engages a scrollbar ONLY on overflow. overflow-x stays
           hidden — horizontal bands are fenced by
           tests/playwright/test_tc_responsive_fit_2026_08_06.py. */
        overflow-x: hidden;
        overflow-y: auto;
    }

    body.tc-page[data-tc-episode-tapestry="1"] #tcWorkspaceForm[hidden] {
        display: none;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-save-status {
        position: absolute;
        z-index: 4;
        top: 0.18rem;
        right: 0.45rem;
        max-width: 14rem;
        margin: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        pointer-events: none;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-topbar {
        grid-column: 1 / -1;
        grid-row: 1;
        min-width: 0;
        min-height: 2.65rem;
        margin: 0;
        padding: 0.18rem 15rem 0.38rem 0.45rem;
        border: 0;
        border-bottom: 1px solid var(--term-border-default);
    }

    /* Origin band grid placement: DELETED slice 2 — the strip's placement
       (grid row 2, spanning both columns) lives in transfer-unified.css. */

    body.tc-page[data-tc-episode-tapestry="1"] .tc-bottom-panel {
        grid-column: 1;
        grid-row: 3 / 6;
        min-height: 0;
        margin: 0;
        overflow: hidden;
        border: 0;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-bottom-panel > .tc-section,
    body.tc-page[data-tc-episode-tapestry="1"] .tc-bottom-panel .tc-section-body {
        min-height: 0;
        height: 100%;
        margin: 0;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-recorder {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
        min-width: 0;
        min-height: 0;
        height: 100%;
        margin: 0;
        padding: 0.58rem;
        overflow: hidden;
    }

    /*
     * Split projection intentionally does not manufacture clinical facts
     * during a call. Keep the canonical structured-field roll-up visible as
     * the immediate capture pulse until the evidence-bound post-call strands
     * populate NOW. This is the existing call-recorder authority, not a second
     * clinical projection.
     */
    body.tc-page[data-tc-episode-tapestry="1"].tc-clinical-live #tcRecorderPanel,
    body.tc-page[data-tc-episode-tapestry="1"]
        #tcRecorderPanel:has(
            > #tcClinicalCanvas[data-story-phase="assembling"]
            + #tcLiveIntake[data-capture-phase="complete"]
        ) {
        grid-template-rows: auto minmax(0, 1fr) auto;
    }

    body.tc-page[data-tc-episode-tapestry="1"].tc-clinical-live
        #tcRecorderPanel > #tcLiveIntake,
    body.tc-page[data-tc-episode-tapestry="1"]
        #tcClinicalCanvas[data-story-phase="assembling"]
        + #tcLiveIntake[data-capture-phase="complete"] {
        display: grid !important;
        grid-column: 1;
        grid-row: 3;
        grid-template-columns: minmax(11rem, 0.65fr) minmax(0, 1.35fr);
        grid-template-areas:
            "capture-head capture-detail"
            "capture-bar capture-bar";
        min-width: 0;
        margin: 0.45rem 0 0;
        border-color: var(--tc-arc-line-strong);
        border-radius: 0.6rem;
        background: var(--tc-arc-deep);
        box-shadow: inset 0 1px 0 rgb(255 255 255 / 3%);
    }

    body.tc-page[data-tc-episode-tapestry="1"].tc-clinical-live
        #tcLiveIntake > .tc-live-intake-header,
    body.tc-page[data-tc-episode-tapestry="1"]
        #tcClinicalCanvas[data-story-phase="assembling"]
        + #tcLiveIntake[data-capture-phase="complete"]
        > .tc-live-intake-header {
        grid-area: capture-head;
        min-width: 0;
        padding: 0.42rem 0.65rem;
        border-right: 1px solid var(--tc-arc-line);
        border-bottom: 0;
        background: var(--tc-arc-surface);
        box-shadow: none;
    }

    body.tc-page[data-tc-episode-tapestry="1"].tc-clinical-live
        #tcLiveIntake .tc-live-intake-kicker {
        color: var(--tc-arc-live);
    }

    body.tc-page[data-tc-episode-tapestry="1"]
        #tcClinicalCanvas[data-story-phase="assembling"]
        + #tcLiveIntake[data-capture-phase="complete"]
        .tc-live-intake-kicker {
        color: var(--term-gold);
    }

    body.tc-page[data-tc-episode-tapestry="1"].tc-clinical-live
        #tcLiveIntake .tc-live-intake-title,
    body.tc-page[data-tc-episode-tapestry="1"]
        #tcClinicalCanvas[data-story-phase="assembling"]
        + #tcLiveIntake[data-capture-phase="complete"]
        .tc-live-intake-title {
        display: none;
    }

    body.tc-page[data-tc-episode-tapestry="1"].tc-clinical-live
        #tcLiveIntake > .tc-live-intake-footer,
    body.tc-page[data-tc-episode-tapestry="1"]
        #tcClinicalCanvas[data-story-phase="assembling"]
        + #tcLiveIntake[data-capture-phase="complete"]
        > .tc-live-intake-footer {
        grid-area: capture-detail;
        grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
        min-width: 0;
        gap: 0.55rem;
        padding: 0.42rem 0.65rem;
        border-top: 0;
        background: transparent;
    }

    body.tc-page[data-tc-episode-tapestry="1"].tc-clinical-live
        #tcLiveIntake > #tcCaptureBar,
    body.tc-page[data-tc-episode-tapestry="1"]
        #tcClinicalCanvas[data-story-phase="assembling"]
        + #tcLiveIntake[data-capture-phase="complete"]
        > #tcCaptureBar {
        grid-area: capture-bar;
        height: 0.32rem;
        margin: 0 0.65rem 0.42rem;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-recorder--split > * {
        grid-column: 1;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-recorder-controls {
        display: flex;
        z-index: 5;
        grid-column: 1;
        grid-row: 1;
        min-width: 0;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-recorder > .tc-clinical-canvas {
        display: grid;
        grid-column: 1;
        grid-row: 2;
        min-width: 0;
        min-height: 0;
        height: auto;
        margin-top: 0.5rem;
        align-self: stretch;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-clinical-canvas {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto minmax(0, 1fr) auto;
        grid-template-areas: "switcher" "bedside" "stage" "agenda";
        min-width: 0;
        min-height: 0;
        height: 100%;
        overflow: hidden;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-clinical-canvas__switcher {
        display: grid;
        z-index: 3;
        grid-area: switcher;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.2rem;
        padding: 0.28rem;
        border-bottom: 1px solid var(--tc-arc-line);
        background: var(--tc-arc-deep);
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-clinical-canvas__switcher button {
        min-height: 2.25rem;
        border: 0;
        border-radius: 0.4rem;
        color: var(--tc-arc-muted);
        background: transparent;
        font: inherit;
        font-size: 0.72rem;
        font-weight: 700;
        cursor: pointer;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-clinical-canvas__switcher button[aria-pressed="true"] {
        color: var(--tc-arc-text);
        background: var(--tc-arc-surface-soft);
        box-shadow: inset 0 -2px 0 var(--tc-arc-live);
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-clinical-canvas__bedside {
        grid-area: bedside;
        min-width: 0;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-clinical-canvas__agenda {
        grid-area: agenda;
        min-width: 0;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-clinical-canvas__transcript-pane,
    body.tc-page[data-tc-episode-tapestry="1"] .tc-clinical-canvas__story-pane {
        grid-area: stage;
        min-width: 0;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        border-right: 0;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-clinical-canvas[data-clinical-view="transcript"] .tc-clinical-canvas__story-pane,
    body.tc-page[data-tc-episode-tapestry="1"] .tc-clinical-canvas[data-clinical-view="story"] .tc-clinical-canvas__transcript-pane {
        display: none;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now {
        grid-column: 2;
        grid-row: 3;
        box-sizing: border-box;
        min-height: 0;
        padding: 0.75rem;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-decision-spine {
        grid-column: 2;
        /* grid-row removed 2026-08-10 (adjudicate F-10): this row:4 duplicated
           #tcLabsPanel's cell (col2/row4) and was DEAD — shadowed by
           transfer-ux-polish.css's higher-specificity grid-row:6, which is the
           real placement (its A1 template is the single home for the rows since
           the 2026-08-06 consolidation). Leaving the literal row:4 here was a
           latent collision if that ux-polish rule were edited during the
           slice-by-slice migration. grid-column:2 stays — nothing else sets it. */
        box-sizing: border-box;
        min-width: 0;
        min-height: 0;
        max-height: none;
        margin: 0;
        padding: 0.62rem;
        overflow-y: auto;
        border: 1px solid var(--term-gold-dim);
        border-radius: 0.65rem;
        background: var(--term-bg-elevated);
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-decision-buttons {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.35rem;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-decision-btn {
        min-width: 0;
        min-height: 2.7rem;
        padding: 0.38rem 0.52rem;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-accept-block {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 0.45rem;
        margin-top: 0.5rem;
        padding: 0.52rem;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-accept-unit,
    body.tc-page[data-tc-episode-tapestry="1"] .tc-accept-routing {
        min-width: 0;
        flex-wrap: wrap;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-accept-routing .tc-dest-chips {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
        width: 100%;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-accept-unit .tc-bed-chips {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-accept-routing .tc-select {
        width: min(100%, 10.5rem);
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-workspace-footer {
        display: flex;
        grid-column: 2;
        grid-row: 5;
        align-items: center;
        box-sizing: border-box;
        min-width: 0;
        margin: 0;
        padding: 0.52rem 0;
        border-top: 1px solid var(--term-border-default);
        background: transparent;
        box-shadow: none;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-workspace-footer .tc-generate-btn {
        width: 100%;
        min-width: 0;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-columns,
    body.tc-page[data-tc-episode-tapestry="1"] .tc-decision-detail {
        display: none;
    }

    /* REMOVED 2026-08-02 (owner ruling, real-call shift): the
       [data-origin-details="open"] overlay. It promoted .tc-columns and
       .tc-decision-detail to a full-width z-index:20 panel on rows 3-4 and
       pushed .tc-bottom-panel / .tc-episode-now / .tc-decision-spine to
       visibility:hidden — i.e. opening "Edit transfer details" mid-call
       blanked the recorder, the NOW panel and the decision spine. That is the
       "covers things up" the owner reported. The toggle is gone with it; the
       grids keep the base display:none above and stay mounted as state
       carriers (see templates/transfer.html). Do not reintroduce an opener
       without an owner ruling — this was a parallel surface, §2 item 11. */

    body.tc-page[data-tc-episode-tapestry="1"].tc-clinical-live .tc-workspace-form > .tc-topbar,
    body.tc-page[data-tc-episode-tapestry="1"].tc-clinical-live .tc-workspace-form > .tc-bottom-panel {
        display: flex !important;
    }

    body.tc-page[data-tc-episode-tapestry="1"].tc-note-open {
        grid-template-columns: 0 minmax(0, 1fr);
    }

    body.tc-page[data-tc-episode-tapestry="1"].tc-note-open .tc-list-panel {
        visibility: hidden;
        pointer-events: none;
    }

    body.tc-page[data-tc-episode-tapestry="1"].tc-note-open .tc-workspace {
        margin-right: var(--tc-note-drawer-w, 480px);
    }

    body.tc-page[data-tc-episode-tapestry="1"].tc-note-open #tcWorkspaceForm {
        /* FIX (2026-08-06, Stage 2): was minmax(26rem,1fr) — 416+272px floors
           against a 480px drawer left ~0px slack at the 1200px gate. 23rem
           keeps the drawer-open state inside the gate (~46px slack). */
        grid-template-columns: minmax(23rem, 1fr) minmax(17rem, 20rem);
    }
}

/* REMOVED (2026-08-06, Stage 2): the 1200–1279.98px seam block
   (@media min-width:1200 and max-width:1279.98 → 33rem/17rem floors). The
   base grid above now carries those floors at every desktop width, so the
   seam regime no longer exists — three layouts collapse to one. */

/* -------------------------------------------------------------------------
   Sub-desktop functional stack. Tablet polish is deliberately out of scope;
   reachability and readable single-column flow are not.
   ------------------------------------------------------------------------- */

@media (max-width: 1199.98px) {
    body.tc-page[data-tc-episode-tapestry="1"] {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto auto;
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-header {
        grid-column: 1;
        grid-row: 1;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-list-panel {
        display: block !important;
        grid-column: 1;
        grid-row: 2;
        max-height: 20rem;
        overflow-y: auto;
        visibility: visible;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-workspace {
        grid-column: 1;
        grid-row: 3;
        min-width: 0;
        height: auto;
        padding: 0.75rem;
        overflow: visible;
    }

    body.tc-page[data-tc-episode-tapestry="1"] #tcWorkspaceForm {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto;
        min-width: 0;
        min-height: 0;
        height: auto;
        overflow: visible;
    }

    body.tc-page[data-tc-episode-tapestry="1"] #tcWorkspaceForm[hidden] {
        display: none;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-save-status,
    body.tc-page[data-tc-episode-tapestry="1"] .tc-topbar,
    body.tc-page[data-tc-episode-tapestry="1"] .tc-origin-strip,
    body.tc-page[data-tc-episode-tapestry="1"] .tc-bottom-panel,
    body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now,
    body.tc-page[data-tc-episode-tapestry="1"] .tc-decision-spine,
    body.tc-page[data-tc-episode-tapestry="1"] .tc-workspace-footer {
        grid-column: 1;
        grid-row: auto;
    }

    /* Origin band sub-desktop grid: removed slice 2 — the strip is a flex
       row (transfer-unified.css) and simply flows in the stack. */

    body.tc-page[data-tc-episode-tapestry="1"] .tc-bottom-panel {
        min-height: 34rem;
        margin-top: 0.65rem;
        overflow: visible;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-recorder {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(30rem, 1fr);
        min-width: 0;
        min-height: 34rem;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-recorder > .tc-clinical-canvas {
        display: grid !important;
        grid-column: 1;
        grid-row: 2;
        min-height: 30rem;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now {
        display: block !important;
        max-height: none;
        margin-top: 0.65rem;
        padding: 0.75rem;
        overflow: visible;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-decision-spine {
        display: block !important;
        margin: 0.65rem 0 0;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-workspace-footer {
        display: flex !important;
        margin: 0.65rem 0 0;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-columns,
    body.tc-page[data-tc-episode-tapestry="1"] .tc-decision-detail {
        display: none;
    }

    /* REMOVED 2026-08-02 with the details toggle: the narrow-viewport
       [data-origin-details="open"] reveal for .tc-columns / .tc-decision-detail. */

    body.tc-page[data-tc-episode-tapestry="1"].tc-note-open .tc-workspace {
        margin-right: 0;
    }
}

/* -------------------------------------------------------------------------
   Renderer failure: expose only the canonical stacked controls that the
   legacy live child-sweep hides. The base clinical canvas keeps layout.
   ------------------------------------------------------------------------- */

body[data-tc-episode-fallback="1"].tc-clinical-live #tcWorkspaceForm > .tc-origin-strip {
    display: block !important;
}

body[data-tc-episode-fallback="1"].tc-clinical-live #tcWorkspaceForm > .tc-origin-strip .tc-origin-strip__connector,
body[data-tc-episode-fallback="1"].tc-clinical-live #tcWorkspaceForm > .tc-origin-strip .tc-origin-strip__source,
body[data-tc-episode-fallback="1"].tc-clinical-live #tcWorkspaceForm > .tc-episode-now {
    display: none !important;
}

body[data-tc-episode-fallback="1"].tc-clinical-live #tcChartMaterialsField,
body[data-tc-episode-fallback="1"].tc-clinical-live #tcWorkspaceForm > .tc-decision-spine,
body[data-tc-episode-fallback="1"].tc-clinical-live #tcWorkspaceForm > .tc-workspace-footer {
    display: block !important;
}

body[data-tc-episode-fallback="1"].tc-clinical-live #tcWorkspaceForm > .tc-workspace-footer {
    display: flex !important;
}

body[data-tc-episode-fallback="1"].tc-clinical-live #tcWorkspaceForm {
    height: auto;
    overflow-y: auto;
}

/* -------------------------------------------------------------------------
   Accessibility accommodations
   ------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    body.tc-page[data-tc-episode-tapestry="1"] * {
        scroll-behavior: auto;
    }
}

@media (forced-colors: active) {
    body.tc-page[data-tc-episode-tapestry="1"] .tc-origin-strip,
    body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now {
        border-color: CanvasText;
    }

    body.tc-page[data-tc-episode-tapestry="1"] .tc-episode-now__fact {
        border-color: ButtonText;
    }
}

/* STOPGAP (2026-08-01, density compression of the origin band): REMOVED
   slice 2 (2026-08-02) with the band itself, per the plan — both origin
   stopgaps were explicit bridges to the origin merge. */
