/* Tallyrow app screens, on top of the Schlosser Studio kit and the site palette (/assets/style.css).
   One bright thing: the yarn strip. One accent: cochineal. No gradients, no shadows, no emoji.
   Every target is at least 48 x 48 px with 8 px between neighbors (DESIGN.md section 3). */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body.app { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
body.app main { outline: none; }

/* ---------- shared buttons and fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; box-sizing: border-box; min-height: 52px; min-width: 48px;
  padding: .6rem 1.25rem; border: 2px solid var(--ss-accent); border-radius: var(--ss-radius); background: var(--ss-accent); color: var(--ss-accent-ink);
  font: 600 1rem/1.2 var(--ss-font); text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.btn:hover { filter: brightness(1.08); }
.btn--ghost { background: transparent; border-color: var(--ss-line); color: var(--ss-ink); }
.btn--ghost:hover { background: var(--ss-accent-soft); filter: none; border-color: var(--ss-accent); }
.btn--danger { background: transparent; border-color: var(--ss-accent); color: var(--ss-link); }
.btn[aria-disabled="true"], .btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; padding: 0; border: 0; border-radius: var(--ss-radius);
  background: transparent; color: var(--ss-ink); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.icon-btn:hover { background: var(--ss-accent-soft); }
.ic { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.field { display: grid; gap: 6px; margin: 0 0 18px; }
.field label, .field .field__label { font-weight: 600; }
.field input[type="text"], .field input[type="search"] { width: 100%; box-sizing: border-box; min-height: 52px; }
.hint { color: var(--ss-muted); font-size: .9rem; margin: 0; }
.err { margin: 0; padding: .35rem .6rem; border-left: 4px solid var(--ss-accent); background: var(--ss-accent-soft); font-weight: 600; font-size: .95rem; }
.note { margin: 0; padding: .35rem .6rem; border-left: 4px solid var(--ss-line); color: var(--ss-muted); font-size: .95rem; }

/* ---------- projects list ---------- */
.pl { box-sizing: border-box; max-width: 40rem; margin-inline: auto; padding: 1.25rem 1rem 1rem; }
.pl-title { font-size: clamp(2rem, 1.5rem + 2.2vw, 2.7rem); margin: 0 0 .6rem; }
.pl-note { margin: 12px 0 0; padding: .45rem .7rem; border-left: 4px solid var(--ss-line); color: var(--ss-muted); }
.pl-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ss-line); }
.pl-item { padding: 4px 0; border-bottom: 1px solid var(--ss-line); } /* 8 px between neighboring rows */
.pl-link { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 14px; align-items: center; min-height: 92px; padding: 10px 4px; color: inherit; text-decoration: none; }
.pl-link:hover { background: var(--ss-accent-soft); }
.pl-mini { display: block; width: 48px; height: 76px; border: 1px solid var(--ss-line); border-radius: 5px; background: var(--ss-surface); }
.pl-name { font-family: var(--ss-display); font-weight: 700; font-size: 1.55rem; line-height: 1.1; margin: 0; overflow-wrap: anywhere; }
.pl-meta { margin: 2px 0 0; color: var(--ss-muted); font-size: .95rem; line-height: 1.4; }
.pl-meta strong { color: var(--ss-ink); font-weight: 600; }
.pl-yarn { display: inline-flex; align-items: center; gap: 8px; }
.pl-chip { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--ss-line); background: var(--chip, #8a8f98); flex: none; }
/* The slot is in the page's markup, so the list's room is there from the first paint and nothing below it moves when the list
   fills in (the footer used to jump). One project's height is held (the free version keeps one); the empty line takes the same
   room, and is in the markup but not drawn until list.js knows whether there are projects (it takes pl-slot--wait off). */
.pl-slot { min-height: var(--pl-slot-h, 7.75rem); }
.pl-slot--wait .pl-empty { visibility: hidden; }
.pl-empty { padding: 2.2rem 0 1.4rem; border-top: 1px solid var(--ss-line); }
.pl-empty__line { font-size: 1.15rem; max-width: 24rem; margin: 0; }
.pl-status { margin: .6rem 0 0; min-height: 1.4em; font-weight: 600; }
.pl-actions { position: sticky; bottom: 0; z-index: 3; padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); background: var(--ss-bg); }
.pl-new { display: flex; width: 100%; min-height: 58px; font-size: 1.15rem; }
.pl-more { margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid var(--ss-line); }
.pl-more__title { font-size: 1.5rem; margin: 0 0 .4rem; }
.pl-more__text { max-width: 36rem; margin: 0 0 .9rem; }
.pl-more__row { display: flex; flex-wrap: wrap; gap: 8px; }
.pl-reminder { margin: .8rem 0 0; padding: .4rem .7rem; border-left: 4px solid var(--ss-accent); background: var(--ss-accent-soft); }
.pl-lite { margin: 1.2rem 0 0; max-width: 36rem; font-size: .95rem; }
.pl-warning { margin: 0 0 1rem; padding: .5rem .8rem; border-left: 4px solid var(--ss-accent); background: var(--ss-accent-soft); font-weight: 600; }
.pl-noscript { padding: 1rem; font-size: 1.1rem; }
/* The free version's line is in the markup (so the footer is at its place from the first paint); the full edition has none. */
[data-edition="full"] #lite-line { display: none; }
[data-platform="play"] #lite-line { display: none; }
/* A reload on a project's screen: the list, header and footer stay out of sight until main.js has drawn that screen (see js/route-boot.js). */
[data-route="project"] #view-list, [data-route="project"] #site-header, [data-route="project"] #site-footer { display: none; }

