:root {
  --bg: #0d1015; --card: #161a21; --card2: #1d222b; --line: #262c37; --txt: #eef2f7; --mut: #8b95a5; --dim: #5b6474;
  --lime: #c8f23c; --orange: #ff7a45; --sky: #4cc9f0; --violet: #a78bfa; --pink: #f472b6; --teal: #2dd4bf; --gold: #fbbf24; --gray: #6b7280; --red: #ff5a5f;
  --acc: var(--lime); --floor: #3a4252;
  --r: 18px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--txt); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
body { overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, select { font: inherit; color: var(--txt); background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
.num { font-variant-numeric: tabular-nums; }
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; }
#view { padding: calc(var(--safe-t) + 16px) 16px calc(96px + var(--safe-b)); }
#view > * { animation: rise .45s cubic-bezier(.2, .8, .2, 1) both; }
#view > *:nth-child(2) { animation-delay: .04s } #view > *:nth-child(3) { animation-delay: .08s } #view > *:nth-child(4) { animation-delay: .12s } #view > *:nth-child(5) { animation-delay: .16s } #view > *:nth-child(n+6) { animation-delay: .2s }
@keyframes rise { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: none } }

/* tabs */
#tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: center; gap: 2px; padding: 8px 8px calc(8px + var(--safe-b)); background: rgba(13, 16, 21, .88); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
#tabs button { flex: 1; max-width: 110px; display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--mut); padding: 4px 0; border-radius: 12px; transition: color .2s; }
#tabs button span { font-size: 20px; filter: grayscale(1) opacity(.6); transition: .25s; }
#tabs button.on { color: var(--txt); }
#tabs button.on span { filter: none; transform: translateY(-2px) scale(1.12); }

