:root {
  --tg-bg: #f3f5fa;
  --tg-card: #ffffff;
  --tg-text: #111319;
  --tg-muted: #6b7280;
  --tg-border: #e5e7eb;
  --tg-primary: #5b6cff;
  --tg-primary2: #8b5cf6;
  --tg-danger: #ff5c8a;
  --tg-top: rgba(255,255,255,.88);
  --tg-side: #ffffff;
  --tg-shadow: 0 10px 30px rgba(15,23,42,.06);
}

html.theme-dark {
  --tg-bg: #0b0f1a;
  --tg-card: #141a2a;
  --tg-text: #eef2ff;
  --tg-muted: #9aa3b2;
  --tg-border: #243049;
  --tg-top: rgba(12,16,28,.92);
  --tg-side: #101626;
  --tg-shadow: 0 12px 32px rgba(0,0,0,.35);
}

.tgks-body {
  background: var(--tg-bg) !important;
  background-image: none !important;
  color: var(--tg-text);
  min-height: 100vh;
  padding-bottom: 72px;
}

.tgks-wrap #page-header,
.tgks-wrap .bg-nav-primary-darker { display: none !important; }

.tgks-topbar {
  position: sticky; top: 0; z-index: 1000;
  background: var(--tg-top);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--tg-border);
}
.tgks-topbar-inner {
  max-width: 1280px; margin: 0 auto;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
}
.tgks-brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--tg-text); text-decoration: none; font-weight: 700;
  min-width: 0;
}
.tgks-logo { width: 28px; height: 28px; border-radius: 8px; object-fit: cover; }
.tgks-shop-name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw;
}
.tgks-search {
  flex: 1; max-width: 420px; display: flex; align-items: center;
  background: var(--tg-card); border: 1px solid var(--tg-border); border-radius: 12px; overflow: hidden;
}
.tgks-search .form-control {
  border: 0; background: transparent; color: var(--tg-text); box-shadow: none !important;
}
.tgks-search-btn {
  border: 0; background: transparent; color: var(--tg-muted); padding: 0 12px; cursor: pointer;
}
.tgks-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.tgks-theme-switch {
  display: inline-flex; border: 1px solid var(--tg-border); border-radius: 999px;
  overflow: hidden; background: var(--tg-card);
}
.tgks-theme-switch button {
  border: 0; background: transparent; color: var(--tg-muted);
  font-size: 12px; padding: 6px 10px; cursor: pointer;
}
.tgks-theme-switch button.is-on,
.tgks-theme-switch button:hover { color: var(--tg-text); background: rgba(91,108,255,.12); }

.tgks-user-btn {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--tg-text); text-decoration: none; padding: 4px 8px; border-radius: 10px;
}
.tgks-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.tgks-level {
  display: inline-block; background: var(--tg-primary); color: #fff;
  font-size: 11px; padding: 1px 6px; border-radius: 6px; margin-right: 4px;
}
.tgks-dropdown {
  background: var(--tg-card) !important; border: 1px solid var(--tg-border) !important;
  box-shadow: var(--tg-shadow);
}

.tgks-main { max-width: 1280px; margin: 0 auto; padding: 18px 16px 24px; }
.tgks-layout {
  display: grid; grid-template-columns: 240px 1fr; gap: 18px; align-items: start;
}
.tgks-sidebar {
  position: sticky; top: 72px;
  background: var(--tg-side); border: 1px solid var(--tg-border);
  border-radius: 16px; box-shadow: var(--tg-shadow); padding: 14px;
}
.tgks-side-title {
  font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--tg-muted); margin-bottom: 10px;
}
.tgks-cat-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 12px; color: var(--tg-text);
  text-decoration: none; margin-bottom: 4px;
}
.tgks-cat-item.is-active {
  background: linear-gradient(90deg, rgba(91,108,255,.16), rgba(139,92,246,.14));
  color: var(--tg-primary); font-weight: 600;
}
.tgks-cat-tree .nav-main,
.tgks-cat-tree ul { list-style: none; margin: 0; padding: 0; }
.tgks-cat-tree a {
  display: block; padding: 8px 12px; border-radius: 10px;
  color: var(--tg-text); text-decoration: none; font-size: 14px;
}
.tgks-cat-tree a:hover { background: rgba(91,108,255,.08); }

