/* БебеБазар — лек собствен CSS, без външни зависимости.
   Палитра: топло кремаво + зелено (доверие) + коралов акцент (действие). */

:root {
  --bg: #fbf9f4;
  --surface: #ffffff;
  --ink: #2f3a36;
  --muted: #6d7a74;
  --line: #e6e2d8;
  --green: #0f6e56;
  --green-soft: #e1f5ee;
  --coral: #d85a30;
  --coral-dark: #b34724;
  --coral-soft: #fbeae0;
  --radius: 14px;
  /* Значка "Продадено" — умишлено тъмна плочка и в двете теми, не следва --ink. */
  --badge-dark: #2f3a36;
}

/* ---------- Преход между страници ----------
   View Transitions API — вграден в браузъра кросфейд между навигации в
   рамките на сайта, без нито ред JS. Браузъри без поддръжка просто го
   игнорират (обикновена навигация, без анимация) — нулева цена, нулев риск. */
@view-transition {
  navigation: auto;
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: .12s;
}
/* Резервен лек fade-in при зареждане — работи навсякъде, включително
   браузъри без View Transitions. Само opacity (евтино за GPU), кратко. */
body { animation: page-fade-in .15s ease; }
@keyframes page-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  body { animation: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

/* ---------- Лого-въртележка при бавно зареждане ---------- */
.page-loading-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .15s ease, visibility 0s linear .15s;
}
.page-loading-overlay.show {
  opacity: .97; visibility: visible; pointer-events: auto;
  transition: opacity .15s ease, visibility 0s linear;
}
.page-loading-logo svg, .page-loading-logo img {
  width: 64px; height: 64px; display: block;
  animation: page-loading-spin 1s linear infinite;
}
@keyframes page-loading-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .page-loading-logo svg, .page-loading-logo img { animation: none; }
}

