:root {
  --primary: #1f5fa6;
  --primary-dark: #184c85;
  --success: #1e8e4e;
  --error: #c0392b;
  --bg: #eef2f7;
  --card: #ffffff;
  --text: #13233a;
  --muted: #667488;
  --border: #d6deea;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans Lao', 'Phetsarath OT', 'Saysettha OT', 'Lao Sangam MN',
    'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 17px;
  line-height: 1.6;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  background: var(--primary);
  color: #fff;
  padding: 18px 20px calc(18px + env(safe-area-inset-top));
  padding-top: max(18px, env(safe-area-inset-top));
  text-align: center;
}
.topbar-title { font-size: 20px; font-weight: 800; }
.topbar-sub { font-size: 14px; opacity: 0.9; margin-top: 2px; }

.view {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.view[hidden] { display: none; }

#view-loading, #view-error, #view-success {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
}

.muted { color: var(--muted); }
.foot { text-align: center; font-size: 12px; padding: 14px; }

.spinner {
  width: 42px; height: 42px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.state-icon {
  width: 72px; height: 72px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 40px; font-weight: 800; color: #fff;
  margin-bottom: 8px;
}
.state-icon.success { background: var(--success); }
.state-icon.error { background: var(--error); }

.school-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.school-row { display: flex; gap: 8px; padding: 3px 0; }
.school-row .label { color: var(--muted); min-width: 56px; }
.school-row .value { font-weight: 700; }

.radio-list { display: flex; flex-direction: row; gap: 10px; }
.radio-row {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}
.radio-row input[type="radio"] {
  width: 22px; height: 22px;
  accent-color: var(--primary);
  margin: 0;
  flex: 0 0 auto;
  cursor: pointer;
}
.radio-row .radio-text { font-size: 18px; font-weight: 600; }
.radio-row:has(input:checked) { border-color: var(--primary); background: #f3f8fd; }

.field { margin-bottom: 18px; }
.field > label, .group-label {
  display: block;
  font-weight: 600;
  margin-bottom: 7px;
}
.req { color: var(--error); }

input[type="text"], input[type="tel"] {
  width: 100%;
  font: inherit;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
}
input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31,95,166,.15); }
.field.invalid input { border-color: var(--error); }

.err { color: var(--error); font-size: 14px; margin-top: 6px; min-height: 0; }
.err:empty { display: none; }

.banner {
  background: #fdecea; color: var(--error);
  border: 1px solid #f5c6c0; border-radius: 10px;
  padding: 10px 12px; margin-bottom: 14px; font-size: 15px;
}

.btn {
  width: 100%;
  font: inherit; font-weight: 700;
  padding: 15px;
  border: none; border-radius: 12px;
  cursor: pointer;
  min-height: 52px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-secondary { background: #fff; color: var(--primary); border: 2px solid var(--primary); margin-top: 16px; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
