:root {
  color-scheme: light;
  --cream: #fffaf0;
  --cream-strong: #fff3cf;
  --pastel-green: #cfeecf;
  --green: #8ccf95;
  --yellow: #f5ca63;
  --gray: #eef0ec;
  --ink: #22251f;
  --muted: #687064;
  --line: rgba(34, 37, 31, 0.12);
  --surface: rgba(255, 250, 240, 0.78);
  --surface-solid: #fffdf7;
  --shadow: 0 24px 80px rgba(75, 88, 61, 0.18);
  --glow: 0 18px 44px rgba(140, 207, 149, 0.28);
}

body.dark {
  color-scheme: dark;
  --cream: #161914;
  --cream-strong: #272819;
  --pastel-green: #2b5637;
  --green: #9ddaa4;
  --yellow: #f3c766;
  --gray: #232721;
  --ink: #f7f5ec;
  --muted: #b8bdaf;
  --line: rgba(247, 245, 236, 0.14);
  --surface: rgba(26, 29, 24, 0.78);
  --surface-solid: #1e221c;
  --shadow: 0 24px 90px rgba(0, 0, 0, 0.38);
  --glow: 0 18px 48px rgba(157, 218, 164, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(207, 238, 207, 0.72), rgba(255, 250, 240, 0.9) 42%, rgba(245, 202, 99, 0.28)),
    var(--cream);
  color: var(--ink);
  font-family: "Inter", "Noto Sans Thai", system-ui, sans-serif;
  letter-spacing: 0;
}

body.dark {
  background:
    linear-gradient(120deg, rgba(43, 86, 55, 0.38), rgba(22, 25, 20, 0.94) 46%, rgba(96, 76, 34, 0.24)),
    var(--cream);
}

body.modal-open {
  overflow: hidden;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(18px);
}

.brand,
.top-nav,
.footer-links,
.hero-actions,
.filter-row {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-weight: 800;
}

.brand-mark {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: var(--cream);
  font-size: 0.8rem;
}

.top-nav {
  gap: clamp(12px, 3vw, 34px);
  color: var(--muted);
  font-weight: 600;
}

.top-nav a:hover {
  color: var(--ink);
}

.nav-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  padding: 0;
}

.nav-button:hover {
  color: var(--ink);
}

.admin-only {
  display: none !important;
}

body.is-admin .admin-only {
  display: inline-flex !important;
}

.theme-toggle,
.modal-close {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface-solid);
  color: var(--ink);
  cursor: pointer;
}

.theme-toggle {
  width: 42px;
  height: 42px;
  border-radius: 8px;
}

.hero {
  position: relative;
  min-height: calc(100vh - 78px);
  display: grid;
  align-items: end;
  overflow: hidden;
  padding: clamp(110px, 14vw, 170px) clamp(18px, 5vw, 72px) clamp(64px, 8vw, 92px);
  background:
    radial-gradient(circle at 18% 20%, rgba(207, 238, 207, 0.9), transparent 34%),
    radial-gradient(circle at 82% 16%, rgba(245, 202, 99, 0.5), transparent 30%),
    linear-gradient(135deg, rgba(255, 250, 240, 0.98), rgba(229, 246, 225, 0.94) 48%, rgba(255, 239, 196, 0.9));
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 42%, var(--cream) 98%);
  pointer-events: none;
}

body.dark .hero::after {
  background: linear-gradient(180deg, transparent 42%, var(--cream) 98%);
}

body.dark .hero {
  background:
    radial-gradient(circle at 18% 20%, rgba(43, 86, 55, 0.62), transparent 36%),
    radial-gradient(circle at 82% 16%, rgba(156, 113, 37, 0.34), transparent 30%),
    linear-gradient(135deg, rgba(22, 25, 20, 0.98), rgba(29, 43, 30, 0.96) 50%, rgba(45, 39, 23, 0.92));
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 820px;
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 10px;
  color: color-mix(in srgb, var(--green) 72%, var(--ink));
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 12px;
  font-size: clamp(3.3rem, 10vw, 8.8rem);
  line-height: 0.92;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(1.8rem, 4vw, 3.35rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.hero-subtitle {
  max-width: 620px;
  color: var(--muted);
  font-size: clamp(1.1rem, 2.2vw, 1.45rem);
}

.hero-actions {
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 18px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button.primary {
  border-color: color-mix(in srgb, var(--green) 70%, var(--ink));
  background: var(--ink);
  color: var(--cream);
  box-shadow: var(--glow);
}

.button.secondary {
  background: var(--surface-solid);
  color: var(--ink);
}

.tools-band,
.add-section,
.gallery-section,
.collections,
.about-band {
  padding: clamp(58px, 8vw, 104px) clamp(18px, 5vw, 72px);
}

.tools-band,
.add-section,
.about-band {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(280px, 1.28fr);
  gap: clamp(28px, 5vw, 68px);
  align-items: start;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-solid) 58%, transparent);
}

.section-heading {
  max-width: 680px;
}

.section-heading p,
.about-band p {
  color: var(--muted);
  line-height: 1.8;
}

.section-heading.wide {
  max-width: 920px;
  margin-bottom: 32px;
}

.search-panel {
  display: grid;
  gap: 18px;
}

.search-box,
.add-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.search-box input,
.add-card input,
.add-card select,
.add-card textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--ink);
  padding: 16px 18px;
  outline: none;
}

