:root {
  --night: #000;
  --fur: #17120D;
  --fur2: #221A12;
  --whisker: #2E261E;
  --bone: #EEE6DA;
  --ash: #9E9284;
  --iris: #FF9A1F;
  --ember: #FFC75A;
  --warn: #FF6A3D;
  --display: 'Big Shoulders Display', 'Arial Narrow', Impact, sans-serif;
  --body: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--bone);
  font: 400 17px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body.playing { overflow: hidden; }
a { color: var(--ember); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--iris); outline-offset: 3px; border-radius: 6px; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 1; margin: 0; letter-spacing: .01em; }
h1 { font-size: 52px; }
h2 { font-size: 32px; margin-top: 44px; margin-bottom: 14px; }
h3 { font-size: 23px; font-weight: 700; }
p { margin: 0 0 12px; }
.sub { color: var(--ash); }
.small { font-size: 15px; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
#view { max-width: 560px; margin: 0 auto; padding: 0 18px calc(110px + var(--safe-b)); }
.back { display: inline-flex; align-items: center; gap: 6px; margin: 18px 0 8px; color: var(--ash); text-decoration: none; font-size: 16px; min-height: 44px; }
.back svg { width: 18px; height: 18px; }

/* ---------- tab bar ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 4px 6px calc(4px + var(--safe-b));
  background: rgba(0, 0, 0, .9);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--whisker);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 56px; color: var(--ash); text-decoration: none; font-size: 13px;
}
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] { color: var(--iris); }
.tabs a[aria-current="page"] svg { filter: drop-shadow(0 0 6px rgba(255, 154, 31, .55)); }

/* ---------- buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 64px; padding: 0 22px;
  border: 0; border-radius: 32px; cursor: pointer;
  background: var(--iris); color: #000;
  font-family: var(--display); font-weight: 800; font-size: 27px; letter-spacing: .02em;
  text-decoration: none;
  box-shadow: 0 0 28px rgba(255, 140, 20, .28);
  transition: transform .08s ease, background .15s;
}
.btn:active { transform: scale(.985); background: var(--ember); }
.btn.quiet { background: transparent; color: var(--bone); border: 1.5px solid var(--whisker); box-shadow: none; font-size: 24px; }
.btn.quiet:active { background: var(--fur2); }
.btn.small { min-height: 48px; font-size: 21px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.link { background: none; border: 0; padding: 8px 0; color: var(--ember); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 15px; min-height: 40px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ---------- den ---------- */
.hero { text-align: center; padding-top: 18px; }
.cat { width: min(330px, 86%); height: auto; display: block; margin: 0 auto; overflow: visible; }
.lid { transform-box: fill-box; transform-origin: center; animation: open 1.1s .35s cubic-bezier(.2, .8, .2, 1) both, blink 7.5s 2.4s infinite; }
.lid-r { animation-delay: .4s, 2.45s; }
@keyframes open { from { transform: scaleY(.04); opacity: .3; } to { transform: scaleY(1); opacity: 1; } }
@keyframes blink { 0%, 95.5%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.06); } }
.hero h1 { font-size: clamp(56px, 17vw, 84px); font-weight: 900; margin-top: 6px; letter-spacing: .015em; }
.hero .when { color: var(--ash); margin-top: 8px; }
.hero .when strong { color: var(--bone); font-weight: 700; }

.tonight { margin-top: 30px; padding: 22px 20px 20px; background: var(--fur); border: 1px solid var(--whisker); border-radius: 22px; }
.tonight .day { color: var(--ash); font-size: 16px; }
.tonight h2 { font-size: 66px; font-weight: 900; margin: 2px 0 6px; }
.tonight p { color: var(--bone); }
.tonight .btn { margin-top: 16px; }
.tonight .done-note { color: var(--ember); font-weight: 700; }
.light-week { margin: 14px 0 0; padding: 12px 14px; border-left: 3px solid var(--ember); background: rgba(255, 199, 90, .07); border-radius: 0 10px 10px 0; font-size: 15px; }

