:root {
  --bg: #f4f4f1;
  --panel: #ffffff;
  --line: #e4e4df;
  --line-strong: #cfcfc8;
  --text: #1c1b22;
  --muted: #6c6c64;
  --accent: #7c3aed;
  --accent-soft: #efe8fd;
  --money: #15803d;
  --money-soft: #e8f6ec;
  --danger: #b42318;
  --danger-soft: #fdeeed;
  --warn: #8a6d1f;
  --warn-soft: #fdf6e3;
  --bar: #1c1b22;
  --bar-text: #e9e9ef;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 16px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  font-weight: 600;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #6d28d9; }
.btn-block { width: 100%; }
a.btn { text-decoration: none; }

.icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg); }

.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 4px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bar);
  color: var(--bar-text);
}
.brand { display: flex; align-items: center; gap: 8px; color: inherit; font-size: 17px; font-weight: 700; min-width: 0; }
.brand span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark { color: #c4b5fd; }
.cart-btn { flex: none; background: transparent; color: inherit; border-color: #55535f; }
.badge {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}

.page { max-width: 1120px; margin: 0 auto; padding: 16px 16px 48px; }

.intro { margin-bottom: 14px; }
.intro p { font-size: 17px; }
.notes { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 6px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 14px; }

.filters { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
.filters input, .filters select {
  width: 100%;
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
}

.chips { display: flex; gap: 6px; padding: 10px 0 2px; overflow-x: auto; }
.chips:empty { display: none; }
.chip {
  flex: none;
  padding: 5px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.lote { margin-top: 24px; }
.lote-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin-bottom: 10px; }
.lote-head h2 { font-size: 22px; line-height: 1.2; }
.lote-head h2 a { color: inherit; }
.lote-head p { flex-basis: 100%; color: var(--muted); }
.kind { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; flex-basis: 100%; }
.count { color: var(--muted); font-size: 14px; }

.combo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid #d9c9fb;
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.combo-label { font-size: 13px; font-weight: 600; color: #5b21b6; }
.combo-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.combo-price strong { font-size: 24px; color: var(--money); }
.combo-price s { color: var(--muted); }
.save { font-size: 13px; color: var(--money); font-weight: 600; }
.combo .btn { flex: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }

.tile {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.tile-img { display: block; padding: 8px 8px 0; border: 0; background: none; cursor: zoom-in; }
.tile-img img { display: block; width: 100%; height: auto; aspect-ratio: 168 / 246; object-fit: cover; border-radius: 4px; }
.no-img { display: grid; place-items: center; aspect-ratio: 168 / 246; border-radius: 4px; background: var(--bg); color: var(--line-strong); font-size: 32px; }
.tile-body { display: flex; flex: 1; flex-direction: column; gap: 3px; padding: 8px 10px 10px; }
.tile-body h3 { font-size: 14px; line-height: 1.25; overflow-wrap: anywhere; }
.rarity { color: #5b21b6; font-size: 12px; font-weight: 600; }
.facts { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.price { color: var(--money); font-size: 17px; margin-top: auto; padding-top: 4px; }
.btn-add { width: 100%; margin-top: 4px; font-size: 14px; }
.only-combo { margin-top: 4px; padding: 7px 0; color: var(--muted); font-size: 13px; text-align: center; }

.empty { padding: 40px 0; color: var(--muted); text-align: center; }

dialog { color: inherit; }
dialog::backdrop { background: rgba(20, 19, 26, 0.55); }

.sheet {
  width: min(460px, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  background: var(--panel);
}
.sheet[open] { display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 18px; }
.sheet-body { flex: 1; padding: 4px 16px; overflow-y: auto; }
.sheet-foot { display: grid; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.sheet-foot:empty { display: none; }

.line { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.line-main { display: grid; min-width: 0; }
.line-price { min-width: 76px; font-weight: 600; text-align: right; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel);
  cursor: pointer;
}
.stepper button:disabled { opacity: 0.4; cursor: default; }
.total { display: flex; justify-content: space-between; align-items: baseline; }
.total strong { font-size: 22px; color: var(--money); }

.viewer {
  width: min(400px, calc(100vw - 32px));
  padding: 12px;
  border: 0;
  border-radius: var(--radius);
  background: var(--panel);
}
.viewer .icon-btn { position: absolute; top: 16px; right: 16px; background: rgba(255, 255, 255, 0.85); }
.viewer img { display: block; width: 100%; height: auto; border-radius: 6px; }
.viewer-info { display: grid; gap: 2px; padding-top: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 20;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--bar);
  color: var(--bar-text);
  transform: translateX(-50%);
}

@media (max-width: 640px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input { grid-column: 1 / -1; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .combo { flex-direction: column; align-items: stretch; }
  .line { grid-template-columns: 1fr auto; }
  .line-price { grid-column: 2; }
}
