/* app.css — the client app's visual system, authored as CSS.
 *
 * Organised by LAYER, not by page (the old tracker.css/checkin.css split was the
 * page axis and is gone). Every colour, radius, blur, and saturation references a
 * token in tokens.css — there are NO raw colour literals here, and the contract
 * check (tools/check-css.sh) fails the build if one appears.
 *
 * The glass treatment (translucent gradient + hairline inset + depth shadow +
 * backdrop blur/saturate) is composed from those tokens and written directly onto
 * each semantic component (.app, the cards, inputs, textarea, marker surfaces). The
 * recipe repeats by intent — there is no `.glass-*` abstraction class — so reskinning
 * is a token edit. (A shared primitive would be premature until a third caller needs
 * the exact same recipe; today each surface tunes its own blur/saturation step.)
 *
 * The class name is the contract between Zero (which emits structure) and this
 * file (which owns appearance); behavioural state is carried on data-* hooks, not
 * styling classes. The check (tools/check-css.sh) fails the build on: a class/id
 * emitted with no rule or a rule emitted nowhere (both directions), a var() that
 * resolves to nothing, an unused token, a raw colour, a sync-state hook that
 * disagrees across its owners, a missing/orphan asset, or an untokened chrome hex.
 */

/* ============================== BASE ============================== */
* { box-sizing: border-box; margin: 0; padding: 0 }

html { min-height: 100%; background: var(--bg) }

body {
  position: relative;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  padding: clamp(18px, 5vw, 34px);
}

/* Background photo + tint layers (--veil-* tokens darken the gym-bg image). */
body:before {
  content: '';
  position: fixed;
  inset: -12px;
  background: linear-gradient(180deg, rgb(var(--veil-top-rgb)/.02), rgb(var(--veil-deep-rgb)/.72)),
              url('assets/gym-bg.png') center/cover no-repeat;
  filter: blur(2px) saturate(var(--sat-photo));
  transform: scale(1.015);
  opacity: .92;
  z-index: -2;
}
body:after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 8%, rgb(var(--accent-rgb)/.12), transparent 26%),
              linear-gradient(180deg, rgb(var(--veil-rgb)/.03), rgb(var(--veil-rgb)/.48) 48%, rgb(var(--veil-rgb)/.78));
  z-index: -1;
}

/* =========================== APP SHELL =========================== */
.app {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 22px 18px 18px;
  border: 1px solid rgb(var(--surface-rgb)/.18);
  border-radius: var(--r-4xl);
  background: linear-gradient(145deg, rgb(var(--surface-rgb)/.18), rgb(var(--surface-rgb)/.05));
  box-shadow: 0 24px 80px rgb(var(--shadow-rgb)/.45), inset 0 1px 0 rgb(var(--surface-rgb)/.24);
  backdrop-filter: blur(var(--blur-xl)) saturate(var(--sat-4));
  -webkit-backdrop-filter: blur(var(--blur-xl)) saturate(var(--sat-4));
}

h1 { font-size: 1.35rem; line-height: 1.1; font-weight: 700; color: var(--ink); text-shadow: 0 1px 20px rgb(var(--shadow-rgb)/.42) }

.app-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 16px }

.eyebrow { font-size: .68rem; font-weight: 760; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin-bottom: 5px; text-shadow: 0 0 18px rgb(var(--accent-rgb)/.22) }

.phase-pill { flex-shrink: 0; padding: 7px 10px; border: 1px solid rgb(var(--accent-rgb)/.32); border-radius: var(--r-pill); background: rgb(var(--accent-rgb)/.12); color: var(--accent-ink); font-size: .7rem; font-weight: 760; text-transform: uppercase; box-shadow: inset 0 1px 0 rgb(var(--surface-rgb)/.16) }

/* =========================== CONTROLS =========================== */
input[type=number] {
  width: 100%;
  min-height: 52px;
  padding: 0 15px;
  background: rgb(var(--surface-rgb)/.12);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 12px;
  appearance: none;
  box-shadow: inset 0 1px 0 rgb(var(--surface-rgb)/.16);
  backdrop-filter: blur(var(--blur-sm)) saturate(var(--sat-2));
  -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(var(--sat-2));
}
input[type=number]:focus { outline: none; border-color: rgb(var(--accent-rgb)/.72); box-shadow: 0 0 0 4px rgb(var(--accent-rgb)/.14), inset 0 1px 0 rgb(var(--surface-rgb)/.2) }
input[type=number]::placeholder { color: rgb(var(--text-rgb)/.5) }

