/* Лига кубиков — дизайн-система «Инструкция» */
:root{
	--bg:#eef2f5; --panel:#ffffff; --navy:#16324f; --muted:#5b6b7c;
	--line:#c9d4dd; --blue:#0f5bb5; --yellow:#f2c200; --ok:#1e7a46;
	--mono:"IBM Plex Mono",ui-monospace,Consolas,monospace;
	--sans:"IBM Plex Sans",system-ui,"Segoe UI",sans-serif;
}
*{ box-sizing:border-box; }
body{ margin:0; background:var(--bg); color:var(--navy); font-family:var(--sans); font-size:15px; line-height:1.5; }
a{ color:var(--blue); }
img{ max-width:100%; }
.wrap{ max-width:1160px; margin:0 auto; padding:0 24px; }

/* studs-линейка */
.studs{ height:14px; background-image:radial-gradient(circle at 7px 7px, #c9d4dd 3.2px, transparent 3.7px); background-size:26px 14px; background-repeat:repeat-x; }

/* шапка */
.site-head{ border-bottom:2px solid var(--navy); background:var(--bg); }
.head-in{ display:flex; align-items:center; gap:16px; padding:14px 24px; }
.brand{ font-family:var(--mono); font-weight:600; font-size:17px; letter-spacing:.02em; color:var(--navy); text-decoration:none; white-space:nowrap; }
.brand span{ background:var(--yellow); padding:1px 7px; border-radius:3px; }
.site-nav{ display:flex; gap:4px; font-family:var(--mono); font-size:12.5px; flex:1; }
.site-nav a{ color:var(--navy); text-decoration:none; padding:8px 12px; border-radius:4px; white-space:nowrap; }
.site-nav a:hover{ background:#e2e9ef; }
.site-nav a.on{ background:var(--navy); color:#fff; }
.head-search{ display:flex; margin:0; }
.head-search .search{ margin:0; width:230px; height:38px; }
.cart{ display:inline-flex; align-items:center; height:38px; font-family:var(--mono); font-size:12.5px; background:var(--yellow); color:var(--navy); padding:0 14px; border-radius:4px; font-weight:600; white-space:nowrap; }

@media (max-width:920px){
	.head-in{ flex-wrap:wrap; gap:10px 12px; }
	.brand{ flex:1; }
	.cart{ order:2; }
	.head-search{ order:3; width:100%; }
	.head-search .search{ width:100%; }
	.site-nav{ order:4; width:100%; flex:none; flex-wrap:nowrap; overflow-x:auto; -webkit-overflow-scrolling:touch; scrollbar-width:none; }
	.site-nav::-webkit-scrollbar{ display:none; }
}

/* хлебные крошки */
.crumbs{ font-family:var(--mono); font-size:11.5px; color:var(--muted); padding:18px 24px 6px; overflow-wrap:anywhere; line-height:2; }
.crumbs a{ color:var(--muted); text-decoration:none; }
.crumbs a:hover{ color:var(--blue); }

/* заголовок страницы-инструкции */
.mast{ display:flex; gap:26px; align-items:flex-start; padding:26px 0 20px; border-bottom:1px solid var(--line); flex-wrap:wrap; }
.step{ flex:0 0 auto; width:60px; height:60px; border-radius:50%; background:var(--blue); color:#fff; display:grid; place-items:center; font-family:var(--mono); font-weight:600; font-size:21px; box-shadow:inset 0 -4px 0 rgba(0,0,0,.25); }
.masttxt{ flex:1; min-width:280px; }
.masttxt h1, h1.page-title{ font-size:32px; font-weight:600; margin:2px 0 8px; text-wrap:balance; }
.masttxt p, .lead{ color:var(--muted); font-size:14.5px; max-width:68ch; line-height:1.55; }
.eyebrow{ font-family:var(--mono); font-size:11.5px; letter-spacing:.14em; color:var(--muted); text-transform:uppercase; }

/* панель фильтров */
.tools{ display:flex; flex-wrap:wrap; gap:8px; align-items:flex-start; padding:14px 0; border-bottom:1px solid var(--line); font-family:var(--mono); font-size:12px; }
.tools > .chip{ margin-top:0; }
.chip{ display:inline-block; background:var(--panel); border:1px solid var(--line); border-radius:4px; padding:7px 12px; color:var(--navy); cursor:pointer; text-decoration:none; }
.chip:hover{ border-color:var(--blue); }
.chip.on{ background:var(--blue); border-color:var(--blue); color:#fff; }

/* темы: сворачивающийся список */
.themes-dd{ position:relative; }
.themes-dd summary{ list-style:none; user-select:none; }
.themes-dd summary::-webkit-details-marker{ display:none; }
.themes-toggle::after{ content:'▾'; margin-left:6px; color:var(--muted); }
.themes-dd[open] .themes-toggle::after{ content:'▴'; }
.themes-dd[open] .themes-toggle{ border-color:var(--blue); }
.themes-count{ color:var(--muted); font-size:10.5px; background:#e2e8ee; border-radius:3px; padding:1px 6px; margin-left:6px; }
.themes-dd[open] .themes-toggle{ background:var(--navy); border-color:var(--navy); color:#fff; }
.themes-dd[open] .themes-count{ background:rgba(255,255,255,.18); color:#fff; }
.themes-list{ position:absolute; top:calc(100% + 6px); left:0; z-index:40; width:min(560px, calc(100vw - 48px)); background:var(--panel); border:1px solid var(--line); border-radius:8px; box-shadow:0 10px 28px rgba(22,50,79,.16); padding:10px; display:flex; flex-wrap:wrap; gap:6px; }
.search{ margin-left:auto; font-family:var(--mono); font-size:12.5px; padding:8px 12px; border:1px solid var(--line); border-radius:4px; background:var(--panel); color:var(--navy); width:230px; }
.head-search{ margin-left:auto; }
.head-search .search{ margin-left:0; }

/* живой поиск: выпадающие подсказки */
.search-hints{ position:absolute; top:calc(100% + 6px); right:0; min-width:320px; max-width:92vw; background:var(--panel); border:1px solid var(--line); border-radius:8px; box-shadow:0 10px 28px rgba(22,50,79,.16); overflow:hidden; z-index:50; }
.hint{ display:flex; flex-direction:column; gap:2px; padding:9px 14px; text-decoration:none; border-bottom:1px dashed var(--line); color:var(--navy); background:none; border-left:none; border-right:none; border-top:none; width:100%; text-align:left; cursor:pointer; font:inherit; }
.hint:last-child{ border-bottom:none; }
.hint:hover, .hint.on{ background:#eef4fa; }
.hint-name{ font-size:13.5px; font-weight:600; line-height:1.3; }
.hint-meta{ font-family:var(--mono); font-size:11px; color:var(--muted); }
.hint-empty{ padding:10px 14px 4px; font-family:var(--mono); font-size:11.5px; color:var(--muted); }
.hint-full{ color:var(--blue); font-family:var(--mono); font-size:12px; }
.count{ font-family:var(--mono); font-size:12px; color:var(--muted); padding:12px 2px; }

/* постранично */
.pager{ display:flex; flex-wrap:wrap; gap:8px; align-items:center; padding:6px 0 28px; font-family:var(--mono); font-size:12px; }
.pager-gap{ color:var(--muted); padding:0 2px; }

/* сетка карточек */
.grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:14px; padding-bottom:24px; }
.grid-3{ grid-template-columns:repeat(3,1fr); }
.card{ background:var(--panel); border:1px solid var(--line); border-radius:8px; overflow:hidden; display:flex; flex-direction:column; }
.card:hover{ border-color:var(--blue); }
.pic{ height:170px; display:grid; place-items:center; background:#fff; border-bottom:1px solid var(--line); position:relative; text-decoration:none; }
.pic .fig{ height:118px; width:auto; }
.pic .fig-photo{ max-height:158px; max-width:88%; object-fit:contain; }
.pic .qty{ position:absolute; top:8px; right:8px; background:var(--navy); color:#fff; font-family:var(--mono); font-size:10.5px; padding:2px 7px; border-radius:3px; }
.card .body{ padding:12px 14px 14px; display:flex; flex-direction:column; gap:9px; flex:1; }
.card h3{ font-size:14.5px; font-weight:600; line-height:1.3; min-height:2.6em; margin:0; }
.card h3 a{ color:var(--navy); text-decoration:none; }
.card h3 a:hover{ color:var(--blue); }
.spec{ font-family:var(--mono); font-size:11.5px; display:grid; grid-template-columns:auto 1fr; gap:3px 10px; margin:0; }
.spec dt{ color:var(--muted); }
.spec dd{ margin:0; text-align:right; overflow-wrap:anywhere; }
.card .foot{ margin-top:auto; display:flex; justify-content:space-between; align-items:center; gap:8px; padding-top:10px; border-top:1px dashed var(--line); }
.price{ font-family:var(--mono); font-weight:600; font-size:16px; font-variant-numeric:tabular-nums; }
.price.off{ color:var(--muted); }
.buy{ font:600 11.5px var(--mono); background:var(--yellow); color:var(--navy); border:none; border-radius:4px; padding:8px 12px; cursor:pointer; box-shadow:inset 0 -2px 0 rgba(0,0,0,.18); text-decoration:none; }
.buy:hover{ filter:brightness(.96); }
.buy.off{ background:#e2e8ee; color:var(--muted); box-shadow:none; cursor:default; }

/* карточка без наличия: ч/б фото + жёлтая плашка; при наведении фото «оживает» */
.card.oos .pic .fig-photo{ filter:grayscale(1); opacity:.65; transition:filter .18s, opacity .18s; }
.card.oos .pic .fig{ opacity:.45; transition:opacity .18s; }
.card.oos:hover .pic .fig-photo{ filter:none; opacity:1; }
.card.oos:hover .pic .fig{ opacity:.8; }
.oos-tag{ position:absolute; top:8px; left:8px; background:var(--yellow); color:var(--navy); font:600 10px var(--mono); letter-spacing:.05em; padding:3px 7px; border-radius:3px; }
.card.oos h3 a{ color:var(--muted); }
.card.oos:hover h3 a{ color:var(--navy); }

/* разделитель «далее без наличия» в сетке каталога */
.grid-sep{ grid-column:1/-1; font:600 11.5px var(--mono); letter-spacing:.08em; text-transform:uppercase; color:var(--muted); border-top:2px solid var(--line); padding-top:12px; margin-top:4px; }

/* страница персонажа/версии */
.detail{ display:grid; grid-template-columns:300px 1fr; gap:26px; padding:24px 0; align-items:start; }
.detail > *{ min-width:0; }
.table-scroll{ overflow-x:auto; -webkit-overflow-scrolling:touch; }
.table-scroll .offers{ min-width:560px; }
.detail .shot{ background:#fff; border:1px solid var(--line); border-radius:8px; padding:18px; display:grid; place-items:center; min-height:260px; }
.detail .shot .fig{ height:200px; width:auto; }
.detail .shot .fig-photo{ max-height:320px; max-width:100%; object-fit:contain; }
.block{ background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:16px 18px; margin-bottom:16px; }
.block h2{ font-size:16px; font-weight:600; margin:0 0 10px; padding-bottom:8px; border-bottom:1px solid var(--line); }
.block h2 .tag{ font-family:var(--mono); font-size:11px; color:var(--muted); font-weight:400; margin-left:8px; }
.prose{ font-size:14.5px; line-height:1.6; max-width:72ch; }
.prose p{ margin:.4em 0 .9em; }
.prose a{ color:var(--navy); text-decoration:underline; text-decoration-color:var(--yellow); text-decoration-thickness:2px; text-underline-offset:3px; font-weight:500; }
.prose a:hover{ background:var(--yellow); text-decoration-color:transparent; }

/* таблица экземпляров */
table.offers{ width:100%; border-collapse:collapse; font-size:13.5px; }
table.offers th{ font-family:var(--mono); font-size:11px; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); text-align:left; padding:6px 10px; border-bottom:2px solid var(--navy); }
table.offers td{ padding:8px 10px; border-bottom:1px solid var(--line); vertical-align:middle; }
table.offers tr.archived td{ color:var(--muted); }
.badge{ font-family:var(--mono); font-size:10.5px; padding:2px 8px; border-radius:3px; white-space:nowrap; }
.badge.n{ background:var(--yellow); color:var(--navy); }
.badge.u{ background:#e2e8ee; color:var(--navy); }
.badge.ok{ background:#e1f2e8; color:var(--ok); }
.badge.res{ background:#fdf3d0; color:#8a6a00; }
.badge.sold{ background:#efe6e2; color:#8a4b2d; }
.badge.arch{ background:#eceff2; color:var(--muted); }

/* таймлайн версий персонажа */
.timeline{ list-style:none; margin:0; padding:0; }
.timeline li{ display:flex; flex-wrap:wrap; gap:4px 14px; align-items:baseline; padding:8px 0; border-bottom:1px dashed var(--line); }
.timeline li > a{ min-width:0; overflow-wrap:anywhere; }
.timeline .yr{ font-family:var(--mono); font-weight:600; flex:0 0 52px; }
.timeline .art{ font-family:var(--mono); font-size:11.5px; color:var(--muted); }
.timeline .st{ margin-left:auto; font-family:var(--mono); font-size:11px; }
.timeline .st.ok{ color:var(--ok); }
.timeline .st.off{ color:var(--muted); }

/* формы */
.form-row{ display:flex; flex-wrap:wrap; gap:10px; align-items:center; }
input[type=text],input[type=search],select{ font:inherit; font-size:13.5px; padding:8px 12px; border:1px solid var(--line); border-radius:4px; background:var(--panel); color:var(--navy); }

/* списки-стабы */
.index-list{ list-style:none; margin:0; padding:0; }
.index-list li{ padding:9px 2px; border-bottom:1px dashed var(--line); display:flex; flex-wrap:wrap; gap:2px 12px; align-items:baseline; }
.index-list li > a{ min-width:0; overflow-wrap:anywhere; }
.index-list .mono{ font-family:var(--mono); font-size:11.5px; color:var(--muted); margin-left:auto; }

/* главная: две колонки → одна на мобильном */
.home-grid{ display:grid; grid-template-columns:1fr 1fr; gap:26px; padding:24px 0; align-items:start; }
.home-grid > *{ min-width:0; }

/* пустое состояние */
.empty{ border:1px dashed var(--line); border-radius:8px; padding:28px; text-align:center; color:var(--muted); font-family:var(--mono); font-size:13px; background:var(--panel); }

/* подвал */
.site-foot{ margin-top:48px; border-top:2px solid var(--navy); }
.foot-in{ display:flex; justify-content:space-between; gap:16px; flex-wrap:wrap; padding:16px 24px 28px; font-family:var(--mono); font-size:11.5px; color:var(--muted); }

@media (max-width:980px){ .grid, .grid-3{ grid-template-columns:repeat(2,1fr); } .detail{ grid-template-columns:1fr; } }
@media (max-width:760px){ .home-grid{ grid-template-columns:1fr; } }
@media (max-width:560px){
	.grid, .grid-3{ grid-template-columns:1fr; }
	.search{ margin-left:0; width:100%; }
	.masttxt h1{ font-size:24px; }
	.wrap{ padding:0 14px; }
	.crumbs{ padding:14px 14px 4px; }
	.head-in{ padding:12px 14px; }
	.search-hints{ left:0; right:0; min-width:0; }
	.tools .search-form{ width:100%; margin-left:0 !important; }

	/* экземпляры: таблица → карточки */
	.table-scroll{ overflow:visible; }
	.table-scroll .offers{ min-width:0; }
	table.offers tr:first-child{ display:none; } /* шапка колонок не нужна в карточном виде */
	table.offers, table.offers tbody, table.offers tr, table.offers td{ display:block; }
	table.offers tr{ display:flex; flex-wrap:wrap; gap:6px 10px; align-items:center; border:1px solid var(--line); border-radius:8px; padding:10px 12px; margin-bottom:10px; }
	table.offers td{ border:none; padding:0; }
	table.offers td:nth-child(3){ width:100%; order:4; color:var(--muted); font-size:12.5px; } /* дефекты */
	table.offers td:nth-child(4){ margin-left:auto; } /* цена */
	table.offers td:nth-child(5){ width:100%; order:5; text-align:left !important; } /* кнопка */
	table.offers td:nth-child(5) .buy{ display:block; text-align:center; }
	table.offers td:nth-child(5) .lot-actions{ display:grid; grid-template-columns:1fr 1fr; align-items:center; }
	table.offers td:nth-child(5) .js-cart{ display:contents; }
}

/* ---------- корзина (сессия 4) ---------- */
a.cart{ text-decoration:none; }
.buy.in-cart{ background:#e1f2e8; color:var(--ok); box-shadow:none; }
.buy.ghost{ background:transparent; border:1px solid var(--line); box-shadow:none; color:var(--navy); }
.buy:disabled{ opacity:.6; cursor:wait; }
form.js-cart{ display:inline; }
/* действия лота в таблице экземпляров: корзина НАД ссылкой на лот, одинаковая ширина */
.lot-actions{ display:flex; flex-direction:column; gap:6px; align-items:stretch; min-width:132px; }
.lot-actions .js-cart{ display:contents; }
.lot-actions .buy{ display:block; width:100%; text-align:center; white-space:nowrap; }

.cart-layout{ display:grid; grid-template-columns:1fr 280px; gap:26px; padding:24px 0; align-items:start; }
.cart-layout > *{ min-width:0; }
.cart-total{ position:sticky; top:16px; }
.cart-total .meta{ font-family:var(--mono); font-size:11.5px; color:var(--muted); }
.cart-grand{ font-size:22px; }

.cart-row{ display:grid; grid-template-columns:64px minmax(0,1fr) auto auto auto auto; gap:8px 16px; align-items:center; padding:12px 0; border-bottom:1px solid var(--line); }
.cart-row:last-child{ border-bottom:none; }
.cart-row .thumb{ width:64px; height:64px; background:#fff; border:1px solid var(--line); border-radius:6px; display:grid; place-items:center; }
.cart-row .thumb img{ max-width:56px; max-height:56px; object-fit:contain; }
.cart-row .thumb .fig{ height:52px; width:auto; }
.cart-row .info{ min-width:0; font-size:13.5px; line-height:1.45; overflow-wrap:anywhere; }
.cart-row .meta{ font-family:var(--mono); font-size:11px; color:var(--muted); margin-top:3px; }
.cart-row .defects{ font-size:12px; color:#8a4b2d; margin-top:3px; }
.cart-row .cell{ font-family:var(--mono); font-size:13px; white-space:nowrap; }
.cart-row .c-sum{ font-weight:600; font-size:15px; font-variant-numeric:tabular-nums; }
.cart-row .c-off{ font-size:11px; color:var(--muted); }
.cart-row.off .info, .cart-row.off .thumb{ opacity:.55; }
.cart-row.off .info a{ text-decoration:line-through; }
.cart-row.off .c-off{ grid-column:3/6; }
.qty-sel{ font-family:var(--mono); font-size:13px; padding:6px 8px; }
.rm-btn{ background:none; border:none; color:var(--muted); cursor:pointer; font-size:14px; padding:6px; border-radius:4px; }
.rm-btn:hover{ color:#a63a2b; background:#efe6e2; }

.cart-toast{ position:fixed; left:50%; bottom:26px; transform:translateX(-50%); background:var(--navy); color:#fff; font:600 12.5px var(--mono); padding:10px 16px; border-radius:6px; box-shadow:0 10px 28px rgba(22,50,79,.3); z-index:90; opacity:0; pointer-events:none; transition:opacity .2s; max-width:92vw; }
.cart-toast.show{ opacity:1; }

@media (max-width:980px){ .cart-layout{ grid-template-columns:1fr; } .cart-total{ position:static; } }
@media (max-width:560px){
	.cart-row{ grid-template-columns:56px 1fr auto auto; border:1px solid var(--line); border-radius:8px; padding:10px 12px; margin-bottom:10px; }
	.cart-row:last-child{ margin-bottom:0; }
	.cart-row .thumb{ width:56px; height:56px; grid-row:1/3; }
	.cart-row .info{ grid-column:2/4; }
	.cart-row .c-rm{ grid-column:4; grid-row:1; justify-self:end; align-self:start; }
	.cart-row .c-price{ grid-column:2; grid-row:2; }
	.cart-row .c-qty{ grid-column:3; grid-row:2; justify-self:end; }
	.cart-row .c-sum{ grid-column:4; grid-row:2; justify-self:end; align-self:end; }
	.cart-row.off .c-off{ grid-column:2/5; grid-row:2; }
}
