/* Боковые панели и рисунок тушью на широких экранах (см. desktop-rails.js). */
.rail, .rail-art { display: none; }

@media (min-width: 1240px) {
  :root { --rail-w: clamp(196px, calc((100vw - 760px) / 2 - 56px), 280px); --rail-gap: 28px; }

  .rail-art {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
  }
  .rail-art > div {
    position: absolute;
    top: 0;
    bottom: 0;
    width: calc((100vw - 760px) / 2);
    background-repeat: no-repeat;
    background-size: min(100%, 340px) auto;
    opacity: .45;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent);
  }
  .rail-art-left { left: 0; background-image: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 320 900%22 fill=%22none%22%3E%3Cdefs%3E%3ClinearGradient id=%22m%22 x1=%220%22 y1=%220%22 x2=%220%22 y2=%221%22%3E%3Cstop offset=%220%22 stop-color=%22%23c49a62%22 stop-opacity=%22.22%22/%3E%3Cstop offset=%221%22 stop-color=%22%23c49a62%22 stop-opacity=%220%22/%3E%3C/linearGradient%3E%3ClinearGradient id=%22m2%22 x1=%220%22 y1=%220%22 x2=%220%22 y2=%221%22%3E%3Cstop offset=%220%22 stop-color=%22%238d633d%22 stop-opacity=%22.28%22/%3E%3Cstop offset=%221%22 stop-color=%22%238d633d%22 stop-opacity=%220%22/%3E%3C/linearGradient%3E%3C/defs%3E%3Ccircle cx=%22210%22 cy=%22250%22 r=%2254%22 fill=%22%23c49a62%22 fill-opacity=%22.07%22 stroke=%22%23c49a62%22 stroke-opacity=%22.18%22/%3E%3Cpath d=%22M-10 640 C30 560 60 520 95 470 C120 500 135 520 150 540 C175 480 205 420 240 380 C270 430 300 480 330 520 L330 900 L-10 900Z%22 fill=%22url%28%23m%29%22/%3E%3Cpath d=%22M-10 720 C40 650 80 620 120 590 C150 620 170 640 190 660 C220 620 250 600 290 570 C310 600 330 620 340 640 L340 900 L-10 900Z%22 fill=%22url%28%23m2%29%22/%3E%3Cpath d=%22M95 470 C110 520 100 560 112 610 M240 380 C250 440 236 500 252 560%22 stroke=%22%23c49a62%22 stroke-opacity=%22.16%22 stroke-width=%221.2%22/%3E%3Cg stroke=%22%23c49a62%22 stroke-opacity=%22.34%22 stroke-width=%221.6%22 stroke-linecap=%22round%22%3E%3Cpath d=%22M20 70 C80 110 120 150 150 230 C165 270 170 300 168 330%22/%3E%3Cpath d=%22M72 104 C60 80 58 60 66 40 C86 58 90 82 72 104Z%22 fill=%22%23c49a62%22 fill-opacity=%22.08%22/%3E%3Cpath d=%22M112 150 C130 128 152 120 176 122 C164 146 140 156 112 150Z%22 fill=%22%23c49a62%22 fill-opacity=%22.08%22/%3E%3Cpath d=%22M140 200 C120 186 108 166 106 142 C130 152 142 174 140 200Z%22 fill=%22%23c49a62%22 fill-opacity=%22.08%22/%3E%3Cpath d=%22M158 262 C178 246 200 242 222 248 C206 268 182 272 158 262Z%22 fill=%22%23c49a62%22 fill-opacity=%22.08%22/%3E%3Cpath d=%22M50 88 C40 60 20 48 0 46%22/%3E%3C/g%3E%3Cg fill=%22%23c49a62%22 fill-opacity=%22.28%22%3E%3Ccircle cx=%22190%22 cy=%22140%22 r=%221.6%22/%3E%3Ccircle cx=%2260%22 cy=%22190%22 r=%221.2%22/%3E%3Ccircle cx=%22250%22 cy=%2290%22 r=%221.4%22/%3E%3C/g%3E%3C/svg%3E"); background-position: left bottom; }
  .rail-art-right { right: 0; background-image: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 320 900%22 fill=%22none%22%3E%3Cg stroke=%22%23c49a62%22 stroke-opacity=%22.3%22 stroke-width=%221.6%22 stroke-linecap=%22round%22%3E%3Cpath d=%22M120 560 C100 520 130 500 112 460 C96 424 128 404 116 370%22/%3E%3Cpath d=%22M160 556 C142 512 176 488 156 446 C140 410 172 386 160 350 C150 320 168 300 162 276%22/%3E%3Cpath d=%22M200 560 C186 528 210 510 198 478 C188 452 206 436 200 410%22/%3E%3C/g%3E%3Cpath d=%22M60 600 C60 680 110 720 160 720 C210 720 260 680 260 600Z%22 fill=%22%23c49a62%22 fill-opacity=%22.07%22 stroke=%22%23c49a62%22 stroke-opacity=%22.32%22 stroke-width=%221.6%22/%3E%3Cpath d=%22M52 600 H268%22 stroke=%22%23c49a62%22 stroke-opacity=%22.34%22 stroke-width=%221.6%22 stroke-linecap=%22round%22/%3E%3Cpath d=%22M112 724 H208 L200 744 H120Z%22 fill=%22%23c49a62%22 fill-opacity=%22.06%22 stroke=%22%23c49a62%22 stroke-opacity=%22.26%22 stroke-width=%221.4%22/%3E%3Cpath d=%22M90 630 C120 650 200 650 230 630%22 stroke=%22%23c49a62%22 stroke-opacity=%22.16%22 stroke-width=%221.2%22/%3E%3Cpath d=%22M-10 860 C60 820 140 830 200 845 C250 858 300 850 340 830 L340 900 L-10 900Z%22 fill=%22%238d633d%22 fill-opacity=%22.12%22/%3E%3Cg stroke=%22%23c49a62%22 stroke-opacity=%22.26%22 stroke-width=%221.4%22 fill=%22%23c49a62%22 fill-opacity=%22.06%22%3E%3Cpath d=%22M250 150 C262 130 282 124 300 128 C290 148 270 156 250 150Z%22/%3E%3Cpath d=%22M60 230 C52 210 56 190 70 176 C82 196 78 216 60 230Z%22/%3E%3Cpath d=%22M230 300 C246 290 262 292 274 302 C260 314 244 314 230 300Z%22/%3E%3C/g%3E%3Ctext x=%22160%22 y=%22110%22 text-anchor=%22middle%22 font-family=%22serif%22 font-size=%2264%22 fill=%22%23c49a62%22 fill-opacity=%22.12%22%3E%E8%8C%B6%3C/text%3E%3C/svg%3E"); background-position: right bottom; }
  main { position: relative; z-index: 1; }
  /* Категории на широком экране — в левой панели, поэтому ряд кнопок над каталогом скрыт. */
  #categoryTabs { display: none; }

  .rail {
    display: block;
    position: fixed;
    top: 104px;
    z-index: 5;
    width: var(--rail-w);
    max-height: calc(100vh - 128px);
    overflow-y: auto;
    scrollbar-width: none;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity .3s ease, transform .3s ease;
  }
  .rail-left { right: calc(50% + 380px + var(--rail-gap)); }
  .rail-right { left: calc(50% + 380px + var(--rail-gap)); }
  body.rails-on .rail { opacity: 1; transform: none; pointer-events: auto; }
  /* Левая панель с разделами видна всегда; категории — только когда на экране каталог. */
  body.rails-desktop .rail-left { opacity: 1; transform: none; pointer-events: auto; }
  body.hero-visible .rail { opacity: 0 !important; transform: translateY(8px) !important; pointer-events: none !important; }
  .rail-categories { transition: opacity .3s ease; }
  body:not(.rails-on) .rail-categories { opacity: 0; pointer-events: none; }
  /* Нижнее меню на широком экране заменено левой панелью. */
  /* Наверху страницы — обычное нижнее меню; при прокрутке оно «улетает» влево вверх
     и превращается в левую панель. */
  .bottom-nav {
    transition: opacity .4s ease, translate .5s cubic-bezier(.4, 0, .2, 1), scale .5s cubic-bezier(.4, 0, .2, 1), visibility 0s linear .5s;
    transform-origin: 0 0;
  }
  body.rails-desktop:not(.hero-visible) .bottom-nav {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    translate: calc(-50vw + 60px) calc(-100vh + 220px);
    scale: .4;
  }
  body.hero-visible .bottom-nav { transition-delay: 0s; }
  body.rails-desktop:not(.hero-visible) .rail-left { transition-delay: .22s; }
  body { padding-bottom: 32px; }

  .rail-sections { display: grid; gap: 4px; padding: 10px; }
  .rail-section {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px; border: 0; border-radius: 12px;
    background: none; color: var(--ink-soft); font-size: 15px; font-weight: 600;
    cursor: pointer; text-align: left; transition: background .15s, color .15s;
  }
  .rail-section svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
  .rail-section span { flex: 1; }
  .rail-section:hover { background: rgba(196, 154, 98, .08); color: var(--ink); }
  .rail-section.active { background: linear-gradient(180deg, rgba(196, 154, 98, .28), rgba(141, 99, 61, .22)); color: var(--white); box-shadow: inset 0 0 0 1px rgba(196, 154, 98, .55); }
  .rail-section-badge { min-width: 20px; padding: 3px 6px; border-radius: 999px; background: var(--gold); color: #1a120b; font-size: 11px; text-align: center; }

  .rail-card {
    background: linear-gradient(180deg, rgba(23, 20, 17, .92), rgba(15, 13, 11, .92));
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px 16px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, .35);
    backdrop-filter: blur(6px);
  }
  .rail-card + .rail-card { margin-top: 12px; }
  .rail-eyebrow { display: block; color: var(--gold); font-size: 10px; letter-spacing: .16em; font-weight: 700; }
  .rail-title { margin: 4px 0 12px; font-family: Georgia, "Times New Roman", serif; font-size: 22px; color: var(--white); display: flex; align-items: center; gap: 8px; }
  .rail-count { font: 700 12px/1 Inter, system-ui, sans-serif; color: #1a120b; background: var(--gold); border-radius: 999px; padding: 4px 8px; }

  .rail-cats { display: grid; gap: 2px; }
  .rail-cat {
    text-align: left;
    background: none;
    border: 0;
    color: var(--ink-soft);
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s, color .15s;
  }
  .rail-cat:hover { background: rgba(196, 154, 98, .08); color: var(--ink); }
  .rail-cat.active { background: rgba(196, 154, 98, .16); color: var(--white); box-shadow: inset 2px 0 0 var(--gold); }

  .rail-empty { margin: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.5; }
  .rail-lines { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .rail-lines li { min-width: 0; display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--ink); }
  .rail-lines li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .rail-lines li b { flex-shrink: 0; }
  .rail-lines li b { color: var(--gold); white-space: nowrap; font-weight: 600; }
  .rail-lines .rail-more { color: var(--ink-soft); }
  .rail-total { display: flex; justify-content: space-between; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-soft); }
  .rail-total b { color: var(--white); font-size: 17px; }
  .rail-free { margin-top: 10px; font-size: 12px; color: var(--ink-soft); }
  .rail-progress { height: 4px; margin-top: 6px; border-radius: 4px; background: rgba(196, 154, 98, .14); overflow: hidden; }
  .rail-progress i { display: block; height: 100%; background: var(--gold); border-radius: 4px; transition: width .3s; }
  .rail-checkout {
    width: 100%;
    margin-top: 14px;
    padding: 11px 14px;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(180deg, #c49a62, #9b7444);
    color: #1a120b;
    font-weight: 700;
    cursor: pointer;
  }
  .rail-checkout:hover { filter: brightness(1.07); }
  .rail-note p { margin: 6px 0 0; color: var(--ink-soft); font-size: 12.5px; line-height: 1.55; }
}

/* До первой отрисовки — без анимаций, чтобы ничего не мигало при загрузке. */
body:not(.rails-ready) .rail,
body:not(.rails-ready) .rail-categories,
body:not(.rails-ready) .bottom-nav { transition: none !important; }
