/* =============================================================================
   Superintelligent Labs Design System — Components  v2
   Built only from tokens. Every interactive element has a ≥44pt hit target.
   ============================================================================= */

/* ---- Brand mark -------------------------------------------------------------
   Monogram tile generated from the community name. <span class="mark">ABP</span> */
.mark {
  display: inline-grid; place-items: center; flex: none;
  width: var(--mark-size); height: var(--mark-size); border-radius: 8px;
  background: var(--color-text); color: var(--color-text-inverse);
  font-size: var(--size-11); font-weight: var(--weight-bold); letter-spacing: .04em; line-height: 1;
}
.mark.is-lg { width: 40px; height: 40px; border-radius: 11px; font-size: var(--size-13); }

/* ---- Buttons -----------------------------------------------------------------
   .btn + variant (+ size) (+ .btn-block)
   Variant      Use                                         Rule
   primary      the main action                             one per view
   secondary    supporting actions                          any number
   destructive  delete, clear, withdraw                     always confirm
   link         tertiary inline actions                     text only
   Size         height   hit target
   .btn-sm      36       44 (extended invisibly)
   (default)    44       44
   .btn-lg      48       48   — form submits and the primary CTA
   Heights are minimums: with a larger Text Size a button grows taller and wraps its label.
   ----------------------------------------------------------------------------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-h); max-width: 100%; padding: 0 var(--space-4);
  border: var(--stroke) solid transparent; border-radius: var(--radius-sm);
  font-size: var(--text-control); font-weight: var(--weight-semibold); line-height: 1.25; letter-spacing: -0.005em; text-align: center;
  cursor: pointer; transition: transform var(--duration-1) var(--ease-standard), background-color var(--duration-1), border-color var(--duration-1), opacity var(--duration-1);
}
.btn:active { transform: scale(var(--press-scale)); }
.btn-primary:active { filter: brightness(.92); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn-sm { min-height: 36px; padding: 0 var(--space-3); font-size: var(--text-control-sm); line-height: calc(18 / 14); border-radius: 9px; }
/* 44pt hit area: see "Tap areas" at the end of this file */
.btn-lg { min-height: var(--control-h-lg); padding: 0 var(--space-5); }
.btn-block { display: flex; width: 100%; }

.btn-primary { background: var(--theme-accent); color: var(--color-on-accent); box-shadow: var(--shadow-1); }
.btn-primary:hover { background: color-mix(in srgb, var(--theme-accent) 90%, black); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-control-border); }
.btn-secondary:hover { border-color: var(--color-border-hover); }
.btn-secondary:active { background: var(--color-surface-sunken); }
.btn-destructive { background: var(--color-surface); color: var(--color-danger); border-color: var(--color-danger-border); }
.btn-destructive:active { background: var(--color-danger-bg); }
.btn-link {
  position: relative; display: inline-flex; align-items: center; justify-content: center; height: var(--hit-min); min-width: var(--hit-min); padding: 0;
  border: 0; background: none; cursor: pointer;
  font-size: var(--text-control-sm); font-weight: var(--weight-medium); color: var(--color-text);
  text-decoration: underline; text-decoration-color: var(--color-border-hover); text-underline-offset: 4px;
  transition: opacity var(--duration-1);
}
.btn-link:active { opacity: .5; }
.btn-link.is-danger { color: var(--color-danger); text-decoration-color: var(--color-danger-border); }
.btn-link.is-muted { color: var(--color-text-muted); font-size: var(--text-footnote); }

/* ---- Fields ------------------------------------------------------------------ */
.field { margin-bottom: var(--space-5); }
.field-label, .field > label {
  display: block; margin-bottom: var(--space-2);
  font-size: var(--text-label); font-weight: var(--weight-semibold); color: var(--color-text);
}
.req { color: var(--theme-accent-text, var(--theme-accent)); }
.opt { margin-left: var(--space-1); font-size: var(--text-footnote); font-weight: var(--weight-regular); color: var(--color-text-faint); }
.hint { margin-top: calc(var(--space-1) * -1); margin-bottom: var(--space-3); font-size: var(--text-footnote); color: var(--color-text-muted); }
.field > .hint { margin: var(--space-2) 0 0; }   /* a note under its own field */