.search-box input:focus,
.add-card input:focus,
.add-card select:focus,
.add-card textarea:focus {
  border-color: color-mix(in srgb, var(--green) 78%, var(--ink));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 20%, transparent);
}

.add-card {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(18px, 3vw, 28px);
  background: var(--surface-solid);
  box-shadow: 0 14px 44px rgba(64, 70, 54, 0.08);
}

.add-card textarea {
  min-height: 180px;
  line-height: 1.7;
  resize: vertical;
}

.new-category-field {
  display: none !important;
}

.new-category-field.show {
  display: grid !important;
}

.file-drop {
  min-height: 260px;
  place-items: center;
  border: 1px dashed color-mix(in srgb, var(--green) 56%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--pastel-green) 20%, var(--surface-solid));
  cursor: pointer;
  overflow: hidden;
  padding: 18px;
  text-align: center;
}

.file-drop input {
  display: none;
}

#imagePreview {
  display: none;
  max-width: 100%;
  max-height: 420px;
  border-radius: 8px;
  object-fit: contain;
}

#imagePreview.show {
  display: block;
}

.filter-row {
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-solid);
  color: var(--muted);
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
}

.chip.active,
.chip:hover {
  border-color: transparent;
  background: color-mix(in srgb, var(--pastel-green) 72%, var(--surface-solid));
  color: var(--ink);
}

.gallery-grid {
  column-count: 4;
  column-gap: 18px;
}

.prompt-card {
  display: inline-block;
  width: 100%;
  margin: 0 0 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-solid);
  box-shadow: 0 10px 32px rgba(64, 70, 54, 0.08);
  break-inside: avoid;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.prompt-card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--green) 58%, var(--line));
  box-shadow: var(--glow);
}

.image-button {
  width: 100%;
  display: block;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: zoom-in;
  overflow: hidden;
}

.prompt-card img {
  width: 100%;
  display: block;
  object-fit: cover;
  transition: transform 420ms ease;
}

.prompt-card:hover img {
  transform: scale(1.04);
}

.card-body {
  padding: 16px;
}

.card-kicker {
  color: color-mix(in srgb, var(--green) 76%, var(--ink));
  font-size: 0.78rem;
  font-weight: 800;
}

.card-body h3 {
  margin: 6px 0 8px;
  line-height: 1.2;
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--ink);
}

.prompt-preview {
  color: var(--muted);
  display: -webkit-box;
  min-height: 4.8em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-height: 1.6;
}

.copy-btn {
  width: 100%;
  margin-top: 14px;
  background: color-mix(in srgb, var(--cream-strong) 72%, var(--surface-solid));
  color: var(--ink);
}

.admin-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.admin-actions button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.admin-actions button:hover {
  border-color: color-mix(in srgb, var(--green) 58%, var(--line));
}

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

.collection-item {
  min-height: 118px;
  display: grid;
  align-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--pastel-green) 42%, var(--surface-solid)), var(--surface-solid));
}

.collection-item strong {
  font-size: 1.05rem;
}

.collection-item span {
  color: var(--muted);
  font-size: 0.9rem;
}

.about-band {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 18%, color-mix(in srgb, var(--pastel-green) 42%, transparent), transparent 30%),
    radial-gradient(circle at 88% 12%, color-mix(in srgb, var(--yellow) 24%, transparent), transparent 28%),
    color-mix(in srgb, var(--surface-solid) 74%, transparent);
}

.about-band::before {
  content: "";
  position: absolute;
  inset: 22px;
  border: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  border-radius: 8px;
  pointer-events: none;
}

.about-band > * {
  position: relative;
  z-index: 1;
}

.about-content,
.trust-panel,
.contact-panel {
  display: grid;
  gap: 22px;
}

.trust-panel,
.contact-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(20px, 3vw, 30px);
  background: color-mix(in srgb, var(--surface-solid) 84%, transparent);
  box-shadow: 0 18px 54px rgba(64, 70, 54, 0.1);
  backdrop-filter: blur(16px);
}

.trust-panel h3,
.contact-panel h3 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.65rem);
  line-height: 1.2;
}

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

