:root {
  --bg: #f5f5f7; --surface: #fff; --surface2: #f5f5f7;
  --text: #1d1d1f; --muted: #86868b; --border: #e5e5e7; --border2: #d2d2d7;
  --accent: #0071e3; --price: #c7392f; --buy: #ff6900;
  --shadow: 0 1px 3px rgba(0,0,0,.06); --shadow-hover: 0 6px 16px rgba(0,0,0,.1);
  --skeleton-1: #ececef; --skeleton-2: #f7f7f9;
  --ok: #2bb673;
}
[data-theme="dark"] {
  --bg: #1a1a1c; --surface: #28282b; --surface2: #1f1f22;
  --text: #f2f2f4; --muted: #909094; --border: #3a3a3d; --border2: #4a4a4d;
  --accent: #2596ff; --price: #ff7a6e; --buy: #ff8c33;
  --shadow: 0 1px 3px rgba(0,0,0,.4); --shadow-hover: 0 6px 16px rgba(0,0,0,.5);
  --skeleton-1: #2a2a2d; --skeleton-2: #34343a;
  --ok: #4cc88a;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); transition: background .15s, color .15s; }

header { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 20px; box-shadow: var(--shadow); }
.bar { max-width: 1600px; margin: 0 auto; }

.brand-row { display: flex; gap: 16px; align-items: center; }
.brand { display: inline-flex; gap: 8px; align-items: center; text-decoration: none; color: var(--accent); }
.brand:hover { filter: brightness(1.08); }
.brand .logo-svg { display: block; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; gap: 1px; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.brand-sub { font-size: 10px; font-weight: 500; color: var(--muted); letter-spacing: .1px; }
.topnav { display: flex; gap: 6px; }
.topnav a { padding: 6px 12px; font-size: 13px; color: var(--muted); text-decoration: none; border-radius: 6px; transition: color .15s, background .15s; position: relative; }
.topnav a:hover { color: var(--text); background: var(--surface2); }
.topnav a.active { color: var(--accent); background: var(--surface2); }
.topnav .badge { display: inline-block; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 9px; margin-left: 4px; vertical-align: 2px; }

.search-toggle { display: flex; align-items: center; gap: 4px; }
.search-toggle input[type=text] { width: 0; padding: 0; border: 1px solid transparent; border-radius: 8px; font-size: 14px; background: var(--surface); color: var(--text); opacity: 0; pointer-events: none; transition: width .2s ease, opacity .15s ease, padding .2s ease, border-color .15s ease; }
.search-toggle.open input[type=text] { width: 240px; padding: 8px 12px; opacity: 1; pointer-events: auto; border-color: var(--border2); }
.search-toggle.open input[type=text]:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.search-toggle.open #searchBtn { background: var(--accent); color: #fff; border-color: var(--accent); }

.user-area { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }
.user-area a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 6px; }
.user-area a:hover { color: var(--text); background: var(--surface2); }
.user-area a.cta { background: var(--accent); color: #fff; }
.user-area a.cta:hover { color: #fff; filter: brightness(1.08); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; padding: 4px 20px 20px; max-width: 1600px; margin: 0 auto; }
.card { background: var(--surface); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; display: flex; flex-direction: column; position: relative; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.card .img { aspect-ratio: 1; position: relative; overflow: hidden; cursor: zoom-in; background: linear-gradient(110deg, var(--skeleton-1) 30%, var(--skeleton-2) 50%, var(--skeleton-1) 70%); background-size: 220% 100%; animation: skeleton 1.4s linear infinite; }
.card .img.loaded, .card .img.empty { animation: none; background: var(--surface2); }
.card .img img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .25s; }
.card .img img.loaded { opacity: 1; }
.card .no-image { width: 100%; height: 100%; display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); text-align: center; padding: 12px; }
.card .no-image::before { content: "🖼️"; font-size: 32px; opacity: .35; }
@keyframes skeleton { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.card .plat { position: absolute; top: 6px; left: 6px; color: #fff; font-size: 10px; font-weight: 700; padding: 3px 7px; border-radius: 4px; text-transform: uppercase; letter-spacing: .5px; box-shadow: 0 1px 2px rgba(0,0,0,.3); z-index: 1; }
.card .plat[data-p="1"] { background: #ff5000; }
.card .plat[data-p="2"] { background: #c92e2c; }
.card .plat[data-p="3"] { background: #ff7a00; }
.card .actions .save-rule, .card .actions .save-wish { width: 30px; height: 30px; padding: 0; background: var(--surface2); border: 1px solid var(--border2); border-radius: 6px; color: var(--muted); font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: border-color .15s, color .15s; flex-shrink: 0; line-height: 1; }
.card .actions .save-rule:hover, .card .actions .save-wish:hover { border-color: var(--accent); color: var(--accent); }
.card .actions .save-rule.saved, .card .actions .save-wish.saved { color: var(--ok); border-color: var(--ok); }
.card .body { padding: 10px 12px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.card .title { font-size: 12px; line-height: 1.4; max-height: 2.8em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; }
.card .price { display: flex; align-items: baseline; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.card .price .brl { font-size: 18px; font-weight: 700; color: var(--price); }
.card .price .cny { font-size: 11px; color: var(--muted); }
.card .sku { font-size: 11px; color: var(--muted); max-height: 1.3em; overflow: hidden; }
.card .date { font-size: 10px; color: var(--muted); text-align: center; padding: 2px 0; opacity: .65; letter-spacing: .2px; }
.card .cat-tag { font-size: 10px; color: var(--muted); }
.card .cat-tag a { color: var(--accent); text-decoration: none; }
.card .cat-tag a:hover { text-decoration: underline; }
.card .cat-tag .meta-date { color: var(--muted); opacity: .85; }
.card .actions { display: flex; gap: 10px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); align-items: center; }
.card .actions .primary { flex: 1; text-align: center; background: var(--accent); color: #fff; padding: 7px; border-radius: 6px; font-size: 13px; font-weight: 600; text-decoration: none; transition: filter .15s; }
.card .actions .primary:hover { filter: brightness(1.08); }
.card .actions .source { font-size: 11px; color: var(--muted); text-decoration: none; white-space: nowrap; transition: color .15s; }
.card .actions .source:hover { color: var(--accent); }

#empty { text-align: center; padding: 80px 20px; color: var(--muted); font-size: 16px; }
.load-more-btn { display: block; margin: 16px auto 32px; padding: 12px 28px; background: var(--accent); color: #fff; border: none; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; transition: filter .15s; }
.load-more-btn:hover { filter: brightness(1.08); }
.load-more-btn:disabled { opacity: .65; cursor: wait; }
#status { padding: 8px 20px 4px; text-align: right; color: var(--muted); font-size: 11px; opacity: .55; max-width: 1600px; margin: 0 auto; }
#busy { display: none; padding: 60px 20px; text-align: center; color: var(--muted); font-size: 14px; }
#busy.on { display: block; }

#viewer { position: fixed; inset: 0; background: #000; z-index: 200; display: none; overflow: hidden; touch-action: none; user-select: none; }
#viewer.open { display: block; }
#viewer .stage { position: absolute; inset: 0; cursor: grab; display: flex; align-items: center; justify-content: center; }
#viewer .stage.grabbing { cursor: grabbing; }
#viewer img { max-width: 100%; max-height: 100%; transform-origin: 0 0; will-change: transform; pointer-events: none; }
#viewer .vbtn { position: fixed; top: 16px; background: rgba(255,255,255,.92); border: none; width: 44px; height: 44px; border-radius: 50%; font-size: 20px; cursor: pointer; z-index: 201; display: flex; align-items: center; justify-content: center; }
#viewer .vbtn.close { right: 20px; }
#viewer .vbtn.zin   { right: 132px; }
#viewer .vbtn.zout  { right: 76px; }
#viewer .nav { position: fixed; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.85); border: none; width: 48px; height: 64px; cursor: pointer; z-index: 201; font-size: 28px; display: flex; align-items: center; justify-content: center; }
#viewer .nav.prev { left: 0; border-radius: 0 8px 8px 0; }
#viewer .nav.next { right: 0; border-radius: 8px 0 0 8px; }
#viewer .nav[disabled] { opacity: .25; cursor: default; }
#viewer .info { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); color: #fff; background: rgba(0,0,0,.6); padding: 6px 14px; border-radius: 20px; font-size: 13px; z-index: 201; }
#viewer .vload { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; color: #fff; font-size: 14px; z-index: 202; pointer-events: none; }
#viewer.loading .vload { display: flex; }
#viewer.loading img { opacity: .25; }

#ptr { position: fixed; top: 0; left: 0; right: 0; height: 60px; pointer-events: none; display: flex; align-items: center; justify-content: center; z-index: 50; transform: translateY(-100%); transition: transform .15s; color: var(--muted); font-size: 13px; }
#ptr.show { transform: translateY(0); }
#ptr.spin::before { content: "↻"; display: inline-block; animation: spin 1s linear infinite; margin-right: 8px; font-size: 18px; }
@keyframes spin { to { transform: rotate(360deg); } }

details.more-menu { position: relative; }
details.more-menu summary { cursor: pointer; padding: 4px 8px; list-style: none; color: var(--muted); font-size: 18px; line-height: 1; border-radius: 6px; }
details.more-menu summary::-webkit-details-marker { display: none; }
details.more-menu summary:hover { color: var(--text); background: var(--surface2); }
details.more-menu[open] summary { color: var(--accent); background: var(--surface2); }
details.more-menu .more-menu-content { position: absolute; top: 100%; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.12); padding: 6px; min-width: 180px; z-index: 60; margin-top: 4px; }
details.more-menu .more-menu-content a { display: block; padding: 8px 10px; color: var(--text); text-decoration: none; border-radius: 4px; font-size: 13px; }
details.more-menu .more-menu-content a:hover { background: var(--surface2); color: var(--accent); }

.site-footer { max-width: 1600px; margin: 32px auto 0; padding: 24px 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; text-align: center; }
.site-footer a { color: var(--muted); text-decoration: none; margin: 0 4px; }
.site-footer a:hover { color: var(--accent); }

.page-static { max-width: 760px; margin: 0 auto; padding: 24px 20px 60px; }
.page-static h1 { font-size: 24px; font-weight: 700; margin: 0 0 8px; color: var(--text); }
.page-static .subtitle { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.page-static h2 { font-size: 17px; font-weight: 600; margin: 28px 0 8px; color: var(--text); }
.page-static p, .page-static li { font-size: 14px; line-height: 1.6; color: var(--text); }
.page-static p { margin: 0 0 12px; }
.page-static ul { margin: 0 0 12px; padding-left: 20px; }
.page-static ul li { margin-bottom: 4px; }
.page-static a { color: var(--accent); }
.page-static .alert { padding: 12px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.page-static .alert.ok { background: rgba(43,182,115,.12); color: var(--ok); border: 1px solid rgba(43,182,115,.3); }
.page-static .alert.err { background: rgba(199,57,47,.12); color: var(--price); border: 1px solid rgba(199,57,47,.3); }
.page-static form { display: flex; flex-direction: column; gap: 4px; }
.page-static label { font-size: 12px; color: var(--muted); margin: 12px 0 4px; font-weight: 500; }
.page-static input[type=text], .page-static input[type=email], .page-static textarea { padding: 10px 12px; border: 1px solid var(--border2); border-radius: 8px; font-size: 14px; background: var(--surface); color: var(--text); font-family: inherit; }
.page-static input:focus, .page-static textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.page-static textarea { resize: vertical; min-height: 120px; }
.page-static button.submit { margin-top: 18px; padding: 11px; background: var(--accent); color: #fff; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: filter .15s; align-self: flex-start; padding: 11px 28px; }
.page-static button.submit:hover { filter: brightness(1.08); }

.toast { position: fixed; top: 16px; right: 16px; background: var(--accent); color: #fff; padding: 10px 14px; border-radius: 10px; display: flex; gap: 10px; align-items: center; font-size: 13px; z-index: 300; box-shadow: 0 6px 20px rgba(0,0,0,.25); transform: translateX(calc(100% + 30px)); transition: transform .3s; max-width: calc(100% - 32px); }
.toast.show { transform: translateX(0); }
.toast strong { font-weight: 700; }
.toast .toast-cta { color: #fff; background: rgba(255,255,255,.22); padding: 4px 12px; border-radius: 6px; text-decoration: none; font-weight: 600; transition: background .15s; white-space: nowrap; }
.toast .toast-cta:hover { background: rgba(255,255,255,.34); }
.toast .toast-close { background: none; border: none; color: #fff; font-size: 18px; cursor: pointer; padding: 0 4px; line-height: 1; opacity: .8; }
.toast .toast-close:hover { opacity: 1; }

@keyframes badgePulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,105,0,.45); }
  50%      { transform: scale(1.18); box-shadow: 0 0 0 7px rgba(255,105,0,0); }
}
.topnav .badge.pulse { background: var(--buy); animation: badgePulse 1.8s ease-in-out infinite; }

@media (max-width: 768px) {
  header { padding: 8px 12px; }
  .brand { gap: 6px; }
  .brand .logo-svg { width: 22px; height: 22px; }
  .brand-name { font-size: 15px; }
  .brand-sub { font-size: 9px; }

  header .brand-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
  }
  header .brand-row > .spacer { display: none; }
  header .brand { order: 0; flex: 0 0 auto; min-width: 0; }
  header #toggleFilters,
  header .search-toggle { order: 1; margin-left: auto; }
  header .user-area { order: 2; margin-left: auto; }
  header #toggleFilters ~ .user-area,
  header .search-toggle ~ .user-area { margin-left: 0; }
  header .topnav { order: 3; flex-basis: 100%; }

  header .search-toggle { gap: 2px; }
  header .search-toggle.open input[type=text] { width: 130px; padding: 6px 10px; font-size: 13px; }
  header .user-area { gap: 2px; font-size: 11px; }
  header .user-area > span { display: none; }
  header .user-area a { padding: 4px 6px; font-size: 12px; }
  header .user-area a.cta { padding: 5px 9px; font-size: 12px; }
  header .user-area button.btn.icon,
  header .user-area a.btn.icon,
  header #toggleFilters,
  header .search-toggle #searchBtn,
  header details.more-menu summary { width: 30px; height: 30px; font-size: 13px; padding: 0; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
  header .topnav { display: flex; justify-content: center; gap: 4px; padding-top: 6px; margin-top: 2px; border-top: 1px solid var(--border); }
  header .topnav a { padding: 6px 10px; font-size: 12px; }
  header .topnav .badge { font-size: 9px; padding: 1px 5px; }

  header .root-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin: 0 -12px; padding: 0 12px; }
  header .root-tabs::-webkit-scrollbar { display: none; }
  header .root-tab { white-space: nowrap; flex-shrink: 0; padding: 6px 12px; font-size: 13px; }

  header .sub-chips { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin: 8px -12px 0; padding: 8px 12px 4px; }
  header .sub-chips::-webkit-scrollbar { display: none; }
  header .sub-chip { white-space: nowrap; flex-shrink: 0; padding: 5px 11px; font-size: 12px; }

  header .size-chips { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin: 0 -12px; padding: 8px 12px 4px; }
  header .size-chips::-webkit-scrollbar { display: none; }
  header .size-chip { flex-shrink: 0; }
  header .size-chips .label { flex-shrink: 0; }

  header .bar-filters { gap: 6px; padding-top: 8px; margin-top: 8px; }
  header .bar-filters input[type=text] { min-width: 0; max-width: 100%; flex: 1 1 100%; }
  header .bar-filters select { font-size: 12px; padding: 6px 10px; }
  header .bar-filters label.chk { font-size: 12px; }
  header .bar-filters a.clear-link { font-size: 11px; }

  header .bar-main .count { font-size: 12px; padding: 0 4px; }
  header .bar-main button.btn.icon, header .bar-main a.btn.icon { width: 34px; height: 34px; font-size: 14px; }

  header .timeline-bar { gap: 8px; padding-top: 8px; margin-top: 8px; }
  header .timeline-bar .label { font-size: 11px; }

  header .rules-bar { gap: 6px; padding-top: 8px; margin-top: 8px; margin: 8px -12px 0; padding: 8px 12px 4px; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  header .rules-bar::-webkit-scrollbar { display: none; }
  header .rules-bar .rule-chip, header .rules-bar .add-rule { white-space: nowrap; flex-shrink: 0; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 12px; }
  .card .body { padding: 8px 10px; gap: 4px; }
  .card .title { font-size: 11px; }
  .card .price .brl { font-size: 15px; }
  .card .price .cny { font-size: 10px; }
  .card .actions { gap: 6px; padding-top: 6px; margin-top: 6px; }
  .card .actions .primary { font-size: 12px; padding: 6px; }
  .card .actions .save-rule, .card .actions .save-wish { width: 26px; height: 26px; font-size: 13px; }
  .card .actions .source { font-size: 10px; }

  .day-divider { font-size: 12px; padding: 12px 4px 6px; }
  #status, #empty { padding: 12px 10px; font-size: 12px; }

  #viewer .vbtn { width: 38px; height: 38px; font-size: 18px; top: 12px; }
  #viewer .vbtn.close { right: 12px; }
  #viewer .vbtn.zin   { right: 100px; }
  #viewer .vbtn.zout  { right: 56px; }
  #viewer .nav { width: 36px; height: 50px; font-size: 22px; }
}

@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 10px; }
  .card .price .brl { font-size: 14px; }
  .card .actions .primary { font-size: 11px; padding: 5px; }
}
