/*
 * Admissions Manuscript document host — ADM S-Series Phase 1.
 * Flag: ENABLE_AW_MANUSCRIPT (requires ENABLE_ADMISSIONS_REDESIGN).
 * Spec: ADMISSIONS-S-SERIES-HANDOFF.md §1 (surface) + §5 (tokens); reference
 * frames 5a/6a/7a/7b in "Admissions Workspace.dc.html" (Claude Design cf6a41fd).
 *
 * DISCIPLINE:
 * - Every selector is namespaced .awm-* and this sheet loads ONLY flag-on —
 *   zero interaction with admissions.css / admissions-redesign.css flag-off.
 * - Night Dispatch three-role color discipline (handoff §5): slate = chrome,
 *   cyan #59D6C5 = live/machine ONLY, amber #F2A93B = decision ONLY.
 * - Design px values are canvas minima — production floors: mono chrome >=10px,
 *   prose >=15px.
 * - The manuscript renders INSIDE #awSectionSidebar (section-sidebar.js owns
 *   the lifecycle); persistent chrome (rail, intake) participates in the same
 *   render/reset cycle. Nothing here may restyle stock (.aw-* / .awx-*) nodes.
 */

/* ── Retire the visible textarea (S-series decision 1). It stays in the DOM as
   the durable typed-fragment store; only its VISIBLE surface goes. The recorder
   panel + route stamp inside .awx-capture stay (they are the dictation strip). */
.awx-capture label[for="awClinicalData"],
#awClinicalData {
    display: none;
}
.awx-capture {
    padding-block: 4px;
}
/* P1 UAT fix (2026-07-08): retire the stock Dictate button too — the intake
   line owns dictation entry (its DICTATE delegates a click to #awVoiceBtn,
   which stays in the DOM as the voice-recorder's toggle target). The rest of
   the recorder strip (REC indicator, timer, meter, routing pill, transcript)
   remains — it is live-session chrome, not an entry point. */
#awVoiceBtn {
    display: none;
}

