/* ============================================================================
   REPS — training log
   Mobile-first. Bottom tab bar in portrait, left rail in landscape,
   sidebar on desktop. Dark by default, light theme available.
   ========================================================================== */

:root {
  --bg: #0a0e13;
  --bg-2: #0f151c;
  --surface: #151d26;
  --surface-2: #1c2733;
  --line: #23303d;
  --line-soft: #1a232d;
  --text: #eef4fa;
  --muted: #8b9bad;
  --faint: #5d6c7d;

  --volt: #d4fd50;
  --volt-dim: #a8cc2f;
  --cyan: #4dd8e8;
  --violet: #a78bfa;
  --rose: #fb7185;
  --amber: #fbbf24;
  --green: #34d399;

  --accent: var(--volt);
  --on-accent: #10190a;

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .3);

  --nav-h: 62px;
  --rail-w: 64px;
  --side-w: 250px;

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);

  --ease: cubic-bezier(.2, .8, .2, 1);
}

html[data-theme="light"] {
  --bg: #f2f5f8;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f7fa;
  --line: #dde5ed;
  --line-soft: #e9eef4;
  --text: #0e1720;
  --muted: #5b6b7c;
  --faint: #8695a5;
  --volt: #5ea500;
  --volt-dim: #4b8600;
  --cyan: #0b9fb4;
  --violet: #7c5cf0;
  --on-accent: #ffffff;
  --shadow: 0 10px 30px rgba(15, 30, 50, .12);
  --shadow-sm: 0 2px 8px rgba(15, 30, 50, .08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.02em; }
p { margin: 0 0 10px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ shell */

.app { min-height: 100%; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--side-w);
  padding: calc(20px + var(--sat)) 14px calc(16px + var(--sab));
  background: var(--bg-2);
  border-right: 1px solid var(--line-soft);
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 40;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 20px;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(140deg, var(--volt), var(--cyan));
  display: grid; place-items: center;
  color: #0b1206; font-weight: 900; font-size: 15px; letter-spacing: -.04em;
  flex: none;
}
.brand-name { font-size: 17px; font-weight: 800; letter-spacing: -.03em; }
.brand-sub { font-size: 11px; color: var(--faint); letter-spacing: .12em; text-transform: uppercase; }

.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 12px;
  color: var(--muted); font-weight: 600;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.nav-link svg { width: 21px; height: 21px; flex: none; }
.nav-link:hover { background: var(--surface); color: var(--text); }
.nav-link.on { background: var(--surface-2); color: var(--text); }
.nav-link.on svg { color: var(--accent); }

.sidebar-foot { margin-top: auto; display: grid; gap: 8px; }

/* main column */
.main {
  padding: calc(10px + var(--sat)) max(14px, var(--sar)) calc(var(--nav-h) + 28px + var(--sab)) max(14px, var(--sal));
  max-width: 1180px;
  margin: 0 auto;
}

/* mobile top bar */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 2px 14px;
}
.topbar h1 { font-size: 26px; }
.topbar .sub { color: var(--faint); font-size: 12.5px; margin-top: 2px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* bottom tab bar (portrait phones) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex;
  padding: 6px max(6px, var(--sal)) calc(6px + var(--sab)) max(6px, var(--sar));
  background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line-soft);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px; border-radius: 12px;
  color: var(--faint); font-size: 10.5px; font-weight: 600; letter-spacing: .01em;
  transition: color .16s var(--ease);
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.on { color: var(--text); }
.tabbar a.on svg { color: var(--accent); }

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 16px;
}
.card + .card { margin-top: 12px; }
.card-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.card-head h2 { font-size: 15px; letter-spacing: -.01em; }
.card-head .spacer { margin-left: auto; }
.card-sub { color: var(--faint); font-size: 12px; }

