:root {
  --bg: #f7f9fb;
  --bg-elevated: #ffffff;
  --bg-subtle: #eaf0f6;
  --bg-pill: rgba(15, 30, 46, 0.055);
  --ink: #0f1e2e;
  --ink-muted: #536579;
  --ink-faint: #8496a9;
  --border: rgba(15, 30, 46, 0.09);
  --border-strong: rgba(15, 30, 46, 0.2);
  --accent: #1d63ff;
  --accent-soft: rgba(29, 99, 255, 0.11);
  --lime: #d9f94b;
  --lime-ink: #0f1e2e;
  --mint: #0ea57a;
  --shadow-card: 0 2px 10px rgba(15, 30, 46, 0.045);
  --shadow-hover: 0 12px 28px rgba(15, 30, 46, 0.12);
  --radius-card: 16px;
  --radius-pill: 999px;
  --font-display: "Plus Jakarta Sans", "PingFang SC", "Hiragino Sans GB", "Noto Sans JP", "Apple SD Gothic Neo", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans JP", "Apple SD Gothic Neo", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0b131e;
  --bg-elevated: #131e2e;
  --bg-subtle: #1b2a3f;
  --bg-pill: rgba(237, 243, 249, 0.08);
  --ink: #edf3f9;
  --ink-muted: #93a7be;
  --ink-faint: #647992;
  --border: rgba(237, 243, 249, 0.1);
  --border-strong: rgba(237, 243, 249, 0.22);
  --accent: #4c8dff;
  --accent-soft: rgba(76, 141, 255, 0.18);
  --lime: #d9f94b;
  --lime-ink: #0b131e;
  --mint: #24c295;
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.34);
  --shadow-hover: 0 14px 34px rgba(0, 0, 0, 0.54);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 8% 0%, rgba(29, 99, 255, 0.065), transparent 34%),
    radial-gradient(circle at 92% 4%, rgba(217, 249, 75, 0.12), transparent 28%);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[data-theme="dark"] body {
  background-image:
    radial-gradient(circle at 10% 0%, rgba(76, 141, 255, 0.12), transparent 36%),
    radial-gradient(circle at 90% 6%, rgba(217, 249, 75, 0.06), transparent 28%);
}

button, input {
  font: inherit;
  color: inherit;
}

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1520px;
  margin: 0 auto;
  padding: 11px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 12.5px;
  letter-spacing: -0.04em;
  box-shadow: 0 3px 10px rgba(29, 99, 255, 0.32);
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lime);
  border: 1.5px solid var(--bg);
}

.brand-title {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.brand-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-muted);
  font-family: var(--font-mono);
}

.fresh-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mint) 22%, transparent);
}

.top-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.lang-switch {
  display: inline-flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  max-width: 100%;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: var(--bg-pill);
  border: 1px solid var(--border);
  scrollbar-width: none;
}

.lang-switch::-webkit-scrollbar {
  display: none;
}

.lang-btn {
  border: 0;
  background: transparent;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink-muted);
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease;
}

.lang-btn:hover {
  color: var(--ink);
}

.lang-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 6px rgba(29, 99, 255, 0.28);
}

.ctrl-btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: border-color 0.15s ease, transform 0.12s ease, background 0.15s ease;
}

.ctrl-btn:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.ctrl-btn.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.ctrl-btn.active-mode {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* Filter bar */
.filter-bar {
  max-width: 1520px;
  margin: 0 auto;
  padding: 14px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 6px 13px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.14s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.chip:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

.chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.chip .cnt {
  font-family: var(--font-mono);
  font-size: 11px;
  opacity: 0.72;
}

.chip.tag-chip {
  background: transparent;
  padding: 4px 11px;
  font-size: 12.5px;
}

.chip.tag-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.search-box {
  position: relative;
  min-width: 210px;
  flex: 0 1 270px;
}

.search-box input {
  width: 100%;
  padding: 7px 32px 7px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 13px;
}

.search-box input::placeholder {
  color: var(--ink-faint);
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px 5px;
}

/* Multi-column balanced masonry wall */
.wall-wrap {
  max-width: 1520px;
  margin: 0 auto;
  padding: 2px 20px 64px;
}

.masonry {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.masonry.compact {
  gap: 10px;
}

.masonry-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.masonry.compact .masonry-col {
  gap: 10px;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  animation: cardIn 0.25s ease both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.card-media {
  position: relative;
  width: 100%;
  background: var(--bg-subtle);
  cursor: zoom-in;
  overflow: hidden;
  display: block;
}

.card-media img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.card:hover .card-media img {
  transform: scale(1.015);
}

.card-badges {
  position: absolute;
  top: 9px;
  left: 9px;
  display: flex;
  gap: 5px;
  pointer-events: none;
  z-index: 2;
}

.badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 6px rgba(15, 30, 46, 0.2);
}

.badge-gif {
  background: var(--lime);
  color: var(--lime-ink);
}

.badge-gif .gif-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lime-ink);
  opacity: 0.45;
}

.card.is-playing .badge-gif .gif-dot {
  background: #1d63ff;
  opacity: 1;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.65; }
}