/* Every text-like field shares one look, whatever its type. */
input:not([type]), input[type="text"], input[type="search"], input[type="tel"], input[type="email"], input[type="url"],
input[type="number"], input[type="password"], input[type="date"], input[type="time"], input[type="datetime-local"],
select, textarea {
  display: block; width: 100%; height: var(--control-h); padding: 0 var(--space-3);
  border: var(--stroke) solid var(--color-control-border); border-radius: var(--radius-sm);
  background-color: var(--color-field); color: var(--color-text); font-weight: var(--weight-semibold);
  font-size: var(--text-input); line-height: 1.3;   /* page viewport sets maximum-scale=1 so iOS does not zoom */
  appearance: none; -webkit-appearance: none;
  transition: border-color var(--duration-1), box-shadow var(--duration-1);
}
textarea { height: auto; min-height: 72px; padding: var(--space-3); resize: vertical; line-height: var(--leading-body); }
input::placeholder, textarea::placeholder { color: var(--color-text-faint); font-weight: var(--weight-regular); }
input:hover, select:hover, textarea:hover { border-color: var(--color-border-hover); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--theme-accent-text, var(--theme-accent)); box-shadow: 0 0 0 3px var(--color-focus-halo); }
select {
  padding-right: var(--space-8); cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%237c756e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px;
}
input[type="search"] {
  height: var(--control-h); padding-left: 36px; border-radius: var(--radius-sm); background-color: var(--color-surface-subtle);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23a39c94' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='8.5' cy='8.5' r='5.5'/%3E%3Cpath d='M13 13l4 4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 12px center; background-size: 16px;
}
input[type="file"] { max-width: 100%; min-height: var(--hit-min); font-size: var(--text-control-sm); color: var(--color-text-muted); }
input[type="file"]::file-selector-button {
  height: 36px; margin-right: var(--space-3); padding: 0 var(--space-3); cursor: pointer;
  border: var(--stroke) solid var(--color-control-border); border-radius: 9px; background: var(--color-surface);
  font: inherit; font-weight: var(--weight-semibold); color: var(--color-text);
}
.input-number { text-align: center; font-variant-numeric: tabular-nums; }

/* ---- Choice chips ---------------------------------------------------------------
   Checkbox or radio styled as a tappable option.
   <label class="chip"><input type="checkbox"><span>Setup</span></label>        */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chips.is-2up { display: grid; grid-template-columns: 1fr 1fr; }
.chip { position: relative; }
.chip input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.chip span {
  display: flex; align-items: center; gap: var(--space-2); height: 100%; min-height: var(--control-h); padding: 0 var(--space-3);
  border: var(--stroke) solid var(--color-control-border); border-radius: var(--radius-sm); background: var(--color-surface);
  font-size: var(--text-control-sm); color: var(--color-text); cursor: pointer;
  transition: background-color var(--duration-1), border-color var(--duration-1), transform var(--duration-1) var(--ease-standard);
}
.chip:active span { transform: scale(var(--press-scale)); }
.chip input:checked + span { border-color: var(--theme-accent-line); background: var(--theme-accent-bg); color: var(--theme-accent-ink); font-weight: var(--weight-semibold); }
.chip input:focus-visible + span { outline: 2px solid var(--color-focus-ring); outline-offset: 1px; }
.radio-dot { width: 18px; height: 18px; flex: none; border-radius: 50%; border: 1.5px solid var(--color-border-hover); background: var(--color-surface); transition: border-color var(--duration-1), box-shadow var(--duration-1); }
.chip input:checked + span .radio-dot { border-color: var(--theme-accent-text, var(--theme-accent)); box-shadow: inset 0 0 0 4px var(--color-surface), inset 0 0 0 9px var(--theme-accent); }
.swatch { width: 16px; height: 16px; flex: none; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); }

/* ---- Switch (iOS) ------------------------------------------------------------- */
.field > label.switch, .switch { display: flex; margin-bottom: 0; font-weight: var(--weight-regular); align-items: center; justify-content: space-between; gap: var(--space-3); min-height: var(--hit-min); font-size: var(--text-body); color: var(--color-text); cursor: pointer; }
.switch input {
  order: 2; position: relative; flex: none; width: 46px; height: 28px; margin: 0;
  appearance: none; -webkit-appearance: none; border-radius: var(--radius-full);
  background: var(--color-border-strong); cursor: pointer; transition: background-color var(--duration-2);
}
.switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--color-surface); box-shadow: 0 2px 6px rgba(0, 0, 0, .15), 0 0 1px rgba(0, 0, 0, .1);
  transition: transform var(--duration-2) var(--ease-standard);
}
.switch input:checked { background: var(--color-switch-on); }
.switch input:checked::after { transform: translateX(18px); }

