@font-face {
    font-family: 'Noto Looped Thai';
    src: url('NotoLoopedThai-Regular.ttf') format('truetype');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Noto Looped Thai';
    src: url('NotoLoopedThai-Bold.ttf') format('truetype');
    font-weight: 700;
    font-display: swap;
}
:root {
    color-scheme: light;
    --bg: #f4f7f4;
    --card: #fff;
    --text: #172b23;
    --muted: #4d6259;
    --border: #d5e2db;
    --primary: #146447;
    --on-primary: #fff;
    --subtle: #e7f3ec;
    --hero: #143e31;
    --error-bg: #ffede8;
    --error: #912e25;
    --bar: #28805e;
    --shadow: 0 8px 26px #1d463009;
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #101a16;
    --card: #182720;
    --text: #edf5ef;
    --muted: #b8cbbe;
    --border: #394d42;
    --primary: #97dfb9;
    --on-primary: #102d20;
    --subtle: #263d31;
    --hero: #194634;
    --error-bg: #4d2828;
    --error: #ffd0c7;
    --bar: #69c59a;
    --shadow: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.6 'Noto Looped Thai', system-ui, sans-serif;
    overflow-wrap: anywhere;
}
a { color: var(--primary); text-underline-offset: .22em; }
button, input, textarea, select { font: inherit; }
h1, h2, h3, p { margin: 0 0 .65em; }
h1, h2, h3 { line-height: 1.35; }
h1 { font-size: clamp(1.65rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.12rem, 2.3vw, 1.45rem); }
h3 { font-size: 1.05rem; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.skip { position: absolute; left: 1rem; top: -8rem; background: var(--card); padding: .7rem; z-index: 3; }
.skip:focus { top: 1rem; }
.wrap { width: min(1120px, calc(100% - 2rem)); margin-inline: auto; }
.site-header { background: var(--card); border-bottom: 1px solid var(--border); }
.header-inner, nav, .split, .actions { display: flex; align-items: center; gap: .7rem 1rem; flex-wrap: wrap; }
.header-inner, .split { justify-content: space-between; }
.header-inner { padding-block: 1rem; }
.brand { display: flex; align-items: center; gap: .8rem; text-decoration: none; color: var(--text); }
.brand small { display: block; color: var(--muted); }
.brand img, .brand-mark { width: 48px; height: 48px; object-fit: contain; flex: none; }
.brand-mark {
    display: grid; place-items: center; border: 1px solid var(--border);
    border-radius: 14px; background: var(--subtle); color: var(--primary); font-weight: 700;
}
nav a { font-weight: 700; text-decoration: none; }
nav form { margin: 0; }
main { padding-block: clamp(1.25rem, 4vw, 2.8rem); min-height: 74vh; }
footer { color: var(--muted); border-top: 1px solid var(--border); padding-block: 1.2rem; font-size: .9rem; }
.hero {
    padding: clamp(1.6rem, 5vw, 3.7rem);
    background: radial-gradient(ellipse at right top, #2f7b59, transparent 65%), var(--hero);
    color: #fff;
    border-radius: 24px;
    margin-bottom: 1.3rem;
}
.hero p { color: #e4f1e9; max-width: 72ch; margin-bottom: 0; }
.card {
    padding: clamp(1rem, 3vw, 1.75rem);
    min-width: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 19px;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}
.card > :last-child { margin-bottom: 0; }
.projects, .two-columns, .summary { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.projects .project { display: flex; flex-direction: column; align-items: flex-start; margin: 0; }
.project .button { margin-top: auto; }
.empty { text-align: center; padding-block: 2.2rem; color: var(--muted); }
.narrow { max-width: 500px; margin-inline: auto; }
.stack { display: grid; gap: 1rem; }
.stack > .card, .stack > h2, .stack > p { margin-bottom: 0; }
.stack button { justify-self: start; }
button, .button {
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
    padding: .64rem 1rem; min-height: 44px; border: 1px solid transparent; border-radius: 11px;
    background: var(--primary); color: var(--on-primary); text-decoration: none; font-weight: 700;
}
button:hover, .button:hover { filter: brightness(.91); }
button.quiet, .secondary { background: var(--subtle); color: var(--primary); border-color: var(--border); }
button.quiet { min-height: 38px; font-size: .88rem; padding: .32rem .6rem; }
label { font-weight: 700; }
label small { color: var(--muted); display: block; font-weight: 400; }
input, select, textarea {
    display: block; width: 100%; color: var(--text); background: var(--card);
    border: 1px solid var(--border); border-radius: 9px; padding: .57rem .65rem; margin-top: .3rem;
    min-height: 44px;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: auto; min-height: auto; margin: 0; }
textarea { resize: vertical; }
.inline { display: flex; align-items: center; gap: .5rem; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; }
.keypad button { width: 100%; }
.message { padding: .8rem 1rem; border: 1px solid var(--border); border-radius: 10px; background: var(--subtle); margin-bottom: 1rem; }
.message.error { color: var(--error); background: var(--error-bg); }
.muted { color: var(--muted); }
.preserve { white-space: pre-wrap; }
.progress-panel progress, meter { width: 100%; accent-color: var(--bar); }
.progress-panel progress { height: 16px; }
progress::-webkit-progress-value { background: var(--bar); }
progress::-webkit-progress-bar { background: var(--subtle); border-radius: 5px; }
.progress-panel p { margin: 0; }
fieldset.question { margin: 0 0 1rem; padding: 0; border: 0; min-width: 0; }
.question legend { margin-bottom: .46rem; padding: 0; font-weight: 700; }
.scores { display: grid; grid-template-columns: repeat(5, minmax(0, 52px)); gap: .45rem; }
.score { display: grid; cursor: pointer; position: relative; }
.score input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.score span { display: grid; place-items: center; min-height: 44px; border-radius: 10px; background: var(--card); color: var(--text); border: 2px solid var(--rating); }
.score input:checked + span { color: #fff; background: var(--rating); }
.score input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }
.score-1 { --rating: #ad423a; }
.score-2 { --rating: #955321; }
.score-3 { --rating: #776018; }
.score-4 { --rating: #24715c; }
.score-5 { --rating: #205481; }
.success { text-align: center; max-width: 650px; margin-inline: auto; }
.top, .report-actions { margin-bottom: 1rem; }
.top h1, .split h2 { margin-bottom: 0; }
.select-project { display: flex; align-items: end; gap: .6rem; }
.select-project label { flex: 1; min-width: 0; }
.tag { display: inline-block; margin-top: .4rem; background: var(--subtle); color: var(--primary); padding: .22rem .57rem; border-radius: 7px; font-size: .85rem; }
.summary { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.summary > div { background: var(--subtle); padding: .7rem; border-radius: 11px; }
.summary small { display: block; color: var(--muted); }
.metric { font-size: clamp(1.35rem, 3vw, 2.2rem); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.3; color: var(--primary); }
.columns-chart { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); text-align: center; gap: .4rem; }
.column-track { height: 164px; border-bottom: 1px solid var(--border); margin-bottom: .45rem; display: flex; align-items: end; justify-content: center; padding-top: 1.5rem; }
.column-fill { width: min(62%, 4.5rem); background: var(--bar); position: relative; border-radius: 7px 7px 0 0; height: 0; }
.column-fill span { position: absolute; width: 100%; left: 0; bottom: 100%; font-size: .88rem; font-weight: 700; }
.group-bar { margin-bottom: .45rem; }
meter::-webkit-meter-optimum-value { background: var(--bar); }
meter::-moz-meter-bar { background: var(--bar); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .44rem .55rem; text-align: start; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th, .area-row { background: var(--subtle); }
.results { min-width: 530px; }
.results :is(th,td):not(:first-child), .report-group :is(th,td):not(:first-child) { text-align: center; white-space: nowrap; }
.report-title { text-align: center; margin-bottom: 1.3rem; }
.report-title img { max-height: 86px; width: auto; }
.report h2 { margin-top: 1rem; }
.signature { text-align: center; margin-top: 2rem; }
@media (max-width: 660px) {
    .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .summary > div:first-child { grid-column: 1 / -1; }
    .two-columns, .projects { grid-template-columns: minmax(0, 1fr); }
    .header-inner { gap: .8rem; }
    .brand small { font-size: .77rem; }
}
@page { size: A4 portrait; margin: 13mm; }
@media print {
    :root, :root[data-theme="dark"] { color-scheme: light; --text: #000; --card: #fff; --muted: #222; --border: #aaa; --subtle: #eef2ef; }
    body { background: #fff; color: #000; font-size: 10pt; }
    .no-print, .skip { display: none !important; }
    .wrap { width: auto; margin: 0; }
    main, .report { padding: 0; min-height: 0; border: 0; border-radius: 0; box-shadow: none; }
    .report h1 { font-size: 17pt; }
    .report h2 { font-size: 12pt; }
    .report h3 { font-size: 11pt; }
    .report .two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .table-wrap { overflow: visible; }
    .results { min-width: 0; }
    .report-title, .signature, .report-group, tr { break-inside: avoid; }
    h2, h3, .area-row { break-after: avoid; }
    thead { display: table-header-group; }
    th, td { padding: .22rem .3rem; }
}