/* ---------- Тъмен режим ----------
   Прилага се или от системните настройки (ако потребителят не е избрал ръчно),
   или изрично през data-theme, което header.php сменя при клик и пази в
   localStorage. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #171a18; --surface: #202422; --ink: #c2bfb8; --muted: #8b928d; --line: #343a37; --green: #3ecb9e; --green-soft: #163229; --coral: #ff8b62; --coral-dark: #ffab8a; --coral-soft: #3a241c; }
  :root:not([data-theme="light"]) body { background-image: url('bg-pattern-dark.svg'); }
  :root:not([data-theme="light"]) .site-header { background: linear-gradient(120deg, #2a2230, #1c2733); }
  :root:not([data-theme="light"]) .site-header::after { background-image: url('header-wave-dark.svg'); }
  :root:not([data-theme="light"]) .fc-thread-0 { border-color: #1f4a3b; }
  :root:not([data-theme="light"]) .fc-thread-1 { border-color: #5a3221; }
  :root:not([data-theme="light"]) .fc-thread-2 { background: #202b3a; border-color: #2c3d54; }
  :root:not([data-theme="light"]) .fc-thread-3 { background: #2c2333; border-color: #3d2f47; }
  :root:not([data-theme="light"]) .fc-thread-4 { background: #332f1a; border-color: #4a4324; }
  :root:not([data-theme="light"]) .fc-bubble-topic { border-color: #1f4a3b; }
  :root:not([data-theme="light"]) .tracker-due-banner { border-color: #5a3221; }
  :root:not([data-theme="light"]) .tracker-sleep-status { border-color: #1f4a3b; }
  :root:not([data-theme="light"]) .error-box { background: #3a2020; color: #f5b8b8; }
  :root:not([data-theme="light"]) .req { color: #ff8f8f; }
  :root:not([data-theme="light"]) .btn-danger { background: #3a2020; border-color: #5a2f2f; color: #ff8f8f; }
}
:root[data-theme="dark"] { --bg: #171a18; --surface: #202422; --ink: #c2bfb8; --muted: #8b928d; --line: #343a37; --green: #3ecb9e; --green-soft: #163229; --coral: #ff8b62; --coral-dark: #ffab8a; --coral-soft: #3a241c; }
:root[data-theme="dark"] body { background-image: url('bg-pattern-dark.svg'); }
:root[data-theme="dark"] .site-header { background: linear-gradient(120deg, #2a2230, #1c2733); }
:root[data-theme="dark"] .site-header::after { background-image: url('header-wave-dark.svg'); }
:root[data-theme="dark"] .fc-thread-0 { border-color: #1f4a3b; }
:root[data-theme="dark"] .fc-thread-1 { border-color: #5a3221; }
:root[data-theme="dark"] .fc-thread-2 { background: #202b3a; border-color: #2c3d54; }
:root[data-theme="dark"] .fc-thread-3 { background: #2c2333; border-color: #3d2f47; }
:root[data-theme="dark"] .fc-thread-4 { background: #332f1a; border-color: #4a4324; }
:root[data-theme="dark"] .fc-bubble-topic { border-color: #1f4a3b; }
:root[data-theme="dark"] .tracker-due-banner { border-color: #5a3221; }
:root[data-theme="dark"] .tracker-sleep-status { border-color: #1f4a3b; }
:root[data-theme="dark"] .error-box { background: #3a2020; color: #f5b8b8; }
:root[data-theme="dark"] .req { color: #ff8f8f; }
:root[data-theme="dark"] .btn-danger { background: #3a2020; border-color: #5a2f2f; color: #ff8f8f; }

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg) url('bg-pattern.svg') repeat;
  color: var(--ink);
  line-height: 1.55;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

.container { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

/* ---------- Header ---------- */
.site-header {
  background: linear-gradient(120deg, #fbe4ef, #e3ecfa);
  border-bottom: none;
  position: sticky; top: 0; z-index: 10;
}
.site-header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -7px; height: 14px;
  background: url('header-wave.svg') repeat-x;
  background-size: 40px 14px;
  pointer-events: none;
}
.header-inner { display: flex; align-items: center; gap: 14px; padding: 10px 16px; flex-wrap: wrap; }
.logo { font-size: 20px; font-weight: 700; color: var(--ink); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.logo:hover { text-decoration: none; }
.logo-mark svg, .logo-mark img { width: 42px; height: 42px; display: block; object-fit: contain; }
.search { display: flex; }
.search input {
  flex: 1; padding: 9px 14px; border: 1px solid var(--line);
  border-radius: 999px 0 0 999px; font-size: 14px; background: var(--bg); outline-color: var(--green);
}
.search button { border: 1px solid var(--line); border-left: 0; background: var(--surface); border-radius: 0 999px 999px 0; padding: 0 14px; cursor: pointer; }
.home-search { max-width: 480px; margin: 0 auto 22px; }
.nav { display: flex; align-items: center; gap: 14px; font-size: 14px; margin-left: auto; min-width: 0; }
.nav-account { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
.nav-account .nav-icon { display: none; }
.nav-account .nav-icon svg { width: 22px; height: 22px; display: block; }
.guest-login-btn { display: inline-flex; align-items: center; gap: 4px; background: #e98a8a; border-color: #e98a8a; color: #fff; }
.guest-login-btn:hover { background: #de7373; border-color: #de7373; }
.guest-login-icon { display: inline-flex; }
.guest-login-icon svg { width: 17px; height: 17px; display: block; }
.nav-publish-icon { margin-right: 4px; }
.nav-text-short { display: none; }

/* ---------- Падащо меню „Моят профил" ---------- */
.dropdown { position: relative; }
.dropdown-trigger {
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  font: inherit; padding: 8px 14px; position: relative; cursor: pointer;
}
.dropdown-trigger:hover { border-color: var(--green); }
.dropdown-caret { font-size: 16px; color: var(--muted); margin-left: 1px; line-height: 1; }
.hamburger-btn {
  display: none; border: 1px solid var(--line); background: var(--bg); border-radius: 50%;
  width: 36px; height: 36px; align-items: center; justify-content: center;
  cursor: pointer; position: relative; flex-shrink: 0;
}
.hamburger-btn .bar {
  display: block; width: 16px; height: 2px; background: var(--ink); border-radius: 2px;
  position: absolute; left: 50%; transform: translateX(-50%);
  transition: transform .25s ease, opacity .2s ease;
}
.hamburger-btn .bar:nth-child(1) { top: 12px; }
.hamburger-btn .bar:nth-child(2) { top: 17px; }
.hamburger-btn .bar:nth-child(3) { top: 22px; }
.hamburger-btn.open .bar:nth-child(1) { transform: translateX(-50%) translateY(5px) rotate(45deg); }
.hamburger-btn.open .bar:nth-child(2) { opacity: 0; }
.hamburger-btn.open .bar:nth-child(3) { transform: translateX(-50%) translateY(-5px) rotate(-45deg); }
.nav-hamburger { display: none; }
.dropdown-menu {
  position: absolute; top: calc(100% + 12px); right: 0; min-width: 210px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,.12); padding: 6px; z-index: 20;
  transform-origin: top right;
  opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(-6px) scale(.98);
  transition: opacity .16s ease, transform .16s ease, visibility 0s linear .16s;
}
.dropdown-menu.open {
  opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0) scale(1);
  transition: opacity .16s ease, transform .16s ease, visibility 0s linear;
}
.dropdown-menu a, .dropdown-item-disabled {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-radius: 8px; font-size: 14px; color: var(--ink); white-space: nowrap;
}
.dropdown-menu a:hover { background: var(--bg); text-decoration: none; }
.dropdown-menu a[hidden] { display: none; }
.dropdown-menu a.dropdown-profile-link { justify-content: flex-start; font-weight: 700; font-size: 15px; }
.dropdown-menu-btn.theme-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 9px 12px; border-radius: 8px; font-size: 14px; font-family: inherit;
  color: var(--ink); background: none; border: none; cursor: pointer; text-align: left;
}
.dropdown-menu-btn.theme-toggle:hover { background: var(--bg); }
.dropdown-menu-btn.theme-toggle svg { width: 18px; height: 18px; }
.dropdown-profile-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-item-disabled { color: var(--muted); cursor: default; }
.dropdown-item-disabled small { font-size: 11px; }
.dropdown-badge {
  background: var(--coral); color: #fff; font-size: 10px; font-weight: 700; min-width: 16px; height: 16px;
  border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px;
}
.nav-badge[hidden], .dropdown-badge[hidden] { display: none; }
.forum-team-badge {
  display: inline-block; font-size: 11px; font-weight: 700; color: var(--green);
  background: var(--green-soft); border-radius: 999px; padding: 2px 8px; margin-left: 6px;
  vertical-align: middle;
}
.dropdown-divider { height: 1px; background: var(--line); margin: 5px 6px; }
.nav-favorites { font-size: 21px; line-height: 1; display: inline-flex; align-items: center; transition: transform .12s ease; }
.nav-favorites:hover { text-decoration: none; transform: scale(1.15); }

@media (max-width: 640px) {
  .header-inner { padding: 6px 8px; gap: 6px; }
  .nav { gap: 6px; }
  .logo-text { display: none; }
  .logo-mark svg, .logo-mark img { width: 34px; height: 34px; }
  .nav-text-only { display: none; }

  .nav-hide-mobile { display: none; }
  .nav-hamburger { display: inline-flex; }
  .hamburger-btn { display: flex; }
}

/* ---------- Бутони ---------- */
.btn {
  display: inline-block; padding: 9px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer;
}
.btn:hover { text-decoration: none; filter: brightness(0.97); }
.btn-primary { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn-primary:hover { background: var(--coral-dark); }
.btn-secondary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-danger { background: #fcebeb; border-color: #f0c0c0; color: #a32d2d; }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* ---------- Мото ---------- */
.hero {
  text-align: center; padding: 40px 0 12px;
  font-family: ui-rounded, "Segoe UI Rounded", "Century Gothic", Verdana, sans-serif;
}
.hero h1 { margin: 0; font-size: 34px; font-weight: 800; letter-spacing: -.01em; color: var(--ink); }
.hero p { margin: 10px 0 0; color: var(--muted); font-size: 16px; }

/* ---------- Категории ---------- */
.cats-heading { text-align: center; font-size: 19px; margin: 18px 0 0; }
.cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 10px; padding: 22px 0; }
.cat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  text-align: center; padding: 14px 6px; color: var(--ink); font-size: 13px;
  transition: transform .12s ease;
}
.cat:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--green); }
.cat .ico { display: block; margin-bottom: 6px; }
.cat .ico svg { width: 26px; height: 26px; color: var(--green); }
.cat .ico img { width: 60px; height: 60px; object-fit: contain; display: block; margin: 0 auto; }
.cat-stats { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 11px; margin-top: 4px; }
.cat-stat-comments { display: inline-flex; align-items: center; gap: 3px; }
.cat-stat-comments svg { width: 13px; height: 13px; }