.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* stat tiles */
.stat {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 13px 14px;
  position: relative;
  overflow: hidden;
}
.stat .k { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.stat .v { font-size: 27px; font-weight: 800; letter-spacing: -.035em; margin-top: 4px; line-height: 1.1; }
.stat .v small { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.stat .d { font-size: 12px; margin-top: 5px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.stat .d.up { color: var(--green); }
.stat .d.down { color: var(--rose); }
.stat .d.flat { color: var(--faint); }
.stat.accent { background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 16%, var(--surface)), var(--surface)); border-color: color-mix(in srgb, var(--accent) 28%, var(--line)); }

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 16px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; color: var(--text);
  font-weight: 650; font-size: 14.5px;
  cursor: pointer; user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s var(--ease), background .16s var(--ease), opacity .16s;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--rose) 45%, transparent); color: var(--rose); }
.btn-sm { min-height: 34px; padding: 0 11px; font-size: 13px; border-radius: 10px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; pointer-events: none; }

.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 11px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s var(--ease);
}
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 19px; height: 19px; }

.fab {
  position: fixed; z-index: 45;
  right: max(16px, var(--sar)); bottom: calc(var(--nav-h) + 16px + var(--sab));
  height: 54px; padding: 0 20px;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: var(--on-accent);
  border: none; border-radius: 27px;
  font-weight: 750; font-size: 15px;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 32%, transparent);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .14s var(--ease);
}
.fab:active { transform: scale(.95); }
.fab svg { width: 20px; height: 20px; }

/* ------------------------------------------------------------------ forms */

.field { margin-bottom: 14px; }
.field > label {
  display: block; font-size: 11.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: 6px;
}
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 11px 13px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 12px; color: var(--text);
  font-size: 16px; /* keeps iOS from zooming on focus */
  appearance: none; -webkit-appearance: none;
}
textarea.input { min-height: 84px; resize: vertical; line-height: 1.5; }
select.input {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b9bad' stroke-width='2.5' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 17px;
  padding-right: 38px;
}
.input:focus { border-color: var(--accent); outline: none; }
.input::placeholder { color: var(--faint); }
.hint { font-size: 12px; color: var(--faint); margin-top: 5px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

/* stepper: big thumb targets for logging mid-set */
.stepper { display: flex; align-items: stretch; gap: 8px; }
.stepper button {
  width: 50px; flex: none;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; color: var(--text);
  font-size: 22px; font-weight: 700; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .1s var(--ease), background .15s;
}
.stepper button:active { transform: scale(.93); background: var(--surface); }
.stepper .input { text-align: center; font-size: 21px; font-weight: 750; letter-spacing: -.02em; }

/* segmented control */
.seg {
  display: flex; gap: 4px; padding: 4px;
  background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 13px;
}
.seg button {
  flex: 1; min-height: 36px; padding: 0 10px;
  background: transparent; border: none; border-radius: 10px;
  color: var(--muted); font-weight: 650; font-size: 13.5px; cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: var(--shadow-sm); }

/* effort picker */
.feelings { display: flex; gap: 7px; }
.feel {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 2px 8px;
  background: var(--bg-2); border: 1.5px solid var(--line);
  border-radius: 14px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .14s var(--ease), border-color .16s, background .16s;
}
.feel .e { font-size: 25px; line-height: 1; filter: grayscale(.55); transition: filter .16s, transform .16s var(--ease); }
.feel .l { font-size: 9.5px; font-weight: 700; color: var(--faint); text-align: center; letter-spacing: .01em; }
.feel:active { transform: scale(.94); }
.feel.on { background: color-mix(in srgb, var(--fc) 15%, var(--bg-2)); border-color: var(--fc); }
.feel.on .e { filter: none; transform: scale(1.14); }
.feel.on .l { color: var(--text); }

/* ------------------------------------------------------------------ exercise cards */

.ex-grid { display: grid; gap: 11px; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); }