button {
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border: 1px solid rgb(var(--surface-rgb)/.18);
  border-radius: var(--r-lg);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 12px;
  color: var(--ink);
  transition: transform var(--t) ease, background var(--t) ease;
  backdrop-filter: blur(var(--blur-sm)) saturate(var(--sat-4));
  -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(var(--sat-4));
}
button:active { transform: scale(.985) }
.btn-sync { background: linear-gradient(135deg, rgb(var(--accent-rgb)/.52), rgb(var(--accent-2-rgb)/.24)); color: var(--accent-ink-soft); border-color: rgb(var(--accent-rgb)/.34); box-shadow: 0 16px 44px rgb(var(--accent-rgb)/.13), 0 10px 32px rgb(var(--accent-2-rgb)/.08), inset 0 1px 0 rgb(var(--surface-rgb)/.28); text-shadow: 0 1px 16px rgb(var(--shadow-rgb)/.28) }
.btn-sync:disabled { background: rgb(var(--surface-rgb)/.12); color: rgb(var(--text-rgb)/.42); cursor: not-allowed; box-shadow: none; opacity: .8 }
.btn-checkin { background: linear-gradient(135deg, rgb(var(--accent-2-rgb)/.22), rgb(var(--accent-rgb)/.12)); box-shadow: 0 14px 38px rgb(var(--accent-2-rgb)/.1), inset 0 1px 0 rgb(var(--surface-rgb)/.2) }

.link-button { display: grid; place-items: center; width: 100%; min-height: 54px; padding: 0 16px; border: 1px solid rgb(var(--surface-rgb)/.18); border-radius: var(--r-lg); font-size: 1rem; font-weight: 700; cursor: pointer; margin-bottom: 12px; color: var(--ink); text-decoration: none; backdrop-filter: blur(var(--blur-sm)) saturate(var(--sat-4)); -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(var(--sat-4)) }

/* =========================== LAYOUT ============================= */
.action-bar { position: sticky; bottom: 0; margin: 0 -6px -6px; padding: 10px 6px 0; background: linear-gradient(180deg, rgb(var(--scrim-rgb)/0), rgb(var(--scrim-rgb)/.72) 18%, rgb(var(--scrim-rgb)/.9)); backdrop-filter: blur(var(--blur-sm)) saturate(var(--sat-1)); -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(var(--sat-1)); z-index: 10 }

/* ============================ CARDS ============================= */
.session-card, .exercise-card, .meal-card { border: 1px solid rgb(var(--surface-rgb)/.15); border-radius: var(--r-xl); background: linear-gradient(145deg, rgb(var(--surface-rgb)/.14), rgb(var(--surface-rgb)/.045)); box-shadow: inset 0 1px 0 rgb(var(--surface-rgb)/.16), 0 18px 48px rgb(var(--shadow-rgb)/.18); backdrop-filter: blur(var(--blur-lg)) saturate(var(--sat-2)); -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(var(--sat-2)) }
.session-card { padding: 14px }
.session-meta { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 8px }
.session-meta span { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 760 }
.session-meta strong { color: var(--ink); font-size: .9rem; text-align: right }
.session-card p { color: rgb(var(--text-rgb)/.64); font-size: .82rem; line-height: 1.45 }

/* ========================== EXERCISES ========================== */
.exercise-list { display: grid; gap: 12px }
.exercise-card, .meal-card { padding: 14px }
.exercise-head, .meal-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; margin-bottom: 10px }
.exercise-head p { color: var(--accent-2); font-size: .68rem; font-weight: 760; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 4px }
.exercise-head h2 { font-size: 1.02rem; line-height: 1.15; color: var(--ink); font-weight: 760 }
.exercise-head span { flex-shrink: 0; color: var(--accent-ink); font-size: .76rem; font-weight: 760; padding: 7px 9px; border-radius: var(--r-pill); background: rgb(var(--accent-rgb)/.12); border: 1px solid rgb(var(--accent-rgb)/.24) }
.exercise-media, .meal-media { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 10px }
.exercise-img, .meal-img { width: 100%; max-width: 320px; border-radius: var(--r-sm); border: 1px solid rgb(var(--surface-rgb)/.14) }
.exercise-video, .meal-video { color: var(--accent-2); font-weight: 760; text-decoration: none; align-self: center }
.exercise-cues { margin: 0 0 12px; padding-left: 18px; display: grid; gap: 3px }
.exercise-cues li { color: var(--muted); font-size: .82rem; line-height: 1.3 }
.last-time, .meal-grams { color: var(--accent-2); font-size: .78rem; font-weight: 640; letter-spacing: .02em; margin: 0 0 10px }