/* ---- Tabs --------------------------------------------------------------------- */
.tabs { display: flex; gap: var(--space-5); overflow-x: auto; padding: 0 var(--space-5); border-bottom: var(--stroke) solid var(--color-border); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; flex: none; display: inline-flex; align-items: center; gap: 6px; height: var(--hit-min); padding: 0;
  border: 0; background: none; cursor: pointer; white-space: nowrap;
  font-size: var(--text-control-sm); font-weight: var(--weight-semibold); color: var(--color-text-muted);
  transition: color var(--duration-2);
}
.tab::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--color-text); transform: scaleX(0); transition: transform var(--duration-2) var(--ease-standard); }
.tab:hover { color: var(--color-text-body); }
.tab { transition: color var(--duration-2), transform var(--duration-1) var(--ease-standard); }
.tab:active { transform: scale(.95); color: var(--color-text); }   /* press: every tab answers the tap */
.tab[aria-selected="true"] { color: var(--color-text); }
.tab[aria-selected="true"]::after { transform: scaleX(1); }

/* ---- Badge · Tag · Status ------------------------------------------------------- */
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-full); background: var(--color-surface-sunken); color: var(--color-text-muted); font-size: var(--text-caption); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.tab[aria-selected="true"] .badge { background: var(--color-text); color: var(--color-text-inverse); }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--radius-xs); font-size: var(--text-caption); font-weight: var(--weight-semibold); white-space: nowrap; }
.tag-success { background: var(--color-success-bg); color: var(--color-success); }
.tag-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.tag-neutral { background: var(--color-surface-sunken); color: var(--color-text-muted); }
.tag-info { background: var(--theme-accent-bg); color: var(--theme-accent-text, var(--theme-accent)); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-footnote); font-weight: var(--weight-medium); }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-success { color: var(--color-success); }
.status-danger  { color: var(--color-danger); }

/* ---- Alert -------------------------------------------------------------------- */
.alert { margin-bottom: var(--space-4); padding: var(--space-3) var(--space-4); border: var(--stroke) solid; border-radius: var(--radius-sm); font-size: var(--text-callout); }
.alert-danger  { background: var(--color-danger-bg);  border-color: var(--color-danger-border);  color: var(--color-danger); }
.alert-success { background: var(--color-success-bg); border-color: var(--color-success-border); color: var(--color-success); }
.alert-info    { background: var(--color-surface-subtle); border-color: var(--color-border); color: var(--color-text-body); }

/* ---- Surfaces ---------------------------------------------------------------- */
.card { background: var(--color-surface); border: var(--stroke) solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-2); overflow: clip; }
.row-card { margin-bottom: var(--space-3); padding: var(--space-4); background: var(--color-surface); border: var(--stroke) solid var(--color-border); border-radius: var(--radius-md); }

/* ---- Stats ------------------------------------------------------------------------
   <div class="tile"><div class="tile-label">People</div><div class="tile-value">42</div><div class="tile-note">30 adults</div></div> */
/* Two across; one across once a larger Text Size makes a tile wider than half the row (7rem grows with the text). */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(max(calc(50% - var(--space-2) / 2), min(100%, 7rem)), 1fr)); gap: var(--space-2); }
@media (min-width: 560px) { .tiles.is-3up { grid-template-columns: repeat(3, 1fr); } }
.tile { padding: var(--space-3) var(--space-4) var(--space-4); background: var(--color-surface); border: var(--stroke) solid var(--color-border); border-radius: var(--radius-md); }
.tile-label { font-size: var(--text-overline); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--color-text-muted); }
.tile-value { margin-top: var(--space-1); font-family: var(--font-serif); font-size: var(--text-stat); line-height: 1.2; color: var(--color-text); font-variant-numeric: lining-nums tabular-nums; }
.tile-note { margin-top: var(--space-0-5); font-size: var(--text-footnote); color: var(--color-text-muted); }
.meter { height: 4px; margin-top: var(--space-2); overflow: hidden; border-radius: var(--radius-full); background: var(--color-surface-sunken); }
.meter i { display: block; height: 100%; border-radius: inherit; background: var(--color-success); }
.meter.warn i { background: var(--color-warning); }
.meter.over i { background: var(--color-danger); }

