:root {
  --ink: #101532;
  --ink-2: #0B0F26;
  --sur: #191F45;
  --sur-2: #232A5C;
  --line: #313A78;
  --tx: #ECEAF8;
  --mut: #979DD0;
  --acc: #FF6B35;
  --acc-soft: rgba(255, 107, 53, .14);
  --pro: #4ED4A0;
  --carb: #FFC145;
  --fat: #7B8CFF;
  --bad: #FF5C7A;
  --r: 16px;
  --pad: 16px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --tab-h: 62px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--tx);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

body.app {
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}

h1, h2, h3 { margin: 0; letter-spacing: -.02em; font-weight: 800; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
p { margin: 0; }
button, input, select, textarea { font-family: inherit; font-size: 16px; color: inherit; }
input, select, textarea {
  width: 100%; padding: 12px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--ink-2); color: var(--tx);
}
input[type="checkbox"] { width: auto; margin-right: 7px; vertical-align: -2px; accent-color: var(--acc); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--acc); outline-offset: 1px; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }

.num { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

.eyebrow {
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--mut);
  font-weight: 700;
  margin: 0 0 3px;
}

/* Lock screen */
.gate { display: grid; place-items: center; padding: 24px; }
.lock { width: 100%; max-width: 340px; text-align: center; }
.lock-mark { display: flex; gap: 5px; justify-content: center; margin-bottom: 26px; height: 44px; align-items: flex-end; }
.lock-mark span { width: 9px; background: var(--line); border-radius: 3px; animation: bar 1.6s ease-in-out infinite; }
.lock-mark span:nth-child(1) { height: 40%; animation-delay: 0s; }
.lock-mark span:nth-child(2) { height: 70%; animation-delay: .12s; background: var(--acc); }
.lock-mark span:nth-child(3) { height: 100%; animation-delay: .24s; }
.lock-mark span:nth-child(4) { height: 55%; animation-delay: .36s; }
@keyframes bar { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.55); } }
.lock h1 { font-size: 24px; margin-bottom: 26px; }
.lock-form label { display: block; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--mut); margin-bottom: 8px; }
.lock-form input {
  width: 100%; text-align: center; letter-spacing: .5em; font-size: 24px;
  padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--sur);
}
.lock-form input:focus { outline: 2px solid var(--acc); outline-offset: 2px; }
.lock-form button { width: 100%; margin-top: 14px; padding: 15px; border-radius: 14px; background: var(--acc); color: #2B0F05; font-weight: 800; }
.lock-err { color: var(--bad); font-size: 13px; margin-top: 12px; }

/* Chrome */
.netbar {
  position: sticky; top: 0; z-index: 40; background: var(--acc); color: #2B0F05;
  font-size: 12px; font-weight: 700; text-align: center; padding: 6px 10px;
}

.topbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 16px) var(--pad) 12px;
}
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.icobtn {
  width: 34px; height: 34px; border-radius: 10px; background: var(--sur);
  border: 1px solid var(--line); font-size: 19px; line-height: 1; color: var(--mut);
}
.icobtn:active { background: var(--sur-2); }
.chip {
  padding: 8px 12px; border-radius: 10px; background: var(--sur); border: 1px solid var(--line);
  font-size: 13px; font-weight: 700; white-space: nowrap;
}
.chip.on { background: var(--acc); border-color: var(--acc); color: #2B0F05; }

.view { padding: 0 var(--pad) 20px; display: grid; gap: 14px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(11, 15, 38, .93);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  display: grid; place-items: center; gap: 2px; height: var(--tab-h);
  font-size: 10px; font-weight: 700; letter-spacing: .04em; color: var(--mut);
}
.tab .ti { width: 21px; height: 21px; display: block; }
.tab.on { color: var(--acc); }

/* Cards */
.card { background: var(--sur); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.card.flat { background: transparent; border-color: transparent; padding: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-h .eyebrow { margin: 0; }

/* Signature: lane meter */
.lane { margin-top: 4px; }
.lane-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.lane-val { font-size: 40px; font-weight: 800; line-height: 1; }
.lane-val small { font-size: 15px; font-weight: 700; color: var(--mut); margin-left: 4px; }
.lane-goal { font-size: 12px; color: var(--mut); text-align: right; }
.lane-track {
  position: relative; height: 30px; border-radius: 8px; background: var(--ink-2);
  border: 1px solid var(--line); overflow: hidden;
}
.lane-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #FF8F5E, var(--acc)); transition: width .45s cubic-bezier(.2, .8, .2, 1); }
.lane-fill.over { background: linear-gradient(90deg, var(--acc), var(--bad)); }
.lane-ticks { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(4, 1fr); pointer-events: none; }
.lane-ticks i { border-right: 1px solid rgba(236, 234, 248, .16); }
.lane-ticks i:last-child { border-right: 0; }
.lane-legend { display: flex; justify-content: space-between; font-size: 10px; color: var(--mut); margin-top: 6px; letter-spacing: .08em; }

/* Macro bars */
.macros { display: grid; gap: 11px; margin-top: 16px; }
.macro-row { display: grid; grid-template-columns: 96px 1fr auto; align-items: center; gap: 9px; }
.macro-name { font-size: 11.5px; color: var(--mut); font-weight: 600; line-height: 1.2; }
.macro-bar { height: 7px; border-radius: 4px; background: var(--ink-2); overflow: hidden; }
.macro-bar i { display: block; height: 100%; border-radius: 4px; transition: width .4s ease; }
.macro-num { font-size: 11.5px; color: var(--mut); min-width: 74px; text-align: right; }
.macro-num b { color: var(--tx); font-weight: 700; }

/* Lists */
.list { display: grid; gap: 1px; background: var(--line); border-radius: 12px; overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--sur); width: 100%; text-align: left;
}
.item:active { background: var(--sur-2); }
.item-main { flex: 1; min-width: 0; }
.item-t { font-weight: 650; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-s { font-size: 12px; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-r { text-align: right; flex-shrink: 0; }
.item-r b { font-size: 15px; font-weight: 700; }
.item-r span { display: block; font-size: 11px; color: var(--mut); }
.item-del { width: 34px; height: 34px; border-radius: 9px; background: var(--sur-2); color: var(--mut); font-size: 17px; flex-shrink: 0; }

.meal-h { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 8px; }
.meal-h .eyebrow { margin: 0; }
.meal-sum { font-size: 12px; color: var(--mut); font-weight: 600; }

.empty { text-align: center; padding: 22px 16px; color: var(--mut); font-size: 13.5px; border: 1px dashed var(--line); border-radius: 12px; }
.empty.sm { padding: 13px 14px; font-size: 12.5px; }
.empty b { display: block; color: var(--tx); font-size: 15px; margin-bottom: 4px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 13px 16px; border-radius: 12px; background: var(--sur-2);
  border: 1px solid var(--line); font-weight: 700; font-size: 14.5px;
}
.btn:active { transform: scale(.985); }
.btn.pri { background: var(--acc); border-color: var(--acc); color: #2B0F05; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.full { width: 100%; }
.btn.sm { padding: 9px 12px; font-size: 13px; border-radius: 10px; }
.btn-row { display: grid; grid-auto-flow: column; gap: 10px; grid-auto-columns: 1fr; }

.quad { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Forms */
.field { display: grid; gap: 6px; }
.field label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--mut); font-weight: 700; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--ink-2); color: var(--tx);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--acc); outline-offset: 1px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form { display: grid; gap: 13px; }
.search { position: relative; }
.search input { padding-right: 44px; }
.search .scan {
  position: absolute; right: 5px; top: 5px; bottom: 5px; width: 38px;
  border-radius: 9px; background: var(--sur-2); font-size: 16px;
}

.segs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--ink-2); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
.seg { padding: 9px 4px; border-radius: 9px; font-size: 12.5px; font-weight: 700; color: var(--mut); text-align: center; }
.seg.on { background: var(--acc); color: #2B0F05; }

/* Sheet */
.sheet { position: fixed; inset: 0; z-index: 90; }
.sheet-bg { position: absolute; inset: 0; background: rgba(6, 8, 22, .66); animation: fade .2s ease; }
.sheet-body {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto;
  background: var(--sur); border-radius: 22px 22px 0 0; border-top: 1px solid var(--line);
  padding: 8px var(--pad) calc(24px + env(safe-area-inset-bottom));
  animation: up .26s cubic-bezier(.2, .9, .25, 1);
}
.sheet-grip { width: 40px; height: 4px; border-radius: 3px; background: var(--line); margin: 4px auto 16px; }
.sheet h2 { margin-bottom: 14px; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 95;
  background: var(--tx); color: var(--ink); padding: 11px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 700; box-shadow: 0 8px 26px rgba(0, 0, 0, .45);
  animation: fade .2s ease;
}

/* Charts */
.chart { width: 100%; display: block; height: auto; overflow: visible; }
.chart-wrap { margin: 6px -4px 0; }

/* Sporttest */
.disc { display: grid; gap: 8px; padding: 14px; background: var(--sur); border: 1px solid var(--line); border-radius: 13px; }
.disc-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.disc-n { font-weight: 700; font-size: 14.5px; }
.disc-v { font-size: 19px; font-weight: 800; }
.disc-v.hit { color: var(--pro); }
.disc-v.miss { color: var(--acc); }
.disc-track { position: relative; height: 8px; border-radius: 5px; background: var(--ink-2); overflow: hidden; }
.disc-track i { position: absolute; inset: 0 auto 0 0; border-radius: 5px; background: var(--acc); transition: width .4s ease; }
.disc-track i.hit { background: var(--pro); }
.disc-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--mut); }

.countdown { display: flex; align-items: baseline; gap: 8px; }
.countdown b { font-size: 34px; font-weight: 800; line-height: 1; }

.stack { display: grid; gap: 10px; }
.rowline { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rowline:last-child { border-bottom: 0; }
.rowline span { font-size: 13px; color: var(--mut); }

.pill { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; background: var(--acc-soft); color: var(--acc); }

.set-row { display: grid; grid-template-columns: 26px 1fr 1fr 40px; gap: 8px; align-items: center; }
.set-row input { padding: 10px; text-align: center; border-radius: 10px; border: 1px solid var(--line); background: var(--ink-2); color: var(--tx); }
.set-no { font-size: 12px; color: var(--mut); text-align: center; font-weight: 700; }

.hint { font-size: 12px; color: var(--mut); line-height: 1.5; }

.scanbox { position: relative; border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.scanbox video { width: 100%; height: 100%; object-fit: cover; }
.scanline { position: absolute; left: 12%; right: 12%; top: 50%; height: 2px; background: var(--acc); box-shadow: 0 0 12px var(--acc); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

.act { display: grid; gap: 8px; padding: 13px 14px; background: var(--sur); }
.act-h { display: flex; align-items: center; gap: 9px; }
.act-h .src { font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; font-weight: 800; padding: 3px 7px; border-radius: 6px; }
.src.strava { background: rgba(252, 76, 2, .16); color: #FC8B5E; }
.src.apple { background: rgba(123, 140, 255, .16); color: var(--fat); }
.act-stats { display: flex; flex-wrap: wrap; gap: 12px; }
.act-stat b { display: block; font-size: 15.5px; font-weight: 700; }
.act-stat span { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--mut); }
.copyrow { display: flex; gap: 8px; align-items: stretch; }
.copyrow input { font-size: 12.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.copyrow button { flex-shrink: 0; padding: 0 14px; border-radius: 11px; background: var(--sur-2); border: 1px solid var(--line); font-size: 12.5px; font-weight: 700; }
.steps { counter-reset: st; display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.steps li { position: relative; padding-left: 35px; min-height: 24px; font-size: 13.5px; line-height: 1.55; color: var(--tx); }
.steps li::before { counter-increment: st; content: counter(st); position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; background: var(--acc-soft); color: var(--acc); font-size: 11px; font-weight: 800; }
.steps b { font-weight: 700; }
.steps code { background: var(--ink-2); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mut); display: inline-block; margin-right: 6px; }
.status-dot.on { background: var(--pro); }
