/* The live app's own rules (TP-2089 wave 4): the shell and nav, the front door and set-up, forms,
   the check-in and its report, invites and the admin page. Tokens only: no colour literal appears here
   (tests/skins.test.mjs fails the build on one), and nothing but .mutual in app.css may read --accent. */

/* ---- shell: bottom bar on a phone, a left rail from 900px (the --nav-wide token) ------------ */
.app-shell { display: block; }
.app-main { min-width: 0; }
main#app.app-main { padding-block: 16px 48px; }
.view { width: 100%; max-width: 720px; margin-inline: auto; padding-inline: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-content: start; }
.view[aria-busy="true"] { opacity: 0.6; }
body.has-nav { padding-bottom: calc(var(--nav-height) + var(--nav-safe-bottom) + 8px); }
.app-nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 8;
  background: var(--nav-bg);
  border-top: 1px solid var(--nav-border);
  padding-bottom: var(--nav-safe-bottom);
}
.app-nav ul { display: grid; grid-template-columns: repeat(4, 1fr); }
.app-nav a {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  min-height: var(--nav-height);
  min-width: var(--nav-item-min);
  padding: 6px 4px;
  color: var(--nav-ink);
  text-decoration: none;
  font-size: var(--nav-label-size);
  font-weight: 600;
}
.app-nav a[aria-current="page"] { color: var(--nav-ink-active); background: var(--nav-bg-active); }
.app-nav a[aria-current="page"]::before {
  content: "";
  position: absolute;
  inset: 0 12px auto 12px;
  height: var(--nav-indicator-size);
  background: var(--nav-indicator);
  border-radius: 0 0 4px 4px;
}
.nav-glyph {
  width: 24px;
  height: 24px;
  background: currentColor;
  -webkit-mask: var(--glyph) center / contain no-repeat;
  mask: var(--glyph) center / contain no-repeat;
}
.nav-this-week { --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 6h18v4a2 2 0 0 0 0 4v4H3v-4a2 2 0 0 0 0-4zm5 3v6h2V9zm5 0v6h2V9z'/%3E%3C/svg%3E"); }
.nav-plans { --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 5h16v3H4zm0 5.5h16v3H4zM4 16h16v3H4z'/%3E%3C/svg%3E"); }
.nav-chat { --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 4h16v12H9l-5 4z'/%3E%3C/svg%3E"); }
.nav-you { --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21c0-4.5 3.6-7 8-7s8 2.5 8 7z'/%3E%3C/svg%3E"); }
@media (min-width: 900px) {
  body.has-nav { padding-bottom: 0; }
  .app-shell { display: grid; grid-template-columns: var(--nav-rail-width) minmax(0, 1fr); gap: 24px; max-width: 1080px; margin-inline: auto; padding-inline: 24px; }
  .app-nav { position: sticky; top: 16px; inset: auto; align-self: start; border: 1px solid var(--nav-border); border-radius: var(--r-card); padding: 8px; background: var(--nav-bg); }
  .app-nav[hidden] { display: none; }
  .app-nav ul { grid-template-columns: 1fr; gap: 4px; }
  .app-nav a { grid-template-columns: 24px 1fr; justify-items: start; gap: 12px; padding: 0 12px; border-radius: var(--r-control); font-size: 1rem; }
  .app-nav a[aria-current="page"]::before { inset: 10px auto 10px 0; width: var(--nav-indicator-size); height: auto; border-radius: 0 4px 4px 0; }
  .view { margin-inline: 0; padding-inline: 0; max-width: 680px; }
  main#app.app-main { padding-block: 16px 64px; }
  body:not(.has-nav) .app-shell { grid-template-columns: minmax(0, 1fr); }
  body:not(.has-nav) .view { margin-inline: auto; }
}

/* ---- forms ------------------------------------------------------------------------------------- */
input[type="text"], input[type="email"], input[type="number"] {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  border: 2px solid var(--field-border);
  border-radius: var(--r-control);
  background: var(--surface);
}
.stack { display: grid; gap: 14px; justify-items: start; }
.stack > .field, .stack > fieldset { justify-self: stretch; }
.field-error { color: var(--error); font-weight: 600; }
.tag {
  display: inline-block;
  padding: 0 8px;
  border: 1.5px solid var(--field-border);
  border-radius: 999px;
  font-size: var(--type-caption);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  vertical-align: middle;
}
.back-row { margin-top: -4px; }
.text-link { color: var(--action); }
.state-card { display: grid; gap: 12px; justify-items: start; padding: 20px; border: 2px solid var(--text); border-radius: var(--r-card); background: var(--surface); }

/* ---- front door and set-up ----------------------------------------------------------------- */
.front { display: grid; gap: 20px; padding-top: 12px; }
.front-headline { font-family: var(--display); font-weight: var(--display-weight); letter-spacing: var(--display-tracking); font-style: var(--display-style); font-size: 2.75rem; line-height: 1.02; }
.front-links { display: grid; gap: 10px; }
.choice-stack { display: grid; gap: 12px; margin-top: 4px; }
.card-choice, .choice-radio { min-height: 76px; }
.card-choice { display: grid; gap: 4px; width: 100%; }
.choice-hint { display: block; font-weight: 400; font-size: 0.9375rem; color: var(--muted); }
.choice-radio {
  position: relative;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 12px 16px;
  border: 2px solid var(--field-border);
  border-radius: var(--r-card);
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
}
.choice-radio input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice-radio:has(input:checked) { border-color: var(--action); background: var(--selected); box-shadow: inset 0 0 0 1px var(--action); }
.choice-radio:has(input:checked) .choice-label::before { content: "✓ "; }
.choice-radio:has(input:focus-visible) { outline: var(--focus-ring); outline-offset: 3px; }
.slot-radio {
  position: relative;
  display: grid;
  gap: 2px;
  align-content: center;
  justify-items: center;
  min-height: 56px;
  padding: 6px;
  text-align: center;
  border: 2px solid var(--field-border);
  border-radius: var(--r-control);
  background: var(--surface);
  line-height: 1.2;
  cursor: pointer;
}
.slot-radio input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.slot-radio:has(input:checked) { border-color: var(--action); background: var(--selected); box-shadow: inset 0 0 0 1px var(--action); }
.slot-radio:has(input:checked) .slot-label::before { content: "✓ "; }
.slot-radio:has(input:focus-visible) { outline: var(--focus-ring); outline-offset: 3px; }
.setup { display: grid; gap: 22px; }
.guess .view-title { margin-bottom: 8px; }
.correction { display: grid; gap: 14px; justify-items: start; }
.correction .field { justify-self: stretch; }

/* ---- sign-in -------------------------------------------------------------------------------------- */
.google-form { display: grid; gap: 8px; }
.google-button { gap: 12px; }
.g-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--action);
  font-family: var(--body);
  font-weight: 800;
}
.google-button:disabled .g-mark { background: var(--disabled); color: var(--on-disabled); }
.dev-login { display: grid; gap: 12px; padding: 16px; border: 2px dashed var(--field-border); border-radius: var(--r-card); background: var(--surface); }
.dev-login h2 { font-size: 1.125rem; }

/* ---- plan pages ------------------------------------------------------------------------------------ */
.why-title { font-size: 1.125rem; margin-bottom: 4px; }
.plan-tabs ul { display: flex; flex-wrap: wrap; gap: 4px 8px; border-bottom: 1px solid var(--line); }
.plan-tabs a { display: inline-flex; align-items: center; min-height: 48px; padding: 0 10px; color: var(--muted); font-weight: 600; text-decoration: none; border-bottom: 3px solid transparent; }
.plan-tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--action); }
.plan-list { display: grid; gap: 10px; }
.plan-card { display: grid; gap: 2px; padding: 14px 16px; border: 2px solid var(--line); border-radius: var(--r-card); background: var(--surface); color: var(--text); text-decoration: none; min-height: 56px; }
.plan-card span { color: var(--muted); font-size: 0.9375rem; }
.chip[role="radio"][aria-checked="true"] { border-color: var(--action); background: var(--selected); box-shadow: inset 0 0 0 1px var(--action); }
.chip[role="radio"][aria-checked="true"]::before { content: "✓ "; margin-right: 4px; }
.wrap-chips { max-height: 22rem; overflow-y: auto; padding: 2px; }
.chip:disabled { background: var(--disabled); color: var(--on-disabled); border-color: var(--disabled); }
.composer textarea { min-height: 52px; }
.chat-empty { padding: 8px 0; }
.attend { display: grid; gap: 12px; }
.quota { font-weight: 700; }