/* ========================== LOG GRID ========================== */
.log-grid { display: grid; gap: 8px }
.log-labels, .log-row { display: grid; grid-template-columns: 36px 1fr 1fr 1fr; gap: 8px; align-items: center }
.log-labels { color: rgb(var(--text-rgb)/.42); font-size: .66rem; font-weight: 760; text-transform: uppercase; letter-spacing: .08em; padding: 0 2px }
.log-row span { display: grid; place-items: center; min-height: 42px; border-radius: var(--r-sm); background: rgb(var(--surface-rgb)/.08); color: rgb(var(--text-rgb)/.72); font-weight: 760; border: 1px solid rgb(var(--surface-rgb)/.1) }
.log-row input { min-height: 42px; margin: 0; padding: 0 8px; text-align: center; font-size: .92rem; border-radius: var(--r-sm) }

/* ====================== MEALS / INSTRUCTIONS ====================== */
.meal-card { margin-bottom: 12px }
.meal-notes { color: rgb(var(--text-rgb)/.7); font-size: .85rem; line-height: 1.52; margin: 0 0 6px }
.instr-title { font-size: .96rem; font-weight: 760; color: var(--ink); line-height: 1.2; margin-bottom: 8px }
.instr-text { color: rgb(var(--text-rgb)/.7); font-size: .85rem; line-height: 1.52 }
.plan-lead { margin-bottom: 14px }
.instr-btn { margin-top: 14px; margin-bottom: 0 }

/* ====================== DAILY STANDARDS ====================== */
.daily-standards { margin-bottom: 16px; padding: 14px 12px 12px; border: 1px solid rgb(var(--surface-rgb)/.14); border-radius: var(--r-2xl); background: linear-gradient(145deg, rgb(var(--surface-rgb)/.12), rgb(var(--surface-rgb)/.04)); box-shadow: inset 0 1px 0 rgb(var(--surface-rgb)/.16) }
.standards-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px }
.standards-head .eyebrow { margin-bottom: 0 }
/* Each daily standard is its own logger — field + its own button — so the scope
 * is self-evident: this logs THIS number, not "the day". Structure-pass layout;
 * the button sits beside the field, the sync receipt wraps full-width below. */
.standard-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 10px }
.standard-row:last-child { margin-bottom: 0 }
.standard-row .marker-field { flex: 1 1 60% }
.standard-row .standards-btn { flex: 0 0 auto; width: auto; min-width: 92px }
.standard-row .sync-status { flex-basis: 100% }
/* The logged-pill's bigger sibling: the workout session's done confirmation —
   same accent-tint family, scaled up and bold so the client reads it at a glance. */
.logged-today { text-align: center; font-size: 1.1rem; font-weight: 760; color: var(--accent-ink-dim); padding: 14px 16px; border: 1px solid rgb(var(--accent-rgb)/.32); border-radius: var(--r-lg); background: rgb(var(--accent-rgb)/.1); margin: 2px 0 12px }
.standards-btn { min-height: 46px; margin: 2px 0 0 }
.plan-pills { flex-wrap: wrap }
.plan-pills label { flex: 1 1 45% }
.plan-pills label span { font-size: .78rem; font-weight: 700; min-height: 46px; padding: 4px 8px; line-height: 1.15; text-align: center }

/* =========================== COCKPIT ===========================
 * The landing page is a dispatch: today's surfaces become routing cards
 * (check-in / workout / meals), each a label plus a status, linking to its own
 * focused page; daily standards stay inline above. This is STRUCTURE-PASS styling
 * only — functional layout so the skeleton reads and the contract holds. The
 * visual pass (glass, depth, the premium feel) refines these same rules later.
 * cockpit-card-static is an inert card (e.g. a rest day); back-link is the return
 * affordance on the /workout and /meals drill-in pages. */
