/* Colours come from Telegram (it sets --tg-theme-* on the page); the fallbacks are for a plain browser. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f3f6);
  --text: var(--tg-theme-text-color, #0f1419);
  --hint: var(--tg-theme-hint-color, #6b7280);
  --link: var(--tg-theme-link-color, #2481cc);
  --button: var(--tg-theme-button-color, #2481cc);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #d93025);
  --ok: #31b545;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--tg-theme-bg-color, #17212b);
    --bg2: var(--tg-theme-secondary-bg-color, #0e1621);
    --text: var(--tg-theme-text-color, #f5f5f5);
    --hint: var(--tg-theme-hint-color, #8b9aa7);
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg2); color: var(--text); font: 15px/1.45 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 22px; }
h2 { font-size: 16px; margin: 0; }
p { margin: 6px 0; }
.center { min-height: 100vh; display: grid; place-content: center; text-align: center; padding: 24px; }
.app { min-height: 100vh; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
.status { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 10px 16px; font-size: 13px; border-bottom: 1px solid color-mix(in srgb, var(--hint) 20%, transparent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--hint); margin-right: 6px; vertical-align: 1px; }
.dot.on { background: var(--ok); }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.error { margin: 8px 16px 0; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--danger) 12%, var(--bg)); color: var(--danger); }
main { padding: 12px 16px; display: grid; gap: 12px; }
section { background: var(--bg); border-radius: 14px; padding: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.count { background: var(--bg2); color: var(--hint); border-radius: 10px; padding: 1px 8px; font-size: 12px; white-space: nowrap; }
.running { color: var(--ok); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
button { font: inherit; border: 0; border-radius: 10px; padding: 9px 12px; background: var(--bg2); color: var(--text); cursor: pointer; min-height: 40px; }
button.primary { background: var(--button); color: var(--button-text); }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
textarea, select { width: 100%; font: inherit; color: var(--text); background: var(--bg2); border: 1px solid transparent; border-radius: 10px; padding: 9px 10px; }
textarea { resize: vertical; }
textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; }
.tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.task { border-bottom: 1px solid color-mix(in srgb, var(--hint) 18%, transparent); padding: 8px 0; }
.task:last-child { border-bottom: 0; }
.task-head { display: block; width: 100%; text-align: left; background: transparent; padding: 0; min-height: 0; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.report { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: var(--bg2); }
.badge { font-size: 12px; border-radius: 8px; padding: 1px 8px; background: var(--bg2); color: var(--hint); white-space: nowrap; }
.badge.running { color: var(--ok); }
.badge.done { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--bg)); }
.badge.error, .badge.timeout, .badge.interrupted { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--bg)); }
.badge.pending, .badge.queued { color: var(--link); }
.tabs { position: fixed; inset: auto 0 0; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid color-mix(in srgb, var(--hint) 20%, transparent); }
.tabs button { background: transparent; color: var(--hint); }
.tabs button.active { color: var(--link); font-weight: 600; }
