/* =========================================================================
   Sharby — дизайн-система интерфейса.
   Токены цвета/шрифтов — из BRAND_BOOK.md (сняты пипеткой с утверждённых
   ассетов, не выдуманы). Здесь их не переопределять «на глаз»: если цвет
   меняется — сначала бренд-бук, потом этот файл.
   Порядок: токены → база → лейаут → компоненты → экраны → адаптив.
   ========================================================================= */

/* ---------- 1. Токены ---------------------------------------------------- */

:root {
  /* Палитра (BRAND_BOOK.md) */
  --cream: #fbf6ea;
  --cream-deep: #f1e7d3;
  --terracotta: #d6692f;
  --terracotta-deep: #a5501f;
  --sage: #9ca88c;
  --sage-deep: #75816a;
  --peach: #f3b99c;
  --ink: #241c16;
  --ink-soft: #6b5844;

  /* Производные (для поверхностей и границ) */
  --surface: #fffdf7;
  --surface-2: var(--cream);
  --surface-sunken: var(--cream-deep);
  --line: rgba(36, 28, 22, 0.1);
  --line-strong: rgba(36, 28, 22, 0.18);
  --ink-faint: rgba(36, 28, 22, 0.45);
  --terracotta-tint: rgba(214, 105, 47, 0.1);
  --sage-tint: rgba(156, 168, 140, 0.22);
  --peach-tint: rgba(243, 185, 156, 0.28);
  --danger: #b3402c;
  --danger-tint: rgba(179, 64, 44, 0.1);

  /* Типографика */
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Manrope", var(--font-body);

  /* Скругления */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 30px;
  --r-pill: 999px;

  /* Тени — тёплые, не серые */
  --shadow-xs: 0 1px 2px rgba(36, 28, 22, 0.05);
  --shadow-sm: 0 2px 8px rgba(36, 28, 22, 0.06);
  --shadow-md: 0 6px 20px rgba(36, 28, 22, 0.08);
  --shadow-lg: 0 16px 40px rgba(36, 28, 22, 0.12);

  /* Ритм */
  --gap: 16px;
  --container: 1180px;
  --header-h: 72px;

  --ease: cubic-bezier(0.2, 0.8, 0.3, 1);
  --dur: 0.18s;
}