.ex-card {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r); overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .15s var(--ease), border-color .16s;
}
.ex-card:active { transform: scale(.985); }
.ex-thumb {
  aspect-ratio: 4 / 3; background: var(--surface-2);
  position: relative; overflow: hidden;
}
.ex-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ex-thumb .ph {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--faint);
  background: repeating-linear-gradient(45deg, var(--surface-2) 0 10px, var(--surface) 10px 20px);
}
.ex-thumb .ph svg { width: 30px; height: 30px; }
.ord {
  position: absolute; top: 8px; left: 8px;
  min-width: 24px; height: 24px; padding: 0 7px;
  display: grid; place-items: center;
  background: rgba(6, 10, 14, .78); backdrop-filter: blur(6px);
  color: #fff; border-radius: 8px;
  font-size: 12px; font-weight: 800;
}
.ex-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.ex-body .n { font-weight: 700; font-size: 14.5px; line-height: 1.25; letter-spacing: -.01em; }
.ex-body .m { font-size: 11.5px; color: var(--faint); }
.ex-last {
  margin-top: auto; padding-top: 8px; border-top: 1px dashed var(--line);
  font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px;
}
.ex-last b { color: var(--text); font-weight: 700; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  font-size: 11px; font-weight: 650; color: var(--muted);
}
.tag.pr { background: color-mix(in srgb, var(--amber) 18%, transparent); border-color: color-mix(in srgb, var(--amber) 40%, transparent); color: var(--amber); }

/* workout list row */
.wrow {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line-soft);
  transition: border-color .18s, background .18s;
}
.wrow + .wrow { margin-top: 9px; }
.wrow.done { border-color: color-mix(in srgb, var(--green) 40%, transparent); background: color-mix(in srgb, var(--green) 7%, var(--surface)); }
.wrow .t { width: 56px; height: 56px; flex: none; border-radius: 12px; overflow: hidden; background: var(--surface-2); position: relative; }
.wrow .t img { width: 100%; height: 100%; object-fit: cover; }
.wrow .t .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); font-weight: 800; font-size: 17px; }
.wrow .i { flex: 1; min-width: 0; }
.wrow .i .n { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 7px; }
.wrow .i .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrow .drag { color: var(--faint); cursor: grab; touch-action: none; padding: 6px 2px; }
.wrow.dragging { opacity: .5; }
.wrow.dropzone { border-color: var(--accent); }

/* ------------------------------------------------------------------ lists / tables */

.list { display: grid; gap: 8px; }
.lrow {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px; border-radius: 13px;
  background: var(--surface); border: 1px solid var(--line-soft);
}
.lrow .e { font-size: 20px; flex: none; }
.lrow .i { flex: 1; min-width: 0; }
.lrow .i .n { font-weight: 660; font-size: 14px; }
.lrow .i .s { font-size: 12px; color: var(--faint); margin-top: 1px; }
.lrow .v { text-align: right; flex: none; }
.lrow .v .a { font-weight: 750; font-size: 14.5px; letter-spacing: -.02em; }
.lrow .v .b { font-size: 11.5px; color: var(--faint); }

.day-head {
  display: flex; align-items: baseline; gap: 8px;
  margin: 18px 2px 8px; font-size: 12px;
  color: var(--faint); text-transform: uppercase; letter-spacing: .09em; font-weight: 700;
}
.day-head .vol { margin-left: auto; text-transform: none; letter-spacing: 0; color: var(--muted); }

