@font-face {
  font-family: 'Manrope';
  src: url('/fonts/Manrope-VariableFont_wght.woff2') format('woff2');
  font-weight: 200 800;               /* диапазон весов */
  font-style: normal;
  font-display: optional;             /* или fallback — для PWA часто лучший выбор */
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy: #1a2b5e;
  --navy-dark: #14234d;
  --navy-light: #e8ecf8;
  --red: #e63946;
  --green: #2dc76d;
  --bg: #f0f2f8;
  --white: #ffffff;
  --text: #111827;
  --muted: #8890a4;
  --border: #e4e8f0;
  --header-h: 60px;
  --nav-h: 78px;
  --nav-bottom: 14px;
  --nav-side: 14px;
  --radius: 18px;
}

html, body {
  height: 100%; width: 100%;
  font-family: 'Manrope', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── HEADER ── */
#app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 200;
}
.logo { font-size: 20px; font-weight: 800; color: var(--navy); letter-spacing: -.5px; }
.logo span { font-weight: 400; }
#back-btn {
  display: none; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--navy); padding: 4px 10px 4px 0;
}
#back-btn svg { width: 22px; height: 22px; display: block; }
#page-title { font-size: 18px; font-weight: 700; }
.header-right { display: flex; align-items: center; gap: 8px; }
.bonus-badge {
  background: var(--navy); color: #fff;
  font-size: 13px; font-weight: 700;
  padding: 5px 12px; border-radius: 8px;
  display: flex; align-items: center; gap: 5px;
}
.notif-btn {
  position: relative; background: none; border: none; cursor: pointer;
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
}
.notif-btn svg { width: 23px; height: 23px; color: var(--navy); }
.notif-dot {
  position: absolute; top: 2px; right: 2px;
  background: var(--red); color: #fff; font-size: 9px; font-weight: 800;
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}

/* ── CONTENT WRAP ── */
#content-wrap {
  position: fixed;
  top: var(--header-h);
  bottom: 0;
  left: 0;
  right: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);

  /* чтобы контент не попадал под нижнее меню */
  padding-bottom: calc(var(--nav-h) + var(--nav-bottom) + env(safe-area-inset-bottom) + 16px);
}

.home-spacer, .h-spacer { height: 0 !important; }

/* ── PRELOADER ── */
#preloader {
  display: none; position: absolute; inset: 0;
  background: var(--bg); z-index: 50;
  align-items: center; justify-content: center;
}
#preloader.active { display: flex; }
.spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--border);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── BOTTOM NAV ── */
#app-nav {
  position: fixed;
  bottom: var(--nav-bottom);
  left: var(--nav-side);
  right: var(--nav-side);
  height: var(--nav-h);
 background: var(--navy-dark);
  display: flex;
  border-radius: 22px;
  overflow: hidden;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(20,35,77,.35);

}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  color: rgba(255,255,255,.45);
  text-decoration: none; font-size: 10.5px; font-weight: 700;
  transition: color .2s; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border: none; background: none;
}
.nav-item svg { width: 24px; height: 24px; }
.nav-item.active { color: #fff; }

/* ── PAGE ANIMATION ── */
#page-content { animation: pageIn .22s ease; min-height: 100%; }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ── SHARED COMPONENTS ── */
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; background: var(--navy); color: #fff;
  font-family: 'Manrope', sans-serif; font-size: 16px; font-weight: 700;
  padding: 17px; border-radius: 16px; border: none; cursor: pointer;
  text-decoration: none; -webkit-tap-highlight-color: transparent;
  transition: transform .1s, opacity .1s;
}
.btn-primary:active { transform: scale(.98); opacity: .9; }
.btn-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: transparent; color: var(--navy);
  font-family: 'Manrope', sans-serif; font-size: 15px; font-weight: 700;
  padding: 14px 20px; border-radius: 14px; border: 2px solid var(--navy);
  cursor: pointer; text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.section-title { font-size: 17px; font-weight: 800; padding: 0 18px 10px; }
.card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(26,43,94,.06);
  overflow: hidden;
}
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 60px 20px; color: var(--muted);
  gap: 12px; font-size: 15px; font-weight: 600;
}

/* ── PROFILE SHARED ── */
.profile-banner { width: 100%; height: 190px; object-fit: cover; display: block; }
.profile-greeting { padding: 18px 18px 6px; font-size: 22px; font-weight: 800; color: var(--muted); }
.profile-menu { background: var(--white); margin: 10px 0 6px; }
.profile-menu-item {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  cursor: pointer; text-decoration: none; color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.profile-menu-item:last-child { border-bottom: none; }
.pmi-icon { width: 28px; display: flex; align-items: center; justify-content: center; }
.pmi-icon svg { width: 24px; height: 24px; }
.pmi-label { flex: 1; font-size: 15px; font-weight: 600; }
.pmi-arrow svg { width: 18px; height: 18px; color: var(--muted); }

/* ── CHAT SHARED ── */
.chat-item {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 18px; border-bottom: 1px solid var(--border);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  background: var(--white);
}
.chat-avatar {
  width: 50px; height: 50px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: #fff; flex-shrink: 0;
}
.chat-info { flex: 1; min-width: 0; }
.chat-name { font-size: 15px; font-weight: 700; margin-bottom: 3px; }
.chat-preview { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.chat-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.chat-badge {
  background: #555; color: #fff; font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
}
/* Персональный bg для страниц внизу */
body[data-page="book"] #content-wrap {
  background: var(--white);
}
body[data-page="profile"] #content-wrap {
  background: var(--white);
}
/* ── HEADER: center page title on sub-pages ── */
#app-header {
  position: relative; /* already fixed but we need grid layout */
}

/* Override header layout for sub-pages with a title */
body:not([data-page="home"]) #app-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 8px 0 4px;
}

body:not([data-page="home"]) #app-header > div:first-child {
  justify-self: start;
}

body:not([data-page="home"]) #app-header > div:last-child {
  justify-self: end;
}

#page-title {
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* STO-map page: content fills screen without padding-bottom */
body[data-page="book"] #content-wrap,
body[data-page="sto-map"] #content-wrap {
  background: var(--white);
  padding-bottom: 0;
  overflow: hidden;
}

/* Header mid: hidden by default, shown on sub-pages */
#header-mid { display: none; }
body.has-title #header-mid { display: flex !important; }