/* ---------- 2. База ------------------------------------------------------ */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  font-feature-settings: "cv05" 1;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 0.5em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(1.75rem, 1.3rem + 1.8vw, 2.5rem);
}
h2 {
  font-size: clamp(1.35rem, 1.15rem + 0.9vw, 1.75rem);
}
h3 {
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

p {
  margin: 0 0 1em;
}

a {
  color: var(--terracotta-deep);
  text-decoration: none;
  transition: color var(--dur) var(--ease);
}

a:hover {
  color: var(--terracotta);
}

img {
  max-width: 100%;
  display: block;
  /* height: auto обязателен. Атрибуты width/height в разметке (они нужны,
     чтобы не прыгал лейаут при загрузке) браузер применяет как CSS-подсказку:
     если переопределить только ширину, высота останется от атрибута и
     картинка растянется. */
  height: auto;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 24px 0;
}

:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection {
  background: var(--peach);
  color: var(--ink);
}

/* Скроллбар в тон бренду (webkit) */
* {
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: var(--r-pill);
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  stroke-width: 1.9;
}
.icon-sm {
  width: 16px;
  height: 16px;
}
.icon-lg {
  width: 26px;
  height: 26px;
  stroke-width: 1.7;
}
.icon-xl {
  width: 34px;
  height: 34px;
  stroke-width: 1.6;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- 3. Лейаут ---------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 20px;
}

.page {
  flex: 1;
  padding-block: 32px 56px;
}

.page-narrow {
  max-width: 720px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--gap);
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.page-head h1 {
  margin: 0;
}

.page-head .subtitle {
  color: var(--ink-soft);
  margin: 6px 0 0;
}

.stack > * + * {
  margin-top: var(--gap);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 500;
  margin-bottom: 14px;
}

.back-link:hover {
  color: var(--ink);
}

/* --- Шапка --- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(251, 246, 234, 0.88);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}

.site-header__inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--gap);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.logo img {
  height: 44px;
  width: auto;
}

.logo__text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.45rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1;
}

.logo__tagline {
  display: block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0;
  color: var(--ink-soft);
  margin-top: 3px;
}

.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: var(--r-pill);
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 0.95rem;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.nav-link:hover {
  background: var(--cream-deep);
  color: var(--ink);
}

.nav-link.is-active {
  color: var(--ink);
  background: var(--cream-deep);
}

.nav-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--terracotta);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* --- Подвал --- */

.site-footer {
  background: var(--cream-deep);
  border-top: 1px solid var(--line);
  padding-block: 40px;
  margin-top: auto;
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  align-items: flex-start;
  justify-content: space-between;
}

.site-footer p {
  color: var(--ink-soft);
  font-size: 0.9rem;
  max-width: 34ch;
  margin: 8px 0 0;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  font-size: 0.92rem;
}

.footer-links a {
  color: var(--ink-soft);
  font-weight: 500;
}

.footer-links a:hover {
  color: var(--terracotta-deep);
}

/* --- Нижняя навигация (мобильная) --- */

.tabbar {
  display: none;
  position: fixed;
  z-index: 45;
  inset: auto 0 0 0;
  background: rgba(251, 246, 234, 0.94);
  backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}

.tabbar__list {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
}

.tabbar__item {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 2px;
  border-radius: var(--r-sm);
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 500;
}

.tabbar__item.is-active {
  color: var(--terracotta-deep);
}

.tabbar__item--accent {
  color: var(--terracotta-deep);
}

.tabbar__dot {
  position: absolute;
  top: 4px;
  left: 50%;
  margin-left: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--terracotta);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---------- 4. Компоненты ------------------------------------------------ */

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

.btn {
  --btn-bg: var(--cream-deep);
  --btn-fg: var(--ink);
  --btn-bd: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: 1px solid var(--btn-bd);
  border-radius: var(--r-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.btn:hover {
  color: var(--btn-fg);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

.btn--primary {
  --btn-bg: var(--terracotta);
  --btn-fg: #fff;
  box-shadow: 0 4px 14px rgba(214, 105, 47, 0.28);
}

.btn--primary:hover {
  --btn-bg: var(--terracotta-deep);
  box-shadow: 0 8px 22px rgba(214, 105, 47, 0.32);
}

.btn--secondary {
  --btn-bg: transparent;
  --btn-bd: var(--line-strong);
  --btn-fg: var(--ink);
}

.btn--secondary:hover {
  --btn-bg: var(--cream-deep);
  --btn-bd: transparent;
}

.btn--ghost {
  --btn-bg: transparent;
  --btn-fg: var(--ink-soft);
  padding-inline: 14px;
}

.btn--ghost:hover {
  --btn-bg: var(--cream-deep);
  --btn-fg: var(--ink);
}

.btn--danger {
  --btn-bg: var(--danger);
  --btn-fg: #fff;
}

.btn--danger:hover {
  --btn-bg: #93341f;
}

.btn--sm {
  padding: 8px 14px;
  font-size: 0.87rem;
}

.btn--lg {
  padding: 14px 26px;
  font-size: 1.02rem;
}

.btn--block {
  width: 100%;
}

.btn--icon {
  padding: 10px;
  border-radius: var(--r-pill);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card--flat {
  box-shadow: none;
  background: var(--cream-deep);
  border-color: transparent;
}

.card__title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.card__title .icon {
  color: var(--sage-deep);
}

/* --- Бейджи --- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  background: var(--cream-deep);
  color: var(--ink-soft);
  font-size: 0.79rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.badge--active {
  background: var(--sage-tint);
  color: var(--sage-deep);
}

.badge--reserved {
  background: var(--peach-tint);
  color: #a2542f;
}

.badge--given {
  background: rgba(36, 28, 22, 0.07);
  color: var(--ink-soft);
}

.badge--archived {
  background: rgba(36, 28, 22, 0.07);
  color: var(--ink-faint);
}

.badge--danger {
  background: var(--danger-tint);
  color: var(--danger);
}

.badge--accent {
  background: var(--terracotta-tint);
  color: var(--terracotta-deep);
}

.meta {
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.meta-row > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.meta-row .icon {
  width: 15px;
  height: 15px;
  color: var(--sage-deep);
}

/* --- Аватар --- */

.avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--r-pill);
  background: var(--sage-tint);
  color: var(--sage-deep);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: none;
  user-select: none;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar--sm {
  width: 32px;
  height: 32px;
  font-size: 0.8rem;
}

.avatar--lg {
  width: 68px;
  height: 68px;
  font-size: 1.4rem;
}

/* --- Уведомления (django messages) --- */

.alerts {
  position: fixed;
  z-index: 60;
  top: calc(var(--header-h) + 12px);
  right: 20px;
  left: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(420px, calc(100vw - 40px));
  pointer-events: none;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  font-size: 0.93rem;
  font-weight: 500;
  pointer-events: auto;
  animation: alert-in 0.32s var(--ease) both;
}

.alert .icon {
  margin-top: 1px;
  color: var(--sage-deep);
}

.alert--success .icon {
  color: var(--sage-deep);
}
.alert--error,
.alert--warning {
  border-color: rgba(179, 64, 44, 0.28);
}
.alert--error .icon,
.alert--warning .icon {
  color: var(--danger);
}

.alert__close {
  margin-left: auto;
  border: 0;
  background: none;
  padding: 2px;
  color: var(--ink-faint);
  cursor: pointer;
  border-radius: var(--r-xs);
}

.alert__close:hover {
  color: var(--ink);
  background: var(--cream-deep);
}

@keyframes alert-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
}

/* --- Формы --- */

.form-field {
  margin-bottom: 18px;
}

.form-field > label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 7px;
}

.form-field .required-star {
  color: var(--terracotta);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="tel"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.97rem;
  line-height: 1.4;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  appearance: none;
}

textarea {
  min-height: 140px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-faint);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px var(--terracotta-tint);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B5844' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 17px;
  padding-right: 38px;
  cursor: pointer;
}

.form-field__help {
  font-size: 0.83rem;
  color: var(--ink-soft);
  margin: 6px 0 0;
}

.form-field__help ul,
.form-field__help ol {
  margin: 0;
  padding-left: 18px;
}

.form-field__help li + li {
  margin-top: 3px;
}

.form-field__errors {
  list-style: none;
  margin: 7px 0 0;
  padding: 0;
  font-size: 0.85rem;
  color: var(--danger);
  font-weight: 500;
}

.form-field--invalid input,
.form-field--invalid select,
.form-field--invalid textarea {
  border-color: var(--danger);
}

.form-errors {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 13px 16px;
  border-radius: var(--r-md);
  background: var(--danger-tint);
  color: var(--danger);
  font-size: 0.92rem;
  font-weight: 500;
  margin-bottom: 18px;
}

.form-errors .icon {
  flex: none;
  margin-top: 1px;
}

.form-errors ul {
  margin: 0;
  padding-left: 18px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 24px;
}

/* Поле загрузки файла (аватар) — Django рендерит ClearableFileInput
   как текст + чекбокс «очистить» + сам input, поэтому стилизуем блоком. */
.form-field input[type="file"] {
  display: block;
  width: 100%;
  /* Без min-width:0 нативный file input не даёт колонке сузиться и
     раздвигает мобильный вьюпорт (страница уезжает вбок). */
  min-width: 0;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--cream-deep);
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 0.87rem;
  cursor: pointer;
}