/* ---- Table ---------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; background: var(--color-surface); border: var(--stroke) solid var(--color-border); border-radius: var(--radius-md); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-callout); }
.table th { height: 36px; padding: 0 var(--space-2); text-align: left; white-space: nowrap; background: var(--color-surface-subtle); border-bottom: var(--stroke) solid var(--color-border); font-size: var(--text-overline); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--color-text-muted); }
.table td { padding: var(--space-3) var(--space-2); vertical-align: top; border-top: var(--stroke) solid var(--color-border); color: var(--color-text-body); }
.table tr:first-child td { border-top: 0; }
.table td:first-child, .table th:first-child { padding-left: var(--space-4); }
.table td:last-child,  .table th:last-child  { padding-right: var(--space-4); }
.table .num { width: 1%; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .fit { width: 1%; white-space: nowrap; }
.table .sno { width: 1%; color: var(--color-text-faint); font-variant-numeric: tabular-nums; }
.table .strong { color: var(--color-text); font-weight: var(--weight-medium); }
.amount { color: var(--color-text); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }

/* ---- List --------------------------------------------------------------------- */
.list { list-style: none; padding: 0; background: var(--color-surface); border: var(--stroke) solid var(--color-border); border-radius: var(--radius-md); }
.list li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 60px; padding: var(--space-3) var(--space-4); border-top: var(--stroke) solid var(--color-border); }
.list li:first-child { border-top: 0; }
.list .n { width: 18px; flex: none; font-size: var(--text-footnote); color: var(--color-text-faint); font-variant-numeric: tabular-nums; }
.list .main { flex: 1; min-width: 0; }
.list .title { font-size: var(--text-headline); font-weight: var(--weight-semibold); color: var(--color-text); }
.meta { font-size: var(--text-footnote); color: var(--color-text-muted); }
.empty { padding: var(--space-6) var(--space-4); text-align: center; font-size: var(--text-callout); color: var(--color-text-muted); }

/* ---- Key–value list ---------------------------------------------------------------- */
.summary { padding: 0 var(--space-4); background: var(--color-surface); border: var(--stroke) solid var(--color-border); border-radius: var(--radius-md); font-size: var(--text-callout); text-align: left; }
.summary div { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) 0; border-top: var(--stroke) solid var(--color-border); }
.summary div:first-child { border-top: 0; }
.summary span { color: var(--color-text-muted); }
.summary b { font-weight: var(--weight-semibold); color: var(--color-text); text-align: right; }

/* ---- Success mark --------------------------------------------------------------- */
.check { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto var(--space-4); border-radius: 50%; background: var(--color-success); animation: pop .4s var(--ease-standard) both; }
.check svg { width: 28px; height: 28px; }
.check path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw var(--duration-3) .2s ease-out forwards; }
@keyframes pop { 0% { transform: scale(.5); opacity: 0; } 70% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---- Sheet ---------------------------------------------------------------------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: var(--z-overlay); display: flex; align-items: flex-end; justify-content: center; background: var(--scrim); opacity: 0; transition: opacity var(--duration-2); }
.sheet-backdrop.show { opacity: 1; }
.sheet { width: 100%; max-width: 440px; padding: 6px var(--space-5) calc(var(--space-6) + env(safe-area-inset-bottom)); background: var(--color-surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-3); transform: translateY(100%); transition: transform var(--duration-3) var(--ease-standard); }
.sheet-backdrop.show .sheet { transform: none; }
@media (min-width: 560px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: var(--radius-lg); padding-bottom: var(--space-6); } }
.grabber { width: 36px; height: 5px; margin: 0 auto var(--space-3); border-radius: 3px; background: var(--color-border-strong); }
/* the grabber and header are drag handles (design/sheet-drag.js): the page must not scroll while dragging them;
   the grabber gets a 44pt-tall invisible area */
.grabber, .sheet-head { touch-action: none; }
.grabber { position: relative; }
.grabber::after { content: ""; position: absolute; inset: -20px -40px -14px; }
/* A sheet you can cancel: Cancel at the leading edge, the title centred (Apple HIG › Sheets).
   <div class="sheet-head has-cancel"><button data-close>Cancel</button><h3>Title</h3></div>
   Sheets with nothing to cancel keep Done at the trailing edge. */
.sheet-head.has-cancel { display: grid; grid-template-columns: 1fr minmax(0, auto) 1fr; align-items: center; gap: var(--space-2); }
.sheet-head.has-cancel > :first-child { justify-self: start; }
.sheet-head.has-cancel > :nth-child(2) { grid-column: 2; text-align: center; }

/* ---- Toast ---------------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top)); z-index: var(--z-toast);
  max-width: calc(100% - var(--space-8)); padding: 10px var(--space-4); border-radius: var(--radius-full);
  background: var(--toast-bg); color: var(--toast-text); font-size: var(--text-callout); font-weight: var(--weight-medium);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: var(--shadow-3);
  opacity: 0; pointer-events: none; transform: translate(-50%, -12px); transition: opacity var(--duration-2), transform var(--duration-3) var(--ease-standard);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast { width: max-content; }   /* centred at 50%: size to the text, not to the half-width left of it */

/* ---- Busy button --------------------------------------------------------------
   A button waiting on the network (app.js › setBusy): can't be pressed again, shows a small spinner and
   says what it's doing ("Saving…"). It keeps its full colour, unlike a disabled button. Under Reduce
   Motion the spinner stands still (a ring with a gap). */
