/* SKA1 media archive — "Editorial Media Archive".
   Navy masthead, warm-white page, white surfaces, gold as a small accent.
   Depth comes from spacing, type and a two-level navy-tinted shadow — no gradients/glass/autoplay motion. */

/* ---------- Tokens ---------- */
:root {
  /* colour */
  --bg: #f7f5f0;            /* warm white page */
  --surface: #ffffff;       /* cards, panels */
  --stage: #efebe3;         /* document stage behind previews */
  --stage-line: #e2dccf;
  --ink: #1a1f27;
  --muted: #5a616c;
  --line: #e4dfd5;
  --line-strong: #c9c2b4;
  --navy: #14305a;
  --navy-700: #1e4380;
  --navy-050: #eef2f8;
  --navy-100: #dfe6f1;
  --gold: #b8892b;
  --gold-050: #f7efdc;
  --focus: #c2932f;
  --text: var(--ink);

  /* type */
  --font: "Sukhumvit Set", "Leelawadee UI", "Noto Sans Thai", "Thonburi", system-ui, sans-serif;
  --fs-xs: 13px;
  --fs-sm: 15px;
  --fs-md: 17px;
  --fs-lg: 19px;
  --fs-xl: 22px;
  --fs-2xl: 28px;

  /* space / shape */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --radius: var(--r-md);

  /* elevation (navy-tinted) */
  --shadow-1: 0 1px 2px rgba(20, 48, 90, 0.06), 0 1px 1px rgba(20, 48, 90, 0.04);
  --shadow-2: 0 10px 24px -10px rgba(20, 48, 90, 0.22), 0 2px 6px rgba(20, 48, 90, 0.08);
  --shadow-doc: 0 1px 2px rgba(26, 31, 39, 0.10), 0 6px 14px -6px rgba(26, 31, 39, 0.28);

  /* motion */
  --dur: 180ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  --wrap: 1200px;
  --read: 800px;

  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-size: var(--fs-md); line-height: 1.7; background: var(--bg); color: var(--ink); overflow-wrap: anywhere; }
a { color: var(--navy-700); text-underline-offset: 3px; }
a:hover { color: var(--navy); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; height: auto; }
svg.icon { flex: none; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--s4); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: var(--s2); background: var(--surface); padding: var(--s2) var(--s3); z-index: 10; border-radius: var(--r-sm); box-shadow: var(--shadow-2); }
.skip:focus { left: var(--s2); }
[hidden] { display: none !important; } /* must beat component display rules (.btn is inline-flex) */
.muted { color: var(--muted); }

