:root {
  --bg: #000;
  --fg: #fff;
  --muted: rgba(255, 255, 255, 0.62);
  --accent: #ff375f;
  --accent-soft: rgba(255, 55, 95, 0.16);
  --card: rgba(28, 28, 32, 0.92);
  --stroke: rgba(255, 255, 255, 0.12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

#app { position: fixed; inset: 0; overflow: hidden; }
.screen { position: absolute; inset: 0; }

/* ---------- Загрузка ---------- */
.boot { display: flex; align-items: center; justify-content: center; padding: 32px; text-align: center; }
.boot-inner { max-width: 420px; }
.spinner {
  width: 34px; height: 34px; margin: 0 auto 18px;
  border: 3px solid rgba(255,255,255,.18); border-top-color: var(--fg);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.boot p { color: var(--muted); font-size: 15px; line-height: 1.5; }
.boot-error {
  margin-top: 16px; padding: 12px; text-align: left; font-size: 12px; line-height: 1.5;
  background: rgba(255,255,255,.06); border: 1px solid var(--stroke); border-radius: 12px;
  white-space: pre-wrap; word-break: break-word; color: #ffb4b4; max-height: 40vh; overflow: auto;
}

/* ---------- Лента ---------- */
.feed { overflow: hidden; }
.pager {
  height: 100%;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}
.pager::-webkit-scrollbar { display: none; }

.reel {
  position: relative;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex; align-items: center; justify-content: center;
  background: #000;
  overflow: hidden;
}
.reel video {
  width: 100%; height: 100%; object-fit: contain; background: #000;
  display: block;
}
.reel-thumb {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; filter: blur(1px) brightness(.55);
}
.reel-skeleton {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px; gap: 8px;
}

.reel-meta {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 16px 16px calc(20px + var(--safe-bottom));
  background: linear-gradient(to top, rgba(0,0,0,.82), rgba(0,0,0,0));
  pointer-events: none;
}
.reel-author { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.reel-caption {
  font-size: 13px; color: rgba(255,255,255,.86); line-height: 1.4;
  max-height: 3.9em; overflow: hidden;
}
.reel-stats { margin-top: 8px; font-size: 12px; color: var(--muted); display: flex; gap: 12px; }

.reel-fail {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 24px;
}

.big-play {
  position: absolute; width: 62px; height: 62px; border-radius: 50%;
  background: rgba(0,0,0,.5); border: none; color: #fff; font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; opacity: 0; transition: opacity .18s ease;
}
.big-play.show { opacity: 1; }

/* ---------- HUD ---------- */
.hud {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(10px + var(--safe-top)) 12px 10px;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,.55), rgba(0,0,0,0));
}
.hud-left { pointer-events: none; }
.hud-right { display: flex; gap: 8px; pointer-events: auto; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(0,0,0,.45); backdrop-filter: blur(10px);
  border: 1px solid var(--stroke);
  font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600;
}
.pill.warn { border-color: rgba(255, 149, 0, .5); }
.pill.danger { border-color: rgba(255, 55, 95, .6); background: var(--accent-soft); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #34c759; }
.pill.warn .dot { background: #ff9500; }
.pill.danger .dot { background: var(--accent); }

.progress {
  margin-top: 6px; width: 96px; height: 3px; border-radius: 3px;
  background: rgba(255,255,255,.2); overflow: hidden;
}
.progress-fill { height: 100%; width: 0%; background: #34c759; transition: width .4s ease, background .4s ease; }
.progress-fill.warn { background: #ff9500; }
.progress-fill.danger { background: var(--accent); }

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(0,0,0,.45); backdrop-filter: blur(10px);
  border: 1px solid var(--stroke); color: var(--fg);
  font-size: 16px; display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.icon-btn:active { transform: scale(.94); }

.hint {
  position: absolute; left: 50%; bottom: calc(12px + var(--safe-bottom));
  transform: translateX(-50%); font-size: 12px; color: var(--muted);
  background: rgba(0,0,0,.5); padding: 6px 12px; border-radius: 999px;
  transition: opacity .4s ease; pointer-events: none;
}
.hint.hide { opacity: 0; }

/* ---------- Шторка настроек ---------- */
.sheet {
  position: absolute; inset: 0; display: flex; align-items: flex-end;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px); z-index: 20;
}
.sheet-body {
  width: 100%; max-height: 88vh; overflow-y: auto;
  background: var(--card); border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(18px + var(--safe-bottom));
  border-top: 1px solid var(--stroke);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sheet-head h2 { margin: 0; font-size: 18px; }

.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.field-row { display: flex; align-items: baseline; gap: 8px; }
.limit-input {
  width: 90px; padding: 10px 12px; font-size: 22px; font-weight: 700;
  background: rgba(255,255,255,.07); border: 1px solid var(--stroke);
  border-radius: 12px; color: var(--fg); text-align: center;
}
.field-unit { color: var(--muted); font-size: 14px; }

.slider { width: 100%; margin-top: 14px; accent-color: var(--accent); }

.quick-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip {
  padding: 8px 14px; border-radius: 999px; font-size: 13px;
  background: rgba(255,255,255,.08); border: 1px solid var(--stroke);
  color: var(--fg); cursor: pointer;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent); }

.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px;
}
.stat {
  background: rgba(255,255,255,.05); border: 1px solid var(--stroke);
  border-radius: 14px; padding: 12px 10px; text-align: center;
}
.stat-value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11px; color: var(--muted); margin-top: 4px; }

.history { margin-bottom: 18px; }
.history h3 { font-size: 14px; margin: 0 0 10px; color: var(--muted); font-weight: 500; }
.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; padding: 8px 12px; border-radius: 10px;
  background: rgba(255,255,255,.04);
}
.history-row .hit { color: var(--accent); font-size: 11px; }
.history-bars { display: flex; align-items: flex-end; gap: 3px; height: 26px; }
.history-bars i { display: block; width: 5px; background: rgba(255,255,255,.28); border-radius: 2px; }
.history-bars i.hit { background: var(--accent); }

.ig-status {
  font-size: 12px; color: var(--muted); line-height: 1.5; margin-bottom: 16px;
  padding: 12px; border-radius: 12px; background: rgba(255,255,255,.04);
  border: 1px solid var(--stroke); word-break: break-word;
}
.ig-status.bad { color: #ffb4b4; border-color: rgba(255,80,80,.4); }

.btn {
  width: 100%; padding: 14px; border-radius: 14px; font-size: 15px; font-weight: 600;
  border: 1px solid var(--stroke); background: rgba(255,255,255,.08); color: var(--fg);
  cursor: pointer; margin-top: 10px;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn[disabled] { opacity: .5; cursor: default; }

/* ---------- Экран блокировки ---------- */
.blocked { display: flex; align-items: center; justify-content: center; padding: 28px; text-align: center; }
.blocked-inner { max-width: 360px; width: 100%; }
.blocked-emoji { font-size: 52px; margin-bottom: 12px; }
.blocked h1 { font-size: 21px; margin: 0 0 10px; line-height: 1.3; }
.blocked-used { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.countdown {
  font-size: 40px; font-weight: 700; font-variant-numeric: tabular-nums;
  letter-spacing: 1px; margin-bottom: 6px;
}
.blocked-note { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.blocked-hint { color: var(--muted); font-size: 12px; margin-top: 6px; line-height: 1.5; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  background: rgba(28,28,32,.96); border: 1px solid var(--stroke);
  padding: 11px 16px; border-radius: 12px; font-size: 13px; z-index: 40;
  opacity: 0; transition: all .25s ease; max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