/* ── Counter / readiness line (fixed header of the note host) */
.awm-counter {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    padding: 6px 10px;
    border-bottom: 1px solid #22303C;
    color: #7A93A5;
}
.awm-counter-req { color: #F2A93B; }           /* amber = decision */
.awm-counter-ready, .awm-counter-done { color: #59D6C5; } /* cyan = live/machine */
.awm-counter-stream { color: #59D6C5; }
.awm-counter-meta { color: #43535F; margin-left: 8px; }

/* ── Document sheet */
.awm-sheet {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 0 40px;
}
.awm-preamble {
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    color: #9FB0BC;
    padding: 8px 14px;
    border-left: 2px solid #31424F;
    margin: 0 8px 6px;
    white-space: pre-wrap;
}

/* ── Rows */
.awm-row {
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 6px 10px 10px;
    margin: 0 6px;
}
.awm-row--primary { border-color: #31424F; background: #0D141B; }
.awm-row--required { border: 1px dashed #F2A93B55; }
.awm-row--live { outline: 1px solid #59D6C5; outline-offset: -1px; }
.awm-row--compiled .awm-body { color: #E8EDF2; }

.awm-row-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 3px;
}
.awm-abbrev { font-size: 10px; font-weight: 600; color: #59D6C5; min-width: 34px; }
.awm-row--ghost .awm-abbrev { color: #43535F; }
.awm-title { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: #7A93A5; }
.awm-actions { margin-left: auto; display: inline-flex; gap: 6px; }

/* Pills — runtime statuses made visible (handoff §1.1) */
.awm-pill {
    font-size: 9px;
    letter-spacing: 0.1em;
    padding: 1px 6px;
    border-radius: 3px;
    border: 1px solid #22303C;
    color: #7A93A5;
}
.awm-pill--suggested { color: #59D6C5; border-color: #59D6C544; }
.awm-pill--edited { color: #9FB0BC; border-color: #31424F; }
.awm-pill--pinned { color: #9FB0BC; background: #43535F33; border-color: #43535F; }
.awm-pill--conflict { color: #F2A93B; border-color: #F2A93B55; }
.awm-pill--live { color: #59D6C5; border-color: transparent; }
.awm-pill--done { color: #59D6C5; border-color: transparent; }

/* Bodies — DM Sans prose, machine text dotted, doctor text plain */
.awm-body {
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: #C7D1DA;
    white-space: pre-wrap;
    min-height: 1.2em;
    outline: none;
}
.awm-row--machine .awm-body {
    text-decoration: underline dotted #59D6C555;
    text-underline-offset: 3px;
}
.awm-row--ghost .awm-body:empty::before {
    content: attr(data-ghost-hint);
    color: #43535F;
    font-style: italic;
}
.awm-body:focus { background: #0E151C; border-radius: 3px; }

/* ── Clinical intake workspace — the clinician's primary working surface */
.awm-intake {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 0 0 auto;
    margin: 10px 14px 12px;
    padding: 14px;
    border: 1px solid var(--term-border-default);
    border-left: 3px solid var(--term-accent);
    border-radius: 6px;
    background: var(--term-bg-elevated);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 8px 28px rgba(0,0,0,0.24);
    font-family: var(--term-font-mono);
}
.awm-intake:focus-within {
    border-color: var(--term-accent-dim);
    border-left-color: var(--term-accent);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), var(--term-glow-accent);
}
.awm-intake-head,
.awm-intake-foot,
.awm-intake-actions {
    display: flex;
    align-items: center;
}
.awm-intake-head { justify-content: space-between; gap: 16px; }
.awm-intake-actions { gap: 8px; flex: 0 0 auto; }
.awm-intake-title {
    margin: 0;
    color: var(--term-fg-primary);
    font: 600 0.78rem/1.2 var(--term-font-display);
    letter-spacing: 0.11em;
    text-transform: uppercase;
}
.awm-intake-help {
    margin: 4px 0 0;
    color: var(--term-fg-secondary);
    font: 400 0.78rem/1.4 var(--term-font-body);
}
.awm-intake-input {
    display: block;
    width: 100%;
    min-height: clamp(180px, 25vh, 300px);
    max-height: 58vh;
    box-sizing: border-box;
    resize: vertical;
    padding: 14px 16px;
    background: var(--term-bg-input);
    border: 1px solid var(--term-border-strong);
    border-radius: 5px;
    outline: none;
    color: var(--term-fg-primary);
    font-family: var(--term-font-body);
    font-size: 16px;
    line-height: 1.55;
    caret-color: var(--term-accent);
    scrollbar-gutter: stable;
}
.awm-intake-input:focus { border-color: var(--term-accent); }
.awm-intake--expanded .awm-intake-input { min-height: min(52vh, 560px); }
.awm-intake-input::placeholder { color: var(--term-fg-muted); }
.awm-intake-dictate,
.awm-intake-expand {
    font-family: var(--term-font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    color: var(--term-fg-secondary);
    background: transparent;
    border: 1px solid var(--term-border-strong);
    border-radius: 3px;
    padding: 7px 11px;
    cursor: pointer;
}
.awm-intake-expand:hover { color: var(--term-accent); border-color: var(--term-accent-dim); }
.awm-intake-dictate:hover { color: var(--term-status-error); border-color: var(--term-status-error); }
/* Live-dictation state — voice-recorder toggles body.aw-dictating while the
   session is live; the same button click stops it. */
body.aw-dictating .awm-intake-dictate {
    color: var(--term-status-error);
    border-color: var(--term-status-error);
}
body.aw-dictating .awm-intake-dictate::after {
    content: ' ●';
    animation: awm-rec-pulse 1.2s ease-in-out infinite;
}
@keyframes awm-rec-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
}
.awm-intake-foot { justify-content: space-between; gap: 12px; min-height: 18px; }
.awm-intake-meta,
.awm-intake-stamp { font-size: 10px; color: var(--term-fg-muted); }
.awm-intake-stamp { color: var(--term-accent); text-align: right; }

@media (max-width: 760px) {
    .awm-intake { margin: 8px; padding: 11px; }
    .awm-intake-head { align-items: flex-start; }
    .awm-intake-help { display: none; }
    .awm-intake-input { min-height: 210px; }
}

/* ── Manuscript layout: sheet | margin rail (handoff §1: 1fr | 276px) */
.awm-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 276px;
    gap: 0;
    align-items: start;
}
@media (max-width: 1279px) {
    .awm-layout { grid-template-columns: minmax(0, 1fr); }
    .awm-rail { display: none; }   /* rail is a >=1280 surface, like verify split */
}

/* ── Margin rail (T1.5) */
.awm-rail {
    border-left: 1px solid #1C2833;
    padding: 8px 10px 40px;
    font-family: 'JetBrains Mono', monospace;
    position: sticky;
    top: 0;
}
.awm-rail-sec { padding: 6px 0; border-bottom: 1px solid #131C24; }
.awm-rail-head { display: flex; align-items: baseline; gap: 6px; }
.awm-rail-prov { font-size: 10px; color: #7A93A5; margin-top: 2px; }
.awm-rail-evi {
    font-size: 10px;
    color: #43535F;
    margin-top: 3px;
    padding-left: 8px;
    border-left: 1px solid #22303C;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.awm-rail-evi-src { color: #59D6C5; }
.awm-rail-queued {
    font-size: 10px;
    color: #F2A93B;
    margin-top: 3px;
    cursor: help;
}
.awm-rail-unrouted {
    font-size: 10px;
    color: #F2A93B;
    padding: 6px;
    border: 1px dashed #F2A93B55;
    border-radius: 3px;
    margin-bottom: 6px;
}

/* ── Freshness (receipt, S-4) + pending (S-5) pills */
.awm-pill--fresh { color: #59D6C5; border-color: #59D6C544; }
.awm-pill--same { color: #43535F; border-color: #22303C; }
.awm-pill--pending { color: #F2A93B; border-color: #F2A93B55; }
.awm-pill--violation { color: #F2A93B; background: #F2A93B22; border-color: #F2A93B; }

/* ── P2 T2.1 (ENABLE_AW_MANIPULATE): selection micro-toolbar ──────────────────
   Singleton fixed-position strip on document.body — JS creates it only when the
   manipulate flag is on, so these rules are inert otherwise. */
.awm-mtb {
    position: fixed;
    z-index: 400;
    display: flex;
    gap: 2px;
    padding: 3px;
    background: #0D141B;
    border: 1px solid #31424F;
    border-radius: 4px;
    box-shadow: 0 4px 14px #00000066;
    font-family: 'JetBrains Mono', monospace;
}
.awm-mtb button {
    font-size: 10px;
    letter-spacing: 0.08em;
    color: #9FB0BC;
    background: transparent;
    border: none;
    border-radius: 3px;
    padding: 4px 9px;
    cursor: pointer;
}
.awm-mtb button:hover { color: #59D6C5; background: #16212B; }
.awm-mtb button[data-mtb="delete"]:hover { color: #E05B4F; }
.awm-pill--actionable { cursor: pointer; }
.awm-pill--actionable:hover { border-color: #9FB0BC; }
.awm-mtb-label { color: #59D6C5; padding: 4px 4px 4px 7px; font-size: 11px; }

/* ── P2 T2.9: aimed dictation — live-only ring + pill (motion budget) */
body.aw-dictating .awm-row--aimed {
    outline: 1px solid #59D6C5;
    outline-offset: -1px;
    border-radius: 4px;
}
body.aw-dictating .awm-row--aimed .awm-row-head::after {
    content: '● LIVE — AIMED HERE';
    font-size: 9px;
    letter-spacing: 0.08em;
    color: #59D6C5;
    margin-left: auto;
}
.awm-row-head { cursor: pointer; }

/* ── P2 T2.6: MEDS per-line list — grip · line · strike */
.awm-medlist { display: flex; flex-direction: column; gap: 1px; }
.awm-med {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 1px 2px;
    border-radius: 3px;
}
.awm-med:hover { background: #0E151C; }
.awm-med-grip { color: #31424F; cursor: grab; font-size: 10px; flex: none; user-select: none; }
.awm-med-text {
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: #C7D1DA;
    flex: 1;
    outline: none;
    white-space: pre-wrap;
}
.awm-med-text:focus { background: #0E151C; border-radius: 3px; }
.awm-med-strike {
    flex: none;
    background: none;
    border: none;
    color: #31424F;
    font-size: 11px;
    cursor: pointer;
    padding: 0 4px;
    visibility: hidden;
}
.awm-med:hover .awm-med-strike { visibility: visible; }
.awm-med-strike:hover { color: #E05B4F; }

/* ── P2 T2.5: VS/LABS chip strip (a lens over the parse; prose stays truth) */
.awm-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 2px 0 5px;
}
.awm-chip {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: #7A93A5;
    background: #0E151C;
    border: 1px solid #22303C;
    border-radius: 3px;
    padding: 2px 7px;
    cursor: pointer;
}
.awm-chip b { color: #C7D1DA; font-weight: 600; }
.awm-chip:hover { border-color: #59D6C544; color: #9FB0BC; }
.awm-chip--ghost { color: #43535F; border-style: dashed; }
.awm-chip--ghost:hover { color: #59D6C5; }
.awm-chip-input {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: #C7D1DA;
    background: #0E151C;
    border: 1px solid #59D6C544;
    border-radius: 3px;
    padding: 2px 7px;
    width: 120px;
    outline: none;
}

/* ── P2 T2.4: rail lens (MARGIN ⇄ LEDGER) */
.awm-rail-lensbar { display: flex; gap: 2px; margin-bottom: 6px; }
.awm-rail-lensbar button {
    flex: 1;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.1em;
    color: #43535F;
    background: transparent;
    border: 1px solid #22303C;
    border-radius: 3px;
    padding: 3px 0;
    cursor: pointer;
}
.awm-rail-lensbar button.is-active { color: #59D6C5; border-color: #59D6C544; }
.awm-led-filter {
    font-size: 10px;
    color: #F2A93B;
    border: 1px dashed #F2A93B55;
    border-radius: 3px;
    padding: 3px 6px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.awm-led-filter button { background: none; border: none; color: #7A93A5; cursor: pointer; font-size: 10px; }
.awm-led-cap { font-size: 9px; color: #F2A93B; margin-bottom: 4px; }
.awm-led-row {
    display: flex;
    gap: 6px;
    align-items: baseline;
    font-size: 10px;
    color: #7A93A5;
    padding: 3px 0;
    border-bottom: 1px solid #131C24;
}
.awm-led-row--compile { color: #59D6C5; }
.awm-led-t { color: #43535F; flex: none; }
.awm-led-g { flex: none; color: #59D6C5; }
.awm-led-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.awm-led-route { flex: none; color: #43535F; }
.awm-led-st { flex: none; font-size: 8px; letter-spacing: 0.08em; padding: 0 4px; border-radius: 2px; border: 1px solid #22303C; }
.awm-led-st--pending { color: #F2A93B; border-color: #F2A93B55; }
.awm-led-st--consumed { color: #43535F; }
.awm-led-st--superseded { color: #43535F; text-decoration: line-through; }
.awm-led-empty { font-size: 10px; color: #43535F; padding: 8px 0; }
.awm-rail-prov [data-awm-ledger-sec] { cursor: pointer; }
.awm-rail-prov [data-awm-ledger-sec]:hover { color: #59D6C5; }
.awm-row--hl { outline: 1px dashed #59D6C555; outline-offset: -1px; }

/* ── P2 T2.3: conflict card (amber = decision) + jump flash */
.awm-conflict {
    margin-top: 6px;
    padding: 6px 9px;
    border: 1px solid #F2A93B55;
    border-left: 2px solid #F2A93B;
    border-radius: 3px;
    font-family: 'JetBrains Mono', monospace;
}
.awm-conflict-head { font-size: 10px; letter-spacing: 0.06em; color: #F2A93B; }
.awm-conflict-text {
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    color: #9FB0BC;
    margin: 4px 0 6px;
    white-space: pre-wrap;
}
.awm-conflict-actions { display: flex; gap: 6px; }
.awm-conflict-actions button {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
    color: #9FB0BC;
    background: transparent;
    border: 1px solid #31424F;
    border-radius: 3px;
    padding: 2px 8px;
    cursor: pointer;
}
.awm-conflict-actions button:hover { color: #F2A93B; border-color: #F2A93B66; }
.awm-rail-queued[data-awm-jump] { cursor: pointer; }
.awm-row--flash { outline: 1px solid #F2A93B; outline-offset: -1px; transition: outline-color 1.4s ease; }

/* ── P2 T2.2: misroute question banner (amber = decision) */
.awm-misroute {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
    padding: 5px 8px;
    border: 1px dashed #F2A93B55;
    border-radius: 3px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
}
.awm-misroute-q { color: #F2A93B; }
.awm-misroute button {
    font-size: 10px;
    letter-spacing: 0.06em;
    color: #9FB0BC;
    background: transparent;
    border: 1px solid #31424F;
    border-radius: 3px;
    padding: 2px 8px;
    cursor: pointer;
}
.awm-misroute button:hover { color: #F2A93B; border-color: #F2A93B66; }

/* ── S-13 demographics auto-fill stamp */
.awm-demo-stamp {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: #59D6C5;
    margin-left: 8px;
    white-space: nowrap;
}

/* ── Active-skin token bridge
   Manuscript used to remain Night Dispatch blue/teal while the shell toggled
   Stock or Phosphor. These late declarations intentionally replace every
   user-facing hardcoded manuscript role with the active Admissions tokens. */
.awm-counter,
.awm-title,
.awm-pill,
.awm-rail-prov,
.awm-conflict-text,
.awm-conflict-actions button,
.awm-misroute button,
.awm-led-row { color: var(--term-fg-secondary); }

.awm-counter-meta,
.awm-row--ghost .awm-abbrev,
.awm-row--ghost .awm-body:empty::before,
.awm-intake-meta,
.awm-rail-evi,
.awm-pill--same,
.awm-led-t,
.awm-led-route,
.awm-led-st--consumed,
.awm-led-st--superseded,
.awm-led-empty { color: var(--term-fg-muted); }

.awm-preamble,
.awm-body,
.awm-row--compiled .awm-body,
.awm-med-text,
.awm-chip b { color: var(--term-fg-primary); }

.awm-counter-ready,
.awm-counter-done,
.awm-counter-stream,
.awm-abbrev,
.awm-pill--suggested,
.awm-pill--live,
.awm-pill--done,
.awm-pill--fresh,
.awm-mtb-label,
.awm-led-row--compile,
.awm-led-g,
.awm-rail-evi-src,
.awm-rail-prov [data-awm-ledger-sec]:hover,
.awm-demo-stamp { color: var(--term-accent); }

.awm-counter-req,
.awm-pill--conflict,
.awm-pill--pending,
.awm-pill--violation,
.awm-rail-queued,
.awm-rail-unrouted,
.awm-led-cap,
.awm-led-st--pending,
.awm-conflict-head,
.awm-misroute-q { color: var(--term-gold); }

.awm-counter,
.awm-pill,
.awm-rail,
.awm-rail-sec,
.awm-rail-evi,
.awm-med,
.awm-chip,
.awm-rail-lensbar,
.awm-led-row,
.awm-led-st,
.awm-conflict-actions button,
.awm-misroute button { border-color: var(--term-border-default); }

.awm-row--primary,
.awm-body:focus,
.awm-med:hover,
.awm-med-text:focus,
.awm-chip { background: var(--term-bg-input); }

.awm-mtb { background: var(--term-bg-elevated); border-color: var(--term-border-strong); }
.awm-mtb button:hover { color: var(--term-accent); background: var(--term-bg-surface); }
.awm-mtb button[data-mtb="delete"]:hover,
.awm-med-strike:hover { color: var(--term-status-error); }

.awm-row--live { outline-color: var(--term-accent); }
.awm-row--required,
.awm-rail-unrouted,
.awm-conflict,
.awm-misroute { border-color: var(--term-gold-dim); }
.awm-conflict { border-left-color: var(--term-gold); }
.awm-row--flash { outline-color: var(--term-gold); }
.awm-row--hl { outline-color: var(--term-accent-dim); }

.awm-sheet,
.awm-counter,
.awm-rail,
.awm-mtb,
.awm-conflict,
.awm-misroute,
.awm-demo-stamp { font-family: var(--term-font-mono); }
.awm-preamble,
.awm-body,
.awm-med-text,
.awm-conflict-text { font-family: var(--term-font-body); }