.form-field input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 7px 14px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
}

.form-field input[type="file"]:hover {
  border-color: var(--terracotta);
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 0.93rem;
  cursor: pointer;
}

.checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--terracotta);
  cursor: pointer;
}

/* --- Пустое состояние --- */

.empty {
  text-align: center;
  padding: 44px 20px 52px;
}

.empty img {
  width: min(190px, 45vw);
  margin: 0 auto 18px;
}

.empty h2,
.empty h3 {
  margin-bottom: 8px;
}

.empty p {
  color: var(--ink-soft);
  max-width: 42ch;
  margin-inline: auto;
}

.empty .btn-row {
  justify-content: center;
  margin-top: 20px;
}

/* --- Табы --- */

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--cream-deep);
  border-radius: var(--r-pill);
}

.tabs a {
  padding: 8px 18px;
  border-radius: var(--r-pill);
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 600;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.tabs a:hover {
  color: var(--ink);
}

.tabs a.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}

/* --- Карта --- */

.map {
  height: 420px;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--cream-deep);
}

.map--compact {
  height: 260px;
}

.map-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 24px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  background: var(--cream-deep);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  min-height: 140px;
}

.map-placeholder .icon {
  color: var(--sage-deep);
}

/* ---------- 5. Экраны ---------------------------------------------------- */

