:root {
  --maroon: #7A1F2B;
  --maroon-2: #5E1520;
  --saffron: #E07A1F;
  --saffron-soft: #FCE9D6;
  --cream: #FBF6EE;
  --paper: #FFFFFF;
  --ink: #2A1F1A;
  --muted: #7B6D63;
  --line: #EADFD0;
  --ok: #2E7D4F;
  --ok-soft: #E3F2E8;
  --warn: #9A6200;
  --warn-soft: #FFF3D6;
  --bad: #B3261E;
  --bad-soft: #FBE9E7;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 30, 10, .06), 0 6px 20px rgba(60, 30, 10, .06);
  --font: 'Noto Sans', 'Noto Sans Oriya', 'Noto Sans Bengali', 'Noto Sans Devanagari', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Noto Serif', 'Noto Sans Oriya', 'Noto Sans Bengali', 'Noto Sans Devanagari', Georgia, serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); background: var(--cream);
  font-size: 16px; line-height: 1.5;
}
body.no-scroll { overflow: hidden; }
[hidden] { display: none !important; }
a { color: var(--maroon); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--maroon); color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; flex: none; background: #fff; }
.brand-org { font-size: .75rem; opacity: .85; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-app { font-weight: 700; font-size: 1rem; line-height: 1.25; }
.topbar-actions { display: flex; gap: 8px; flex: none; }
.topbar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.35); background: rgba(255,255,255,.08); }
.lang-chip { display: inline-flex; align-items: center; gap: 6px; }

main { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 12px; border: 1.5px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: transform .06s, background .15s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--saffron); color: #fff; box-shadow: 0 2px 0 #B85F12; }
.btn.primary:hover { background: #D06E15; }
.btn.ghost { background: transparent; color: var(--maroon); border-color: var(--line); }
.btn.ghost:hover { background: var(--saffron-soft); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .875rem; border-radius: 10px; }
.btn.big { width: 100%; min-height: 56px; font-size: 1.125rem; border-radius: 14px; }
.btn.danger { color: var(--bad); border-color: #F0C9C5; background: transparent; }
.btn.light { color: #fff; border-color: rgba(255,255,255,.4); }

/* ---------- language screen ---------- */
.hero { text-align: center; padding: 28px 8px 20px; }
.hero h1 { font-family: var(--serif); color: var(--maroon); font-size: 1.75rem; margin: 6px 0 8px; }
.hero-kicker { color: var(--saffron); font-weight: 600; font-size: .875rem; }
.lang-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.lang-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 108px; padding: 16px; border-radius: 18px; cursor: pointer;
  background: var(--paper); border: 2px solid var(--line); box-shadow: var(--shadow); font: inherit; color: var(--ink);
  transition: border-color .15s, transform .08s;
}
.lang-tile:hover, .lang-tile:focus-visible { border-color: var(--saffron); outline: none; }
.lang-tile:active { transform: scale(.98); }
.lang-native { font-size: 1.6rem; font-weight: 700; color: var(--maroon); }
.lang-en { font-size: .8rem; color: var(--muted); }

/* ---------- form ---------- */
.intro { margin: 4px 2px 16px; color: var(--muted); }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin: 0 0 16px; min-width: 0;
}
fieldset.card { padding-top: 8px; }
legend {
  display: flex; align-items: center; gap: 10px; float: left; width: 100%;
  font-weight: 700; font-size: 1.05rem; color: var(--maroon); padding: 8px 0 12px;
}
legend + * { clear: both; }
.step {
  width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--saffron-soft); color: var(--saffron); font-size: .9rem;
}
.field { margin-bottom: 14px; clear: both; }
.field:last-child { margin-bottom: 0; }
.field > label, .english-preview > label { display: block; font-weight: 600; font-size: .925rem; margin-bottom: 6px; }
.req { color: var(--bad); font-weight: 700; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row .narrow { flex: 0 0 110px; }
.row .grow { flex: 1 1 240px; }

input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; min-height: 48px; padding: 11px 12px; font: inherit; color: var(--ink);
  background: #FFFCF8; border: 1.5px solid var(--line); border-radius: 12px; appearance: none;
}
textarea { resize: vertical; min-height: 80px; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%237A1F2B' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--saffron); box-shadow: 0 0 0 3px rgba(224,122,31,.18); }
.field.invalid input, .field.invalid select, .field.invalid textarea, .field.invalid .seg { border-color: var(--bad); }
.err { color: var(--bad); font-size: .85rem; min-height: 0; margin-top: 4px; }
.err:empty { display: none; }

.with-mic { display: flex; align-items: stretch; gap: 8px; position: relative; }
.with-mic.top { align-items: flex-start; }
.with-mic > input, .with-mic > select, .with-mic > textarea, .with-mic > .seg { flex: 1; min-width: 0; }
.prefix {
  display: grid; place-items: center; padding: 0 10px; border-radius: 12px; background: var(--saffron-soft);
  color: var(--maroon); font-weight: 600; font-size: .95rem;
}
.mic {
  flex: none; width: 48px; height: 48px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--paper); color: var(--maroon); cursor: pointer; display: grid; place-items: center;
}
.mic:hover { background: var(--saffron-soft); }
.mic.on { background: var(--saffron); color: #fff; border-color: var(--saffron); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(224,122,31,.5)} 70%{box-shadow:0 0 0 12px rgba(224,122,31,0)} 100%{box-shadow:0 0 0 0 rgba(224,122,31,0)} }

.seg { display: flex; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; background: #FFFCF8; }
.seg label { flex: 1; position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: grid; place-items: center; min-height: 45px; padding: 6px 8px; font-weight: 600; font-size: .95rem; border-right: 1px solid var(--line); text-align: center; }
.seg label:last-child span { border-right: 0; }
.seg input:checked + span { background: var(--maroon); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid rgba(224,122,31,.4); outline-offset: -3px; }

.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; cursor: pointer; margin-bottom: 8px; }
.check input { width: 22px; height: 22px; accent-color: var(--maroon); flex: none; margin-top: 1px; }
.consent-card .check { margin: 0; }

.english-preview { margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: var(--saffron-soft); }
.english-preview > label { font-size: .8rem; font-weight: 600; color: var(--maroon); }
.english-preview input, .english-preview textarea { min-height: 40px; background: #fff; }

/* photo */
.photo-area { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.photo-frame {
  position: relative; width: 150px; aspect-ratio: 3/4; border-radius: 14px; overflow: hidden; flex: none;
  background: linear-gradient(180deg, #F6EEE3, #EFE3D3); border: 1.5px dashed #D8C6B0;
}
.photo-frame.has-photo { border-style: solid; border-color: var(--line); }
.photo-frame.cutout { background: linear-gradient(180deg, #FDF1E4, #F4D9BC); }
.photo-frame .silhouette { position: absolute; inset: 18% 14% 0; width: 72%; fill: #DCCAB5; }
.photo-frame.has-photo .silhouette { display: none !important; }

.photo-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-busy { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; background: rgba(255,250,244,.88); font-size: .8rem; text-align: center; padding: 8px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--saffron-soft); border-top-color: var(--saffron); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.photo-side { flex: 1 1 200px; min-width: 0; }
.photo-side p { margin: 0 0 12px; }
.photo-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-status { margin-top: 10px; font-size: .9rem; font-weight: 600; border-radius: 10px; }
.photo-status:empty { display: none; }
.photo-status.ok { color: var(--ok); }
.photo-status.warn { color: var(--warn); background: var(--warn-soft); padding: 8px 10px; font-weight: 500; }
.photo-status.bad { color: var(--bad); background: var(--bad-soft); padding: 8px 10px; }

.form-error { background: var(--bad-soft); color: var(--bad); padding: 10px 14px; border-radius: 12px; margin-bottom: 12px; font-weight: 600; }
.footer-note { text-align: center; font-size: .8rem; margin-top: 28px; }
.footer-note a { color: var(--muted); }

/* ---------- success / ID card ---------- */
.success { text-align: center; padding-top: 12px; }
.success h1 { font-family: var(--serif); color: var(--maroon); margin: 8px 0 4px; font-size: 1.6rem; }
.tick svg { width: 64px; height: 64px; }
.tick circle { fill: var(--ok-soft); stroke: var(--ok); stroke-width: 2; }
.tick path { fill: none; stroke: var(--ok); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .5s .15s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.id-card {
  margin: 20px auto 24px; max-width: 420px; text-align: left; border-radius: 18px; overflow: hidden;
  background: var(--paper); box-shadow: 0 10px 30px rgba(90, 30, 20, .15); border: 1px solid var(--line);
}
.id-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--maroon); color: #fff; }
.id-head img { width: 34px; height: 34px; border-radius: 8px; background: #fff; }
.id-org { font-weight: 700; font-size: .9rem; }
.id-event { font-size: .75rem; opacity: .85; }
.id-body { display: flex; gap: 14px; padding: 16px; background: linear-gradient(180deg, #fff, #FFF7EE); }
.id-photo { width: 104px; aspect-ratio: 3/4; flex: none; border-radius: 12px; overflow: hidden; background: linear-gradient(180deg, #FDF1E4, #F4D9BC); }
.id-photo img { width: 100%; height: 100%; object-fit: cover; }
.id-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.id-role { display: inline-block; align-self: flex-start; background: var(--saffron); color: #fff; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; }
.id-name { font-weight: 700; font-size: 1.15rem; margin-top: 4px; line-height: 1.25; }
.id-name-orig { color: var(--muted); font-size: .9rem; }
.id-sangha { font-size: .9rem; color: var(--maroon); margin-top: 2px; }
.id-reg { margin-top: auto; padding-top: 8px; font-size: .75rem; color: var(--muted); display: flex; flex-direction: column; }
.id-reg strong { font-size: 1.1rem; color: var(--ink); letter-spacing: .04em; font-variant-numeric: tabular-nums; }

/* ---------- overlays ---------- */
.sync-banner { background: var(--warn-soft); color: var(--warn); text-align: center; padding: 8px 16px; font-weight: 600; font-size: .9rem; }
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(30, 15, 10, .45); display: grid; place-items: center; padding: 16px; }
.modal-box { background: var(--paper); border-radius: 18px; padding: 20px; max-width: 420px; width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-box p { margin: 0 0 18px; font-size: 1.05rem; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.listening {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 55;
  display: flex; align-items: center; gap: 14px; min-width: min(90vw, 340px); max-width: 90vw;
  background: var(--ink); color: #fff; padding: 14px 18px; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.3); cursor: pointer;
}
.listening .pulse { width: 16px; height: 16px; border-radius: 50%; background: var(--saffron); animation: pulse 1.2s infinite; flex: none; }
.listening .interim { opacity: .75; font-size: .9rem; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; max-width: min(92vw, 480px); box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

@media (max-width: 480px) {
  .brand-app { font-size: .9rem; }
  .photo-frame { width: 128px; }
  .row .narrow { flex: 1 1 100%; }
  .hero h1 { font-size: 1.5rem; }
}

/* =================================================================
   ADMIN
   ================================================================= */
body.admin main { max-width: 1280px; }
.login-card { max-width: 380px; margin: 48px auto; }
.login-card h1 { font-family: var(--serif); color: var(--maroon); font-size: 1.4rem; margin: 0 0 16px; }
.warn-bar { background: var(--warn-soft); color: var(--warn); padding: 10px 14px; border-radius: 12px; margin-bottom: 16px; font-size: .9rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); cursor: default; text-align: left; font: inherit; color: inherit; }
button.stat { cursor: pointer; }
button.stat:hover { border-color: var(--saffron); }
.stat .num { font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .85rem; }
.stat.alert .num { color: var(--saffron); }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; }
.tab { background: none; border: 0; font: inherit; font-weight: 600; padding: 10px 16px; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tab.active { color: var(--maroon); border-bottom-color: var(--saffron); }

.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
.filters input, .filters select { min-height: 42px; padding: 8px 10px; font-size: .925rem; }
.filters-2 { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 12px; font-size: .9rem; }
.filters-2 .age { display: flex; align-items: center; gap: 6px; }
.filters-2 .age input { width: 70px; min-height: 38px; padding: 6px 8px; }
.filters-2 .check { margin: 0; font-weight: 500; }
.filters-2 .spacer { flex: 1; }
@media (max-width: 900px) { .filters { grid-template-columns: 1fr 1fr; } .filters .q { grid-column: 1 / -1; } }

.bulkbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--maroon); color: #fff; padding: 8px 12px; border-radius: 12px; margin-bottom: 10px; }
.bulkbar select { min-height: 38px; width: auto; padding: 6px 34px 6px 10px; font-size: .9rem; }
.bulkbar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.4); }

.table-wrap { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table.vol { width: 100%; border-collapse: collapse; font-size: .925rem; }
table.vol th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: #FFFBF6; white-space: nowrap; }
table.vol td { padding: 8px 12px; border-bottom: 1px solid #F3EBDF; vertical-align: middle; }
table.vol tr:last-child td { border-bottom: 0; }
table.vol tbody tr { cursor: pointer; }
table.vol tbody tr:hover { background: #FFF8F0; }
table.vol .cb { width: 36px; }
table.vol .cb input { width: 18px; height: 18px; accent-color: var(--maroon); }
.person { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.avatar { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; flex: none; background: linear-gradient(180deg, #FDF1E4, #F4D9BC); display: grid; place-items: center; font-weight: 700; color: var(--maroon); font-size: .85rem; }
.person .nm { font-weight: 600; line-height: 1.2; }
.person .sub { color: var(--muted); font-size: .8rem; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge.leader { background: var(--saffron); color: #fff; }
.badge.review { background: var(--warn-soft); color: var(--warn); }
.badge.lang { background: #F1ECE6; color: var(--muted); }
.badge.none { background: #F4F1ED; color: var(--muted); font-weight: 500; }
.nowrap { white-space: nowrap; }
.empty { padding: 36px; text-align: center; color: var(--muted); }

/* drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(30,15,10,.35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--cream); z-index: 41; overflow-y: auto; box-shadow: -10px 0 40px rgba(0,0,0,.2); }
.drawer-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--maroon); color: #fff; }
.drawer-head .btn { color: #fff; border-color: rgba(255,255,255,.4); }
.drawer-body { padding: 16px; }
.profile { display: flex; gap: 16px; margin-bottom: 16px; }
.profile .ph { width: 120px; aspect-ratio: 3/4; border-radius: 12px; overflow: hidden; background: linear-gradient(180deg, #FDF1E4, #F4D9BC); flex: none; display: grid; place-items: center; font-size: 2rem; font-weight: 700; color: var(--maroon); }
.profile .ph img { width: 100%; height: 100%; object-fit: cover; }
.profile h2 { margin: 0; font-size: 1.25rem; line-height: 1.25; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: .925rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.edit-grid .full { grid-column: 1 / -1; }
.edit-grid label { font-size: .8rem; font-weight: 600; color: var(--muted); display: block; margin-bottom: 4px; }
.edit-grid input, .edit-grid select, .edit-grid textarea { min-height: 40px; padding: 8px 10px; font-size: .925rem; }
.section-title { font-weight: 700; color: var(--maroon); margin: 18px 0 8px; font-size: .95rem; }

.remarks { display: flex; flex-direction: column; gap: 8px; }
.remark { background: var(--paper); border: 1px solid var(--line); border-left: 3px solid var(--saffron); border-radius: 10px; padding: 8px 10px; font-size: .9rem; position: relative; }
.remark .meta { color: var(--muted); font-size: .75rem; margin-top: 2px; }
.remark .x { position: absolute; top: 4px; right: 6px; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; }
.remark-form { display: flex; gap: 8px; margin-top: 8px; }
.remark-form input { min-height: 40px; padding: 8px 10px; font-size: .9rem; }

/* sanghas & groups */
.sangha-list { display: grid; gap: 14px; }
.sangha { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.sangha > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.sangha > summary::-webkit-details-marker { display: none; }
.sangha > summary .chev { transition: transform .15s; color: var(--muted); }
.sangha[open] > summary .chev { transform: rotate(90deg); }
.sangha .s-name { font-weight: 700; }
.sangha .s-loc { color: var(--muted); font-size: .85rem; }
.sangha .s-counts { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.sangha-body { border-top: 1px solid var(--line); padding: 14px 16px 16px; }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.group-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #FFFCF8; display: flex; flex-direction: column; gap: 8px; }
.group-card .g-head { display: flex; align-items: center; gap: 8px; }
.group-card .g-name { font-weight: 700; flex: 1; }
.group-card .leader-row { display: flex; align-items: center; gap: 8px; background: var(--saffron-soft); border-radius: 10px; padding: 6px 8px; }
.group-card .leader-row .avatar { width: 32px; height: 32px; }
.group-card select { min-height: 38px; padding: 6px 30px 6px 10px; font-size: .875rem; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.inline-form input { width: auto; flex: 1 1 180px; min-height: 40px; padding: 8px 10px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .two-col, .edit-grid { grid-template-columns: 1fr; } .kv { grid-template-columns: 100px 1fr; } }
.link-btn { background: none; border: 0; padding: 0; color: var(--maroon); font: inherit; font-size: .85rem; text-decoration: underline; cursor: pointer; }
.i18n-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }

/* Event name on the language screen */
.event-name { margin-top: 28px; padding-top: 18px; border-top: 1px dashed var(--line); text-align: center;
  font-family: var(--serif); font-weight: 700; font-size: 1.15rem; color: var(--maroon); letter-spacing: .01em; }
/* Language tiles: Odia · Bengali / Assamese · Hindi / English (full width) */
.lang-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.lang-tile[lang="en"] { grid-column: 1 / -1; }
#lang-select option { color: var(--ink); background: #fff; }
.field > label.check { font-weight: 500; font-size: 1rem; display: flex; }

/* =================================================================
   MOBILE-FIRST STEP FLOW — each step fits one phone screen
   ================================================================= */
.progress { margin: 0 0 12px; }
.progress-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.progress-steps span { height: 6px; border-radius: 99px; background: var(--line); transition: background .2s; }
.progress-steps span.done { background: var(--maroon); }
.progress-steps span.current { background: var(--saffron); }
.progress-label { margin-top: 6px; font-size: .85rem; color: var(--muted); }
.progress-label b { color: var(--maroon); }
#progress + form .intro { margin-top: 0; }

.consent-field { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.consent-field .check { margin: 0; }

.wizard-nav {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; gap: 10px; margin: 0 -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(251,246,238,0) 0, var(--cream) 14px);
}
.wizard-nav .btn { flex: 1; min-height: 52px; font-size: 1.05rem; border-radius: 14px; }
.wizard-nav #back-btn { flex: 0 0 34%; background: var(--paper); }
body.public main { padding-bottom: 8px; }
.form-error { margin-top: 4px; }

/* never allow sideways scrolling on a phone */
html, body { overflow-x: hidden; max-width: 100%; }
input, select, textarea { font-size: 16px; } /* ≥16px stops iOS zooming on focus */
select { text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 400px) {
  main { padding: 12px 12px 8px; }
  .wizard-nav { margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
  .topbar { padding-left: 12px; padding-right: 12px; }
  .brand-org { display: none; }
  .brand-mark { width: 32px; height: 32px; }
  .card { padding: 12px; border-radius: 12px; }
  legend { font-size: 1rem; padding: 4px 0 10px; }
  .field { margin-bottom: 12px; }
  .mic { width: 46px; height: 46px; }
  .seg span { font-size: .875rem; padding: 6px 4px; }
  .prefix { padding: 0 8px; font-size: .9rem; }
  .intro { font-size: .9rem; margin-bottom: 10px; }
  .lang-tile { min-height: 88px; }
  .lang-native { font-size: 1.4rem; }
  .hero { padding: 16px 4px 14px; }
}
@media (max-width: 340px) {
  .lang-chip span { display: none; }       /* globe icon only */
  .brand-app { font-size: .82rem; }
  .seg span { font-size: .8rem; }
}
/* short phones: tighten vertical rhythm so a step still fits */
@media (max-height: 700px) {
  .photo-frame { width: min(118px, 34vw); }
  .photo-side p { margin-bottom: 8px; font-size: .82rem; }
  textarea { min-height: 64px; }
  .success h1 { font-size: 1.35rem; }
  .id-card { margin: 12px auto 16px; }
}
@media (max-width: 480px) {
  .photo-area { flex-wrap: nowrap; gap: 12px; }
  .photo-frame { width: min(130px, 36vw); }
  .photo-buttons { flex-direction: column; }
  .photo-buttons .btn { width: 100%; }
  .id-photo { width: 92px; }
  .id-name { font-size: 1.05rem; }
}

/* Admin on a phone: table rows become cards */
@media (max-width: 720px) {
  body.admin main { padding: 12px; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { padding: 10px; }
  .stat .num { font-size: 1.35rem; }
  .stat .lbl { font-size: .75rem; line-height: 1.25; }
  .tabs { overflow-x: auto; }
  .tab { white-space: nowrap; padding: 10px 12px; }
  .table-wrap { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  table.vol thead { display: none; }
  table.vol, table.vol tbody { display: block; }
  table.vol tr { display: grid; grid-template-columns: 28px 1fr auto; gap: 4px 10px; align-items: center;
    background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; }
  table.vol td { display: block; padding: 0; border: 0; }
  table.vol td:nth-child(2) { grid-column: 2 / 4; }
  table.vol td:nth-child(n+3) { grid-column: 2 / 4; font-size: .85rem; }
  table.vol td:nth-child(5), table.vol td:nth-child(7), table.vol td:nth-child(8) { display: none; }
  .person { min-width: 0; }
  .filters-2 .spacer { display: none; }
  .topbar-actions #lang-select { max-width: 110px; }
  .drawer-body { padding: 12px; }
  .profile .ph { width: 96px; }
}

/* Keep Back/Next at the bottom of the screen (thumb reach) on every phone */
body.public { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
body.public main { flex: 1; width: 100%; display: flex; flex-direction: column; }
#form-screen:not([hidden]) { flex: 1; display: flex; flex-direction: column; }
#form-screen #reg-form { flex: 1; display: flex; flex-direction: column; }
#form-screen .wizard-nav { margin-top: auto; }
body.public main { padding-bottom: 0; }
@media (max-height: 640px) {
  .intro { display: none; }
  .progress { margin-bottom: 8px; }
  legend { padding-bottom: 6px; }
  .field > label { margin-bottom: 4px; }
  .english-preview { padding: 6px 10px; margin-top: 6px; }
  input:not([type=checkbox]):not([type=radio]), select { min-height: 44px; padding-top: 8px; padding-bottom: 8px; }
  .mic { height: 44px; }
  .seg span { min-height: 42px; }
  .wizard-nav { padding-top: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .wizard-nav .btn { min-height: 46px; }
}


/* =================================================================
   PHOTO STEP — live camera inside the form
   ================================================================= */
.cam { display: grid; gap: 10px; justify-items: center; }
.cam-frame {
  position: relative; overflow: hidden; border-radius: 18px;
  aspect-ratio: 3 / 4; height: min(40vh, 420px); height: min(40dvh, 420px); max-width: 100%;
  background: #2A2020;
}
.cam-frame video, .cam-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
.cam-frame .cam-guide { z-index: 2; }
.cam-frame .cam-msg, .cam-frame .photo-busy { z-index: 3; }
.cam-frame video.mirror { transform: scaleX(-1); }
.cam-frame.has-photo video, .cam-frame:not(.live) video { visibility: hidden; }
.cam-frame.cutout { background: linear-gradient(180deg, #FDF1E4, #F4D9BC); }
/* dotted oval: dims everything outside it, turns green when the face fits */
.cam-guide {
  position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%);
  width: 62%; height: 62%; border-radius: 50% 50% 46% 46% / 55% 55% 45% 45%;
  border: 3px dashed rgba(255, 255, 255, .9);
  pointer-events: none; transition: border-color .2s, box-shadow .2s;
}
.cam-frame.aligned .cam-guide { border: 4px solid #3DDC84; }
/* dim everything outside the oval */
.cam-frame::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse 31% 31% at 50% 45%, transparent 99%, rgba(20, 10, 10, .5) 100%); }
.cam-frame.has-photo::after, .cam-frame.no-cam::after, .cam-frame:not(.live)::after { display: none; }
.cam-frame.has-photo .cam-guide, .cam-frame.no-cam .cam-guide { display: none; }
.cam-msg { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 20px; text-align: center; color: #F3E7DA; font-size: .95rem; }
.photo-status.guide { color: var(--muted); font-weight: 600; background: none; padding: 0; }
.photo-status.guide.ok { color: var(--ok); }
.photo-status { text-align: center; min-height: 1.4em; }
.cam-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; width: 100%; max-width: 360px; }
.cam-controls #upload-photo-label { justify-self: start; white-space: nowrap; font-size: .85rem; padding-inline: 10px; }
.cam-controls .icon-btn { justify-self: end; width: 46px; padding: 0; }
.cam-controls .shutter, .cam-controls #retake-btn { grid-column: 2; }
.shutter {
  width: 66px; height: 66px; border-radius: 50%; cursor: pointer;
  border: 4px solid var(--paper); background: var(--saffron); box-shadow: 0 0 0 3px var(--saffron), 0 4px 12px rgba(0,0,0,.18);
}
.shutter:active { transform: scale(.95); }
.shutter:disabled { opacity: .45; cursor: default; }
.cam-frame.aligned ~ .cam-controls .shutter { box-shadow: 0 0 0 3px #2E7D4F, 0 4px 12px rgba(0,0,0,.18); }
@media (max-height: 780px) { .cam-frame { height: min(36dvh, 420px); } } @media (max-height: 640px) { .cam-frame { height: 32dvh; } .shutter { width: 58px; height: 58px; } }
.cam .photo-status.bad, .cam .photo-status.warn { padding: 5px 10px; font-size: .85rem; line-height: 1.35; max-width: 360px; }

/* Start over + home */
.progress-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.progress-row .progress-label { margin-top: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.restart-btn { flex: none; display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; padding: 6px 2px; font: inherit; font-size: .85rem; font-weight: 600; color: var(--maroon); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
#brand { cursor: pointer; border-radius: 10px; }
#brand:focus-visible { outline: 2px solid rgba(255,255,255,.7); outline-offset: 4px; }
