/* App layer over tokens.css + components.css. Only token values, two added below with reasons. */

:root {
  /* Geist for the work, Newsreader for titles: the report reads like a document, the controls like a tool. */
  --font-sans: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Newsreader", Georgia, serif;
  --ok: var(--state);
}

html, body { height: 100%; overflow: hidden; }
body { background: var(--ground); }
.login { overflow: auto; height: 100%; }
.serif { font-family: var(--font-serif); font-weight: 500; letter-spacing: -0.01em; }
h1.serif { font-size: var(--step-title); line-height: var(--lh-title); }
.display.serif { font-size: var(--step-display); line-height: var(--lh-display); letter-spacing: -0.02em; }
.kicker { display: block; font-size: var(--step-small); line-height: var(--lh-small); font-weight: var(--weight-strong); color: var(--muted); }
.lede { color: var(--text-2); white-space: pre-wrap; }
.grow { flex: 1; }
.link { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.link:hover { text-decoration-color: currentColor; }
.btn.danger { color: var(--danger); }
.btn kbd { order: 2; margin: 0 -4px 0 2px; }
.todo { font-size: var(--step-small); font-weight: var(--weight-strong); color: var(--danger); white-space: nowrap; }
.todo::before { content: "◆ "; font-size: 8px; vertical-align: 2px; }

/* Login */
.login { display: grid; place-items: center; min-height: 100dvh; padding: var(--space-4); }
.login form { display: grid; gap: var(--space-5); width: min(380px, 100%); }
.login-head { display: grid; gap: var(--space-2); margin-bottom: var(--space-4); }
.login h1.serif { font-size: var(--step-display); line-height: var(--lh-display); }

/* Shell */
.side { gap: 1px; }
.side .brand { display: grid; gap: 2px; padding: 4px 10px 16px; }
.side .brand .serif { font-size: 19px; line-height: 1.2; }
.side h3 { margin-top: var(--space-6); }
.nav { cursor: pointer; border: 0; background: none; width: 100%; text-align: left; font-family: inherit; }
.nav.add span { color: var(--muted); }
.nav.add:hover span { color: var(--text); }
.tally { font-size: var(--step-small); color: var(--muted); }
.tally.full { color: var(--ok); }
.count.fresh { box-shadow: none; background: var(--state); color: var(--on-solid); }
:root[data-theme="dark"] .count.fresh { color: var(--ground); }
.side .foot { display: grid; gap: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--border); }
.who { display: flex; align-items: center; gap: var(--space-2); padding: 0 4px 0 6px; font-size: var(--step-row); }
.who-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.keys { padding: 0 10px; line-height: 2; }
.keys kbd { margin-right: 2px; }
.avatar { flex: none; }
.avatar[data-role="doctor"] { background: var(--state); color: var(--on-solid); }
:root[data-theme="dark"] .avatar[data-role="doctor"] { color: var(--ground); }

.top { gap: var(--space-3); }
.top .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .menu-btn { display: none; }
/* Presence */
.presence { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 400; }
.faces { display: inline-flex; }
.faces .avatar { width: 24px; height: 24px; font-size: 10px; box-shadow: 0 0 0 2px var(--panel); }
.faces .avatar + .avatar { margin-left: -6px; }
.online-label::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: var(--radius-round); background: var(--state); vertical-align: 1px; }
.avatar.xs, .nav span.avatar.xs { flex: none; width: 20px; height: 20px; font-size: 9px; }
.here { display: inline-flex; gap: 2px; }
.here:empty { display: none; }
.who-online .nav { height: auto; min-height: var(--row-nav); padding: 6px 10px; }
.who-online .nav > span:last-child { display: grid; white-space: normal; }
.who-online .where { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-online .none { padding: 4px 10px; }
.typing { font-size: var(--step-small); line-height: var(--lh-small); color: var(--state); padding: 0 14px; }
.typing:empty { display: none; }
.scroll { overflow: auto; min-height: 0; }

/* Page frame */
.page { max-width: 800px; margin: 0 auto; padding: var(--space-10) var(--space-6) var(--space-16); }
.page > section { margin-top: var(--space-12); }
.banner { margin-bottom: var(--space-8); padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--panel); box-shadow: inset 0 0 0 1px var(--border); font-size: var(--step-row); color: var(--text-2); }
.page-head { display: grid; gap: var(--space-3); margin-bottom: var(--space-6); }
.title-row { display: flex; align-items: baseline; gap: var(--space-3); justify-content: space-between; }
.page-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); justify-content: space-between; margin-bottom: var(--space-4); }
.section-title { font-size: var(--step-row); line-height: var(--lh-row); font-weight: var(--weight-title); margin-bottom: var(--space-3); }
.section-head { display: flex; align-items: center; justify-content: space-between; }
.section-head .section-title { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.filtered { padding: var(--space-6) 0; border-top: 1px solid var(--text); }

/* Home */
.hero { display: grid; gap: var(--space-3); }
.hero .lede { max-width: 60ch; }
.progress { display: grid; gap: var(--space-6); padding-top: var(--space-6); border-top: 1px solid var(--text); }
.meter.big { font-size: var(--step-row); font-weight: var(--weight-strong); }
.meter.big .meter-track { height: 6px; }
.meter.big .meter-value { color: var(--text); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); margin: 0; }
.stats div { display: flex; flex-direction: column-reverse; gap: 2px; }
.stats dt { font-size: var(--step-small); line-height: var(--lh-small); color: var(--muted); }
.stats dd { margin: 0; font-size: var(--step-title); line-height: var(--lh-title); font-weight: var(--weight-title); letter-spacing: var(--tr-title); }
.next { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-5); border-radius: var(--radius-lg); background: var(--panel); box-shadow: inset 0 0 0 1px var(--border); }
.next > div { min-width: 0; }
.next-title { font-family: var(--font-serif); font-size: 20px; line-height: 1.3; font-weight: 500; margin: 2px 0; }
.all-done { color: var(--ok); font-weight: var(--weight-strong); }
.sections .row { grid-template-columns: minmax(0, 1fr) auto; }
.mini { display: inline-grid; grid-template-columns: 64px auto; align-items: center; gap: var(--space-2); font-size: var(--step-small); color: var(--muted); }
.mini i { display: block; height: 4px; border-radius: var(--radius-pill); background: linear-gradient(to right, var(--text) calc(var(--p) * 100%), var(--selected) 0); } /* deslop-ignore 06: a two-stop hard edge is a meter fill, not a gradient surface */

