:root {
  --bg: var(--tg-theme-secondary-bg-color, #f1f1f4);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #111114);
  --hint: var(--tg-theme-hint-color, #8a8a93);
  --link: var(--tg-theme-link-color, #2f7de1);
  --btn: var(--tg-theme-button-color, #2f7de1);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --line: rgba(128, 128, 140, 0.18);
  --ok: #1f9d6b;
  --bad: #d64545;
  --warn: #c98a12;
  --ok-bg: rgba(31, 157, 107, 0.13);
  --bad-bg: rgba(214, 69, 69, 0.13);
  --warn-bg: rgba(201, 138, 18, 0.15);
  --opus: #6b5fd3;
  --opus-bg: rgba(107, 95, 211, 0.13);
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) { --bg: #101014; --card: #1b1b21; --text: #ececf1; --hint: #8d8d98; }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
#top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--bg); }
.brand { font-weight: 600; font-size: 17px; letter-spacing: 0.2px; }
.top-right { display: flex; align-items: center; gap: 8px; color: var(--hint); font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--hint); display: inline-block; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
main { padding: 0 12px 12px; }
.card { background: var(--card); border-radius: 14px; padding: 12px 14px; margin: 10px 0; }
.card h3 { margin: 0 0 8px; font-size: 13px; font-weight: 500; color: var(--hint); text-transform: none; }
.big { font-size: 28px; font-weight: 600; letter-spacing: -0.3px; }
.sub { color: var(--hint); font-size: 13px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; }
.row .l { color: var(--hint); font-size: 14px; }
.row .r { text-align: right; font-variant-numeric: tabular-nums; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 8px 0 4px; }
.bar > i { display: block; height: 100%; border-radius: 4px; }
.pos { color: var(--ok); } .neg { color: var(--bad); }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; font-weight: 500; vertical-align: 1px; }
.pill.long, .pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.short, .pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.opus { background: var(--opus-bg); color: var(--opus); }
.pill.mute { background: var(--line); color: var(--hint); }
.inst { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; }
.inst:first-of-type { border-top: 0; }
.inst .nm { font-weight: 500; min-width: 64px; }
.inst .mid { flex: 1; color: var(--hint); font-size: 13px; line-height: 1.3; }
.inst .val { text-align: right; font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 0; background: var(--card); color: var(--text); padding: 6px 12px; border-radius: 16px; font-size: 14px; white-space: nowrap; }
.chip.on { background: var(--btn); color: var(--btn-text); }
#chart { height: 280px; margin: 0 -6px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--hint); margin-top: 6px; }
.legend i { display: inline-block; width: 14px; height: 2px; vertical-align: 3px; margin-right: 4px; }
.legend i.band { height: 8px; vertical-align: 0; border-radius: 2px; }
.zonelist .row .l { font-size: 12px; }
.sw { display: inline-block; width: 12px; height: 3px; vertical-align: 3px; margin-right: 6px; border-radius: 1px; }
.sw.band { height: 9px; vertical-align: -1px; }
.txt { font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.mini { font-size: 12px; color: var(--hint); }
.steps { display: flex; gap: 4px; margin-top: 6px; }
.steps span { flex: 1; text-align: center; font-size: 11px; padding: 3px 0; border-radius: 6px; background: var(--line); color: var(--hint); }
.steps span.done { background: var(--ok-bg); color: var(--ok); }
button.act { width: 100%; border: 0; border-radius: 12px; padding: 12px; font-size: 15px; font-weight: 500;
  background: var(--btn); color: var(--btn-text); margin-top: 8px; }
button.act.sec { background: var(--line); color: var(--text); }
button.act.danger { background: var(--bad-bg); color: var(--bad); }
button.act:disabled { opacity: 0.55; }
.banner { margin: 0 12px; padding: 10px 12px; border-radius: 12px; background: var(--warn-bg); color: var(--warn); font-size: 14px; }
.empty { color: var(--hint); font-size: 14px; padding: 6px 0; }
.err { color: var(--bad); }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.t td { padding: 6px 2px; border-top: 1px solid var(--line); }
table.t td.r { text-align: right; }
table.t tr:first-child td { border-top: 0; }
.spark { width: 100%; height: 70px; display: block; }
nav#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
nav#tabs button { flex: 1; border: 0; background: none; color: var(--hint); font-size: 11px; padding: 8px 0 7px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; }
nav#tabs button .ico { font-size: 18px; line-height: 1; }
nav#tabs button.on { color: var(--btn); }
.skel { color: var(--hint); padding: 24px 0; text-align: center; }

.row.col { flex-direction: column; align-items: stretch; gap: 3px; }
.rowtop { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row.tap { cursor: pointer; }
.row.tap:active { opacity: 0.6; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.news { padding: 8px 0; border-top: 1px solid var(--line); }
.news:first-of-type { border-top: 0; }
.ntitle { font-size: 14px; line-height: 1.4; margin-top: 2px; }
img.shot { width: 100%; border-radius: 10px; margin-top: 6px; display: block; background: var(--line); min-height: 60px; }
img.shot.zoom { width: 160%; max-width: none; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 62px; margin-top: 6px; }
.bcol { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.bcol i { display: block; width: 100%; background: var(--opus); border-radius: 3px 3px 0 0; opacity: 0.75; }
.bcol span { font-size: 9px; color: var(--hint); }
.logl { font: 11px/1.4 ui-monospace, Menlo, monospace; color: var(--hint); padding: 5px 0; border-top: 1px solid var(--line); word-break: break-word; }
.logl:first-of-type { border-top: 0; }
.card:has(img.shot.zoom) { overflow-x: auto; }
nav#tabs button { font-size: 10px; }

.plpos { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 8px; }
.plp { font-size: 14px; padding: 6px 8px; border-radius: 8px; background: var(--line); }
.plp.best { background: var(--ok-bg); }
.plp.worst { background: var(--bad-bg); }
.ladder { display: flex; flex-direction: column; border-left: 2px solid var(--line); margin-left: 2px; }
.lrow { display: grid; grid-template-columns: 86px 1fr auto; gap: 8px; align-items: start; padding: 8px 0 8px 10px; border-top: 1px solid var(--line); position: relative; }
.lrow:first-child { border-top: 0; }
.lrow::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--hint); }
.lrow.fav::before { background: var(--ok); }
.lrow.adv::before { background: var(--warn); }
.lrow.k-replan::before { background: var(--bad); }
.lrow.now { background: var(--opus-bg); border-radius: 8px; }
.lrow.now::before { background: var(--opus); width: 12px; height: 12px; left: -7px; }
.lp { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 14px; }
.lt { font-size: 14px; line-height: 1.35; }
.lv { font-variant-numeric: tabular-nums; font-size: 14px; text-align: right; white-space: nowrap; }
.quote { margin-top: 8px; padding: 8px 10px; border-left: 3px solid var(--opus); background: var(--opus-bg); border-radius: 0 8px 8px 0; font-size: 14px; line-height: 1.45; }
.sect { margin: 16px 4px 4px; font-size: 13px; color: var(--hint); font-weight: 600; }
.mini.nx { color: var(--opus); margin-top: 2px; }

.notes { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 4px; }
.notebox { margin-top: 10px; }
.nhead b { font-size: 14px; }
textarea.note { width: 100%; margin-top: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-family: inherit; font-size: 14px; line-height: 1.4;
  background: var(--bg); color: var(--text); resize: vertical; min-height: 64px; }
textarea.note:focus { outline: none; border-color: var(--btn); }
.nrow { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; gap: 8px; }
.nbtns { display: flex; gap: 6px; }
button.act.small { width: auto; margin-top: 0; padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.mini.warnt { color: var(--warn); margin-top: 4px; }

.qas { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.qa { font-size: 14px; line-height: 1.4; padding: 8px 10px; border-radius: 10px; background: var(--line); }
.qa.ask { background: var(--warn-bg); }
.qa > div + div { margin-top: 4px; }
.lesson { padding: 10px 0; border-top: 1px solid var(--line); }
.lesson:first-of-type { border-top: 0; }
.lesson.pend .rowtop b { color: var(--opus); }
.lfield { margin-top: 6px; }
.nbtns.wrap { flex-wrap: wrap; justify-content: flex-end; }
.card.waiting { background: var(--warn-bg); color: var(--text); cursor: pointer; }
.card.waiting b { color: var(--warn); }
nav#tabs button.badge { position: relative; }
nav#tabs button.badge::after { content: ""; position: absolute; top: 6px; right: calc(50% - 16px); width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