.badge-new {
  background: var(--accent);
  color: #fff;
}

.badge-visual {
  background: rgba(15, 30, 46, 0.72);
  color: #fff;
  backdrop-filter: blur(4px);
}

.card-quick {
  position: absolute;
  top: 9px;
  right: 9px;
  display: flex;
  gap: 5px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 2;
}

.card:hover .card-quick,
.card:focus-within .card-quick {
  opacity: 1;
  transform: translateY(0);
}

.icon-btn {
  width: 31px;
  height: 31px;
  border-radius: 9px;
  border: 0;
  background: rgba(15, 30, 46, 0.78);
  color: #fff;
  backdrop-filter: blur(6px);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
  text-decoration: none;
  transition: background 0.14s ease, transform 0.12s ease;
}

.icon-btn:hover {
  background: var(--accent);
  transform: scale(1.06);
}

.icon-btn.liked {
  background: var(--accent);
  color: #fff;
}

.card-foot {
  padding: 10px 12px 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.masonry.compact .card-foot {
  padding: 7px 9px 8px;
  gap: 4px;
}

.card-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 650;
  line-height: 1.38;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}

.masonry.compact .card-title {
  font-size: 12.5px;
  -webkit-line-clamp: 1;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink-faint);
}

.card-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.mini-tag {
  background: var(--bg-pill);
  color: var(--ink-muted);
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 11px;
}

.empty-state {
  text-align: center;
  padding: 72px 20px;
  color: var(--ink-muted);
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: 20px;
}

.load-more-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
}

.load-more-btn {
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--ink);
  padding: 10px 24px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 650;
  cursor: pointer;
  transition: all 0.14s ease;
}

.load-more-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.load-more-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faint);
}

.wall-loading {
  text-align: center;
  padding: 64px 20px;
  color: var(--ink-muted);
  font-size: 14px;
}

/* Lightbox */
.lightbox-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(9, 16, 26, 0.84);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-backdrop[hidden] {
  display: none;
}

.lightbox {
  width: min(1040px, 100%);
  max-height: 92vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 22px;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 340px);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
}

.lb-stage {
  position: relative;
  background: #070d15;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 360px;
  max-height: 92vh;
  padding: 16px;
}

.lb-stage img {
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 8px;
}

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(15, 30, 46, 0.72);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.lb-nav:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.lb-prev { left: 12px; }
.lb-next { right: 12px; }

.lb-side {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.lb-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.lb-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 750;
  line-height: 1.32;
}

.lb-close {
  border: 1px solid var(--border);
  background: var(--bg-pill);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.lb-note {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-subtle);
  font-size: 13px;
  color: var(--ink-muted);
}

.lb-peek {
  font-size: 12.5px;
  color: var(--ink-muted);
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}

.lb-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-muted);
}

.lb-spec {
  background: var(--bg-pill);
  padding: 7px 10px;
  border-radius: 10px;
}

.lb-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.lb-btn {
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 13.5px;
  font-weight: 650;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.lb-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.lb-btn:hover {
  border-color: var(--border-strong);
}

.lb-source {
  font-size: 12px;
  color: var(--ink-faint);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.lb-source a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.lb-source a:hover {
  text-decoration: underline;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 22px 20px 38px;
  color: var(--ink-muted);
  font-size: 13px;
}

.footer-inner {
  max-width: 1520px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.footer-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.footer-link {
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-size: 13px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--ink);
  color: var(--bg);
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 90;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Info modal */
.info-box {
  width: min(560px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

.info-box h2 {
  margin: 0 0 10px;
  font-family: var(--font-display);
}

.info-box p {
  margin: 0 0 10px;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1.65;
}

@media (max-width: 860px) {
  .lightbox {
    grid-template-columns: 1fr;
    max-height: 94vh;
  }
  .lb-stage {
    min-height: 220px;
    max-height: 52vh;
  }
  .lb-stage img {
    max-height: 48vh;
  }
  .card-quick {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 560px) {
  .topbar-inner, .filter-bar, .wall-wrap {
    padding-left: 12px;
    padding-right: 12px;
  }
  .masonry { gap: 10px; }
  .masonry-col { gap: 10px; }
  .brand-meta { display: none; }
}

/* RTL support (Arabic) */
[dir="rtl"] .card-badges { left: auto; right: 9px; }
[dir="rtl"] .card-quick { right: auto; left: 9px; }
[dir="rtl"] .search-box input { padding: 7px 14px 7px 32px; }
[dir="rtl"] .search-clear { right: auto; left: 8px; }
[dir="rtl"] .lb-peek { border-left: 0; border-right: 3px solid var(--accent); padding-left: 0; padding-right: 10px; }
[dir="rtl"] .lb-prev { left: auto; right: 12px; }
[dir="rtl"] .lb-next { right: auto; left: 12px; }
[dir="rtl"] .brand-mark::after { right: auto; left: -2px; }
