/* ============ кабинет: каталог ============ */
body.cabinet main, body.cabinet .topbar-in { max-width: 1320px; }

/* шапка */
.cab-head { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: end; padding: 34px 0 18px; }
.cab-title h1 { font-size: clamp(32px, 4vw, 46px); letter-spacing: -.035em; margin: 0 0 14px; font-weight: 800; line-height: 1; }
.stepper { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.stepper li { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--dim); padding: 6px 12px 6px 6px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); transition: all .4s var(--ease); }
.stepper li i { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 12px; background: var(--surface-2); transition: all .4s var(--spring); }
.stepper li + li::before { content: ""; }
.stepper li.cur { color: var(--text); border-color: color-mix(in srgb, var(--a1) 45%, transparent); }
.stepper li.cur i { background: var(--grad); color: #fff; box-shadow: 0 0 0 4px color-mix(in srgb, var(--a1) 18%, transparent); }
.stepper li.done { color: var(--muted); }
.stepper li.done i { background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 12.5 4 4 8-9' fill='none' stroke='%23062a14' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/13px no-repeat; color: transparent; }

.cab-connect { display: flex; align-items: center; gap: 14px; padding: 12px 12px 12px 14px; border-radius: 20px; max-width: 520px; background: linear-gradient(135deg, color-mix(in srgb, var(--a1) 14%, transparent), color-mix(in srgb, var(--a2) 5%, transparent)); border: 1px solid color-mix(in srgb, var(--a1) 35%, transparent); }
.cab-connect-ico { width: 42px; height: 42px; flex: none; border-radius: 13px; display: grid; place-items: center; background: var(--grad); box-shadow: 0 8px 20px -8px var(--glow); }
.cab-connect-ico svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; }
/* текст сжимается, кнопки — никогда (иначе «Войти в Apple ID» обрезалась) */
.cab-connect-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.cab-connect > .btn, .cab-connect-btns .btn { flex: none; }
/* карточка гостя: значок и текст сверху, кнопки — во всю ширину снизу (текст не сжимается в узкую колонку) */
#cabGuest { flex-wrap: wrap; row-gap: 14px; }
#cabGuest .cab-connect-text { flex: 1 1 calc(100% - 60px); }
#cabGuest .cab-connect-btns { width: 100%; }
#cabGuest .cab-connect-btns .btn { flex: 1; }
.cab-connect-text b { font-size: 15px; }
.cab-connect-text span { font-size: 13px; color: var(--muted); }
/* три состояния: гость / нет Apple ID / Apple ID подключён */
.cab-connect-btns { display: flex; gap: 8px; flex: none; }
.cab-apple { display: grid; gap: 8px; justify-items: end; max-width: 520px; }
.cab-apple .cab-me { width: 100%; }
.cab-me-ico { width: 38px; height: 38px; border-radius: 12px; flex: none; display: grid; place-items: center; background: var(--surface-2); }
.cab-me-ico svg { width: 18px; height: 18px; fill: var(--text); }
.cab-me-text { flex: 1; min-width: 0; display: grid; }
.cab-me-text small { font-size: 12px; color: var(--muted); }
.cab-me-text b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cab-hint { margin: 0; font-size: 12.5px; color: var(--dim); text-align: right; max-width: 460px; }

/* переключатель Вход / Регистрация */
.seg { position: relative; display: flex; padding: 4px; margin: 14px 0 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.seg button { position: relative; z-index: 1; flex: 1; font: inherit; font-weight: 600; font-size: 15px; color: var(--muted); background: none; border: 0; padding: 9px 12px; border-radius: 10px; cursor: pointer; transition: color .3s; }
.seg button.on { color: #fff; }
.seg-pill { position: absolute; top: 4px; bottom: 4px; left: 4px; border-radius: 10px; background: var(--grad); transition: transform .4s var(--spring), width .4s var(--spring); }
#authPass2Box { animation: fade-down .35s var(--ease); }

.cab-me { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); padding: 10px 10px 10px 10px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); animation: fade-down .45s var(--ease); }
.cab-me b { color: var(--text); font-weight: 600; }
.cab-me-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px rgba(61, 220, 132, .15); }