.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 460px; }
table.tbl th {
  text-align: left; padding: 8px 10px; font-size: 11px; color: var(--faint);
  text-transform: uppercase; letter-spacing: .07em; font-weight: 700;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.tbl td { padding: 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl td.wrap { white-space: normal; min-width: 140px; color: var(--muted); }

/* ------------------------------------------------------------------ charts */

.chart { width: 100%; display: block; overflow: visible; touch-action: pan-y; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis-t { fill: var(--faint); font-size: 10px; font-weight: 600; }
.chart .bar { fill: var(--accent); rx: 3; transition: opacity .15s; }
.chart .bar.empty { fill: var(--line-soft); }
.chart .ln { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart .dot { stroke: var(--bg); stroke-width: 2; }
.chart .area-fill { fill: url(#voltFade); }
.chart-empty {
  display: grid; place-items: center; min-height: 120px;
  color: var(--faint); font-size: 13px; text-align: center; padding: 20px;
}

.legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; font-size: 11.5px; color: var(--muted); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }

/* consistency heatmap */
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; }
.heat i {
  aspect-ratio: 1; border-radius: 3px; background: var(--line-soft);
  display: block; min-width: 8px;
}
.heat i[data-l="1"] { background: color-mix(in srgb, var(--accent) 32%, var(--line-soft)); }
.heat i[data-l="2"] { background: color-mix(in srgb, var(--accent) 58%, var(--line-soft)); }
.heat i[data-l="3"] { background: color-mix(in srgb, var(--accent) 80%, var(--line-soft)); }
.heat i[data-l="4"] { background: var(--accent); }
.heat i[data-future="1"] { opacity: .25; }

/* effort mix bar */
.mixbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--line-soft); }
.mixbar span { display: block; height: 100%; transition: width .4s var(--ease); }

/* progress ring for the weekly goal */
.ring { width: 62px; height: 62px; flex: none; }
.ring circle { fill: none; stroke-width: 7; stroke-linecap: round; }
.ring .track { stroke: var(--line); }
.ring .fill { stroke: var(--accent); transition: stroke-dasharray .6s var(--ease); }
.ring-t { font-size: 15px; font-weight: 800; fill: var(--text); }

/* gains rows */
.gain {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 0; border-bottom: 1px solid var(--line-soft);
}
.gain:last-child { border-bottom: none; }
.gain .t { width: 42px; height: 42px; flex: none; border-radius: 11px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; color: var(--faint); font-weight: 800; }
.gain .t img { width: 100%; height: 100%; object-fit: cover; }
.gain .i { flex: 1; min-width: 0; }
.gain .i .n { font-weight: 660; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gain .i .s { font-size: 11.5px; color: var(--faint); }
.gain .spark { width: 66px; height: 26px; flex: none; }
.gain .d { font-weight: 780; font-size: 14px; letter-spacing: -.02em; text-align: right; min-width: 62px; }
.gain .d.up { color: var(--green); }
.gain .d.down { color: var(--rose); }
.gain .d.flat { color: var(--faint); }
.gain .d small { display: block; font-size: 10.5px; font-weight: 600; color: var(--faint); }

/* ------------------------------------------------------------------ sheet / modal */

.scrim {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(3, 6, 10, .6);
  backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none;
  transition: opacity .25s var(--ease);
}
.scrim.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed; z-index: 95;
  left: 0; right: 0; bottom: 0;
  max-height: 92vh; max-height: 92dvh;
  display: flex; flex-direction: column;
  background: var(--bg-2);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-top: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateY(102%);
  padding-bottom: var(--sab);
  /* A closed sheet is centred and transparent on wide screens — without this
     it would silently swallow clicks meant for the page behind it.
     visibility flips as a delayed step, not an interpolation: instant on open,
     held back until the slide-out finishes on close. */
  visibility: hidden;
  pointer-events: none;
  transition: transform .32s var(--ease), visibility 0s linear .32s;
}
.sheet.open {
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
  transition: transform .32s var(--ease), visibility 0s;
}
.sheet-grab { padding: 9px 0 3px; display: grid; place-items: center; flex: none; cursor: grab; }
.sheet-grab i { width: 38px; height: 4px; border-radius: 2px; background: var(--line); display: block; }
.sheet-head {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 16px 12px; flex: none;
}
.sheet-head h3 { font-size: 17px; }
.sheet-head .spacer { margin-left: auto; }
.sheet-body {
  padding: 0 16px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1;
}
.sheet-foot {
  padding: 12px 16px calc(12px + var(--sab));
  border-top: 1px solid var(--line-soft);
  display: flex; gap: 10px; flex: none;
  background: var(--bg-2);
}
.sheet-foot .btn { flex: 1; }

/* photo capture */
.shot {
  position: relative; border-radius: var(--r);
  border: 1.5px dashed var(--line); background: var(--bg-2);
  aspect-ratio: 4 / 3; overflow: hidden;
  display: grid; place-items: center; cursor: pointer;
}
.shot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.shot .cta { text-align: center; color: var(--muted); padding: 16px; }
.shot .cta svg { width: 32px; height: 32px; margin-bottom: 6px; color: var(--faint); }
.shot .cta b { display: block; font-size: 14px; color: var(--text); }
.shot .cta span { font-size: 12px; }
.shot-tools { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; }
.shot-tools .icon-btn { background: rgba(6, 10, 14, .75); backdrop-filter: blur(6px); border-color: rgba(255,255,255,.15); color: #fff; }

.setchip {
  display: inline-block; margin: 0 4px 3px 0; padding: 2px 7px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: 7px; font-size: 11.5px; font-weight: 650;
}
.setchip small { color: var(--faint); margin: 0 1px; }

/* per-set table -------------------------------------------------------- */

.setgrid { margin-top: 4px; }
.setgrid-head, .setrow {
  display: grid;
  grid-template-columns: 34px minmax(52px, 1fr) minmax(64px, 1.1fr) minmax(58px, 1fr) 38px;
  gap: 6px; align-items: center;
}
.setgrid-head {
  padding: 0 0 6px;   /* must match .setrow exactly or the columns drift */
  font-size: 10.5px; font-weight: 700; color: var(--faint);
  text-transform: uppercase; letter-spacing: .07em;
}
.setgrid-head span:first-child, .setgrid-head span:nth-child(2) { text-align: center; }
.setrow { margin-bottom: 7px; }
.setrow .setno {
  height: 42px; display: grid; place-items: center;
  background: var(--surface-2); border-radius: 10px;
  font-weight: 800; font-size: 14px; color: var(--muted);
}
.setrow .prev {
  text-align: center; font-size: 11.5px; color: var(--faint);
  font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis;
}
.setrow .input { min-height: 42px; padding: 8px; text-align: center; font-size: 16px; font-weight: 700; }
.setrow .set-del {
  width: 34px; height: 34px; font-size: 19px; line-height: 1;
  background: transparent; border-color: transparent; color: var(--faint);
}
.setrow .set-del:hover { color: var(--rose); }
#setTotals { margin-top: 10px; text-align: center; }

/* login --------------------------------------------------------------- */

.login-body {
  display: grid; place-items: center; min-height: 100dvh;
  padding: calc(24px + var(--sat)) 18px calc(24px + var(--sab));
  background: radial-gradient(120% 90% at 50% 0%, #16202b 0%, var(--bg) 62%);
}
html[data-theme="light"] .login-body {
  background: radial-gradient(120% 90% at 50% 0%, #ffffff 0%, var(--bg) 62%);
}
.login-wrap { width: min(420px, 100%); }
.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand img { border-radius: 14px; margin-bottom: 10px; }
.login-brand h1 { font-size: 25px; }
.login-brand p { font-size: 13px; margin-top: 4px; }

.who-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.who {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 20px 12px 16px;
  background: var(--surface); border: 1.5px solid var(--line-soft);
  border-radius: var(--r); cursor: pointer; color: var(--text);
  -webkit-tap-highlight-color: transparent;
  transition: transform .14s var(--ease), border-color .16s;
}
.who:active { transform: scale(.96); }
.who:hover { border-color: var(--uc); }
.who-n { font-weight: 700; font-size: 15px; }
.who-tag {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--faint);
}
.who-av {
  width: 54px; height: 54px; flex: none;
  display: grid; place-items: center; border-radius: 50%;
  background: color-mix(in srgb, var(--uc) 22%, transparent);
  border: 2px solid var(--uc);
  color: var(--uc); font-weight: 800; font-size: 19px; letter-spacing: -.02em;
}
.who-av.sm { width: 38px; height: 38px; font-size: 14px; border-width: 1.5px; }

.pin-who {
  display: flex; align-items: center; gap: 12px; justify-content: center;
  margin-bottom: 18px; font-size: 17px; font-weight: 750;
}
.pin-dots {
  display: flex; gap: 9px; justify-content: center; align-items: center;
  min-height: 22px;
}
.pin-dots i {
  width: 13px; height: 13px; border-radius: 50%; background: var(--accent);
  animation: pop .18s var(--ease);
}
@keyframes pop { from { transform: scale(.3); opacity: .4; } }
.pin-error { min-height: 20px; text-align: center; font-size: 13px; color: var(--rose); margin: 8px 0 4px; font-weight: 600; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.key {
  min-height: 62px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text); font-size: 25px; font-weight: 600;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform .1s var(--ease), background .15s;
}
.key:active { transform: scale(.94); background: var(--surface-2); }
.key-soft { font-size: 15px; font-weight: 650; color: var(--muted); }

.shake { animation: shake .4s; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

/* account chip in the nav */
.me-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line-soft);
  margin-bottom: 8px;
}
.me-chip .who-av { width: 30px; height: 30px; font-size: 11.5px; border-width: 1.5px; }
.me-chip .nm { font-weight: 700; font-size: 13.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-chip a { color: var(--faint); display: grid; place-items: center; }
.me-chip a svg { width: 17px; height: 17px; }

.colour-row { display: flex; gap: 10px; flex-wrap: wrap; }
.colour-dot {
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  background: color-mix(in srgb, var(--uc) 30%, transparent);
  border: 2px solid var(--uc);
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s var(--ease);
}
.colour-dot:active { transform: scale(.9); }
.colour-dot.on { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--uc); }

/* built-in equipment artwork ------------------------------------------ */

:root {
  --art-1: #4a6076;   /* machine body   */
  --art-2: #2c3a49;   /* frame, shadow  */
  --art-3: var(--volt);
}
html[data-theme="light"] {
  --art-1: #9fb3c6;
  --art-2: #64798e;
  --art-3: #6fb400;
}

.ex-art, .shot-art {
  width: 100%; height: 100%; display: block;
  background: var(--surface-2);
  padding: 8%;
}
.shot-art { position: absolute; inset: 0; padding: 6%; background: var(--bg-2); }

.art-picker {
  display: grid; gap: 8px; margin-top: 10px;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  max-height: 260px; overflow-y: auto;
  padding: 10px; border-radius: var(--r);
  background: var(--bg-2); border: 1px solid var(--line);
}
.art-opt {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 4px; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line-soft);
  border-radius: 12px; color: var(--muted);
  -webkit-tap-highlight-color: transparent;
  transition: border-color .16s, transform .12s var(--ease);
}
.art-opt:active { transform: scale(.94); }
.art-opt.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--text); }
.art-opt svg { width: 100%; height: auto; aspect-ratio: 4/3; }
.art-opt span { font-size: 9.5px; font-weight: 650; text-align: center; line-height: 1.2; }