.others { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.others a {
  display: flex; flex-direction: column; justify-content: center; min-height: 64px; padding: 10px 14px;
  border: 1px solid var(--whisker); border-radius: 14px; text-decoration: none; color: var(--bone);
}
.others a b { font-family: var(--display); font-size: 23px; font-weight: 800; line-height: 1.05; }
.others a span { color: var(--ash); font-size: 14px; }

.resume { margin-top: 26px; padding: 18px 20px; border: 1.5px solid var(--iris); border-radius: 22px; box-shadow: 0 0 30px rgba(255, 140, 20, .18) inset; }
.resume h3 { margin-bottom: 4px; }
.resume .btn { margin-top: 12px; }

.notice { display: block; margin-top: 12px; padding: 14px 16px; border-radius: 14px; background: var(--fur); text-decoration: none; color: var(--bone); border: 1px dashed var(--whisker); }
.notice b { color: var(--ember); }

.weekstrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 4px; }
.weekstrip div { text-align: center; padding: 8px 0 6px; border-radius: 10px; font-size: 13px; color: var(--ash); }
.weekstrip div.today { background: var(--fur); color: var(--bone); outline: 1px solid var(--whisker); }
.weekstrip b { display: block; font-family: var(--display); font-size: 17px; font-weight: 700; color: var(--bone); margin: 2px 0 4px; }
.weekstrip svg { width: 20px; height: 12px; }
.weekstrip svg path { fill: none; stroke: var(--whisker); stroke-width: 1.4; }
.weekstrip svg.on path { fill: var(--iris); stroke: var(--iris); filter: drop-shadow(0 0 3px rgba(255, 154, 31, .8)); }

.grid9 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile {
  position: relative; display: flex; flex-direction: column; justify-content: space-between;
  min-height: 108px; padding: 12px 11px 11px; border-radius: 14px;
  background: var(--fur); border: 1px solid var(--whisker); color: var(--bone); text-decoration: none;
}
.tile b { font-family: var(--display); font-weight: 800; font-size: 21px; line-height: 1.02; }
.tile span { font-size: 13px; color: var(--ash); }
.tile.ready { border-color: var(--iris); }
.tile.ready::after { content: ''; position: absolute; top: 10px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--iris); box-shadow: 0 0 8px var(--iris); }
.extra { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }

