@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("atkinson-next-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Noto Sans Thai Looped";
  src: url("noto-sans-thai-looped.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}

:root {
  color-scheme: light;
  font-family: "Atkinson Hyperlegible Next", "Noto Sans Thai Looped", "Segoe UI", "Leelawadee UI", sans-serif;
  line-height: 1.55;
  --ink: #192b42;
  --muted: #4d6278;
  --border: #d9e2ec;
  --accent: #245db5;
  background: #f1f5f9;
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; padding-left: max(0px, calc(env(safe-area-inset-left, 0px) - 16px)); padding-right: max(0px, calc(env(safe-area-inset-right, 0px) - 16px)); background: radial-gradient(ellipse at 82% 8%, #e3edf9 0%, transparent 32rem), #f1f5f9; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, textarea { font: inherit; }
button, summary { cursor: pointer; }
button, a, summary, .field { -webkit-tap-highlight-color: transparent; transition: background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, color 180ms ease, transform 180ms ease; }
button:active { transform: scale(.98); }
:focus-visible { outline: 3px solid #3176c9; outline-offset: 3px; }
p, h1, h2, h3 { margin: 0; }
.frame { width: min(1176px, calc(100% - 64px)); margin-inline: auto; }

.topbar { position: sticky; z-index: 10; top: 0; padding-top: env(safe-area-inset-top, 0px); background: rgba(248, 251, 255, .9); border-bottom: 1px solid rgba(201, 214, 230, .8); backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2); }
.navigation { display: flex; align-items: center; justify-content: space-between; min-height: 66px; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 1.375rem;
  font-weight: 750;
  letter-spacing: -.02em;
  text-decoration: none;
  white-space: nowrap;
}
.brand-icon { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 11px; background: linear-gradient(145deg, #2f72cc, #194486); box-shadow: 0 3px 9px #2b66af32; }
.brand-icon > span { width: 14px; height: 14px; border: 2px solid #f0efff; border-radius: 50%; position: relative; transform: translate(-1px, -1px); }
.brand-icon > span::after { content: ""; width: 8px; height: 2px; border-radius: 2px; background: #f0efff; position: absolute; right: -6px; bottom: -3px; transform: rotate(48deg); }
.nav-link {
  color: #285b97;
  padding: 11px 16px;
  font-size: .9375rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 14px;
  min-height: 44px;
}
.nav-link:hover { background: #e7f0fa; }
.nav-link span { margin-left: 5px; }

main { padding-block: 28px calc(48px + env(safe-area-inset-bottom, 0px)); }
.hero {
  border-radius: 26px;
  overflow: hidden;
  position: relative;
  isolation: isolate;
  display: grid;
  align-content: end;
  background: #102b4c;
  color: #fff;
  box-shadow: 0 14px 32px #213e6222;
}
.hero-image {
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(90deg, #102b4c 0%, #102b4cfa 30%, #102b4ca8 56%, #102b4c24 100%), url("hero.webp") right 53% / cover, #365c85;
}
.hero-copy { min-width: 0; padding: 32px 38px 26px; }
.custom-data .hero-image { background: radial-gradient(ellipse at right bottom, #467a91, transparent 60%), linear-gradient(115deg, #102b4c, #264e77); }
.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #c7ddf4;
  font-size: .8125rem;
  font-weight: 650;
  letter-spacing: .10em;
  text-transform: uppercase;
}
.eyebrow { overflow-wrap: anywhere; }
.eyebrow span { flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; background: #9fd5ff; }
.hero h1 { max-width: 16ch; margin: 13px 0 0; font-size: clamp(2.5rem, 4.6vw, 3.75rem); letter-spacing: -.035em; line-height: 1.08; }
.hero h1 em { color: #a6d8ff; font-style: normal; }
.hero-data { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 9px; color: #173553; }
.hero-data strong { font-size: 1.55rem; font-weight: 720; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hero-data span { color: var(--muted); font-size: .9375rem; }
.dataset-picker { background: #f7fafe; padding: 10px 32px 10px 38px; }
.dataset-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 14px; }
.source > summary .section-icon {
  flex-basis: 42px;
  height: 42px;
  border-radius: 14px;
  color: #215d99;
  background: linear-gradient(145deg, #e6f3ff, #dcecf9);
  box-shadow: inset 0 1px 1px #fff;
}
.dataset-current { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.dataset-current strong { display: block; color: #173553; font-size: 1.0625rem; line-height: 1.35; }
.dataset-current small { display: block; margin-top: 4px; color: var(--muted); font-size: .9375rem; line-height: 1.45; }
.dataset-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.dataset-actions button {
  min-height: 44px;
  padding: 10px 17px;
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: .9375rem;
  font-weight: 700;
  white-space: nowrap;
}
.dataset-actions .dataset-primary { background: linear-gradient(135deg, #2b6abb, #21539a); color: #fff; border-color: #285ca4; box-shadow: 0 5px 12px #245db531, inset 0 1px 0 #ffffff33; }
.dataset-primary span { display: inline-block; margin-right: 4px; font-size: 1.08em; }
.dataset-primary:hover { background: #1c4d98; }
.dataset-secondary { background: #f7fafe; color: var(--accent); }
.dataset-secondary:hover { background: #eaf2fc; }
.dataset-actions button:disabled { opacity: .65; cursor: wait; }
.dataset-note { margin: 8px 0 0; padding: 10px 13px; border-radius: 12px; background: #edf5fc; color: #405d77; font-size: .875rem; line-height: 1.5; overflow-wrap: anywhere; }
.dataset-error { color: #952f40; }

.workspace { display: grid; grid-template-columns: minmax(0, .94fr) minmax(0, 1.06fr); gap: 20px; margin-top: 20px; }
.panel, .source {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 8px 28px #28455f0c;
}
.panel {
  padding: 25px 27px 27px;
  min-width: 0;
  background: linear-gradient(160deg, #ffffff 35%, #f6faff 100%);
  border-color: #d6e3ef;
  box-shadow: 0 10px 30px #28455f12, inset 0 1px 0 #ffffff;
}
.panel-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.panel-heading h2 { font-size: 1.375rem; font-weight: 700; letter-spacing: -.015em; line-height: 1.25; color: #173553; }
.panel-heading .section-icon {
  flex-basis: 40px;
  height: 40px;
  border-radius: 14px;
  background: linear-gradient(145deg, #e6f3ff, #dcecf9);
  color: #215d99;
  box-shadow: inset 0 1px 1px #ffffff;
}
.section-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 35px;
  height: 35px;
  border-radius: 12px;
  background: #e9f2fc;
  color: #2863ad;
  font-weight: 700;
  font-size: 19px;
}
.field { border: 1px solid #cedded; border-radius: 18px; background: #f5f9fd; box-shadow: inset 0 1px 3px #17365c08; overflow: hidden; }
.field:focus-within { border-color: #4280cb; background: #fff; box-shadow: 0 0 0 4px #b9d7f180; }
textarea {
  display: block;
  background: transparent;
  width: 100%;
  resize: vertical;
  padding: 18px 19px;
  border: 0;
  border-radius: inherit;
  min-height: 132px;
  color: var(--ink);
  font-weight: 550;
  font-size: 1.25rem;
  line-height: 1.65;
}
textarea:focus-visible { outline: none; }
textarea::placeholder { color: #59657c; font-weight: 400; }
.field-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 5px 16px;
  border-top: 1px solid #dce8f4;
  color: var(--muted);
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
}
.field-footer p { display: flex; align-items: center; gap: 7px; }
.field-footer p > span { display: inline-block; flex: 0 0 6px; width: 6px; height: 6px; border-radius: 50%; background: #3379bf; }
.field-footer .visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.quick-examples { display: flex; flex-wrap: wrap; gap: 5px; }
.quick-examples button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #315c87;
  padding: 7px 12px;
  font-size: .875rem;
  font-weight: 650;
}
.quick-examples button[aria-pressed="true"] { background: #e1efff; border-color: #bdd6f1; color: #164e91; }
.quick-examples button:hover { background: #e8f2fc; }
.example-picker {
  margin-left: auto;
  font-size: .9375rem;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding-inline: 9px;
  color: var(--accent);
  font-weight: 650;
  border-radius: 9px;
}
.example-picker:hover, .example-picker:focus-within { background: #e1eefb; }
.example-picker:focus-within { outline: 2px solid var(--accent); }
.example-picker select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 1rem; }
.retry { background: #fff; color: var(--accent); border: 1px solid var(--border); border-radius: 12px; min-height: 44px; padding: 7px 14px; }
.retry:hover { background: #edf6ff; }
.calculation { margin-top: 12px; border-top: 1px solid #dce8f3; }
.calculation summary { display: flex; align-items: center; justify-content: space-between; min-height: 44px; color: var(--accent); font-size: .9375rem; font-weight: 600; }
.calculation p { color: var(--muted); overflow-wrap: anywhere; }
.csv-comparison > :only-child { grid-column: 1 / -1; }
.evidence { min-height: 346px; }
.evidence .panel-heading { margin-bottom: 17px; }
.verdict {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 12px;
  padding: 7px 11px;
  background: #e9eefb;
  color: #344a83;
  font-size: 1rem;
  font-weight: 700;
}
.verdict[data-verdict="supported"] { background: #e6f5ed; color: #176145; }
.verdict[data-verdict="refuted"] { background: #faeced; color: #952f40; }
.verdict[data-verdict="unknown"] { background: #fbf1d8; color: #76551c; }
.verdict-mark { display: grid; place-items: center; flex: 0 0 19px; height: 19px; border: 1px solid currentColor; border-radius: 50%; line-height: 1; font-size: .8125rem; }
.interpretation { margin-top: 11px; font-size: 1rem; color: #3c5067; line-height: 1.6; overflow-wrap: anywhere; }
.match-count { display: inline-block; margin-inline-start: 7px; font-size: .875rem; color: var(--muted); }
.figures { margin-top: 21px; }
.figures-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 10px; }
.figures-head h3 { font-size: 1.0625rem; }
.figures-head > span { color: var(--muted); font-size: .875rem; font-weight: 600; }
.comparison, .skeleton { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.metric-card {
  background: linear-gradient(150deg, #eff8ff, #e8f2fc);
  color: #174a82;
  border: 1px solid #d6e8f7;
  border-radius: 19px;
  padding: 16px 17px;
  box-shadow: inset 0 1px 0 #ffffffb3;
  --series: #347dca;
}
.metric-card[data-color="purple"] { background: linear-gradient(150deg, #f5f5fd, #eceefa); border-color: #e1e4f3; color: #4d4785; --series: #8073bc; }
.series-label { display: flex; align-items: baseline; gap: 6px; font-size: .9375rem; font-weight: 700; }
.series-label span { display: inline-block; width: 7px; height: 7px; flex: 0 0 7px; background: var(--series); border-radius: 50%; }
.metric-card strong { display: block; margin-top: 5px; font-size: clamp(1.875rem, 3.4vw, 2.5rem); font-weight: 750; letter-spacing: -.02em; line-height: 1.12; font-variant-numeric: tabular-nums; }
.track { width: 100%; height: 6px; margin: 12px 0 9px; border-radius: 5px; background: #18214a18; overflow: hidden; }
.fill { height: 100%; background: var(--series); border-radius: inherit; }
.metric-card small { display: block; color: #3e4a64; font-size: .875rem; line-height: 1.5; font-variant-numeric: tabular-nums; }
.csv-metric { overflow-wrap: anywhere; }
.csv-metric strong { margin-block: 5px 9px; font-size: clamp(1.625rem, 3vw, 2.25rem); }
.csv-metric small + small { margin-top: 4px; }

.message { border: 1px solid #e0eaf3; border-radius: 16px; background: #f2f7fb; padding: 16px; color: var(--muted); }
.message p { margin-top: 5px; }
.message strong { color: var(--ink); }
.retry { margin-top: 12px; }
.spinner { display: inline-block; vertical-align: -.15em; margin-right: 4px; width: 14px; height: 14px; border: 2px solid #c7c1ef; border-top-color: var(--accent); border-radius: 50%; animation: spin 950ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { margin-top: 16px; }
.skeleton span { height: 103px; border-radius: 16px; background: #f2f6fa; }

summary { list-style: none; }
summary::-webkit-details-marker { display: none; }
.department-details { margin-top: 9px; }
.department-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  color: #245d9b;
  font-size: .9375rem;
  font-weight: 650;
}
.department-details summary span { font-size: 18px; }
.department-table { border-radius: 10px; }
.department-table table { min-width: 410px; }
.table-hint, .source-body .table-hint { display: none; }
details[open] > summary > span:last-child { transform: rotate(45deg); }
.source {
  margin-top: 20px;
  scroll-margin-top: calc(82px + env(safe-area-inset-top, 0px));
  border-color: #d6e3ef;
  background: linear-gradient(150deg, #fff 38%, #f5f9fd 100%);
  box-shadow: 0 10px 30px #28455f12, inset 0 1px 0 #fff;
}
.source > summary { display: flex; align-items: center; gap: 14px; min-height: 78px; padding: 16px 20px; border-radius: 22px; }
.source > summary:hover { background: #eaf4fd80; }
.source > summary > span:nth-child(2) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.source strong { color: #173553; font-size: 1.0625rem; }
.source small { display: block; color: var(--muted); margin-top: 4px; font-size: .875rem; line-height: 1.45; }
.source .disclosure { display: grid; place-items: center; flex: 0 0 36px; height: 36px; margin-left: auto; border: 1px solid #d4e4f2; border-radius: 12px; background: #f3f8fd; color: #245d9b; font-size: 22px; line-height: 1; transition: transform 180ms ease; }
.source-body { padding: 0 20px 20px; }
.source-body p { color: var(--muted); padding-block: 13px 15px; border-top: 1px solid #e1ebf4; line-height: 1.55; }
.table-wrap { overflow-x: auto; }
.source .table-wrap { border: 1px solid #dce8f3; border-radius: 15px; background: #fff; }
.source table { min-width: 480px; }
.source thead th { background: #edf5fc; color: #345675; font-size: .875rem; }
.source th, .source td { padding: 11px 13px; }
.source tbody tr:last-child > * { border-bottom: 0; }
.csv-preview th, .csv-preview td { min-width: 108px; max-width: 280px; overflow-wrap: anywhere; }
.csv-preview th small { margin-top: 1px; font-size: .75rem; font-weight: 500; }
table { width: 100%; border-collapse: collapse; font-size: .9375rem; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--border); }
.source-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.source-links a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 13px; border: 1px solid #d2e2f1; border-radius: 12px; background: #f8fbff; color: #245d9b; font-size: .9375rem; font-weight: 650; text-decoration: none; }
.source-links a:hover { background: #eaf4fd; border-color: #aac9e8; }

@media (max-width: 860px) {
  .frame { width: calc(100% - 40px); }
  .hero-copy { padding: 28px; }
  .dataset-picker { padding-inline: 28px; }
  .panel { padding: 18px; }
  .workspace { gap: 14px; }
}
@media (max-width: 680px) {
  .frame { width: calc(100% - 32px); }
  .navigation { min-height: 60px; }
  main { padding-top: 15px; }
  .hero { border-radius: 22px; }
  .hero-copy { padding: 23px 20px; }
  .hero h1 { font-size: clamp(2rem, 8.8vw, 2.75rem); max-width: 13ch; margin-block: 13px 9px; }

  .eyebrow { font-size: .75rem; letter-spacing: .065em; }
  .hero-image { background: linear-gradient(90deg, #102b4cf7 0%, #102b4cdb 52%, #102b4c80 100%), url("hero.webp") 62% center / cover, #365c85; }
  .hero-data { flex: 1; flex-direction: column; gap: 1px; }
  .hero-data span { font-size: .8125rem; }
  .dataset-picker { padding: 10px 16px; }
  .dataset-actions { gap: 5px; }
  .dataset-actions button { padding-inline: 11px; }
  .dataset-actions .dataset-secondary { border-color: transparent; background: transparent; }
  .custom-data .hero-data { flex-basis: 130px; }
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    margin-top: 13px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 8px 28px #28455f10;
  }
  .workspace .panel { border: 0; box-shadow: none; border-radius: 0; background: transparent; }
  .editor { padding: 8px 15px 0; }
  .panel-heading { margin-bottom: 4px; gap: 8px; }
  .editor .section-icon { display: none; }
  .editor h2 { font-size: 1.125rem; }
  textarea { font-size: 1.0625rem; line-height: 1.4; min-height: 0; height: 4.55em; padding: 9px 12px; }
  .field-footer { padding: 2px 12px; font-size: .8125rem; }
  .quick-examples { flex: 1; }
  .quick-examples button { flex: 1; padding-inline: 7px; }
  .evidence { min-height: 0; padding: 10px 15px 12px; }
  .evidence .panel-heading { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .evidence .verdict { padding: 3px 9px; font-size: .9375rem; }
  .figures { margin-top: 7px; }
  .figures-head { margin-bottom: 5px; }
  .figures-head h3 { font-size: .9375rem; }
  .comparison { gap: 8px; }
  .metric-card { padding: 9px 12px; border-radius: 14px; }
  .metric-card strong { margin-top: 1px; }
  .track { height: 4px; margin: 6px 0; }
  .csv-metric { display: flex; flex-direction: column; }
  .csv-metric strong { order: -1; }
  .calculation { margin-top: 8px; }
  body:has(#headline:focus) .topbar { position: static; }

  .source { margin-top: 13px; border-radius: 20px; }
  .source > summary { padding: 15px; border-radius: 20px; }
  .source-body { padding: 0 15px 15px; }
}
@media (max-width: 510px) {
  .table-hint, .source-body .table-hint { display: block; margin: 0 0 8px; padding: 0; border: 0; color: #4d6278; font-size: .8125rem; line-height: 1.4; }
}
@media (max-width: 360px) {
  .brand { gap: 8px; font-size: 1.125rem; }
  .nav-link { padding-inline: 10px; font-size: .875rem; }
  .editor h2 { font-size: 1rem; white-space: nowrap; }
  .example-picker { font-size: .8125rem; white-space: nowrap; }
  .quick-examples button { font-size: .8125rem; white-space: nowrap; }
  .metric-card { padding-inline: 11px; }
  .metric-card strong { font-size: 1.65rem; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  button, a, summary, .field { transition: none; }
  .source .disclosure { transition: none; }
}
