/* SMItraining Mini App. Colors come from Telegram theme variables; fallbacks are for a regular browser. */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #15171c);
  --hint: var(--tg-theme-hint-color, #6f7580);
  --accent: var(--tg-theme-button-color, #2f6fed);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #2f6fed);
  --danger: var(--tg-theme-destructive-text-color, #d93a3a);
  --ok: #2e9d5b;
  --warn: #c98a12;
  --line: rgba(127, 127, 127, 0.18);
  --soft: rgba(127, 127, 127, 0.1);
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #0f1115; --card: #1a1d23; --text: #eceef2; --hint: #99a0ab;
    --accent: #5b8df5; --link: #7aa2f7; --danger: #ef6b6b;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
[x-cloak] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--link); }

.app { max-width: 640px; margin: 0 auto; min-height: var(--tg-viewport-stable-height, 100vh); padding-bottom: 96px; }
.content { padding: 12px 12px 24px; display: flex; flex-direction: column; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.big { font-size: 22px; font-weight: 700; line-height: 1.2; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: 10px 12px 8px; border-bottom: 1px solid var(--line);
}
.topbar__title { font-weight: 700; font-size: 17px; }
.topbar__meta { color: var(--hint); font-size: 13px; }

/* cards */
.card { background: var(--card); border-radius: var(--radius); padding: 14px; }
.card--accent { background: var(--accent); color: var(--accent-text); }
.card--accent .muted { color: var(--accent-text); opacity: 0.8; }
.card__title { font-weight: 700; font-size: 17px; margin: 0 0 4px; }
.card__sub { color: var(--hint); font-size: 13px; margin: 0; }
.card--accent .card__sub { color: var(--accent-text); opacity: 0.85; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--hint); margin: 8px 4px 0; }

/* buttons */
.btn {
  border: 0; border-radius: 12px; padding: 12px 14px; background: var(--soft);
  font-weight: 600; cursor: pointer; touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; }
.btn--primary { background: var(--accent); color: var(--accent-text); }
.btn--ghost { background: transparent; color: var(--link); padding-left: 6px; padding-right: 6px; }
.btn--danger { color: var(--danger); }
.btn--block { width: 100%; }
.btn--small { padding: 8px 10px; font-size: 14px; border-radius: 10px; }
.btn--huge { width: 100%; padding: 18px; font-size: 18px; border-radius: 16px; }

/* progress */
.progress { height: 6px; border-radius: 3px; background: var(--soft); overflow: hidden; }
.progress__bar { height: 100%; background: var(--accent); transition: width 0.3s; }
.card--accent .progress { background: rgba(255, 255, 255, 0.3); }
.card--accent .progress__bar { background: var(--accent-text); }

/* lists */
.list { display: flex; flex-direction: column; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.list__item {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; width: 100%;
}
.list__item:first-child { border-top: 0; }
.list__item--current { background: var(--soft); }
.list__item--done .list__name { color: var(--hint); }
.list__icon { width: 22px; text-align: center; flex: none; }
.list__name { font-weight: 600; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--soft); color: var(--hint); white-space: nowrap; }
.badge--ok { color: var(--ok); }
.badge--warn { color: var(--warn); }

/* sets */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-width: 56px; padding: 6px 10px; border-radius: 10px; text-align: center;
  background: var(--soft); color: var(--hint); font-size: 14px; font-variant-numeric: tabular-nums;
}
.chip--done { background: rgba(46, 157, 91, 0.15); color: var(--ok); font-weight: 600; }
.chip--pending { outline: 1px dashed var(--ok); }
.chip--extra { background: rgba(201, 138, 18, 0.15); color: var(--warn); }

/* steppers */
.stepper { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; gap: 8px; }
.stepper__btn { height: 56px; border-radius: 14px; border: 0; background: var(--soft); font-size: 26px; font-weight: 600; }
.stepper__btn:active { background: var(--line); }
.stepper__value { text-align: center; font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stepper__label { text-align: center; font-size: 12px; color: var(--hint); margin-top: -2px; }
.stepper__input {
  width: 100%; text-align: center; border: 0; background: transparent; font-size: 28px; font-weight: 700;
  font-variant-numeric: tabular-nums; padding: 0;
}

/* rest */
.rest { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: 12px; background: var(--soft); }
.rest__time { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rest--over .rest__time { color: var(--ok); }

/* tabs */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--soft); padding: 3px; border-radius: 10px; margin-top: 8px; }
.tab { border: 0; background: transparent; padding: 7px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--hint); }
.tab--active { background: var(--card); color: var(--text); }

/* forms */
.input, .textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  padding: 10px 12px; font-size: 16px;
}
.textarea { min-height: 72px; resize: vertical; }
.textarea--code { min-height: 180px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

/* habits */
.check { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 0; border-top: 1px solid var(--line); background: transparent; width: 100%; text-align: left; }
.check:first-child { border-top: 0; }
.check__box { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line); flex: none; display: grid; place-items: center; font-size: 15px; }
.check--done .check__box { background: var(--ok); border-color: var(--ok); color: #fff; }
.check--done .check__title { color: var(--hint); text-decoration: line-through; }

/* upload report */
.issue { padding: 8px 10px; border-radius: 10px; font-size: 14px; }
.issue--error { background: rgba(217, 58, 58, 0.12); }
.issue--warning { background: rgba(201, 138, 18, 0.12); }
.issue__label { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--hint); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--hint); }
.kv dd { margin: 0; }

/* bottom bar: stands in for Telegram MainButton in a regular browser */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
}
.bottombar .btn { max-width: 616px; margin: 0 auto; display: block; }

/* toast & offline */
.toast {
  position: fixed; left: 12px; right: 12px; bottom: 90px; z-index: 20; margin: 0 auto; max-width: 600px;
  background: var(--text); color: var(--bg); padding: 12px 14px; border-radius: 12px; font-size: 14px;
}
.offline { background: rgba(201, 138, 18, 0.15); color: var(--warn); padding: 6px 12px; font-size: 13px; text-align: center; }
.empty { padding: 32px 16px; text-align: center; color: var(--hint); }
