:root {
  --bg: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --card2: #f2f2f7;
  --text: var(--tg-theme-text-color, #000000);
  --hint: #6c6c70;
  --line: #e5e5ea;
  --track: #e5e5ea;
  --accent: var(--tg-theme-button-color, #2481cc);
  --on-accent: var(--tg-theme-button-text-color, #ffffff);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --good: #1f9d55;
  --warn: #c25e00;
  --warn-soft: rgba(255, 149, 0, 0.14);
  --bad: #d70015;
  --miss: #ffd8d3;
  --empty: #f6f8fa;
  --h0: #ebedf0; --h1: #9be9a8; --h2: #40c463; --h3: #30a14e; --h4: #216e39;
  --bar: #b9d6ef;
  color-scheme: light;
}
:root[data-scheme="dark"] {
  --bg: var(--tg-theme-secondary-bg-color, #000000);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #1c1c1e));
  --card2: rgba(255, 255, 255, 0.07);
  --text: var(--tg-theme-text-color, #ffffff);
  --hint: #a1a1a8;
  --line: rgba(255, 255, 255, 0.09);
  --track: rgba(255, 255, 255, 0.14);
  --accent: var(--tg-theme-button-color, #5aa9ff);
  --good: #32d74b;
  --warn: #ff9f0a;
  --warn-soft: rgba(255, 159, 10, 0.16);
  --bad: #ff6961;
  --miss: #4a2422;
  --empty: rgba(255, 255, 255, 0.04);
  --h0: rgba(255, 255, 255, 0.08); --h1: #0e4429; --h2: #006d32; --h3: #26a641; --h4: #39d353;
  --bar: #2f4b66;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; padding: 0; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, p { margin: 0; }

.app { min-height: 100vh; display: flex; flex-direction: column; }
.content {
  flex: 1; display: flex; flex-direction: column; gap: 14px;
  padding: calc(14px + var(--tg-content-safe-area-inset-top, 0px)) 16px calc(96px + env(safe-area-inset-bottom));
  max-width: 560px; width: 100%; margin: 0 auto;
}
.screen { display: flex; flex-direction: column; gap: 14px; animation: rise .28s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 6px 4px 2px; }
.header .date { font-size: 13px; font-weight: 500; color: var(--hint); }
.header h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.6px; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 7px 12px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); font-weight: 700; font-size: 15px; }

.card { background: var(--card); border-radius: 22px; }
.card.pad { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-head h2, .card h2 { font-size: 17px; font-weight: 700; }
.muted { color: var(--hint); font-size: 13px; }
.list { display: flex; flex-direction: column; overflow: hidden; }
.list > .card-head { padding: 16px 18px 8px; }
.row { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-top: 1px solid var(--line); }
.row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row .title { font-size: 16px; font-weight: 600; transition: opacity .2s; }
.row.is-done .title { text-decoration: line-through; opacity: .55; }
.empty { padding: 4px 18px 18px; color: var(--hint); font-size: 14px; line-height: 1.45; }

.summary { display: flex; align-items: center; gap: 18px; padding: 18px; }
.summary .headline { font-size: 18px; font-weight: 700; line-height: 1.25; }
.summary .sub { font-size: 14px; line-height: 1.4; color: var(--hint); margin-top: 6px; }
.ring-arc { transition: stroke-dasharray .5s cubic-bezier(.2,.8,.2,1); }

.check {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--track); display: flex; align-items: center; justify-content: center;
  transition: background .2s, border-color .2s, transform .15s;
}
.check:active { transform: scale(.9); }
.check.on { background: var(--good); border-color: var(--good); }
.check.skip { border-style: dashed; }
.check svg { opacity: 0; transform: scale(.5); transition: all .2s; }
.check.on svg { opacity: 1; transform: none; }
.box { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--track); display: flex; align-items: center; justify-content: center; transition: all .2s; }
.box.on { background: var(--good); border-color: var(--good); }
.box.late { border-color: var(--bad); }
.taskbtn { flex-shrink: 0; width: 44px; height: 44px; margin: -8px 0 -8px -10px; display: flex; align-items: center; justify-content: center; }
.late-text { color: var(--bad); }

.progress { height: 5px; border-radius: 3px; background: var(--track); margin-top: 4px; overflow: hidden; }
.progress > div { height: 100%; border-radius: 3px; background: var(--good); transition: width .35s; }
.plus { flex-shrink: 0; height: 36px; padding: 0 12px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px; }
.streak { flex-shrink: 0; display: flex; align-items: center; gap: 3px; font-size: 14px; font-weight: 700; color: var(--hint); }
.streak.hot { color: var(--warn); }

.icon-tile { flex-shrink: 0; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.rem { display: flex; align-items: center; gap: 12px; }
.rem .t { font-size: 15px; font-weight: 600; }

.heat { display: grid; grid-template-rows: 15px repeat(7, auto); grid-auto-flow: column; column-gap: 3px; row-gap: 3px; align-items: center; }
.heat-month, .heat-day { font-size: 10px; line-height: 15px; color: var(--hint); white-space: nowrap; overflow: visible; }
.heat-day { line-height: 1; }
.cell { width: 100%; aspect-ratio: 1; max-width: 20px; border-radius: 4px; background: var(--h0); transition: transform .12s; }
.cell:active { transform: scale(.85); }
.cell.l1 { background: var(--h1); } .cell.l2 { background: var(--h2); } .cell.l3 { background: var(--h3); } .cell.l4 { background: var(--h4); }
.cell.none { background: var(--empty); }
.cell.future { visibility: hidden; }
.cell.today { outline: 2px solid var(--hint); outline-offset: 1px; }
.cell.sel { outline: 2px solid var(--accent); outline-offset: 1px; }
.dayinfo { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 14px; background: var(--card2); }
.dayinfo .t { font-size: 14px; font-weight: 600; }
.legend { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--hint); }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.kpi { padding: 14px; border-radius: 18px; background: var(--card); display: flex; flex-direction: column; gap: 4px; }
.kpi b { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.kpi span { font-size: 12px; line-height: 1.3; color: var(--hint); }

.strip { display: grid; grid-template-columns: repeat(30, minmax(0, 1fr)); gap: 2px; }
.strip i { height: 16px; border-radius: 3px; background: var(--empty); }
.strip .done { background: var(--h3); } .strip .partial { background: var(--h1); }
.strip .skip { background: var(--track); } .strip .miss { background: var(--miss); }
.strip .before { background: transparent; }
.strip .today { outline: 1.5px solid var(--hint); outline-offset: 1px; }
.big-streak { font-size: 22px; font-weight: 800; color: var(--warn); letter-spacing: -0.4px; text-align: right; }

.area .bar { position: relative; height: 10px; border-radius: 5px; background: var(--track); }
.area .bar > div { position: absolute; left: 0; top: 0; height: 10px; border-radius: 5px; background: var(--accent); transition: width .5s; }
.area .bar > div.stale { background: var(--warn); }
.area .bar > span { position: absolute; top: -4px; width: 3px; height: 18px; border-radius: 2px; background: var(--text); opacity: .55; }
.up { color: var(--good); } .stale-text { color: var(--warn); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chip { height: 36px; padding: 0 14px; border-radius: 18px; border: 1.5px solid var(--line); background: var(--card); font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip.big { height: 44px; padding: 0 16px; border-radius: 22px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 110px; }
.bars > div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; height: 100%; font-size: 10px; color: var(--hint); }
.bars i { width: 100%; border-radius: 6px; background: var(--bar); transition: height .5s; }
.bars .cur i { background: var(--accent); }

.slider-card label { font-size: 16px; font-weight: 700; }
.slider-card .val { font-size: 15px; font-weight: 700; color: var(--accent); }
.slider-card .ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--hint); }
.slider-card .desc { font-size: 14px; line-height: 1.45; color: var(--hint); }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--p), var(--track) var(--p)); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--track); }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%; background: #fff; margin-top: -10px; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
input[type=range]::-moz-range-thumb { width: 26px; height: 26px; border: none; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.feel { background: var(--accent-soft); }
.feel .t { font-size: 14px; font-weight: 700; color: var(--accent); }
.feel p { font-size: 14px; line-height: 1.45; }
.wide-btn { height: 52px; border-radius: 16px; background: var(--card); font-size: 16px; font-weight: 700; }
.wide-btn.primary { background: var(--accent); color: var(--on-accent); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}
.tab { height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--hint); font-size: 11px; font-weight: 600; transition: color .2s; }
.tab.on { color: var(--accent); }

.center { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 40px 28px; text-align: center; }
.center h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.center p { font-size: 16px; line-height: 1.5; color: var(--hint); max-width: 340px; }
.lock { width: 88px; height: 88px; border-radius: 26px; background: var(--card); display: flex; align-items: center; justify-content: center; color: var(--accent); }
.tg-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; max-width: 340px; height: 54px; border-radius: 16px; background: var(--accent); color: var(--on-accent); text-decoration: none; font-size: 17px; font-weight: 700; }
.skeleton { background: var(--card); border-radius: 22px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 6; max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 14px; background: rgba(0,0,0,.82); color: #fff; font-size: 14px; font-weight: 500; animation: rise .2s ease both; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