.btn[aria-busy="true"], .btn[aria-busy="true"]:disabled { opacity: 1; cursor: progress; }
.is-busy > .ico { display: none; }
.btn-spinner { flex: none; width: 1em; height: 1em; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; opacity: .85; animation: btn-spin 700ms linear infinite; }
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn-spinner { animation: none; } }

/* ---- Field note ----------------------------------------------------------------
   One line under the field or buttons it's about (app.js › inlineNote): a problem to fix on blur, or a
   note after an action. Never a modal alert for something that can be fixed in place. */
.field-note { margin: var(--space-2) 0 0; font-size: var(--text-footnote); color: var(--color-text-muted); }
.field-note.is-error { color: var(--color-danger); }

/* ---- Colour swatch picker ------------------------------------------------------
   Small dots, no labels (name lives in aria-label). 24pt dot, 44pt hit area.
   <label class="swatch-option"><input type="radio" aria-label="Saffron"><span style="--sw:#a64b16"></span></label> */
.swatches { display: flex; align-items: center; gap: var(--space-1); }
.swatch-option { position: relative; display: grid; place-items: center; width: var(--hit-min); height: var(--hit-min); cursor: pointer; }
.swatch-option input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.swatch-option span {
  width: 18px; height: 18px; border-radius: 50%; background: var(--sw);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
  transition: transform var(--duration-1) var(--ease-standard), box-shadow var(--duration-1);
}
.swatch-option:active span { transform: scale(.9); }
.swatch-option input:checked + span { box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 3.5px var(--sw); }
.swatch-option input:focus-visible + span { outline: 2px solid var(--color-focus-ring); outline-offset: 4px; }

/* ---- Icon option (small square choice, e.g. decoration) -------------------------- */
.icon-option { position: relative; display: grid; place-items: center; width: var(--hit-min); height: var(--hit-min); cursor: pointer; }
.icon-option input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.icon-option span {
  display: grid; place-items: center; width: 32px; height: 26px; overflow: hidden;
  border: var(--stroke) solid var(--color-border-strong); border-radius: 8px; background: var(--color-surface); color: var(--color-text-faint);
  transition: border-color var(--duration-1), background-color var(--duration-1);
}
.icon-option svg { width: 26px; height: auto; }
.icon-option input:checked + span { border-color: var(--theme-accent-line); background: var(--theme-accent-bg); }

/* =============================================================================
   Motion utilities — all disabled under prefers-reduced-motion (see base.css)
   ============================================================================= */
/* Staggered entrance: <div class="reveal" style="--i:2"> */
.reveal { animation: reveal 600ms var(--ease-standard) both; animation-delay: calc(var(--i, 0) * 80ms + 80ms); }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* Rows and tiles slide in when their panel opens */
.table tbody tr, .list li, .tiles .tile { animation: reveal 420ms var(--ease-standard) both; }
.tiles .tile:nth-child(2) { animation-delay: 40ms; } .tiles .tile:nth-child(3) { animation-delay: 80ms; }
.tiles .tile:nth-child(4) { animation-delay: 120ms; } .tiles .tile:nth-child(n+5) { animation-delay: 160ms; }
.table tbody tr:nth-child(2), .list li:nth-child(2) { animation-delay: 30ms; }
.table tbody tr:nth-child(3), .list li:nth-child(3) { animation-delay: 60ms; }
.table tbody tr:nth-child(4), .list li:nth-child(4) { animation-delay: 90ms; }
.table tbody tr:nth-child(5), .list li:nth-child(5) { animation-delay: 120ms; }
.table tbody tr:nth-child(6), .list li:nth-child(6) { animation-delay: 150ms; }
.table tbody tr:nth-child(n+7), .list li:nth-child(n+7) { animation-delay: 180ms; }
/* Live dot */
.pulse { position: relative; }
.pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: currentColor; animation: pulse 2s ease-out 4; }   /* a few beats, then still */
@keyframes pulse { 0% { transform: scale(1); opacity: .5; } 80%, 100% { transform: scale(3); opacity: 0; } }
/* Count change */
.bump { animation: bump 360ms var(--ease-standard); }
@keyframes bump { 40% { transform: scale(1.25); } }
/* Celebration burst (spawned by script) */
.confetti { position: fixed; z-index: var(--z-toast); pointer-events: none; width: 8px; height: 8px; border-radius: 2px; animation: confetti 1100ms cubic-bezier(.2, .6, .3, 1) forwards; }
@keyframes confetti {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}

