/* ── Sidebar overlay ── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(20, 22, 30, .6);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}

.sidebar-overlay.open {
  opacity: 1;
  pointer-events: all;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  z-index: 400;
  background: var(--s1);
  border-right: 1px solid var(--border2);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-head);
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.3px;
}

.sidebar-logo svg {
  color: var(--accent);
}

.sidebar-close {
  background: none;
  border: none;
  color: var(--ink3);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--r3);
  display: flex;
  transition: color .15s, background .15s;
}

.sidebar-close:hover {
  color: var(--ink);
  background: var(--s3);
}

.sidebar-nav {
  flex: 1;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--r2);
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink3);
  cursor: pointer;
  transition: all .15s;
  text-align: left;
  position: relative;
}

.sidebar-link svg {
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
}

.sidebar-link span:first-of-type {
  flex: 1;
}

.sidebar-link:hover {
  color: var(--ink2);
  background: var(--s2);
}

.sidebar-link.active {
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(59, 130, 246, .14);
}

.sidebar-link:active {
  transform: scale(.97);
}

.sidebar-badge {
  background: var(--red);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

.sidebar-badge--gold {
  background: var(--accent) !important;
  color: #07101e !important;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-version {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink3);
  letter-spacing: 1px;
}

/* ── Topbar ── */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  z-index: 200;
  background: rgba(18, 18, 18, .92);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border2);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

[data-theme="light"] .topbar {
  background: rgba(238, 240, 250, .92);
}

.burger-btn {
  width: 34px;
  height: 34px;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: var(--r3);
  transition: background .15s;
  flex-shrink: 0;
}

.burger-btn:hover {
  background: var(--s2);
}

.burger-btn span {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--ink2);
  border-radius: 2px;
  transition: all .2s;
}

.topbar-title {
  flex: 1;
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Pages ── */
.page {
  display: none;
  position: relative;
  z-index: 1;

  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 80px);
  height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.page.active {
  display: block;
}

#pageAi.active {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-bottom: 0;
  overflow: hidden;
}

.page-header {
  margin-bottom: 22px;
}

.page-header-title {
  font-family: var(--font-head);
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.4px;
  margin-bottom: 4px;
}

.page-header-sub {
  font-size: 13px;
  color: var(--ink3);
}

#pageDashboard {
  padding: 0px;
  padding-bottom: 0px;
}

/* ── Glass navbar ── */
.glass-navbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 456px;
  height: var(--navbar-h);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 6px calc(env(safe-area-inset-bottom, 6px) + 4px);
  background: rgba(35, 37, 39, 0.637);
  backdrop-filter: blur(10px) saturate(1.6);
  -webkit-backdrop-filter: blur(10px) saturate(1.6);
  border-radius: 22px;
  border: none;
  outline: none;
  margin-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);

}

[data-theme="light"] .glass-navbar {
  background: rgba(238, 240, 250, .88);
  border-color: rgba(80, 100, 150, .12);
  box-shadow: 0 -2px 20px rgba(0, 0, 0, .08);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 14px;
  transition: all .18s cubic-bezier(.34, 1.4, .64, 1);
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.nav-item svg {
  width: 21px;
  height: 21px;
  stroke: var(--ink3);
  fill: none;
  transition: stroke .18s, transform .2s cubic-bezier(.34, 1.4, .64, 1);
}

.nav-item span {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--ink3);
  transition: color .18s;
}

.nav-item.active svg {
  stroke: var(--accent);
  transform: scale(1.1) translateY(-1px);
}

.nav-item.active span {
  color: var(--accent);
}

.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .7;
}

.nav-item:active {
  transform: scale(.88);
}

/* Кнопка "Ещё" */
.nav-item--more {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 14px;
  transition: all .18s cubic-bezier(.34, 1.4, .64, 1);
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.nav-item--more svg {
  width: 21px;
  height: 21px;
}

.nav-item--more span {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--ink3);
  transition: color .18s;
}

.nav-item--more.open span {
  color: var(--accent);
}

.nav-item--more:active {
  transform: scale(.88);
}

/* Скрываем топбар — используем шторку */
.topbar {
  display: none !important;
}

/* ═══════════════════════════════
   ИКОНКИ НАВБАРА / САЙДБАРА ИЗ SVG-ФАЙЛОВ
   (assets/navbar_icons/*.svg — белые заливки, перекрашиваются через mask)
═══════════════════════════════ */
.nav-icon {
  display: block;
  flex-shrink: 0;
}

.sidebar-link .nav-icon {
  width: 17px;
  height: 17px;
}

.nav-item .nav-icon {
  width: 21px;
  height: 21px;
}

@supports ((mask-image: url("")) or (-webkit-mask-image: url(""))) {
  .nav-icon {
    background-color: currentColor;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
    transition: background-color .18s, transform .2s cubic-bezier(.34, 1.4, .64, 1);
  }

  .nav-icon--home {
    -webkit-mask-image: url('../assets/navbar_icons/home.svg');
    mask-image: url('../assets/navbar_icons/home.svg');
  }

  .nav-icon--channel {
    -webkit-mask-image: url('../assets/navbar_icons/channel.svg');
    mask-image: url('../assets/navbar_icons/channel.svg');
  }

  .nav-item .nav-icon {
    background-color: var(--ink3);
  }

  .nav-item.active .nav-icon {
    background-color: var(--accent);
    transform: scale(1.1) translateY(-1px);
  }
}