/* Feed */
.feed .row { grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; padding: 12px 6px; }
.feed .avatar { width: 26px; height: 26px; font-size: 11px; }
.feed-text { min-width: 0; line-height: var(--lh-row); padding-top: 2px; }
.feed .row-title { white-space: normal; }
.feed .what { color: var(--text-2); }
.feed .small { padding-top: 4px; white-space: nowrap; }
.feed .row[data-new] .row-title::after { content: " · nou"; color: var(--state); font-weight: var(--weight-strong); }

/* Items */
.items { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--text); }
.item { padding: var(--space-8) 0; border-bottom: 1px solid var(--border); scroll-margin-top: var(--space-4); transition: background-color var(--motion); }
.item[data-cur] { background: linear-gradient(var(--hover), var(--hover)) no-repeat -24px 0 / calc(100% + 48px) 100%; } /* deslop-ignore 06: a flat fill that bleeds past the column, not a gradient */
.item-head { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: var(--space-2); align-items: start; }
.item-num { padding-top: 3px; font-size: var(--step-row); color: var(--muted); }
.item[data-status="ok"] .item-num { color: var(--ok); }
.item[data-status="change"] .item-num { color: var(--warn); }
.item[data-status="no"] .item-num { color: var(--danger); }
.item h2 { font-size: 18px; line-height: 1.4; font-weight: var(--weight-title); letter-spacing: -0.01em; }
.item-body { padding-left: 52px; display: grid; gap: var(--space-5); margin-top: var(--space-3); }
.new-mark { font-size: var(--step-small); font-weight: var(--weight-strong); color: var(--state); vertical-align: 2px; }
.decision-line { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: 2px; }
.status-word { font-weight: var(--weight-strong); }
.status-word::before { content: "● "; font-size: 9px; vertical-align: 1px; }
.status-word[data-s="ok"] { color: var(--ok); }
.status-word[data-s="change"] { color: var(--warn); }
.status-word[data-s="no"] { color: var(--danger); }
.status-word[data-s="no"]::before { content: "◆ "; }
.body { display: grid; gap: var(--space-2); color: var(--text-2); }
.body p, .compare p { white-space: pre-wrap; }

/* Before / after */
.compare { display: grid; grid-template-columns: 1fr 1fr; border-radius: var(--radius-lg); box-shadow: inset 0 0 0 1px var(--border); overflow: hidden; }
.compare > div { display: grid; align-content: start; gap: var(--space-2); padding: var(--space-4) var(--space-5); font-size: var(--step-row); line-height: var(--lh-row); min-width: 0; }
.compare h3 { font-size: var(--step-small); line-height: var(--lh-small); font-weight: var(--weight-strong); color: var(--muted); }
.side-now { background: var(--panel); color: var(--text-2); border-right: 1px solid var(--border); }
.side-target h3 { color: var(--text); }
.side-target h3::after { content: " →"; color: var(--muted); }

