/* Compose, simple version (views/composer.js): a list of cards, one "Add element" button, one question per sheet.
   Uses the brand tokens of brand.css only. Phone first: big targets (min 52px), sheets cover the screen. */

.cz { max-width: 720px; margin: 0 auto; display: grid; gap: 12px; padding-bottom: 96px; }

/* header: apparatus, title + D, check line */
.cz-head { display: grid; gap: 14px; padding-top: 8px; }
.cz-apps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.cz-apps button { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 6px; border: 1.5px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; }
.cz-apps button[aria-checked="true"] { background: var(--deep); border-color: var(--deep); color: var(--on-deep); }
.cz-app-art svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; display: block; }
.cz-app-art svg .thin { stroke-width: 1.6; opacity: .6; }
.cz-titlerow { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.cz-title { margin: 0; font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--display-tracking); font-size: calc(clamp(34px, 6vw, 52px) * var(--display-scale)); line-height: .98; text-wrap: balance; min-width: 0; }
.cz-d { display: grid; justify-items: end; flex: none; }
.cz-k { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cz-dn { font-family: var(--font-display); font-weight: 900; font-size: calc(44px * var(--display-scale)); line-height: 1; color: var(--ink); }
.cz-subrow { display: flex; align-items: center; gap: 12px; min-height: 44px; border-bottom: 2px solid var(--ink); padding-bottom: 8px; }
.cz-check { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 10px 0 8px; border: 0; border-radius: var(--radius-s); background: var(--sunk); color: var(--ink); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.cz-check[hidden] { display: none; }
.cz-check svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.cz-check[data-ok="true"] { color: var(--ok); background: transparent; padding-left: 0; cursor: default; }
.cz-check[data-ok="false"] svg:first-child { color: var(--bad); }
.cz-saved { color: var(--muted); font-size: 13px; margin-left: auto; }
.cz-saved[data-state="error"], .cz-saved[data-state="memory"] { color: var(--bad); font-weight: 700; }
.cz-more { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 8px; border: 0; background: none; color: var(--accent-text); font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; }
.cz-more svg { width: 20px; height: 20px; fill: currentColor; }

/* routine cards */
.cz-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cz-card { width: 100%; display: grid; grid-template-columns: 26px 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 14px 10px 8px; border: 1.5px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.cz-card:hover { border-color: var(--primary); }
.cz-card.is-static { cursor: default; grid-template-columns: 26px 44px minmax(0, 1fr); }
.cz-card.is-static:hover { border-color: var(--line); }
.cz-card.is-new { animation: cz-new .9s ease; }
.cz-card.is-flash { animation: cz-new .9s ease; }
@keyframes cz-new { from { background: color-mix(in srgb, var(--hi) 35%, var(--surface)); border-color: var(--hi); } to { background: var(--surface); } }
.cz-n { font-family: var(--font-display); font-weight: 800; font-size: 20px; color: var(--muted); text-align: center; }
.cz-art { width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--radius-s); background: var(--carpet); color: #fff; padding: 5px; flex: none; }
.cz-art svg { width: 100%; height: 100%; }
.cz-R .cz-art { background: var(--hi); color: var(--on-hi); --pose-app: var(--on-hi); }
.cz-DA .cz-art, .cz-NOTE .cz-art { background: var(--surface); color: var(--accent-text); box-shadow: inset 0 0 0 1.5px var(--line); }
.cz-art .app-art svg, .cz-art > svg[viewBox="0 0 32 32"] { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.cz-art .app-art { display: block; width: 100%; height: 100%; }
.cz-art .app-art svg .thin { stroke-width: 1.6; opacity: .6; }
.cz-t { min-width: 0; display: grid; gap: 2px; }
.cz-t b { font-weight: 600; line-height: 1.25; }
.cz-t small { color: var(--muted); font-size: 13px; line-height: 1.3; }
.cz-t em { font-style: normal; color: var(--bad); font-size: 13px; line-height: 1.3; }
.cz-t .cz-note { font-style: italic; }
.cz-v { font-family: var(--font-display); font-weight: 900; font-size: 26px; line-height: 1; }
.cz-card.is-zero .cz-v { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 2px; }
.cz-tip { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.cz-tip[hidden] { display: none; }

/* empty */
.cz-empty { display: grid; gap: 10px; padding: 16px 0 8px; }
.cz-empty-h { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: calc(28px * var(--display-scale)); line-height: 1.05; text-wrap: balance; max-width: 22ch; }
.cz-empty p { margin: 0; color: var(--muted); max-width: 52ch; }
.cz-tpls { display: grid; gap: 6px; margin-top: 12px; }
.cz-tpl { display: grid; gap: 2px; padding: 12px 14px; border: 1.5px dashed var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.cz-tpl:hover { border-color: var(--primary); }
.cz-tpl small { color: var(--muted); font-size: 13px; }

/* bottom bar: Add element (+ Send on the entry page) */
.cz-bar { position: sticky; bottom: 0; z-index: 30; display: flex; gap: 8px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); margin-top: 8px; }
.cz-bar .btn { min-height: 56px; font-size: 17px; }
.cz-add { flex: 1; }
.cz-send { flex: none; min-width: 120px; }

/* entry page: other apparatus */
.cz-others { margin-top: 28px; padding-top: 20px; border-top: 2px solid var(--ink); display: grid; gap: 10px; }
.cz-others h2, .cz-others p { margin: 0; }
.cz-others p { max-width: 52ch; }
.cz-others-apps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.cz-others-apps button { display: grid; justify-items: center; gap: 2px; padding: 12px 4px; min-height: 92px; border: 1.5px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.cz-others-apps svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; }
.cz-others-apps svg .thin { stroke-width: 1.6; opacity: .6; }
.cz-others-apps small { color: var(--muted); font-size: 12px; text-align: center; }
.cz-others-apps [aria-current="true"] { border-color: var(--primary); box-shadow: inset 0 0 0 1.5px var(--primary); }

/* ---------- sheets ---------- */
.cz-scrim { position: fixed; inset: 0; z-index: 80; background: var(--scrim); }
.cz-sheet { position: fixed; z-index: 81; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 32px)); max-height: min(860px, calc(100vh - 48px)); display: flex; flex-direction: column; background: var(--surface); color: var(--ink); border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: 0 30px 80px -20px var(--scrim); animation: cz-in .2s ease; }
@keyframes cz-in { from { opacity: 0; transform: translate(-50%, calc(-50% + 16px)); } }
.cz-s-top { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 8px 14px 8px 6px; border-bottom: 1px solid var(--line); }
.cz-x { width: 48px; height: 48px; display: grid; place-items: center; border: 0; background: none; color: var(--ink); cursor: pointer; border-radius: var(--radius-s); }
.cz-x svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.cz-s-st { font-size: 13px; color: var(--muted); min-width: 0; }
.cz-s-st b { display: block; color: var(--ink); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cz-s-v { font-family: var(--font-display); font-weight: 900; font-size: 32px; line-height: 1; }
.cz-prog { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 4px; padding: 10px 16px 0; }
.cz-prog i { height: 4px; background: var(--line); }
.cz-prog i.on { background: var(--primary); }
.cz-s-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px; display: grid; align-content: start; gap: 12px; }
.cz-q { margin: 2px 0 0; font-family: var(--font-display); font-weight: 800; font-size: calc(32px * var(--display-scale)); line-height: 1.02; text-wrap: balance; outline: none; }
.cz-qh { margin: 0; color: var(--muted); font-size: 15px; max-width: 56ch; }
.cz-state { color: var(--ink); }
.cz-state[data-ok="true"] { color: var(--ok); }
.cz-s-bar { display: grid; grid-template-columns: auto 1fr; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.cz-s-bar .btn { min-height: 56px; font-size: 17px; }

.cz-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.cz-tiles.one { grid-template-columns: minmax(0, 1fr); }
.cz-tile { position: relative; display: grid; align-content: start; gap: 4px; min-height: 64px; padding: 12px 34px 12px 12px; border: 1.5px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.cz-tile:hover { border-color: var(--ink); }
.cz-tile b { font-weight: 600; line-height: 1.25; }
.cz-tile small { color: var(--muted); font-size: 13px; line-height: 1.3; }
.cz-plus { color: var(--accent-text); font-weight: 700; font-size: 13px; }
.cz-tile[aria-pressed="true"] { border-color: var(--primary); box-shadow: inset 0 0 0 1.5px var(--primary); background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
.cz-tile[aria-pressed="true"]::after { content: ""; position: absolute; top: 13px; right: 12px; width: 16px; height: 16px; background: var(--primary); clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 22%, 86% 8%, 38% 72%); }
.cz-big { grid-template-columns: 52px minmax(0, 1fr); align-items: center; gap: 14px; min-height: 76px; align-content: center; }
.cz-big .cz-art { width: 52px; height: 52px; }
.cz-big b { font-size: 18px; display: block; }
.cz-big small { display: block; }
.cz-tile.cz-big[data-what="R"] .cz-art { background: var(--hi); color: var(--on-hi); --pose-app: var(--on-hi); }
.cz-tile.cz-big[data-what="DA"] .cz-art, .cz-tile.cz-big[data-what="NOTE"] .cz-art { background: var(--surface); color: var(--accent-text); box-shadow: inset 0 0 0 1.5px var(--line); }

.cz-nums { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.cz-nums button { min-height: 64px; border: 1.5px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font-family: var(--font-display); font-weight: 900; font-size: 30px; cursor: pointer; font-variant-numeric: tabular-nums; }
.cz-nums button:hover { border-color: var(--ink); }
.cz-nums button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.cz-fou { display: flex; flex-wrap: wrap; gap: 6px; }
.cz-fou button { min-width: 64px; min-height: 52px; border: 1.5px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; font-variant-numeric: tabular-nums; }
.cz-fou button.is-on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.cz-stepper { display: flex; align-items: center; gap: 12px; }
.cz-stepper button { width: 52px; height: 52px; border: 1.5px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font-size: 26px; font-weight: 700; cursor: pointer; }
.cz-stepper button:disabled { opacity: .4; cursor: default; }
.cz-stepper output { font-family: var(--font-display); font-weight: 900; font-size: 36px; min-width: 2ch; text-align: center; }
.cz-stepper span { color: var(--muted); }

.cz-search { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 12px; border: 2px solid var(--ink); border-radius: var(--radius-s); background: var(--surface); }
.cz-search:focus-within { box-shadow: 0 0 0 3px var(--signal); }
.cz-search svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2.2; }
.cz-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; font-size: 17px; }
.cz-sec { margin: 6px 0 0; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cz-pick { list-style: none; margin: 0; padding: 0; display: grid; }
.cz-pick button { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 56px; padding: 10px 4px; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.cz-pick button:hover { background: var(--sunk); }
.cz-pick button[aria-current="true"] { box-shadow: inset 4px 0 0 var(--primary); padding-left: 12px; }
.cz-pick b { display: block; font-weight: 600; line-height: 1.25; }
.cz-pick small { color: var(--muted); font-size: 13px; }
.cz-pv { font-family: var(--font-display); font-weight: 900; font-size: 22px; }
.cz-none { color: var(--muted); padding: 12px 0; }

.cz-write { display: grid; gap: 6px; }
.cz-write [hidden] { display: none; }
.cz-write > div { display: grid; gap: 6px; }
.cz-write label { font-weight: 600; font-size: 15px; }
.cz-write textarea, .cz-input { width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; }
.cz-write textarea { resize: vertical; min-height: 64px; }
.cz-write textarea:focus, .cz-input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--signal); }
.cz-link { justify-self: start; min-height: 40px; padding: 0; border: 0; background: none; color: var(--accent-text); font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.cz-link[hidden] { display: none; }
.cz-wide { width: 100%; min-height: 52px; }

.cz-sum { display: grid; gap: 6px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--radius-s); }
.cz-sum > div { display: flex; justify-content: space-between; gap: 12px; }
.cz-sum-tot { border-top: 2px solid var(--ink); padding-top: 8px; margin-top: 2px; }
.cz-adv { border-top: 1px solid var(--line); padding-top: 8px; }
.cz-adv summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; color: var(--accent-text); }
.cz-adv[open] { display: grid; gap: 10px; }

.cz-acts { display: grid; gap: 8px; }
.cz-acts .btn { min-height: 52px; width: 100%; }
.cz-acts .cz-sec { margin-top: 10px; }
.cz-two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cz-del { color: var(--bad); }
.cz-field { display: grid; gap: 6px; }
.cz-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cz-seg button { min-height: 48px; border: 1.5px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.cz-seg button[aria-checked="true"] { background: var(--deep); border-color: var(--deep); color: var(--on-deep); }
.cz-eq { display: flex; flex-wrap: wrap; gap: 16px; color: var(--muted); }
.cz-eq b { color: var(--ink); font-size: 18px; }
.cz-warns { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cz-warns li > * { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; align-items: start; width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font: inherit; text-align: left; }
.cz-warns button { cursor: pointer; }
.cz-warns button:hover { border-color: var(--ink); }
.cz-warns svg { width: 20px; height: 20px; fill: none; stroke: var(--bad); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.cz button:focus-visible, .cz input:focus-visible, .cz summary:focus-visible, .cz label.btn:focus-within { outline: 3px solid var(--signal); outline-offset: 2px; }

/* toasts above the Add element bar */
body[data-route="composer"] .toast-region { bottom: 104px; }

@media (max-width: 900px) {
  body[data-route="composer"] main { padding-bottom: 24px; }
  .cz { padding-bottom: 0; }
  /* the bar sits on top of the tab bar of the app; the entry page has no tab bar */
  .cz-bar { position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); padding: 10px max(16px, env(safe-area-inset-left)) 10px max(16px, env(safe-area-inset-right)); margin: 0; }
  body.entry .cz-bar { bottom: 0; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .cz-list, .cz-empty, .cz-tip { scroll-margin-bottom: 160px; }
  .cz-tip { margin-bottom: 150px; }
  body.entry .cz-tip { margin-bottom: 0; }
  body.entry .cz { padding-bottom: 96px; }
  body[data-route="composer"] .toast-region { bottom: calc(144px + env(safe-area-inset-bottom)); }
  body.entry .toast-region { bottom: calc(92px + env(safe-area-inset-bottom)); }
  /* sheets fill the screen on a phone */
  .cz-sheet { left: 0; top: 0; right: 0; bottom: 0; transform: none; width: auto; max-height: none; border: 0; border-radius: 0; animation: cz-up .22s ease; padding-top: env(safe-area-inset-top); }
  @keyframes cz-up { from { opacity: 0; transform: translateY(24px); } }
  .cz-title { font-size: calc(34px * var(--display-scale)); }
  .cz-dn { font-size: calc(38px * var(--display-scale)); }
  .cz-apps button { font-size: 14px; gap: 4px; }
}
@media (max-width: 380px) {
  .cz-apps .cz-app-art { display: none; }
  .cz-tiles { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .cz-sheet, .cz-card.is-new, .cz-card.is-flash { animation: none; }
}
/* the app's top bar already shows the save state; the entry page hides it */
body:not(.entry) .cz-saved:not([data-state="error"]):not([data-state="memory"]) { visibility: hidden; }
.cz-nums.cz-nums7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cz-nums.cz-nums7 button { font-size: 26px; }
.cz-photo { margin-top: 8px; border-style: dashed; }
.cz-sheets { display: flex; gap: 10px; align-items: center; margin: 0; padding: 10px 12px; background: var(--sunk); border-radius: var(--radius-s); font-size: 14px; }
.cz-sheets[hidden] { display: none; }
.cz-sheets svg, .cz-tile .cz-art > svg[viewBox="0 0 32 32"] { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.cz-err { color: var(--bad); }
label.cz-tile { cursor: pointer; }
.cz-sheet a.btn { min-height: 56px; }
.cz-adv .cz-k { margin: 16px 0 8px; }
/* "Not sure of the name?" shape filters */
.cz-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cz-chip { min-height: 44px; padding: 8px 14px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.cz-chip:hover { border-color: var(--ink); }
.cz-chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
