:root {
  --preview-header-height: 91px;
}

#app :is(a, button, [tabindex]):focus-visible {
  outline: 2px solid #ffec88;
  outline-offset: 3px;
}

#app .search-input input:focus-visible {
  outline: 2px solid #9d0919;
  outline-offset: -3px;
}

#app .search-input input::placeholder {
  color: #686868;
}

#app :is(.home-page, .resource-page) .search-button {
  border: 0;
  padding: 0;
}

#app .home-page {
  --preview-hero-height: clamp(520px, calc(100svh - var(--preview-header-height)), 950px);
}

.home-page .background-image {
  height: var(--preview-hero-height);
}

.home-page .search-container {
  top: calc(var(--preview-hero-height) * 0.64);
}

.home-page .footer-stats {
  top: calc(var(--preview-hero-height) - 100px);
  height: 100px;
}

.home-page .pattern-hot-search {
  margin-top: var(--preview-hero-height);
}

.home-page .title-en-container {
  position: static;
}

.home-page .banner-navigation {
  pointer-events: none;
}

.home-page .banner-nav-button {
  pointer-events: auto;
}

#app .home-page .logo-container {
  align-items: center;
  flex-wrap: wrap;
  gap: clamp(16px, 4vw, 64px);
  width: min(92%, 1050px);
}

#app .home-page .partner-logo {
  width: min(260px, 25vw);
  max-width: 100%;
  min-width: 0;
  height: auto;
}

.home-page .partner-logo--zhiliao {
  display: block;
  aspect-ratio: 799 / 344;
  /* The existing title artwork contains this mark at (4720, 2292), 799 × 344 px. */
  background: url("../assets/zt-B3xXsSxf.png") no-repeat;
  background-size: calc(7592 * 100% / 799) auto;
  background-position: calc(4720 * 100% / (7592 - 799)) bottom;
}

.resource-page .search-container {
  width: min(938px, calc(100% - 48px));
}

.resource-page .search-box {
  width: 100% !important;
}

.resource-page .filter-sidebar {
  top: calc(var(--preview-header-height) + 16px);
  flex: 0 0 195px;
}

.resource-page .resource-content {
  min-width: 0;
}

.resource-page .pattern-wrapper {
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.resource-page .result-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  max-width: 2000px;
  margin: 0 auto 8px;
  color: #d4d4d4;
}

.resource-page .result-status button {
  width: auto;
  min-height: 44px;
  margin: 0;
  padding: 6px 12px;
  border: 1px solid #876364;
  border-radius: 6px;
  background: #1a1a1a;
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.resource-page .empty-state {
  padding: 28px 16px;
  color: #d4d4d4;
  text-align: center;
}

.pattern-detail .detail-container {
  width: min(100%, 1885px);
}

.pattern-detail .main-image img {
  object-fit: contain;
}

.pattern-detail .image-type-selector,
.pattern-detail .pattern-header,
.pattern-detail .actions {
  flex-wrap: wrap;
}

.pattern-detail .pattern-header {
  row-gap: 12px;
}

.pattern-detail .actions {
  margin-right: 0;
}

.pattern-detail .color-palette {
  position: static;
  flex-basis: 100%;
  width: auto;
  min-height: 0;
  padding: 10px 12px;
}

.pattern-detail .color-palette-title {
  position: static;
  line-height: 1.5;
}

.pattern-detail .color-circles {
  gap: 12px;
  max-width: none;
  margin-top: 8px;
}

.pattern-detail .info-row .value {
  min-width: 0;
  overflow-wrap: anywhere;
}

.pattern-detail .empty-palette {
  color: #c3c3c3;
}

.pattern-detail a.masonry-item {
  color: inherit;
  text-decoration: none;
}

#app .knowledge-graph {
  min-height: calc(100svh - var(--preview-header-height));
}

.knowledge-graph .graph-container {
  height: max(260px, calc(100svh - var(--preview-header-height) - 145px));
}

#app .auth-container {
  min-height: calc(100svh - var(--preview-header-height));
  padding: 16px;
}

.auth-container .auth-box {
  max-width: 100%;
}

@media (max-width: 1200px) {
  .resource-page .search-box::before,
  .resource-page .search-box::after {
    display: none;
  }

  .home-page .more-link-exploration {
    left: auto;
    right: 7.6%;
    width: auto;
  }
}

