@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@500;600;700;800&family=Inter:wght@400;500;600&display=swap');

  :root {
    /* 60% — фон */
    --bg: #F5F7FA;
    --surface: #FFFFFF;
    --border: #E4E8F0;

    /* 30% — основной (индиго) */
    --ink: #1A1F36;
    --ink-soft: #5A6A7A;

    /* 10% — акцент (изумруд) */
    --accent: #0F7B6E;
    --accent-light: #E6F2F0;
    --accent-dark: #0A5E54;
    --accent-gradient: linear-gradient(135deg, #1A2A6C, #0F7B6E);
    --shadow: 0 4px 20px rgba(26, 42, 108, 0.20);
    --heart: #E74C3C;
    --heart-empty: #B0B8C4;

    /* iPhone Safe Area: значение ставит JS из Telegram (isExpanded) */
    --safe-top: var(--tg-safe-top, 0px);
    --safe-bottom: var(--tg-safe-bottom, 0px);

    /* Ширина контента на широких экранах (ПК/планшет) */
    --content-max: 1120px;
  }

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

  /* запрет авто-зума iOS: двойной тап и фокус не приближают страницу */
  input, textarea, select, button, a { touch-action: manipulation; }

  html, body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--ink);
    -webkit-tap-highlight-color: transparent;
    min-height: var(--tg-viewport-height, 100vh);
    padding-bottom: 110px;
  }

  /* ===== Header ===== */
  header {
    padding: calc(14px + var(--safe-top, 0px)) 16px 10px;
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 0 var(--border);
  }

  .brand-left { display: flex; flex-direction: column; cursor: pointer; }
  .brand {
    font-family: 'Archivo', sans-serif;
    font-weight: 800;
    font-size: 24px;
    letter-spacing: -0.5px;
    line-height: 1.2;
    color: var(--ink);
  }
  .brand .accent {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
  .subtitle { font-size: 12px; color: var(--ink-soft); margin-top: 1px; }

  .header-actions { display: flex; gap: 4px; align-items: center; }

  /* ===== МЕНЮ ВЫБОРА ЯЗЫКА (шторка) ===== */
  .lang-menu-btn .lang-current-flag {
    width: 24px;
    height: 18px;
    border-radius: 4px;
    object-fit: cover;
    display: block;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
  }

  .lang-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 90;
    animation: fadeIn 0.2s ease;
  }
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

  .lang-menu {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface);
    border-radius: 22px 22px 0 0;
    padding: 10px 16px 28px;
    z-index: 91;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.25);
    animation: langSlideUp 0.28s cubic-bezier(0.32, 0.72, 0.35, 1);
  }
  @keyframes langSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
  .lang-menu-handle {
    width: 44px;
    height: 5px;
    border-radius: 100px;
    background: var(--border);
    margin: 4px auto 14px;
  }
  .lang-menu-title {
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 17px;
    color: var(--ink);
    text-align: center;
    margin-bottom: 14px;
  }
  .lang-opt {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    background: none;
    border: none;
    padding: 13px 12px;
    border-radius: 14px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: var(--ink);
    transition: background 0.15s;
    text-align: left;
  }
  .lang-opt:active { background: var(--accent-light); transform: scale(0.98); }
  .lang-opt .flag {
    width: 28px;
    height: 21px;
    border-radius: 4px;
    object-fit: cover;
    display: block;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
  }
  .lang-opt .name { flex: 1; }
  .lang-opt .check {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    visibility: hidden;
  }
  .lang-opt.active { background: var(--accent-light); }
  .lang-opt.active .check { visibility: visible; }
  .lang-cancel {
    width: 100%;
    margin-top: 10px;
    padding: 13px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: none;
    color: var(--ink-soft);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
  }
  .lang-cancel:active { background: var(--bg); }

  .icon-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--ink);
    font-size: 22px;
    padding: 8px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    position: relative;
  }
  .icon-btn:active { transform: scale(0.92); border-color: var(--accent); }
  .icon-btn svg { display: block; }
  
  .notification-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--surface);
  }

  .favorites-count {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--heart);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface);
    padding: 0 4px;
  }

  .pull-indicator {
    text-align: center;
    padding: 12px 16px;
    color: var(--ink-soft);
    font-size: 14px;
    display: none;
    user-select: none;
  }
  .pull-indicator.active { display: block; }
  .pull-indicator .spinner {
    display: inline-block;
    animation: spin 0.8s linear infinite;
  }
  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }

  .filters {
    padding: 4px 16px 14px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .filters::-webkit-scrollbar { display: none; }

  .chip {
    flex-shrink: 0;
    padding: 8px 18px;
    border-radius: 100px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-soft);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: 'Inter', sans-serif;
  }
  .chip:active { transform: scale(0.94); }
  .chip.active {
    background: var(--accent-gradient);
    color: white;
    border-color: var(--accent);
    box-shadow: var(--shadow);
  }

  /* ===== Grid ===== */
  .grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 0 16px 16px;
    transition: transform 0.15s ease;
  }

  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
    position: relative;
    /* Нативная виртуализация: браузер не рендерит карточки вне экрана */
    content-visibility: auto;
    contain-intrinsic-size: auto 300px;
  }
  .card:active {
    transform: scale(0.97);
    border-color: var(--accent);
    box-shadow: 0 6px 20px rgba(15, 123, 110, 0.16);
  }
  /* Нажатие на сердечко НЕ должно сжимать всю карточку
     (:active зажигается и на предках — от этого «прыгал» отступ) */
  .card:active:has(.card-heart:active) {
    transform: none;
    border-color: var(--border);
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  }

  .card-heart {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 5;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(4px);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 0;
    line-height: 1;
  }
  .card-heart:active { transform: scale(0.85); }
  .card-heart .heart-icon.filled { color: var(--heart); }
  .card-heart .heart-icon.empty { color: var(--heart-empty); }

  /* SVG-сердце: по центру кнопки, без базовой линии текста */
  .heart-icon { display: inline-flex; align-items: center; justify-content: center; }
  .heart-icon svg { display: block; }

  .photo {
    position: relative;
    aspect-ratio: 1 / 1;
    background: linear-gradient(135deg, #EDF0F5, #DCE1E8);
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
  }

  .tag {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(26, 42, 108, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: white;
    font-size: 15px;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 100px;
    font-family: 'Archivo', sans-serif;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  }

  .info { padding: 12px 12px 14px; }
  .title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--ink);
  }
  .meta { font-size: 12px; color: var(--ink-soft); }

  .empty {
    text-align: center;
    padding: 60px 24px;
    color: var(--ink-soft);
    grid-column: 1 / -1;
  }
  .empty-title {
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 18px;
    color: var(--ink);
    margin-bottom: 6px;
  }

  .feed-end {
    grid-column: 1 / -1;
    text-align: center;
    padding: 28px 16px 40px;
    color: var(--ink-soft);
    font-size: 14px;
  }

  /* ===== СКЕЛЕТОНЫ ЗАГРУЗКИ ===== */
  .skeleton-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
  }
  .skeleton {
    background: linear-gradient(100deg, var(--bg) 40%, var(--surface) 50%, var(--bg) 60%);
    background-size: 200% 100%;
    animation: shimmer 1.3s infinite linear;
  }
  @keyframes shimmer {
    to { background-position: -200% 0; }
  }
  .skeleton-photo { aspect-ratio: 1 / 1; }
  .skeleton-line { height: 12px; border-radius: 6px; margin: 12px 12px 8px; }
  .skeleton-line.short { width: 45%; margin-bottom: 14px; }

  /* Мягкое появление карточек */
  .card { animation: cardIn 0.3s ease backwards; }
  @keyframes cardIn {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }

  /* ===== КНОПКА ЖАЛОБЫ ===== */
  .report-btn {
    width: 100%;
    margin-top: 10px;
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: none;
    color: var(--ink-soft);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
  }
  .report-btn:active { background: rgba(230, 126, 34, 0.1); border-color: #E67E22; color: #E67E22; }

  /* ===== ТОСТ (копирование заготовки продавцу) ===== */
  .toast {
    position: fixed;
    bottom: calc(90px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--ink);
    color: var(--bg);
    padding: 10px 18px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s ease;
    z-index: 120;
    max-width: 90vw;
    text-align: center;
  }
  .toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  /* ===== НИЖНЕЕ ТАБ-МЕНЮ ===== */
  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    z-index: 40;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 9px 0 7px;
    background: none;
    border: none;
    color: var(--ink-soft);
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
  }
  .tab svg { width: 23px; height: 23px; }
  .tab:active { transform: scale(0.94); }
  .tab.active { color: var(--accent); }
  .tab.active svg { stroke-width: 2.4; }
  .tab-fav-count {
    top: 4px;
    right: calc(50% - 30px);
    border-color: var(--surface);
  }

  /* ===== FAB ===== */
  .fab {
    position: fixed;
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 60px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 15px;
    box-shadow: var(--shadow);
    z-index: 20;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .fab:active { transform: scale(0.94); }

  /* ===== ПЛАВАЮЩАЯ СТРЕЛКА «НАВЕРХ» ===== */
  .scroll-top-btn {
    position: fixed;
    left: 16px;
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--ink);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
  }
  .scroll-top-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }
  .scroll-top-btn:active { transform: scale(0.92); }

  /* ===== SEARCH SCREEN ===== */
  #search-screen {
    display: none;
    background: var(--bg);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    overflow: hidden;
  }
  #search-screen.active {
    /* топбар фиксирован сверху, весь остальной контент скроллится под ним
       в отдельной области — надписи не могут заехать за строку поиска */
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
  }
  @keyframes slideUp {
    0% { transform: translateY(20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
  }

  .search-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* место под таббар (футер), чтобы контент не прятался за ним */
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .search-topbar {
    padding: calc(4px + var(--safe-top, 0px)) 16px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg);
    flex-shrink: 0;
    box-shadow: 0 1px 0 var(--border);
    z-index: 5;
  }
  .search-topbar .back-btn {
    font-size: 24px;
    cursor: pointer;
    color: var(--ink);
    flex-shrink: 0;
  }
  .search-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0 14px;
    transition: border 0.2s;
  }
  .search-input-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 123, 110, 0.1);
  }
  .search-input-wrap .icon {
    font-size: 18px;
    color: var(--ink-soft);
    margin-right: 10px;
  }
  .search-input-wrap input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    padding: 12px 0;
    background: transparent;
    color: var(--ink);
    font-family: 'Inter', sans-serif;
  }
  .search-input-wrap input::placeholder { color: var(--ink-soft); }
  .search-clear {
    font-size: 18px;
    color: var(--ink-soft);
    cursor: pointer;
    padding: 4px;
    display: none;
  }
  .search-clear.visible { display: block; }

  .search-suggestions { padding: 8px 16px 16px; }
  .suggestions-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
    margin: 16px 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
  }
  .suggestion-chip {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 100px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 14px;
    color: var(--ink);
    cursor: pointer;
    margin: 0 8px 8px 0;
    transition: all 0.2s;
  }
  .suggestion-chip:active { transform: scale(0.94); border-color: var(--accent); }
  .suggestion-chip .emoji { margin-right: 4px; }

  .search-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
  }
  .search-history-item:active { opacity: 0.6; }
  .search-history-item .text { font-size: 14px; color: var(--ink); }
  .search-history-item .remove {
    font-size: 16px;
    color: var(--ink-soft);
    cursor: pointer;
    padding: 4px 8px;
  }

  .search-results { padding: 0 16px 16px; }
  .search-results .grid { padding: 0; }
  .search-results .empty { padding: 40px 24px; }
  .search-results .empty .empty-title { font-size: 16px; }

  /* ===== Detail Screen ===== */
  #detail-screen {
    display: none;
    background: var(--bg);
    min-height: var(--tg-viewport-height, 100vh);
    position: relative;
  }

  .detail-topbar {
    padding: calc(12px + var(--safe-top, 0px)) 16px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 5;
  }

  .detail-langs {
    display: flex;
    gap: 6px;
  }

  .back-btn {
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px 4px 0;
    user-select: none;
    color: var(--ink);
  }

  .gallery {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    background: var(--surface);
    position: relative;
    min-height: 280px;
  }
  .gallery img {
    width: 100%;
    flex-shrink: 0;
    scroll-snap-align: start;
    object-fit: cover;
    aspect-ratio: 1 / 1;
    background: #EDF0F5;
  }
  .gallery-empty {
    width: 100%;
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    background: var(--surface);
  }
  .gallery-dots {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    background: rgba(0,0,0,0.35);
    padding: 6px 10px;
    border-radius: 100px;
    backdrop-filter: blur(4px);
  }
  .gallery-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    transition: background 0.2s;
  }
  .gallery-dots span.active { background: white; }

  .detail-body { padding: 16px 20px 20px; }
  .detail-price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
  }
  .detail-price {
    font-family: 'Archivo', sans-serif;
    font-size: 28px;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
  .detail-heart-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    transition: transform 0.2s;
    line-height: 1;
    /* фиксированный размер: смена ♡ на SVG не двигает раскладку */
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .detail-heart-btn:active { transform: scale(0.85); }
  .detail-heart-btn .heart-icon.filled { color: var(--heart); }
  .detail-heart-btn .heart-icon.empty { color: var(--heart-empty); }
  .detail-title {
    font-size: 16px;
    line-height: 1.5;
    margin-bottom: 12px;
    color: var(--ink);
  }
  .detail-meta-row {
    font-size: 13px;
    color: var(--ink-soft);
    margin-bottom: 20px;
  }

  /* ===== Перевод (языковые флаги в тэкбаре) ===== */
  .lang-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 10px;
  }
  .lang-chip {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    padding: 0;
  }
  .lang-chip:active { transform: scale(0.88); }
  .lang-chip.active {
    background: var(--accent-gradient);
    border-color: var(--accent);
    box-shadow: var(--shadow);
    transform: scale(1.06);
  }
  .lang-chip.loading { opacity: 0.4; }
  .lang-flag-img {
    width: 22px;
    height: 16px;
    border-radius: 3px;
    object-fit: cover;
    display: block;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
  }
  .ai-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-light);
    border-radius: 100px;
    padding: 3px 10px;
    margin-bottom: 8px;
  }

  /* ===== График истории цены ===== */
  .price-history-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 20px;
  }
  .price-history-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 10px;
  }
  .price-history-delta {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
  }
  .price-history-delta.down { color: #27AE60; }
  .price-history-delta.up { color: #E74C3C; }
  .price-history-box svg { display: block; width: 100%; height: 60px; }

  .contact-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
  }
  .contact-box-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 14px;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .contact-box-title::before { content: '💬'; font-size: 18px; }
  .contact-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 500;
    font-size: 15px;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    width: 100%;
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow);
  }
  .contact-link:active { transform: scale(0.97); }
  .contact-link .icon {
    font-size: 20px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    flex-shrink: 0;
    color: white;
  }
  .contact-link .label { flex: 1; text-align: left; color: white; }
  .contact-none {
    color: var(--ink-soft);
    font-size: 14px;
    padding: 8px 0;
    text-align: center;
  }

  /* ===== FAVORITES SCREEN ===== */
  #favorites-screen {
    display: none;
    min-height: var(--tg-viewport-height, 100vh);
    background: var(--bg);
  }
  .favorites-header {
    padding: calc(12px + var(--safe-top, 0px)) 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 5;
  }
  .favorites-title {
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 18px;
    color: var(--ink);
  }

  /* ===== My Screen ===== */
  #my-screen {
    display: none;
    min-height: var(--tg-viewport-height, 100vh);
    background: var(--bg);
  }
  .my-header {
    padding: calc(12px + var(--safe-top, 0px)) 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 5;
  }
  .my-title {
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 18px;
    color: var(--ink);
  }

  /* ===== Post Screen ===== */
  #post-screen {
    display: none;
    min-height: var(--tg-viewport-height, 100vh);
    background: var(--bg);
  }
  .post-topbar {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 5;
  }
  .post-topbar-title {
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 18px;
    color: var(--ink);
  }
  .post-body {
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
  .post-section-label {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--ink);
  }
  .post-textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    resize: vertical;
    background: var(--surface);
    transition: border 0.2s;
    color: var(--ink);
  }
  .post-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 123, 110, 0.1);
  }
  .post-input {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    background: var(--surface);
    transition: border 0.2s;
    color: var(--ink);
  }
  .post-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 123, 110, 0.1);
  }
  .price-row {
    display: flex;
    gap: 10px;
  }
  .currency-select {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    color: var(--ink);
  }
  .post-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .post-chip {
    padding: 8px 16px;
    border-radius: 100px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-soft);
    cursor: pointer;
    transition: all 0.2s;
  }
  .post-chip:active { transform: scale(0.94); }
  .post-chip.active {
    background: var(--accent-gradient);
    color: white;
    border-color: var(--accent);
    box-shadow: var(--shadow);
  }
  .post-submit {
    margin: 0 20px 24px;
    padding: 16px;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: 14px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
  }
  .post-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
  }
  .post-submit:active { transform: scale(0.97); }

  .photo-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }
  .photo-add-btn {
    width: 80px;
    height: 80px;
    border: 2px dashed var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--ink-soft);
    font-size: 28px;
    transition: all 0.2s;
    background: var(--surface);
  }
  .photo-add-btn:active {
    border-color: var(--accent);
    background: var(--accent-light);
  }
  .photo-thumb {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 12px;
    overflow: hidden;
  }
  .photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  .photo-thumb-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }

  .checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--ink-soft);
    cursor: pointer;
  }
  .checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
  }

  .my-item {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: 14px;
    display: flex;
    gap: 12px;
    align-items: center;
    transition: all 0.2s;
  }
  .my-item:active { border-color: var(--accent); }
  .my-item-photo {
    width: 64px;
    height: 64px;
    background-size: cover;
    background-position: center;
    border-radius: 10px;
    flex-shrink: 0;
    background-color: #EDF0F5;
  }
  .my-item-content { flex: 1; min-width: 0; }
  .my-item-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .my-item-meta {
    font-size: 12px;
    color: var(--ink-soft);
    margin-top: 4px;
  }
  .my-item-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
  }
  .my-item-actions .chip {
    font-size: 12px;
    padding: 4px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
  }
  .my-item-actions .chip:active { border-color: var(--accent); }

  /* ===== ПОХОЖИЕ ОБЪЯВЛЕНИЯ ===== */
  .similar-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 20px;
  }
  .similar-title {
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 15px;
    color: var(--ink);
    margin-bottom: 12px;
  }
  .similar-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    padding: 0 4px;
  }
  .similar-scroll::-webkit-scrollbar { display: none; }
  .similar-card {
    flex-shrink: 0;
    width: 132px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
  }
  .similar-card:active { transform: scale(0.95); border-color: var(--accent); }
  .similar-photo {
    aspect-ratio: 1 / 1;
    background: linear-gradient(135deg, #EDF0F5, #DCE1E8);
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
  }
  .similar-info { padding: 8px 10px 10px; }
  .similar-price {
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 13px;
    color: var(--accent);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .similar-name {
    font-size: 11px;
    color: var(--ink-soft);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* ===== ФИЛЬТРЫ В ПОИСКЕ ===== */
  .search-filters-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px 10px;
  }
  .search-filter-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    color: var(--ink);
    cursor: pointer;
    transition: all 0.2s;
  }
  .search-filter-toggle.open { border-color: var(--accent); color: var(--accent); }
  .search-filter-toggle:active { transform: scale(0.95); }
  #search-filter-panel { margin: 0 16px 12px; }

  /* ===== FILTER BAR + PANEL (лента) ===== */
  .filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px 12px;
  }
  .filter-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    color: var(--ink);
    cursor: pointer;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: all 0.2s;
  }
  .filter-toggle:active { transform: scale(0.95); }
  .filter-toggle.open {
    border-color: var(--accent);
    color: var(--accent);
  }
  .filter-badge {
    background: var(--accent);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 17px;
    height: 17px;
    border-radius: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
  }
  .filter-summary {
    font-size: 12px;
    color: var(--ink-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .filter-panel {
    display: none;
    margin: 0 16px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    animation: slideUp 0.25s ease;
  }
  .filter-panel.open { display: block; }
  .filter-section { margin-bottom: 16px; }
  .filter-section:last-of-type { margin-bottom: 4px; }
  .filter-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--ink-soft);
    margin-bottom: 8px;
  }
  .filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .fopt {
    padding: 8px 14px;
    border-radius: 100px;
    background: var(--bg);
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-soft);
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
  }
  .fopt:active { transform: scale(0.94); }
  .fopt.active {
    background: var(--accent-gradient);
    color: white;
    border-color: var(--accent);
    box-shadow: var(--shadow);
  }

  .price-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .price-inputs input {
    flex: 1;
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Inter', sans-serif;
    -moz-appearance: textfield;
  }
  .price-inputs input::-webkit-outer-spin-button,
  .price-inputs input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }
  .price-inputs input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 123, 110, 0.1);
  }
  .price-dash { color: var(--ink-soft); }

  .filter-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
  }
  .filter-reset {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink-soft);
    font-size: 14px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
  }
  .filter-reset:active { transform: scale(0.97); }
  .filter-apply {
    flex: 2;
    padding: 12px;
    border-radius: 12px;
    border: none;
    background: var(--accent-gradient);
    color: white;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.2s;
  }
  .filter-apply:active { transform: scale(0.97); }

  /* Билд-бейдж для отладки кэша */
  .build-badge {
    position: fixed;
    bottom: 2px;
    left: 6px;
    font-size: 9px;
    font-weight: 700;
    color: var(--ink-soft);
    opacity: 0.35;
    z-index: 99;
    pointer-events: none;
    font-family: monospace;
  }

  @media (min-width: 500px) {
    .grid {
      grid-template-columns: 1fr 1fr 1fr;
      gap: 14px;
      max-width: 720px;
      margin: 0 auto;
    }
  }

  /* ===== ДЕСКТОП / ПЛАНШЕТ: контент по центру, без растяжения на весь экран ===== */
  @media (min-width: 768px) {
    /* Шапки: содержимое выравниваем по краям контентной колонки */
    header,
    .search-topbar,
    .search-filters-bar,
    .favorites-header,
    .my-header,
    .post-topbar {
      padding-left: max(16px, calc((100% - var(--content-max)) / 2));
      padding-right: max(16px, calc((100% - var(--content-max)) / 2));
    }

    /* Полосы чипов и фильтров */
    .filters,
    .filter-bar {
      padding-left: max(16px, calc((100% - var(--content-max)) / 2));
      padding-right: max(16px, calc((100% - var(--content-max)) / 2));
    }
    .filter-panel,
    #search-filter-panel {
      max-width: calc(var(--content-max) - 32px);
      margin-left: auto;
      margin-right: auto;
    }
    .search-suggestions,
    #my-list {
      max-width: var(--content-max);
      margin-left: auto;
      margin-right: auto;
    }

    /* Нижнее таб-меню — плавающая «пилюля» по центру */
    .tabbar {
      left: 50%;
      right: auto;
      transform: translateX(-50%);
      width: min(560px, calc(100% - 32px));
      border-radius: 18px 18px 0 0;
      border: 1px solid var(--border);
      border-bottom: none;
      box-shadow: 0 -4px 24px rgba(0,0,0,0.08);
    }

    /* FAB — у правого края контентной колонки */
    .fab {
      right: max(16px, calc((100% - var(--content-max)) / 2 + 16px));
    }

    /* Стрелка «наверх» — у левого края контентной колонки */
    .scroll-top-btn {
      left: max(16px, calc((100% - var(--content-max)) / 2 + 16px));
    }

    /* Нижние шторки (язык/жалоба) — по центру, не на всю ширину */
    .lang-menu {
      max-width: 560px;
      margin-left: auto;
      margin-right: auto;
      border-radius: 22px;
      bottom: 16px;
    }
  }

  /* ===== ШИРОКИЕ ЭКРАНЫ: 4 колонки, деталь в две колонки ===== */
  @media (min-width: 900px) {
    .grid {
      grid-template-columns: repeat(4, 1fr);
      gap: 16px;
      max-width: var(--content-max);
    }

    /* Деталь: галерея слева, описание справа */
    #detail-screen {
      display: flex;
      gap: 28px;
      align-items: flex-start;
      max-width: var(--content-max);
      margin: 0 auto;
      padding: 16px;
    }
    .gallery {
      flex: 1 1 52%;
      min-width: 0;
      align-self: flex-start;
      position: sticky;
      top: calc(16px + var(--safe-top, 0px));
      border-radius: 20px;
      overflow: hidden;
      min-height: 420px;
    }
    .detail-body {
      flex: 1 1 48%;
      min-width: 0;
      padding: 4px 4px 24px;
    }
    .detail-title { font-size: 17px; }

    /* Форма объявления — как обычная колонка */
    .post-body {
      max-width: 720px;
      margin-left: auto;
      margin-right: auto;
    }
    .post-submit {
      display: block;
      width: 100%;
      max-width: 680px;
      margin: 0 auto 24px;
    }
  }

  /* ===== LUX MARKET BRANDING (ценник-улыбка) ===== */
  .brand {
    align-items: center;
    gap: 8px;
    letter-spacing: 0;
    line-height: 1.05;
  }
  .brand .brand-mark {
    flex: 0 0 auto;
    filter: drop-shadow(0 1px 3px rgba(180, 110, 10, .30));
  }
  .brand .word-strong { font-weight: 800; }
  .brand .word-soft { font-weight: 700; color: var(--ink-soft); letter-spacing: .3px; }
  .brand-left .subtitle { font-size: 11px; letter-spacing: .2px; margin-top: 3px; }