/* ---------- Masthead ---------- */
.site-header { background: var(--navy); color: #fff; border-bottom: 3px solid var(--gold); }
.site-header.band-below { border-bottom: 0; padding-bottom: 40px; }
.header-row { display: flex; align-items: center; min-height: 64px; padding-top: var(--s3); padding-bottom: var(--s3); }
.band-below .header-row { padding-bottom: var(--s4); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; line-height: 1.25; min-width: 0; }
.brand:hover { color: #fff; }
.brand-logo { flex: none; width: 44px; height: 44px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 2px 6px rgba(0, 0, 0, 0.25); }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
@media (max-width: 639px) { .brand-logo { width: 38px; height: 38px; } }
.brand-title { font-weight: 700; font-size: var(--fs-lg); letter-spacing: 0.1px; }
.brand-org { font-size: var(--fs-xs); color: #cfd8e6; }
.brand-org .org-short { display: none; }
@media (max-width: 639px) {
  .brand-org .org-long { display: none; }
  .brand-org .org-short { display: inline; }
  .site-header.band-below { padding-bottom: 32px; }
}

main { padding-top: var(--s4); }
main.main-under-band { padding-top: 0; }
.site-footer { margin-top: var(--s7); padding: var(--s5) 0; color: var(--muted); font-size: var(--fs-sm); border-top: 1px solid var(--line); background: var(--surface); }

/* ---------- Controls ---------- */
input, select { font: inherit; font-size: 16px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: #fff; color: var(--ink); transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
input:hover, select:hover { border-color: #a99f8c; }
/* keep a real outline (box-shadow alone disappears in Windows high-contrast mode) */
input:focus-visible, select:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--navy-700); }
.btn { font: inherit; font-size: 16px; font-weight: 600; min-height: 44px; padding: 8px 18px; border-radius: var(--r-sm); border: 1px solid var(--navy); background: var(--navy); color: #fff; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }
.btn:hover { background: var(--navy-700); color: #fff; box-shadow: var(--shadow-1); }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: #fff; color: var(--navy); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--navy-050); color: var(--navy); border-color: var(--navy-100); }
.btn-small { min-height: 44px; padding: 4px 10px; font-size: var(--fs-sm); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); color: var(--muted); }
.loading-note { margin: var(--s2) 0 0; color: var(--navy); font-weight: 600; font-size: var(--fs-sm); }
.link-btn { min-height: 44px; display: inline-flex; align-items: center; font-size: var(--fs-sm); }
.notice { background: var(--gold-050); border: 1px solid #ead7aa; padding: var(--s2) var(--s3); border-radius: var(--r-sm); font-size: var(--fs-sm); }

/* ---------- Search toolbar (floats over the navy band) ---------- */
.toolbar { position: relative; margin-top: -40px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: var(--s3); }
@media (min-width: 640px) { .toolbar { padding: var(--s4); } }
@media (max-width: 639px) { .toolbar { margin-top: -32px; } }
.search-row { display: flex; gap: var(--s2); }
.search-field { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; }
.search-field .icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search-field input { width: 100%; padding-left: 40px; min-height: 48px; background: #fbfaf7; }
.btn-search { min-height: 48px; padding: 8px 20px; }
.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-top: var(--s3); flex-wrap: wrap; }
.adv-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 var(--s2); font-size: var(--fs-sm); font-weight: 600; color: var(--navy-700); text-decoration: none; border-radius: var(--r-sm); transition: background-color var(--dur) var(--ease); }
.adv-link:hover { background: var(--navy-050); text-decoration: underline; }

/* Segmented type switch: one row on desktop, 2×2 on phones */
.seg { display: inline-grid; grid-auto-flow: column; gap: 4px; padding: 4px; background: #f3f0e9; border: 1px solid var(--line); border-radius: calc(var(--r-sm) + 4px); }
.seg-item { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 4px 14px; border-radius: var(--r-sm); text-decoration: none; color: var(--muted); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.seg-item:hover { color: var(--navy); background: rgba(255, 255, 255, 0.7); }
.seg-item.active { background: var(--navy); color: #fff; box-shadow: var(--shadow-1); }
.seg-item.active:hover { color: #fff; background: var(--navy); }
@media (max-width: 639px) {
  .toolbar-row { flex-direction: column; align-items: stretch; gap: var(--s2); }
  .seg { display: grid; grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
  .seg-item { min-height: 44px; white-space: normal; text-align: center; line-height: 1.3; }
  .adv-link { justify-content: center; }
}

/* ---------- Result bar, chips, sort, view ---------- */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin: var(--s4) 0 0; }
.chips-label { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 12px; border-radius: 999px; background: var(--navy-050); border: 1px solid var(--navy-100); color: var(--navy); text-decoration: none; font-size: var(--fs-sm); transition: background-color var(--dur) var(--ease); }
.chip:hover { background: var(--navy-100); }
.result-bar { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); flex-wrap: wrap; margin: var(--s4) 0 var(--s3); }
.result-count { margin: 0; color: var(--muted); font-size: var(--fs-sm); }
.result-tools { display: flex; gap: var(--s3); align-items: center; }
.sort-form { display: inline-flex; align-items: center; gap: 6px; }
.sort-label { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; }
.sort-form select { min-height: 44px; font-size: var(--fs-sm); max-width: 240px; background: var(--surface); }
.view-toggle { display: inline-flex; flex: none; padding: 3px; gap: 3px; background: #f3f0e9; border: 1px solid var(--line); border-radius: calc(var(--r-sm) + 3px); }
.view-toggle a { padding: 6px 12px; min-height: 38px; display: inline-flex; align-items: center; text-decoration: none; color: var(--muted); border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease); }
.view-toggle a:hover { color: var(--navy); background: rgba(255, 255, 255, 0.7); }
.view-toggle a.active { background: var(--surface); color: var(--navy); box-shadow: var(--shadow-1); }
@media (max-width: 639px) {
  .result-bar { flex-direction: column; align-items: stretch; }
  .result-tools { justify-content: space-between; flex-wrap: wrap; }
  .sort-form { flex: 1 1 auto; min-width: 0; }
  .sort-form select { flex: 1 1 auto; min-width: 0; max-width: none; }
}

/* ---------- Cards: document on a stage ---------- */
.cards { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr; gap: var(--s3); }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(2, 1fr); gap: var(--s4); } }
@media (min-width: 1024px) { .cards { grid-template-columns: repeat(3, 1fr); gap: var(--s5); } }
.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); border: 1px solid var(--line); transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--stage-line); }
.card:active { transform: translateY(-1px); }
.card:focus-within { box-shadow: var(--shadow-2); }
.card-link { display: flex; flex-direction: column; height: 100%; color: inherit; text-decoration: none; border-radius: var(--r-lg); }
.card-link:hover { color: inherit; }
.card-link:hover .card-title { color: var(--navy); text-decoration: underline; text-decoration-thickness: 1px; }
.card-link:focus-visible { outline-offset: 3px; }
.card-stage { background: var(--stage); border-radius: var(--r-lg) var(--r-lg) 0 0; border-bottom: 1px solid var(--stage-line); padding: var(--s4); height: 300px; display: flex; align-items: center; justify-content: center; }
.thumb { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.thumb img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; background: #fff; box-shadow: var(--shadow-doc); border-radius: 2px; }
.thumb-missing { flex-direction: column; gap: var(--s2); color: var(--muted); }
.doc-placeholder { width: 64px; height: 84px; border: 2px dashed var(--line-strong); border-radius: 4px; background: rgba(255, 255, 255, 0.6); }
.thumb-missing-text { font-size: var(--fs-sm); }
.thumb-missing-inline { width: 100%; height: 100%; min-height: 120px; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); font-size: var(--fs-sm); background: rgba(255, 255, 255, 0.55); border: 2px dashed var(--line-strong); border-radius: 4px; }
.card-body { padding: var(--s3) var(--s4) var(--s4); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.badge { display: inline-flex; align-items: center; flex: none; align-self: flex-start; font-size: var(--fs-xs); font-weight: 600; line-height: 1.5; padding: 1px 8px; border-radius: 999px; background: var(--gold-050); color: #7a5a17; border: 1px solid #ecdcb4; white-space: nowrap; }
.card-title { font-size: var(--fs-md); line-height: 1.55; margin: 0; font-weight: 700; color: var(--ink); }
.meta { color: var(--muted); font-size: var(--fs-sm); margin: 0; }
.meta .issue { color: var(--navy); font-weight: 600; }

/* Phones: compact horizontal card so the first title is visible in the first screen */
@media (max-width: 639px) {
  .card-link { flex-direction: row; align-items: stretch; }
  .card-stage { flex: none; width: 112px; height: auto; min-height: 140px; padding: var(--s2); border-radius: var(--r-lg) 0 0 var(--r-lg); border-bottom: 0; border-right: 1px solid var(--stage-line); }
  .card-body { padding: var(--s3); justify-content: center; }
  .card-title { font-size: 16px; line-height: 1.5; }
  .doc-placeholder { width: 44px; height: 58px; }
  .thumb-missing-text { font-size: var(--fs-xs); text-align: center; line-height: 1.3; }
}

/* ---------- List view ---------- */
.rows { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: hidden; }
.row-item + .row-item { border-top: 1px solid var(--line); }
.row-link { display: flex; flex-direction: column; gap: 4px; padding: var(--s3) var(--s4); text-decoration: none; color: inherit; transition: background-color var(--dur) var(--ease); }
.row-link:hover { background: #fbfaf6; color: inherit; }
.row-link:hover .row-title { color: var(--navy); text-decoration: underline; text-decoration-thickness: 1px; }
.row-top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--s2); }
.row-title { font-weight: 700; line-height: 1.55; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: var(--s2); margin: var(--s6) 0 var(--s5); flex-wrap: wrap; }
.pagination ul { display: flex; gap: 4px; list-style: none; padding: 0; margin: 0; }
.page-num, .page-btn, .page-gap { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; border-radius: var(--r-sm); text-decoration: none; font-size: var(--fs-sm); font-weight: 600; }
.page-num, .page-btn { border: 1px solid var(--line); background: var(--surface); color: var(--navy); transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.page-num:hover, .page-btn:hover { background: var(--navy-050); border-color: var(--navy-100); }
.page-num.current { background: var(--navy); color: #fff; border-color: var(--navy); }
.page-btn.disabled { color: #a39b8c; background: transparent; }

/* ---------- States ---------- */
.state-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: var(--s6) var(--s4); text-align: center; color: var(--muted); }
.state-box p:first-child { font-size: var(--fs-lg); color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.state-box .actions { justify-content: center; }

/* ---------- Inner-page navigation ---------- */
.header-row { gap: var(--s4); }
.site-nav { margin-left: auto; }
.site-nav ul { display: flex; align-items: center; gap: 2px; list-style: none; margin: 0; padding: 0; }
.site-nav a { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 12px; border-radius: var(--r-sm); color: #e6ecf5; text-decoration: none; font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease); }
.site-nav a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.site-nav a[aria-current="page"] { color: #fff; box-shadow: inset 0 -3px 0 var(--gold); border-radius: var(--r-sm) var(--r-sm) 2px 2px; }
.site-nav .nav-search { border: 1px solid rgba(255, 255, 255, 0.35); }
@media (max-width: 899px) { .site-nav .nav-type { display: none; } }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--s3); margin: var(--s2) 0 var(--s3); font-size: var(--fs-sm); }
.crumbs a { min-height: 44px; display: inline-flex; align-items: center; }
.crumb-trail { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); }
@media (max-width: 639px) { .crumb-trail { display: none; } }

/* ---------- Article: header + actions first, then text | document ---------- */
.back { margin: 0 0 var(--s2); }
.back a { min-height: 44px; display: inline-flex; align-items: center; }
.article { max-width: var(--wrap); margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: var(--s5) var(--s4); }
@media (min-width: 640px) { .article { padding: var(--s6); } }
.article-head { max-width: 860px; }
.kicker { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin: 0; }
.kicker .issue { color: var(--navy); font-weight: 700; font-size: var(--fs-sm); }
.article h1 { font-size: var(--fs-2xl); line-height: 1.4; margin: var(--s2) 0 var(--s1); }
@media (max-width: 639px) { .article h1 { font-size: 23px; } }
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s4); }
.action-row .btn { padding: 8px 14px; }
@media (max-width: 639px) {
  .action-row { display: grid; grid-template-columns: 1fr 1fr; }
  .action-row .btn, .action-row .more, .action-row .more summary { width: 100%; }
  .action-row > .btn:first-child { grid-column: 1 / -1; } /* primary action gets the full row, no awkward wrap */
}
.action-status { min-height: 1.7em; margin: var(--s2) 0 0; color: var(--navy); font-weight: 600; font-size: var(--fs-sm); }
.more { position: relative; }
.more summary { list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more[open] summary { background: var(--navy-050); }
.more-menu { position: absolute; z-index: 5; top: calc(100% + 6px); left: 0; min-width: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-2); padding: 6px; display: flex; flex-direction: column; }
@media (max-width: 639px) { .more-menu { left: auto; right: 0; } }
.more-menu a, .more-menu button { display: flex; align-items: center; min-height: 44px; padding: 6px 12px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; font: inherit; font-size: var(--fs-sm); background: none; border: 0; text-align: left; cursor: pointer; }
.more-menu a:hover, .more-menu button:hover { background: var(--navy-050); color: var(--navy); }

.view-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: var(--s4) 0 0; background: #f3f0e9; border: 1px solid var(--line); border-radius: calc(var(--r-sm) + 4px); }
.view-switch button { font: inherit; font-size: var(--fs-sm); font-weight: 600; min-height: 44px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); cursor: pointer; transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease); }
.view-switch button[aria-selected="true"] { background: var(--surface); color: var(--navy); box-shadow: var(--shadow-1); }
@media (min-width: 1024px) { .view-switch { display: none !important; } }
@media (max-width: 1023px) {
  .article[data-mview="text"] .article-doc { display: none; }
  .article[data-mview="doc"] .article-text { display: none; }
}

.article-grid { display: grid; grid-template-columns: 1fr; gap: var(--s5); margin-top: var(--s5); border-top: 1px solid var(--line); padding-top: var(--s5); }
@media (min-width: 1024px) { .article-grid { grid-template-columns: minmax(0, 1fr) 380px; gap: var(--s6); } }
.article-body { font-size: 18px; line-height: 1.8; white-space: pre-line; margin: 0 0 var(--s5); max-width: 760px; }
.article-doc { align-self: start; }
@media (min-width: 1024px) { .article-doc { position: sticky; top: var(--s4); } }
.doc-stage { margin: 0; background: var(--stage); border: 1px solid var(--stage-line); border-radius: var(--r-lg); padding: var(--s4); text-align: center; }
.doc-zoom { position: relative; display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 4px; }
.doc-zoom img { display: block; margin: 0 auto; max-height: 70vh; width: auto; background: #fff; box-shadow: var(--shadow-doc); border-radius: 2px; transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.doc-zoom:hover img { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(26, 31, 39, 0.12), 0 12px 24px -10px rgba(26, 31, 39, 0.35); }
.doc-zoom-hint { position: absolute; right: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; background: rgba(20, 48, 90, 0.88); color: #fff; font-size: var(--fs-xs); font-weight: 600; }
.doc-stage figcaption { margin-top: var(--s3); font-size: var(--fs-sm); color: var(--muted); }
.doc-stage-empty { display: flex; flex-direction: column; align-items: center; gap: var(--s2); padding: var(--s6) var(--s4); color: var(--muted); }
.doc-stage-empty p { margin: 0; font-size: var(--fs-sm); }
.cover-missing { color: var(--muted); }
.actions-panel { border-top: 1px solid var(--line); padding-top: var(--s4); }
.links { border-top: 1px solid var(--line); padding-top: var(--s4); max-width: 760px; }
.links h2 { font-size: var(--fs-md); margin: 0 0 var(--s2); }
.links ul { padding-left: 20px; margin: 0; }
.links li { margin: 4px 0; }

.doc-dialog { border: 0; padding: 0; border-radius: var(--r-lg); box-shadow: 0 24px 60px rgba(10, 20, 40, 0.45); max-width: min(96vw, 900px); max-height: 94vh; background: var(--stage); }
.doc-dialog::backdrop { background: rgba(14, 24, 44, 0.72); }
.doc-dialog-bar { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); background: var(--surface); border-bottom: 1px solid var(--line); font-size: var(--fs-sm); font-weight: 600; color: var(--navy); }
.doc-dialog-actions { display: inline-flex; align-items: center; gap: var(--s3); }
.doc-dialog img { display: block; margin: var(--s4) auto; max-width: calc(100% - 32px); height: auto; max-height: calc(94vh - 90px); width: auto; background: #fff; box-shadow: var(--shadow-doc); }

/* ---------- Advanced search: main fields first, rare ones behind "เงื่อนไขเพิ่มเติม" ---------- */
.panel { max-width: var(--read); margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: var(--s5) var(--s4); }
@media (min-width: 640px) { .panel { padding: var(--s6); } }
.panel h1 { font-size: var(--fs-xl); margin: 0 0 var(--s4); }
.hint { color: var(--muted); font-size: var(--fs-sm); margin: var(--s2) 0 0; }
.adv-main { display: grid; gap: var(--s3); }
.adv-main .field label { font-weight: 600; color: var(--ink); }
.seg-radio { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin: 0; background: #f3f0e9; border: 1px solid var(--line); border-radius: calc(var(--r-sm) + 4px); justify-self: start; }
.seg-radio legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.seg-radio label { position: relative; display: inline-flex; }
.seg-radio input { position: absolute; opacity: 0; inset: 0; margin: 0; min-height: 0; cursor: pointer; }
.seg-radio span { display: inline-flex; align-items: center; min-height: 40px; padding: 4px 14px; border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 600; color: var(--muted); transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease); }
.seg-radio input:checked + span { background: var(--surface); color: var(--navy); box-shadow: var(--shadow-1); }
.seg-radio input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.adv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); margin-top: var(--s4); }
@media (min-width: 900px) { .adv-panel { max-width: 960px; } .adv-grid { grid-template-columns: repeat(4, 1fr); } }
.adv-grid select { width: 100%; min-width: 0; }
.more-conditions { margin-top: var(--s4); border: 1px solid var(--line); border-radius: var(--r-md); background: #fcfbf8; }
.more-conditions summary { display: flex; align-items: center; flex-wrap: wrap; gap: 4px var(--s2); min-height: 48px; padding: var(--s2) var(--s4); cursor: pointer; font-weight: 600; color: var(--navy); list-style: none; }
.more-conditions summary::-webkit-details-marker { display: none; }
.more-conditions summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); margin-right: 4px; transition: transform var(--dur) var(--ease); }
.more-conditions[open] summary::before { transform: rotate(45deg); }
.more-conditions summary .muted { font-weight: 400; font-size: var(--fs-sm); }
.count-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--navy); color: #fff; font-size: var(--fs-xs); }
.more-body { padding: 0 var(--s4) var(--s4); border-top: 1px solid var(--line); }
.issue-field { max-width: 260px; margin-top: var(--s3); }
.presets { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s4); font-size: var(--fs-sm); }
.presets .chip { font: inherit; font-size: var(--fs-sm); cursor: pointer; }
.chip-quiet { background: transparent; border-color: var(--line); color: var(--muted); }
.adv-dates { display: grid; grid-template-columns: 1fr; gap: var(--s3); margin-top: var(--s3); }
@media (min-width: 640px) { .adv-dates { grid-template-columns: repeat(2, 1fr); } }
.date-group { border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s2) var(--s3) var(--s3); margin: 0; background: var(--surface); }
.date-group legend { font-size: var(--fs-sm); color: var(--muted); padding: 0 4px; }
.date-row { display: grid; grid-template-columns: 0.8fr 1.4fr 1fr; gap: 6px; }
.date-row select { width: 100%; min-width: 0; padding: 8px 6px; }
.date-row select[aria-invalid="true"] { border-color: #b3261e; }
.field-error { margin: var(--s3) 0 0; padding: var(--s2) var(--s3); border-radius: var(--r-sm); background: #fdecea; border: 1px solid #f3b7b1; color: #8c1d18; font-size: var(--fs-sm); font-weight: 600; }
.adv-actions { margin-top: var(--s5); }
.radio-group { border: 0; padding: 0; margin: 0; }

/* ---------- Motion & print ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
  .card:hover, .card:active, .btn:active { transform: none !important; }
}

@media print {
  .site-header, .site-footer, .back, .crumbs, .actions-panel, .action-row, .action-status, .view-switch, .skip, .toolbar, .chips, .result-bar, .pagination, .doc-zoom-hint, .doc-dialog { display: none !important; }
  .article[data-mview] .article-text, .article[data-mview] .article-doc { display: block !important; }
  .article-grid { display: block; border: 0; }
  body { background: #fff; font-size: 14pt; }
  .article { border: 0; padding: 0; max-width: none; box-shadow: none; }
  .doc-stage { background: none; border: 0; padding: 0; }
  .doc-zoom img { max-height: 60vh; box-shadow: none; }
}

/* Admin preview banner on public templates */
.preview-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2); margin: var(--s3) 0; padding: var(--s3) var(--s4); border-radius: var(--r-md); background: #fff4d6; border: 1px solid #e9cf8b; color: #5d4511; }

/* ---------- PR images & videos (public) ---------- */
.media-desc { margin-top: var(--s4); }
.gallery { list-style: none; padding: 0; margin: var(--s5) 0 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s3); }
@media (min-width: 900px) { .gallery { grid-template-columns: repeat(4, 1fr); gap: var(--s4); } }
.gallery-item { display: flex; flex-direction: column; gap: 6px; }
.gallery-zoom { background: var(--stage); border: 1px solid var(--stage-line); border-radius: var(--r-md); padding: var(--s2); aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; }
.gallery-zoom img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; box-shadow: var(--shadow-doc); }
.gallery-missing { aspect-ratio: 1 / 1; background: var(--stage); border-radius: var(--r-md); }
.gallery-link { font-size: var(--fs-sm); min-height: 44px; display: inline-flex; align-items: center; }
.video-grid { display: grid; grid-template-columns: 1fr; gap: var(--s5); margin-top: var(--s5); border-top: 1px solid var(--line); padding-top: var(--s5); }
@media (min-width: 1024px) { .video-grid { grid-template-columns: minmax(0, 1fr) 360px; } }
.video-cover img { display: block; margin: 0 auto; max-height: 60vh; width: auto; box-shadow: var(--shadow-doc); }
.watch-on h2 { font-size: var(--fs-lg); margin: 0 0 var(--s3); }
.watch-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.watch-link { display: flex; flex-direction: column; gap: 2px; padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); text-decoration: none; color: var(--ink); box-shadow: var(--shadow-1); transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.watch-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); color: var(--ink); }
.watch-platform { font-weight: 700; color: var(--navy); }
.watch-platform::after { content: " ↗"; font-weight: 400; }
.watch-meta { font-size: var(--fs-sm); color: var(--muted); }
.platform-youtube { border-left: 4px solid #c4302b; }
.platform-facebook { border-left: 4px solid #1877f2; }
.platform-tiktok { border-left: 4px solid #111; }
.platform-drive { border-left: 4px solid #1fa463; }
.badge-image { background: #e8f1fb; color: #1e4380; border-color: #c9dbf2; }
.badge-video { background: #f3e9f8; color: #5b2a78; border-color: #e1cdeb; }

/* Generated stand-in for videos without any preview (no image file, no fake picture) */
.video-ph { width: 100%; aspect-ratio: 16 / 9; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: var(--s3); background: var(--navy); color: #e8eef7; border-radius: 6px; text-align: center; box-shadow: var(--shadow-doc); }
.video-ph-play { width: 44px; height: 44px; color: #fff; opacity: 0.9; }
.video-ph-platforms { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.3px; color: #f1d58f; }
.video-ph-text { font-size: var(--fs-sm); line-height: 1.4; }
.video-ph-detail { max-width: 640px; margin: 0 auto; border-radius: var(--r-md); }
.video-ph-detail .video-ph-play { width: 64px; height: 64px; }
.video-ph-detail .video-ph-text { font-size: var(--fs-md); }
.video-cover-ph { margin: 0; }
@media (max-width: 639px) {
  .video-ph-card { aspect-ratio: auto; height: 100%; min-height: 120px; padding: var(--s2); gap: 4px; }
  .video-ph-card .video-ph-play { width: 30px; height: 30px; }
  .video-ph-card .video-ph-text { font-size: 12px; }
  .video-ph-card .video-ph-platforms { font-size: 11px; }
}

/* Pinned strip (first page of the unfiltered listing only) */
.pinned { margin: 0 0 var(--s5); padding: var(--s4); background: #fbf6e9; border: 1px solid #eedfb8; border-radius: var(--r-lg); }
.pinned-title { margin: 0 0 var(--s3); font-size: var(--fs-md); color: #6b4f12; display: flex; align-items: center; gap: 6px; }
.pinned-title::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); }
.badge-pin { background: var(--gold); color: #fff; border-color: var(--gold); }
.footer-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s3) var(--s5); }
.footer-name { margin: 0; font-weight: 600; color: var(--ink); }
.footer-text { margin: 4px 0 0; white-space: pre-line; }
.footer-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px var(--s4); }
.footer-links a { min-height: 44px; display: inline-flex; align-items: center; }
