/* Цвета — из темы Telegram (telegram-web-app.js выставляет --tg-theme-*); запасные — для браузера. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f2f6);
  --section: var(--tg-theme-section-bg-color, var(--bg));
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #2481cc);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #e5484d);
  --header-text: var(--tg-theme-section-header-text-color, var(--hint));
  --sep: color-mix(in srgb, var(--hint) 25%, transparent);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg2);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}

#top { padding: 14px 16px 4px; }
#top h1 { margin: 0; font-size: 20px; font-weight: 600; overflow-wrap: anywhere; }
#view { padding: 8px 12px 16px; max-width: 720px; margin: 0 auto; }

#tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; background: var(--bg);
  border-top: 1px solid var(--sep);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs a {
  flex: 1; text-align: center; padding: 12px 2px; font-size: 13px;
  color: var(--hint); text-decoration: none;
}
#tabs a.active { color: var(--accent); font-weight: 600; }

.section { background: var(--section); border-radius: var(--radius); padding: 12px 14px; margin: 10px 0; }
.section > h2 {
  margin: 0 0 8px; font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .02em; color: var(--header-text);
}
.hint { color: var(--hint); font-size: 13px; }
.muted { opacity: .55; }
.row { display: flex; align-items: center; gap: 8px; }
.row + .row { margin-top: 8px; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }

.list { margin: 0; padding: 0; list-style: none; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--sep); }
.list li:last-child { border-bottom: 0; }
.item { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.item .name { font-weight: 500; overflow-wrap: anywhere; }
.item .sub { color: var(--hint); font-size: 13px; overflow-wrap: anywhere; }
.badge {
  display: inline-block; min-width: 26px; text-align: center; padding: 2px 6px; border-radius: 8px;
  background: var(--bg2); font-size: 13px;
}

input[type=text], input[type=search], input[type=datetime-local], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg2);
  border: 1px solid transparent; border-radius: 10px; padding: 9px 10px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { min-height: 70px; resize: vertical; }

button {
  font: inherit; border: 0; border-radius: 10px; padding: 9px 14px; cursor: pointer;
  background: var(--accent); color: var(--accent-text); white-space: nowrap;
}
button.secondary { background: var(--bg2); color: var(--link); }
button.danger { background: transparent; color: var(--danger); padding: 6px 8px; }
button.small { padding: 5px 10px; font-size: 13px; }
button:disabled { opacity: .5; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 10px; border-radius: 16px;
  background: var(--bg2); font-size: 14px;
}
.chip button { background: transparent; color: var(--hint); padding: 0 4px; font-size: 16px; line-height: 1; }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg button { background: var(--bg2); color: var(--text); padding: 10px 4px; font-size: 18px; }
.seg button.on { background: var(--accent); color: var(--accent-text); }

.field { padding: 10px 0; border-bottom: 1px solid var(--sep); }
.field:last-child { border-bottom: 0; }
.field .label { font-weight: 500; }
.field .eff { color: var(--hint); font-size: 13px; margin: 2px 0 6px; overflow-wrap: anywhere; }

.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; background: var(--sep); border-radius: 14px; transition: .2s;
}
.switch span::before {
  content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(18px); }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tile { background: var(--bg2); border-radius: 10px; padding: 10px 12px; }
.tile b { display: block; font-size: 22px; }

.pair { padding: 8px 0; border-bottom: 1px solid var(--sep); font-size: 14px; }
.pair:last-child { border-bottom: 0; }
.pair .in { color: var(--hint); overflow-wrap: anywhere; }
.pair .out { overflow-wrap: anywhere; }

.empty { color: var(--hint); text-align: center; padding: 24px 0; }
.error { color: var(--danger); }
.toast {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 10px; font-size: 14px;
  opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw;
}
.toast.show { opacity: .92; }

/* Отступы классами: CSP style-src 'self' запрещает инлайновые style-атрибуты. */
.mt { margin-top: 8px; }
.mt6 { margin-top: 6px; }
.my { margin: 6px 0 10px; }
.mb { margin-bottom: 8px; }
.hidden { display: none; }
.plain { text-decoration: none; color: inherit; }