/* ---------- counter screen ---------- */
body.on-counter { overflow: hidden; overscroll-behavior: none; }
body.on-counter #site-header, body.on-counter #site-footer { display: none; }
.cs { box-sizing: border-box; display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-width: 34rem; margin-inline: auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--ss-bg); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.cs-top { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 4px 8px 4px 4px; border-bottom: 1px solid var(--ss-line); }
.cs-name { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 4px; min-height: 48px; padding: 0 8px; border: 0; border-radius: var(--ss-radius);
  background: transparent; color: var(--ss-ink); font: 700 1.45rem/1.1 var(--ss-display); letter-spacing: .01em; text-align: left; cursor: pointer; }
.cs-name:hover { background: var(--ss-accent-soft); }
.cs-name__text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-lamp { flex: none; display: inline-flex; align-items: center; gap: 6px; box-sizing: border-box; min-height: 48px; max-width: 108px; padding: 4px 8px;
  border: 2px solid var(--ss-line); border-radius: var(--ss-radius); background: transparent; color: var(--ss-ink); font: 600 .78rem/1.15 var(--ss-font); text-align: left; cursor: pointer; }
.cs-lamp[aria-pressed="true"] { border-color: var(--ss-accent); background: var(--ss-accent-soft); }
.cs-lamp[aria-pressed="true"] .ic { color: var(--ss-link); fill: var(--ss-accent); }
.cs-lamp[aria-disabled="true"] { opacity: .6; cursor: not-allowed; }
.cs-lampnote { margin: 0; padding: .3rem 12px; font-size: .85rem; color: var(--ss-muted); border-bottom: 1px solid var(--ss-line); }
.cs-lampnote--bad { color: var(--ss-ink); font-weight: 600; }