.tgks-page-head {
  display: flex; justify-content: space-between; gap: 16px; align-items: end; margin-bottom: 16px;
}
.tgks-kicker { color: var(--tg-muted); font-size: 13px; }
.tgks-h1 { margin: 4px 0; font-size: 28px; font-weight: 800; color: var(--tg-text); }
.tgks-sub { margin: 0; color: var(--tg-muted); }
.tgks-search-mobile { display: none; width: 100%; max-width: none; }

.tgks-card-link { text-decoration: none; color: inherit; display: block; height: 100%; }
.tgks-card {
  height: 100%; background: var(--tg-card); border: 1px solid var(--tg-border);
  border-radius: 16px; overflow: hidden; box-shadow: var(--tg-shadow);
  transition: transform .2s ease, box-shadow .2s ease; position: relative;
  display: flex; flex-direction: column;
}
@media (hover:hover) and (pointer:fine) {
  .tgks-card:hover { transform: translateY(-4px); box-shadow: 0 16px 36px rgba(0,0,0,.12); }
}
.tgks-thumb {
  height: 140px; background-size: cover; background-position: center; background-color: #eef1f7;
}
.tgks-card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; flex: 1; }
.tgks-tags { display: flex; gap: 6px; margin-bottom: 6px; min-height: 20px; }
.tgks-badge {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px;
}
.tgks-badge-warn { background: rgba(255,92,138,.12); color: var(--tg-danger); }
.tgks-title {
  font-weight: 700; font-size: 14px; line-height: 1.4; color: var(--tg-text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.8em; margin-bottom: 8px;
}
.tgks-price { color: var(--tg-danger); font-weight: 800; font-size: 18px; margin-top: auto; }
.tgks-meta {
  display: flex; justify-content: space-between; color: var(--tg-muted);
  font-size: 12px; margin-top: 6px;
}
.tgks-card.is-soldout { filter: grayscale(.9); opacity: .85; }
.tgks-soldout {
  position: absolute; top: 12px; left: -34px; transform: rotate(-45deg);
  background: linear-gradient(90deg, #ff8080, #ff5c8a); color: #fff;
  font-size: 12px; font-weight: 800; padding: 4px 40px;
}
.tgks-empty {
  text-align: center; padding: 48px 16px; color: var(--tg-muted);
  background: var(--tg-card); border: 1px solid var(--tg-border); border-radius: 16px;
}

.tgks-notice-mask {
  position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.tgks-notice-modal {
  width: min(560px, 100%); background: var(--tg-card); color: var(--tg-text);
  border: 1px solid var(--tg-border); border-radius: 18px; box-shadow: var(--tg-shadow); padding: 22px;
}
.tgks-notice-label { font-size: 12px; color: var(--tg-muted); text-transform: uppercase; letter-spacing: .08em; }
.tgks-notice-body { margin: 12px 0 18px; line-height: 1.7; color: var(--tg-muted); max-height: 40vh; overflow: auto; }
.tgks-notice-actions { display: flex; justify-content: flex-end; gap: 10px; }
.tgks-btn-primary, .tgks-btn-ghost {
  border-radius: 10px; padding: 8px 14px; font-size: 13px; cursor: pointer; border: 1px solid transparent;
}
.tgks-btn-primary {
  background: linear-gradient(90deg, var(--tg-primary), var(--tg-primary2)); color: #fff; border: 0;
}
.tgks-btn-ghost { background: transparent; border-color: var(--tg-border); color: var(--tg-text); }

.tgks-bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 999;
  display: none; grid-template-columns: repeat(4, 1fr);
  background: var(--tg-top); border-top: 1px solid var(--tg-border); backdrop-filter: blur(14px);
}
.tgks-bottom-nav a {
  text-align: center; padding: 10px 4px; color: var(--tg-muted); text-decoration: none; font-size: 11px;
  display: flex; flex-direction: column; gap: 2px; align-items: center;
}
.tgks-bottom-nav a.is-active { color: var(--tg-primary); font-weight: 700; }
.tgks-bottom-nav i { font-size: 16px; }

.tgks-footer {
  background: transparent !important; border-top: 1px solid var(--tg-border);
  color: var(--tg-muted); margin-top: 12px;
}
.tgks-footer-inner {
  max-width: 1280px; margin: 0 auto; padding: 16px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px;
}
.tgks-footer a { color: var(--tg-muted); text-decoration: none; }

/* 详情/查询页卡片统一 */
.tgks-body .content .block,
.tgks-body .block.block-rounded {
  background: var(--tg-card) !important;
  border: 1px solid var(--tg-border) !important;
  border-radius: 16px !important;
  box-shadow: var(--tg-shadow);
}
.tgks-body .item-title-content,
.tgks-body .item-controls {
  background: transparent !important;
}

@media (max-width: 991.98px) {
  .tgks-layout { grid-template-columns: 1fr; }
  .tgks-sidebar { position: static; }
  .tgks-page-head { flex-direction: column; align-items: stretch; }
  .tgks-search-mobile { display: flex; }
  .tgks-theme-switch { display: none; }
  .tgks-bottom-nav { display: grid; }
  .tgks-thumb { height: 110px; }
}
/* ===== 分类侧栏 ===== */
.tgks-side-title{
  font-size:11px;letter-spacing:.12em;color:var(--tg-muted);
  margin-bottom:10px;font-weight:700;
}
.tgks-cat-nav{display:flex;flex-direction:column;gap:4px}
.tgks-cat-item{
  display:flex;align-items:center;gap:8px;
  padding:10px 12px;border-radius:12px;
  color:var(--tg-text);text-decoration:none;font-size:14px;
  transition:.15s ease;
}
.tgks-cat-item:hover{background:rgba(91,108,255,.08)}
.tgks-cat-item.active{
  background:linear-gradient(135deg,rgba(91,108,255,.18),rgba(139,92,246,.12));
  color:#5b6cff;font-weight:600;
}
.tgks-cat-item em,.tgks-cat-parent em{
  margin-left:auto;font-style:normal;font-size:12px;color:var(--tg-muted);
}
.tgks-cat-icon{width:18px;height:18px;border-radius:4px;object-fit:cover}
.tgks-cat-parent{
  display:flex;align-items:center;gap:8px;
  padding:10px 12px;font-size:13px;font-weight:600;color:var(--tg-muted);
}
.tgks-cat-children{padding-left:10px;display:flex;flex-direction:column;gap:2px}
.tgks-empty{text-align:center;padding:60px 20px;color:var(--tg-muted)}
.tgks-empty-icon{font-size:40px;margin-bottom:12px;opacity:.5}

/* ===== 商品详情 ===== */
.tgks-item-wrap{max-width:1100px;margin:0 auto;padding:8px 16px 40px}
.tgks-item-back{margin-bottom:14px}
.tgks-back-link{
  color:var(--tg-muted);text-decoration:none;font-size:14px;
}
.tgks-back-link:hover{color:var(--tg-primary)}
.tgks-item-panel{
  background:var(--tg-card);
  border:1px solid var(--tg-border);
  border-radius:20px;
  box-shadow:var(--tg-shadow);
  overflow:hidden;
}
.tgks-item-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:28px;
  padding:24px;
}
@media(max-width:900px){
  .tgks-item-grid{grid-template-columns:1fr}
}
.tgks-item-mainimg{
  border-radius:16px;overflow:hidden;
  background:rgba(0,0,0,.03);
  aspect-ratio:1/1;
  display:flex;align-items:center;justify-content:center;
}
.tgks-item-mainimg img{
  width:100%;height:100%;object-fit:cover;
}
.tgks-item-thumbs{
  display:flex;flex-wrap:wrap;gap:8px;margin-top:12px;
}
.tgks-thumb-btn{
  width:56px;height:56px;border-radius:10px;overflow:hidden;
  border:2px solid transparent;cursor:pointer;display:block;
}
.tgks-thumb-btn img{width:100%;height:100%;object-fit:cover}
.tgks-thumb-btn.image-active{border-color:var(--tg-primary)}

.tgks-item-name{font-size:22px;font-weight:800;margin:0 0 6px;color:var(--tg-text)}
.tgks-item-sold{font-size:13px;color:var(--tg-muted);margin-bottom:12px}
.tgks-item-price{margin-bottom:20px}
.tgks-currency{color:var(--tg-danger);font-weight:700}
.tgks-price-from{font-size:13px;color:var(--tg-muted);margin-left:4px}

.tgks-field{margin-bottom:16px}
.tgks-label{font-size:13px;color:var(--tg-muted);margin-bottom:8px}
.tgks-sku-list{display:flex;flex-wrap:wrap;gap:8px}
.tgks-sku-btn{
  display:inline-flex;align-items:center;gap:6px;
  padding:8px 12px;border-radius:12px;
  border:1px solid var(--tg-border);
  background:var(--tg-card);cursor:pointer;
  font-size:13px;color:var(--tg-text);
}
.tgks-sku-btn.sku-current{
  border-color:var(--tg-primary);
  background:rgba(91,108,255,.1);
  color:#5b6cff;font-weight:600;
}
.tgks-sku-icon{width:22px;height:22px;border-radius:6px;object-fit:cover}

.tgks-qty-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.tgks-qty-input{
  width:100px;padding:10px 12px;border-radius:12px;
  border:1px solid var(--tg-border);background:var(--tg-card);
  color:var(--tg-text);font-size:15px;
}
.tgks-tag{
  font-size:12px;padding:4px 8px;border-radius:8px;
  background:rgba(255,92,138,.12);color:var(--tg-danger);
}
.tgks-stock-badge{
  font-size:12px;padding:4px 10px;border-radius:999px;
}
.tgks-stock-badge.is-ok{background:rgba(34,197,94,.12);color:#16a34a}
.tgks-stock-badge.is-off{background:rgba(148,163,184,.15);color:var(--tg-muted)}

.tgks-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:8px}
.tgks-btn{
  border:none;border-radius:14px;padding:12px 20px;
  font-size:15px;font-weight:700;cursor:pointer;
  display:inline-flex;align-items:center;gap:6px;
}
.tgks-btn-primary{
  background:linear-gradient(135deg,#5b6cff,#8b5cf6);
  color:#fff;box-shadow:0 8px 20px rgba(91,108,255,.35);
}
.tgks-btn-ghost{
  background:transparent;color:var(--tg-text);
  border:1px solid var(--tg-border);
}
.tgks-btn-disabled{background:#e5e7eb;color:#9ca3af;cursor:not-allowed}

.tgks-item-detail{
  border-top:1px solid var(--tg-border);
  padding:20px 24px 28px;
}
.tgks-tabs{margin-bottom:14px}
.tgks-tab{
  border:none;background:transparent;
  font-weight:700;font-size:15px;color:var(--tg-text);
  padding:8px 4px;border-bottom:2px solid var(--tg-primary);
}
.tgks-attr-table{width:100%;margin-bottom:16px;border-collapse:collapse}
.tgks-attr-table td{padding:10px 8px;border-bottom:1px solid var(--tg-border);font-size:14px}
.tgks-attr-k{width:28%;color:var(--tg-muted)}
.tgks-introduce{line-height:1.7;color:var(--tg-text);word-break:break-word}
.tgks-introduce img{max-width:100%;height:auto;border-radius:12px}
/* ========== 强力清理旧背景 / 水印 ========== */
html,
body,
body.tgks-body,
#page-container,
#main-container,
.tgks-wrap,
.tgks-main {
  background: var(--tg-bg) !important;
  background-image: none !important;
  background-color: var(--tg-bg) !important;
}

body.tgks-body {
  background-image: none !important;
  min-height: 100vh;
}

/* 隐藏系统旧导航、旧容器装饰 */
#page-header,
.bg-nav-primary-darker,
.bg-black-10,
.notice-background,
.item-background {
  display: none !important;
}

#page-container.page-header-dark,
#page-container.main-content-boxed {
  background: transparent !important;
  box-shadow: none !important;
}

/* ========== 主布局 ========== */
.tgks-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 16px 80px;
}

.tgks-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  align-items: start;
}