/* --- Главная: hero --- */

.hero {
  position: relative;
  border-radius: var(--r-xl);
  overflow: hidden;
  margin-bottom: 32px;
  background: var(--cream-deep);
  isolation: isolate;
}

.hero__media {
  position: absolute;
  inset: 0;
  z-index: -2;
}

.hero__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(100deg, rgba(36, 28, 22, 0.82) 0%, rgba(36, 28, 22, 0.62) 42%, rgba(36, 28, 22, 0.15) 78%);
}

.hero__body {
  padding: clamp(32px, 5vw, 64px);
  max-width: 640px;
  color: #fff;
}

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(6px);
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.hero h1 {
  color: #fff;
  margin-bottom: 12px;
  font-size: clamp(1.9rem, 1.2rem + 2.6vw, 3rem);
}

.hero p {
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.12rem);
  max-width: 46ch;
  margin-bottom: 24px;
}

.hero .btn--secondary {
  --btn-fg: #fff;
  --btn-bd: rgba(255, 255, 255, 0.45);
}

.hero .btn--secondary:hover {
  --btn-bg: rgba(255, 255, 255, 0.16);
  --btn-bd: rgba(255, 255, 255, 0.45);
}

/* --- Категории --- */

.categories {
  margin-bottom: 28px;
}

.categories__list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.category-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  min-height: 92px;
  padding: 14px 8px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
  hyphens: auto;
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}

.category-chip .icon {
  width: 26px;
  height: 26px;
  stroke-width: 1.6;
  color: var(--sage-deep);
  transition: color var(--dur) var(--ease);
}

.category-chip:hover {
  transform: translateY(-2px);
  border-color: transparent;
  box-shadow: var(--shadow-md);
  color: var(--ink);
}

.category-chip:hover .icon {
  color: var(--terracotta);
}

.category-chip.is-active {
  background: var(--terracotta-tint);
  border-color: rgba(214, 105, 47, 0.4);
  color: var(--terracotta-deep);
}

.category-chip.is-active .icon {
  color: var(--terracotta);
}

/* --- Панель фильтров --- */

.filters {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.filters__main {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-field {
  position: relative;
  flex: 1;
  min-width: 0;
}

.search-field .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-faint);
  pointer-events: none;
}

.search-field input {
  padding-left: 42px;
  border-radius: var(--r-pill);
}

.filters__toggle {
  flex: none;
}

.filters__extra {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.filters__extra .form-field {
  margin: 0;
}

.filters__extra .form-field > label {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.filters__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.filters details > summary {
  list-style: none;
}
.filters details > summary::-webkit-details-marker {
  display: none;
}

/* --- Результаты + переключатель вида --- */

.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.results-bar h2 {
  margin: 0;
  font-size: 1.3rem;
}

.results-bar .meta {
  margin-left: 4px;
  font-weight: 500;
}

.view-switch {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: var(--cream-deep);
  border-radius: var(--r-pill);
}

.view-switch button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border: 0;
  border-radius: var(--r-pill);
  background: none;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.view-switch button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}

/* --- Сетка объявлений --- */

.listing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.listing-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}

.listing-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}

.listing-card__media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--cream-deep);
  overflow: hidden;
}

.listing-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s var(--ease);
}

