:root {
  --black: #050607;
  --panel: #11161a;
  --panel-strong: #171d22;
  --line: rgba(255, 255, 255, .12);
  --line-strong: rgba(102, 219, 255, .42);
  --white: #f7fafc;
  --silver: #aeb8c2;
  --muted: #6f7c86;
  --blue: #05a9d6;
  --blue-soft: #6bdcff;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--black);
  color: var(--white);
  font-family: "Noto Sans Thai", "Inter", sans-serif;
  line-height: 1.6;
}

.color-library-page {
  user-select: none;
  -webkit-user-select: none;
}

.color-library-page input,
.color-library-page select,
.color-library-page textarea {
  user-select: text;
  -webkit-user-select: text;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.library-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  background: rgba(5, 6, 7, .92);
  backdrop-filter: blur(14px);
}

.library-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand img {
  display: block;
  width: 156px;
  height: auto;
}

.mobile-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid rgba(107, 220, 255, .42);
  background: rgba(17, 22, 26, .86);
  color: var(--white);
  padding: 9px 13px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.mobile-menu-toggle span:first-child {
  color: var(--blue-soft);
  font-family: "Inter", sans-serif;
  font-size: 1.1rem;
  line-height: 1;
}

.library-nav a,
.line-button,
.reset-button,
.toggle-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  padding: 11px 16px;
  font-weight: 900;
  cursor: pointer;
}

.library-nav a {
  background: var(--panel);
  color: var(--white);
}

.header-line,
.line-button {
  background: var(--blue);
  color: #001217;
}

main {
  width: min(1560px, calc(100% - 36px));
  margin: 0 auto;
}

.hero {
  padding: clamp(54px, 7vw, 104px) 0 clamp(36px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue-soft);
  font-family: "Inter", sans-serif;
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 980px;
  margin: 0;
  font-size: clamp(2.5rem, 8vw, 6.8rem);
  font-weight: 900;
  line-height: .98;
}

.hero-subtitle {
  max-width: 860px;
  margin: 18px 0 0;
  color: var(--blue-soft);
  font-family: "Inter", sans-serif;
  font-size: clamp(1.05rem, 2vw, 1.55rem);
  font-weight: 900;
}

.hero-copy {
  max-width: 760px;
  margin: 24px 0 0;
  color: var(--silver);
  font-size: clamp(1rem, 1.6vw, 1.28rem);
  font-weight: 700;
}

.hero-count {
  display: inline-flex;
  margin: 28px 0 0;
  border: 1px solid var(--line-strong);
  padding: 10px 14px;
  color: var(--white);
  background: rgba(5, 169, 214, .12);
  font-family: "Inter", sans-serif;
  font-weight: 900;
}

.protection-notice {
  margin: 12px 0 0;
  color: var(--muted);
  font-family: "Inter", sans-serif;
  font-size: .82rem;
  font-weight: 800;
}

.library-toolbar {
  display: grid;
  gap: 18px;
  padding: 28px 0;
  border-bottom: 1px solid var(--line);
}

.search-field,
.filters label {
  display: grid;
  gap: 8px;
  color: var(--silver);
  font-size: .86rem;
  font-weight: 800;
}

.search-field input,
.filters select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #07090b;
  color: var(--white);
  padding: 12px 14px;
  outline: none;
}

.search-field input:focus,
.filters select:focus {
  border-color: var(--line-strong);
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.reset-button,
.toggle-button {
  background: var(--panel);
  color: var(--white);
}

.toggle-button.is-active {
  border-color: var(--blue);
  background: rgba(5, 169, 214, .15);
  color: var(--blue-soft);
}

.library-status {
  padding: 18px 0;
  color: var(--silver);
  font-family: "Inter", sans-serif;
  font-weight: 800;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 20px;
  padding-bottom: 72px;
}

.color-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
  transition: border-color .18s ease, box-shadow .18s ease;
}

.color-card.is-selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(5, 169, 214, .2);
}

.color-card.is-selected::after {
  content: "✓";
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--blue-soft);
  border-radius: 50%;
  background: rgba(5, 169, 214, .92);
  color: #001217;
  font-family: "Inter", sans-serif;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}

.image-button {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: #07090b;
  cursor: zoom-in;
}

.protected-image {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
}