/* ---- Skeleton -------------------------------------------------------------------
   Placeholder shapes shown while content loads. Rule: a skeleton has the same size,
   position and radius as the real element it stands in for, so nothing jumps.
   <span class="sk sk-line" style="width:60%"></span>                                */
.sk {
  display: block; border-radius: var(--radius-xs);
  background: linear-gradient(90deg, var(--color-surface-sunken) 0%, var(--color-surface-subtle) 40%, var(--color-surface-sunken) 80%) 0 0 / 300% 100%;
  animation: sk-shimmer 1.4s ease-in-out infinite;
}
@keyframes sk-shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }
.sk-line     { height: 10px; margin: 6px 0; }
.sk-line.lg  { height: 14px; }
.sk-title    { height: 30px; border-radius: 8px; margin: 6px 0; }
.sk-display  { height: 40px; border-radius: 10px; margin: 8px 0; }
.sk-input    { height: var(--control-h); border-radius: var(--radius-sm); }
.sk-chip     { display: inline-block; height: var(--control-h); border-radius: var(--radius-sm); }
.sk-pill     { display: inline-block; height: 20px; width: 26px; border-radius: var(--radius-full); vertical-align: middle; }
.sk-dot      { display: inline-block; width: 18px; height: 18px; border-radius: 50%; }
.tile.is-skeleton .sk-line:first-child { width: 48%; height: 8px; }
.tile.is-skeleton .sk-title { width: 40%; height: 24px; }
/* Content refreshing in place: soft shimmer over the existing table */
.is-refreshing .table-wrap, .is-refreshing .list { position: relative; }
.is-refreshing .table-wrap::after, .is-refreshing .list::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, transparent 20%, rgba(255, 255, 255, .55) 50%, transparent 80%) 0 0 / 250% 100%;
  animation: sk-shimmer 1.1s ease-in-out infinite;
}

/* ---- Brand lockup: design/brand.css ---- */
.tab .badge.sk, .tab[aria-selected="true"] .badge.sk { background-color: var(--color-surface-sunken); }

/* ---- Empty state -------------------------------------------------------------------
   Illustration (themed line art) + short title + one line. Used for empty lists,
   no search results, closed forms and errors.                                       */