.listing-card:hover .listing-card__media img {
  transform: scale(1.04);
}

.listing-card__placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sage);
}

.listing-card__placeholder .icon {
  width: 40px;
  height: 40px;
  stroke-width: 1.4;
}

.listing-card__badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(255, 253, 247, 0.92);
  backdrop-filter: blur(4px);
  box-shadow: var(--shadow-xs);
}

.listing-card__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 16px 18px;
  flex: 1;
}

.listing-card__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.03rem;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--ink);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Заголовок карточки — обычный текст: терракота зарезервирована за
   действиями, иначе лента превращается в «стену ссылок». */
.listing-card__link,
.my-listing__title,
.conversation__title,
.chat__head-title {
  color: inherit;
}

.listing-card__link:hover,
.my-listing__title:hover,
.conversation__title:hover,
.chat__head-title:hover {
  color: var(--terracotta-deep);
}

.listing-card__link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.listing-card__foot {
  margin-top: auto;
  padding-top: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 10px;
  color: var(--ink-faint);
  font-size: 0.8rem;
}

/* В узкой карточке район не должен выдавливать дату за край. */
.listing-card__place {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  max-width: 100%;
}

.listing-card__place span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.listing-card__foot time {
  white-space: nowrap;
}

.listing-card--rejected {
  border-color: rgba(179, 64, 44, 0.35);
}

/* --- Страница объявления --- */

/* Раскладка страницы объявления. Области, а не просто две колонки:
   на мобильном порядок должен быть «заголовок → фото → автор и кнопка
   → описание», иначе кнопка «Написать автору» уезжает под всю страницу. */
.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr);
  grid-template-areas:
    "head side"
    "media side"
    "body side";
  gap: 24px 32px;
  align-items: start;
}

.detail-head {
  grid-area: head;
}
.detail-media {
  grid-area: media;
}
.detail-body {
  grid-area: body;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.detail-aside {
  grid-area: side;
  position: sticky;
  top: calc(var(--header-h) + 20px);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.gallery {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gallery__main {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--cream-deep);
  border: 1px solid var(--line);
}

.gallery__main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery__thumbs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.gallery__thumb {
  flex: none;
  width: 84px;
  height: 68px;
  border: 2px solid transparent;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--cream-deep);
  padding: 0;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), opacity var(--dur) var(--ease);
  opacity: 0.72;
}

.gallery__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery__thumb:hover {
  opacity: 1;
}

.gallery__thumb.is-active {
  border-color: var(--terracotta);
  opacity: 1;
}

.detail-title {
  margin-bottom: 10px;
}

.detail-description {
  font-size: 1.02rem;
  line-height: 1.65;
}

.detail-description p:last-child {
  margin-bottom: 0;
}

.author-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.author-card__name {
  font-weight: 600;
  line-height: 1.3;
}

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--danger-tint);
  color: var(--danger);
  font-size: 0.92rem;
  font-weight: 500;
  margin-bottom: 20px;
}

.notice .icon {
  flex: none;
  margin-top: 2px;
}

.notice--info {
  background: var(--sage-tint);
  color: var(--sage-deep);
}

.disclosure > summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 500;
  list-style: none;
  padding: 6px 0;
}

.disclosure > summary::-webkit-details-marker {
  display: none;
}

.disclosure > summary:hover {
  color: var(--ink);
}

.disclosure[open] > summary {
  margin-bottom: 12px;
}

/* --- Лайтбокс --- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(36, 28, 22, 0.86);
  backdrop-filter: blur(4px);
}

.lightbox.is-open {
  display: flex;
  animation: fade-in 0.2s var(--ease);
}

.lightbox img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: var(--r-md);
  object-fit: contain;
}

.lightbox__close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.lightbox__close:hover {
  background: rgba(255, 255, 255, 0.28);
}

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

/* --- Форма объявления: фото --- */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid var(--line);
  cursor: pointer;
  display: block;
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity var(--dur) var(--ease), filter var(--dur) var(--ease);
}

.photo-item__mark {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px;
  background: rgba(255, 253, 247, 0.92);
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 600;
}

