/* Daily Life Doc, round 10: a document of blocks (docs/build/r10/PLAN.md 2.11; the page "One chat", Parts 5 and 7).
   The page `document` (js/docs/docs-page.js), the blocks as the patient reads them (js/docs/doc-draw.js), the editor
   by blocks (js/docs/doc-edit.js), the body of the document card and the card in the chat (js/docs/doc-card.js), the
   experiment's Documents (js/exp/exp-docs.js), each attachment with its own ✕ in edit mode (js/exp/edit-rows.js) and
   a document under an Atlas entry (js/docs/doc-atlas.js). Tokens and the shared type scale only; tinted, not boxed. */

/* The title is the page's heading and may take two lines (a document's title is a whole phrase). */
.pg[data-page="document"] .pg-head { align-items: flex-start; }
.pg[data-page="document"] .pg-head h2 { white-space: normal; overflow: visible; font-size: var(--t-l); line-height: 1.3; padding-top: 9px; text-wrap: balance; }

.dcp { display: flex; flex-direction: column; min-height: 100%; }
/* Under the title: "Care team · Not checked by a clinician yet · Home exercise" for the patient; "Draft · v2 · Home
   exercise" and the pink "Care team only" for the care team. */
.dcp-sub { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; margin: 0 2px 10px; font-size: var(--t-s); font-weight: 500; color: var(--ink2); }
.dcp-sub .quiet.link { min-height: 24px; font-size: var(--t-sm); }
.dcp-sub .team-word { font-size: var(--t-xs); font-weight: 600; color: var(--care-d); }
.dc-wait { margin: 0; min-height: 28px; font-size: var(--t-s); line-height: 28px; color: var(--ink3); }