.empty-state { display: grid; justify-items: center; gap: var(--space-1); padding: var(--space-8) var(--space-4); text-align: center; }
.empty-state .t-callout { max-width: 32ch; color: var(--color-text-muted); }
.empty-state .btn { margin-top: var(--space-3); }
.empty-art { width: 120px; height: 80px; margin-bottom: var(--space-2); animation: float 4s ease-in-out 4 alternate both; }
.empty-art svg { width: 100%; height: 100%; overflow: visible; }
.empty-art .d-1 { fill: var(--theme-highlight); }
.empty-art .d-2 { fill: var(--art-fill, var(--theme-accent-bg)); }
.empty-art .d-3 { fill: var(--theme-accent-text, var(--theme-accent)); }
.empty-art .d-line { fill: none; stroke: var(--art-line, var(--theme-accent-ink)); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@keyframes float { from { transform: translateY(0); } to { transform: translateY(-4px); } }
.empty-cell { padding: 0 !important; }
.empty-li { display: block !important; padding: 0 !important; border: 0 !important; }

/* ---- Segmented control (iOS) ---------------------------------------------------- */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); padding: 3px; border-radius: var(--radius-sm); background: var(--color-surface-sunken); }
.segmented label { position: relative; }
.segmented input { position: absolute; inset: -3px 0; opacity: 0; margin: 0; cursor: pointer; }   /* over the track's padding too: 44pt tall */
.segmented span { display: grid; place-items: center; min-height: 38px; padding: 0 var(--space-1); border-radius: 8px; line-height: 1.2; text-align: center; font-size: var(--text-control-sm); font-weight: var(--weight-semibold); color: var(--color-text-muted); transition: background-color var(--duration-2), color var(--duration-2), box-shadow var(--duration-2); }
.segmented input:checked + span { background: var(--color-selected); color: var(--color-text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.segmented input:focus-visible + span { outline: 2px solid var(--color-focus-ring); }

/* ---- Button icons ---------------------------------------------------------------
   Icons are for actions with a universally understood symbol only — never decoration:
   <button class="btn" data-icon="share">Share</button>. /design/icons.js draws an inline SVG
   (stroke = currentColor), so it matches the label colour in every theme and mode, in every browser.
   data-icon-end puts it after the label (Next →). */
[data-icon] > .ico { flex: none; width: 18px; height: 18px; margin-top: -1px; }
/* right-to-left text: arrows and chevrons that mean "back" or "forward" point the other way */
[dir="rtl"] .ico[data-i="chevron-left"], [dir="rtl"] .ico[data-i="chevron-right"], [dir="rtl"] .ico[data-i="arrow-right"] { transform: scaleX(-1); }
.btn-sm[data-icon] > .ico, .btn-link[data-icon] > .ico { width: 16px; height: 16px; }
.btn-lg[data-icon] > .ico { width: 19px; height: 19px; }
.btn-link[data-icon] { gap: 5px; }
.btn-link[data-icon].is-muted > .ico { width: 14px; height: 14px; }

/* ---- Dialog (confirm / notice) -----------------------------------------------------
   Apple-style alert: short title, one sentence, Cancel + one action. Destructive actions in red. */
.dialog-backdrop { position: fixed; inset: 0; z-index: calc(var(--z-overlay) + 5); display: grid; place-items: center; padding: var(--space-6); background: var(--scrim); opacity: 0; transition: opacity var(--duration-2); }
.dialog-backdrop.show { opacity: 1; }
.dialog { width: 100%; max-width: 300px; overflow: hidden; border-radius: var(--radius-md); background: var(--color-surface); box-shadow: var(--shadow-3); transform: scale(1.06); transition: transform var(--duration-2) var(--ease-standard); }
.dialog-backdrop.show .dialog { transform: none; }
.dialog-body { padding: var(--space-5) var(--space-5) var(--space-4); text-align: center; }
.dialog-body h3 { margin: 0; color: var(--color-text); font-size: var(--text-headline); font-weight: var(--weight-semibold); }
.dialog-body p { margin: var(--space-1) 0 0; color: var(--color-text-muted); font-size: var(--text-callout); }
.dialog-body p:empty { display: none; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; border-top: var(--stroke) solid var(--color-border); }
.dialog-actions button { height: 46px; border: 0; background: none; font: inherit; font-size: var(--text-body); color: var(--theme-accent-text, var(--theme-accent)); cursor: pointer; }
.dialog-actions button + button { border-left: var(--stroke) solid var(--color-border); font-weight: var(--weight-semibold); }
.dialog-actions button:active { background: var(--color-surface-sunken); }
.dialog-actions .is-danger { color: var(--color-danger); }
.dialog.is-notice .dialog-actions { grid-template-columns: 1fr; }
.dialog.is-notice #dialog-cancel { display: none; }
.dialog.is-notice #dialog-ok { border-left: 0; }
@media (prefers-reduced-motion: reduce) { .dialog { transform: none; } }
.toast { display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px 12px 14px; font-size: var(--text-body); font-weight: var(--weight-semibold); }
.toast::before { content: ""; flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--color-success) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23fff' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 10.5l3 3 6-6.5'/%3E%3C/svg%3E") center / 14px no-repeat; }

/* Field with a problem: red outline until the person edits it */
.is-invalid, .is-invalid:hover { border-color: var(--color-danger) !important; box-shadow: 0 0 0 3px var(--color-danger-bg) !important; }

/* ---- Motion (driven by /design/motion.js; nothing here applies under Reduce Motion) ------------- */
.motion .rv { opacity: 0; transform: translateY(16px); transition: opacity 600ms var(--ease-standard), transform 700ms var(--ease-standard); transition-delay: calc(var(--rv-i, 0) * 70ms); }
.motion .rv.is-in { opacity: 1; transform: none; }
/* progress bars fill as they appear */
.motion .rv .meter i { transform-origin: left center; transform: scaleX(0); transition: transform 900ms var(--ease-standard) 250ms; }
.motion .rv.is-in .meter i { transform: scaleX(1); }
/* tab underline glides between tabs */
.tabs { position: relative; }
.tab-slider { position: absolute; left: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--color-text); pointer-events: none; transition: transform 380ms var(--ease-standard), width 380ms var(--ease-standard), opacity 200ms; }
.tabs.has-slider .tab::after { display: none; }
/* segmented pill glides between choices */
.seg-nav { position: relative; }
.seg-slider { position: absolute; top: 3px; bottom: 3px; left: 0; border-radius: 8px; background: var(--color-selected); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); pointer-events: none; transition: transform 380ms var(--ease-standard), width 380ms var(--ease-standard), opacity 200ms; }
.seg-nav.has-slider button { position: relative; z-index: 1; }
.seg-nav.has-slider button[aria-selected="true"] { background: transparent; box-shadow: none; }
/* panels switch with a soft cross-fade and lift */
.motion [data-panel]:not([hidden]), .motion [data-apanel]:not([hidden]), .motion [data-seg-panel]:not([hidden]) { animation: panel-in 420ms var(--ease-standard); }
@keyframes panel-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* SVG line drawing for [data-draw] */
.motion [data-draw].rv path, .motion .rv [data-draw] path { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 1400ms var(--ease-standard) 200ms; }
.motion [data-draw].rv.is-in path, .motion .rv.is-in [data-draw] path { stroke-dashoffset: 0; }
.motion .rv [data-pop] { opacity: 0; transform: scale(.4); transform-box: fill-box; transform-origin: center; transition: opacity 400ms, transform 500ms cubic-bezier(.3, 1.5, .6, 1); transition-delay: calc(900ms + var(--pop, 0) * 140ms); }
.motion .rv.is-in [data-pop] { opacity: 1; transform: none; }

