/* Помощник в Telegram (Mini App). Цвета — из темы Telegram (--tg-theme-*, их ставит telegram-web-app.js);
   запасные --fb-* — для просмотра в обычном браузере. */

:root {
  --fb-bg: #efeff4;
  --fb-card: #ffffff;
  --fb-text: #000000;
  --fb-hint: #8e8e93;
  --fb-sep: rgba(60, 60, 67, 0.18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --fb-bg: #000000;
    --fb-card: #1c1c1e;
    --fb-text: #ffffff;
    --fb-hint: #8d8d93;
    --fb-sep: rgba(84, 84, 88, 0.6);
  }
}

:root {
  --bg: var(--tg-theme-secondary-bg-color, var(--fb-bg));
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, var(--fb-card)));
  --text: var(--tg-theme-text-color, var(--fb-text));
  --hint: var(--tg-theme-hint-color, var(--fb-hint));
  --sub: var(--tg-theme-subtitle-text-color, var(--hint));
  --head: var(--tg-theme-section-header-text-color, var(--hint));
  --sep: var(--tg-theme-section-separator-color, var(--fb-sep));
  --accent: var(--tg-theme-accent-text-color, var(--tg-theme-link-color, #2481cc));
  --bad: var(--tg-theme-destructive-text-color, #e53935);
  --warn: #e08a00;
  --button: var(--tg-theme-button-color, #2481cc);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 16px calc(32px + env(safe-area-inset-bottom));
}

.hint {
  color: var(--hint);
}

.center {
  text-align: center;
}

.loading {
  margin: 30vh 16px 0;
}

/* ─── шапка экрана ─── */

header.top {
  margin: 8px 4px 20px;
}

header.top h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 700;
}

header.top p {
  margin: 2px 0 0;
  color: var(--hint);
  font-size: 15px;
}

/* ─── группы и строки ─── */

.group {
  margin: 0 0 24px;
}

.group > h2 {
  margin: 0 16px 6px;
  color: var(--head);
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
}

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 16px;
}

.row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 16px;
  height: 1px;
  background: var(--sep);
  transform: scaleY(0.5);
  transform-origin: top;
}

.row.with-icon + .row::before,
.row + .row.with-icon::before {
  left: 56px;
}

.row.tap {
  cursor: pointer;
  user-select: none;
}

.row.tap:active {
  background: var(--sep);
}

.icon {
  flex: none;
  width: 28px;
  font-size: 22px;
  line-height: 1;
  text-align: center;
}

.body {
  flex: 1;
  min-width: 0;
}

.title {
  overflow-wrap: anywhere;
}

.subtitle {
  margin-top: 2px;
  color: var(--sub);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.subtitle.warn {
  color: var(--warn);
}

.subtitle.bad {
  color: var(--bad);
}

.after {
  flex: none;
  color: var(--hint);
  font-size: 15px;
}

.chev {
  flex: none;
  margin-left: -4px;
  color: var(--hint);
  font-size: 24px;
  line-height: 1;
}

.foot {
  margin: 8px 16px 0;
  color: var(--hint);
  font-size: 13px;
}

/* ─── сообщения и кнопки ─── */

.notice {
  margin: 0 0 20px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--card);
  border-left: 4px solid var(--warn);
}

.notice.bad {
  border-left-color: var(--bad);
}

.btn {
  display: block;
  width: 100%;
  padding: 13px 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--button);
  color: var(--button-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn:active {
  opacity: 0.8;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.82);
  color: #ffffff;
  font-size: 15px;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.toast.show {
  opacity: 1;
}
