/* Bikepacking constructor (static/js/ai/hike-bikepack.js). Bicycle plans only.
   :not(#bp-x) keeps it above hike-planner-calm.css (.is-hike-mode:not(#hc-unused) ...). */

.tp-gearpanel.bp-mode:not(#bp-x) {
    --bp-ink: #13201a; --bp-muted: #627067; --bp-line: rgba(19, 32, 26, .1); --bp-card: #fff; --bp-soft: #f3f7f4;
    --bp-ease: cubic-bezier(.22, 1, .36, 1); --bp-spring: cubic-bezier(.34, 1.56, .64, 1);
    display: block;
}
.tp-gearpanel.bp-mode:not(#bp-x) .hc-gear-main > :is(.tp-pack, .tp-gearsets, .tp-gearpanel__empty) { display: none; }
.tp-gearpanel.bp-mode:not(#bp-x) > :not(.hc-gear-main) { margin-top: 24px; }

.bp { display: grid; grid-template-columns: minmax(360px, 1.05fr) minmax(0, 1fr); gap: 24px; align-items: start; color: var(--bp-ink); }

/* ---------- Sticky scene ---------- */
.bp-scene {
    position: sticky; top: 84px; display: grid; gap: 14px; max-height: calc(100vh - 96px); overflow-y: auto; scrollbar-width: thin;
    padding: 20px; border: 1px solid var(--bp-line); border-radius: 26px;
    background: radial-gradient(520px 240px at 20% 0, rgba(107, 188, 255, .16), transparent 70%), radial-gradient(420px 220px at 100% 100%, rgba(255, 106, 26, .1), transparent 70%), var(--bp-card);
    box-shadow: 0 2px 6px rgba(19, 32, 26, .04), 0 24px 54px rgba(19, 32, 26, .1);
}
.bp-scene__head h3 { margin: 2px 0 10px; font-size: 24px !important; font-weight: 850 !important; letter-spacing: -.03em !important; }
.bp-steps { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; counter-reset: bp; }
.bp-steps li { counter-increment: bp; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--bp-soft); font-size: 12px; font-weight: 750; color: var(--bp-muted); }
.bp-steps li::before { content: counter(bp); display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #fff; font-size: 11px; }
.bp-steps li.is-done { color: #1d6b47; background: #e2f3e9; }
.bp-steps li.is-done::before { content: "✓"; background: #2c8a5a; color: #fff; }

.bp-bike { position: relative; margin: 0 -6px; }
.bp-svg { display: block; width: 100%; height: auto; overflow: visible; }
.bp-bike__hint { margin: 0; text-align: center; font-size: 12.5px; font-weight: 700; color: var(--bp-muted); min-height: 18px; }

/* bicycle */
.bp-ground { fill: rgba(19, 32, 26, .1); }
.bp-tire { fill: none; stroke: #27302b; stroke-width: 11; }
.bp-rim { fill: none; stroke: #a9b6bd; stroke-width: 3; }
.bp-wheel line { stroke: #b9c4c9; stroke-width: 1.2; }
.bp-hub { fill: #33443b; }
.bp-wheel { transform-box: fill-box; transform-origin: center; }
.bp-drive circle { fill: none; stroke: #4b5a52; stroke-width: 5; }
.bp-drive path { fill: none; stroke: #6b7a72; stroke-width: 2; }
.bp-drive .bp-crank { stroke: #33443b; stroke-width: 6; stroke-linecap: round; }
.bp-frame path { fill: none; stroke: #3b7ea8; stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.bp-frame .bp-head { stroke-width: 13; stroke: #2f6b90; }
.bp-frame .bp-forkline { stroke: #4b5a52; stroke-width: 8; }
.bp-post { fill: none; stroke: #4b5a52; stroke-width: 6; stroke-linecap: round; }
.bp-saddle { fill: #7a5232; }
.bp-cockpit { fill: none; stroke: #33443b; stroke-width: 6; stroke-linecap: round; }
.bp-grip { fill: #27302b; }
.bp-rack { fill: none; stroke: #6b7a72; stroke-width: 4; stroke-linecap: round; }
.bp-strap { fill: none; stroke: #9aa8a0; stroke-width: 4; }

/* bags: ghost until switched on */
.bp-bag { cursor: pointer; outline: none; }
.bp-bag__in { transform-box: fill-box; transform-origin: center; }
.bp-bag__body { fill: #dfe5e1; opacity: .6; transition: fill .4s, opacity .3s; }
.bp-bag__fill { fill: var(--c); transform: scaleY(var(--fill, 0)); transform-box: fill-box; transform-origin: 50% 100%; opacity: 0; transition: transform .8s var(--bp-ease), opacity .3s; }
.bp-bag__line { fill: none; stroke: #a3b0a8; stroke-width: 2; stroke-dasharray: 5 4; transition: stroke .3s; }
.bp-bag__plus { fill: none; stroke: #7d8c84; stroke-width: 2.6; stroke-linecap: round; transition: opacity .25s; }
.bp-bag:hover .bp-bag__body, .bp-bag:focus-visible .bp-bag__body { opacity: .95; fill: color-mix(in srgb, var(--c) 22%, #fff); }
.bp-bag:hover .bp-bag__line, .bp-bag:focus-visible .bp-bag__line { stroke: var(--c); }
.bp-bag:focus-visible .bp-bag__line { stroke-width: 3.5; }
.bp-bag .bp-strap, .bp-bag .bp-rack { opacity: .45; }
.bp-bag.is-on .bp-bag__body { fill: color-mix(in srgb, var(--c) 30%, #fff); opacity: 1; }
.bp-bag.is-on .bp-bag__fill { opacity: 1; }
.bp-bag.is-on .bp-bag__line { stroke: color-mix(in srgb, var(--c) 70%, #000); stroke-dasharray: none; stroke-width: 2.4; }
.bp-bag.is-on .bp-bag__plus { opacity: 0; }
.bp-bag.is-on :is(.bp-strap, .bp-rack) { opacity: 1; }
.bp-bag.is-active .bp-bag__in { filter: drop-shadow(0 0 8px color-mix(in srgb, var(--c) 70%, transparent)); }
.bp-bag.is-active .bp-bag__line { stroke-dasharray: 8 5; animation: bp-march 1.2s linear infinite; stroke: var(--c); stroke-width: 3; }
.bp-bag.is-over .bp-bag__fill { fill: #d63a3a; }
.bp-bag.is-over .bp-bag__in { animation: bp-shake .5s; }
.bp-bag.is-gulp .bp-bag__in { animation: bp-gulp .55s var(--bp-spring); }

/* totals */
.bp-total { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bp-total > div { padding: 10px 12px; border-radius: 16px; background: var(--bp-soft); }
.bp-total small { display: block; font-size: 11.5px; color: var(--bp-muted); font-weight: 700; }
.bp-total b { font-size: 20px; font-weight: 850; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.bp-total > div:first-child { background: linear-gradient(135deg, #fff1e7, #ffe2cc); }
.bp-total > div:first-child b { color: #c2410c; }

.bp-balance__bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: rgba(19, 32, 26, .07); }
.bp-balance__bar i { flex-basis: 0; transition: flex-grow .8s var(--bp-ease); }
.bp-balance .is-front { --z: #2c8a5a; } .bp-balance .is-frame { --z: #ff6a1a; } .bp-balance .is-rear { --z: #2b6fd6; } .bp-balance .is-back { --z: #c2410c; }
.bp-balance__bar i { background: var(--z); }
.bp-balance ul { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.bp-balance li { display: grid; font-size: 11.5px; color: var(--bp-muted); padding-left: 10px; border-left: 3px solid var(--z); }
.bp-balance li b { font-size: 13.5px; color: var(--bp-ink); font-variant-numeric: tabular-nums; }
.bp-balance li small { font-size: 11px; }

.bp-warnings { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.bp-warnings li { --w: #23527a; position: relative; padding: 8px 10px 8px 30px; border-radius: 12px; font-size: 12.5px; line-height: 1.45; background: #eef5fb; color: var(--w); animation: bp-in .35s var(--bp-ease); }
.bp-warnings li::before { content: "i"; position: absolute; left: 9px; top: 9px; display: grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: var(--w); color: #fff; font-size: 10px; font-weight: 900; }
.bp-warnings li.is-alert { --w: #a3410f; background: #fff1e9; }
.bp-warnings li.is-alert::before { content: "!"; }

/* ---------- Work column ---------- */
.bp-work { display: grid; gap: 18px; min-width: 0; }
.bp-block { padding: 18px; border: 1px solid var(--bp-line); border-radius: 22px; background: var(--bp-card); box-shadow: 0 1px 2px rgba(19, 32, 26, .04), 0 10px 26px rgba(19, 32, 26, .05); }
.bp-block > header { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.bp-block > header > span { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(135deg, #ff6a1a, #ef540c); color: #fff; font-weight: 900; font-size: 14px; }
.bp-block h4 { margin: 2px 0 2px; font-size: 17px !important; font-weight: 850 !important; }
.bp-block > header p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--bp-muted); }
.bp-empty { margin: 0; padding: 12px; border-radius: 12px; border: 1px dashed var(--bp-line); font-size: 13px; color: var(--bp-muted); }

.bp-bags { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.bp-bags.is-nudge { animation: bp-shake .5s; }
.bp-bagcard {
    display: grid; grid-template-columns: 12px minmax(0, 1fr) 24px; gap: 10px; align-items: center; padding: 10px 12px; min-height: 52px;
    border: 1.5px dashed #c6d0ca; border-radius: 14px; background: #fafbfa; color: var(--bp-ink); font: inherit; text-align: left; cursor: pointer;
    transition: border-color .25s, background .25s, transform .3s var(--bp-spring), box-shadow .25s;
}
.bp-bagcard:hover { transform: translateY(-2px); border-color: var(--c); }
.bp-bagcard:active { transform: scale(.97); }
.bp-bagcard i { width: 12px; height: 12px; border-radius: 4px; background: #cfd8d2; transition: background .25s; }
.bp-bagcard b { display: block; font-size: 13px; font-weight: 750; line-height: 1.25; }
.bp-bagcard small { font-size: 11.5px; color: var(--bp-muted); }
.bp-bagcard em { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 1px solid var(--bp-line); font-style: normal; font-weight: 900; font-size: 13px; color: var(--bp-muted); }
.bp-bagcard.is-on { border-style: solid; border-color: color-mix(in srgb, var(--c) 55%, transparent); background: color-mix(in srgb, var(--c) 8%, #fff); }
.bp-bagcard.is-on i { background: var(--c); }
.bp-bagcard.is-on em { background: var(--c); color: #fff; border-color: transparent; }
.bp-bagcard:focus-visible, .bp-item:focus-visible, .bp-target button:focus-visible { outline: 3px solid rgba(255, 106, 26, .55); outline-offset: 2px; }

.bp-target { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; padding: 6px; border-radius: 16px; background: var(--bp-soft); }
.bp-target button { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 6px 12px; border: 0; border-radius: 11px; background: transparent; color: var(--bp-ink); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; transition: background .2s, box-shadow .2s, transform .25s var(--bp-spring); }
.bp-target button i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.bp-target button[aria-checked="true"] { background: #fff; box-shadow: 0 0 0 2px var(--c), 0 6px 14px rgba(19, 32, 26, .1); }
.bp-target button:active { transform: scale(.96); }
.bp-target .bp-empty { flex: 1; border: 0; padding: 6px; }

.bp-search input { width: 100%; min-height: 44px; padding: 10px 14px; border: 1.5px solid #d6dfd8; border-radius: 14px; background: #fcfdfb; font: inherit; font-size: 14px; color: var(--bp-ink); }
.bp-search input:focus { outline: none; border-color: #ff6a1a; box-shadow: 0 0 0 4px rgba(255, 106, 26, .16); }

.bp-catalog { display: grid; gap: 16px; margin-top: 14px; }
.bp-cat h5 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--bp-muted); }
.bp-cat h5 small { padding: 1px 8px; border-radius: 999px; background: var(--bp-soft); letter-spacing: 0; }
.bp-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.bp-itemwrap { position: relative; }
.bp-item {
    position: relative; display: grid; gap: 10px; align-items: center; width: 100%; min-height: 62px; padding: 8px 10px 8px 8px;
    border: 1.5px solid var(--bp-line); border-radius: 16px; background: #fff; color: var(--bp-ink); font: inherit; text-align: left; cursor: pointer;
    transition: transform .3s var(--bp-ease), box-shadow .3s var(--bp-ease), border-color .25s, background .25s;
}
.bp-item:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(19, 32, 26, .09); }
.bp-item:active { transform: scale(.98); }
.bp-item__art { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; background: radial-gradient(circle at 30% 25%, #fff, #eef3f0); }
.bp-item__art svg { width: 36px; height: 36px; overflow: visible; filter: drop-shadow(0 3px 4px rgba(19, 32, 26, .16)); transition: transform .45s var(--bp-spring); }
.bp-item:hover .bp-item__art svg { transform: translateY(-3px) rotate(-8deg) scale(1.08); }
.bp-item__copy { min-width: 0; }
.bp-item__copy b { display: block; font-size: 13px; font-weight: 750; line-height: 1.25; }
.bp-item__copy small { display: block; margin-top: 2px; font-size: 11.5px; color: var(--bp-muted); font-variant-numeric: tabular-nums; }
.bp-item__tag { display: inline-block; margin-top: 4px; padding: 1px 7px; border-radius: 999px; background: #fff1e7; color: #b5470f; font-size: 10.5px; font-weight: 800; }
.bp-item__add { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 1.5px dashed #b9c5be; color: var(--bp-muted); font-weight: 900; transition: background .2s, color .2s, border-color .2s; }
.bp-item:hover .bp-item__add { background: #ff6a1a; border-color: #ff6a1a; color: #fff; }
.bp-item__bag { padding: 3px 8px; border-radius: 999px; background: var(--c); color: #fff; font-size: 10.5px; font-weight: 800; line-height: 1.25; text-align: center; animation: bp-pop .45s var(--bp-spring); }
.bp-item.is-packed { border-color: color-mix(in srgb, var(--c) 45%, transparent); background: color-mix(in srgb, var(--c) 7%, #fff); }
.bp-item.is-packed .bp-item__art svg { transform: scale(.85); opacity: .65; }
.bp-item { grid-template-columns: 46px minmax(0, 1fr) 26px; grid-template-rows: auto auto; row-gap: 4px; }
.bp-item__art { grid-row: 1 / 3; }
.bp-item__copy { grid-column: 2; grid-row: 1; }
.bp-item__add { grid-column: 3; grid-row: 1 / 3; }
.bp-item__bag { grid-column: 2; grid-row: 2; justify-self: start; max-width: 100%; }
.bp-item.is-packed::after { content: "✓"; grid-column: 3; grid-row: 1 / 3; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--c); color: #fff; font-size: 12px; font-weight: 900; animation: bp-pop .45s var(--bp-spring); }
.bp-item__del { position: absolute; top: -7px; right: -7px; display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 50%; background: #33443b; color: #fff; font-size: 14px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .2s; }
.bp-itemwrap:hover .bp-item__del, .bp-item__del:focus-visible { opacity: 1; }

.bp-custom { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: end; margin-top: 16px; padding: 14px; border-radius: 16px; background: var(--bp-soft); }
.bp-custom > b { grid-column: 1 / -1; font-size: 13px; }
.bp-custom label, .bp-food label { display: grid; gap: 4px; font-size: 11.5px; font-weight: 700; color: var(--bp-muted); }
.bp-custom input, .bp-food input { width: 100%; min-height: 42px; padding: 8px 10px; border: 1.5px solid #d6dfd8; border-radius: 12px; background: #fff; font: inherit; font-size: 14px; color: var(--bp-ink); }
.bp-custom input:focus, .bp-food input:focus { outline: none; border-color: #ff6a1a; box-shadow: 0 0 0 4px rgba(255, 106, 26, .16); }
.bp-custom button { min-height: 42px; border-radius: 12px; }

.bp-food { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.bp-food__item { grid-column: 1 / -1; display: grid; gap: 6px; }
.bp-food__item p { margin: 0; font-size: 13px; color: var(--bp-muted); }
.bp-food__item p b { color: var(--bp-ink); }

.bp-summary table { width: 100%; border-collapse: collapse; font-size: 13px; }
.bp-summary th { padding: 6px 8px; text-align: left; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--bp-muted); }
.bp-summary td { padding: 9px 8px; border-top: 1px solid var(--bp-line); vertical-align: middle; font-variant-numeric: tabular-nums; }
.bp-summary td:first-child { font-weight: 750; }
.bp-summary td:first-child i { display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 3px; background: var(--c); }
.bp-summary td small { display: block; margin-left: 18px; font-size: 11px; font-weight: 600; color: var(--bp-muted); }
.bp-summary tfoot td { font-weight: 850; }
.bp-meter { display: block; height: 6px; margin-bottom: 4px; border-radius: 999px; background: rgba(19, 32, 26, .08); overflow: hidden; }
.bp-meter i { display: block; height: 100%; border-radius: inherit; background: var(--c); transition: width .6s var(--bp-ease); }
.bp-meter.is-over i { background: #d63a3a; }
.bp-mobile-extra { display: none; }

@keyframes bp-march { to { stroke-dashoffset: -26; } }
@keyframes bp-gulp { 0% { transform: scale(1); } 35% { transform: scale(1.14, .9); } 65% { transform: scale(.95, 1.06); } 100% { transform: scale(1); } }
@keyframes bp-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes bp-pop { 0% { transform: scale(.5); opacity: 0; } 70% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }
@keyframes bp-in { from { opacity: 0; transform: translateY(-4px); } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .bp { grid-template-columns: minmax(320px, 1fr) minmax(0, 1fr); } }
@media (max-width: 900px) {
    .bp { grid-template-columns: 1fr; }
    .bp-scene { top: 60px; z-index: 5; gap: 8px; padding: 10px 12px; border-radius: 20px; max-height: none; overflow: visible; }
    .bp-scene__head, .bp-scene > .bp-balance, .bp-scene > .bp-warnings { display: none; }
    .bp-bike { margin: 0; }
    .bp-svg { max-height: 150px; }
    .bp-bike__hint { font-size: 11.5px; }
    .bp-total b { font-size: 16px; }
    .bp-total > div { padding: 6px 10px; border-radius: 12px; }
    .bp-mobile-extra { display: grid; gap: 10px; margin-bottom: 12px; }
    .bp-custom { grid-template-columns: 1fr 1fr; }
    .bp-custom label:first-of-type { grid-column: 1 / -1; }
    .bp-custom button { grid-column: 1 / -1; }
    .bp-food { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) { .bp-items, .bp-bags { grid-template-columns: 1fr; } }

/* ---------- Dark theme ---------- */
:is(html[data-theme=dark], html.dark, body.dark) .tp-gearpanel.bp-mode:not(#bp-x) { --bp-ink: #e7eee8; --bp-muted: #a6b6ab; --bp-line: rgba(231, 238, 232, .1); --bp-card: #18241d; --bp-soft: #22322a; }
:is(html[data-theme=dark], html.dark, body.dark) :is(.bp-item, .bp-bagcard, .bp-custom input, .bp-food input, .bp-search input, .bp-target button[aria-checked="true"]) { background: #1b2a21; color: #e7eee8; }
:is(html[data-theme=dark], html.dark, body.dark) .bp-item__art { background: radial-gradient(circle at 30% 25%, #2a3b31, #1b2a21); }
:is(html[data-theme=dark], html.dark, body.dark) .bp-bag__body { fill: #3a4a41; }
:is(html[data-theme=dark], html.dark, body.dark) .bp-bag.is-on .bp-bag__body { fill: color-mix(in srgb, var(--c) 30%, #18241d); }
:is(html[data-theme=dark], html.dark, body.dark) .bp-tire { stroke: #0d1310; }
:is(html[data-theme=dark], html.dark, body.dark) .bp-total > div:first-child { background: linear-gradient(135deg, #3a2a1d, #4a3524); }
:is(html[data-theme=dark], html.dark, body.dark) .bp-total > div:first-child b { color: #ffb27f; }
:is(html[data-theme=dark], html.dark, body.dark) .bp-warnings li { background: #1d2c3a; color: #a9cdf0; }
:is(html[data-theme=dark], html.dark, body.dark) .bp-warnings li.is-alert { background: #3a2a1d; color: #ffc7a3; }

@media (prefers-reduced-motion: reduce) {
    .bp *, .bp *::before { animation: none !important; transition-duration: .01ms !important; }
}
