/* Base rules that the original host page supplied around the app. Kept so the layout is unchanged. */
:root { color-scheme: light; box-sizing: border-box; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body { margin: 0; padding: 0; }
img { max-width: 100%; }
[hidden]:not([hidden="until-found" i]) { display: none !important; }

/* Layout: one phone column. Sticky date bar on top, the day's lifts as stacked set tables, fixed three-tab bar at the thumb.
   Split colors borrow the bumper-plate code: red, blue, yellow, green. */
:root {
  --bg: #eceef2; --surface: #ffffff; --sunk: #f3f4f7; --ink: #151a22; --muted: #5b6472; --line: #d3d8e0;
  --red: #c4302a; --blue: #2253c0; --amber: #a86e00; --green: #2a7a4b; --on-color: #ffffff;
  --display: "Barlow Condensed", "IBM Plex Sans KR", system-ui, sans-serif;
  --body: "IBM Plex Sans KR", system-ui, -apple-system, "Malgun Gothic", sans-serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0f1217; --surface: #191e26; --sunk: #12161c; --ink: #e8ebf0; --muted: #98a1ae; --line: #2b323d;
  --red: #f0695e; --blue: #729ef6; --amber: #e2b23f; --green: #5ec088; --on-color: #0f1217; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #0f1217; --surface: #191e26; --sunk: #12161c; --ink: #e8ebf0; --muted: #98a1ae; --line: #2b323d;
  --red: #f0695e; --blue: #729ef6; --amber: #e2b23f; --green: #5ec088; --on-color: #0f1217; color-scheme: dark }

* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.45; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--sc, var(--blue)); outline-offset: 2px; }
[data-split="cs"] { --sc: var(--red); } [data-split="ba"] { --sc: var(--blue); }
[data-split="lg"] { --sc: var(--amber); } [data-split="rest"] { --sc: var(--green); }

