@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700&display=swap');

:root {
  --gallery-blue: #0749ad;
  --gallery-blue-dark: #052f72;
  --gallery-blue-deep: #031d49;
  --gallery-orange: #ff720c;
  --gallery-ink: #14213d;
  --gallery-muted: #64748b;
  --gallery-line: #dce5f2;
  --gallery-soft: #f3f7fc;
  --gallery-white: #fff;
  --gallery-shadow: 0 18px 50px rgba(4, 45, 105, .12);
  --gallery-radius: 22px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body.gallery-public-body,
body.gallery-admin-body {
  margin: 0;
  color: var(--gallery-ink);
  font-family: "Noto Sans Thai", Tahoma, sans-serif;
  line-height: 1.65;
  overflow-x: hidden;
  background: var(--gallery-white);
}
button, input, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

.gallery-container { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.gallery-eyebrow { margin: 0 0 8px; color: var(--gallery-orange); font-size: .78rem; font-weight: 700; letter-spacing: .14em; }
.gallery-breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-bottom: 44px; color: rgba(255,255,255,.72); font-size: .9rem; }
.gallery-breadcrumb a:hover { color: #fff; text-decoration: underline; }

.gallery-hero {
  position: relative;
  min-height: 460px;
  display: grid;
  align-items: center;
  color: #fff;
  background:
    radial-gradient(circle at 80% 15%, rgba(40,131,255,.32), transparent 33%),
    linear-gradient(135deg, var(--gallery-blue-deep), var(--gallery-blue));
  overflow: hidden;
}
.gallery-hero::after { content: ""; position: absolute; right: -80px; bottom: -180px; width: 480px; height: 480px; border: 70px solid rgba(255,255,255,.055); border-radius: 50%; }
.gallery-hero .gallery-container { position: relative; z-index: 1; padding-block: 58px; }
.gallery-hero h1 { max-width: 800px; margin: 0; font-size: clamp(2.2rem, 5vw, 4.5rem); line-height: 1.17; letter-spacing: -.03em; }
.gallery-hero > .gallery-container > p:not(.gallery-eyebrow) { max-width: 740px; margin: 18px 0 0; color: rgba(255,255,255,.8); font-size: clamp(1rem, 2vw, 1.18rem); }
.gallery-stats { display: flex; gap: 38px; margin-top: 34px; }
.gallery-stats div { display: grid; grid-template-columns: auto auto; align-items: baseline; gap: 10px; }
.gallery-stats strong { font-size: 2rem; line-height: 1; }
.gallery-stats span { color: rgba(255,255,255,.7); font-size: .9rem; }

.gallery-year-nav { position: relative; z-index: 2; background: rgba(255,255,255,.96); box-shadow: 0 8px 28px rgba(4,45,105,.08); backdrop-filter: blur(12px); }
.gallery-year-nav .gallery-container { display: flex; gap: 10px; padding-block: 16px; overflow-x: auto; scrollbar-width: none; }
.gallery-year-nav .gallery-container::-webkit-scrollbar { display: none; }
.gallery-year-nav a { flex: 0 0 auto; display: flex; align-items: center; gap: 9px; min-height: 43px; padding: 8px 17px; border: 1px solid var(--gallery-line); border-radius: 999px; color: #38506e; font-weight: 600; transition: .2s ease; }
.gallery-year-nav a:hover, .gallery-year-nav a.active { border-color: var(--gallery-blue); color: #fff; background: var(--gallery-blue); }
.gallery-year-nav small { opacity: .75; font-size: .72rem; font-weight: 500; }

.gallery-content { padding: 70px 0 96px; background: linear-gradient(#f8fbff, #fff 460px); }
.gallery-year-section + .gallery-year-section { margin-top: 76px; }
.gallery-year-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 26px; padding-bottom: 16px; border-bottom: 1px solid var(--gallery-line); }
.gallery-year-heading span { color: var(--gallery-muted); font-size: .86rem; }
.gallery-year-heading h2 { margin: 1px 0 0; color: var(--gallery-blue-dark); font-size: clamp(1.8rem, 4vw, 2.7rem); line-height: 1.15; }
.gallery-year-heading p { margin: 0; color: var(--gallery-muted); }
.gallery-album-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 26px; }
.gallery-album-card { display: flex; min-width: 0; flex-direction: column; overflow: hidden; border: 1px solid var(--gallery-line); border-radius: var(--gallery-radius); background: #fff; box-shadow: 0 7px 22px rgba(4,45,105,.06); transition: transform .25s ease, box-shadow .25s ease; }
.gallery-album-card:hover { transform: translateY(-7px); box-shadow: var(--gallery-shadow); }
.gallery-card-image { position: relative; display: block; aspect-ratio: 3 / 2; overflow: hidden; background: #dbe7f7; }
.gallery-card-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.gallery-album-card:hover .gallery-card-image img { transform: scale(1.045); }
.gallery-photo-count { position: absolute; right: 14px; bottom: 14px; padding: 7px 12px; color: #fff; border-radius: 999px; background: rgba(3,29,73,.86); font-size: .78rem; font-weight: 600; backdrop-filter: blur(5px); }
.gallery-no-cover { width: 100%; height: 100%; display: grid; place-content: center; text-align: center; color: #fff; background: linear-gradient(135deg, var(--gallery-blue-dark), var(--gallery-blue)); font-weight: 700; letter-spacing: .1em; }
.gallery-no-cover span { display: block; margin-top: 5px; font-size: .75rem; font-weight: 400; letter-spacing: normal; opacity: .7; }
.gallery-card-body { display: flex; flex: 1; flex-direction: column; padding: 23px; }
.gallery-card-date { margin-bottom: 9px; color: var(--gallery-orange); font-size: .82rem; font-weight: 600; }
.gallery-card-body h3 { margin: 0; color: var(--gallery-blue-dark); font-size: 1.18rem; line-height: 1.45; }
.gallery-card-body h3 a:hover { color: var(--gallery-blue); }
.gallery-card-body p { margin: 11px 0 0; color: var(--gallery-muted); font-size: .9rem; }
.gallery-card-body .gallery-location { color: #3d5270; }
.gallery-card-link { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 20px; color: var(--gallery-blue); font-size: .9rem; font-weight: 700; }
.gallery-card-link span { font-size: 1.25rem; transition: transform .2s ease; }
.gallery-card-link:hover span { transform: translateX(5px); }

.gallery-album-hero { color: #fff; background: linear-gradient(135deg, var(--gallery-blue-deep), var(--gallery-blue)); }
.gallery-album-hero .gallery-container { padding-block: 52px 65px; }
.gallery-album-hero .gallery-breadcrumb { margin-bottom: 30px; }
.gallery-back { display: inline-block; margin-bottom: 24px; color: rgba(255,255,255,.78); font-size: .9rem; }
.gallery-back:hover { color: #fff; }
.gallery-album-hero h1 { max-width: 970px; margin: 0; font-size: clamp(2rem, 4.8vw, 3.8rem); line-height: 1.25; }
.gallery-album-meta { display: flex; flex-wrap: wrap; gap: 12px 25px; margin-top: 23px; color: rgba(255,255,255,.82); }
.gallery-album-description { max-width: 820px; margin: 22px 0 0; padding-top: 22px; border-top: 1px solid rgba(255,255,255,.16); color: rgba(255,255,255,.78); }
.gallery-photo-section { min-height: 420px; padding: 55px 0 90px; background: #f6f9fd; }
.gallery-photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; }
.gallery-photo-grid figure { margin: 0; overflow: hidden; border-radius: 16px; background: #fff; box-shadow: 0 7px 22px rgba(4,45,105,.08); }
.gallery-photo-grid button { position: relative; width: 100%; padding: 0; border: 0; aspect-ratio: 4 / 3; cursor: zoom-in; overflow: hidden; background: #dce6f3; }
.gallery-photo-grid img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease, filter .4s ease; }
.gallery-photo-grid button > span { position: absolute; inset: auto 12px 12px auto; padding: 7px 11px; color: #fff; border-radius: 999px; background: rgba(3,29,73,.8); font-size: .75rem; opacity: 0; transform: translateY(6px); transition: .25s ease; }
.gallery-photo-grid button:hover img { transform: scale(1.04); filter: brightness(.88); }
.gallery-photo-grid button:hover > span { opacity: 1; transform: translateY(0); }
.gallery-photo-grid figcaption { padding: 13px 16px 15px; color: var(--gallery-muted); font-size: .86rem; }

.gallery-lightbox[hidden] { display: none; }
.gallery-lightbox { position: fixed; inset: 0; z-index: 99999; display: grid; grid-template-columns: 70px minmax(0,1fr) 70px; align-items: center; padding: 32px; background: rgba(1,10,28,.96); }
.gallery-lightbox-content { display: grid; justify-items: center; max-height: calc(100vh - 64px); }
.gallery-lightbox-content img { max-width: 100%; max-height: calc(100vh - 130px); object-fit: contain; }
.gallery-lightbox-content p { margin: 14px 0 0; color: rgba(255,255,255,.85); text-align: center; }
.gallery-lightbox-content span { margin-top: 4px; color: rgba(255,255,255,.55); font-size: .82rem; }
.gallery-lightbox button { color: #fff; border: 0; background: transparent; cursor: pointer; }
.gallery-lightbox-prev, .gallery-lightbox-next { font-size: 4rem; opacity: .75; }
.gallery-lightbox-prev:hover, .gallery-lightbox-next:hover { opacity: 1; }
.gallery-lightbox-close { position: absolute; top: 14px; right: 22px; font-size: 2.6rem; line-height: 1; }
body.gallery-lightbox-open { overflow: hidden; }

.gallery-empty { padding: 70px 25px; border: 1px dashed #bfd0e6; border-radius: var(--gallery-radius); background: #fff; text-align: center; }
.gallery-empty > div { color: var(--gallery-blue); font-size: 2.8rem; }
.gallery-empty h1, .gallery-empty h2, .gallery-empty h3 { margin: 7px 0; color: var(--gallery-blue-dark); }
.gallery-empty p { margin: 7px auto 24px; color: var(--gallery-muted); }
.gallery-empty.compact { padding: 34px 20px; }

.gallery-btn { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 44px; padding: 10px 18px; border: 1px solid transparent; border-radius: 11px; cursor: pointer; font-weight: 600; transition: .2s ease; }
.gallery-btn.primary { color: #fff; background: var(--gallery-blue); box-shadow: 0 7px 16px rgba(7,73,173,.2); }
.gallery-btn.primary:hover { background: var(--gallery-blue-dark); }
.gallery-btn.soft { color: var(--gallery-blue); background: #edf4ff; }
.gallery-btn.soft:hover { background: #dfeeff; }
.gallery-btn.outline { color: #41536b; border-color: var(--gallery-line); background: #fff; }
.gallery-btn.danger, button.danger { color: #b42318; background: #fff1f0; }
.gallery-btn.small { min-height: 36px; padding: 7px 12px; font-size: .8rem; }

/* Admin */
.gallery-admin-body { min-height: 100vh; background: #f0f4f9 !important; }
.gallery-admin-topbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; min-height: 70px; padding: 12px max(24px, calc((100% - 1180px) / 2)); color: #fff; background: var(--gallery-blue-deep); }
.gallery-admin-topbar div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; }
.gallery-admin-topbar strong { font-size: 1.25rem; }
.gallery-admin-topbar span { color: rgba(255,255,255,.66); font-size: .84rem; }
.gallery-admin-topbar nav { display: flex; gap: 8px; }
.gallery-admin-topbar nav a { padding: 7px 12px; border: 1px solid rgba(255,255,255,.2); border-radius: 8px; font-size: .84rem; }
.gallery-admin-shell { width: min(1180px, calc(100% - 40px)); margin: 34px auto 80px; }
.gallery-admin-panel { margin-top: 24px; padding: 28px; border: 1px solid #dce4ef; border-radius: 18px; background: #fff; box-shadow: 0 7px 26px rgba(4,45,105,.06); }
.gallery-panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 22px; }
.gallery-panel-heading h1, .gallery-panel-heading h2 { margin: 0; color: var(--gallery-blue-dark); line-height: 1.3; }
.gallery-count { display: inline-grid; min-width: 29px; height: 29px; place-items: center; padding-inline: 7px; color: var(--gallery-blue); border-radius: 999px; background: #eaf2ff; font-size: .78rem; vertical-align: middle; }
.gallery-form { display: grid; gap: 16px; }
.gallery-form-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
.gallery-form label, .gallery-mini-form label { display: grid; gap: 7px; color: #334155; font-size: .88rem; font-weight: 600; }
.gallery-form input, .gallery-form textarea, .gallery-mini-form input { width: 100%; padding: 11px 13px; color: #152238; border: 1px solid #ccd8e8; border-radius: 9px; outline: 0; background: #fff; font-weight: 400; }
.gallery-form textarea { resize: vertical; }
.gallery-form input:focus, .gallery-form textarea:focus, .gallery-mini-form input:focus { border-color: var(--gallery-blue); box-shadow: 0 0 0 3px rgba(7,73,173,.1); }
.gallery-form-grid .wide { grid-column: 1 / -1; }
.gallery-checkbox { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 10px !important; }
.gallery-checkbox input { width: 18px; height: 18px; }
.gallery-form-actions { display: flex; gap: 10px; }
.gallery-alert { margin-bottom: 18px; padding: 13px 16px; border-radius: 10px; font-size: .9rem; }
.gallery-alert.success { color: #086544; border: 1px solid #a9dfc9; background: #eafaf4; }
.gallery-alert.warning { color: #7a4a00; border: 1px solid #f4d48b; background: #fff8e6; }
.gallery-alert.error { color: #9b1c16; border: 1px solid #f0b5b1; background: #fff0ef; }
.gallery-upload-box { display: flex; align-items: end; gap: 16px; margin-bottom: 24px; padding: 20px; border: 2px dashed #b8cbe4; border-radius: 14px; background: #f7faff; }
.gallery-upload-box label { flex: 1; display: grid; gap: 5px; }
.gallery-upload-box label span { color: var(--gallery-muted); font-size: .78rem; }
.gallery-upload-box input { margin-top: 8px; }
.gallery-admin-images { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; }
.gallery-admin-image { overflow: hidden; border: 1px solid var(--gallery-line); border-radius: 14px; }
.gallery-admin-image.is-cover { border: 2px solid var(--gallery-orange); }
.gallery-admin-image-preview { position: relative; aspect-ratio: 4 / 3; background: #e7edf5; }
.gallery-admin-image-preview img { width: 100%; height: 100%; object-fit: cover; }
.gallery-admin-image-preview span { position: absolute; top: 9px; left: 9px; padding: 5px 9px; color: #fff; border-radius: 999px; background: var(--gallery-orange); font-size: .72rem; font-weight: 700; }
.gallery-mini-form { display: grid; gap: 10px; padding: 13px; }
.gallery-mini-form input { padding: 8px 10px; font-size: .78rem; }
.gallery-image-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 13px 13px; }
.gallery-image-actions form { margin: 0; }
.gallery-image-actions button { min-height: 31px; padding: 5px 9px; color: #38506e; border: 0; border-radius: 7px; background: #eef3f9; cursor: pointer; font-size: .74rem; }
.gallery-image-actions button:disabled { opacity: .35; cursor: not-allowed; }
.gallery-admin-albums { display: grid; gap: 12px; }
.gallery-admin-albums > article { display: grid; grid-template-columns: 150px minmax(0,1fr) auto; align-items: center; gap: 18px; padding: 12px; border: 1px solid var(--gallery-line); border-radius: 13px; }
.gallery-admin-album-thumb { display: grid; width: 150px; aspect-ratio: 3/2; place-items: center; overflow: hidden; border-radius: 9px; color: var(--gallery-muted); background: #e8eef6; font-size: .76rem; }
.gallery-admin-album-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery-admin-album-info h3 { margin: 5px 0 2px; color: var(--gallery-blue-dark); font-size: 1rem; }
.gallery-admin-album-info p { margin: 0; color: var(--gallery-muted); font-size: .8rem; }
.gallery-status { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: .67rem; font-weight: 700; }
.gallery-status.published { color: #086544; background: #e1f7ee; }
.gallery-status.draft { color: #6b7280; background: #eef0f3; }
.gallery-admin-album-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.gallery-admin-album-actions form { margin: 0; }
.gallery-login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 30px 20px; background: radial-gradient(circle at top right, rgba(44,128,246,.22), transparent 33%), linear-gradient(135deg, var(--gallery-blue-deep), var(--gallery-blue)); }
.gallery-login-card { width: min(460px, 100%); padding: 34px; border-radius: 20px; background: #fff; box-shadow: 0 30px 70px rgba(0,0,0,.24); }
.gallery-login-card h1 { margin: 0; color: var(--gallery-blue-dark); }
.gallery-login-card > p:not(.gallery-eyebrow) { margin: 8px 0 20px; color: var(--gallery-muted); }
.gallery-back-link { display: inline-block; margin-top: 20px; color: var(--gallery-blue); font-size: .86rem; }

@media (max-width: 900px) {
  .gallery-album-grid, .gallery-photo-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .gallery-admin-images { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .gallery-admin-albums > article { grid-template-columns: 120px minmax(0,1fr); }
  .gallery-admin-album-thumb { width: 120px; }
  .gallery-admin-album-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 640px) {
  .gallery-container, .gallery-admin-shell { width: min(100% - 28px, 1180px); }
  .gallery-hero { min-height: 420px; }
  .gallery-hero .gallery-container { padding-block: 40px; }
  .gallery-breadcrumb { margin-bottom: 30px; font-size: .78rem; }
  .gallery-stats { gap: 20px; }
  .gallery-stats div { display: block; }
  .gallery-stats span { display: block; margin-top: 7px; }
  .gallery-content { padding: 45px 0 68px; }
  .gallery-year-heading { align-items: start; }
  .gallery-album-grid, .gallery-photo-grid, .gallery-admin-images { grid-template-columns: 1fr; }
  .gallery-card-image { aspect-ratio: 16 / 10; }
  .gallery-album-hero .gallery-container { padding-block: 36px 48px; }
  .gallery-photo-section { padding: 30px 0 65px; }
  .gallery-lightbox { grid-template-columns: 42px minmax(0,1fr) 42px; padding: 18px 5px; }
  .gallery-lightbox-prev, .gallery-lightbox-next { font-size: 3rem; }
  .gallery-admin-topbar { align-items: start; padding: 13px 15px; }
  .gallery-admin-topbar div { display: grid; gap: 0; }
  .gallery-admin-topbar nav { display: grid; }
  .gallery-admin-panel { padding: 19px 15px; }
  .gallery-panel-heading { align-items: start; }
  .gallery-form-grid { grid-template-columns: 1fr; }
  .gallery-upload-box { align-items: stretch; flex-direction: column; }
  .gallery-admin-albums > article { grid-template-columns: 100px minmax(0,1fr); gap: 12px; }
  .gallery-admin-album-thumb { width: 100px; }
  .gallery-admin-album-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .gallery-admin-album-actions .gallery-btn { width: 100%; }
  .gallery-login-card { padding: 26px 20px; }
}
