:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f3f5);
  --text: var(--tg-theme-text-color, #1c1c1e);
  --hint: var(--tg-theme-hint-color, #6b7280);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #d93a3a);
  --on: #3fae5a;
  --off: #d9473f;
  --maybe: #e4a62b;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg2); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
main { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--hint); }
.center { text-align: center; }
.small { font-size: 13px; }
.card { background: var(--bg); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.tile { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; color: var(--text);
  background: var(--bg); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; font: inherit; cursor: pointer; }
.tile .icon { font-size: 26px; }
.tile .title { font-weight: 600; }
.tile .sub { color: var(--hint); font-size: 14px; }
button { font: inherit; }
.btn { border: 0; border-radius: 12px; padding: 12px 16px; background: var(--btn); color: var(--btn-text);
  font-weight: 600; cursor: pointer; width: 100%; }
.btn.secondary { background: var(--bg); color: var(--link); }
.btn:disabled { opacity: .5; }
.chip { border: 1px solid var(--bg2); background: var(--bg2); color: var(--text); border-radius: 999px;
  padding: 8px 14px; cursor: pointer; }
.chip.active { background: var(--btn); color: var(--btn-text); border-color: var(--btn); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.link { background: none; border: 0; color: var(--link); cursor: pointer; padding: 4px 0; }
.danger { color: var(--danger); }
.bar { display: flex; height: 28px; border-radius: 8px; overflow: hidden; background: var(--bg2); position: relative; }
.bar span { flex: 1; border-right: 1px solid rgba(255,255,255,.35); }
.bar span:last-child { border-right: 0; }
.s-on { background: var(--on); } .s-off { background: var(--off); } .s-maybe { background: var(--maybe); }
.marker { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); }
.axis { display: flex; justify-content: space-between; color: var(--hint); font-size: 12px; margin: 4px 0 8px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; color: var(--hint); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
ul.plain { list-style: none; padding: 0; margin: 8px 0 0; }
ul.plain li { padding: 4px 0; }
label { display: block; font-weight: 600; margin: 12px 0 4px; }
input, textarea { width: 100%; font: inherit; color: var(--text); background: var(--bg2); border: 0;
  border-radius: 10px; padding: 10px 12px; }
textarea { min-height: 84px; resize: vertical; }
.warn { background: rgba(228,166,43,.18); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; font-size: 14px; }
.error { background: rgba(217,58,58,.14); color: var(--danger); border-radius: 10px; padding: 8px 12px; margin: 12px 0; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; }
.chip.light { background: var(--bg); border-color: var(--bg); }
.progress { height: 8px; border-radius: 999px; background: var(--bg2); overflow: hidden; margin: 8px 0; }
.progress.big { height: 14px; }
.progress .fill { height: 100%; background: var(--btn); border-radius: 999px; transition: width .3s; }
.progress .fill.done { background: var(--on); } .progress .fill.mid { background: var(--maybe); } .progress .fill.bad { background: var(--off); }
.tname { font-weight: 600; word-break: break-word; }
.actions { margin-top: 6px; }
.big-state { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.chip:disabled { opacity: .4; }
input[type=search] { margin-bottom: 8px; }
.meter { margin-bottom: 10px; }
.meter:last-child { margin-bottom: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 400; margin: 0; padding: 10px 0; }
.check { width: 24px; height: 24px; flex: none; accent-color: var(--btn); }

pre.logs { background: var(--tg-theme-secondary-bg-color, rgba(127,127,127,.12)); border-radius: 10px; padding: 10px;
  font: 11px/1.4 ui-monospace, monospace; white-space: pre-wrap; word-break: break-all; max-height: 60vh; overflow: auto; margin-top: 10px; }