/* A file input that is reachable but invisible. display:none stops Safari
   opening the picker at all, so it must stay in the layout. */
.vis-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* toast */
.toasts {
  position: fixed; z-index: 120; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 20px + var(--sab));
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(440px, calc(100vw - 24px)); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 15px; border-radius: 13px;
  background: var(--surface-2); border: 1px solid var(--line);
  box-shadow: var(--shadow); font-size: 14px; font-weight: 600;
  animation: toast-in .28s var(--ease);
  max-width: 100%;
}
.toast.good { border-color: color-mix(in srgb, var(--green) 45%, transparent); }
.toast.pr { border-color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, var(--surface-2)); }
.toast.bad { border-color: color-mix(in srgb, var(--rose) 45%, transparent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }

/* rest timer pill */
.timer {
  position: fixed; z-index: 60;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 16px + var(--sab));
  display: none; align-items: center; gap: 10px;
  padding: 9px 10px 9px 16px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  box-shadow: var(--shadow); font-weight: 750;
}
.timer.on { display: flex; }
.timer.ready { border-color: var(--green); color: var(--green); }
.timer .t { font-size: 17px; letter-spacing: -.02em; min-width: 52px; text-align: center; }

/* misc */
.empty {
  text-align: center; padding: 40px 20px; color: var(--muted);
}
.empty .big { font-size: 40px; margin-bottom: 10px; }
.empty h3 { font-size: 17px; margin-bottom: 6px; color: var(--text); }
.empty p { font-size: 13.5px; max-width: 330px; margin: 0 auto 16px; }