/* ── Отступы сверху для страниц ── */
.page {
  padding-top: 32px !important;
}

#pageDashboard {
  padding-top: 0px !important;
}

#pageAi.active {
  padding-top: 0 !important;
}

.ai-scroll-area {
  padding-top: 24px !important;
}

/* ── Отступ снизу для всех страниц (чтобы контент не прятался под навбаром) ── */
.page {
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--navbar-h, 62px) + 24px) !important;
}

/* Dashboard и AI управляют отступами сами */
#pageDashboard {
  padding-bottom: 0px !important;
}

#pageAi.active {
  padding-bottom: 0 !important;
}

/* ── Sections ── */
.section {
  margin-bottom: 20px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 11px;
}

.section-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--ink3);
}

.section-count {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--ink3);
  background: var(--s2);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 20px;
}

/* ── Skeleton ── */
.sk-line {
  display: inline-block;
  height: .8em;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--s2) 25%, var(--s3) 50%, var(--s2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  vertical-align: middle;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }

  to {
    background-position: -200% 0;
  }
}

/* ── Animations ── */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-3px);
  }

  75% {
    transform: translateX(3px);
  }
}

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

@keyframes blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .3;
  }
}

@keyframes ripple {
  0% {
    transform: scale(.5);
    opacity: .8;
  }

  50% {
    transform: scale(2.4);
    opacity: 0;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

/* ── Pulse dot ── */
.pulse-ring {
  position: relative;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pulse-ring::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(57, 255, 20, .18);
  animation: ripple 2.5s ease-out infinite;
}

.pulse-ring.sm {
  width: 10px;
  height: 10px;
}

.pulse-ring.sm::before {
  width: 10px;
  height: 10px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  position: relative;
  z-index: 1;
}

.pulse-dot.off {
  background: var(--red);
}

.pulse-ring.sm .pulse-dot {
  width: 5px;
  height: 5px;
}

.pulse-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--green);
}

.pulse-label.off {
  color: var(--red);
}

/* ── More sheet ── */
.more-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 490;
  background: rgba(20, 22, 30, .55);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s cubic-bezier(.4, 0, .2, 1);
}

.more-sheet-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.more-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 480px;
  z-index: 495;
  background: var(--s1);
  border-top: 1px solid var(--border2);
  border-radius: 20px 20px 0 0;
  padding: 0 0 calc(env(safe-area-inset-bottom, 0px) + 80px);
  transition: transform .32s cubic-bezier(.34, 1.15, .64, 1);
}

.more-sheet.open {
  transform: translateX(-50%) translateY(0);
}

.more-sheet__handle {
  width: 36px;
  height: 3px;
  background: var(--border2);
  border-radius: 2px;
  margin: 12px auto 0;
}

.more-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border);
}

.more-sheet__title {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.2px;
}

.more-sheet__close {
  width: 28px;
  height: 28px;
  background: var(--s2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink3);
  cursor: pointer;
  transition: all .15s;
}

.more-sheet__close:hover {
  color: var(--ink);
  background: var(--s3);
}

.more-sheet__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px 6px;
  padding: 16px 10px 8px;
}

.more-sheet-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 6px 2px 2px;
  background: transparent;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: all .18s cubic-bezier(.34, 1.4, .64, 1);
  user-select: none;
}

.more-sheet-item:hover {
  background: transparent;
}

.more-sheet-item:active {
  transform: scale(.93);
}

/* Один квадрат под иконку (без внешней «плитки») — единый серый цвет */
.more-sheet-item__icon {
  width: 100%;
  max-width: 96px;
  aspect-ratio: 1;
  border-radius: 18px;
  background: var(--s2);
  border: 1px solid var(--border2);
  color: var(--ink2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.more-sheet-item__icon svg,
.more-sheet-item__icon img {
  width: 28px;
  height: 28px;
}

.more-sheet-item__icon svg {
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.more-sheet-item__icon-wrap {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}

.more-sheet-item__label {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
}

.more-sheet__divider {
  height: 1px;
  background: var(--border);
  margin: 4px 16px 12px;
}

.more-sheet__status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px 0;
}

.more-sheet__status-left {
  display: flex;
  align-items: center;
  gap: 7px;
}

.more-sheet__status-text {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--ink3);
  text-transform: uppercase;
}

.more-sheet__version {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink3);
}

/* Иконки в шторке — единый нейтральный цвет (серый), задан в .more-sheet-item__icon */

/* Кастомная иконка истории (assets/icons/history.svg) — файл белый, в светлой теме инвертируем */
[data-theme="light"] .more-sheet-item--history .more-sheet-item__icon img {
  filter: invert(1);
}

/* Скрываем старые элементы */
.bottom-bar,
.bot-status-bar,
.nav,
.nav-pulse {
  display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 3px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 2px;
}

/* ── Hide floating theme toggle (из fixes.css) ── */
#themeToggleFloat {
  display: none !important;
}