/* ---- check-in ------------------------------------------------------------------------------------------ */
.progress-bar { height: 8px; border-radius: 999px; background: var(--paper2); border: 1px solid var(--line); overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--action); }
.scale .choice-radio { min-height: 56px; }
.total-card { display: grid; gap: 6px; padding: 18px 20px; border: 2px solid var(--text); border-radius: var(--r-card); background: var(--surface); }
.total-value { font-family: var(--display); font-weight: var(--display-weight); font-size: 3rem; line-height: 1; }
.report-part { padding: 14px 0; border-top: 1px solid var(--line); }
.exits { gap: 14px; }
.exit-card { display: grid; gap: 10px; justify-items: start; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
.exit-card .field, .exit-card form { justify-self: stretch; }
.exit-card form { display: grid; gap: 10px; justify-items: start; }

/* ---- you, invites, about, admin ------------------------------------------------------------------ */
.link-list { display: grid; gap: 4px; }
.link-list li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; min-height: 44px; align-content: center; }
.link-list a { font-weight: 600; }
.bullets { display: grid; gap: 6px; padding-left: 1.2em; list-style: disc; }
.steps { display: grid; gap: 6px; padding-left: 1.4em; list-style: decimal; }
.skin-toggle { justify-self: start; }
.danger { padding-top: 4px; }
.invite-link { font-family: ui-monospace, "SF Mono", Menlo, monospace; word-break: break-all; padding: 10px 12px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-control); max-width: none; }
.invite-list, .feedback-list { display: grid; gap: 10px; }
.invite-row { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
.feedback-row { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); display: grid; gap: 4px; }
.tree { display: grid; gap: 10px; }
.tree.nested { margin: 8px 0 0 18px; padding-left: 14px; border-left: 2px solid var(--line); }
.tree-row { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; }
.tree-row .confirm { display: inline-flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.metrics > div { grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr); }
.about-facts { margin-top: 4px; }
.receipt { padding: 10px 14px; border-left: 4px solid var(--success); background: var(--success-surface); border-radius: 0 var(--r-control) var(--r-control) 0; }