.divider { height: 1px; background: var(--line-soft); margin: 16px 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }
.scroll-x { display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; margin: 0 -14px; padding-left: 14px; padding-right: 14px; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }
.scroll-x > * { flex: none; }

.hero-photo {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover;
  border-radius: var(--r); border: 1px solid var(--line-soft); background: var(--surface-2);
  display: block;
}

/* ================================================================== layouts */

/* Landscape phone: swap the bottom bar for a slim left rail so vertical
   space goes to content, not chrome. */
@media (orientation: landscape) and (max-height: 500px) {
  .tabbar {
    top: 0; bottom: 0; right: auto;
    width: calc(var(--rail-w) + var(--sal));
    flex-direction: column; justify-content: center; gap: 4px;
    padding: var(--sat) 6px var(--sab) max(6px, var(--sal));
    border-top: none; border-right: 1px solid var(--line-soft);
  }
  .tabbar a { flex: none; padding: 9px 2px; font-size: 9px; }
  .main {
    padding-left: calc(var(--rail-w) + 14px + var(--sal));
    padding-bottom: calc(20px + var(--sab));
    padding-top: calc(10px + var(--sat));
  }
  .fab { bottom: calc(14px + var(--sab)); }
  .toasts { bottom: calc(14px + var(--sab)); left: calc(50% + var(--rail-w) / 2); }
  .timer { bottom: calc(14px + var(--sab)); left: calc(50% + var(--rail-w) / 2); }
  .sheet { left: calc(var(--rail-w) + var(--sal)); max-height: 96dvh; }
  .ex-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .sheet-body .row-land { display: flex; gap: 12px; }
  .sheet-body .row-land > * { flex: 1; min-width: 0; }
}