/* закреплённая панель: вкладки + поиск, категории */
.cab-bar { position: sticky; top: 61px; z-index: 10; margin: 0 -20px; padding: 10px 20px 2px; border-bottom: 1px solid transparent; transition: background .3s, border-color .3s; }
.cab-bar.stuck { background: rgba(11, 11, 15, .82); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-bottom-color: var(--border); }
.cab-bar-row { display: flex; gap: 12px; align-items: center; }
.cab-bar .tabs { margin: 0; flex: none; }
.cab-bar .searchbar { flex: 1; height: 50px; border-radius: 16px; }
.cab-bar .chips { padding: 10px 0; }

/* разделы */
.cat-view { padding-top: 6px; }
.cv-sec { margin-top: 26px; animation: card-in .5s var(--ease) both; }
.cv-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.cv-head h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.cv-head h2 span { font-size: 14px; font-weight: 600; color: var(--dim); margin-left: 6px; }
.cv-more { font: inherit; font-size: 14px; font-weight: 600; color: var(--a2); background: none; border: 0; cursor: pointer; padding: 4px 6px; border-radius: 8px; transition: background .2s; }
.cv-more:hover { background: var(--surface-2); }

/* крупные карточки «Популярное» */
.feat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.feat { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 20px 12px 14px; border-radius: 22px; font: inherit; color: inherit; cursor: pointer; background: var(--surface); border: 1px solid var(--border); overflow: hidden; animation: card-in .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 30ms); transition: transform .35s var(--ease), border-color .3s, background .3s; }
.feat::before { content: ""; position: absolute; left: 50%; top: 14px; width: 90px; height: 90px; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--a1) 30%, transparent), transparent); opacity: 0; transition: opacity .35s; }
.feat:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--a1) 35%, transparent); background: var(--surface-2); }
.feat:hover::before { opacity: 1; }
.feat-icon { position: relative; width: 72px; height: 72px; border-radius: 18px; object-fit: cover; margin-bottom: 10px; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; font-size: 26px; box-shadow: 0 14px 28px -12px rgba(0, 0, 0, .8); transition: transform .45s var(--spring); }
.feat:hover .feat-icon { transform: scale(1.07) translateY(-2px); }
.feat b { font-size: 14.5px; line-height: 1.25; }
.feat small { font-size: 12px; color: var(--dim); margin-bottom: 10px; }

