:root {
  --bg: #f4efe5;
  --bg-deep: #eae2d3;
  --surface: #fffefb;
  --surface-warm: #f9f5ec;
  --card-cream: #f5f2ea;
  --ink: #201d19;
  --ink-soft: #4c453b;
  --ink-muted: #766c5e;
  --orange: #c44b25;
  --orange-hover: #ab3d1a;
  --orange-tint: rgba(196, 75, 37, 0.11);
  --navy: #1c3254;
  --navy-hover: #142540;
  --navy-tint: rgba(28, 50, 84, 0.09);
  --border: rgba(110, 94, 74, 0.2);
  --border-strong: rgba(110, 94, 74, 0.34);
  --shadow-soft: 0 10px 30px rgba(38, 31, 20, 0.06);
  --shadow-card: 0 14px 36px rgba(38, 31, 20, 0.08);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  scroll-behavior: smooth;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(circle at 14px 14px, rgba(145, 126, 98, 0.13) 2.3px, transparent 2.7px);
  background-size: 32px 32px;
  line-height: 1.55;
}

h1, h2, h3, p, ol {
  margin: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.container {
  width: min(1240px, calc(100% - 40px));
  margin-inline: auto;
}

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

/* ==========================================================================
   TOP BAR (Floating Sticky Header + Creator Homepage Guide + GitHub)
   ========================================================================== */
.top-bar-wrap {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(244, 239, 229, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(110, 94, 74, 0.14);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  flex-wrap: wrap;
}

.top-bar__actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

/* ==========================================================================
   1. OPEN-SOURCE HERO CARD
   ========================================================================== */
.os-hero {
  padding: 16px 0 18px;
}

.os-hero__card {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(300px, 0.82fr);
  gap: 26px;
  align-items: center;
  padding: 28px 30px;
  border-radius: 24px;
  background: linear-gradient(140deg, #fffefb 0%, #faf5ea 100%);
  border: 1.5px solid var(--border-strong);
  box-shadow: var(--shadow-card);
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 14px;
}

.h-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
}

.h-badge--orange {
  background: var(--orange-tint);
  color: var(--orange);
}

.h-badge--navy {
  background: var(--navy-tint);
  color: var(--navy);
}

.h-badge--soft {
  background: var(--bg-deep);
  color: var(--ink-soft);
}

.os-hero__copy h1 {
  font-size: clamp(28px, 3.6vw, 44px);
  font-weight: 900;
  line-height: 1.16;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.os-hero__copy h1 span {
  color: var(--orange);
}

.os-hero__lead {
  font-size: 15.5px;
  line-height: 1.65;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 20px;
  max-width: 620px;
}

.os-hero__lead strong {
  color: var(--navy);
  font-weight: 850;
}

.os-hero__ctas {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* 3x2 Showcase Deck */
.os-hero__deck {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.deck-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px 10px;
  border-radius: 16px;
  border: 1.5px solid var(--border);
  background: var(--card-cream);
  color: var(--ink-soft);
  font: inherit;
  cursor: pointer;
  transition: transform 160ms var(--ease), border-color 160ms var(--ease), box-shadow 160ms var(--ease), background 160ms var(--ease);
}

.deck-tile:hover {
  transform: translateY(-3px);
  background: #ffffff;
  border-color: var(--orange);
  box-shadow: 0 10px 22px rgba(38, 31, 20, 0.09);
}

.deck-tile img {
  width: 78px;
  height: 78px;
  object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(24, 20, 14, 0.1));
}

.deck-tile span {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ink-soft);
}

/* ==========================================================================
   2. COMPACT 4-STEP VIDEO FLOW
   ========================================================================== */
.flow-section {
  padding: 0 0 24px;
}

.flow-card {
  padding: 18px 22px;
  border-radius: 20px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.flow-head {
  margin-bottom: 12px;
}

.flow-head h2 {
  font-size: clamp(19px, 2vw, 23px);
  font-weight: 900;
  letter-spacing: -0.01em;
}

.flow-head h2 b {
  color: var(--orange);
}

.flow-steps {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 11px;
}

.flow-step {
  padding: 12px 13px;
  border-radius: 13px;
  background: var(--surface-warm);
  border: 1px solid var(--border);
}

.flow-step:target {
  border-color: var(--orange);
  background: #ffffff;
}

.flow-step__top {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
}

.flow-num {
  display: inline-grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 7px;
  background: var(--orange-tint);
  color: var(--orange);
  font-size: 11px;
  font-weight: 900;
}

.flow-step strong {
  font-size: 14.5px;
  font-weight: 850;
  color: var(--ink);
}

.flow-step p {
  font-size: 12.8px;
  line-height: 1.5;
  font-weight: 600;
  color: var(--ink-soft);
}

.flow-step p b {
  color: var(--navy);
  font-weight: 800;
}

/* ==========================================================================
   3. PURE 2.5D BRICK ASSET LIBRARY (INFINITE SCROLL 100 PER BATCH)
   ========================================================================== */
.library-section {
  padding: 8px 0 44px;
  scroll-margin-top: 84px;
}

.library-head {
  margin-bottom: 14px;
}

.library-head h2 {
  font-size: clamp(25px, 3vw, 34px);
  font-weight: 900;
  line-height: 1.15;
}

.library-head h2 span {
  color: var(--orange);
}

.library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.search-box {
  position: relative;
  flex: 1 1 320px;
  max-width: 560px;
}

.search-box input {
  width: 100%;
  min-height: 44px;
  padding: 9px 40px 9px 15px;
  border-radius: 12px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  font-weight: 650;
}

.search-box input:focus {
  border-color: var(--orange);
  outline: none;
  box-shadow: 0 0 0 3px rgba(196, 75, 37, 0.16);
}

.search-clear {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: var(--bg-deep);
  color: var(--ink-soft);
  font-weight: 800;
  cursor: pointer;
}

.backdrop-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border-radius: 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
}

.backdrop-switch__label {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink-muted);
  padding-left: 4px;
}

.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 18px;
}