/* common */
.hdr { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 14px; }
.hdr h1 { font-size: 26px; }
.sub { color: var(--mut); font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 12px; }
.card h3 { font-size: 15px; margin-bottom: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 18px; border-radius: 14px; font-weight: 700; background: var(--card2); border: 1px solid var(--line); transition: transform .12s; }
.btn:active { transform: scale(.96); }
.btn.pri { background: var(--acc); color: #111; border: 0; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 99px; background: var(--card2); border: 1px solid var(--line); font-size: 12px; color: var(--mut); white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bar { height: 8px; border-radius: 99px; background: var(--card2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--acc); transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: color-mix(in srgb, var(--c, var(--acc)) 18%, transparent); color: var(--c, var(--acc)); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--mut); }
.warn { background: color-mix(in srgb, var(--gold) 12%, var(--card)); border-color: color-mix(in srgb, var(--gold) 35%, var(--line)); }
.small { font-size: 13px; }
ul.clean { margin: 6px 0 0; padding-left: 18px; } ul.clean li { margin: 3px 0; }

/* rig */
.rig { width: 100%; height: auto; display: block; }
.rig line { stroke-linecap: round; transition: none; }
.rig .body line, .rig .near line { stroke: var(--txt); }
.rig .far line { stroke: #667183; }
.rig .head { fill: var(--txt); }
.rig .floor { stroke: #3a4252; stroke-width: 2; }
.rig .prop { fill: #8a6b4a; } .rig .faint { opacity: .35; }
.rig .propbar { stroke: #b8c0cc; stroke-width: 6; stroke-linecap: round; }
.rig .shadow { fill: #000; opacity: .5; }
.rig.hot .near line, .rig.hot .body line, .rig.hot .head { stroke: var(--acc); fill: var(--acc); }
.rig.hot .body line { stroke: var(--acc); }

/* home */
.hello { font-size: 13px; color: var(--mut); }
.today { position: relative; overflow: hidden; border-radius: 22px; padding: 18px; margin-bottom: 12px; background: radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--c) 30%, transparent), transparent 60%), var(--card); border: 1px solid color-mix(in srgb, var(--c) 35%, var(--line)); }
.today .ttl { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 2px; }
.today .fig { position: absolute; right: -8px; top: 8px; width: 150px; opacity: .95; pointer-events: none; }
.today .meta { display: flex; gap: 14px; margin: 10px 0 14px; color: var(--mut); font-size: 13px; }
.today .meta b { color: var(--txt); font-size: 18px; display: block; }
.today .done { color: var(--lime); font-weight: 700; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.dayc { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; border-radius: 12px; background: var(--card2); border: 1px solid transparent; font-size: 11px; color: var(--mut); position: relative; }
.dayc .ic { font-size: 17px; }
.dayc.today { border-color: var(--acc); color: var(--txt); }
.dayc.done::after { content: '✓'; position: absolute; top: -5px; right: -3px; background: var(--lime); color: #111; width: 16px; height: 16px; border-radius: 50%; font-size: 10px; font-weight: 800; display: grid; place-items: center; }
.dayc.past:not(.done) { opacity: .45; }
.goal { margin: 10px 0; }
.goal .row { margin-bottom: 5px; font-size: 13px; }
.goal b { font-size: 15px; }
.habit { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.habit:first-of-type { border-top: 0; }
.habit .hx { flex: 1; font-size: 14px; }
.habit .hx small { display: block; color: var(--mut); font-size: 12px; }
.tick { width: 30px; height: 30px; border-radius: 10px; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 800; transition: .2s; }
.tick.on { background: var(--lime); border-color: var(--lime); color: #111; transform: scale(1.05); }
.dots { display: flex; gap: 4px; } .dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--card2); border: 1px solid var(--line); } .dots i.on { background: var(--lime); border-color: var(--lime); }

/* plan */
.wk { margin-bottom: 10px; }
.wk .wkh { display: flex; justify-content: space-between; font-size: 12px; color: var(--mut); margin: 0 2px 6px; }
.wk .wkh b { color: var(--txt); }
.phase { border-left: 3px solid var(--c); padding: 2px 0 2px 12px; margin: 10px 0; }
.phase b { display: block; }

/* library */
.libgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.lib { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 8px 10px 10px; text-align: left; }
.lib .nm { font-weight: 700; font-size: 14px; } .lib .en { font-size: 11px; color: var(--mut); }
.cats { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; scrollbar-width: none; }
.cats button { padding: 7px 12px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); font-size: 13px; white-space: nowrap; color: var(--mut); }
.cats button.on { background: var(--acc); color: #111; border-color: var(--acc); font-weight: 700; }

/* progress */
.chart { width: 100%; height: 120px; display: block; }
.chart .ln { fill: none; stroke: var(--c, var(--acc)); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .ar { fill: color-mix(in srgb, var(--c, var(--acc)) 15%, transparent); }
.chart .pt { fill: var(--bg); stroke: var(--c, var(--acc)); stroke-width: 2; }
.chart text { fill: var(--mut); font-size: 10px; }
.chart .gl { stroke: var(--line); stroke-dasharray: 3 4; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th, table.t td { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: center; }
table.t th { color: var(--mut); font-weight: 600; font-size: 11px; }
.stat { background: var(--card2); border-radius: 14px; padding: 12px; }
.stat b { font-size: 22px; display: block; } .stat span { color: var(--mut); font-size: 12px; }

/* settings */
.field { margin-bottom: 12px; } .field label { display: block; font-size: 12px; color: var(--mut); margin-bottom: 5px; }
.seg { display: flex; background: var(--card2); border-radius: 12px; padding: 3px; border: 1px solid var(--line); }
.seg button { flex: 1; padding: 8px 4px; border-radius: 9px; font-size: 13px; color: var(--mut); }
.seg button.on { background: var(--acc); color: #111; font-weight: 700; }
.sw { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); gap: 10px; }
.sw:first-of-type { border-top: 0; }
.sw small { display: block; color: var(--mut); font-size: 12px; }
.tog { width: 50px; height: 30px; border-radius: 99px; background: var(--card2); border: 1px solid var(--line); position: relative; flex: none; transition: .2s; }
.tog::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--mut); transition: .25s cubic-bezier(.3, 1.4, .5, 1); }
.tog.on { background: var(--acc); border-color: var(--acc); } .tog.on::after { left: 23px; background: #111; }
.stepper { display: inline-flex; align-items: center; gap: 2px; background: var(--card2); border-radius: 10px; border: 1px solid var(--line); }
.stepper button { width: 32px; height: 32px; font-size: 18px; color: var(--mut); }
.stepper b { min-width: 36px; text-align: center; font-size: 14px; }

/* sheet (bottom modal) */
#sheet-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .55); opacity: 0; pointer-events: none; transition: opacity .25s; }
#sheet-wrap.on { opacity: 1; pointer-events: auto; }
#sheet { position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; max-height: 90vh; overflow-y: auto; background: var(--card); border-radius: 24px 24px 0 0; padding: 10px 16px calc(20px + var(--safe-b)); transform: translateY(100%); transition: transform .35s cubic-bezier(.2, .9, .2, 1); }
#sheet-wrap.on #sheet { transform: none; }
#sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 12px; }
.item { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.item .th { width: 64px; flex: none; background: var(--card2); border-radius: 10px; }
.item .ix { flex: 1; min-width: 0; }
.item .ix b { display: block; font-size: 14px; }
.item .ix small { color: var(--mut); }
.secname { font-size: 12px; font-weight: 700; color: var(--acc); text-transform: uppercase; letter-spacing: .06em; margin: 14px 0 4px; }

/* toast */
#toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translate(-50%, 20px); background: var(--txt); color: #111; padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; opacity: 0; transition: .3s; z-index: 90; pointer-events: none; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ============ player ============ */
#overlay { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: none; flex-direction: column; overflow: hidden; }
#overlay.on { display: flex; animation: ovIn .35s ease both; }
@keyframes ovIn { from { opacity: 0; transform: scale(1.04) } to { opacity: 1; transform: none } }
.pl-top { padding: calc(var(--safe-t) + 10px) 16px 8px; display: flex; align-items: center; gap: 10px; }
.pl-top .x { width: 38px; height: 38px; border-radius: 12px; background: var(--card); font-size: 18px; }
.pl-top .sec { flex: 1; font-size: 12px; color: var(--mut); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.pl-top .clock { font-size: 14px; color: var(--mut); }
.segs { display: flex; gap: 3px; padding: 0 16px; }
.segs i { flex: 1; height: 4px; border-radius: 4px; background: var(--card2); overflow: hidden; position: relative; }
.segs i.done { background: var(--acc); }
.segs i.cur::after { content: ''; position: absolute; inset: 0; width: var(--p, 0%); background: var(--acc); }
.pl-body { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; padding: 0 8px; }
.stage .rig { max-height: 100%; width: auto; max-width: 100%; }
.stage .rigbox { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.stage .rigbox svg { width: 100%; height: 100%; }
.pl-info { text-align: center; padding: 0 16px; }
.pl-info .exn { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.pl-info .setl { color: var(--mut); font-size: 14px; margin-top: 2px; }
.cue { color: var(--mut); font-size: 13px; min-height: 20px; margin-top: 6px; transition: opacity .3s; }
.big { display: flex; align-items: center; justify-content: center; margin: 10px 0 6px; position: relative; height: 128px; }
.ring { width: 128px; height: 128px; transform: rotate(-90deg); position: absolute; }
.ring circle { fill: none; stroke-width: 9; }
.ring .bg { stroke: var(--card2); } .ring .fg { stroke: var(--acc); stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.big .val { font-size: 46px; font-weight: 800; position: relative; letter-spacing: -.03em; }
.big .val small { font-size: 20px; color: var(--mut); font-weight: 600; }
.pop { animation: pop .3s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { 0% { transform: scale(1.35) } 100% { transform: scale(1) } }
.pl-ctl { display: flex; gap: 10px; padding: 8px 16px calc(16px + var(--safe-b)); align-items: center; }
.pl-ctl .btn { flex: 1; padding: 16px; font-size: 16px; }
.pl-ctl .ic { flex: none; width: 56px; height: 56px; padding: 0; font-size: 20px; }
.tapzone { position: absolute; inset: 0; }
.stage .hint { position: absolute; bottom: 6px; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--dim); }

/* rest mode */
#overlay.rest { --acc: var(--sky); }
.restview { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 20px; gap: 6px; }
.restview h2 { font-size: 20px; color: var(--sky); text-transform: uppercase; letter-spacing: .1em; }
.restview .big { height: 180px; } .restview .ring { width: 180px; height: 180px; }
.restview .big .val { font-size: 60px; }
.next { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 10px 14px; display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.next .th { width: 110px; flex: none; }
.next .nx small { color: var(--mut); text-transform: uppercase; font-size: 11px; letter-spacing: .06em; font-weight: 700; }
.next .nx b { display: block; font-size: 18px; }
.logreps { display: flex; align-items: center; gap: 12px; margin-top: 10px; font-size: 14px; color: var(--mut); }

/* slide transitions */
.slide-in { animation: slideIn .45s cubic-bezier(.2, .9, .2, 1) both; }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px) } to { opacity: 1; transform: none } }
.flash { animation: flash .6s ease; }
@keyframes flash { 0% { background: color-mix(in srgb, var(--acc) 25%, var(--bg)) } 100% { background: var(--bg) } }
.banner { position: absolute; inset: 0; display: grid; place-items: center; z-index: 5; background: var(--bg); animation: bannerOut 1.6s ease forwards; pointer-events: none; }
.banner div { text-align: center; } .banner small { color: var(--mut); text-transform: uppercase; letter-spacing: .12em; font-size: 12px; } .banner b { display: block; font-size: 30px; margin-top: 4px; animation: slideIn .5s both; }
@keyframes bannerOut { 0%, 70% { opacity: 1 } 100% { opacity: 0 } }

/* finish */
.finish { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 20px; gap: 14px; text-align: center; }
.finish .trophy { font-size: 64px; animation: pop .6s cubic-bezier(.3, 1.6, .5, 1); }
.finish h1 { font-size: 28px; }
.rpe { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rpe button { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 4px; font-size: 13px; }
.rpe button span { display: block; font-size: 26px; }
.rpe button.on { border-color: var(--acc); background: color-mix(in srgb, var(--acc) 15%, var(--card)); }
.confetti { position: fixed; top: -10px; width: 8px; height: 14px; z-index: 70; animation: fall linear forwards; border-radius: 2px; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }

/* test */
.counter { width: 170px; height: 170px; border-radius: 50%; background: var(--acc); color: #111; font-size: 64px; font-weight: 800; display: grid; place-items: center; box-shadow: 0 0 0 10px color-mix(in srgb, var(--acc) 18%, transparent); transition: transform .08s; }
.counter:active { transform: scale(.94); }
.counter small { display: block; font-size: 13px; font-weight: 600; margin-top: -40px; }
