:root {
  color-scheme: light;
  --navy: #171b52;
  --navy-2: #2a3170;
  --ink: #1f2333;
  --ink-2: #454a5e;
  --muted: #6b7083;
  --bg: #f3f4f7;
  --card: #ffffff;
  --line: #d8dbe3;
  --line-2: #e9ebf0;
  --saffron: #f47b20;
  --saffron-bg: #fff4ea;
  --green: #138808;
  --ok: #1b6e35;
  --ok-bg: #edf7f0;
  --err: #b3261e;
  --err-bg: #fdf0ef;
  --focus: rgba(244, 123, 32, .35);
  --radius: 6px;
  font-size: 17px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select, textarea { font: inherit; color: inherit; }

.tricolor { height: 5px; background: linear-gradient(90deg, #ff9933 0 33.3%, #ffffff 33.3% 66.6%, #138808 66.6%); }

.topbar { position: sticky; top: 0; z-index: 10; background: var(--card); box-shadow: 0 1px 0 var(--line), 0 2px 6px rgba(23, 27, 82, .06); padding-top: env(safe-area-inset-top); }
.topbar-head { background: var(--navy); color: #fff; }
.topbar-inner { max-width: 680px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; gap: 12px; }
.brand { font-weight: 700; font-size: .98rem; line-height: 1.3; letter-spacing: .1px; }
.brand small { display: block; font-weight: 400; font-size: .72rem; opacity: .8; letter-spacing: .3px; }
#langSwitch { background: #fff; color: var(--navy); border: 0; border-radius: 4px; padding: 6px 10px; font-size: .88rem; font-weight: 600; }

.steps { list-style: none; margin: 0 auto; padding: 10px 16px; max-width: 680px; display: flex; counter-reset: step; }
.steps li { flex: 1; position: relative; counter-increment: step; font-size: .72rem; text-align: center; color: var(--muted); }
.steps li::before {
  content: counter(step); display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; margin: 0 auto 3px; border-radius: 50%;
  border: 2px solid var(--line); background: #fff; color: var(--muted); font-weight: 700; font-size: .8rem;
  position: relative; z-index: 1;
}
.steps li + li::after { content: ""; position: absolute; top: 13px; right: 50%; width: 100%; height: 2px; background: var(--line); }
.steps li.done::before { content: "✓"; background: var(--green); border-color: var(--green); color: #fff; }
.steps li.done + li::after, .steps li.now::after { background: var(--green); }
.steps li.now::before { background: var(--navy); border-color: var(--navy); color: #fff; }
.steps li.now { color: var(--navy); font-weight: 700; }

main { max-width: 680px; margin: 0 auto; padding: 18px 16px 120px; outline: none; }
h1 { font-size: 1.4rem; line-height: 1.3; margin: 4px 0 8px; color: var(--navy); }
h2 { font-size: 1.12rem; margin: 18px 0 8px; color: var(--navy); }
.lead { color: var(--ink-2); margin: 0 0 16px; }
.muted { color: var(--muted); font-size: .86rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; }
.loading { text-align: center; color: var(--muted); padding: 40px 0; }
.notice { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--navy); border-radius: var(--radius); padding: 12px 14px; font-size: .84rem; color: var(--ink-2); }
.deadline { display: inline-flex; align-items: center; gap: 6px; background: var(--saffron-bg); color: #9a4a0b; border: 1px solid #f7c9a1; border-radius: 4px; padding: 4px 10px; font-size: .84rem; font-weight: 700; margin-bottom: 12px; }
.deadline::before { content: "⏱"; }

.lang-grid { display: grid; gap: 10px; margin: 12px 0 18px; }
.lang-btn {
  display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 60px; padding: 12px 16px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); font-size: 1.2rem; font-weight: 700; color: var(--navy); cursor: pointer;
}
.lang-btn[aria-pressed="true"] { border: 2px solid var(--navy); box-shadow: inset 4px 0 0 var(--saffron); }
.lang-btn small { font-weight: 400; color: var(--muted); font-size: .84rem; }

.field { margin-bottom: 14px; }
.field label, .field .label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; color: var(--ink); }
.field .req { color: var(--err); }
.field .opt { color: var(--muted); font-weight: 400; font-size: .78rem; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 4px; border: 1px solid #c3c7d2; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--saffron); }
.field input:disabled, .field select:disabled { background: #f1f2f5; color: var(--muted); }
.field .hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.field .error { display: none; color: var(--err); font-size: .8rem; margin-top: 4px; font-weight: 600; }
.field.invalid input, .field.invalid select { border-color: var(--err); background: var(--err-bg); }
.field.invalid .error { display: block; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

details.section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
details.section > summary {
  list-style: none; cursor: pointer; padding: 13px 16px; font-weight: 700; color: var(--navy);
  display: flex; justify-content: space-between; gap: 8px; align-items: center; border-left: 4px solid var(--navy);
}
details.section[open] > summary { background: #f7f8fb; border-bottom: 1px solid var(--line); }
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::after { content: "▾"; color: var(--muted); transition: transform .2s; }
details.section[open] > summary::after { transform: rotate(180deg); }
details.section > summary .count { margin-left: auto; font-weight: 600; font-size: .75rem; color: var(--ok); background: var(--ok-bg); border-radius: 3px; padding: 1px 7px; white-space: nowrap; }
.q { padding: 14px 16px; border-top: 1px solid var(--line-2); }
.q:first-of-type { border-top: 0; }
.q-text { margin: 0 0 10px; font-size: .94rem; }
.q-text b { color: var(--saffron); margin-right: 5px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; border: 0; margin: 0; padding: 0; }
.chips legend { font-size: .8rem; color: var(--muted); font-weight: 600; padding: 0; margin-bottom: 4px; width: 100%; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 8px 14px 8px 10px;
  border-radius: 4px; border: 1px solid #c3c7d2; background: #fff; font-size: .9rem; font-weight: 600; color: var(--ink-2);
}
.chip span::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #9aa0b2; flex: 0 0 16px; background: #fff; }
.chip input:checked + span { border-color: var(--navy); background: #eef0f9; color: var(--navy); }
.chip input:checked + span::before { border-color: var(--navy); background: radial-gradient(circle, var(--navy) 0 4px, #fff 5px); }
.chip input:focus-visible + span { outline: 3px solid var(--focus); }
.reason { margin: 10px 0 0; font-size: .82rem; color: var(--ink-2); background: #f7f8fb; border-left: 3px solid var(--saffron); padding: 6px 10px; border-radius: 0 4px 4px 0; }
.reason .star { color: var(--saffron); font-weight: 700; }
.age-row { display: grid; gap: 10px; }

.essay textarea { min-height: 220px; line-height: 1.6; font-size: .92rem; resize: vertical; }
.opt-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.opt-chips::-webkit-scrollbar { display: none; }
.opt-chips button { flex: 0 0 auto; max-width: 230px; text-align: left; border: 1px solid #c3c7d2; background: #fff; border-radius: 4px; padding: 8px 12px; font-size: .8rem; line-height: 1.3; cursor: pointer; color: var(--ink-2); }
.opt-chips button[aria-pressed="true"] { border-color: var(--navy); background: var(--navy); color: #fff; }
.counter { text-align: right; font-size: .76rem; color: var(--muted); margin-top: 4px; }
.counter.over { color: var(--err); font-weight: 700; }
.edited { font-size: .76rem; color: var(--ok); }

.summary dl { display: grid; grid-template-columns: auto 1fr; gap: 0; margin: 0; font-size: .9rem; }
.summary dt, .summary dd { padding: 7px 0; border-bottom: 1px solid var(--line-2); }
.summary dt { color: var(--muted); padding-right: 14px; }
.summary dd { margin: 0; font-weight: 600; word-break: break-word; }
.consent { display: flex; gap: 12px; align-items: flex-start; font-weight: 600; padding: 12px; margin: 4px 0 8px; cursor: pointer; background: #f7f8fb; border: 1px solid var(--line); border-radius: 4px; }
.consent input { width: 22px; height: 22px; flex: 0 0 22px; margin-top: 2px; accent-color: var(--navy); }
.success { border: 1px solid #b9dcc4; border-top: 4px solid var(--green); background: var(--ok-bg); }
.success h2 { color: var(--ok); margin-top: 0; }
.warn { background: var(--err-bg); color: var(--err); border: 1px solid #f0c4c0; border-radius: 4px; padding: 12px 14px; font-weight: 600; font-size: .88rem; }
.linkrow { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

.btn { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 50px; padding: 12px 20px; border-radius: 4px; border: 1px solid transparent; font-weight: 700; font-size: 1rem; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-primary:disabled { background: #9a9db5; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--navy); border-color: var(--navy); }
.btn-wa { background: #1fa855; color: #fff; }
.btn-small { min-height: 40px; padding: 7px 14px; font-size: .86rem; }
.btn-block { width: 100%; }
.bottombar { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -2px 8px rgba(23, 27, 82, .06); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); z-index: 9; }
.bottombar-inner { max-width: 680px; margin: 0 auto; display: flex; gap: 10px; }
.bottombar .btn-primary { flex: 1; }
.bottombar .btn-ghost { min-width: 56px; }

.toast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 4px; font-size: .88rem; z-index: 20; max-width: calc(100% - 32px); text-align: center; box-shadow: 0 4px 14px rgba(0, 0, 0, .2); }
.testbanner { background: var(--err); color: #fff; font-weight: 700; font-size: .82rem; text-align: center; padding: 6px 12px; word-break: break-all; }

@media (min-width: 560px) {
  .age-row { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
