/* Compact layout: phones are narrow, so spacing is tight and tap targets stay ≥ 40px. */
:root {
  --bg: #f5f6f8; --card: #fff; --text: #1d2330; --muted: #5d6677; --accent: #2459c4; --accent-dark: #1a449a;
  --ok: #18794e; --ok-bg: #e5f5ec; --warn: #8a5a00; --warn-bg: #fff4d6; --err: #b42318; --err-bg: #fde8e7;
  --border: #d5d9e0; --rail: 2.1rem; --down: #b42318; --up: #18794e;
}
html { font-size: 100%; }
html.ts-125 { font-size: 125%; }
html.ts-150 { font-size: 150%; }
html.ts-175 { font-size: 175%; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: .95rem/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
main { max-width: 640px; margin: 0 auto; padding: 4px 6px 40px; }
body.admin main { max-width: 1000px; padding: 6px 10px 40px; }
a { color: var(--accent); }
h1 { font-size: 1.15rem; margin: 6px 0 4px; }
h2 { font-size: 1rem; margin: 10px 0 4px; }
h3 { font-size: .95rem; margin: 8px 0 4px; }
h2.inline { display: inline; }
p { margin: 4px 0; }
small { font-weight: normal; }
.muted { color: var(--muted); font-size: .85rem; }

/* ----- Header ----- */
.top { display: flex; align-items: center; gap: 6px; padding: 3px 6px; background: #fff; border-bottom: 1px solid var(--border); font-size: .85rem; }
.top nav { display: flex; gap: 10px; align-items: center; margin-left: auto; flex-wrap: wrap; }
.brand { font-weight: 800; text-decoration: none; color: var(--text); }
/* The owner's wordmark (ask 95 a). 22 px tall in the top bar and 48 px on Log In: set by hand; the owner is judging
   the 22 px size. Images: wordmark-bar.png (66 px tall) and wordmark.png (144 px), cropped copies of his file. */
.brand img { display: block; height: 22px; width: auto; }
.signin-mark { display: block; height: 48px; width: auto; margin: 14px 0 6px; }
.devtag { font-size: .65rem; font-weight: 800; color: var(--warn); background: var(--warn-bg); border-radius: 4px; padding: 0 4px; }
.crumbs { margin: 2px 0 0; font-size: .8rem; }

/* ----- Client strip (top) ----- */
.client-strip { display: flex; gap: 3px; overflow-x: auto; padding: 3px 4px 0; background: #e9edf4; border-bottom: 2px solid var(--accent); position: sticky; top: 0; z-index: 6; scrollbar-width: none; }
.client-strip::-webkit-scrollbar { display: none; }
.client-strip a { flex: 0 0 auto; padding: 5px 10px; font-weight: 800; font-size: .9rem; text-decoration: none; color: var(--text); background: #fff; border: 1px solid var(--border); border-bottom: 0; border-radius: 8px 8px 0 0; }
.client-strip a.active { font-size: 1.35rem; padding: 2px 14px; letter-spacing: .04em; background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }

/* ----- Goal tabs (right side, text turned 90° clockwise, scrolls) ----- */
.goal-tabs { position: fixed; right: 0; top: 0; bottom: 0; width: var(--rail); padding: 2px 0 16px; background: #dfe4ec; border-left: 2px solid var(--accent); display: flex; flex-direction: column; gap: 2px; overflow-y: auto; overscroll-behavior: contain; z-index: 7; scrollbar-width: none; }
.goal-tabs::-webkit-scrollbar { display: none; }
.goal-tabs a { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; padding: .55rem 0; margin-right: 3px; text-decoration: none; color: var(--text); font-weight: 700; font-size: .78rem; border-radius: 0 7px 7px 0; background: #fff; border: 1px solid var(--border); border-left: 0; }
.goal-tabs a.active { margin-right: 0; }
.goal-tabs a span { writing-mode: vertical-rl; white-space: nowrap; }
.goal-tabs a.active { outline: 3px solid var(--accent); outline-offset: -3px; font-weight: 900; }
body.has-goal-tabs { padding-right: var(--rail); }

/* ----- Cards, forms, buttons ----- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin: 6px 0; }
.narrow { max-width: 360px; }
label { display: block; font-weight: 600; margin: 5px 0; font-size: .92rem; }
label.check, label.pill { font-weight: 500; }
input, select, textarea { width: 100%; font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: inherit; min-height: 38px; margin-top: 2px; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; margin: 0 5px 0 0; }
input[type=color] { padding: 2px; width: 60px; }
textarea { min-height: 60px; resize: vertical; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 4px 6px; margin: 6px 0; }
legend { font-weight: 700; padding: 0 3px; font-size: .9rem; }
button, .button { display: inline-block; font: inherit; font-weight: 600; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; text-decoration: none; min-height: 40px; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.big { width: 100%; padding: 10px; font-size: 1rem; margin-top: 6px; }
button.huge { width: 100%; padding: 26px 0; font-size: 2.2rem; border-radius: 14px; }
button.link { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent); font-weight: 500; text-decoration: underline; }
button.danger { color: var(--err); border-color: #f4b4ae; }
form.inline { display: inline; }
.flash { padding: 6px 8px; border-radius: 8px; margin: 4px 0; font-size: .9rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--err); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }

/* ----- Dashboard / lists ----- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.tile { display: block; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px 6px; text-align: center; font-size: 1.15rem; font-weight: 800; text-decoration: none; color: var(--text); }
.tile small { display: block; font-size: .75rem; color: var(--muted); font-weight: 500; }
.dash { display: grid; gap: 6px; }
.dash-card { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 8px; text-decoration: none; color: var(--text); }
.dash-initials { font-size: 1.35rem; font-weight: 800; min-width: 3.2em; text-align: center; background: #eef1f6; border-radius: 8px; padding: 6px 4px; }
.dash-stats { color: var(--muted); font-size: .85rem; }
.behind { color: var(--warn); }
.goal-list { list-style: none; padding: 0; margin: 0; }
.goal-list a { display: flex; justify-content: space-between; gap: 6px; padding: 9px 8px; background: #fff; border: 1px solid var(--border); border-radius: 8px; margin: 4px 0; text-decoration: none; color: var(--text); }
.goal-name { font-weight: 700; }
.tally { color: var(--muted); font-size: .82rem; white-space: nowrap; }

/* ----- Goal page ----- */
.question { font-size: .98rem; font-weight: 600; }
details.info { background: #fff; border: 1px solid var(--border); border-radius: 8px; margin: 3px 0; }
details.info summary { padding: 6px 8px; font-weight: 700; cursor: pointer; font-size: .92rem; }
.info-body { padding: 0 8px 4px; font-size: .92rem; }
.info-body ul { margin: 2px 0; padding-left: 18px; }
.ack { border-color: #f0d58a; background: var(--warn-bg); }
.count-today { text-align: center; font-size: 1rem; font-weight: 700; margin: 0 0 4px; }
.btn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 6px; }
.btn-grid button small, .score small { display: block; font-weight: 400; font-size: .78rem; }
.score-list { display: grid; gap: 5px; }
.score { text-align: left; padding: 6px 10px; }
.score.independent { border-color: var(--ok); background: var(--ok-bg); }
.score b { display: inline-block; min-width: 1.5em; }
.steps { padding-left: 16px; margin: 4px 0; }
.steps li { margin: 6px 0; }
.step-text { margin: 0; font-weight: 600; }
.reminder { margin: 1px 0 3px; color: var(--warn); font-size: .85rem; }
.seg { display: flex; flex-wrap: wrap; gap: 3px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: inline-block; min-width: 33px; text-align: center; padding: 8px 3px; border: 1px solid var(--border); border-radius: 6px; font-weight: 700; }
.seg input:checked + span { background: var(--accent); color: #fff; border-color: var(--accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
label.pill { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 999px; padding: 5px 9px; margin: 2px 2px 2px 0; background: #fff; font-size: .9rem; }
.issues { background: var(--warn-bg); border: 1px solid #f0d58a; border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; }
.issues.has-block { background: var(--err-bg); border-color: #f4b4ae; }
.issues ul { margin: 2px 0; padding-left: 18px; }
.timer { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.clock { font-size: 1.6rem; font-variant-numeric: tabular-nums; font-weight: 800; min-width: 4.5ch; }
details.earlier, details.key { margin-top: 6px; font-size: .9rem; }
.entries { list-style: none; padding: 0; margin: 2px 0; }
.entries li { display: grid; grid-template-columns: 4.2em 1fr auto auto; gap: 6px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.entries li.muted { display: block; }
.entries li.void .what { text-decoration: line-through; color: var(--muted); }
.who { color: var(--muted); font-size: .8rem; }
.badge { background: #eee; border-radius: 5px; padding: 0 5px; font-size: .75rem; }
.history { padding-left: 18px; }
.history li { margin: 5px 0; font-size: .9rem; }
.eos-item { border-top: 1px solid var(--border); padding: 5px 0; }

/* ----- Admin ----- */
.row-form { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: end; }
.row-form > label { flex: 1 1 150px; }
.row2 { display: flex; flex-wrap: wrap; gap: 0 6px; }
.row2 > label { flex: 1 1 13rem; min-width: 0; }
input, select, textarea { min-width: 0; max-width: 100%; }
table.grid { width: 100%; border-collapse: collapse; background: #fff; font-size: .9rem; }
table.grid th, table.grid td { border-bottom: 1px solid var(--border); padding: 4px 6px; text-align: left; vertical-align: top; }
tr.inactive, tr.void { color: var(--muted); }
.adminnav { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 4px 0; font-size: .88rem; }
.field-block { margin: 6px 0; }
.field-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .9rem; }
.field-head input:not([type]) { flex: 1; }
.type-opts { border-top: 1px dashed var(--border); margin-top: 8px; padding-top: 2px; }
ul.plain { padding-left: 18px; margin: 4px 0; }
code { background: #eef1f6; padding: 0 3px; border-radius: 3px; }
.records-table td, .records-table th { font-size: .85rem; }

/* ----- Print ----- */
@media print {
  .top, .client-strip, .goal-tabs, .adminnav, .no-print, .flash { display: none !important; }
  body.has-goal-tabs { padding-right: 0; }
  main { margin: 0; padding: 0; max-width: none; }
  body { background: #fff; font-size: 10.5pt; }
  .card { border: 0; padding: 0; }
  tr { page-break-inside: avoid; }
  a { color: #000; text-decoration: none; }
}

/* ----- Categories: Behavior Reduction (goal: down) / Adaptive Living (goal: up) ----- */
.cat-head { display: flex; align-items: baseline; gap: .4em; margin: .7rem 0 .2rem; }
.cat-head .muted { font-weight: 500; }
.goal-title { display: flex; align-items: baseline; gap: .35em; flex-wrap: wrap; }
.goal-title .edit-link { margin-left: auto; font-size: .8rem; font-weight: 500; }

/* ----- Information sections: Short Form when collapsed, Long Form when opened ----- */
details.info .short { display: block; font-weight: 400; margin-top: 2px; }
details.info[open] .short { display: none; }
div.info { background: #fff; border: 1px solid var(--border); border-radius: 8px; margin: 3px 0; padding: 0 0 2px; }
.info-name { margin: 0; padding: 6px 8px 0; font-size: .92rem; }
.quick-edit { margin: 2px 8px 6px; font-size: .85rem; }
.quick-edit summary { color: var(--accent); cursor: pointer; }

/* ----- Data fields: question directly above the answer ----- */
.dfield { margin: .5rem 0; }
.q, label.q { font-weight: 700; font-size: 1rem; margin: .3rem 0 .2rem; }
.textsize { font-weight: 800; text-decoration: none !important; }
.textsize big { font-size: 1.25em; }
.narrowfield { flex: 0 0 5.5em !important; }
.sec-row, .fld-row { background: #fafbfc; }
.savebar { position: sticky; bottom: 0; background: var(--bg); padding: 4px 0; }

/* ----- Privacy reminder under every free-text box ----- */
/* Hidden until someone is typing in the box right above it. */
.phi-note { display: none; margin: 2px 0 6px; padding: 3px 8px; font-size: .82rem; font-weight: 600; color: var(--err); background: var(--err-bg); border-radius: 6px; }

/* ----- ABC ----- */
legend .explain { font-weight: 500; color: var(--muted); }
label.other { margin-top: 6px; }

/* ----- Number + stopwatch on one row ----- */
.num-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.num-row input { flex: 1 1 6em; width: auto; }
.num-row .timer { margin: 0; }
.num-row .clock { font-size: 1.25rem; }
.sw-start { white-space: nowrap; }

label:focus-within + .phi-note, .other-box:focus-within .phi-note { display: block; }

/* "Other": its text box appears only after the Other chip is ticked. */
.other-box { display: none; margin-top: 4px; }
fieldset:has(.other-toggle:checked) .other-box { display: block; }

/* ----- Carets: one style everywhere. Collapsed points right (at the text); open points down. ----- */
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; display: inline-block; width: 1em; color: var(--muted); font-weight: 700; }
details[open] > summary::before { content: "▾"; }
details.info > summary { padding-left: .5rem; }
details.info .short { margin-left: 1em; }

/* ----- Goal tabs: the current one is wider, larger and outlined; no arrows. ----- */
:root { --rail: 2.5rem; }
.goal-tabs { background: #e9edf4; }
.goal-tabs a { margin-left: .45rem; margin-right: 0; }
.goal-tabs a.active {
  margin-left: 0; padding: 1rem 0; font-size: .92rem; font-weight: 900;
  outline: none; border: 3px solid var(--accent); border-left: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}
.goal-tabs a.active { box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }

/* Header: keep the brand on one line; let the links wrap neatly to the right. */
.brand, .devtag { white-space: nowrap; flex: 0 0 auto; }
.top nav { gap: 4px 10px; justify-content: flex-end; }
.top nav a, .top nav button { white-space: nowrap; }

/* ----- Admin: Homes & Clients, Goal Bank ----- */
.home-block > summary { font-size: 1.05rem; padding: 2px 0; }
.client-rows { list-style: none; padding: 0; margin: 6px 0; }
.client-rows li { display: flex; gap: 10px; align-items: baseline; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.client-rows li.inactive { opacity: .6; }
details.sub { margin: 6px 0; }
.add-to-client { display: flex; flex-wrap: wrap; gap: 4px; }
.add-to-client select { width: auto; min-width: 7em; }
option.taken, select option:disabled { color: #9aa1ad; }

/* ----- Goal page links (All Goal Information, resource pages) ----- */
.goal-links { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: .85rem; margin: 0 0 4px; }
.isp-section { margin: 8px 0; }
.isp-section h2 { margin-bottom: 2px; }

/* ----- Owner Edit Mode ----- */
.editmode.on { color: #fff; background: var(--warn); border-radius: 6px; padding: 0 6px; text-decoration: none; }
.owner-box { border: 1px dashed var(--warn); border-radius: 8px; padding: 4px 8px; background: #fffaf0; }
.fld-quick { border-top: 1px solid var(--border); padding-top: 4px; margin-top: 4px; }
.push-right { margin-left: auto; }
button.small { padding: 3px 8px; min-height: 0; font-size: .85rem; }

/* ----- Add Goals on the client page ----- */
.bank-pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 2px 10px; margin: 4px 0; }
.bank-pick { font-weight: 500; display: flex; align-items: center; gap: 4px; padding: 3px 0; }
.bank-pick.has-it { color: var(--muted); }

/* ----- Data Sheet preview: a phone-width look at what staff see ----- */
.phone-preview { max-width: 360px; border: 8px solid #2b2f36; border-radius: 22px; padding: 6px; background: var(--bg); }
.preview-lock { border: 0; padding: 0; margin: 0; }
.preview-lock[disabled] button, .preview-lock[disabled] input { opacity: 1; cursor: default; }

/* Date and time pickers with a Now button */
.time-row { display: flex; gap: 6px; align-items: center; }
.time-row input[type=time] { flex: 1 1 8em; width: auto; min-width: 0; font-size: 1.15rem; }
.time-row input[type=date] { flex: 1 1 9em; width: auto; min-width: 0; font-size: 1.15rem; }
.time-row .now-btn { flex: 0 0 auto; }

/* Rich-text editor (owner text staff read) */
.rt-wrap { border: 1px solid var(--line, #c9ced6); border-radius: 8px; background: #fff; margin-top: 4px; }
.rt-dock { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 2px; padding: 2px 4px; margin: 2px 0 4px; background: #f6f7f9; border: 1px solid #c9ced6; border-radius: 8px; }
.rt-dock[hidden], .rt-dock button[hidden] { display: none; }
.rt-dock button { flex: 0 0 auto; min-width: 40px; min-height: 40px; padding: 0 8px; font-size: 1.05rem; line-height: 1; border-radius: 6px; background: transparent; border: 1px solid transparent; color: inherit; font-weight: normal; display: inline-flex; align-items: center; justify-content: center; }
.rt-dock button[aria-pressed="true"] { background: #dfe7fb; border-color: #9fb5ef; }
.rt-dock .rt-gap { margin-right: 8px; }
.rt-dock .rt-b { font-weight: 700; }
.rt-dock .rt-i { font-style: italic; font-family: Georgia, serif; }
.rt-dock .rt-u { text-decoration: underline; }
.rt-dock .rt-s { text-decoration: line-through; }
.rt-box { padding: 6px 8px; min-height: 1.6em; outline: none; font-weight: normal; overflow-wrap: anywhere; }
.rt-block .rt-box { min-height: 5em; }
.rt-box:empty::before { content: attr(data-placeholder); color: #8a929c; }
.rt-box p { margin: 0 0 0.5em; }
.rt-wrap:focus-within { border-color: #1d4ed8; box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.15); }
mark { background: #fff1a8; color: inherit; padding: 0 1px; }

/* Admin > Staff: homes and which clients */
.home-access { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 0; border-bottom: 1px solid #eef0f3; }
.home-access:last-child { border-bottom: none; }
.access-choice { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.access-choice .check { margin: 0; }

/* Goal editor: numbered steps, folded sections and questions */
.step h2 { display: flex; align-items: center; gap: 8px; }
.step-n { display: inline-flex; align-items: center; justify-content: center; width: 1.6em; height: 1.6em; border-radius: 50%;
  background: #1d4ed8; color: #fff; font-size: 0.85em; flex: 0 0 auto; }
details.sec-row, details.fld-row { border: 1px solid #e3e6ea; border-radius: 8px; margin: 6px 0; padding: 0 10px; background: #fafbfc; }
details.sec-row > summary, details.fld-row > summary { cursor: pointer; padding: 8px 0; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
details.sec-row[open], details.fld-row[open] { padding-bottom: 10px; background: #fff; }
.preview { color: #5b6470; font-weight: normal; flex: 1 1 14em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 0.8em; background: #eef1f5; color: #3d4652; border-radius: 10px; padding: 0 8px; white-space: nowrap; }
details.more { margin: 8px 0 0; }
details.more > summary { cursor: pointer; color: #1d4ed8; font-size: 0.95em; padding: 4px 0; }
details.card.extra > summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
details.card.extra > summary h2 { margin: 0; }
.add-row { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: flex-end; margin-top: 10px; padding-top: 8px; border-top: 1px dashed #d5d9df; }
.add-row label { flex: 1 1 12em; margin: 0; }
details.tips > summary { cursor: pointer; color: #1d4ed8; font-size: 0.95em; }

.sec-opts { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 8px; }
.sec-opts fieldset { flex: 1 1 18em; margin: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.row-actions .danger { margin-left: auto; }
details.info .short p, details.info .short ul, details.info .short ol { margin: 0; }

.link-list { list-style: none; padding: 0; margin: 6px 0; }
.link-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 0; border-bottom: 1px solid #eef0f3; }
.link-list li .danger { margin-left: auto; }

/* Pressing Enter in a box saves (the first button in the form), never moves or removes. */
.enter-saves { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; padding: 0; }

/* Data sheet editor: choices and steps as rows */
fieldset.rows { margin: 10px 0; }
.item-row { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: flex-end; padding: 6px 0; border-bottom: 1px solid #eef0f3; }
.item-row .grow { flex: 2 1 14em; margin: 0; }
.item-row .code { flex: 0 0 5.5em; margin: 0; }
.item-row label { margin: 0; }
.item-row.new-row { background: #f6f8fb; border-radius: 6px; padding: 6px; }
.row-n { flex: 0 0 auto; font-weight: 600; color: #5b6470; min-width: 2em; padding-bottom: 8px; }
.row-actions.small { display: flex; gap: 4px; margin: 0 0 4px; }
.row-actions.small button { padding: 2px 8px; min-height: 0; font-size: 0.85rem; }
