:root {
  --bg: #f7f9fc; --card: #fff; --ink: #082d62; --muted: #667791;
  --line: #e2e8f0; --primary: #082d62; --primary-2: #16447c;
  --primary-soft: #edf3fa; --yellow: #ffcb05; --danger: #bf2525;
  --radius: 12px; --header-height: 82px; --sidebar-width: clamp(250px, 23vw, 320px);
  font-family: "Noto Sans Thai", system-ui, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body.menu-open { overflow: hidden; }
button, input { font: inherit; }
a { color: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
svg { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #c99300; outline-offset: 4px; }
.skip-link { position: fixed; top: -80px; left: 16px; padding: 10px 16px; background: var(--ink); color: white; z-index: 100; }
.skip-link:focus { top: 12px; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--header-height); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 32px; background: white; border-bottom: 2px solid var(--yellow); }
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; min-width: 0; }
.brand b { display: block; font-size: 20px; line-height: 1.4; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.brand-mark { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: var(--ink); color: var(--yellow); flex: none; }
.brand-mark svg { width: 27px; height: 27px; }
.top-actions { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; max-width: 30vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: white; }
.icon-btn:hover { background: var(--primary-soft); }
.mobile-menu { display: none; }
.layout { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); transition: grid-template-columns .22s ease; min-height: calc(100dvh - var(--header-height)); }
.sidebar { position: sticky; top: var(--header-height); height: calc(100dvh - var(--header-height)); min-width: 0; background: white; border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 28px 22px 24px; overflow: hidden; }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 18px; }
.sidebar-heading h2 { font-size: 27px; margin: 0; font-weight: 700; }
.sidebar-content { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.nav-all { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 7px; text-decoration: none; font-size: 18px; font-weight: 600; border-left: 5px solid transparent; }
.nav-all svg { width: 24px; height: 24px; }
.nav-all.selected { color: white; background: var(--ink); border-left-color: var(--yellow); }
.nav-all:not(.selected):hover { background: var(--primary-soft); }
.sidebar-label { font-size: 14px; color: var(--muted); margin: 26px 8px 12px; font-weight: 600; }
.sidebar-album { display: flex; gap: 12px; align-items: center; padding: 10px 8px; margin: 0 0 4px; border-radius: 8px; text-decoration: none; }
.sidebar-album:hover, .sidebar-album.selected { background: var(--primary-soft); }
.sidebar-album.selected { box-shadow: inset 3px 0 var(--yellow); }
.sidebar-thumb { width: 84px; height: 94px; flex: none; overflow: hidden; border-radius: 6px; background: var(--primary-soft); display: grid; place-items: center; color: var(--muted); }
.sidebar-thumb img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-album-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sidebar-album-info b { font-size: 16px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.sidebar-album-info small { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 14px; }
.sidebar-message { font-size: 13px; color: var(--muted); padding: 4px 8px; overflow-wrap: anywhere; }
.sidebar-more { border: 0; background: var(--primary-soft); color: var(--ink); padding: 9px; width: 100%; border-radius: 7px; font-size: 13px; }
.sidebar-more:disabled { opacity: .6; }
.collapse-btn { display: flex; gap: 14px; align-items: center; margin: 20px 8px 0; padding: 12px 16px; border: 0; border-radius: 7px; color: var(--ink); background: var(--bg); font-size: 14px; flex: none; }
.collapse-btn:hover { background: var(--primary-soft); }
.sidebar-collapsed { --sidebar-width: 76px; }
.sidebar-collapsed .sidebar { padding: 28px 10px 24px; }
.sidebar-collapsed .sidebar-heading { justify-content: center; }
.sidebar-collapsed .sidebar-heading h2, .sidebar-collapsed .nav-all span, .sidebar-collapsed .sidebar-label, .sidebar-collapsed #sidebarAlbums, .sidebar-collapsed .collapse-btn span { display: none; }
.sidebar-collapsed .nav-all { justify-content: center; padding: 12px 7px; border-left-width: 3px; }
.sidebar-collapsed .collapse-btn { justify-content: center; padding: 12px 8px; margin: 20px 0 0; }
.sidebar-collapsed .collapse-btn svg { transform: rotate(180deg); }
.sidebar-scrim { display: none; }
.container { width: 100%; min-width: 0; max-width: 1800px; margin: 0 auto; padding: 32px 40px 24px; }
.container:focus { outline: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 7px; padding: 10px 17px; background: var(--primary); color: #fff; font-weight: 600; font-size: 14px; text-decoration: none; transition: background .15s; }
.btn:hover { background: var(--primary-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
#loginBtn { background: var(--ink); color: white; border-color: var(--ink); padding: 10px 16px; font-size: 14px; }
#loginBtn:hover { background: var(--primary-2); }
.hero { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 20px; margin: 0 0 26px; }
.hero h1 { margin: 0; font-size: clamp(29px, 2.9vw, 44px); letter-spacing: -.025em; line-height: 1.35; }
.hero p { margin: 6px 0 0; color: var(--muted); font-size: 16px; }
.tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; max-width: 100%; }
.search { display: flex; align-items: center; gap: 10px; background: white; border: 1px solid #d9e1ec; border-radius: 30px; padding: 11px 18px; width: 290px; max-width: 100%; }
.search:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px var(--primary-soft); }
.search input { border: 0; outline: 0; flex: 1; background: transparent; min-width: 0; width: 100%; font-size: 14px; color: var(--ink); }
.search svg { color: var(--muted); }
.featured { display: grid; grid-template-columns: 56% minmax(0, 1fr); background: white; border-radius: 10px; overflow: hidden; text-decoration: none; margin-bottom: 28px; }
.featured:hover h2 { color: var(--primary-2); }
.featured-cover { aspect-ratio: 1.65; min-height: 290px; height: 100%; overflow: hidden; display: grid; place-items: center; background: var(--primary-soft); color: #879fbd; }
.featured-cover img { width: 100%; height: 100%; object-fit: contain; }
.featured-cover > svg { width: 64px; height: 64px; }
.featured-copy { position: relative; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; padding: 28px 24px 24px 32px; }
.featured-copy::before { content: ""; position: absolute; width: 4px; background: var(--yellow); border-radius: 2px; top: 16px; bottom: 16px; left: 16px; }
.eyebrow { color: var(--muted); font-size: 14px; font-weight: 600; }
.featured h2 { font-size: clamp(27px, 2.5vw, 38px); line-height: 1.4; margin: 14px 0 16px; letter-spacing: -.015em; overflow-wrap: anywhere; }
.featured p { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.featured-bottom { margin-top: auto; display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 12px; }
.album-open { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--yellow); color: var(--ink); }
.section-title { font-size: 25px; line-height: 1.4; margin: 0 0 18px; }
.grid { display: grid; gap: 28px 20px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.album { min-width: 0; text-decoration: none; display: flex; flex-direction: column; }
.cover { aspect-ratio: 1.75; border-radius: 7px; background: var(--primary-soft); display: grid; place-items: center; color: #879fbd; overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: contain; display: block; transition: transform .2s ease; }
.album:hover .cover img { transform: scale(1.025); }
.album:hover h3 { text-decoration: underline; text-underline-offset: 4px; }
.cover svg { width: 42px; height: 42px; }
.album-body { padding: 10px 0 0; }
.album-body h3 { margin: 0 0 7px; font-size: 16px; line-height: 1.5; overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: 13px; display: flex; gap: 8px 16px; flex-wrap: wrap; align-items: center; }
.meta span { display: inline-flex; align-items: center; gap: 6px; }
.meta svg { width: 16px; height: 16px; }
.page-footer { margin-top: 36px; padding: 18px 0 0; border-top: 1px solid var(--line); text-align: center; color: var(--muted); font-size: 12px; }
.empty { text-align: center; padding: 70px 24px; color: var(--muted); background: white; border-radius: var(--radius); border: 1px solid var(--line); }
.empty > svg { width: 44px; height: 44px; color: #8498b4; }
.empty h2 { font-size: 20px; font-weight: 600; color: var(--ink); margin: 12px 0 4px; }
.empty p { margin: 0; font-size: 14px; }
.empty .btn { margin: 12px auto 0; display: flex; width: fit-content; }
.more { display: flex; justify-content: center; margin-top: 28px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; margin-bottom: 14px; font-size: 14px; }
.back:hover { color: var(--ink); }
.album-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; align-items: start; margin-bottom: 26px; }
.album-head h1 { margin: 0 0 8px; font-size: 30px; line-height: 1.45; overflow-wrap: anywhere; }
.dropzone { border: 2px dashed #b9c9df; background: #fff; border-radius: var(--radius); padding: 24px; text-align: center; color: var(--muted); margin-bottom: 20px; cursor: pointer; }
.dropzone.over { background: var(--primary-soft); border-color: var(--primary); }
.dropzone b { color: var(--primary); }
.progress { margin: -6px 0 20px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font-size: 14px; }
.bar { height: 6px; background: var(--primary-soft); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--primary); width: 0; transition: width .2s; }
.photos { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.photo { position: relative; aspect-ratio: 4/3; border-radius: 7px; overflow: hidden; background: var(--primary-soft); cursor: zoom-in; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .ph-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 5px; opacity: 0; transition: opacity .15s; }
.photo:hover .ph-actions, .photo:focus-within .ph-actions { opacity: 1; }
@media (hover: none) { .photo .ph-actions { opacity: 1; } }
.ph-actions button { width: 34px; height: 34px; border-radius: 7px; border: 0; display: grid; place-items: center; background: rgba(255,255,255,.95); color: var(--ink); }
.ph-actions button.del { color: var(--danger); }
.badge { position: absolute; left: 8px; top: 8px; background: var(--primary); color: white; font-size: 11px; padding: 3px 9px; border-radius: 5px; }
dialog { border: 0; border-radius: 14px; padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(8,45,98,.2); color: var(--ink); }
dialog::backdrop { background: rgba(8,25,50,.5); }
dialog form { padding: 24px; }
dialog h2 { margin: 0 0 4px; font-size: 22px; }
dialog p.hint { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
label.field { display: block; margin-bottom: 14px; font-size: 14px; font-weight: 500; }
label.field input { display: block; width: 100%; margin-top: 5px; padding: 10px 12px; border-radius: 7px; border: 1px solid var(--line); color: var(--ink); font-size: 16px; }
label.field input:focus { border-color: var(--primary); }
.err { color: var(--danger); font-size: 13px; min-height: 1.2em; margin: 0 0 8px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(5,13,25,.97); display: flex; align-items: center; justify-content: center; padding: 66px 72px 90px; color: white; }
.lightbox img { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.lb-status { text-align: center; padding: 20px; color: #ced9e6; }
.lb-btn { position: absolute; border: 1px solid #ffffff26; background: #ffffff16; color: white; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; }
.lb-btn:hover { background: #ffffff30; }
.lb-close { top: max(16px, env(safe-area-inset-top)); right: 18px; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lb-bar { position: absolute; bottom: 0; left: 0; right: 0; display: flex; gap: 24px; align-items: center; justify-content: space-between; padding: 16px 24px max(16px, env(safe-area-inset-bottom)); border-top: 1px solid #ffffff1c; color: #cbd5e1; font-size: 14px; }
.lb-bar > div { min-width: 0; }
#lbCount { display: block; color: white; font-variant-numeric: tabular-nums; }
.lb-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 65vw; color: #a3b4cb; font-size: 12px; }
.lb-bar a { display: inline-flex; align-items: center; gap: 8px; flex: none; color: white; text-decoration: none; padding: 9px 13px; border: 1px solid #ffffff35; border-radius: 7px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; background: var(--ink); color: white; padding: 11px 18px; border-radius: 8px; font-size: 14px; max-width: calc(100vw - 32px); }
.toast.error { background: var(--danger); }
@media (min-width: 1700px) { .photos { grid-template-columns: repeat(4, minmax(0,1fr)); } }
@media (max-width: 1180px) {
  :root { --sidebar-width: 250px; }
  .container { padding: 26px 24px; }
  .hero h1 { font-size: 30px; }
  .hero p { font-size: 14px; }
  .hero .tools { width: 100%; }
  .search { width: 100%; }
  .hero .tools .search { flex: 1; }
  .featured h2 { font-size: 25px; }
  .featured-copy { padding: 24px 20px 22px 28px; }
  .featured-copy::before { left: 12px; }
  .featured-bottom { flex-wrap: wrap; }
  .featured-cover { min-height: 300px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  :root { --header-height: 68px; }
  .topbar { gap: 10px; padding: 10px 16px; }
  .mobile-menu { display: inline-flex; width: 36px; height: 36px; }
  .brand { gap: 10px; flex: 1; }
  .brand-mark { display: none; }
  .brand b { font-size: 16px; }
  .brand small { font-size: 11px; }
  #loginBtn { font-size: 12px; padding: 8px 10px; }
  #loginBtn svg { display: none; }
  .who { max-width: 24vw; font-size: 12px; }
  .who svg { display: none; }
  .layout { display: block; }
  .sidebar { position: fixed; left: 0; top: var(--header-height); width: min(320px, calc(100vw - 48px)); z-index: 42; transform: translateX(-100%); transition: transform .2s ease; padding: 24px 20px; }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-scrim:not([hidden]) { display: block; position: fixed; inset: var(--header-height) 0 0; z-index: 40; border: 0; background: rgba(5,18,40,.45); }
  .container { padding: 26px 20px; }
  .hero { margin-bottom: 22px; gap: 18px; }
  .hero h1 { font-size: 29px; }
  .featured { grid-template-columns: 1fr; margin-bottom: 26px; }
  .featured-cover { aspect-ratio: 1.7; min-height: 0; height: auto; }
  .featured-copy { padding: 22px 22px 22px 32px; }
  .featured-copy::before { top: 20px; bottom: 20px; left: 16px; }
  .featured h2 { font-size: 25px; margin: 10px 0 10px; }
  .featured p { margin-bottom: 18px; }
  .section-title { font-size: 23px; }
  .grid { gap: 24px 14px; }
  .album-body h3 { font-size: 14px; }
  .meta { font-size: 12px; gap: 5px 10px; }
  .album-body .meta { flex-direction: column; align-items: flex-start; }
  .cover { aspect-ratio: 4/3; }
  .photos { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
  .album-head h1 { font-size: 26px; }
  .lightbox { padding: 70px 12px 100px; }
  .lb-prev, .lb-next { top: auto; bottom: 102px; transform: none; width: 42px; height: 42px; background: #142237d9; }
  .lb-bar { padding-left: 16px; padding-right: 16px; gap: 10px; }
  .lb-name { max-width: 50vw; }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }

/* แก้ไขอัลบั้ม / เลือกภาพ / ดาวน์โหลด / อัพโหลดจากหน้ารวม */
label.field textarea, label.field select { display: block; width: 100%; margin-top: 5px; padding: 10px 12px; border-radius: 7px; border: 1px solid var(--line); color: var(--ink); font: inherit; font-size: 16px; background: #fff; }
label.field textarea { resize: vertical; }
label.field textarea:focus, label.field select:focus { border-color: var(--primary); outline: 0; }
label.field[hidden] { display: none; }
.seg { display: flex; gap: 8px; margin-bottom: 14px; }
.seg label { flex: 1; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 7px; font-size: 14px; cursor: pointer; }
.seg label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.album-desc { margin: 10px 0 0; color: var(--ink); white-space: pre-line; max-width: 70ch; font-size: 15px; line-height: 1.7; }
.btn.on { background: var(--primary-soft); border-color: var(--primary); }
.select-bar { position: sticky; top: var(--header-height); z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--primary); border-radius: 8px; padding: 10px 12px; margin-bottom: 16px; box-shadow: 0 6px 18px rgba(8, 45, 98, .08); }
.select-bar > span { margin-right: auto; font-size: 14px; }
.photos.selecting .photo { cursor: pointer; }
.photo.picked { outline: 3px solid var(--primary); outline-offset: -3px; }
.photo.picked img { opacity: .82; }
.photo.locked { opacity: .45; cursor: not-allowed; }
.photo .tick { position: absolute; top: 8px; left: 8px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; background: rgba(0, 0, 0, .25); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.photo.picked .tick { background: var(--primary); }
.dl-parts { display: grid; gap: 8px; margin-bottom: 8px; }
.dl-parts .btn { justify-content: flex-start; }