/* Tablet and up */
@media (min-width: 700px) {
  .main { padding-left: 24px; padding-right: 24px; }
  .topbar h1 { font-size: 30px; }
  .grid-4 { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); }
  .ex-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .sheet {
    left: 50%; bottom: auto; top: 50%;
    transform: translate(-50%, -46%) scale(.97);
    width: min(560px, calc(100vw - 48px));
    max-height: min(88vh, 860px);
    border-radius: var(--r-lg);
    border: 1px solid var(--line);
    opacity: 0;
    transition: transform .26s var(--ease), opacity .2s var(--ease), visibility 0s linear .26s;
  }
  .sheet.open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    transition: transform .26s var(--ease), opacity .2s var(--ease), visibility 0s;
  }
  .sheet-grab { display: none; }
  .sheet-head { padding-top: 16px; }
}

/* Desktop: persistent sidebar, no bottom bar */
@media (min-width: 980px) {
  .sidebar { display: flex; }
  .tabbar { display: none; }
  .main {
    padding-left: calc(var(--side-w) + 32px);
    padding-right: 32px;
    padding-bottom: 40px;
    max-width: calc(1180px + var(--side-w));
  }
  .fab { bottom: 28px; right: 28px; }
  .toasts { bottom: 24px; left: calc(50% + var(--side-w) / 2); }
  .timer { bottom: 24px; left: calc(50% + var(--side-w) / 2); }
  .hide-desk { display: none !important; }
  .grid-dash { display: grid; grid-template-columns: 1.55fr 1fr; gap: 14px; align-items: start; }
  .ex-grid { grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); }
  .ex-card:hover { border-color: var(--line); transform: translateY(-2px); }
  .lrow:hover, .wrow:hover { border-color: var(--line); }
}

@media (max-width: 979px) { .hide-mob { display: none !important; } }

/* Touch devices: grow the small controls towards Apple's 44px guidance. */
@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; }
  .seg button { min-height: 42px; }
  .btn-sm { min-height: 40px; }
  .tabbar a { padding-top: 8px; padding-bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .tabbar, .sidebar, .fab, .timer, .toasts { display: none !important; }
  .main { padding: 0; max-width: none; }
  body { background: #fff; color: #000; }
}