/* «Популярное» — горизонтальная лента с докруткой */
.scroller-wrap { position: relative; margin: 0 -20px; }
.feat-grid.scroller { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 158px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0 20px; padding: 4px 20px 10px; scrollbar-width: none; mask-image: linear-gradient(90deg, transparent, #000 20px, #000 calc(100% - 20px), transparent); }
.feat-grid.scroller::-webkit-scrollbar { display: none; }
.feat-grid.scroller .feat { scroll-snap-align: start; }
.sc-btn { position: absolute; top: 50%; z-index: 2; width: 40px; height: 40px; margin-top: -26px; border-radius: 50%; border: 1px solid var(--border-2); background: rgba(22, 22, 28, .9); backdrop-filter: blur(8px); color: var(--text); font-size: 22px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .25s, transform .25s var(--ease), background .2s; }
.sc-btn.prev { left: 4px; }
.sc-btn.next { right: 4px; }
.scroller-wrap:hover .sc-btn { opacity: 1; }
.sc-btn:hover { background: var(--grad); border-color: transparent; transform: scale(1.08); }

/* строки приложений */
.rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 8px 14px; }
.app-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px 10px 10px; border-radius: 16px; font: inherit; color: inherit; text-align: left; cursor: pointer; background: transparent; border: 1px solid transparent; animation: card-in .45s var(--ease) both; animation-delay: calc(var(--i, 0) * 18ms); transition: background .25s, border-color .25s; }
.app-row:hover { background: var(--surface); border-color: var(--border); }
.app-row-icon { width: 50px; height: 50px; border-radius: 13px; flex: none; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; font-size: 20px; color: var(--muted); box-shadow: 0 8px 18px -10px rgba(0, 0, 0, .8); transition: transform .4s var(--spring); }
.app-row:hover .app-row-icon { transform: scale(1.06); }
.app-row-meta { flex: 1; min-width: 0; display: grid; gap: 2px; padding-bottom: 2px; }
.app-row-meta b { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-row-meta small { font-size: 12.5px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-row-meta small.warn-t { color: var(--warn); }

/* кнопка «Установить» — таблетка, заливается при наведении */
.get { flex: none; font-size: 13px; font-weight: 700; color: var(--a1); padding: 7px 14px; border-radius: 999px; background: color-mix(in srgb, var(--a1) 13%, transparent); transition: background .25s, color .25s, box-shadow .25s, transform .2s var(--ease); }
.app-row:hover .get, .feat:hover .get { color: #fff; background: var(--grad); box-shadow: 0 6px 16px -6px var(--glow); }
.app-row:active .get, .feat:active .get { transform: scale(.95); }
.feat .get { margin-top: auto; }

.extra h3 { margin-top: 10px; }

/* «уже установлено» и плашка о готовой ссылке */
.close-link { text-align: center; margin-top: 6px; }
.close-link .btn-text { color: var(--muted); font-weight: 600; font-size: 13.5px; }
.close-link .btn-text:hover { color: var(--text); }
.ready-toast { position: fixed; left: 50%; bottom: 20px; z-index: 40; transform: translateX(-50%); width: min(520px, calc(100vw - 24px)); display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 12px; border-radius: 18px; background: rgba(24, 24, 30, .97); border: 1px solid color-mix(in srgb, var(--a1) 35%, transparent); box-shadow: 0 20px 50px -15px rgba(0, 0, 0, .8); animation: toast-in .5s var(--spring); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 30px); } }
.ready-toast img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); }
.rt-text { flex: 1; min-width: 0; display: grid; }
.rt-text b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-text span { font-size: 12.5px; color: var(--muted); }
.rt-x { width: 32px; height: 32px; flex: none; border-radius: 50%; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; }
.rt-x:hover { background: var(--surface-2); color: var(--text); }

/* прервать установку / конфликт с текущей */
.cancel-box { text-align: center; margin-top: 10px; }
.cancel-box .btn-text { color: var(--muted); font-weight: 600; }
.cancel-box .btn-text:hover { color: #ff8a95; background: rgba(255, 93, 108, .08); }
.job-conflict { margin-top: 18px; animation: fade-down .4s var(--ease); }
.jc-now { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--surface); border: 1px solid color-mix(in srgb, var(--a1) 30%, transparent); }
.jc-now img { width: 44px; height: 44px; border-radius: 11px; object-fit: cover; background: var(--surface-2); flex: none; }
.jc-now small { display: block; font-size: 12.5px; color: var(--muted); }
.jc-now b { font-size: 15.5px; }
.jc-now::after { content: ""; margin-left: auto; width: 18px; height: 18px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--a1) 30%, transparent); border-top-color: var(--a1); animation: rot .8s linear infinite; flex: none; }
.job-conflict .actions { flex-wrap: wrap; }
.job-conflict .btn-primary { white-space: normal; text-align: center; }

