:root {
  --bg: #0a0a0a;
  --bg-2: #141414;
  --fg: #f4f4f5;
  --fg-mute: #71717a;
  --accent: #FB0000;       /* matchbox red — точно из фона логотипа */
  --accent-2: #FF3838;     /* hover/secondary — чуть светлее */
  --accent-soft: #2a0808;  /* мягкий красный фон для tinted areas */
  --border: #27272a;
  --grid-gap: 8px;
  --col: 200px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; min-height: 100vh; }
a { color: inherit; text-decoration: none; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: rgba(10,10,10,0.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.logo img { width: 32px; height: 32px; border-radius: 6px; display: block; }
.sort-tabs {
  display: flex; gap: 4px; padding: 2px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-2);
}
.sort-tab {
  padding: 6px 12px; background: transparent; color: var(--fg-mute);
  border: 0; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500;
  white-space: nowrap;
}
.sort-tab:hover { color: var(--fg); }
.sort-tab.active { background: var(--bg); color: var(--accent); }

.search { flex: 1; max-width: 600px; display: flex; gap: 0; }
.search input {
  flex: 1; padding: 9px 14px; border: 1px solid var(--border); border-right: 0;
  background: var(--bg-2); color: var(--fg); border-radius: 8px 0 0 8px;
  font-size: 14px; outline: none;
}
.search input:focus { border-color: var(--accent); }
.search button {
  padding: 0 16px; border: 1px solid var(--accent); background: var(--accent); color: #fff;
  border-radius: 0 8px 8px 0; cursor: pointer; font-weight: 700;
}
.actions { display: flex; gap: 8px; }
.ghost {
  padding: 8px 12px; background: transparent; color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 13px;
}
.ghost:hover { border-color: var(--accent); }

/* Row-based grid: new images always go top-left, older below.
   All images are 1:1 (FLUX 512x512), so square cells with object-fit: cover. */
/* Hall of Fame strip — top-liked enhanced images, single-row horizontal carousel */
.top-strip {
  position: relative;
  margin: var(--grid-gap);
  padding: 0;
}
.top-strip.hidden { display: none; }
.top-carousel {
  display: flex;
  gap: var(--grid-gap);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;       /* Firefox */
  padding: 4px 2px;
  outline: none;
  /* No scroll-snap — мешает trackpad смесь delta */
  /* No scroll-behavior: smooth — interferes с native trackpad inertia */
}
.top-carousel::-webkit-scrollbar { display: none; }
.top-card {
  flex: 0 0 auto;
  width: 240px;                /* desktop: ~2× regular cell (12-col grid ~120px wide) */
  height: 240px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-2);
  position: relative;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: transform .15s ease;
}
.top-card:hover { transform: translateY(-2px); }
.top-card img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.top-card .top-card-likes {
  position: absolute; top: 8px; right: 8px;
  font-size: 14px; font-weight: 700; color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.85), 0 0 6px rgba(0,0,0,0.55);
}
.top-card .top-card-meta {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 6px 10px;
  background: linear-gradient(to top, rgba(0,0,0,0.75), transparent);
  color: #fff; font-size: 12px; font-weight: 500;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
@media (max-width: 800px)  { .top-card { width: 180px; height: 180px; } }
@media (max-width: 520px)  { .top-card { width: 150px; height: 150px; } }

.top-arrow {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  width: 36px; height: 56px;
  border: 1px solid var(--border); border-radius: 8px;
  background: rgba(20,20,20,0.85); color: #fff;
  cursor: pointer; font-size: 26px; font-weight: 700;
  z-index: 5;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s ease, opacity .12s ease;
  backdrop-filter: blur(4px);
}
.top-arrow:hover { background: var(--accent); border-color: var(--accent); }
.top-arrow:disabled { opacity: 0.3; cursor: default; pointer-events: none; }
.top-arrow-left { left: -4px; }
.top-arrow-right { right: -4px; }

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--grid-gap);
  padding: var(--grid-gap);
  max-width: 100%;
}
@media (max-width: 1800px) { .grid { grid-template-columns: repeat(10, 1fr); } }
@media (max-width: 1400px) { .grid { grid-template-columns: repeat(8, 1fr); } }
@media (max-width: 1100px) { .grid { grid-template-columns: repeat(6, 1fr); } }
@media (max-width: 800px)  { .grid { grid-template-columns: repeat(5, 1fr); } }
@media (max-width: 520px)  { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-2);
  cursor: pointer;
  position: relative;
  transition: transform .12s ease;
  aspect-ratio: 1 / 1;
}
.card:hover { transform: translateY(-2px); }
.card img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card .meta {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 6px 8px; font-size: 11px; color: rgba(255,255,255,0.85);
  background: linear-gradient(to top, rgba(0,0,0,0.65), transparent);
  opacity: 0; transition: opacity .12s ease;
}
.card:hover .meta { opacity: 1; }
.card .likes { float: right; }