@media (max-width: 840px) {
  :root {
    --preview-header-height: 64px;
  }

  #app > main {
    margin-top: var(--preview-header-height);
  }

  #app .header {
    height: var(--preview-header-height);
    gap: 4px;
    padding-inline: clamp(6px, 3vw, 20px) !important;
  }

  .header .dots {
    display: none;
  }

  .header :is(.nav-link, .auth-link) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    margin: 0;
    padding-inline: 5px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.25;
    white-space: nowrap;
  }

  .home-page .title-en,
  .home-page .title-en-second {
    font-size: 22px;
    line-height: 1.2;
  }

  .resource-page .search-section {
    height: clamp(184px, 38vw, 275px);
    margin-top: 0;
  }

  .resource-page .search-container {
    top: 50%;
    height: 56px;
    transform: translate(-50%, -50%);
  }

  .resource-page .main-content {
    flex-direction: column;
  }

  .resource-page .filter-sidebar {
    position: static;
    flex: auto;
    width: auto;
    margin: 8px 16px 0;
  }

  .resource-page .filter-section {
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr);
    gap: 6px;
    margin-bottom: 8px;
  }

  .resource-page .filter-header {
    justify-content: center;
    min-height: 44px;
    padding: 0;
    border-radius: 6px;
  }

  .resource-page .filter-header h3 {
    font-size: 14px;
  }

  .resource-page .filter-content {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    padding: 0 5px;
    border: 1px solid #71333a;
    border-radius: 6px;
    scrollbar-width: thin;
  }

  .resource-page .filter-button {
    flex: 0 0 auto;
    width: auto;
    min-height: 44px;
    margin: 0;
    padding: 0 8px;
    font-size: 14px;
    white-space: nowrap;
  }

  #app .filter-button:focus-visible {
    outline-offset: -3px;
  }

  .resource-page .resource-content {
    padding: 16px;
  }

  .resource-page .patterns-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px 16px;
    padding: 0;
  }

  .resource-page :is(.pattern-card, .pattern-name) {
    width: 100%;
    max-width: none;
    min-height: 0;
    overflow-wrap: anywhere;
  }

  .resource-page .details-row {
    flex-direction: column;
    gap: 2px;
  }

  .resource-page .detail-item:last-child {
    justify-content: flex-start;
  }

  .pattern-detail .detail-container {
    padding: 16px;
  }

  .pattern-detail .image-showcase {
    height: clamp(210px, 64vw, 400px);
  }

  .pattern-detail .image-type-selector {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 16px;
  }

  .pattern-detail .type-button {
    min-width: 0;
    min-height: 44px;
    padding-inline: 8px;
    font-size: 14px;
  }

  .pattern-detail .pattern-header h1 {
    flex-basis: 100%;
    font-size: clamp(20px, 5vw, 28px);
    overflow-wrap: anywhere;
  }

  .pattern-detail .action-button {
    min-height: 44px;
  }

  .pattern-detail .info-row {
    gap: 12px;
    font-size: 16px;
    line-height: 1.5;
  }

  .pattern-detail .info-row .label {
    flex: 0 0 5em;
    width: auto;
  }

  .pattern-detail .masonry-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 145px), 1fr));
    gap: 12px;
  }

  .knowledge-graph .title {
    margin-bottom: 12px;
    font-size: 22px;
  }

  .knowledge-graph .graph-mode-toggle {
    gap: 8px;
    margin-bottom: 12px;
    padding-inline: 8px;
  }

  .knowledge-graph .graph-mode-button,
  .knowledge-graph .camera-controls button {
    min-height: 44px;
    padding-inline: 12px;
    font-size: 14px;
  }

  .knowledge-graph .camera-controls {
    right: 10px;
    bottom: 10px;
  }
}

@media (max-width: 768px) {
  #app .home-page {
    --preview-hero-height: clamp(390px, calc(100svh - var(--preview-header-height)), 630px);
  }

  .home-page .main-title-image {
    top: clamp(70px, 16svh, 140px);
    width: 88%;
  }

  .home-page .footer-stats {
    top: calc(var(--preview-hero-height) - 78px);
    height: 70px;
  }

  #app .home-page .stat-value {
    font-size: clamp(24px, 7vw, 38px) !important;
    line-height: 1.1;
  }

  #app .home-page :is(.stat-label, .stat-unit) {
    font-size: 12px !important;
    line-height: 1.4;
  }

  #app :is(.home-page, .resource-page) .search-box {
    flex-direction: row;
    height: 56px !important;
  }

  #app :is(.home-page, .resource-page) :is(.search-category, .search-button) {
    flex: 0 0 clamp(52px, 16vw, 80px);
    height: 100%;
    font-size: 16px !important;
  }

  #app :is(.home-page, .resource-page) .search-category {
    border-radius: 14px 0 0 14px;
  }

  #app :is(.home-page, .resource-page) .search-button {
    border: 0;
    border-radius: 0 14px 14px 0;
  }

  #app :is(.home-page, .resource-page) .search-input {
    min-width: 0;
    padding-inline: 8px;
  }

  #app :is(.home-page, .resource-page) .search-input input,
  #app :is(.home-page, .resource-page) .search-input input::placeholder {
    font-size: 16px;
  }

  .home-page .pattern-exploration-container {
    height: 335px;
  }

  .home-page .exploration-title,
  .home-page .exploration-title-en {
    font-size: 26px;
    line-height: 1.25;
  }

  .home-page .more-link-exploration {
    top: 55%;
    right: auto;
    left: 7.6%;
  }

  .home-page .banner-navigation {
    align-items: flex-end;
    padding: 0 16px 12px;
  }

  #app .home-page .partner-logo {
    width: min(140px, 38vw);
    object-fit: contain;
  }

  .auth-container .auth-box {
    padding: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-page .dynamic-video-background {
    display: none;
  }

  #app :is(.banner-fade-enter-active, .banner-fade-leave-active, .pattern-wrapper, .masonry-item) {
    transition: none;
  }
}