/* Brick Grid */
.brick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
  gap: 15px;
}

.brick-card {
  display: flex;
  flex-direction: column;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  overflow: hidden;
  box-shadow: 0 3px 10px rgba(38, 31, 20, 0.04);
  transition: transform 150ms var(--ease), border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}

.brick-card:hover {
  transform: translateY(-2px);
  border-color: rgba(196, 75, 37, 0.52);
  box-shadow: 0 10px 24px rgba(38, 31, 20, 0.09);
}

.brick-card__preview {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}

.brick-card__stage,
.brick-modal__stage {
  width: 100%;
  display: grid;
  place-items: center;
  padding: 15px;
  background: var(--card-cream);
  transition: background 150ms var(--ease);
}

.brick-card__stage {
  aspect-ratio: 1 / 1;
}

[data-backdrop="cream"] .brick-card__stage,
.brick-modal__stage[data-backdrop="cream"] {
  background: #f5f2ea;
}

[data-backdrop="checker"] .brick-card__stage,
.brick-modal__stage[data-backdrop="checker"] {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #e7e2d8 25%, transparent 25%),
    linear-gradient(-45deg, #e7e2d8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e7e2d8 75%),
    linear-gradient(-45deg, transparent 75%, #e7e2d8 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

[data-backdrop="navy"] .brick-card__stage,
.brick-modal__stage[data-backdrop="navy"] {
  background: #1c3254;
}

.brick-card__stage img {
  width: 100%;
  height: 100%;
  max-height: 168px;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(24, 20, 14, 0.1));
}

.brick-card__footer {
  padding: 10px 12px 11px;
  border-top: 1px solid rgba(110, 94, 74, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: 1;
}

.brick-card__info {
  min-width: 0;
  cursor: pointer;
}

.brick-card__cat {
  display: block;
  font-size: 11px;
  font-weight: 850;
  color: var(--orange);
  margin-bottom: 2px;
}

.brick-card__title {
  display: block;
  font-size: 14px;
  font-weight: 850;
  line-height: 1.3;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-dl-btn.is-done {
  background: var(--orange);
  border-color: var(--orange);
  color: #fffefb;
}

/* Infinite Scroll Load More Sentinel Bar */
.load-more-bar {
  margin-top: 26px;
  padding: 18px 20px;
  border-radius: 16px;
  background: var(--surface);
  border: 1.5px dashed var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.load-more-bar[hidden] {
  display: none !important;
}

.empty-state {
  padding: 40px 20px;
  text-align: center;
  border-radius: 16px;
  background: var(--surface);
  border: 1.5px dashed var(--border-strong);
}

.empty-state p {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 14px;
}

/* ==========================================================================
   4. CREATOR PROFILE & HOMEPAGE GUIDE BANNER
   ========================================================================== */
.author-section {
  padding: 0 0 56px;
}

.author-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding: 24px 28px;
  border-radius: 22px;
  background: linear-gradient(135deg, #fffefb 0%, #f8f2e4 100%);
  border: 1.5px solid var(--border-strong);
  box-shadow: var(--shadow-soft);
}

.author-card__profile {
  display: flex;
  align-items: center;
  gap: 18px;
  flex: 1 1 480px;
}

.author-card__profile img {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #ffffff;
  box-shadow: 0 4px 14px rgba(38, 31, 20, 0.12);
  flex: 0 0 auto;
}

.author-card__profile h2 {
  font-size: 19px;
  font-weight: 900;
  margin-bottom: 5px;
}

.author-card__profile p {
  font-size: 14px;
  line-height: 1.6;
  font-weight: 600;
  color: var(--ink-soft);
}

.author-card__profile strong {
  color: var(--navy);
}

.author-card__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ==========================================================================
   MODAL PREVIEW & PNG DOWNLOAD
   ========================================================================== */
.brick-modal {
  padding: 0;
  border: 0;
  border-radius: 22px;
  max-width: min(740px, calc(100vw - 28px));
  width: 100%;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 28px 72px rgba(18, 15, 10, 0.28);
}

.brick-modal::backdrop {
  background: rgba(24, 20, 14, 0.5);
}

.brick-modal__card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
}

.brick-modal__stage {
  min-height: 290px;
  padding: 26px;
}

.brick-modal__stage img {
  max-height: 260px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.brick-modal__info {
  padding: 26px 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 11px;
}

.modal-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modal-badges span {
  padding: 3px 9px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 850;
}

.modal-cat { background: var(--orange-tint); color: var(--orange); }
.modal-series { background: var(--navy-tint); color: var(--navy); }
.modal-size { background: var(--bg-deep); color: var(--ink-soft); }

.brick-modal__info h3 {
  font-size: 22px;
  font-weight: 900;
  line-height: 1.25;
}

.modal-note {
  font-size: 14.5px;
  color: var(--ink-soft);
  font-weight: 600;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modal-tags span {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-warm);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
}

.modal-download-bar {
  margin-top: 6px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* ==========================================================================
   RESPONSIVE & REDUCED MOTION
   ========================================================================== */
@media (max-width: 980px) {
  .os-hero__card {
    grid-template-columns: 1fr;
    padding: 22px;
  }
  .flow-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .library-section {
    scroll-margin-top: 130px;
  }
  .container {
    width: calc(100% - 28px);
  }
  .os-hero__card {
    padding: 18px;
  }
  .os-hero__deck {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .deck-tile img {
    width: 60px;
    height: 60px;
  }
  .flow-card {
    padding: 16px;
  }
  .flow-steps,
  .brick-modal__card {
    grid-template-columns: 1fr;
  }
  .brick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px;
  }
  .brick-card__stage {
    padding: 11px;
  }
  .brick-card__footer {
    padding: 9px 10px 10px;
  }
  .brick-card__title {
    font-size: 13.5px;
  }
  .author-card {
    padding: 18px;
  }
  .author-card__profile {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* Give long asset names room beside a usable download control on phones. */
@media (max-width: 420px) {
  .brick-card__footer { align-items: stretch; flex-direction: column; }
  .brick-card__title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    min-height: 2.6em;
    white-space: normal;
  }
  .brick-card__footer .k-button { align-self: flex-start; min-height: 36px; }
}

.brand-chip__lic-short { display: none; }

/* Phone layout: keep navigation and filters compact while showing every category. */
@media (max-width: 680px) {
  /* Keep the compact single row when it fits; let it wrap at narrow widths or enlarged text. */
  .top-bar.top-bar--compact { flex-wrap: wrap; gap: 5px; padding: 7px 0; }
  .top-bar .top-bar__actions { flex-wrap: wrap; min-width: 0; max-width: 100%; gap: 5px; }
  /* The sticky header must mask content scrolling behind it. */
  .top-bar-wrap { background: #f4efe5; backdrop-filter: none; -webkit-backdrop-filter: none; }

  .site-compact .library-section { scroll-margin-top: 62px; }
  .library-head { margin-bottom: 10px; }
  .library-toolbar { flex-wrap: nowrap; gap: 7px; margin-bottom: 10px; }
  .search-box { flex: 1 1 auto; min-width: 0; }
  .search-box input { min-height: 38px; padding: 7px 32px 7px 10px; font-size: 16px; }
  .backdrop-switch { flex: none; gap: 1px; padding: 2px 3px; border-radius: 10px; }
  .backdrop-switch__label { padding-left: 2px; font-size: 10px; }

  .category-pills { gap: 5px; margin-bottom: 12px; }

}
@media (max-width: 420px) {

  .brand-chip__lic-full { display: none; }
  .brand-chip__lic-short { display: inline; }
}
@media (max-width: 385px) {
  .brand-chip__lic { display: none; }
  .site-compact .library-section { scroll-margin-top: 105px; }
}
@media (max-width: 360px) {
  .gh-pill__label { display: none; }
}

/* Tactile page-specific deck and workflow cards. */

.deck-tile { box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 3px 0 rgba(104,88,68,.12); }
.deck-tile:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(104,88,68,.12); }
.flow-step { position: relative; padding-top: 20px; overflow: hidden; }
.flow-step::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 9px;
  background: radial-gradient(ellipse 5px 3px at 12px 3px, rgba(255,255,255,.48) 90%, transparent 100%) 0 0 / 21px 8px repeat-x, #c44b25;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 1px 0 rgba(104,48,24,.14);
}
.flow-step:nth-child(even)::before {
  background: radial-gradient(ellipse 5px 3px at 12px 3px, rgba(255,255,255,.42) 90%, transparent 100%) 0 0 / 21px 8px repeat-x, #1c3254;
}

@media (prefers-reduced-motion: reduce) {
  .deck-tile { transition: none; }
}