/* ---- Floating labels -------------------------------------------------------------------------
   <div class="field float"><input placeholder=" "><label>Name</label></div>
   The label sits inside the empty field like a placeholder, and moves up small once someone types
   (or autofill fills it), so the field still says what it is. Saves a label row per field. */
.field.float { position: relative; }
.field.float > input { height: max(56px, calc(1.75rem + 1.3 * var(--text-input) + 2 * var(--stroke))); padding: 1.375rem var(--space-3) .375rem; }   /* 56 tall, padding 22 / 6 at the default text size; taller with a larger Text Size */
.field.float > textarea { min-height: 96px; padding: 1.625rem var(--space-3) var(--space-2); }
.field.float > label {
  position: absolute; top: 1.0625em; left: calc(var(--space-3) + var(--stroke)); right: var(--space-3); margin: 0;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-size: var(--text-input); font-weight: var(--weight-regular); line-height: 1.375; color: var(--color-text-muted);
  pointer-events: none; transform-origin: left top; transition: transform var(--duration-1) var(--ease-standard), color var(--duration-1);
}
.field.float > :focus + label,
.field.float > :not(:placeholder-shown) + label,
.field.float > :-webkit-autofill + label { transform: translateY(-.625em) scale(.75); font-weight: var(--weight-semibold); }
.field.float > :focus + label { color: var(--theme-accent-text, var(--theme-accent)); }
.field.float > .is-invalid + label { color: var(--color-danger); }
.field.float .opt { font-size: inherit; }

/* ---- Tap areas (Apple HIG: at least 44×44pt) ------------------------------------
   Every control answers to a 44×44pt area. Full-size controls (buttons, inputs, tabs, rows) are
   44pt or more. Compact ones keep their look and get an invisible area, centred on the control,
   that sits above decorative layers so a tap just outside the outline still lands.
   Add a new compact control to this list rather than giving it its own ::after. */
.btn-sm, .bell-btn, .footer-link, .cal-link, .share-chip, .th-sort, .seg-nav > button, .dash-chip, .member-list a, .act-chip, .appearance button, .tap-area { position: relative; }
.btn-sm::after, .bell-btn::after, .footer-link::after, .cal-link::after, .share-chip::after, .th-sort::after, .seg-nav > button::after, .dash-chip::after, .member-list a::after, .act-chip::after, .appearance button::after, .tap-area::after {
  content: ""; position: absolute; z-index: 1;
  top: min(0px, calc(50% - var(--hit-min) / 2)); bottom: min(0px, calc(50% - var(--hit-min) / 2));
  left: min(0px, calc(50% - var(--hit-min) / 2)); right: min(0px, calc(50% - var(--hit-min) / 2));
}
.tab { min-width: var(--hit-min); justify-content: center; }

/* WhatsApp chat sheet (public/chat.js): the QR code for computers, where WhatsApp usually isn't */
.chat-sheet .sheet { text-align: center; }
.chat-sheet-lede { margin: 0 0 var(--space-4); color: var(--color-text-muted); font-size: var(--text-callout); }
.chat-qr { display: block; width: min(240px, 70vw); height: auto; aspect-ratio: 1; margin: 0 auto; border-radius: var(--radius-md); box-shadow: 0 0 0 1px var(--color-border); }
.chat-sheet-note { margin: var(--space-3) 0 0; color: var(--color-text-muted); font-size: var(--text-footnote); }
.chat-sheet-actions { display: flex; gap: var(--space-3); justify-content: center; margin-top: var(--space-5); }
.chat-sheet-actions .btn { flex: 1; max-width: 200px; }
/* The gate: the organizer holds the phone up and neighbours scan it. A bigger code inside a marigold kolam frame. */
.chat-sheet.is-gate .chat-qr { width: min(360px, 78vw); padding: var(--space-2); box-shadow: none;
  border: 3px dotted var(--brand-marigold); outline: 2px solid var(--brand-marigold); outline-offset: 6px; border-radius: var(--radius-lg); }
.chat-sheet.is-gate .chat-sheet-note { margin-top: var(--space-5); }