/* ---- ?dev=1 inspector (never part of the product's own surface) -------------------------------- */
.dev-inspector { position: fixed; right: 8px; top: 8px; z-index: 30; max-width: min(420px, calc(100% - 16px)); max-height: 60vh; overflow: auto; background: var(--surface); border: 2px solid var(--text); border-radius: var(--r-control); padding: 6px 10px; font-size: 0.75rem; }
.dev-inspector pre { white-space: pre-wrap; word-break: break-all; margin: 6px 0 0; }
.dev-inspector summary { cursor: pointer; font-weight: 700; min-height: 28px; }

/* A heading takes focus when a screen opens so a screen reader starts there; it is not a control. */
.view [tabindex="-1"]:focus { outline: none; }

/* A long email address or a lab name never pushes a phone screen sideways, even at 200% text. */
.view p, .view li, .view h1, .view h2, .view h3, .view label, .view dd { overflow-wrap: anywhere; }

/* The sticky "I'm in" bar sits above the bottom bar on a phone, never under it. */
@media (max-width: 899px) {
  body.has-nav .commit-bar { bottom: calc(var(--nav-height) + var(--nav-safe-bottom)); }
}
/* One slim header line on a phone: the Safety flag is an icon (its name is still read), the words return at 720px. */
.header-tools { flex-wrap: nowrap; gap: 4px; }
.safety-open { padding-inline: 12px; }
.safety-open .safety-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (min-width: 720px) {
  .safety-open { padding-inline: 14px; }
  .safety-open .safety-text { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; }
}
.day-group { margin: 0; }
.day-group legend { font-weight: 700; color: var(--muted); font-size: 0.9375rem; }
.seed-group { border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface); padding: 0 12px; }
.seed-group summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }

.inline-form { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.inline-form input[type="number"] { width: 5.5rem; min-height: 44px; }
.inline-form .button.small { min-height: 44px; }