@media (min-width: 641px) {
  .cats { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Обяви (карти) ---------- */
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 12px 0 4px; }
.section-head h2, .section-head h1 { font-size: 19px; margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; padding: 12px 0 28px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; color: var(--ink); display: flex; flex-direction: column;
  transition: transform .12s ease, box-shadow .12s ease;
}
.card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.06); }
.card .thumb { aspect-ratio: 4/3; background: var(--green-soft); object-fit: cover; width: 100%; }
.card .thumb-empty { aspect-ratio: 4/3; background: var(--green-soft); display: flex; align-items: center; justify-content: center; font-size: 30px; }
.card .body { padding: 10px 12px 12px; }
.card .title { font-size: 14px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .price { font-size: 16px; font-weight: 700; margin: 3px 0 2px; color: var(--green); }
.card .meta { font-size: 12px; color: var(--muted); }
.badge-sold {
  position: absolute; margin: 8px; background: var(--badge-dark); color: #fff;
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
}

/* ---------- Формуляри ---------- */
.form-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px; max-width: 560px; margin: 28px auto;
}

/* ---------- Съветник стъпка по стъпка (регистрация) ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 24, 22, .55); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-backdrop[hidden] { display: none; }
.name-edit-form { display: flex; gap: 6px; align-items: center; margin: 0 0 12px; justify-content: center; }
.name-edit-form[hidden] { display: none; }
.modal-box {
  display: none; background: var(--surface); border-radius: var(--radius);
  padding: 26px; max-width: 420px; width: 100%; max-height: 90vh; overflow-y: auto;
}
.modal-box.active { display: block; }
.form-card h1 { margin-top: 0; font-size: 22px; }
label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; font-family: inherit; background: var(--surface); color: var(--ink); outline-color: var(--green);
}
textarea { min-height: 120px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.error-box { background: #fcebeb; color: #791f1f; padding: 12px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 8px; }
.req { color: #a32d2d; }
.flash { background: var(--green-soft); color: var(--green); padding: 12px 14px; border-radius: 10px; font-size: 14px; margin: 14px 0; }

/* ---------- Страница на обява ---------- */
.listing-page { display: grid; grid-template-columns: 3fr 2fr; gap: 22px; padding: 24px 0; }
.gallery-main { border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); width: 100%; aspect-ratio: 4/3; object-fit: contain; cursor: zoom-in; }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 8px; }
.gallery-thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 2px solid transparent; cursor: pointer; }
.gallery-thumbs img.active { border-color: var(--coral); }