/* что происходит на iPhone + подсказки, если установка не пошла */
.job-device { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; padding: 10px 14px; border-radius: 14px; font-size: 14px; font-weight: 600; background: var(--surface); border: 1px solid var(--border); animation: fade-down .4s var(--ease); }
.job-device .jd-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.job-device.run { color: var(--text); border-color: color-mix(in srgb, var(--a1) 35%, transparent); }
.job-device.run .jd-dot { background: var(--a1); animation: ping-c 1.2s infinite; }
.job-device.ok { color: var(--ok); border-color: rgba(61, 220, 132, .35); background: rgba(61, 220, 132, .07); }
.job-device.ok .jd-dot { background: var(--ok); }
.job-help { margin-top: 16px; padding: 14px 16px; border-radius: 16px; text-align: left; font-size: 14px; background: rgba(255, 181, 71, .07); border: 1px solid rgba(255, 181, 71, .28); animation: fade-down .45s var(--ease); }
.job-help > b { display: block; color: #ffd59a; margin-bottom: 8px; }
.job-help ul { margin: 0 0 4px; padding-left: 18px; color: #d7d8e0; }
.job-help li { margin: 6px 0; line-height: 1.4; }
.job-help .btn { margin-top: 8px; }
@keyframes ping-c { 50% { opacity: .3; } }
@keyframes fade-down { from { opacity: 0; transform: translateY(-6px); } }
.rows-one { grid-template-columns: minmax(0, 560px); }
.rows-one .app-row { background: var(--surface); border-color: var(--border); padding: 14px 16px 14px 14px; }
.rows-one .app-row-icon { width: 64px; height: 64px; border-radius: 16px; }
.rows-one .app-row-meta b { font-size: 17px; }
.app-row.skeleton { cursor: default; }
.app-row.skeleton .app-row-icon, .app-row.skeleton b, .app-row.skeleton small { background: linear-gradient(90deg, var(--surface-2) 25%, rgba(255, 255, 255, .1) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: 8px; }
.app-row.skeleton b { display: block; width: 160px; height: 14px; }
.app-row.skeleton small { display: block; width: 110px; height: 11px; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 860px) {
  .cab-head { grid-template-columns: 1fr; align-items: start; }
  .cab-connect { max-width: none; }
}
@media (max-width: 560px) {
  .cab-head { padding-top: 22px; }
  .cab-bar { margin: 0 -16px; padding: 8px 16px 0; top: 57px; }
  .cab-bar-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .cab-bar .tabs { display: flex; }
  .cab-connect { flex-wrap: wrap; }
  .cab-connect > .btn { width: 100%; }
  .cab-connect-btns { width: 100%; }
  .cab-connect-btns .btn { flex: 1; }
  .cab-apple { max-width: none; justify-items: stretch; }
  .cab-hint { text-align: left; }
  .cab-me .btn-sm { padding: 8px 10px; font-size: 13px; white-space: nowrap; }
  .stepper li { font-size: 12px; }
  .feat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .feat-grid.scroller { grid-auto-columns: 112px; }
  .scroller-wrap { margin: 0 -16px; }
  .sc-btn { display: none; }
  .feat { padding: 14px 6px 10px; border-radius: 18px; }
  .feat-icon { width: 54px; height: 54px; border-radius: 14px; }
  .feat b { font-size: 12.5px; }
  .feat small { display: none; }
  .feat .get { padding: 5px 10px; font-size: 12px; margin-top: 8px; }
  .rows { grid-template-columns: 1fr; gap: 2px; }
  .app-row { padding: 8px 4px; }
}

/* --- баланс и оплата --- */
.bal { display: inline-flex; align-items: center; gap: 10px; margin-top: 12px; padding: 6px 6px 6px 12px; border-radius: 999px; font-size: 14px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); }
.bal b { color: var(--text); font-size: 15px; }
.bal-ico { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; color: #fff; background: var(--grad); }
.buy-sheet { max-width: 480px; }
.packs { display: grid; gap: 8px; margin: 16px 0 4px; }
.pack { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; cursor: pointer; background: var(--surface); border: 1.5px solid var(--border); transition: border-color .2s, background .2s, transform .2s var(--ease); }
.pack:hover { border-color: var(--border-2); }
.pack.on { border-color: var(--a1); background: color-mix(in srgb, var(--a1) 9%, transparent); }
.pack input { position: absolute; opacity: 0; pointer-events: none; }
.pack-n { width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 16px; background: var(--surface-2); transition: background .2s, color .2s; }
.pack.on .pack-n { background: var(--grad); color: #fff; }
.pack-t { flex: 1; min-width: 0; display: grid; }
.pack-t b { font-size: 15px; }
.pack-t small { font-size: 12.5px; color: var(--muted); }
.pack-p { font-size: 18px; font-weight: 800; white-space: nowrap; }
.pack-badge { position: absolute; top: -9px; right: 14px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; color: #fff; background: var(--grad); }
.buy-sheet .btn-block { margin-top: 14px; }
.pay-state { width: 72px; height: 72px; margin: 4px auto 14px; border-radius: 50%; display: grid; place-items: center; font-size: 34px; font-weight: 800; animation: pop-in .45s var(--spring); }
.pay-state.wait { background: var(--surface-2); }
.pay-state.ok { color: #062a14; background: var(--ok); box-shadow: 0 10px 30px -8px rgba(61, 220, 132, .6); }
.pay-state.bad { color: #fff; background: var(--danger); }
.pay-spin { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--border-2); border-top-color: var(--a1); animation: rot .8s linear infinite; }

/* переключение вкладок: проявление блока; строки истории анимируются только при первом показе */
.view-in { animation: view-in .28s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }
.hist-list.no-anim .hist-row { animation: none; }

/* шаги пути к установке в окнах */
.flow { display: flex; gap: 6px; margin: 2px 0 14px; }
.flow span { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 11.5px; color: var(--dim); min-width: 0; white-space: nowrap; }
.flow span::before { content: ''; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .1); }
.flow .done::before, .flow .cur::before { background: linear-gradient(90deg, var(--a1), var(--a2)); }
.flow .done { color: var(--muted); }
.flow .cur { color: var(--text); font-weight: 600; }

/* проверка до установки */
.precheck { margin-top: 16px; padding: 16px; border-radius: 16px; background: rgba(251, 138, 92, .08); border: 1px solid rgba(251, 138, 92, .3); text-align: left; }
.precheck b { display: block; font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }
.precheck p { margin: 8px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.precheck .actions { margin-top: 14px; flex-wrap: wrap; }
.precheck .actions .btn { flex: 1 1 auto; }

/* не подходит версия iOS / не Safari */
.job-oswarn { display: grid; gap: 6px; margin-bottom: 12px; padding: 12px 14px; border-radius: 14px; background: rgba(244, 63, 94, .1); border: 1px solid rgba(244, 63, 94, .35); text-align: left; font-size: 13px; color: var(--muted); }
.job-oswarn b { color: var(--text); font-size: 14px; }
.job-oswarn .btn { justify-self: start; }
.job-safari { margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; background: rgba(251, 138, 92, .1); border: 1px solid rgba(251, 138, 92, .3); font-size: 13px; color: var(--muted); text-align: left; }
.job-safari b { color: var(--text); }
#jobDemo .iosd { max-width: 380px; margin: 16px auto 8px; padding: 14px; border-radius: 18px; background: rgba(255, 255, 255, .03); border: 1px solid var(--border); }
#jobDemo .iosd-steps { text-align: left; }

/* открыть на iPhone */
.handoff-sheet { text-align: center; max-width: 400px; }
.handoff-sheet .qr { margin: 14px 0 6px; }

/* гостю: «Войти» и «Регистрация» помещаются и на 320 px */
@media (max-width: 360px) { #cabGuest .cab-connect-btns .btn { padding-left: 10px; padding-right: 10px; min-width: 0; } }

/* шаг «код из письма» */
.auth-code .callout { margin: 0 0 12px; }
.auth-code input#authCode { font-size: 26px; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.auth-code-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 10px; }
.auth-code-links .btn-text:disabled { opacity: .5; cursor: default; }
.auth-code input#authCode::placeholder { letter-spacing: normal; font-size: 17px; }

.auth-forgot { display: flex; justify-content: flex-end; margin: -4px 0 8px; }
.auth-forgot .btn-text { font-size: 13px; }
