/* Solitary OS styles. Colors live in variables so light/dark mode swap in one place. */
:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #ecebe7;
  --line: #dddcd6;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #eb6834;      /* orange: brand accent, buttons */
  --accent-ink: #ffffff;
  --good: #1a7f37;
  --warn: #b26a00;
  --bad: #c62828;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --heat-0: #ecebe7;
  --heat-1: #86b6ef;
  --heat-2: #2a78d6;
  --heat-3: #184f95;
  --grid: rgba(0,0,0,.08);
  --radius: 14px;
  --tabbar-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111214;
    --surface: #1a1a19;
    --surface-2: #252523;
    --line: #333331;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e88;
    --accent: #f07a45;
    --accent-ink: #111214;
    --good: #4cc26b;
    --warn: #e0a030;
    --bad: #ef6b6b;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --heat-0: #252523;
    --heat-1: #184f95;
    --heat-2: #3987e5;
    --heat-3: #9ec5f4;
    --grid: rgba(255,255,255,.08);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111214; --surface: #1a1a19; --surface-2: #252523; --line: #333331;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e88; --accent: #f07a45; --accent-ink: #111214;
  --good: #4cc26b; --warn: #e0a030; --bad: #ef6b6b;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9;
  --heat-0: #252523; --heat-1: #184f95; --heat-2: #3987e5; --heat-3: #9ec5f4; --grid: rgba(255,255,255,.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* ---------- top + bottom bars ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; letter-spacing: .02em; font-size: 18px; }
.brand b { color: var(--accent); }
.syncbadge {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; color: var(--text-2); cursor: pointer;
}
.syncbadge.ok { color: var(--good); }
.syncbadge.wait { color: var(--warn); }
.syncbadge.err { color: var(--bad); }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 12px;
}
.tabbar a .ti { font-size: 20px; line-height: 1; }
.tabbar a.active { color: var(--accent); }
body.in-workout .tabbar { display: none; }
body.in-workout { padding-bottom: 120px; }

/* ---------- layout ---------- */
.view { max-width: 720px; margin: 0 auto; padding: 16px; }
h1 { font-size: 26px; margin: 4px 0 2px; line-height: 1.15; }
h2 { font-size: 19px; margin: 24px 0 10px; }
h3 { font-size: 16px; margin: 0 0 4px; }
.sub { color: var(--text-2); margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin: 0 0 12px;
}
.card.tap { cursor: pointer; }
.card.done { border-color: color-mix(in srgb, var(--good) 55%, var(--line)); }
.card .kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; }
.pill {
  display: inline-block; font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.pill.good { color: var(--good); }
.pill.accent { color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); cursor: pointer; font-weight: 600;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; font-weight: 500; }
.btn:disabled { opacity: .5; }

label.f { display: block; font-size: 13px; color: var(--text-2); margin: 0 0 10px; }
label.f input, label.f select, label.f textarea { margin-top: 4px; }
input[type=text], input[type=number], input[type=date], input[type=password], input[type=url], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); font-size: 17px;
}
textarea { min-height: 70px; }

/* ---------- week strip ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 8px 0 16px; }
.week .d { text-align: center; padding: 8px 0; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.week .d b { display: block; font-size: 15px; color: var(--text); }
.week .d.today { border-color: var(--accent); }
.week .dots { display: flex; justify-content: center; gap: 3px; margin-top: 4px; min-height: 8px; }
.week .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.week .dot.on { background: var(--good); }

/* ---------- workout screen ---------- */
.wohead { position: sticky; top: 57px; z-index: 15; background: var(--bg); padding: 8px 0 10px; }
.extabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.extabs::-webkit-scrollbar { display: none; }
.extab {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 6px 10px; font-size: 13px; cursor: pointer; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.extab.cur { border-color: var(--accent); color: var(--accent); }
.extab.full { color: var(--good); }

.setrow { display: grid; grid-template-columns: 34px 1fr 1fr 56px; gap: 8px; align-items: center; margin-bottom: 8px; }
.setrow .n { color: var(--muted); text-align: center; font-weight: 600; }
.setrow input { text-align: center; font-size: 20px; min-height: 52px; padding: 6px; }
.setrow .chk {
  height: 52px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface);
  font-size: 22px; cursor: pointer; color: var(--muted);
}
.setrow.logged .chk { background: var(--good); border-color: var(--good); color: #fff; }
.setrow.logged input { border-color: color-mix(in srgb, var(--good) 50%, var(--line)); }
.sethead { display: grid; grid-template-columns: 34px 1fr 1fr 56px; gap: 8px; font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 4px; }

.hint { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 8px 0 12px; }
.hint.up { border-left: 4px solid var(--good); }

.circles { display: flex; gap: 8px; flex-wrap: wrap; }
.circle {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface);
  cursor: pointer; font-weight: 600; color: var(--muted);
}
.circle.on { background: var(--good); border-color: var(--good); color: #fff; }

.checkitem { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.checkitem:last-child { border-bottom: 0; }
.checkitem .box { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 8px; border: 2px solid var(--line); display: grid; place-items: center; cursor: pointer; }
.checkitem.on .box { background: var(--good); border-color: var(--good); color: #fff; }

.restbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 12px); z-index: 40;
  background: var(--text); color: var(--bg); border-radius: 16px; padding: 10px 12px;
  display: flex; align-items: center; gap: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
.restbar .t { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 80px; }
.restbar button { background: transparent; color: inherit; border: 1px solid currentColor; border-radius: 10px; min-height: 40px; padding: 0 10px; opacity: .85; }
.restbar.done { background: var(--good); color: #fff; }
.restbar.over { background: var(--bad); color: #fff; }
.pacebar { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.pacebar.idle { color: var(--text-2); font-size: 13px; }
.pacebar.good { border-color: color-mix(in srgb, var(--good) 50%, var(--line)); }
.pacebar.warn { border-color: var(--warn); }
.pacebar.bad { border-color: var(--bad); }
.pacebar.bad .small:last-child { color: var(--bad); }
.pacebar .track { position: relative; height: 8px; border-radius: 4px; background: var(--surface-2); margin: 8px 0 6px; }
.pacebar .track i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--good); }
.pacebar.warn .track i { background: var(--warn); }
.pacebar.bad .track i { background: var(--bad); }
.pacebar .track b { position: absolute; top: -3px; width: 2px; height: 14px; background: var(--text); transform: translateX(-1px); }

.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; }
.modal .sheet {
  background: var(--surface); width: 100%; max-width: 720px; max-height: 88vh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px);
}
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  z-index: 60; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px);
}

/* ---------- stats ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.tile .v { font-size: 26px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.tile .d { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.chartbox { position: relative; height: 220px; }
.chartbox.short { height: 170px; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; overflow-x: auto; }
.heat i { display: block; width: 16px; height: 16px; border-radius: 4px; background: var(--heat-0); }
.heat i.h1 { background: var(--heat-1); } .heat i.h2 { background: var(--heat-2); } .heat i.h3 { background: var(--heat-3); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; background: var(--c); vertical-align: -1px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t td, table.t th { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; }
table.t th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
table.t td.num { text-align: right; font-variant-numeric: tabular-nums; }
details.more summary { cursor: pointer; color: var(--text-2); font-size: 14px; padding: 6px 0; }

.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 8px; min-height: 36px; cursor: pointer; color: var(--text-2); }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.1); }

@media (min-width: 560px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
}