.trust-card {
  position: relative;
  min-height: 112px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 84%, transparent);
  border-radius: 8px;
  padding: 18px 46px 18px 18px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface-solid) 94%, transparent), color-mix(in srgb, var(--pastel-green) 18%, var(--surface-solid)));
  box-shadow: 0 10px 28px rgba(64, 70, 54, 0.07);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.trust-card::after {
  content: "→";
  position: absolute;
  top: 16px;
  right: 18px;
  color: color-mix(in srgb, var(--green) 72%, var(--ink));
  font-size: 1.25rem;
  font-weight: 800;
}

.trust-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--green) 62%, var(--line));
  box-shadow: var(--glow);
}

.trust-card span {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.35;
}

.trust-card small {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.trust-card.highlight {
  grid-column: 1 / -1;
  min-height: 92px;
  background:
    linear-gradient(135deg, var(--ink), color-mix(in srgb, var(--ink) 78%, var(--green)));
  color: var(--cream);
}

.trust-card.highlight::after,
.trust-card.highlight small {
  color: color-mix(in srgb, var(--cream) 76%, var(--green));
}

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

.contact-list p {
  display: grid;
  gap: 4px;
  margin: 0;
  border: 1px solid color-mix(in srgb, var(--line) 84%, transparent);
  border-radius: 8px;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--cream-strong) 32%, var(--surface-solid));
}

.contact-list span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.contact-list a,
.site-footer a {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.contact-list a:hover,
.site-footer a:hover {
  color: color-mix(in srgb, var(--green) 58%, var(--ink));
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 30px clamp(18px, 5vw, 72px);
  border-top: 1px solid var(--line);
  color: var(--muted);
}

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

.footer-links a:hover {
  color: var(--ink);
}

.prompt-modal,
.admin-modal {
  width: min(1120px, calc(100vw - 28px));
  max-height: min(840px, calc(100vh - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--surface-solid);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.prompt-modal::backdrop,
.admin-modal::backdrop {
  background: rgba(21, 22, 18, 0.62);
  backdrop-filter: blur(12px);
}

.admin-modal {
  width: min(760px, calc(100vw - 28px));
}

.modal-form {
  display: grid;
  gap: 16px;
  padding: clamp(24px, 4vw, 42px);
}

.modal-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.modal-form input,
.modal-form select,
.modal-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--ink);
  padding: 14px 16px;
  outline: none;
}

.modal-form input:focus,
.modal-form select:focus,
.modal-form textarea:focus {
  border-color: color-mix(in srgb, var(--green) 78%, var(--ink));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 20%, transparent);
}

.modal-form textarea {
  min-height: 190px;
  line-height: 1.7;
  resize: vertical;
}

.modal-form .file-drop input {
  display: none;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  font-size: 1.6rem;
}

.modal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.82fr);
  gap: 0;
}

.modal-layout > img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(840px, calc(100vh - 28px));
  object-fit: contain;
  place-self: center;
  background: var(--gray);
}

.modal-copy {
  max-height: min(840px, calc(100vh - 28px));
  overflow: auto;
  padding: clamp(24px, 4vw, 42px);
}

.modal-copy p {
  color: var(--muted);
  line-height: 1.75;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 28px;
}

.meta-grid span {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: color-mix(in srgb, var(--gray) 48%, transparent);
}

.meta-grid strong {
  font-size: 0.72rem;
  text-transform: uppercase;
}

.meta-grid em {
  color: var(--muted);
  font-style: normal;
}

.copy-large {
  width: 100%;
  margin-top: 18px;
}

.toast,
.empty-state {
  display: none;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  border-radius: 8px;
  background: var(--ink);
  color: var(--cream);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  font-weight: 800;
}

.toast.show,
.empty-state.show {
  display: block;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1100px) {
  .gallery-grid {
    column-count: 3;
  }

  .collection-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .site-header,
  .site-footer,
  .tools-band,
  .add-section,
  .about-band,
  .modal-layout {
    grid-template-columns: 1fr;
  }

  .site-header {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .top-nav {
    grid-column: 1 / -1;
    justify-content: space-between;
    font-size: 0.94rem;
  }

  .hero {
    min-height: 720px;
    padding-top: 92px;
  }

  .hero-content {
    padding: 22px;
  }

  .gallery-grid {
    column-count: 2;
    column-gap: 12px;
  }

  .trust-links,
  .contact-list {
    grid-template-columns: 1fr;
  }

  .prompt-card {
    margin-bottom: 12px;
  }

  .card-body {
    padding: 13px;
  }

  .modal-layout > img {
    max-height: 46vh;
  }
}

@media (max-width: 520px) {
  .gallery-grid,
  .collection-grid {
    column-count: 1;
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: clamp(3rem, 18vw, 4.4rem);
  }

  .hero-actions .button,
  .copy-btn {
    width: 100%;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }
}