.marks { display: inline-flex; gap: 3px; margin-top: 8px; }
.marks svg { width: 18px; height: 12px; }
.marks svg path { fill: none; stroke: #4A3D30; stroke-width: 1.3; }
.marks svg.on path { fill: var(--iris); stroke: var(--iris); }
.marks.big svg { width: 26px; height: 17px; }

/* ---------- lists ---------- */
.lifelist { list-style: none; margin: 0; padding: 0; }
.lifelist a {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px;
  padding: 14px 4px; border-bottom: 1px solid var(--whisker); color: var(--bone); text-decoration: none;
}
.lifelist b { font-family: var(--display); font-size: 26px; font-weight: 800; line-height: 1.05; }
.lifelist span { color: var(--ash); font-size: 15px; grid-column: 1; }
.lifelist .marks { grid-row: 1 / 3; grid-column: 2; margin: 0; }
.lifelist .tag { color: var(--ember); font-size: 13px; grid-column: 1; }

/* ---------- life page ---------- */
.lifehead h1 { font-size: 60px; font-weight: 900; }
.lifehead .sub { margin-top: 6px; font-size: 18px; }
.why { margin-top: 16px; font-size: 18px; line-height: 1.55; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 22px 0 10px; }
.seg button {
  position: relative; min-height: 54px; padding: 6px 4px; border-radius: 12px; cursor: pointer;
  background: transparent; border: 1.5px solid var(--whisker); color: var(--ash);
  font-family: var(--display); font-weight: 800; font-size: 20px; line-height: 1.05;
}
.seg button[aria-pressed="true"] { color: var(--bone); background: var(--fur2); border-color: var(--bone); }
.seg button .yours { display: block; font-family: var(--body); font-weight: 400; font-size: 12px; color: var(--iris); }
.items { list-style: none; margin: 18px 0 0; padding: 0; counter-reset: it; }
.items > li { padding: 18px 0 20px; border-top: 1px solid var(--whisker); }
.items > li h3 { margin-bottom: 4px; }
.dose { font-family: var(--display); font-size: 24px; font-weight: 700; color: var(--ember); margin-bottom: 12px; }
.note { color: var(--ash); font-size: 15px; margin: -6px 0 12px; }
.cues { margin: 8px 0 0; padding-left: 20px; }
.cues li { margin-bottom: 6px; }
.callout { margin-top: 18px; padding: 14px 16px; border-radius: 14px; background: var(--fur); font-size: 16px; }
.callout.warn { border-left: 3px solid var(--warn); border-radius: 0 14px 14px 0; }
.gatebox { margin-top: 26px; padding: 18px; border-radius: 18px; border: 1.5px dashed var(--whisker); }
.gatebox h3 { margin-bottom: 8px; }
.gatebox .hits { color: var(--ash); font-size: 15px; margin: 8px 0 12px; }
.gatebox.ready { border-style: solid; border-color: var(--iris); }
details.alt { margin-top: 10px; }
details.alt summary { color: var(--ember); cursor: pointer; min-height: 40px; display: flex; align-items: center; font-size: 15px; }

/* ---------- video ---------- */
.vid { margin: 4px 0 0; }
.vid-frame { position: relative; display: block; width: 100%; padding: 0; border: 0; border-radius: 14px; overflow: hidden; background: #0A0807; cursor: pointer; aspect-ratio: 16 / 9; }
.vid.tall .vid-frame { aspect-ratio: 9 / 16; max-height: 70vh; width: auto; margin: 0 auto; }
.vid-frame img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .82; }
.vid-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.vid-play { position: absolute; inset: 0; display: grid; place-items: center; }
.vid-play svg { width: 64px; height: 64px; padding: 16px 14px 16px 18px; border-radius: 50%; background: rgba(0, 0, 0, .7); fill: var(--iris); border: 1.5px solid rgba(255, 154, 31, .7); box-shadow: 0 0 20px rgba(255, 140, 20, .35); }
.vid-meta { display: flex; flex-direction: column; margin-top: 8px; }
.vid-title { font-size: 14px; line-height: 1.35; }
.vid-by { font-size: 13px; color: var(--ash); }
.vid-links { display: flex; gap: 18px; flex-wrap: wrap; }

/* ---------- tables ---------- */
.plain { width: 100%; border-collapse: collapse; font-size: 16px; }
.plain th, .plain td { text-align: left; padding: 11px 6px; border-bottom: 1px solid var(--whisker); vertical-align: top; }
.plain th { color: var(--ash); font-weight: 400; font-size: 14px; }
.plain td.now { color: var(--ember); font-weight: 700; }

/* ---------- test ---------- */
.tests { list-style: none; padding: 0; margin: 10px 0 0; }
.tests li { padding: 16px 0; border-bottom: 1px solid var(--whisker); }
.tests .top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.tests .name { font-weight: 700; }
.tests .std { color: var(--ash); font-size: 14px; white-space: nowrap; }
.tests .entry { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.tests input[type="number"] {
  width: 110px; min-height: 48px; padding: 0 12px; border-radius: 12px;
  background: var(--fur); border: 1.5px solid var(--whisker); color: var(--bone);
  font-family: var(--display); font-size: 26px; font-weight: 700;
}
.tests input:focus { border-color: var(--iris); outline: none; }
.tests .unit { color: var(--ash); font-size: 15px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 48px; cursor: pointer; }
.check input { width: 26px; height: 26px; accent-color: var(--iris); }
.bar { height: 6px; border-radius: 3px; background: var(--whisker); margin-top: 10px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ash); border-radius: 3px; }
.bar i.met { background: var(--iris); box-shadow: 0 0 8px var(--iris); }
.progress-note { color: var(--ash); font-size: 14px; margin-top: 6px; }
.progress-note b { color: var(--bone); }
.vidlink { background: none; border: 0; color: var(--ember); font-size: 14px; padding: 4px 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.msg { margin-top: 12px; color: var(--ember); min-height: 24px; }

/* ---------- plan ---------- */
.rules { padding-left: 22px; margin: 0; }
.rules li { margin-bottom: 12px; }
.phases { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--whisker); }
.phases li { position: relative; padding: 0 0 18px 20px; }
.phases li::before { content: ''; position: absolute; left: -7px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--night); border: 2px solid var(--ash); }
.phases li.goal::before { background: var(--iris); border-color: var(--iris); box-shadow: 0 0 10px var(--iris); }
.phases b { font-family: var(--display); font-size: 24px; font-weight: 800; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--whisker); }
.setting input[type="date"] { background: var(--fur); color: var(--bone); border: 1.5px solid var(--whisker); border-radius: 10px; padding: 8px 10px; font: inherit; }
.toggle { position: relative; width: 56px; height: 32px; border-radius: 16px; background: var(--whisker); border: 0; cursor: pointer; flex: none; }
.toggle::after { content: ''; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--ash); transition: transform .15s; }
.toggle[aria-checked="true"] { background: rgba(255, 154, 31, .35); }
.toggle[aria-checked="true"]::after { transform: translateX(24px); background: var(--iris); }