/* Questions, options, branches */
.qs { list-style: none; counter-reset: q; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.qs li { counter-increment: q; display: grid; grid-template-columns: 22px minmax(0, 1fr); column-gap: var(--space-2); row-gap: 6px; }
.qs li::before { content: counter(q); grid-row: span 3; color: var(--muted); font-variant-numeric: tabular-nums; font-size: var(--step-small); padding-top: 1px; }
.qs .q { color: var(--text); font-weight: var(--weight-strong); }
.opts { display: flex; flex-wrap: wrap; gap: 4px; }
.opt { padding: 1px 8px; border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--border-strong); font-size: var(--step-small); line-height: 20px; color: var(--text-2); background: var(--ground); }
.branch { color: var(--text-2); font-size: var(--step-small); line-height: var(--lh-small); padding-left: var(--space-3); border-left: 1px solid var(--border-strong); }
.branch::before { content: "↳ "; color: var(--muted); }

/* Threshold bands */
.range { display: grid; grid-template-columns: 1fr 1.4fr 1fr; border-radius: var(--radius); box-shadow: inset 0 0 0 1px var(--border); overflow: hidden; }
.band { display: grid; gap: 2px; padding: var(--space-3) var(--space-4); min-width: 0; }
.band + .band { border-left: 1px solid var(--border); }
.band-label { font-size: var(--step-small); line-height: var(--lh-small); font-weight: var(--weight-strong); }
.band-value { font-size: var(--step-body); color: var(--text); }
.band.alert .band-label { color: var(--danger); }
.band.alert .band-label::before { content: "◆ "; font-size: 8px; vertical-align: 1px; }
.band.normal { background: var(--state-soft); }
.band.normal .band-label { color: var(--text); }
.band.na .band-label { color: var(--muted); }
.band.na .band-label::before { content: none; }

/* Decision */
.decide { justify-self: start; }
.decide button { height: 34px; padding: 0 14px; gap: 8px; display: inline-flex; align-items: center; }
.decide button::before { content: ""; width: 8px; height: 8px; border-radius: var(--radius-round); box-shadow: inset 0 0 0 1.5px var(--faint); }
.decide button[data-v="ok"][aria-pressed="true"] { color: var(--ok); }
.decide button[data-v="ok"][aria-pressed="true"]::before { background: var(--ok); box-shadow: none; }
.decide button[data-v="change"][aria-pressed="true"] { color: var(--warn); }
.decide button[data-v="change"][aria-pressed="true"]::before { background: var(--warn); box-shadow: none; }
.decide button[data-v="no"][aria-pressed="true"] { color: var(--danger); }
.decide button[data-v="no"][aria-pressed="true"]::before { background: var(--danger); box-shadow: none; border-radius: 1px; transform: rotate(45deg); }

/* Notes */
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-4); }
.note { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--space-3); }
.note-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); }
.note-author { font-weight: var(--weight-strong); color: var(--text); }
.note-acts { display: inline-flex; gap: var(--space-2); opacity: .9; }
.note .text { white-space: pre-wrap; margin-top: 2px; }
.note[data-role="doctor"] .text { color: var(--text); }
.files { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.thumb img { display: block; width: 132px; height: 96px; object-fit: cover; border-radius: var(--radius-sm); box-shadow: 0 0 0 1px var(--border); }
.file { display: inline-flex; align-items: center; gap: var(--space-2); height: var(--control-sm); padding: 0 10px 0 6px; border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--border-strong); color: var(--text); text-decoration: none; font-size: var(--step-row); max-width: 100%; }
.file:hover { background: var(--hover); }
.file-ext { padding: 2px 5px; border-radius: 4px; background: var(--selected); font-size: 10px; font-weight: var(--weight-title); text-transform: uppercase; color: var(--text-2); }

/* Composer: one quiet line until used */
.compose { display: grid; border-radius: var(--radius); box-shadow: inset 0 0 0 1px var(--border-strong); background: var(--ground); transition: box-shadow var(--motion); }
.compose:focus-within { box-shadow: inset 0 0 0 1px var(--state), 0 0 0 3px var(--state-soft); }
.compose textarea.field { border: 0; box-shadow: none; background: transparent; min-height: 46px; padding: 12px 14px 4px; }
.compose textarea.field:focus { box-shadow: none; }
.compose-bar { display: flex; align-items: center; gap: var(--space-2); padding: 4px 6px 6px; }
.compose input[type=file] { display: none; }
.picked { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hint { display: inline-flex; gap: 2px; }

/* Edit + add */
.edit { display: grid; gap: var(--space-4); }
.edit .label .field { margin-top: 6px; font-weight: 400; }
.edit .two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.add-item { margin-top: var(--space-8); }
.inline { display: flex; gap: var(--space-2); }

/* Pager */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-top: var(--space-12); }
.pager-btn { display: grid; gap: 2px; padding: var(--space-4); border: 0; border-radius: var(--radius-lg); background: var(--ground); box-shadow: inset 0 0 0 1px var(--border); color: var(--text); font: var(--weight-strong) var(--step-row)/var(--lh-row) var(--font-sans); text-align: left; cursor: pointer; transition: background-color var(--motion), box-shadow var(--motion); }
.pager-btn:hover { background: var(--hover); box-shadow: inset 0 0 0 1px var(--border-strong); }
.pager-btn.next { text-align: right; grid-column: 2; }

