:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1c1f24;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #2563eb;
  --accent-soft: #e8efff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.05);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand h1 { margin: 0; font-size: 18px; font-weight: 650; }
.count { color: var(--muted); }
.topbar-controls { display: flex; align-items: center; gap: 10px; }
.sort { color: var(--muted); display: flex; align-items: center; gap: 6px; }
select, input[type=search], input[type=text] {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
}
.btn {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); cursor: pointer;
}
.btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn:disabled { opacity: .4; cursor: default; }
.only-mobile { display: none; }

.layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 0; min-height: calc(100vh - 53px); }

.filters {
  position: sticky; top: 53px; align-self: start;
  height: calc(100vh - 53px); overflow-y: auto;
  padding: 14px 16px 40px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.filter { margin-bottom: 14px; }
.filter > label { display: block; font-weight: 600; margin-bottom: 6px; }
.filter input[type=search] { width: 100%; }
.filter summary { font-weight: 600; cursor: pointer; margin-bottom: 6px; list-style: none; display: flex; align-items: center; }
.filter summary::before { content: "▸"; display: inline-block; width: 14px; color: var(--muted); font-size: 11px; }
.filter[open] summary::before { content: "▾"; }
.filter summary::-webkit-details-marker { display: none; }
.options { display: flex; flex-direction: column; gap: 3px; padding-left: 14px; }
.options label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.options label .n { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.options label.zero { color: var(--muted); }
.options label .swatch { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.range { display: flex; align-items: center; gap: 8px; padding-left: 14px; }
.range select { flex: 1; }
.check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
#eth { margin: 0 0 8px 14px; width: calc(100% - 14px); }

.main { padding: 16px 20px 60px; min-width: 0; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 14px;
}
.card {
  min-width: 0;
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}
.card:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,.09); }
.card .pic { position: relative; aspect-ratio: 1 / 1; background: #eceff3; overflow: hidden; }
.card .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .pic .noimg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  flex-direction: column; color: #9aa3ad; gap: 6px;
}
.card .pic .noimg svg { width: 56px; height: 56px; opacity: .55; }
.card .pic .noimg span { font-size: 12px; }
.card .pic .kind {
  position: absolute; left: 8px; bottom: 8px; padding: 2px 7px; font-size: 11px;
  background: rgba(0,0,0,.55); color: #fff; border-radius: 999px;
}
.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 16%, white); color: color-mix(in srgb, var(--c) 70%, black);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.card h3 { margin: 2px 0 0; font-size: 15px; font-weight: 650; }
.card h3 .alias { font-weight: 400; color: var(--muted); }
.card .stats { margin: 0; color: var(--text); }
.card .eth { margin: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.card .foot a { font-size: 13px; text-decoration: none; }
.card .foot a:hover { text-decoration: underline; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: #f1f3f5; color: var(--muted); border: 1px solid var(--line); }

/* ---- favorite / dislike marks ---- */
.marks { display: inline-flex; gap: 6px; }
.mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.85); color: #6b7280; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.mark svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.mark.favorite:hover, .mark.favorite.on { color: #db2777; }
.mark.dislike:hover, .mark.dislike.on { color: #475569; }
.mark.on svg { fill: currentColor; }
.mark.dislike.on svg path:last-child { fill: none; }
.card .pic .marks { position: absolute; top: 8px; right: 8px; }
.card.disliked { opacity: .55; }
.card.disliked:hover { opacity: 1; }
.detail-head h2 .marks { vertical-align: middle; margin-left: 4px; }
.detail-head h2 .mark { background: var(--bg); box-shadow: none; border: 1px solid var(--line); }
.filter .check + .check { margin-top: 6px; }
#favonly-label .n, #showdis-label .n { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---- account / auth ---- */
.account { display: flex; align-items: center; gap: 8px; }
.user-email { color: var(--muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#auth { max-width: 380px; }
.auth-inner { position: relative; padding: 22px 24px 20px; display: flex; flex-direction: column; gap: 12px; margin: 0; }
.auth-inner h2 { margin: 0; font-size: 20px; padding-right: 30px; }
.auth-sub { margin: -6px 0 0; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.field input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-weight: 400; }
.field input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; padding: 9px 12px; }
.btn.primary:hover { filter: brightness(1.08); }
.auth-msg { margin: 0; padding: 8px 10px; border-radius: 6px; background: var(--accent-soft); color: var(--text); font-size: 13px; }
.auth-msg.error { background: #fde8e8; color: #9f1239; }
.auth-switch { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }
.linklike { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  padding: 10px 16px; border-radius: 8px; background: #1c1f24; color: #fff; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: min(90vw, 480px);
}

.sentinel { height: 1px; }
.empty { padding: 60px 0; text-align: center; color: var(--muted); font-size: 16px; }

/* ---- modal ---- */
dialog { border: 0; border-radius: 14px; padding: 0; max-width: min(1000px, 94vw); width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(15, 18, 24, .55); }
.detail-inner { position: relative; padding: 18px 22px 24px; max-height: 90vh; overflow-y: auto; }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 26px; line-height: 1; color: var(--muted); }
.icon-btn:hover { color: var(--text); }
.close { position: absolute; top: 10px; right: 14px; }
.detail-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding-right: 40px; }
.pos { color: var(--muted); font-size: 13px; }
.detail-body { display: grid; grid-template-columns: 340px 1fr; gap: 24px; }
.detail-body .photo-col img.main { width: 100%; border-radius: 10px; background: #eceff3; display: block; }
.detail-body .photo-col .noimg { aspect-ratio: 1/1; border-radius: 10px; background: #eceff3; display: flex; align-items: center; justify-content: center; color: #9aa3ad; }
.gallery { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.gallery img { width: 62px; height: 62px; object-fit: cover; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
.gallery img.active { border-color: var(--accent); }
.remote { margin-top: 8px; font-size: 13px; }
.remote a { display: inline-block; margin-right: 8px; }
.detail-head h2 { margin: 0 0 2px; font-size: 22px; }
.detail-head h2 .alias { font-weight: 400; color: var(--muted); font-size: 18px; }
.detail-head .sub { color: var(--muted); margin-bottom: 8px; }
.profile-link { display: inline-block; margin: 6px 0 14px; padding: 7px 14px; background: var(--accent); color: #fff; border-radius: 6px; text-decoration: none; font-weight: 600; }
.profile-link:hover { filter: brightness(1.08); }
.profile-note { color: var(--muted); font-size: 13px; margin-left: 8px; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 5px 14px; margin: 0 0 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
dl.facts dd .raw { color: var(--muted); font-size: 12px; margin-left: 6px; }
.desc { margin: 0 0 14px; white-space: pre-wrap; line-height: 1.5; }
h4 { margin: 12px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .topbar { flex-wrap: wrap; padding: 8px 12px; }
  .main { padding: 12px 12px 60px; }
  .filters { position: fixed; left: 0; right: 0; top: 53px; height: auto; max-height: calc(100vh - 53px); z-index: 15; display: none; border-right: 0; border-bottom: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.15); }
  .filters.open { display: block; }
  .only-mobile { display: inline-block; }
  .brand h1 { font-size: 16px; }
  .detail-body { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* ---- public build (no photos) ---- */
body.public .card .body { padding-top: 12px; gap: 5px; }
body.public .card .foot { flex-wrap: wrap; }
body.public .card .foot .marks { position: static; margin-left: auto; }
body.public .detail-body { grid-template-columns: 1fr; }

/* ---- footer / about ---- */
.site-footer { margin-top: 40px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; text-align: center; }
.auth-consent { margin: 0 0 10px; font-size: 12px; color: var(--muted); }
.about { max-width: 720px; margin: 0 auto; padding: 24px 20px 60px; line-height: 1.55; }
.about h1 { font-size: 24px; margin: 0 0 6px; }
.about h2 { font-size: 16px; margin: 26px 0 6px; }
.about ul { padding-left: 20px; }
.about .back { display: inline-block; margin-bottom: 18px; }