.photo-item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.photo-item:has(input:checked) img {
  opacity: 0.4;
  filter: grayscale(1);
}

.photo-item:has(input:checked) {
  border-color: var(--danger);
}

.photo-item:has(input:checked) .photo-item__mark {
  background: var(--danger);
  color: #fff;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 20px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--cream-deep);
  color: var(--ink-soft);
  font-size: 0.92rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.dropzone:hover,
.dropzone.is-hot {
  border-color: var(--terracotta);
  background: var(--terracotta-tint);
  color: var(--terracotta-deep);
}

.dropzone .icon {
  color: var(--sage-deep);
}

.dropzone input[type="file"] {
  display: none;
}

.dropzone strong {
  font-weight: 600;
  color: var(--ink);
}

/* --- Авторизация --- */

.auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr);
  gap: 40px;
  align-items: center;
  padding-block: 24px;
}

.auth__card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: clamp(24px, 4vw, 40px);
  box-shadow: var(--shadow-md);
  max-width: 480px;
  width: 100%;
  margin-inline: auto;
}

.auth__card h1 {
  margin-bottom: 6px;
}

.auth__lead {
  color: var(--ink-soft);
  margin-bottom: 24px;
}

.auth__aside {
  text-align: center;
}

.auth__aside img {
  width: min(280px, 70%);
  margin: 0 auto 20px;
}

.auth__aside blockquote {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  max-width: 26ch;
  margin-inline: auto;
}

.auth__aside p {
  color: var(--ink-soft);
  max-width: 32ch;
  margin: 10px auto 0;
  font-size: 0.94rem;
}

.auth__foot {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 0.93rem;
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  justify-content: space-between;
}

/* --- Профиль --- */

.profile-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.6fr);
  gap: 28px;
  align-items: start;
}

/* Колонки раскладок обязаны уметь сужаться: min-width:auto у grid-элемента
   иначе передаёт наружу min-content самого широкого содержимого. */
.profile-layout > *,
.detail-layout > *,
.auth > * {
  min-width: 0;
}

.profile-card__head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.profile-card__email {
  color: var(--ink-soft);
  font-size: 0.88rem;
  word-break: break-all;
}

.my-listings {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.my-listing {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.my-listing:hover {
  box-shadow: var(--shadow-sm);
  border-color: transparent;
}

.my-listing__thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--r-sm);
  object-fit: cover;
  background: var(--cream-deep);
  flex: none;
}

.my-listing__thumb--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sage);
}

.my-listing__body {
  min-width: 0;
  flex: 1;
}

.my-listing__title {
  font-weight: 600;
  color: var(--ink);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.my-listing__title::after {
  content: "";
  position: absolute;
  inset: 0;
}

/* --- Чат: список --- */

.conversations {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.conversation {
  position: relative;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}

.conversation:hover {
  box-shadow: var(--shadow-sm);
  border-color: transparent;
  transform: translateY(-1px);
}

.conversation.is-unread {
  background: var(--terracotta-tint);
  border-color: rgba(214, 105, 47, 0.28);
}

.conversation__thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--r-sm);
  object-fit: cover;
  background: var(--cream-deep);
  flex: none;
}

.conversation__body {
  flex: 1;
  min-width: 0;
}

.conversation__title {
  font-weight: 600;
  color: var(--ink);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation__title::after {
  content: "";
  position: absolute;
  inset: 0;
}

.conversation__preview {
  color: var(--ink-soft);
  font-size: 0.89rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 2px 0 0;
}

/* --- Чат: диалог --- */

.chat {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--header-h) - 110px);
  min-height: 460px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.chat__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.chat__head img.chat__listing-thumb {
  width: 46px;
  height: 46px;
  border-radius: var(--r-sm);
  object-fit: cover;
  background: var(--cream-deep);
  flex: none;
}

.chat__head-body {
  min-width: 0;
  flex: 1;
}

.chat__head-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--cream);
  scroll-behavior: smooth;
}