@media (pointer: coarse) { .desk { display: none; } }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: none; }
  .side { display: none; }
  .shell[data-menu] .side { display: flex; position: fixed; inset: 0 16% 0 0; z-index: 41; flex-direction: column; box-shadow: var(--shadow-lg); padding-top: max(16px, env(safe-area-inset-top)); animation: drawer var(--motion-settle) both; }
  .shell[data-menu] .side .nav { flex-direction: row; justify-content: flex-start; gap: var(--space-3); height: var(--tap); font-size: var(--step-row); }
  .side h3 { display: block; }
  .top .menu-btn { display: inline-flex; margin-left: -8px; }
  .main { grid-template-rows: calc(48px + env(safe-area-inset-top)) minmax(0, 1fr); }
  .top { padding-top: env(safe-area-inset-top); }
  .page { padding: var(--space-6) var(--space-4) var(--space-12); }
  .display.serif { font-size: 32px; line-height: 38px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .next { flex-direction: column; align-items: stretch; }
  .item { padding: var(--space-6) 0; }
  .item-head { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .item-body { padding-left: 0; }
  .compare, .edit .two { grid-template-columns: 1fr; }
  .side-now { border-right: 0; border-bottom: 1px solid var(--border); }
  .range { grid-template-columns: 1fr; }
  .band + .band { border-left: 0; border-top: 1px solid var(--border); }
  .band { grid-template-columns: 70px 1fr; align-items: baseline; }
  .decide { display: flex; width: 100%; }
  .decide button { flex: 1; justify-content: center; height: var(--tap); padding: 0 6px; white-space: nowrap; }
  .page-tools { flex-direction: column; align-items: stretch; }
  .page-tools .seg button { flex: 1; padding: 0 6px; }
  .online-label { display: none; }
  .dlg:not(.dlg-lb) { width: 100%; max-width: none; margin: auto 0 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92dvh; }
  .dlg:not(.dlg-lb)[open] { animation: sheet var(--motion-settle) both; }
  .dlg-body { padding: var(--space-5) var(--space-4) max(var(--space-5), env(safe-area-inset-bottom)); }
  .dlg-body::before { content: ""; justify-self: center; width: 36px; height: 4px; margin-top: -8px; border-radius: var(--radius-pill); background: var(--border-strong); }
  .dlg-actions { flex-direction: column-reverse; }
  .dlg-actions .btn { height: var(--tap); width: 100%; }
  .pager { grid-template-columns: 1fr; }
  .pager-btn.next { grid-column: 1; }
}
/* Dialog: a floating panel on the desk, a sheet on the phone */
.dlg { padding: 0; border: 0; width: min(520px, calc(100vw - 32px)); max-height: min(86dvh, 720px); border-radius: var(--radius-lg); background: var(--ground); color: var(--text); box-shadow: var(--shadow-lg); }
.dlg::backdrop { background: var(--scrim); }
.dlg[open] { animation: settle var(--motion-settle) both; }
.dlg-body { display: grid; gap: var(--space-4); padding: var(--space-6); }
.dlg-body h2.serif { font-size: 22px; line-height: 1.25; }
.dlg-text { color: var(--text-2); }
.dlg .label .field { margin-top: 6px; font-weight: 400; }
.dlg textarea.field { min-height: 140px; max-height: 50dvh; }
.dlg-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.btn.danger-solid { background: var(--danger); color: var(--on-solid); }
.btn.danger-solid:hover { filter: brightness(1.08); }
:root[data-theme="dark"] .btn.danger-solid { color: var(--ground); }
.dlg-lb { width: min(1100px, calc(100vw - 32px)); max-height: 92dvh; overflow: hidden; }
.lb { display: grid; grid-template-rows: minmax(0, 1fr) auto; max-height: 92dvh; }
.lb img { display: block; width: 100%; max-height: calc(92dvh - 56px); object-fit: contain; background: var(--panel); }
.lb-bar { display: flex; align-items: center; gap: var(--space-2); padding: 8px 8px 8px 16px; border-top: 1px solid var(--border); }
.lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--step-row); }
.lb-bar form { margin: 0; }

@keyframes drawer { from { transform: translateX(-12px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .shell[data-menu] .side { animation: none; } }
@keyframes sheet { from { transform: translateY(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .dlg[open] { animation: none !important; } }