.cockpit { display: grid; gap: 10px; margin-bottom: 12px }
.cockpit-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; padding: 0 18px; border: 1px solid rgb(var(--surface-rgb)/.18); border-radius: var(--r-lg); background: rgb(var(--surface-rgb)/.06); color: var(--ink); text-decoration: none }
.cockpit-card-static { color: var(--muted) }
.cockpit-card-label { font-size: 1rem; font-weight: 760 }
.cockpit-card-state { font-size: .82rem; font-weight: 700; color: var(--accent) }
.cockpit-card-static .cockpit-card-state { color: var(--muted) }
.back-link { display: inline-block; margin-bottom: 14px; font-size: .82rem; font-weight: 700; color: var(--muted); text-decoration: none }

/* ====================== CHECK-IN SURFACES ====================== */
.checkin-body { width: min(100%, 520px); margin: 0 auto; flex: 1; overflow-y: auto; padding: 18px 16px 128px; scrollbar-width: none }
.checkin-body::-webkit-scrollbar { display: none }
.section-title { font-size: .68rem; font-weight: 760; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin: 30px 2px 5px; text-shadow: 0 0 18px rgb(var(--accent-rgb)/.2) }
.section-title:first-child { margin-top: 0 }
.scale-hint { font-size: .69rem; color: rgb(var(--text-rgb)/.5); margin: 0 2px 14px }
.marker-row { margin-bottom: 10px; padding: 12px; border: 1px solid rgb(var(--surface-rgb)/.14); border-radius: var(--r-lg); background: linear-gradient(145deg, rgb(var(--surface-rgb)/.13), rgb(var(--surface-rgb)/.045)); box-shadow: inset 0 1px 0 rgb(var(--surface-rgb)/.16), 0 16px 44px rgb(var(--shadow-rgb)/.14); backdrop-filter: blur(var(--blur-lg)) saturate(var(--sat-3)); -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(var(--sat-3)) }
.marker-label { font-size: .86rem; color: rgb(var(--text-rgb)/.78); font-weight: 650; margin-bottom: 9px }
.rating-group { display: flex; gap: 8px }
.rating-group label { flex: 1 }
.rating-group input[type=radio] { display: none }
.rating-group label span { display: flex; align-items: center; justify-content: center; min-height: 42px; border: 1px solid rgb(var(--surface-rgb)/.13); border-radius: var(--r-sm); background: rgb(var(--surface-rgb)/.07); color: rgb(var(--text-rgb)/.55); font-size: .92rem; font-weight: 760; cursor: pointer; transition: transform var(--t-fast) ease, background var(--t-fast) ease, border-color var(--t-fast) ease, color var(--t-fast) ease, box-shadow var(--t-fast) ease; box-shadow: inset 0 1px 0 rgb(var(--surface-rgb)/.1) }
.rating-group label span:active { transform: scale(.97) }
.rating-group input[type=radio]:checked + span { background: linear-gradient(135deg, rgb(var(--accent-rgb)/.28), rgb(var(--accent-2-rgb)/.13)); border-color: rgb(var(--accent-rgb)/.62); color: var(--accent-ink); box-shadow: 0 10px 28px rgb(var(--accent-rgb)/.1), inset 0 1px 0 rgb(var(--surface-rgb)/.2) }
.outcomes-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px }
.outcomes-row input { margin-bottom: 0 }
.marker-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px }
.marker-field { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid rgb(var(--surface-rgb)/.14); border-radius: var(--r-lg); background: linear-gradient(145deg, rgb(var(--surface-rgb)/.13), rgb(var(--surface-rgb)/.045)); box-shadow: inset 0 1px 0 rgb(var(--surface-rgb)/.16), 0 16px 44px rgb(var(--shadow-rgb)/.14); backdrop-filter: blur(var(--blur-lg)) saturate(var(--sat-3)); -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(var(--sat-3)) }
.marker-field span { min-height: 28px; display: flex; align-items: flex-end; font-size: .78rem; line-height: 1.18; color: rgb(var(--text-rgb)/.72); font-weight: 720 }
.marker-field input { min-height: 44px; margin: 0; text-align: center; border-radius: var(--r-sm); font-size: .96rem; font-weight: 760; padding: 0 10px }
.photo-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin: 2px 0 14px }
.photo-placeholder { min-height: 86px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 10px; border: 1px dashed rgb(var(--accent-rgb)/.36); border-radius: var(--r-lg); background: linear-gradient(145deg, rgb(var(--surface-rgb)/.1), rgb(var(--surface-rgb)/.035)); color: rgb(var(--text-rgb)/.58); font-size: .74rem; font-weight: 760; line-height: 1.25; box-shadow: inset 0 1px 0 rgb(var(--surface-rgb)/.12) }
textarea { width: 100%; min-height: 82px; padding: 13px 15px; background: linear-gradient(145deg, rgb(var(--surface-rgb)/.13), rgb(var(--surface-rgb)/.045)); border: 1px solid rgb(var(--surface-rgb)/.16); border-radius: var(--r-lg); color: var(--text); font-size: .9rem; font-family: inherit; resize: none; margin-bottom: 12px; line-height: 1.5; box-shadow: inset 0 1px 0 rgb(var(--surface-rgb)/.14); backdrop-filter: blur(var(--blur-md)) saturate(var(--sat-1)); -webkit-backdrop-filter: blur(var(--blur-md)) saturate(var(--sat-1)) }
textarea::placeholder { color: rgb(var(--text-rgb)/.42) }
textarea:focus { outline: none; border-color: rgb(var(--accent-rgb)/.72); box-shadow: 0 0 0 4px rgb(var(--accent-rgb)/.12), inset 0 1px 0 rgb(var(--surface-rgb)/.18) }