/* ---- The blocks as the patient reads them, on one white sheet ---- */
.doc.dk-doc { display: grid; gap: 16px; padding: 18px 18px 20px; border-radius: 22px; box-shadow: 0 1px 0 var(--line); }
.dk { margin: 0; min-width: 0; }
.dk-h { margin: 0 0 6px; font-size: var(--t-sm); font-weight: 600; line-height: 22px; letter-spacing: .02em; color: var(--ink2); }
.dk-text h3 { margin: 0 0 4px; font-size: var(--t-m); font-weight: 600; line-height: 1.45; }
.dk-text p { margin: 0; font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.dk-text p + p { margin-top: 8px; }
.dk-steps { margin: 0; padding-left: 22px; display: grid; gap: 6px; font-size: 15px; line-height: 1.5; }
.dk-steps li::marker { font-weight: 600; color: var(--ink2); }
.dk-pic img { display: block; width: 100%; height: auto; max-height: 340px; object-fit: cover; border-radius: 16px; background: var(--soft); animation: dd-fade 320ms ease both; }
.dk-pic img[hidden] { display: none; }
/* FR2: in dark mode a light picture (the drawing kept under "How to do it") is dimmed a little, so it does not glare. */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .dk-pic img { filter: brightness(.82); } }
:root[data-theme="dark"] .dk-pic img { filter: brightness(.82); }
.dk-pic figcaption, .dk-vid figcaption { margin-top: 6px; font-size: var(--t-xs); line-height: 1.4; color: var(--ink3); }
/* The video: the poster with a play mark; a tap puts the real player in its place, playing inside the page. */
.dk-play, .dk-frame { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 16px; overflow: hidden; background: #11151F; }
.dk-play img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: .92; }
.dk-play i { position: absolute; left: 50%; top: 50%; width: 60px; height: 42px; margin: -21px 0 0 -30px; border-radius: 12px; background: #D5382F; transition: transform var(--m-press) ease; }
.dk-play i::before { content: ''; position: absolute; left: 24px; top: 13px; border-style: solid; border-width: 8px 0 8px 14px; border-color: transparent transparent transparent #fff; }
.dk-play:active i { transform: scale(.94); }
.dk-frame { animation: dd-fade 320ms ease both; }
/* Round 12 (zone DP): the care team's own recording, the phone's own player inside the page. */
.dk-vfile video { display: block; width: 100%; max-height: 420px; border-radius: 16px; background: #11151F; animation: dd-fade 320ms ease both; }
.dk-vid figcaption { display: flex; flex-wrap: wrap; gap: 0 8px; font-size: var(--t-sm); font-weight: 600; color: var(--ink); }
.dk-vid figcaption small { font-weight: 500; color: var(--ink3); }
.dk-link { display: grid; gap: 2px; padding: 11px 14px; border-radius: 16px; background: var(--soft); text-decoration: none; color: var(--ink); transition: opacity var(--m-press) ease; }
.dk-link:active { opacity: .6; }
.dk-link b { font-size: var(--t-s); font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.dk-link small { font-size: var(--t-xs); color: var(--ink3); }
.dk-link span { font-size: var(--t-sm); line-height: 1.45; color: var(--ink2); }
/* Checklist: boxes the patient ticks (a tap springs the box); the care team sees them, read only. */
.dk-ck { display: grid; }
.dk-cr { display: flex; align-items: flex-start; gap: 12px; min-height: 40px; padding: 7px 0; text-align: left; font-size: 15px; line-height: 1.45; color: var(--ink); }
.dk-cr i { flex: none; display: grid; place-items: center; width: 22px; height: 22px; margin-top: 0; border-radius: 7px; box-shadow: inset 0 0 0 1.75px var(--ink3); color: transparent; transition: background-color var(--m-step) ease, box-shadow var(--m-step) ease; }
.dk-cr i svg { width: 14px; height: 14px; }
.dk-cr.on i { background: var(--good); box-shadow: none; color: #fff; }
.dk-cr.on span { color: var(--ink2); }
.dk-cr[disabled] { cursor: default; }
.dk-q { font-size: var(--t-xs); color: var(--ink3); }
.dk-rows { display: grid; gap: 0; }
.dk-row { padding: 10px 0; display: grid; gap: 2px; }
.dk-row + .dk-row { border-top: 1px solid var(--line); }
.dk-row h5 { margin: 0 0 2px; font-size: var(--t-s); font-weight: 600; line-height: 1.4; }
.dk-row i { font-style: normal; font-size: var(--t-2xs); font-weight: 600; color: var(--ink3); margin-top: 4px; }
.dk-row p { margin: 0; font-size: var(--t-sm); line-height: 1.5; color: var(--ink); }
/* "What would you like to do?" at the end: Start now, or Wait for the clinician. */
.dk-try { display: grid; gap: 8px; padding: 12px 14px 14px; border-radius: 16px; background: var(--tint); }
.dk-try .dk-h { margin: 0; color: var(--ink); font-size: var(--t-s); }
.dk-tw { font-size: var(--t-sm); line-height: 1.45; color: var(--ink2); }
.dk-tw b { font-weight: 600; color: var(--ink); }
.dk-tb { display: flex; flex-wrap: wrap; gap: 8px; }
.dk-tb .btn { flex: 1 1 auto; }
.dk-tst { font-size: var(--t-sm); font-weight: 600; color: var(--ink2); animation: dd-fade 320ms ease both; }
.dk-src { display: grid; }
.dk-src a { display: flex; align-items: flex-start; gap: 6px; min-height: 32px; padding: 4px 0; line-height: 24px; font-size: var(--t-s); font-weight: 500; color: var(--ink2); text-decoration: none; }
.dk-src a svg { flex: none; width: 15px; height: 15px; margin-top: 4.5px; }
.dk-src a span { min-width: 0; overflow-wrap: anywhere; }
.dk-src .chev { margin: 9.5px 0 0 2px; }

/* ---- The editor by blocks (the care team) ---- */
.de { display: grid; gap: 10px; }
.de-list { display: grid; gap: 8px; }
.de-b { display: flex; align-items: flex-start; gap: 6px; padding: 8px 8px 8px 4px; border-radius: 18px; background: var(--surface); box-shadow: 0 1px 0 var(--line); transition: box-shadow var(--m-step) ease; }
.de-b.sel { box-shadow: inset 0 0 0 2px var(--ink); }
.de-mv { flex: none; display: grid; }
.de-mv button { display: grid; place-items: center; width: 30px; height: 26px; color: var(--ink3); border-radius: 8px; }
.de-mv button svg { width: 14px; height: 14px; }
.de-mv button:first-child svg { transform: rotate(-90deg); }
.de-mv button:last-child svg { transform: rotate(90deg); }
.de-mv button[disabled] { opacity: .3; }
.de-mv button:active { background: var(--soft); }
.de-m { flex: 1; min-width: 0; display: grid; gap: 8px; }
.de-s { display: flex; align-items: center; gap: 10px; min-height: 40px; text-align: left; font-size: var(--t-sm); line-height: 1.45; color: var(--ink); }
.de-s > span { min-width: 0; overflow-wrap: anywhere; }
.de-w { margin-right: 6px; font-weight: 600; color: var(--care-d); }
.de-th { flex: none; display: block; width: 52px; height: 36px; border-radius: 8px; overflow: hidden; background: var(--soft); }
.de-th img { display: block; width: 100%; height: 100%; object-fit: cover; }
.de-th img[hidden] { display: none; }
.de-fs { display: grid; gap: 6px; }
.de-fs .de-f { width: 100%; min-height: 40px; padding: 8px 12px; border-radius: 12px; font: inherit; font-size: var(--t-s); line-height: 1.45; resize: none; overflow: hidden; }
.de-lab { font-size: var(--t-2xs); font-weight: 600; color: var(--ink3); }
.de-row { display: grid; gap: 4px; padding-top: 4px; }
.de-acts { display: flex; gap: 8px; }
.de-acts .btn svg { width: 16px; height: 16px; }
.de-pick { display: flex; align-items: center; gap: 8px; min-height: 36px; text-align: left; font-size: var(--t-sm); color: var(--ink2); }
.de-pick.on { color: var(--ink); font-weight: 600; }
.de-pick svg { flex: none; width: 15px; height: 15px; }
.de-x { flex: none; display: grid; place-items: center; width: 32px; height: 32px; margin-top: 4px; border-radius: 50%; background: var(--soft); color: var(--ink2); }
.de-x svg { width: 13px; height: 13px; }
.de-x:active, .de-mv button:active { opacity: .6; }
.de-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.de-chip { min-height: 34px; padding: 0 12px; border-radius: 17px; background: var(--soft); font-size: var(--t-sm); font-weight: 500; color: var(--ink2); transition: opacity var(--m-press) ease; }
.de-chip:active { opacity: .6; }

/* The care team's words that go before the card in the chat (a tap changes them). */
.dcp-msg { display: grid; gap: 2px; margin: 14px 0 0; padding: 10px 14px; border-radius: 16px; background: var(--tint-team); text-align: left; color: var(--ink); }
.dcp-msg[hidden] { display: none; }
.dcp-msg small { font-size: var(--t-xs); font-weight: 600; color: var(--care-d); }
.dcp-msg span { font-size: var(--t-sm); line-height: 1.45; }

/* The line that says where Approve sends the document, then Approve · Ask clinician · Drop (the care team). */
.dcp-place { margin: 14px 2px 0; font-size: var(--t-sm); line-height: 1.45; color: var(--ink2); }
.dcp-place[hidden] { display: none; }
.dcp-acts { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; }
.dcp-acts[hidden] { display: none; }
.dcp-acts .btn { flex: 1 1 auto; height: 46px; }

/* ---- The body of a document card (zone A draws the card around it) ---- */
.dcd { display: grid; gap: 4px; }
.dcd-t { display: inline-flex; align-items: center; text-align: left; font-size: var(--t-m); font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; color: var(--ink); }
.dcd-t .chev { margin-left: 6px; }
.dcd-l { display: block; font-size: var(--t-sm); line-height: 1.45; color: var(--ink2); }
.dcd-again { margin-left: 8px; font-size: var(--t-sm); font-weight: 600; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.dcd-pl { display: grid; margin-top: 4px; }
.dcd-sw { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; text-align: left; font-size: var(--t-sm); font-weight: 500; color: var(--ink); }
.dcd-sw i { flex: none; position: relative; width: 40px; height: 24px; border-radius: 12px; background: color-mix(in srgb, var(--ink3) 38%, var(--soft)); transition: background-color var(--m-step) ease; }
.dcd-sw i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px var(--scrim); transition: transform var(--m-step) var(--ease-out); }
.dcd-sw[aria-checked="true"] i { background: var(--good); }
.dcd-sw[aria-checked="true"] i::after { transform: translateX(16px); }
.dcd-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 0 0 6px 12px; animation: dd-fade 240ms ease both; }
.dcd-pick { display: inline-flex; align-items: center; min-height: 32px; font-size: var(--t-sm); font-weight: 600; color: var(--ink); text-align: left; overflow-wrap: anywhere; }
.dcd-pick .chev { margin-left: 4px; }
.dcd-seg { display: inline-flex; padding: 2px; border-radius: 10px; background: var(--soft); }
.dcd-seg button { min-height: 28px; padding: 0 10px; border-radius: 8px; font-size: var(--t-xs); font-weight: 600; color: var(--ink2); transition: background-color var(--m-step) ease; }
.dcd-seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px var(--line); }
.dcd-where { margin: 4px 0 0; font-size: var(--t-xs); line-height: 1.45; color: var(--ink2); }

/* The card in the chat, both sides: the document's title, "Document · How to do it", the clinician's mark. */
.dcc { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 16px; background: var(--surface); text-align: left; color: var(--ink); transition: opacity var(--m-press) ease; }
.dcc:active { opacity: .7; }
.dcc > svg { flex: none; width: 20px; height: 20px; color: var(--ink2); }
.dcc-m { flex: 1; min-width: 0; display: grid; gap: 1px; }
.dcc-m b { font-size: var(--t-s); font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.dcc-m small { font-size: var(--t-xs); color: var(--ink3); }
.dcc-m .dcc-ck { color: var(--ink2); font-weight: 500; }

/* Versions: one row per version, newest first, on a white sheet of their own. */
.dcp-vers { margin-top: 10px; padding: 12px 18px 12px; border-radius: 22px; background: var(--surface); box-shadow: 0 1px 0 var(--line); }
.dcp-vers[hidden] { display: none; }
.dcp-vers .tp-h { margin-bottom: 4px; }
.dcv-row { display: flex; gap: 12px; padding: 7px 0; font-size: var(--t-s); line-height: 1.45; color: var(--ink2); }
.dcv-row + .dcv-row { border-top: 1px solid var(--line); }
.dcv-row b { flex: none; min-width: 26px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.dcv-row span { min-width: 0; overflow-wrap: anywhere; }
.dcv-row .nw { white-space: nowrap; }

/* The field "Say what to change" stays at the bottom of the page while the document scrolls (css/shell.css keeps
   96 px under the content; the box is moved down by the same 96 px). */
.dcp.is-team { min-height: calc(100% + 96px); margin-bottom: -96px; }
.dcp-box { position: sticky; bottom: -96px; z-index: 2; margin: auto calc(-1 * var(--gut)) 0; padding: 22px 12px 14px; background: linear-gradient(transparent, var(--bg) 18px); }
.dcp-box[hidden] { display: none; }

/* ---- The experiment's Documents (in place of Notes and Research) ---- */
.xd-row { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 48px; padding: 6px 0; text-align: left; color: var(--ink); transition: opacity var(--m-press) ease; }
.xd-row + .xd-row { border-top: 1px solid var(--line); }
.xd-row:active { opacity: .6; }
.xd-row > span { flex: 1; min-width: 0; display: grid; gap: 1px; }
.xd-row b { font-size: var(--t-s); font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.xd-row small { font-size: var(--t-xs); line-height: 1.4; color: var(--ink2); }

/* ---- Edit on Today: each attachment under its action with its kind, how long, and its own ✕ ---- */
.xe-h.is-edit { display: grid; gap: 2px; margin-top: 4px; }
.xe-at { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 8px; padding: 2px 0; }
.xe-at .xe-hl { grid-column: 1; color: var(--ink); }
.xe-at small { grid-column: 1; margin: -4px 0 2px 20px; font-size: var(--t-xs); line-height: 1.4; color: var(--ink3); }
.xe-hx { grid-column: 2; grid-row: 1 / span 2; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: var(--ink3); }
.xe-hx svg { width: 13px; height: 13px; }
.xe-hx:active { background: var(--soft); }

/* Today: an action a document started says whether a clinician checked it (round 10). */
.tp-ck { margin-top: 1px; font-size: var(--t-xs); line-height: 1.4; color: var(--ink3); }

/* ---- A document under an Atlas entry ---- */
.ln-docs { display: flex; flex-wrap: wrap; gap: 0 16px; margin-top: 2px; }

@media (prefers-reduced-motion: reduce) {
  .dk-pic img, .dk-frame, .dk-tst, .dcd-sub { animation: none; }
  .dcd-sw i, .dcd-sw i::after, .dk-cr i, .de-b { transition: none; }
}

/* The entry's bar holds five words for the care team (Document added): tighter, and words only on a narrow phone, so
   the bar never runs past the screen (css/lines.css draws the bar). */
.lbar:has([data-act="doc"]:not([hidden])) button { padding: 0 8px; gap: 4px; }
@media (max-width: 440px) { .lbar:has([data-act="doc"]:not([hidden])) button svg { display: none; } }

/* ---- Round 12 (zone DP): "Ask about this" at the very end of the patient's document ---- */
.dk-askbar { display: flex; justify-content: center; padding-top: 4px; }
.dk-askbtn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px; }
.dk-askbtn svg { width: 18px; height: 18px; }
/* The chip "About: <title>" over the patient's field after Ask about this (the care team's chip is blue-grey). */
.cf.is-patient .cf-about.is-doc { margin: 0 0 6px 52px; background: var(--soft); }
.cf.is-patient .cf-about.is-doc .cf-ab b { color: var(--ink2); }

/* ---- Round 12 (zone DP): the patient's Look on a document (DD.docLook puts the classes on the page) ---- */
.hb-text-large .dk-doc .dk-text p, .hb-text-large .dk-doc .dk-steps, .hb-text-large .dk-doc .dk-cr, .hb-text-large .dk-doc .dkn-ta,
.hb-text-large .dk-doc .dkn-read, .hb-text-large .dk-doc .dkq-q { font-size: var(--t-l); }
.hb-text-large .dk-doc .dkq-o, .hb-text-large .dk-doc .dk-link b, .hb-text-large .dk-doc .dkq-why p { font-size: var(--t-m); }
.hb-text-large .dk-doc .dk-text h3 { font-size: var(--t-l); }
.hb-space-roomy .doc.dk-doc { gap: 24px; padding: 22px 20px 24px; }