/* ---------- Lightbox — пълноекранен преглед на снимките ---------- */
.lightbox { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.6); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; touch-action: pan-y; }
.lightbox[hidden] { display: none; }
.lightbox-img { max-width: 92vw; max-height: 88vh; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.lightbox-close, .lightbox-nav {
  position: absolute; border: none; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s ease;
}
.lightbox-close:hover, .lightbox-nav:hover { background: rgba(255,255,255,.24); }
.lightbox-close { top: 14px; right: 14px; width: 40px; height: 40px; font-size: 20px; }
.lightbox-nav { top: 50%; transform: translateY(-50%); width: 48px; height: 48px; font-size: 28px; line-height: 1; }
.lightbox-prev { left: 14px; }
.lightbox-next { right: 14px; }
.lightbox-nav[hidden] { display: none; }
.lightbox-counter {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,.85); font-size: 13px; background: rgba(255,255,255,.14); padding: 4px 12px; border-radius: 999px;
}
@media (max-width: 640px) {
  .lightbox-nav { width: 40px; height: 40px; font-size: 22px; }
  .lightbox-close { width: 34px; height: 34px; font-size: 18px; }
}
.info-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; align-self: start; }
.info-card h1 { font-size: 21px; margin: 0 0 6px; }
.info-card .price { font-size: 26px; font-weight: 700; color: var(--green); margin: 0 0 12px; }
.spec { display: flex; justify-content: space-between; font-size: 14px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.spec span:first-child { color: var(--muted); }
.contact-box { background: var(--green-soft); border-radius: 10px; padding: 14px; margin-top: 16px; font-size: 15px; }
.desc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 28px; white-space: pre-wrap; }

