@font-face {
  font-family: Sarabun;
  src: url("fonts/sarabun-400-thai.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: Sarabun;
  src: url("fonts/sarabun-400-latin.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Sarabun;
  src: url("fonts/sarabun-600-thai.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: Sarabun;
  src: url("fonts/sarabun-600-latin.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Sarabun;
  src: url("fonts/sarabun-700-thai.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: Sarabun;
  src: url("fonts/sarabun-700-latin.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Manrope;
  src: url("fonts/manrope-800-latin.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --paper: #f5f7fc;
  --surface: #fff;
  --ink: #132143;
  --muted: #4e5d78;
  --line: #dde4f1;
  --navy: #14224c;
  --brand: #2343a2;
  --brand-strong: #172f82;
  --soft: #edf2fd;
  --gold: #ffd282;
  --gold-ink: #39240e;
  --shadow: 0 14px 32px #2137720b;
  font: 16px/1.65 Sarabun, "Leelawadee UI", Tahoma, system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
main { flex: 1; min-width: 0; }
h1, h2, h3, p, dl, figure, fieldset { margin: 0; }
h1, h2, h3 { line-height: 1.35; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.95rem, 4.5vw, 3.2rem); }
h2 { font-size: clamp(1.38rem, 2.8vw, 2.05rem); }
h3 { font-size: 1.21rem; }
p, td, dd, dt, legend { overflow-wrap: anywhere; }
a { color: var(--brand); text-underline-offset: .23em; }
a:hover { text-decoration-thickness: 2px; }
img { display: block; max-width: 100%; height: auto; }
:focus-visible { outline: 3px solid #bb6c0e; outline-offset: 3px; }
button, select, input, textarea { font: inherit; }
button { cursor: pointer; }
section[id] { scroll-margin-top: 5.9rem; }
.shell { width: min(calc(100% - 3rem), 1180px); margin-inline: auto; }
.narrow { max-width: 610px; }
.medium { max-width: 860px; }
.block { padding-block: clamp(1.7rem, 4.4vw, 3.9rem); }
.skip { position: fixed; top: -8rem; left: 1rem; z-index: 8; padding: .4rem .75rem; border-radius: .35rem; background: white; }
.skip:focus { top: .55rem; }
.eyebrow, .department-label { color: var(--brand); font-size: .88rem; font-weight: 700; }
.muted { color: var(--muted); font-size: .94rem; }

.site-header { position: sticky; top: 0; z-index: 3; border-bottom: 1px solid var(--line); background: var(--surface); }
.top, .site-footer .shell { display: flex; justify-content: space-between; align-items: center; gap: .75rem 1.7rem; padding-block: .9rem; }
.brand { display: inline-flex; flex: 0 1 auto; align-items: center; gap: .75rem; color: var(--ink); text-decoration: none; line-height: 1.3; min-width: 0; }
.brand-mark { width: 46px; flex: 0 0 46px; aspect-ratio: 1; display: grid; place-items: center; border-radius: .8rem; background: var(--navy); color: var(--gold); font-size: 1rem; font-weight: 700; }
.brand strong { font: 800 1.04rem/1.3 Manrope, Sarabun, sans-serif; }
.brand small { display: block; margin-top: .22rem; color: var(--muted); font-size: .78rem; font-weight: 600; }
.site-nav, .row-links { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1.2rem; }
.site-nav > a { display: inline-flex; align-items: center; gap: .35rem; min-height: 44px; color: var(--ink); font-size: .92rem; font-weight: 600; text-decoration: none; }
.site-nav > a:is(:hover,[aria-current]) { color: var(--brand); text-decoration: underline; }
.site-footer { color: #c6d3f3; background: var(--navy); margin-top: clamp(1.2rem, 4vw, 3rem); font-size: .9rem; }
.site-footer .shell { flex-wrap: wrap; padding-block: 1.45rem; }
.site-footer a, .site-footer strong { color: #fff; }
.menu-toggle { display: none; }
.menu-lines { display: block; width: 1rem; height: .72rem; border-block: 2px solid currentColor; position: relative; }
.menu-lines::after { content: ""; position: absolute; top: 50%; left: 0; right: 0; height: 2px; transform: translateY(-50%); background: currentColor; }

.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .6rem; padding: .48rem 1rem; border: 1px solid #c7d4ee; border-radius: .65rem; color: var(--brand); background: var(--surface); text-decoration: none; font-weight: 700; text-align: center; }
.button:hover { background: var(--soft); border-color: #a4b6e2; }
.button.primary { color: white; background: var(--brand); border-color: var(--brand); }
.button.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.button.quiet { background: transparent; }
.button.gold { color: var(--gold-ink); background: var(--gold); border-color: var(--gold); }
.button.gold:hover { background: #ffe0a4; border-color: #ffe0a4; }
.button.hero-outline { background: #243359; border-color: #8292bb; color: white; }
.button.hero-outline:hover { background: #334b85; }
.button.arrow::after { content: ""; width: .48em; height: .48em; border-top: 2px solid; border-right: 2px solid; transform: rotate(45deg); }
.button.add::before { content: "+"; font: 600 1.2rem/1 Sarabun, sans-serif; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; margin-top: 1rem; }

.hero { color: #fff; background: radial-gradient(ellipse at 80% 85%, #294975 0, transparent 55%), var(--navy); }
.hero-inner { display: grid; grid-template-columns: minmax(0, .91fr) minmax(0, 1.09fr); align-items: center; gap: clamp(1.25rem, 4.7vw, 4.1rem); padding-block: clamp(2rem, 5vw, 4.5rem); }
.hero-copy { min-width: 0; }
.hero-year { display: inline-flex; padding: .2rem .68rem; border: 1px solid #8091bd; border-radius: 10rem; color: #ffdb9d; font-size: .86rem; font-weight: 700; }
.hero h1 { margin-block: .55rem .52rem; font-family: Manrope, Sarabun, sans-serif; font-weight: 800; font-size: clamp(2.65rem, 6.45vw, 6.15rem); line-height: 1.1; letter-spacing: -.058em; text-wrap: balance; }
.hero-school { color: #f8faff; font-size: clamp(1.25rem, 2.25vw, 1.85rem); font-weight: 700; line-height: 1.4; }
.hero-intro { margin-top: .6rem; max-width: 34rem; color: #e0e8fa; font-size: clamp(.98rem, 1.4vw, 1.09rem); }
.hero .actions { margin-top: 1.4rem; }
.hero-details { display: flex; flex-wrap: wrap; gap: .6rem 1.8rem; margin-top: 1.45rem; padding-top: .85rem; border-top: 1px solid #6f82b068; }
.hero-details dt { color: #c4d2f0; font-size: .78rem; }
.hero-details dd { margin: .1rem 0 0; color: #fff; font-size: .93rem; font-weight: 600; }
.hero-figure { isolation: isolate; position: relative; margin: 0; min-width: 0; aspect-ratio: 1.38; overflow: hidden; border-radius: clamp(.9rem, 2vw, 1.65rem); background: #213c68; box-shadow: 0 25px 55px #090e2659; }
.hero-figure img { width: 100%; height: 100%; object-fit: cover; object-position: center; }
.hero-figure figcaption { position: absolute; right: .62rem; bottom: .62rem; padding: .14rem .55rem; border-radius: 1rem; background: #0c1532e8; color: #fff; font-size: .72rem; }

.home-stack { display: grid; gap: clamp(2rem, 4.8vw, 3.75rem); padding-block: clamp(1.7rem, 4.3vw, 3.5rem); }
.section-head { display: flex; gap: .3rem 1rem; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: .85rem; }
.section-head a, .list-meta a { font-weight: 700; }
.section-heading { margin-bottom: 1.2rem; }
.section-heading p { margin-top: .33rem; }
.breadcrumb { margin-bottom: .75rem; font-size: .94rem; font-weight: 600; }
.breadcrumb + .badge { margin-bottom: .45rem; }
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 1rem; }
.tile { min-width: 0; border: 1px solid var(--line); border-radius: 1rem; padding: clamp(.95rem, 2vw, 1.28rem); background: var(--surface); box-shadow: var(--shadow); display: grid; gap: .55rem; align-content: start; }
.tile h3 a { color: var(--ink); text-decoration: none; }
.tile h3 a:hover { color: var(--brand); text-decoration: underline; }
.eyeline { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .4rem .7rem; }
.competition-card { grid-template-rows: auto auto auto minmax(0,1fr) auto; }
.competition-card .card-footer { grid-row: 5; }
.competition-format { color: var(--muted); font-size: .94rem; }
.card-footer { display: grid; justify-items: start; gap: .55rem; margin-top: .38rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.badge { display: inline-flex; align-items: center; gap: .4rem; width: fit-content; padding: .15rem .62rem; border-radius: 4rem; background: #edf0f6; color: #3a4863; font-weight: 700; font-size: .82rem; white-space: nowrap; }
.badge::before { content: ""; width: .4rem; aspect-ratio: 1; border-radius: 50%; background: currentColor; }
.badge-positive { background: #e0f5e9; color: #176446; }
.badge-attention { background: #fff1d8; color: #81530e; }
.badge-negative { background: #fde8e9; color: #8d2b37; }
.empty, .notice, .error { border: 1px solid var(--line); padding: .85rem 1rem; border-radius: .68rem; color: var(--muted); background: var(--surface); }
.empty { border-style: dashed; background: #f9fbff; }
.notice, .error { margin-block: .65rem; }
.notice { color: #165834; background: #e9f8ee; border-color: #cbebd7; }
.error { color: #8d2b37; background: #fff0f0; border-color: #efc0c5; }
.split { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; min-width: 0; align-items: start; }
.content-section { display: grid; align-content: start; gap: .8rem; min-width: 0; }
.home-panel { align-self: stretch; padding: clamp(1rem, 3vw, 1.6rem); border: 1px solid var(--line); border-radius: 1.15rem; background: var(--surface); box-shadow: var(--shadow); }
.content-entry { display: grid; gap: .6rem; padding-block: .75rem; border-top: 1px solid var(--line); }
.content-entry p, .gallery-tile p { margin-top: .23rem; }
.content-entry .entry-date, .gallery-tile .entry-date { color: var(--brand); font-size: .86rem; font-weight: 700; }
#schedule .content-entry { border-top: 0; border-left: 3px solid #afbee8; padding: .35rem 0 .35rem .82rem; }
.content-image { width: 100%; max-height: 300px; object-fit: cover; border-radius: .7rem; }
.gallery-tile .content-image { aspect-ratio: 4/3; }
.result-callout { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .85rem 2rem; padding: clamp(1.1rem, 4vw, 2.25rem); color: var(--ink); background: var(--soft); border: 1px solid #d0ddfc; border-radius: 1.05rem; }
.result-callout p { color: var(--muted); margin-top: .2rem; }

.filters { display: flex; flex-wrap: wrap; gap: .7rem; align-items: end; margin-block: .8rem 1.15rem; }
.search-filters { display: grid; grid-template-columns: minmax(210px, 1.4fr) minmax(170px, 1fr) minmax(130px,.7fr) auto; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); padding: 1rem; box-shadow: var(--shadow); }
.list-meta { display: flex; flex-wrap: wrap; gap: .3rem 1rem; justify-content: space-between; margin-bottom: .75rem; color: var(--muted); font-size: .94rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(170px, 100%),1fr)); gap: .85rem 1.1rem; border: 1px solid var(--line); background: var(--surface); padding: 1rem; border-radius: .8rem; margin-block: .75rem; }
.facts dt { color: var(--muted); font-size: .87rem; }
.facts dd { margin: .12rem 0 0; font-weight: 700; }
.text-block { margin-block: 1.15rem; }
.results-group + .results-group { margin-top: 1.5rem; }
.form-stack { display: grid; gap: 1rem; margin-top: .6rem; }
.form-panel, .admin-main > .form-stack:not(.admin-section) { padding: clamp(.95rem, 3.2vw, 1.55rem); border: 1px solid var(--line); border-radius: .9rem; background: var(--surface); box-shadow: var(--shadow); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .75rem 1rem; }
.form-stack .actions { margin-top: 0; }
fieldset { min-width: 0; border: 1px solid var(--line); border-radius: .9rem; background: var(--surface); padding: .75rem 1rem 1.12rem; }
legend { padding: 0 .45rem; color: var(--ink); font-weight: 700; }
label { display: grid; min-width: 0; gap: .28rem; font-weight: 600; }
.field-hint { padding: .4rem .55rem; border-radius: .45rem; color: var(--brand-strong); background: var(--soft); font-size: .85rem; font-weight: 400; }
input:not([type="checkbox"]), textarea, select { width: 100%; min-width: 0; min-height: 44px; background: var(--surface); color: var(--ink); border: 1px solid #bfcae0; border-radius: .55rem; padding: .47rem .65rem; font-weight: 400; }
input[type="file"] { width: min(100%, 600px); }
textarea { resize: vertical; }
.check { display: flex; gap: .55rem; align-items: start; }
.check input { margin: .44rem 0 0; accent-color: var(--brand); }
.application-summary { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem; padding: .7rem .95rem; border-radius: .72rem; background: var(--soft); border: 1px solid #d8e3fc; color: var(--brand-strong); font-weight: 600; }

.admin-body { background: #f2f5fb; }
.admin-shell { display: grid; grid-template-columns: 220px minmax(0,1fr); gap: clamp(1rem, 3.6vw, 2.65rem); align-items: start; }
.admin-nav { position: sticky; top: 5.65rem; margin-top: clamp(1.7rem, 4.4vw, 3.9rem); padding: .68rem; border: 1px solid var(--line); background: var(--surface); border-radius: 1rem; box-shadow: var(--shadow); }
.admin-identity { padding: .42rem .64rem .75rem; border-bottom: 1px solid var(--line); }
.admin-year { margin-bottom: .17rem; color: var(--brand); font-size: .82rem; font-weight: 700; }
.admin-nav nav { display: grid; gap: .12rem; margin-top: .52rem; }
.admin-nav a { display: flex; align-items: center; min-height: 43px; padding: .36rem .66rem; border-radius: .56rem; color: var(--ink); text-decoration: none; font-weight: 600; }
.admin-nav a[aria-current], .admin-nav a:hover { color: var(--brand); background: var(--soft); }
.admin-main > .empty, .admin-main > .table-wrap { margin-top: .9rem; }
.admin-section { padding-top: 1rem; margin-top: 1.35rem; border-top: 1px solid var(--line); }
.dashboard-summary { display: grid; gap: .7rem; grid-template-columns: repeat(3,minmax(0,1fr)); }
.dashboard-summary > div { padding: .85rem 1rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--surface); }
.dashboard-summary dt { color: var(--muted); font-size: .9rem; font-weight: 600; }
.dashboard-summary dd { margin: .12rem 0 0; color: var(--ink); font: 800 clamp(1.4rem, 2.8vw, 2.1rem)/1.2 Manrope, Sarabun, sans-serif; font-variant-numeric: tabular-nums; }
.dashboard-summary > div:last-child { background: #fff8eb; border-color: #f0dab4; }
.table-wrap { min-width: 0; overflow: auto; border: 1px solid var(--line); border-radius: .8rem; background: var(--surface); margin-block: .7rem; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: .65rem .75rem; vertical-align: top; }
th { color: var(--ink); background: #edf2fa; font-size: .9rem; }
td { border-top: 1px solid var(--line); }
td small { display: block; color: var(--muted); font-size: .84rem; }
td .button { min-height: 44px; padding: .32rem .67rem; font-size: .87rem; white-space: nowrap; }
.row-links { gap: .35rem; }
.edit-image { max-height: 230px; width: auto; object-fit: contain; border-radius: .6rem; }

@media (max-width: 920px) {
  .top { flex-wrap: wrap; gap: .5rem 1.25rem; }
  .site-header { position: static; }
  section[id] { scroll-margin-top: 1rem; }
  .site-nav { width: 100%; }
  .admin-nav { top: 1rem; }
}

@media (max-width: 800px) {
  .shell { width: min(calc(100% - 2rem), 1180px); }
  .top { min-height: 68px; padding-block: .65rem; }
  .menu-toggle[data-ready] { display: inline-flex; align-items: center; gap: .5rem; min-height: 44px; padding: .32rem .6rem; border: 1px solid var(--line); border-radius: .58rem; background: var(--surface); color: var(--ink); font-size: .9rem; font-weight: 700; }
  .site-nav[data-collapsed="true"], .admin-nav nav[data-collapsed="true"] { display: none; }
  .site-nav { padding-top: .55rem; border-top: 1px solid var(--line); gap: .25rem 1rem; }
  .hero-inner { grid-template-columns: 1fr; gap: 1.45rem; }
  .hero h1 { font-size: clamp(3rem, 10vw, 5.2rem); text-wrap: initial; }
  .hero-figure { aspect-ratio: 1.65; }
  .card-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .search-filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .search-filters > label:first-of-type { grid-column: 1 / -1; }
  .search-filters button { justify-self: start; }
  .admin-shell { grid-template-columns: 1fr; gap: 0; }
  .admin-nav { position: static; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .4rem; align-items: center; }
  .admin-identity { border-bottom: 0; padding: .25rem .48rem; }
  .admin-nav nav { grid-column: 1 / -1; display: flex; flex-wrap: wrap; padding-top: .45rem; border-top: 1px solid var(--line); }
}

@media (max-width: 540px) {
  .shell { width: calc(100% - 1.5rem); }
  .brand-mark { width: 40px; flex-basis: 40px; }
  .brand { gap: .5rem; }
  .brand small { font-size: .72rem; }
  .hero h1 { font-size: clamp(2.7rem, 13.5vw, 4.3rem); }
  .hero .actions { margin-top: 1rem; }
  .hero-details { margin-top: 1rem; }
  .card-grid, .split, .fields { grid-template-columns: 1fr; }
  .hero-figure { aspect-ratio: 1.56; }
  .search-filters { padding: .75rem; }
  .search-filters button { grid-column: 1 / -1; justify-self: stretch; }
  .dashboard-summary { gap: .45rem; }
  .dashboard-summary > div { padding: .55rem; }
  .dashboard-summary dt { font-size: .81rem; }
  .overview-table, .overview-table tbody { display: block; }
  .overview-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .overview-table tbody tr { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .5rem; padding: .75rem; }
  .overview-table tbody tr + tr { border-top: 1px solid var(--line); }
  .overview-table td { padding: 0; border: 0; }
}