/* ---------- player ---------- */
#player { position: fixed; inset: 0; z-index: 50; background: var(--night); display: flex; flex-direction: column; }
#player[hidden] { display: none; }
.p-head { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; padding: max(8px, env(safe-area-inset-top)) 8px 6px; }
.icon { width: 48px; height: 48px; display: grid; place-items: center; background: none; border: 0; color: var(--ash); cursor: pointer; border-radius: 50%; }
.icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon[disabled] { opacity: .25; }
.p-where { text-align: center; line-height: 1.2; }
.p-where b { display: block; font-family: var(--display); font-size: 21px; font-weight: 800; }
.p-where span { color: var(--ash); font-size: 14px; }
.p-bar { height: 3px; background: var(--whisker); margin: 0 16px; border-radius: 2px; overflow: hidden; }
.p-bar i { display: block; height: 100%; background: var(--iris); box-shadow: 0 0 8px var(--iris); transition: width .3s; }
.p-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 18px 18px; max-width: 560px; width: 100%; margin: 0 auto; }
.p-life { color: var(--ash); font-size: 15px; display: flex; gap: 8px; align-items: center; }
.p-life .marks { margin: 0; }
.p-name { font-size: clamp(32px, 9vw, 42px); font-weight: 800; margin: 6px 0 4px; line-height: 1.02; }
.p-setline { color: var(--bone); font-size: 18px; margin-top: 14px; }
.big { font-family: var(--display); font-weight: 900; font-size: clamp(96px, 30vw, 150px); line-height: .9; letter-spacing: -.01em; margin: 6px 0 0; font-variant-numeric: tabular-nums; }
.big.running { color: var(--ember); text-shadow: 0 0 26px rgba(255, 140, 20, .45); }
.big-unit { color: var(--ash); font-size: 18px; margin-top: 4px; }
.seglist { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.seglist li { padding: 5px 10px; border-radius: 10px; border: 1px solid var(--whisker); color: var(--ash); font-size: 14px; }
.seglist li.now { color: #000; background: var(--iris); border-color: var(--iris); }
.seglist li.past { opacity: .4; }
.showdemo { margin-top: 14px; }
.p-foot { padding: 10px 18px calc(14px + var(--safe-b)); max-width: 560px; width: 100%; margin: 0 auto; }
.p-foot .sec { display: flex; justify-content: space-between; margin-top: 6px; }
.light-tag { display: inline-block; margin-top: 10px; font-size: 14px; color: var(--ember); }
.best { color: var(--ash); margin-top: 8px; }
.best b { color: var(--bone); }
.newbest { color: var(--iris); font-weight: 700; }

/* rest overlay */
.rest { position: absolute; inset: 0; z-index: 2; background: var(--night); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 22px calc(24px + var(--safe-b)); text-align: center; }
.rest .label { font-family: var(--display); font-size: 30px; font-weight: 800; color: var(--ash); }
.ring { position: relative; width: min(340px, 88vw); margin: 10px 0 6px; }
.ring svg { width: 100%; height: auto; display: block; overflow: visible; }
.ring .track { fill: none; stroke: var(--whisker); stroke-width: 3; }
.ring .prog { fill: none; stroke: var(--iris); stroke-width: 4; stroke-linecap: round; filter: drop-shadow(0 0 6px rgba(255, 140, 20, .7)); transition: stroke-dashoffset .2s linear; }
.ring .digits { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-weight: 900; font-size: clamp(80px, 26vw, 120px); color: var(--ember); font-variant-numeric: tabular-nums; }
.rest .next { color: var(--ash); margin: 8px 0 22px; max-width: 420px; }
.rest .next b { color: var(--bone); }
.rest .row { width: 100%; max-width: 420px; }

/* sheets */
.sheet-back { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .7); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; background: var(--fur); border-radius: 22px 22px 0 0; border-top: 1px solid var(--whisker); padding: 20px 18px calc(20px + var(--safe-b)); max-height: 88vh; overflow-y: auto; }
.sheet h3 { margin-bottom: 12px; }
.sheet .btn + .btn { margin-top: 10px; }

/* finish */
.finish h1 { font-size: 64px; font-weight: 900; margin-top: 10px; }
.stats { display: flex; gap: 22px; margin: 14px 0 6px; }
.stats div b { display: block; font-family: var(--display); font-size: 44px; font-weight: 900; color: var(--ember); line-height: 1; }
.stats div span { color: var(--ash); font-size: 14px; }
.gatecheck { display: flex; gap: 12px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--whisker); cursor: pointer; }
.gatecheck input { width: 26px; height: 26px; margin-top: 2px; accent-color: var(--iris); flex: none; }
.gatecheck b { font-family: var(--display); font-size: 21px; font-weight: 800; display: block; }

@media (prefers-reduced-motion: reduce) {
  .lid { animation: none; }
  .btn, .p-bar i, .ring .prog, .toggle::after { transition: none; }
}
@media (min-width: 700px) {
  h1 { font-size: 64px; }
}