/* ---------- Чат ---------- */
.chat-layout { display: grid; grid-template-columns: 280px 1fr; gap: 20px; padding: 24px 0; align-items: start; }
.chat-sidebar {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; max-height: 640px; overflow-y: auto;
}
.chat-sidebar .chat-list-item { padding: 8px 6px; border-radius: 10px; position: relative; }
.chat-sidebar .chat-list-item:hover { background: var(--bg); text-decoration: none; }
.chat-sidebar .chat-list-item.active { background: var(--green-soft); }
.chat-main.form-card { margin: 0; max-width: none; }
.chat-back-mobile { display: none; margin-right: 12px; }
@media (max-width: 780px) {
  .chat-layout { grid-template-columns: 1fr; padding: 12px 0 24px; }
  .chat-sidebar { display: none; }
  .chat-back-mobile { display: inline; }
}
.chat-thread { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; padding: 4px 2px; }
.chat-msg { align-self: flex-start; max-width: 78%; }
.chat-msg.mine { align-self: flex-end; }
.chat-bubble { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.chat-msg.mine .chat-bubble { background: var(--green); color: #fff; border-color: var(--green); }
.chat-time { font-size: 11px; color: var(--muted); margin: 3px 4px 0; }
.chat-msg.mine .chat-time { text-align: right; }
.chat-list-item { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.chat-list-item:last-child { border-bottom: none; }
.chat-list-item img, .chat-list-thumb-empty { width: 48px; height: 36px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.chat-list-thumb-empty { background: var(--green-soft); display: flex; align-items: center; justify-content: center; font-size: 16px; }
.chat-list-body { flex: 1; min-width: 0; }
.chat-list-body .who { font-size: 14px; font-weight: 600; }
.chat-list-body .snippet { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--coral); flex-shrink: 0; }
.avatar-img { border-radius: 50%; object-fit: cover; display: inline-block; }
.avatar-fallback {
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
  color: #fff; font-weight: 700; flex-shrink: 0; font-family: inherit;
}
.chat-filter { display: flex; gap: 6px; margin-bottom: 10px; }
.chat-filter-btn {
  flex: 1; padding: 6px 8px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.chat-filter-btn.active { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.nav-badge {
  position: absolute; top: -6px; right: -10px; background: var(--coral); color: #fff;
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px; line-height: 1;
}

/* ---------- Филтри ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 18px 0 6px; align-items: end; }
.filters .f { flex: 1; min-width: 130px; }
.filters label { margin: 0 0 3px; font-size: 12px; }

/* ---------- Таблици (профил, админ) ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 18px 0 30px; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th, table.list td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
table.list th { background: var(--bg); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.list tr:last-child td { border-bottom: 0; }

/* ---------- Страниране ---------- */
.pager { display: flex; gap: 6px; justify-content: center; padding: 6px 0 32px; }
.pager a, .pager span { padding: 7px 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 14px; }
.pager .cur { background: var(--green); color: #fff; border-color: var(--green); }

/* ---------- Форум ---------- */
.forum-topic-row {
  display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); margin-bottom: 10px; color: var(--ink); transition: transform .12s ease;
}
.forum-topic-row:hover { border-color: var(--green); text-decoration: none; transform: translateY(-1px); }
.forum-topic-row .title { font-weight: 700; font-size: 15px; margin: 0 0 4px; }
.forum-topic-row .meta { font-size: 12px; color: var(--muted); margin: 0; }
.forum-status-pending, .forum-status-rejected {
  display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 12px; color: #fff; margin-bottom: 8px;
}
.forum-status-pending { background: #e0a800; }
.forum-status-rejected { background: #c0392b; }

/* ---------- Форум — коментари (аватар + балонче + мета ред) ---------- */
/* Всяка тема-нишка (основен отговор + неговите подотговори) седи в едно
   цветно поле — цветът показва кой подотговор към кой отговор принадлежи,
   вместо свързващи линии (изпробвано и премахнато — не се получи надеждно). */
.fc-thread { border-radius: var(--radius); border: 1px solid transparent; padding: 16px 18px; margin-bottom: 20px; }
.fc-thread-0 { background: var(--green-soft); border-color: #bfe3d5; }
.fc-thread-1 { background: var(--coral-soft); border-color: #f3d3c2; }
.fc-thread-2 { background: #e3ecfa; border-color: #c7d9f5; }
.fc-thread-3 { background: #f5e9fb; border-color: #e2c9ee; }
.fc-thread-4 { background: #fdf6d8; border-color: #f0e2a0; }
.fc-comment { display: flex; gap: 10px; align-items: flex-start; }
.fc-comment + .fc-comment { margin-top: 14px; }
.fc-avatar { flex-shrink: 0; }
.fc-col { flex: 1; min-width: 0; }
.fc-bubble {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 10px 14px; display: inline-block; max-width: 100%;
}
.fc-bubble-topic { background: var(--green-soft); border-color: #bfe3d5; }
.fc-name { font-weight: 700; font-size: 14px; margin: 0; }
.fc-body { font-size: 14px; margin: 2px 0 0; white-space: pre-wrap; }
.fc-mention { font-weight: 700; color: var(--green); }
.fc-edited { font-style: italic; cursor: help; }
.fc-body-collapsed { cursor: pointer; color: var(--muted); }
.fc-body-collapsed:hover { color: var(--ink); }
.fc-meta { display: flex; align-items: center; gap: 10px; margin: 6px 0 0 4px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.fc-meta form { margin: 0; display: contents; }
.fc-action {
  background: none; border: none; padding: 0; font-size: 12px; font-weight: 700;
  color: var(--muted); cursor: pointer; font-family: inherit;
}
.fc-action:hover { color: var(--green); text-decoration: underline; }
.fc-action.active-up { color: var(--green); }
.fc-action.active-down { color: var(--coral-dark); }
.fc-nested-group { margin-left: 40px; padding-top: 14px; }
.fc-reply-box { margin: 10px 0 0 4px; }
.fc-reply-box textarea { min-height: 70px; }
.fc-show-earlier {
  background: none; border: none; padding: 0; margin: 0 0 12px 4px; font-size: 13px; font-weight: 700;
  color: var(--green); cursor: pointer; font-family: inherit; display: block;
}
.fc-show-earlier:hover { text-decoration: underline; }
.forum-new-notice {
  background: var(--green-soft); color: var(--green); border: 1px solid var(--green);
  border-radius: var(--radius); padding: 10px 14px; font-size: 14px; margin: 0 0 14px;
}
.forum-new-notice a { font-weight: 700; text-decoration: underline; }
.forum-float-reply-btn {
  position: fixed; right: 18px; bottom: 18px; z-index: 50;
  padding: 12px 20px; border-radius: 999px; font-size: 14px; font-weight: 700;
  background: var(--coral); color: #fff; border: none; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
}
.forum-float-reply-btn:hover { background: var(--coral-dark); }
@media (max-width: 640px) {
  .forum-float-reply-btn { right: 12px; bottom: 12px; padding: 10px 16px; font-size: 13px; }
}

/* ---------- Дневник на бебето (сън/хранене) ---------- */
.tracker-tabs { display: flex; justify-content: center; gap: 12px; margin: 16px 0 18px; flex-wrap: wrap; }
.tracker-tab-btn {
  padding: 14px 28px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 17px; font-weight: 600; cursor: pointer; color: var(--ink);
  min-width: 230px; text-align: center;
}
.tracker-tab-btn.active { background: var(--green); border-color: var(--green); color: #fff; }
.tracker-stat-cards { display: flex; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.tracker-stat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; min-width: 140px; flex: 1;
}
.tracker-stat-card .num { font-size: 24px; font-weight: 700; color: var(--green); }
.tracker-stat-card .label { font-size: 12px; color: var(--muted); }
.tracker-due-banner {
  background: var(--coral-soft); border: 1px solid #f3d3c2; border-radius: var(--radius);
  padding: 12px 16px; font-size: 14px; margin: 0 0 14px; font-weight: 600; color: var(--coral-dark);
}
.tracker-settings { margin: 18px 0; }
.tracker-settings .f { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.tracker-settings input[type=number] { width: 100px; }
.tracker-save-btn { padding: 12px 28px; font-size: 15px; }
.tracker-settings-view { margin: 18px 0; font-size: 14px; color: var(--ink); }
.tracker-settings-view strong { color: var(--green); }
.tracker-big-btn { padding: 18px; font-size: 17px; border-radius: var(--radius); width: 100%; margin: 16px 0; }
.tracker-datetime-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tracker-datetime-row input[type=number] { width: 56px; text-align: center; }
.tracker-now-btn { white-space: nowrap; }
.tracker-sleep-status {
  text-align: center; margin: 14px 0; padding: 14px; background: var(--green-soft);
  border-radius: var(--radius); border: 1px solid #bfe3d5;
}
.tracker-sleep-status strong { display: block; font-size: 22px; color: var(--green); letter-spacing: .04em; }
.tracker-sleep-status span { display: block; font-size: 28px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tracker-history-filter { display: flex; align-items: center; gap: 10px; margin: 10px 0 14px; flex-wrap: wrap; font-size: 14px; }
.tracker-history-filter input[type=date] { width: auto; }
/* На тесен екран таблиците (час на заспиване/събуждане, времетраене, бутон)
   не се събират на ширина — скриваме текста на бутона за корекция и
   оставяме само иконата, за да не остане извън видимата част без скрол. */
@media (max-width: 640px) {
  table.list th, table.list td { padding: 8px 8px; }
  .tracker-edit-label { display: none; }
}

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 20px; }
.site-footer .container { padding: 18px 16px; font-size: 13px; color: var(--muted); text-align: center; }
.footer-note { font-size: 12px; margin-top: 4px; }

/* ---------- Бутон за тъмен режим ---------- */
.theme-toggle {
  background: none; border: none; padding: 0; margin: 0; cursor: pointer;
  display: inline-flex; align-items: center; color: var(--ink); flex-shrink: 0;
}
.theme-toggle svg { width: 22px; height: 22px; display: block; }
/* Бутонът показва иконата на режима, към който ще превключи при клик —
   не текущия режим. В светъл режим се вижда луна (нощен режим е "на един клик"),
   в тъмен режим се вижда слънце. */
.theme-toggle .theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-icon-sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .theme-icon-moon { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .theme-icon-sun { display: block; }
}

/* ---------- Бутон "нагоре" ---------- */
.back-to-top {
  position: fixed; right: 18px; bottom: 18px; z-index: 40;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
}
.back-to-top.show {
  opacity: 1; visibility: visible; transform: translateY(0);
  transition: opacity .2s ease, transform .2s ease, visibility 0s linear;
}
.back-to-top:hover { border-color: var(--green); color: var(--green); }
.back-to-top svg { width: 22px; height: 22px; display: block; }
@media (max-width: 640px) {
  .back-to-top { right: 12px; bottom: 12px; width: 40px; height: 40px; }
}
/* Форумният плаващ бутон за отговор сяда на същото място — вдигаме "нагоре" по-нагоре, за да не се застъпват. */
body:has(.forum-float-reply-btn) .back-to-top { bottom: 70px; }
@media (max-width: 640px) {
  body:has(.forum-float-reply-btn) .back-to-top { bottom: 62px; }
}

/* ---------- Мобилни ---------- */
@media (max-width: 720px) {
  .header-inner { padding: 8px 12px; }
  .listing-page { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .hero h1 { font-size: 26px; }
}
