:root {
  --bg: var(--tg-theme-secondary-bg-color, #f1f2f6);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #fff));
  --text: var(--tg-theme-text-color, #111);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --accent: #d6336c;
  --accent-text: #fff;
  --link: var(--tg-theme-link-color, #2f80ed);
  --ok: #27ae60;
  --danger: var(--tg-theme-destructive-text-color, #e5484d);
  --border: color-mix(in srgb, var(--hint) 25%, transparent);
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) { --bg: #101114; --card: #1b1d22; --text: #eee; --hint: #8a8f98; }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
main { padding: 12px 12px 84px; max-width: 640px; margin: 0 auto; }
h1 { font-size: 22px; margin: 4px 4px 12px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--hint); margin: 0 0 10px; font-weight: 600; }
.card { background: var(--card); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.muted { color: var(--hint); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.list > * { padding: 10px 0; border-top: 1px solid var(--border); }
.list > *:first-child { border-top: 0; padding-top: 0; }
.list > *:last-child { padding-bottom: 0; }
button, .btn {
  font: inherit; border: 0; border-radius: 10px; padding: 10px 14px; cursor: pointer;
  background: var(--accent); color: var(--accent-text); font-weight: 600;
}
button.secondary { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
button.ghost { background: transparent; color: var(--link); padding: 6px 8px; }
button.danger { background: transparent; color: var(--danger); padding: 6px 8px; }
button.big { width: 100%; padding: 14px; font-size: 16px; }
button:disabled { opacity: .5; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 10px; width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--hint); margin: 8px 0 4px; }
.chips { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.chip { background: var(--bg); color: var(--text); font-weight: 500; padding: 7px 12px; }
.chip.on { background: var(--accent); color: var(--accent-text); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; object-fit: cover;
  background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent);
  display: grid; place-items: center; font-weight: 700;
}
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--hint); white-space: nowrap; }
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.done { background: color-mix(in srgb, var(--ok) 12%, var(--card)); }
.done b { color: var(--ok); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border-radius: 14px; padding: 12px; }
.stat b { display: block; font-size: 26px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 80px; }
.bars div { flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .85; }
.bars div.zero { opacity: .2; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; font-size: 13px; }
.cal span { padding: 6px 0; border-radius: 8px; }
.cal .hd { color: var(--hint); font-size: 11px; }
.cal .on { background: var(--ok); color: #fff; font-weight: 700; }
.cal .today { outline: 2px solid var(--accent); }
.hero { text-align: center; padding: 18px 14px; }
.hero .counter { font-size: 44px; font-weight: 800; line-height: 1.1; }
.hero .counter small { font-size: 15px; font-weight: 500; color: var(--hint); display: block; }
button.mega {
  width: 100%; padding: 22px 14px; font-size: 20px; border-radius: 16px;
  background: linear-gradient(135deg, #d6336c, #f76707); box-shadow: 0 6px 18px color-mix(in srgb, #d6336c 35%, transparent);
}
button.mega:active { transform: scale(.98); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.stars { display: flex; gap: 4px; }
.stars button { background: var(--bg); color: var(--hint); padding: 8px 0; flex: 1; font-size: 18px; }
.stars button.on { background: color-mix(in srgb, #f2b705 25%, transparent); color: #f2b705; }
.entry .tags { font-size: 13px; color: var(--hint); }
.entry .note { font-size: 14px; margin-top: 2px; }
.ach { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ach > div { background: var(--card); border-radius: 14px; padding: 12px; text-align: center; }
.ach .e { font-size: 34px; }
.ach .t { font-weight: 700; margin-top: 4px; }
.ach .d { font-size: 12px; color: var(--hint); }
.ach .off { opacity: .35; filter: grayscale(1); }
.progress { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; background: var(--accent); }
.cal .on { background: var(--accent); }
.cal .on2 { background: #f76707; color: #fff; font-weight: 700; }
.cal .on3 { background: #c92a2a; color: #fff; font-weight: 800; }
.hbars { display: grid; gap: 6px; }
.hbar { display: grid; grid-template-columns: 110px 1fr 28px; gap: 8px; align-items: center; font-size: 13px; }
.hbar .b { height: 10px; border-radius: 5px; background: var(--accent); opacity: .85; min-width: 2px; }
.place { font-size: 22px; width: 32px; text-align: center; flex: none; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; }
.switch input { width: auto; transform: scale(1.3); }
.disclaimer { text-align: center; font-size: 12px; color: var(--hint); margin: 18px 0 4px; }
.chev { transition: transform .15s; color: var(--hint); }
nav#tabs {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
nav#tabs button {
  flex: 1; background: none; color: var(--hint); font-size: 11px; font-weight: 500;
  padding: 8px 0; display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 0;
}
nav#tabs button span { font-size: 20px; }
nav#tabs button.active { color: var(--accent); }
#sheet { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; z-index: 10; }
#sheet[hidden] { display: none; }
.sheet-body {
  background: var(--bg); width: 100%; max-height: 88vh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto;
}
#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 20;
  background: rgba(0,0,0,.85); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
}
.empty { text-align: center; color: var(--hint); padding: 12px 0; }
nav#tabs button { font-size: 10px; }
.badge.warn { background: color-mix(in srgb, #f76707 15%, transparent); color: #f76707; }
.tipcard { font-size: 14px; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stats3 .stat b { font-size: 22px; margin: 2px 0; }
.titles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.title { background: var(--bg); border-radius: 12px; padding: 10px; text-align: center; font-size: 14px; }
.title .e { font-size: 28px; }
.title .t { font-size: 12px; color: var(--hint); text-transform: uppercase; letter-spacing: .03em; margin: 2px 0 4px; font-weight: 600; }
.title.off { opacity: .5; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--hint); font-size: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; font-size: 13px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }
.split { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--border); margin-top: 6px; }
.split i { display: block; height: 100%; }
.split .s { background: var(--accent); }
.split .w { background: #f76707; }
.split .m { background: #ae3ec9; }
.heat { display: grid; grid-template-columns: 26px repeat(6, 1fr); gap: 3px; font-size: 11px; text-align: center; }
.heat .hd { color: var(--hint); align-self: center; }
.heat .cell { border-radius: 6px; padding: 7px 0; min-height: 26px; font-weight: 600; }
button.vote { background: var(--bg); color: var(--text); padding: 6px 10px; font-size: 13px; font-weight: 500; white-space: nowrap; }
button.vote.on { background: color-mix(in srgb, #f76707 25%, transparent); color: #f76707; }
.doubt { font-size: 12px; color: #f76707; margin-top: 2px; }
.nnn { border: 2px solid color-mix(in srgb, #f76707 40%, transparent); }
body.public main { padding-bottom: 24px; max-width: 760px; }
.reacts { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
button.react, span.react { background: var(--bg); color: var(--text); padding: 4px 9px; font-size: 13px; font-weight: 500; border-radius: 999px; }
button.react.on { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.status { font-size: 12px; color: #c92a2a; font-weight: 600; }
.feed-note, .list .note { font-size: 14px; margin-top: 2px; }