/* Короткая переписка прижимается к полю ввода, а не висит вверху пустого
   окна. Через auto-отступ первого элемента, а не justify-content: flex-end —
   тот ломает прокрутку к началу, когда сообщений много. */
.chat__messages > :first-child {
  margin-top: auto;
}

.msg {
  max-width: min(72%, 520px);
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  align-self: flex-start;
  animation: msg-in 0.22s var(--ease) both;
  overflow-wrap: anywhere;
}

.msg[data-mine="1"] {
  align-self: flex-end;
  background: var(--terracotta);
  border-color: transparent;
  color: #fff;
  border-bottom-right-radius: 6px;
}

.msg:not([data-mine="1"]) {
  border-bottom-left-radius: 6px;
}

.msg__author {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--sage-deep);
  margin-bottom: 3px;
}

.msg__text {
  white-space: pre-wrap;
}

.msg__status {
  display: block;
  text-align: right;
  font-size: 0.7rem;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.75);
}

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

.chat__composer {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.chat__composer input {
  border-radius: var(--r-pill);
}

.chat__empty {
  margin: auto;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.92rem;
  max-width: 34ch;
}

.chat__empty img {
  width: 130px;
  margin: 0 auto 12px;
}

.chat__banner {
  display: none;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 9px;
  background: var(--danger-tint);
  color: var(--danger);
  font-size: 0.86rem;
  font-weight: 500;
}

.chat__banner.is-visible {
  display: flex;
}

/* ---------- 6. Адаптив --------------------------------------------------- */

@media (max-width: 960px) {
  .detail-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "head"
      "media"
      "side"
      "body";
  }

  .detail-aside {
    position: static;
  }

  .profile-layout {
    grid-template-columns: 1fr;
  }

  .auth {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .auth__aside {
    order: -1;
  }

  .auth__aside img {
    width: 150px;
    margin-bottom: 12px;
  }

  .auth__aside blockquote {
    font-size: 1.1rem;
  }

  .auth__aside p {
    display: none;
  }
}

@media (max-width: 720px) {
  :root {
    --header-h: 60px;
  }

  body {
    padding-bottom: 68px; /* место под нижнюю навигацию */
  }

  .site-nav {
    display: none;
  }

  .tabbar {
    display: block;
  }

  .logo img {
    height: 36px;
  }

  .logo__text {
    font-size: 1.2rem;
  }

  .logo__tagline {
    display: none;
  }

  .page {
    padding-block: 20px 32px;
  }

  .container {
    padding-inline: 16px;
  }

  .card {
    padding: 18px;
    border-radius: var(--r-md);
  }

  .alerts {
    top: auto;
    bottom: 78px;
    right: 12px;
    left: 12px;
    max-width: none;
  }

  .hero {
    border-radius: var(--r-lg);
  }

  .hero__body {
    max-width: none;
  }

  .hero::after {
    background: linear-gradient(180deg, rgba(36, 28, 22, 0.5) 0%, rgba(36, 28, 22, 0.85) 68%);
  }

  .categories__list {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    margin-inline: -16px;
    padding-inline: 16px;
    padding-bottom: 6px;
  }

  .categories__list > li {
    flex: none;
    width: 106px;
    scroll-snap-align: start;
  }

  .listing-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }

  .listing-card__body {
    padding: 12px 12px 14px;
  }

  .listing-card__title {
    font-size: 0.95rem;
  }

  .map {
    height: 320px;
  }

  .chat {
    height: calc(100dvh - var(--header-h) - 150px);
    border-radius: var(--r-md);
  }

  .msg {
    max-width: 84%;
  }

  .chat__head .btn__label {
    display: none;
  }

  .btn--lg {
    padding: 12px 20px;
    font-size: 0.97rem;
  }

  .form-actions .btn {
    flex: 1;
  }
}

/* На узких экранах лента остаётся в две колонки — так за экран видно
   вчетверо больше вещей; в одну сваливаемся только на совсем узких. */
@media (max-width: 330px) {
  .listing-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .site-header,
  .site-footer,
  .tabbar,
  .alerts,
  .filters,
  .btn {
    display: none !important;
  }
}