.protected-image img {
  -webkit-user-drag: none;
  pointer-events: none;
}

.image-protection-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: transparent;
  cursor: inherit;
}

.image-button .protected-image img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1.08;
  object-fit: cover;
}

.card-copy {
  display: grid;
  gap: 10px;
  padding: 15px;
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-code {
  min-height: 20px;
  color: var(--blue-soft);
  font-family: "Inter", sans-serif;
  font-size: .8rem;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.card-favorite,
.favorite-button {
  border: 1px solid var(--line);
  background: #07090b;
  color: var(--silver);
  cursor: pointer;
  font-weight: 900;
}

.card-favorite {
  min-width: 78px;
  min-height: 34px;
  padding: 6px 8px;
}

.favorite-button {
  min-height: 44px;
  padding: 10px 14px;
}

.card-favorite.is-saved,
.favorite-button.is-saved {
  border-color: var(--blue);
  background: rgba(5, 169, 214, .15);
  color: var(--blue-soft);
}

.card-favorite:focus-visible,
.favorite-button:focus-visible {
  outline: 2px solid var(--blue-soft);
  outline-offset: 2px;
}

.color-card h2 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.card-meta,
.filename {
  margin: 0;
  color: var(--silver);
  font-family: "Inter", "Noto Sans Thai", sans-serif;
  font-size: .82rem;
  overflow-wrap: anywhere;
}

.filename {
  color: var(--muted);
}

.filename {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  font-size: .78rem;
}

.empty-state {
  margin: 30px 0 80px;
  padding: 36px;
  border: 1px solid var(--line);
  background: var(--panel);
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0;
  color: var(--silver);
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .78);
}

.modal-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
  width: min(1180px, 100%);
  max-height: min(860px, calc(100vh - 40px));
  overflow: auto;
  border: 1px solid var(--line-strong);
  background: var(--panel-strong);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  background: rgba(5, 6, 7, .8);
  color: var(--white);
  cursor: pointer;
  font-size: 1.7rem;
  line-height: 1;
}

.modal-image-wrap {
  position: relative;
  display: grid;
  min-height: 420px;
  place-items: center;
  background: #050607;
}

.modal-protected-image {
  display: grid;
  min-height: inherit;
  place-items: center;
}

.modal-image-wrap img {
  display: block;
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
}

.modal-copy {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: clamp(22px, 4vw, 42px);
}

.modal-copy h2 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.modal-copy dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.modal-copy div.meta-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.modal-copy dt {
  color: var(--muted);
  font-weight: 800;
}

.modal-copy dd {
  margin: 0;
  color: var(--silver);
  overflow-wrap: anywhere;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.site-nap-footer {
  margin-top: 42px;
  padding: 28px clamp(18px, 5vw, 72px);
  border-top: 1px solid var(--line);
  background: #050607;
}

.site-nap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}

.site-nap strong {
  color: var(--white);
}

.site-nap a {
  color: var(--blue-soft);
}

@media (max-width: 900px) {
  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modal-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .site-nap {
    display: grid;
  }

  .library-header {
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 16px;
  }

  .brand img {
    width: 128px;
  }

  .mobile-menu-toggle {
    display: inline-flex;
    margin-left: auto;
  }

  .library-nav {
    display: none;
    width: 100%;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 10px;
    border: 1px solid var(--line);
    background: rgba(5, 6, 7, .94);
  }

  .library-header.is-menu-open .library-nav {
    display: grid;
  }

  .library-nav a {
    width: 100%;
    min-height: 40px;
    padding: 9px 10px;
    font-size: .82rem;
  }

  .header-line {
    grid-column: 1 / -1;
  }

  main {
    width: min(100% - 28px, 1560px);
  }

  .hero {
    padding-top: 42px;
  }

  .filters,
  .toolbar-actions {
    grid-template-columns: 1fr;
  }

  .toolbar-actions,
  .line-button,
  .favorite-button {
    width: 100%;
  }

  .color-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .image-button .protected-image img {
    aspect-ratio: 1 / 1.12;
  }

  .card-copy {
    padding: 10px;
  }

  .color-card h2 {
    font-size: .9rem;
  }

  .modal {
    padding: 10px;
  }

  .modal-image-wrap {
    min-height: 260px;
  }
}