/* ============================ STATES ============================ */
.status { min-height: 18px; font-size: .82rem; color: rgb(var(--text-rgb)/.56); text-align: center; margin: 2px 0 12px }
.status.ok { color: var(--accent) }
.status.err { color: var(--danger) }
/* sync-status is the element (emitted by Zero, src/view.0 viewSyncStatus); the live
 * state rides on the data-sync-state hook set by offline.js. Valid states and their
 * copy are declared once in /queue-manifest.js (ZT_SYNC) and the contract check keeps
 * these rules, that declaration, and offline.js in agreement. */
.sync-status { display: none; font-size: .8rem; font-weight: 600; text-align: center; padding: 6px 0 2px; transition: color var(--t) }
.sync-status:not(:empty) { display: block }
.sync-status[data-sync-state="saving"] { color: rgb(var(--text-rgb)/.5) }
.sync-status[data-sync-state="queued"] { color: var(--danger) }
.sync-status[data-sync-state="synced"] { color: var(--accent) }
.sync-status[data-sync-state="error"] { color: var(--danger) }

/* ====================== SEMANTIC HOOKS ======================
 * Emitted by renderers for meaning / future styling, intentionally with no
 * visual override today. Declared here so they read as owned, not orphaned, and
 * so the contract check accounts for them. */
.checkin-page, .inline-checkin, .prescription-item { /* structural hook — no visual rule yet */ }

/* ========================== RESPONSIVE ==========================
 * CSS cannot read a custom property inside @media, so breakpoints are not tokens.
 * These two literals (430px, 360px) are their own single source — they live ONLY
 * here, mirror nothing, and so cannot drift. */
@media (max-width: 430px) {
  .photo-grid { grid-template-columns: 1fr }
  .photo-placeholder { min-height: 68px }
}
@media (max-width: 360px) {
  body { padding: 12px }
  .app { border-radius: var(--r-3xl); padding: 18px 14px }
  h1 { font-size: 1.25rem }
  .exercise-head { flex-direction: column }
  .exercise-head span { align-self: flex-start }
  .log-labels, .log-row { grid-template-columns: 30px 1fr 1fr 1fr; gap: 6px }
  .log-row input { font-size: .84rem }
  .checkin-body { padding: 14px 12px 122px }
  .marker-row, .marker-field { padding: 10px }
  .rating-group { gap: 6px }
  .rating-group label span { min-height: 40px }
  .outcomes-row, .marker-grid { grid-template-columns: 1fr }
}