/* Inline like button on card (no background, just heart + count, white with subtle shadow for legibility) */
.card-like {
  position: absolute; top: 6px; right: 6px;
  background: transparent; color: #fff;
  border: 0; padding: 2px 6px; font-size: 14px; font-weight: 700;
  cursor: pointer; z-index: 2;
  display: flex; align-items: center; gap: 4px;
  opacity: 0; transition: opacity .12s ease, transform .12s ease;
  text-shadow: 0 1px 3px rgba(0,0,0,0.85), 0 0 6px rgba(0,0,0,0.55);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.7));
}
.card:hover .card-like, .card-like.liked { opacity: 1; }
.card-like:hover { transform: scale(1.15); }
.card-like.liked { color: var(--accent); }
.card-like-n { font-size: 12px; }
.card-like.bounce { animation: like-bounce .35s ease; }
@keyframes like-bounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); }
  70%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.status {
  text-align: center; padding: 16px; color: var(--fg-mute); font-size: 13px;
}
.status.error { color: var(--accent-2); }

#sentinel { height: 200px; }
.load-more-wrap { display: flex; justify-content: center; padding: 16px; }
.load-more-btn {
  padding: 12px 32px; background: var(--bg-2); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; font-size: 14px; font-weight: 600;
}
.load-more-btn:hover { border-color: var(--accent); color: var(--accent); }
.load-more-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.load-more-wrap.hidden { display: none; }

.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.78); }
.modal-content {
  position: relative; max-width: 1100px; width: 100%; max-height: calc(100vh - 32px);
  display: grid; grid-template-columns: 1fr 320px;
  gap: 0; background: var(--bg-2); border-radius: 14px;
  border: 1px solid var(--border); overflow: hidden;
}
.modal-content.small { grid-template-columns: 1fr; max-width: 420px; padding: 24px; }
.modal-content img { width: 100%; height: 100%; object-fit: contain; max-height: calc(100vh - 32px); background: #000; }
.modal-meta { padding: 20px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.modal-meta h2 { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.4; }
.caption { color: var(--fg-mute); font-size: 13px; line-height: 1.5; margin: 0; }
.muted { color: var(--fg-mute); font-size: 13px; }

.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.action {
  padding: 10px 14px; border: 1px solid var(--border); background: var(--bg);
  color: var(--fg); border-radius: 8px; cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
}
.action:hover:not(:disabled) { border-color: var(--accent); }
.action:disabled { opacity: 0.5; cursor: not-allowed; }
.action.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.action.primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }

.modal-share { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--border); }
.modal-share.hidden { display: none; }
.modal-share a, .modal-share button {
  padding: 6px 12px; background: var(--bg); border: 1px solid var(--border);
  color: var(--fg); border-radius: 6px; cursor: pointer; font-size: 12px;
}
.modal-share a:hover, .modal-share button:hover { border-color: var(--accent); }

.close {
  position: absolute; top: 12px; right: 12px; z-index: 10;
  width: 32px; height: 32px; border: none; background: rgba(0,0,0,0.6); color: #fff;
  border-radius: 50%; cursor: pointer; font-size: 22px; line-height: 1;
}
.close:hover { background: rgba(0,0,0,0.85); }

input[type="text"], input[type="search"] {
  background: var(--bg-2); color: var(--fg); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; font-size: 14px; outline: none; width: 100%;
}
input[type="text"]:focus, input[type="search"]:focus { border-color: var(--accent); }

.foot { padding: 32px 16px; text-align: center; color: var(--fg-mute); font-size: 12px; border-top: 1px solid var(--border); margin-top: 32px; }