.cs-show { flex: 1 1 0; min-height: 0; display: grid; grid-template-columns: var(--strip-w, 68px) minmax(0, 1fr); gap: 10px; padding: 10px 12px 0; --strip-w: clamp(64px, 20vw, 88px); }
.cs-strip { position: relative; min-height: 0; border: 1px solid var(--ss-line); border-radius: 6px; background: var(--ss-surface); overflow: hidden; }
.cs-strip canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cs-col { container-type: size; min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.cs-label { margin: 0; font-size: 1rem; font-weight: 600; color: var(--ss-muted); line-height: 1.2; }
.cs-count { position: relative; display: block; box-sizing: border-box; max-width: 100%; margin: 0; padding: 0 2px; border: 0; background: transparent; color: var(--ss-ink); cursor: pointer;
  touch-action: none; -webkit-tap-highlight-color: transparent; border-radius: 8px; }
.cs-digits { display: inline-flex; justify-content: center; font-family: var(--ss-display); font-weight: 700; line-height: .74;
  font-size: 7rem; font-size: max(3rem, min(calc((100cqh - 104px) / .74), calc(100cqw / (var(--digits, 2) * 0.5 + 0.1)), 20rem)); }
.cs-digits { pointer-events: none; } /* the glyph boxes are taller than the line: never let them catch taps meant for the top bar or the repeat button */
.cs-digits span { display: inline-block; width: .5em; text-align: center; }
.cs-goal { margin: 6px 0 0; min-height: 1.3em; font-size: 1.05rem; color: var(--ss-muted); line-height: 1.3; }
.cs-repeat { display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; min-height: 48px; max-width: 100%; margin-top: 4px; padding: 6px 12px;
  border: 1px solid var(--ss-line); border-radius: var(--ss-radius); background: transparent; color: var(--ss-ink); font: 600 1rem/1.25 var(--ss-font); cursor: pointer; }
.cs-repeat:hover { background: var(--ss-accent-soft); border-color: var(--ss-accent); }
.cs-repeat--empty { color: var(--ss-muted); border-style: dashed; font-weight: 500; }
.cs-tap__hint { max-width: 15rem; margin-top: 10px; font-size: .9rem; font-weight: 500; line-height: 1.35; color: var(--ss-muted); }

.cs-tap { flex: 0 0 auto; height: 41vh; height: 41dvh; min-height: 168px; box-sizing: border-box; margin: 10px 12px 0; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 2px solid var(--ss-accent); border-radius: 10px; background: var(--ss-surface); color: var(--ss-ink); cursor: pointer; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent; font-family: var(--ss-font); }
.cs-tap__plus { font: 700 clamp(4.5rem, 16vh, 8rem)/.9 var(--ss-display); color: var(--ss-link); }
.cs-tap__word { font-size: 1rem; font-weight: 600; color: var(--ss-muted); }
.cs-tap.is-down { background: var(--ss-accent); }
.cs-tap.is-down .cs-tap__plus, .cs-tap.is-down .cs-tap__word { color: var(--ss-accent-ink); }
.cs-bar { display: flex; gap: 8px; padding: 10px 12px 12px; }
.cs-undo, .cs-redo { display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-sizing: border-box; min-height: 58px; border: 2px solid var(--ss-line); border-radius: var(--ss-radius);
  background: transparent; color: var(--ss-ink); font: 700 1.3rem/1 var(--ss-display); letter-spacing: .02em; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.cs-undo { flex: 3 1 0; }
.cs-redo { flex: 2 1 0; }
.cs-undo:hover, .cs-redo:hover { background: var(--ss-accent-soft); border-color: var(--ss-accent); }
.cs-undo[aria-disabled="true"], .cs-redo[aria-disabled="true"] { opacity: .45; cursor: default; background: transparent; border-color: var(--ss-line); }
.cs-ring { position: fixed; z-index: 30; width: 120px; height: 120px; margin: -60px 0 0 -60px; pointer-events: none; opacity: 0; }
.cs-ring circle { fill: none; stroke-width: 7; }
.cs-ring .track { stroke: var(--ss-line); }
.cs-ring .fill { stroke: var(--ss-accent); stroke-linecap: round; stroke-dasharray: 327; stroke-dashoffset: 327; transform: rotate(-90deg); transform-origin: 50% 50%; }
.cs-ring.on { opacity: 1; }
.cs-ring.on .fill { animation: ring-fill var(--hold, 600ms) linear forwards; }
@keyframes ring-fill { to { stroke-dashoffset: 0; } }

/* ---------- the screens a project has besides the counter: shared top bar, tools row ---------- */
.cs-tools { display: flex; gap: 8px; padding: 6px 12px 0; }
.cs-tools + .cs-show { padding-top: 6px; }
/* Heights from 521 px up were the rule's before the landscape layout reached 560 px; windows under 600 px wide keep exactly that, and from 600 px
   wide it starts one pixel above the landscape limit (561), so at 960 x 540 it cannot outrank the landscape grid's .cs-tap { height: auto }. */
@media (min-height: 561px), (max-width: 599px) and (min-height: 521px) {
  .cs-tools:not([hidden]) ~ .cs-tap { height: 35vh; height: 35dvh; min-height: 150px; }
}
.cs-tool { flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; min-height: 44px; padding: 4px 8px;
  border: 1px solid var(--ss-line); border-radius: var(--ss-radius); color: var(--ss-ink); font: 600 .95rem/1.2 var(--ss-font); text-decoration: none; -webkit-tap-highlight-color: transparent; }
.cs-tool:hover { background: var(--ss-accent-soft); border-color: var(--ss-accent); }
.cs-tool:focus-visible { outline: 3px solid var(--ss-focus); outline-offset: 2px; }

/* ---------- strip view ---------- */
.sv { box-sizing: border-box; display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-width: 34rem; margin-inline: auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background: var(--ss-bg); }
.sv-top { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 4px 8px 4px 4px; border-bottom: 1px solid var(--ss-line); }
.sv-heading { min-width: 0; }
.sv-title { margin: 0; font-size: 1.6rem; line-height: 1.05; }
.sv-name { margin: 0; color: var(--ss-muted); font-size: .9rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-info { margin: 0; padding: 8px 12px; min-height: 3.6em; box-sizing: border-box; font-weight: 600; line-height: 1.35; border-bottom: 1px solid var(--ss-line); }
.sv-fold { margin: 0; padding: 6px 12px; font-size: .85rem; color: var(--ss-muted); border-bottom: 1px solid var(--ss-line); }
.sv-scroll { flex: 1 1 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; position: relative; background: var(--ss-surface); }
.sv-scroll:focus-visible { outline: 3px solid var(--ss-focus); outline-offset: -3px; }
.sv-canvas { display: block; position: sticky; top: 0; width: 100%; cursor: pointer; }
.sv-pad { width: 1px; }
.sv-bar { display: flex; gap: 8px; padding: 10px 12px 12px; }
.sv-btn { flex: 1 1 0; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; box-sizing: border-box; min-width: 48px; min-height: 56px; padding: 4px;
  border: 2px solid var(--ss-line); border-radius: var(--ss-radius); background: transparent; color: var(--ss-ink); font: 600 .85rem/1.15 var(--ss-font); cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.sv-btn:hover { background: var(--ss-accent-soft); border-color: var(--ss-accent); }
.sv-btn[aria-disabled="true"] { opacity: .45; cursor: default; background: transparent; border-color: var(--ss-line); }
.sv-btn:focus-visible { outline: 3px solid var(--ss-focus); outline-offset: 2px; }

/* ---------- pattern screen ---------- */
.rv { box-sizing: border-box; display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-width: 34rem; margin-inline: auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background: var(--ss-bg); }
.rv-top { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 4px 8px 4px 4px; border-bottom: 1px solid var(--ss-line); }
.rv-heading { flex: 1 1 auto; min-width: 0; }
.rv-title { margin: 0; font-size: 1.6rem; line-height: 1.05; }
.rv-name { margin: 0; color: var(--ss-muted); font-size: .9rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-more .ic { stroke-width: 3.5; }
.rv-note { margin: 0; padding: .35rem 12px; font-size: .85rem; line-height: 1.35; border-bottom: 1px solid var(--ss-line); background: var(--ss-accent-soft); }
.rv-tools { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 8px 12px 0; }
.rv-group { display: flex; align-items: center; gap: 8px; }
.rv-tbtn { display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; width: 44px; height: 44px; padding: 0; border: 1px solid var(--ss-line); border-radius: var(--ss-radius);
  background: transparent; color: var(--ss-ink); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.rv-tbtn:hover { background: var(--ss-accent-soft); border-color: var(--ss-accent); }
.rv-tbtn:focus-visible, .rv-line:focus-visible, .rv-undo:focus-visible, .rv-add:focus-visible { outline: 3px solid var(--ss-focus); outline-offset: 2px; }
.rv-tbtn[aria-disabled="true"] { opacity: .45; cursor: default; background: transparent; border-color: var(--ss-line); }
.rv-label { min-width: 3.4rem; text-align: center; font: 600 .9rem/1.1 var(--ss-font); }

.rv-port { position: relative; flex: 1 1 0; min-height: 0; margin: 8px 12px 0; border: 1px solid var(--ss-line); border-radius: 6px; background: var(--ss-surface); overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.rv-port:focus-visible { outline: 3px solid var(--ss-focus); outline-offset: 2px; }
.rv-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; background: #fff; }
.rv-stage canvas, .rv-stage img { display: block; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; }
.rv-ruler { position: absolute; left: 0; right: 0; z-index: 1; box-sizing: border-box; pointer-events: none; background: color-mix(in srgb, var(--ss-accent) 26%, transparent); border-block: 2px solid var(--ss-accent); }
.rv-handle { position: absolute; right: 0; z-index: 2; display: flex; align-items: center; justify-content: center; box-sizing: border-box; width: 48px; height: 48px; touch-action: none; cursor: ns-resize; -webkit-tap-highlight-color: transparent; }
.rv-handle::before { content: ""; box-sizing: border-box; width: 26px; height: 44px; border: 2px solid var(--ss-bg); border-radius: 10px; background: var(--ss-accent); }
.rv-handle::after { content: ""; position: absolute; box-sizing: border-box; width: 10px; height: 8px; border-block: 2px solid var(--ss-accent-ink); }
.rv-handle:focus-visible { outline: none; }
.rv-handle:focus-visible::before { outline: 3px solid var(--ss-focus); outline-offset: 2px; }
.rv-over { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; box-sizing: border-box; padding: 20px; text-align: center; background: var(--ss-surface); overflow-y: auto; }
.rv-over__title { margin: 0; font-size: 1.7rem; }
.rv-over__text { margin: 0; max-width: 24rem; }
.rv-over__row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 4px; }
.rv-lite { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 24px 16px; }
.rv-lite .rv-over__text { max-width: 26rem; }
.rv-lite .rv-over__row { justify-content: flex-start; }

.rv-lines { display: flex; gap: 8px; padding: 8px 12px 0; }
.rv-line { flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-sizing: border-box; min-height: 52px; padding: 4px 8px; border: 2px solid var(--ss-line); border-radius: var(--ss-radius);
  background: transparent; color: var(--ss-ink); font: 700 1.1rem/1.1 var(--ss-display); letter-spacing: .02em; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.rv-line:hover { background: var(--ss-accent-soft); border-color: var(--ss-accent); }
.rv-line[aria-disabled="true"] { opacity: .45; cursor: default; background: transparent; border-color: var(--ss-line); }
.rv-count { display: flex; gap: 8px; padding: 8px 12px 12px; }
.rv-undo { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-sizing: border-box; min-width: 96px; min-height: 64px; padding: 4px 14px; border: 2px solid var(--ss-line); border-radius: var(--ss-radius);
  background: transparent; color: var(--ss-ink); font: 700 1.2rem/1 var(--ss-display); letter-spacing: .02em; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.rv-undo:hover { background: var(--ss-accent-soft); border-color: var(--ss-accent); }
.rv-undo[aria-disabled="true"] { opacity: .45; cursor: default; background: transparent; border-color: var(--ss-line); }
.rv-add { flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 12px; box-sizing: border-box; min-height: 64px; padding: 4px 12px; border: 2px solid var(--ss-accent); border-radius: 10px;
  background: var(--ss-surface); color: var(--ss-ink); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; font-family: var(--ss-font); }
.rv-add__plus { flex: none; font: 700 2.6rem/1 var(--ss-display); color: var(--ss-link); }
.rv-add__text { min-width: 0; font-size: .85rem; font-weight: 600; line-height: 1.25; text-align: left; color: var(--ss-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rv-add.is-down { background: var(--ss-accent); }
.rv-add.is-down .rv-add__plus, .rv-add.is-down .rv-add__text { color: var(--ss-accent-ink); }

/* ---------- stats ---------- */
.st-body { flex: 1 1 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 12px calc(20px + env(safe-area-inset-bottom)); }
.st-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0 0 16px; }
.st-tile { box-sizing: border-box; min-width: 0; padding: 10px 12px; border: 1px solid var(--ss-line); border-radius: var(--ss-radius); background: var(--ss-surface); }
.st-label { margin: 0 0 2px; font-size: .9rem; color: var(--ss-muted); line-height: 1.25; }
.st-value { margin: 0; font: 700 2rem/1.05 var(--ss-display); letter-spacing: .01em; overflow-wrap: anywhere; }
.st-note { display: block; margin-top: 3px; font: 400 .8rem/1.3 var(--ss-font); color: var(--ss-muted); }
.st-empty { margin: 8px 0 20px; font-size: 1.15rem; max-width: 26rem; }
.st-aside { margin: 0 0 16px; padding: .4rem .7rem; border-left: 4px solid var(--ss-line); color: var(--ss-muted); font-size: .95rem; }
.st-h2 { font-size: 1.5rem; margin: 22px 0 4px; }
.st-cal__table { width: 100%; border-collapse: separate; border-spacing: 3px; table-layout: fixed; margin: 8px 0 12px; }
.st-cal__corner { width: 3.6rem; }
.st-cal__table th { border: 0; }
.st-cal__dow { font: 600 .8rem/1 var(--ss-font); color: var(--ss-muted); padding: 2px 0 4px; text-align: center; }
.st-cal__week { font: 600 .75rem/1.1 var(--ss-font); color: var(--ss-muted); text-align: left; padding: 0 2px; white-space: nowrap; }
.st-cal__table td { border-bottom: 1px solid var(--ss-line); }
.st-cal__day { position: relative; height: 2.6rem; padding: 3px 2px; text-align: center; vertical-align: top; border: 1px solid var(--ss-line); border-radius: 4px; background: transparent; }
.st-cal__day[data-shade="1"] { background: color-mix(in srgb, var(--ss-accent) 14%, var(--ss-surface)); }
.st-cal__day[data-shade="2"] { background: color-mix(in srgb, var(--ss-accent) 26%, var(--ss-surface)); }
.st-cal__day[data-shade="3"] { background: color-mix(in srgb, var(--ss-accent) 36%, var(--ss-surface)); }
.st-cal__day[data-shade="4"] { background: color-mix(in srgb, var(--ss-accent) 45%, var(--ss-surface)); }
.st-cal__day.is-today { border-color: var(--ss-accent); border-width: 2px; padding: 2px 1px; }
.st-cal__day.is-future { border-style: dashed; } /* days to come: dashed only, never faded, so the date keeps 4.5:1 */
.st-cal__date { display: block; font: 600 .75rem/1.1 var(--ss-font); color: var(--ss-muted); }
.st-cal__day:not([data-shade="0"]) .st-cal__date { color: var(--ss-ink); }
.st-cal__rows { display: block; margin-top: 1px; font: 700 .95rem/1.1 var(--ss-font); color: var(--ss-ink); }
.st-list { list-style: none; margin: 8px 0 12px; padding: 0; border-top: 1px solid var(--ss-line); }
.st-item { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--ss-line); }
.st-item__when { font-weight: 600; }
.st-item__what { color: var(--ss-muted); }
.st-more { width: 100%; }
.st-how .st-h2 { color: var(--ss-ink); }
.st-how { margin-top: 26px; padding-top: 4px; border-top: 1px solid var(--ss-line); color: var(--ss-muted); font-size: .95rem; }
.st-how p { margin: 0 0 .7rem; max-width: 36rem; }

/* ---------- sheets (dialogs) ---------- */
dialog.sheet { box-sizing: border-box; width: 100%; max-width: 30rem; max-height: min(92dvh, 48rem); margin: auto auto 0; padding: 0; border: 0; border-top: 3px solid var(--ss-accent);
  border-radius: 14px 14px 0 0; background: var(--ss-surface); color: var(--ss-ink); overflow: hidden; }
dialog.sheet::backdrop { background: rgb(0 0 0 / .6); }
.sheet__in { box-sizing: border-box; max-height: min(92dvh, 48rem); overflow-y: auto; overscroll-behavior: contain; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.sheet__title { font-size: 1.8rem; margin: 0 0 .8rem; }
.sheet__text { margin: 0 0 1rem; }
.sheet__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.sheet__actions .btn { flex: 1 1 8rem; }
.sheet hr { margin: 1.2rem 0; }
.sheet__sec { margin: 1.4rem 0 .5rem; font-size: 1.25rem; }
@media (min-width: 36rem) {
  dialog.sheet { margin: auto; border: 1px solid var(--ss-line); border-top: 3px solid var(--ss-accent); border-radius: 12px; }
}

.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.swatch { position: relative; display: block; min-width: 0; }
.swatch input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0; opacity: 0; cursor: pointer; z-index: 1; }
.swatch__chip { display: flex; align-items: center; justify-content: center; height: 48px; box-sizing: border-box; border: 1px solid var(--ss-line); border-radius: 8px; background: var(--sw); color: var(--on, #000); }
.swatch__chip .ic { opacity: 0; stroke-width: 3; }
.swatch input:checked + .swatch__chip { outline: 3px solid var(--ss-accent); outline-offset: 2px; }
.swatch input:checked + .swatch__chip .ic { opacity: 1; }
.swatch input:focus-visible + .swatch__chip { outline: 3px solid var(--ss-focus); outline-offset: 2px; }
.swatch-pick { margin: 8px 0 0; font-weight: 600; }
.hexrow { display: flex; align-items: center; gap: 10px; }
.hexrow input { flex: 1 1 auto; max-width: 11rem; }
.hexchip { flex: none; width: 48px; height: 48px; box-sizing: border-box; border: 1px solid var(--ss-line); border-radius: 8px; background: var(--sw, transparent); }

.seg { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.seg label { position: relative; display: flex; flex: 1 1 6rem; min-width: 0; font-weight: 600; }
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.seg span { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; box-sizing: border-box; min-height: 52px; padding: 6px 8px; border: 2px solid var(--ss-line); border-radius: var(--ss-radius); text-align: center; }
.seg input:checked + span { border-color: var(--ss-accent); background: var(--ss-accent-soft); }
.seg input:focus-visible + span { outline: 3px solid var(--ss-focus); outline-offset: 2px; }
.rangerow { display: grid; grid-template-columns: minmax(0, 1fr) 5.5rem; gap: 12px; align-items: center; }
.rangerow input[type="range"] { width: 100%; min-height: 48px; padding: 0; border: 0; background: transparent; accent-color: var(--ss-accent); }
.rangerow output { font-weight: 700; text-align: right; font-size: 1.1rem; }
.switchrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; }
.switchrow input { appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 48px; height: 48px; min-height: 0; margin: 0; padding: 0; border: 0; background: transparent; cursor: pointer; }
.switchrow input::before { content: ""; position: absolute; inset: 10px; box-sizing: border-box; border: 2px solid var(--ss-muted); border-radius: 6px; background: transparent; }
.switchrow input:checked::before { border-color: var(--ss-accent); background: var(--ss-accent); }
.switchrow input:checked::after { content: ""; position: absolute; left: 18px; top: 13px; width: 8px; height: 15px; box-sizing: border-box; border: solid var(--ss-accent-ink); border-width: 0 3px 3px 0; transform: rotate(45deg); }
.switchrow input:focus-visible { outline: 3px solid var(--ss-focus); outline-offset: 0; border-radius: 8px; }
.about { color: var(--ss-muted); font-size: .95rem; }
.about p { margin: 0 0 .4rem; }
.filelist { list-style: none; margin: 0 0 1rem; padding: 0; border-top: 1px solid var(--ss-line); }
.filelist li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--ss-line); }
.filelist .n { overflow-wrap: anywhere; font-weight: 600; }
.filelist .r { color: var(--ss-muted); white-space: nowrap; }

@media (min-width: 40rem) and (min-height: 40rem) {
  .cs { border-inline: 1px solid var(--ss-line); }
}
@media (max-height: 520px) {
  .pl-actions { position: static; }
  .cs-tap { height: 34dvh; min-height: 120px; }
  .cs-tap__plus { font-size: 3.2rem; }
}
/* A phone turned sideways: the number and the strip on the left, the big +1 and Undo on the right, so nothing is squeezed or covered. */
@media (max-height: 560px) and (min-width: 600px) {
  .cs { max-width: 64rem; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto auto minmax(0, 1fr) auto; }
  .cs-top, .cs-lampnote, .cs-tools { grid-column: 1 / -1; }
  .cs-show { grid-column: 1; grid-row: 4 / 6; padding-bottom: 10px; }
  .cs-tap { grid-column: 2; grid-row: 4; height: auto; min-height: 0; }
  .cs-bar { grid-column: 2; grid-row: 5; }
  .cs-bar { padding-top: 8px; padding-bottom: 8px; }
  .cs-undo, .cs-redo { min-height: 52px; }
  .cs-tap__plus { font-size: clamp(3rem, 22vh, 5rem); }
}
/* A phone turned sideways: the page on the left, the controls in a column on the right. */
@media (max-height: 560px) and (min-width: 600px) {
  .rv { max-width: 64rem; display: grid; grid-template-columns: minmax(0, 1fr) 17rem; grid-template-rows: auto minmax(0, 1fr) auto auto; }
  .rv-head { grid-column: 1 / -1; grid-row: 1; }
  .rv-port { grid-column: 1; grid-row: 2 / 5; margin-bottom: 8px; }
  .rv-tools { grid-column: 2; grid-row: 2; align-content: start; justify-content: flex-start; flex-direction: column; align-items: stretch; flex-wrap: nowrap; }
  .rv-line .ic, .rv-undo__text { display: none; }
  .rv-line { font-size: 1.05rem; }
  .rv-undo { min-width: 64px; padding: 4px; }
  .rv-add { gap: 8px; padding: 4px 8px; }
  .rv-add__plus { font-size: 2.2rem; }
  .rv-add__text { font-size: .8rem; -webkit-line-clamp: 3; }
  .rv-group { justify-content: space-between; }
  .rv-lines { grid-column: 2; grid-row: 3; }
  .rv-count { grid-column: 2; grid-row: 4; padding-bottom: 8px; }
  .rv > .rv-top, .rv-lite { grid-column: 1 / -1; }
}
/* A wide screen (a 10-inch tablet either way up, an unfolded foldable, a laptop, a desktop): 900 px wide and 561 px tall at least, so no
   phone in portrait or sideways and not the folded foldable (600 px wide) reaches it. The counter is two columns under the full-width top
   bar: the fabric strip at the full height of the screen, then the number, +1 and Undo. The other screens use the room too. */
@media (min-width: 900px) and (min-height: 561px) {
  .cs { max-width: 64rem; display: grid; grid-template-columns: clamp(96px, 9vw, 150px) minmax(0, 1fr); grid-template-rows: auto auto auto minmax(0, 1fr) auto auto; }
  .cs-top { grid-column: 1 / -1; grid-row: 1; }
  .cs-lampnote { grid-column: 1 / -1; grid-row: 2; }
  .cs-tools { grid-column: 2; grid-row: 3; }
  .cs-show { display: contents; }
  .cs-strip { grid-column: 1; grid-row: 3 / 7; margin: 6px 0 12px 12px; }
  .cs-col { grid-column: 2; grid-row: 4; margin: 6px 12px 0; }
  /* 120 px for the label, goal and repeat button (104 on a phone, which leaves them 3 px over the edge of the cell), so Repeat is 8 px or more above +1 */
  .cs-digits { font-size: max(3rem, min(calc((100cqh - 120px) / .74), calc(100cqw / (var(--digits, 2) * 0.5 + 0.1)), 20rem)); }
  /* the second selector is the (0,3,0) one in the min-height: 561px rule above; it is named again here so that this rule wins */
  /* on a short wide window (561 to about 650 px tall, a laptop browser) the +1 and its digits give way, so the row number stays the biggest
     thing (with 180 px and 15vh it was 53 px against the +1's 84 at 960 x 561); from about 622 px tall the sizes are 34dvh and 15vh as before */
  .cs-tap, .cs-tools:not([hidden]) ~ .cs-tap { grid-column: 2; grid-row: 5; height: clamp(120px, min(34vh, calc(100vh - 410px)), 320px); height: clamp(120px, min(34dvh, calc(100dvh - 410px)), 320px); min-height: 120px; }
  .cs-tap__plus { font-size: clamp(3.5rem, min(15vh, calc(100vh - 500px)), 9rem); font-size: clamp(3.5rem, min(15dvh, calc(100dvh - 500px)), 9rem); }
  .cs-bar { grid-column: 2; grid-row: 6; }
  .sv { max-width: 40rem; }
  /* the fabric is drawn at most 280 px wide (strip.js), so its panel is as wide as the drawing needs and sits in the middle of the column */
  .sv:not(.st) .sv-scroll { width: 100%; max-width: 21.5rem; align-self: center; }
  .sv.st { max-width: 64rem; }
  .st-body { display: grid; grid-template-columns: minmax(14rem, 22rem) minmax(0, 1fr); column-gap: 32px; align-content: start; }
  .st-body > * { grid-column: 1 / -1; }
  .st-body > .st-grid { grid-column: 1; grid-row: 1; }
  .st-body > .st-aside { grid-column: 1; grid-row: 2; }
  .st-body > .st-cal { grid-column: 2; grid-row: 1 / span 2; }
  .st-body > .st-sessions { grid-column: 2; grid-row: 3; }
  .st-cal > .st-h2 { margin-top: 0; }
  /* the pattern screen: the page on the left, the controls in a column on the right (the grid of a phone turned sideways) */
  .rv { max-width: 64rem; display: grid; grid-template-columns: minmax(0, 1fr) 17rem; grid-template-rows: auto minmax(0, 1fr) auto auto; }
  .rv-head { grid-column: 1 / -1; grid-row: 1; }
  .rv-port { grid-column: 1; grid-row: 2 / 5; margin-bottom: 8px; }
  .rv-tools { grid-column: 2; grid-row: 2; align-content: start; justify-content: flex-start; flex-direction: column; align-items: stretch; flex-wrap: nowrap; }
  .rv-line .ic, .rv-undo__text { display: none; }
  .rv-line { font-size: 1.05rem; }
  .rv-undo { min-width: 64px; padding: 4px; }
  .rv-add { gap: 8px; padding: 4px 8px; }
  .rv-add__plus { font-size: 2.2rem; }
  .rv-add__text { font-size: .8rem; -webkit-line-clamp: 3; }
  .rv-group { justify-content: space-between; }
  .rv-lines { grid-column: 2; grid-row: 3; }
  .rv-count { grid-column: 2; grid-row: 4; padding-bottom: 8px; }
  .rv > .rv-top, .rv-lite { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .icon-btn { transition: none; }
}
