:root {
  --bg: var(--tg-theme-bg-color, #f6f3ee);
  --bg2: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1f1b16);
  --hint: var(--tg-theme-hint-color, #8a8077);
  --link: var(--tg-theme-link-color, #a4662a);
  --btn: var(--tg-theme-button-color, #b5752f);
  --btn-text: var(--tg-theme-button-text-color, #fff);
  --card: var(--tg-theme-section-bg-color, #ffffff);
  --gold: #c9a24d; --wood: #4f9d69; --fire: #d9573b; --earth: #c08a3e; --metal: #8f98a3; --water: #3f7fb6;
  --good: #4f9d69; --mid: #c9a24d; --bad: #d9573b;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, "SF Pro Text", Inter, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
.top { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--bg); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .3px; }
.logo { font-size: 22px; color: var(--gold); }
.who { font-size: 13px; color: var(--hint); }
.view { padding: 0 16px 92px; max-width: 640px; margin: 0 auto; }
.loading, .error { text-align: center; color: var(--hint); padding: 48px 0; }
.error { color: var(--bad); }
.card { background: var(--card); border-radius: 16px; padding: 16px; margin: 12px 0; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.card h2 { margin: 0 0 10px; font-size: 17px; }
.card h3 { margin: 14px 0 6px; font-size: 14px; color: var(--hint); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.hint { color: var(--hint); font-size: 14px; }
.muted { color: var(--hint); }

/* Столпы */
.pillars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pillars.three { grid-template-columns: repeat(3, 1fr); }
.pillar { border-radius: 14px; padding: 10px 6px; text-align: center; background: var(--bg); }
.pillar .pname { font-size: 12px; color: var(--hint); margin-bottom: 6px; }
.pillar .char { font-size: 30px; line-height: 1.1; font-weight: 600; }
.pillar .sub { font-size: 11px; color: var(--hint); margin-top: 2px; }
.pillar.day { outline: 2px solid var(--gold); }
.el-Дерево { color: var(--wood); } .el-Огонь { color: var(--fire); } .el-Земля { color: var(--earth); } .el-Металл { color: var(--metal); } .el-Вода { color: var(--water); }
.bg-Дерево { background: var(--wood); } .bg-Огонь { background: var(--fire); } .bg-Земля { background: var(--earth); } .bg-Металл { background: var(--metal); } .bg-Вода { background: var(--water); }

.dm { display: flex; gap: 14px; align-items: center; }
.dm .big { font-size: 44px; line-height: 1; }
.dm b { font-size: 18px; }

/* Стихии */
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 84px 1fr 40px; align-items: center; gap: 8px; font-size: 14px; }
.bar .track { height: 10px; border-radius: 6px; background: var(--bg); overflow: hidden; }
.bar .fill { height: 100%; border-radius: 6px; }
.bar .pct { text-align: right; color: var(--hint); font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 10px; border-radius: 999px; background: var(--bg); font-size: 13px; }
.chip.good { background: rgba(79,157,105,.15); } .chip.bad { background: rgba(217,87,59,.12); }

/* День */
.score { display: flex; align-items: center; gap: 12px; }
.score .moons { font-size: 22px; letter-spacing: 2px; }
.score .n { font-size: 28px; font-weight: 700; }
.row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid rgba(0,0,0,.05); font-size: 15px; }
.row:last-child { border-bottom: 0; }
.row .k { color: var(--hint); flex: 0 0 auto; }
.row span:last-child { text-align: right; }
ul.plain { margin: 0; padding-left: 18px; } ul.plain li { margin: 4px 0; }
.warn { background: rgba(217,87,59,.1); border-radius: 10px; padding: 8px 12px; margin: 6px 0; font-size: 14px; }
.datebar { display: flex; justify-content: space-between; align-items: center; margin: 12px 0 0; }
.datebar button { background: var(--card); border: 0; border-radius: 10px; padding: 8px 14px; font-size: 18px; color: var(--text); }
.datebar .d { font-weight: 600; }

/* Календарь */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .wd { text-align: center; font-size: 12px; color: var(--hint); padding: 4px 0; }
.cal .cell { aspect-ratio: 1; border-radius: 12px; background: var(--card); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 15px; position: relative; border: 0; color: var(--text); }
.cal .cell.empty { background: transparent; }
.cal .cell .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 3px; }
.cal .cell.today { outline: 2px solid var(--gold); font-weight: 700; }
.cal .cell.bad::after { content: '!'; position: absolute; top: 3px; right: 6px; font-size: 10px; color: var(--bad); font-weight: 700; }
.s1 { background: var(--bad); } .s2 { background: #e08a5a; } .s3 { background: var(--mid); } .s4 { background: #7fb86f; } .s5 { background: var(--good); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--hint); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

/* Кнопки, замок */
.btn { display: block; width: 100%; border: 0; border-radius: 12px; padding: 14px; font-size: 16px; font-weight: 600; background: var(--btn); color: var(--btn-text); margin-top: 10px; }
.btn.ghost { background: var(--bg); color: var(--text); }
.lock { border: 1px dashed var(--gold); border-radius: 12px; padding: 12px; font-size: 14px; color: var(--hint); margin-top: 10px; }
.price { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid rgba(0,0,0,.05); }
.price b { font-size: 17px; }
.html-text { white-space: pre-wrap; font-size: 15px; }
details summary { cursor: pointer; color: var(--link); font-size: 14px; margin-top: 10px; }

/* Вкладки */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--bg2); border-top: 1px solid rgba(0,0,0,.06); padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); }
.tabs button { border: 0; background: none; font-size: 12px; color: var(--hint); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; }
.tabs button span { font-size: 20px; }
.tabs button.active { color: var(--link); font-weight: 600; }