@media (max-width: 991px) {
  .tgks-layout {
    grid-template-columns: 1fr;
  }
}

/* ========== 侧栏 ========== */
.tgks-sidebar {
  background: var(--tg-card);
  border: 1px solid var(--tg-border);
  border-radius: 16px;
  padding: 14px 12px;
  box-shadow: var(--tg-shadow);
  position: sticky;
  top: 72px;
}

.tgks-side-title {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--tg-muted);
  margin: 0 0 10px 4px;
  font-weight: 700;
}

.tgks-cat-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tgks-cat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--tg-text);
  text-decoration: none;
  font-size: 14px;
  transition: 0.15s ease;
}

.tgks-cat-item:hover {
  background: rgba(91, 108, 255, 0.08);
}

.tgks-cat-item.active {
  background: linear-gradient(135deg, rgba(91, 108, 255, 0.18), rgba(139, 92, 246, 0.12));
  color: #5b6cff;
  font-weight: 600;
}

.tgks-cat-item em,
.tgks-cat-parent em {
  margin-left: auto;
  font-style: normal;
  font-size: 12px;
  color: var(--tg-muted);
}

.tgks-cat-icon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.tgks-cat-parent {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--tg-muted);
}

.tgks-cat-children {
  padding-left: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ========== 内容区标题（修正混乱排版） ========== */
.tgks-content {
  min-width: 0;
}

.tgks-page-head {
  margin-bottom: 16px;
}

.tgks-breadcrumb {
  font-size: 12px;
  color: var(--tg-muted);
  margin-bottom: 4px;
}

.tgks-h1 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 800;
  color: var(--tg-text);
  line-height: 1.2;
}

