/* Основа: сброс, каркас экранов, кнопки, карточки, нижняя навигация, диалоги. */

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

/* Текст, который полезно выделять/копировать (код, вывод программы) */
.selectable,
input,
textarea {
  -webkit-user-select: text;
  user-select: text;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
}

button,
input,
textarea {
  font-family: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.hidden {
  display: none !important;
}

/* ---------- Экран ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.screen--enter {
  animation: screen-in 0.2s ease-out both;
}

.screen--exit {
  animation: screen-out 0.15s ease-in both;
  pointer-events: none;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes screen-out {
  to {
    opacity: 0;
  }
}

.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.scroll::-webkit-scrollbar,
.no-scrollbar::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.no-scrollbar {
  scrollbar-width: none;
}

/* ---------- Кнопки ---------- */

.btn {
  all: unset;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px;
  border-radius: var(--radius-btn);
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.12s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.985);
  filter: brightness(1.08);
}

.btn--primary {
  background: var(--accent);
  color: var(--bg);
}

.btn--secondary {
  padding: 13px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.btn--ghost {
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.btn--danger {
  padding: 14px;
  color: var(--red);
  font-size: 14px;
  font-weight: 700;
}

.btn--success {
  background: var(--green);
  color: var(--bg);
}

.btn--error {
  background: var(--red);
  color: var(--bg);
}

.btn[disabled],
.btn.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.btn.is-loading {
  pointer-events: none;
  opacity: 0.7;
}

.iconbtn {
  all: unset;
  box-sizing: border-box;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.iconbtn:active {
  filter: brightness(1.3);
}

.iconbtn--flat {
  background: transparent;
}

svg.ic {
  display: block;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Карточки ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-2);
}

.dot-accent {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

code.inline,
.inline-code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.92em;
  color: var(--accent-text);
}

/* ---------- Верхняя панель ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding: calc(var(--sat) + 16px) 16px 10px;
}

.topbar__title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

.progressbar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--surface);
  overflow: hidden;
}

.progressbar > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ---------- Нижняя навигация ---------- */

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-shrink: 0;
  padding: 10px 12px calc(max(var(--sab), 12px) + 10px);
  border-top: 1px solid var(--card);
  background: var(--bg);
}

.navbar--glass {
  border-top-color: rgba(29, 32, 39, 0.8);
  background: transparent;
}

.navbar__item {
  all: unset;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 64px;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
}

.navbar__item.is-active {
  color: var(--accent);
  font-weight: 700;
}

.navbar__item .ic {
  stroke-width: 2;
}

/* ---------- Тумблер ---------- */

.switch {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface);
  transition: background 0.18s ease;
  cursor: pointer;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s ease, background 0.18s ease;
}

.switch.is-on {
  background: var(--accent);
}

.switch.is-on::after {
  transform: translateX(16px);
  background: var(--bg);
}

/* ---------- Сегментированный переключатель ---------- */

.seg {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--bg);
  border-radius: 11px;
}

.seg__item {
  all: unset;
  box-sizing: border-box;
  flex: 1;
  padding: 9px 4px;
  border-radius: 9px;
  text-align: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.seg__item.is-active {
  background: var(--accent);
  color: var(--bg);
}

/* ---------- Уведомление внизу (тост) ---------- */

.toast-host {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(max(var(--sab), 12px) + 84px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 24px;
  pointer-events: none;
  z-index: 100;
}

.toast {
  max-width: 340px;
  padding: 11px 16px;
  border-radius: 12px;
  background: #2a2e38;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.2s ease-out both;
}

.toast--out {
  animation: screen-out 0.2s ease-in both;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Диалог и нижняя шторка ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(6, 7, 10, 0.62);
  animation: overlay-in 0.18s ease-out both;
}

.overlay--center {
  align-items: center;
  padding: 24px;
}

@keyframes overlay-in {
  from {
    opacity: 0;
  }
}

.sheet {
  width: 100%;
  max-width: 520px;
  padding: 18px 16px calc(max(var(--sab), 12px) + 14px);
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  animation: sheet-in 0.22s ease-out both;
}

@keyframes sheet-in {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}

.sheet__grip {
  width: 38px;
  height: 4px;
  margin: -6px auto 14px;
  border-radius: 2px;
  background: var(--surface);
}

.sheet__title {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 6px;
}

.sheet__text {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
  margin-bottom: 16px;
}

.sheet__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dialog {
  width: 100%;
  max-width: 340px;
  padding: 20px 18px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  animation: sheet-in 0.2s ease-out both;
}

/* ---------- Загрузка ---------- */

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid var(--surface);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.center-fill {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}

/* Индикатор «нет связи» (тонкая полоска сверху) */
.offline-strip {
  flex-shrink: 0;
  padding: calc(var(--sat) + 4px) 12px 4px;
  background: #2a2419;
  color: var(--yellow);
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
}

/* Режим для автоматических проверок (?noanim): без анимаций, чтобы снимки экрана были стабильными */
.no-anim *,
.no-anim *::before,
.no-anim *::after {
  animation: none !important;
  transition: none !important;
}