body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9; background: var(--bg); border-bottom: 1px solid var(--line); }
.wrap { max-width: 560px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.top .wrap { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-block: 10px; }
.top h1 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 26px; letter-spacing: .01em; line-height: 1; }
.top .date { color: var(--muted); font-size: 13px; }
.timer { font-family: var(--display); font-weight: 600; font-size: 20px; font-variant-numeric: tabular-nums; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
main.wrap { padding-block: 14px 110px; display: flex; flex-direction: column; gap: 14px; }

.cycle { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.cycle button { min-height: 48px; padding: 4px 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-weight: 500; font-size: 13px; border-bottom: 4px solid var(--sc); }
.cycle button[aria-pressed="true"] { background: var(--sc); color: var(--on-color); border-color: var(--sc); font-weight: 600; }
.cycle button:disabled { opacity: .55; cursor: default; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }

.ex { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.ex h2 { margin: 0; font-size: 17px; font-weight: 600; text-wrap: balance; }
.ex .prev { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.sets { display: grid; grid-template-columns: 28px 1fr 1fr 52px; gap: 6px 8px; align-items: center; }
.sets .lab { color: var(--muted); font-size: 11px; letter-spacing: .06em; text-align: center; }
.sets .n { font-family: var(--display); font-weight: 600; font-size: 20px; color: var(--muted); text-align: center; }
.sets input { width: 100%; min-width: 0; height: 46px; text-align: center; font-family: var(--display); font-weight: 600; font-size: 24px; font-variant-numeric: tabular-nums; background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; }
.sets input::placeholder { color: var(--muted); opacity: .6; font-weight: 500; }
.sets .ok { height: 46px; border: 1px solid var(--line); border-radius: 8px; background: var(--sunk); font-size: 20px; color: var(--muted); }
.sets .ok[aria-pressed="true"] { background: var(--sc); border-color: var(--sc); color: var(--on-color); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-weight: 500; }
.btn.small { min-height: 36px; padding: 0 10px; font-size: 13px; color: var(--muted); }
.btn.primary { background: var(--sc, var(--ink)); border-color: var(--sc, var(--ink)); color: var(--on-color); font-weight: 600; }
.btn.primary:disabled { opacity: .4; cursor: default; }
.btn.wide { width: 100%; min-height: 52px; font-size: 16px; }
.btn.danger { color: var(--red); }
.text-in { flex: 1; min-width: 0; height: 44px; padding: 0 12px; font-size: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card h2 { margin: 0; font-size: 18px; font-weight: 600; }
.card p { margin: 0; color: var(--muted); }
.big { font-family: var(--display); font-weight: 700; font-size: 40px; line-height: 1; color: var(--sc); }
.stats { display: flex; gap: 20px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.stats b { display: block; font-family: var(--display); font-size: 26px; font-weight: 600; line-height: 1.1; }
.stats span { color: var(--muted); font-size: 12px; }

.sess { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--sc); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.sess header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sess .d { font-family: var(--display); font-weight: 600; font-size: 20px; }
.sess .sp { color: var(--sc); font-weight: 600; font-size: 14px; }
.sess .meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.sess dl { margin: 0; display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 3px 10px; font-size: 13px; }
.sess dt { font-weight: 500; } .sess dd { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }

.sec h2 { margin: 0 0 8px; font-size: 16px; font-weight: 600; color: var(--sc); }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.list .item { display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 12px; border-bottom: 1px solid var(--line); }
.list .item span { flex: 1; min-width: 0; }
.list .item button { width: 40px; height: 40px; color: var(--muted); font-size: 16px; border-radius: 6px; }
.list .item button:disabled { opacity: .25; cursor: default; }
.list form { display: flex; gap: 8px; padding: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { min-width: 56px; min-height: 40px; background: var(--surface); font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.tabs .wrap { display: grid; grid-template-columns: repeat(5, 1fr); }
.chips .btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.goal { font-size: 13px; font-weight: 500; margin-top: 2px; }
.trend { display: flex; flex-direction: column; gap: 6px; border-block: 1px solid var(--line); padding-block: 8px; }
.trend svg { width: 100%; height: auto; display: block; font-family: var(--body); font-variant-numeric: tabular-nums; }
.trend svg circle:focus-visible { outline: 2px solid var(--sc); }
.trend h4 { margin: 0; font-size: 12px; font-weight: 500; color: var(--muted); }
.trend .tip { margin: 0; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.trend dl { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); gap: 3px 10px; font-size: 13px; }
.trend dd { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.wk { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.wk th { font-size: 11px; font-weight: 500; color: var(--muted); text-align: left; padding: 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.wk td { padding: 7px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.wk th:nth-child(n+3), .wk td:nth-child(n+3) { text-align: right; }
.wk tr:last-child td { border-bottom: 0; }
.chk ul { margin: 0; padding-left: 18px; font-size: 14px; }
.chk h4 { margin: 4px 0 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.chk p { margin: 0; font-size: 14px; }
.diet { --sc: var(--green); display: flex; flex-direction: column; gap: 14px; }
.daynav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.daynav .d { font-family: var(--display); font-weight: 600; font-size: 24px; }
.daynav button { width: 48px; height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 18px; }
.daynav button:disabled { opacity: .3; cursor: default; }
.meter { display: flex; flex-direction: column; gap: 4px; font-variant-numeric: tabular-nums; }
.meter .v { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; color: var(--muted); font-size: 13px; }
.meter .v b { font-family: var(--display); font-weight: 600; font-size: 26px; line-height: 1.1; color: var(--ink); }
.bar { height: 8px; background: var(--sunk); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--sc); }
.mac { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mac label { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--muted); min-width: 0; }
.mac input { width: 100%; min-width: 0; height: 44px; text-align: center; font-size: 16px; font-variant-numeric: tabular-nums; background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; }
.seg.full { display: grid; grid-template-columns: repeat(4, 1fr); }
.seg.full button { min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.slot h3 { margin: 0 0 6px; font-size: 14px; font-weight: 600; display: flex; justify-content: space-between; }
.slot h3 span { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.list .item small { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.list .item:last-child { border-bottom: 0; }
.tabs button { height: 56px; font-weight: 500; color: var(--muted); border-top: 3px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; border-top-color: var(--ink); }
.note { font-size: 13px; color: var(--muted); background: var(--sunk); border: 1px dashed var(--line); border-radius: 8px; padding: 8px 12px; }
.note.err { color: var(--red); border-color: var(--red); }

/* Standalone additions: storage notice, backup card, import confirmation. Same tokens as everything above. */
.note.store { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding-block: 10px; }
.note.store .btn { color: var(--ink); }
.note.ok { margin: 0; color: var(--ink); border-style: solid; border-left: 5px solid var(--green); }
.backup { scroll-margin-top: 72px; }
.backup .last { color: var(--ink); font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; border-left: 5px solid var(--amber); padding: 2px 0 2px 10px; }
.backup .last.done { border-left-color: var(--green); }
.backup .pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.backup .confirm { display: flex; flex-direction: column; gap: 8px; background: var(--sunk); border: 1px solid var(--red); border-left-width: 5px; border-radius: 8px; padding: 12px; }
.backup .confirm .warn { color: var(--ink); font-weight: 600; }
.backup .confirm .file { font-size: 13px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.backup .confirm .row .btn { flex: 1 1 auto; }
.btn.danger.solid { background: var(--red); border-color: var(--red); color: var(--on-color); font-weight: 600; }