.tgks-sub {
  margin: 0;
  font-size: 13px;
  color: var(--tg-muted);
}

/* ========== 商品卡片 ========== */
.tgks-card {
  display: block;
  background: var(--tg-card);
  border: 1px solid var(--tg-border);
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  height: 100%;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.tgks-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.tgks-thumb {
  height: 140px;
  background-size: cover;
  background-position: center;
  background-color: #eef1f6;
}

.tgks-card-body {
  padding: 12px;
}

.tgks-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--tg-text);
  min-height: 2.5em;
  line-height: 1.35;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tgks-price {
  color: var(--tg-danger);
  font-weight: 800;
  font-size: 18px;
  margin-bottom: 6px;
}

.tgks-meta {
  display: flex;
  justify-content: space-between;
  color: var(--tg-muted);
  font-size: 12px;
}

.tgks-card.is-soldout {
  opacity: 0.55;
}

/* 抵消 OneUI / bootstrap 旧间距干扰 */
#masonry-grid.row {
  margin-left: -8px;
  margin-right: -8px;
}
#masonry-grid > [class*="col-"] {
  padding-left: 8px;
  padding-right: 8px;
  margin-bottom: 16px;
}

.tgks-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--tg-muted);
  background: var(--tg-card);
  border-radius: 16px;
  border: 1px solid var(--tg-border);
}
/* ===== 分类图标强制缩小 ===== */
.tgks-sidebar img,
.tgks-cat-nav img,
.tgks-cat-item img,
.tgks-cat-icon,
.tgks-cat-parent img,
.category-icon {
  width: 18px !important;
  height: 18px !important;
  max-width: 18px !important;
  max-height: 18px !important;
  object-fit: cover !important;
  border-radius: 4px !important;
  flex-shrink: 0 !important;
  display: inline-block !important;
  vertical-align: middle !important;
  background: none !important;
}

/* 防止分类图被当成大背景 */
.tgks-sidebar,
.tgks-cat-nav,
.tgks-cat-item,
.tgks-cat-parent,
.tgks-cat-children {
  background-image: none !important;
}

.tgks-sidebar img {
  position: static !important;
  float: none !important;
}
/* ===== 分类图标强制 18px（最高优先级） ===== */
aside.tgks-sidebar img.tgks-cat-icon,
aside.tgks-sidebar .tgks-cat-item img,
aside.tgks-sidebar .tgks-cat-nav img,
.tgks-layout .tgks-sidebar img {
  width: 18px !important;
  height: 18px !important;
  max-width: 18px !important;
  max-height: 18px !important;
  min-width: 18px !important;
  min-height: 18px !important;
  object-fit: cover !important;
  border-radius: 4px !important;
  flex: 0 0 18px !important;
  display: inline-block !important;
  vertical-align: middle !important;
  margin: 0 !important;
  padding: 0 !important;
  position: static !important;
  float: none !important;
  background: none !important;
}

aside.tgks-sidebar {
  overflow: hidden;
  max-width: 240px;
}

aside.tgks-sidebar .tgks-cat-item {
  overflow: hidden;
}