.liked { color: var(--accent) !important; border-color: var(--accent) !important; }
.hidden { display: none !important; }

.google-signin-wrap { display: inline-flex; min-height: 32px; }
.google-signin-wrap.hidden { display: none; }

.user-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--border); border-radius: 18px;
  cursor: pointer; background: var(--bg-2);
  transition: border-color .12s ease;
}
.user-chip:hover { border-color: var(--accent); }
.user-chip img { width: 28px; height: 28px; border-radius: 50%; }
.user-chip span { font-size: 13px; font-weight: 600; color: var(--accent); }

.user-menu {
  position: absolute; top: 56px; right: 16px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 6px; min-width: 200px; z-index: 60;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}
.user-menu-row { padding: 8px 12px; color: var(--fg-mute); font-size: 12px; border-bottom: 1px solid var(--border); }
.user-menu-item {
  display: block; width: 100%; text-align: left;
  background: transparent; border: 0; color: var(--fg);
  padding: 10px 12px; cursor: pointer; border-radius: 6px; font-size: 14px;
}
.user-menu-item:hover { background: var(--bg); }

.edit-cost-row { display: flex; gap: 8px; margin-top: 8px; }
#editSourcePreview, #editResultImg { width: 100%; max-height: 280px; object-fit: contain; border-radius: 8px; margin: 8px 0; background: #000; }
#editResult h3 { margin: 16px 0 4px; font-size: 14px; color: var(--fg-mute); }

.pack-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin: 12px 0; }
.pack {
  border: 1px solid var(--border); border-radius: 10px; padding: 14px 8px;
  text-align: center; cursor: pointer; transition: border-color .12s ease, transform .12s ease;
  background: var(--bg);
}
.pack:hover { border-color: var(--accent); transform: translateY(-2px); }
.pack-name { font-size: 12px; color: var(--fg-mute); text-transform: uppercase; letter-spacing: .05em; }
.pack-tokens { font-size: 28px; font-weight: 800; color: var(--accent); margin: 4px 0; }
.pack-price { font-size: 14px; }
.pack.best { border-color: var(--accent); }
.pack.best::after { content: "BEST VALUE"; display: block; font-size: 9px; color: var(--accent); margin-top: 4px; font-weight: 700; }

/* ─── Tab nav (icon-only, no text/no background) ─── */
.tab-nav {
  display: flex;
  gap: 14px;
  margin-left: 8px;
  align-items: center;
}
.tab-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  background: transparent;
  text-decoration: none;
  color: transparent;
  font-size: 0;
  border-radius: 0;
  transition: transform 0.12s ease, filter 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
/* Hide any leftover labels */
.tab-link span { display: none; }

.tab-link img {
  display: block;
  width: 56px;
  height: 56px;
  border-radius: 0;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.18));
  transition: transform 0.12s ease, filter 0.12s ease;
}
.tab-link:hover { background: transparent; }
.tab-link:hover img {
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25));
  transform: translateY(-1px);
}

/* Active tab — pressed-in look (no color, no border) */
.tab-link.active {
  background: transparent;
  border: 0;
  color: transparent;
  transform: translateY(2px);
}
.tab-link.active img {
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4))
          brightness(0.92) saturate(0.95);
  transform: scale(0.96);
}

/* Click feedback (any tab) */
.tab-link:active img {
  transform: scale(0.92);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4)) brightness(0.88);
}

/* Coming-soon (3rd tab while /people backend isn't ready) */
.tab-link.coming-soon { opacity: 0.55; }
.tab-link.coming-soon:hover img { transform: none; }

/* Cross-tab strip uses identical layout to first top-strip — no extra styles. */


/* Cross-tab strip 2-row layout (taller carousels showing content from other tabs) */
.top-strip-2row {
  margin-top: 6px;
}
.top-carousel-2row {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(2, 1fr);
  grid-auto-columns: 240px;
  gap: var(--grid-gap);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  padding: 4px 2px;
  outline: none;
  height: calc(2 * 240px + var(--grid-gap) + 8px);
}
.top-carousel-2row::-webkit-scrollbar { display: none; }
.top-carousel-2row .top-card {
  width: 240px;
  height: 240px;
}
