/* Survey — FO house style (light content, DM Sans, Sora display), one accent.
 * Mobile-first: thumb-sized targets (>= 48px), 16px+ inputs (no iOS zoom),
 * never scrolls sideways. Logical properties only (margin-inline-*, inset-inline-*)
 * so Arabic mirrors without a second stylesheet. No inline styles (CSP style-src 'self').
 */
:root {
  --accent: #0d9488; --accent-strong: #0f766e; --accent-soft: #f0fdfa; --accent-ring: rgba(13, 148, 136, .28);
  --bg: #f5f6fa; --surface: #fff; --surface-2: #f8fafc; --ink: #0f172a; --ink-2: #334155; --muted: #64748b;
  --line: #e2e8f0; --line-strong: #cbd5e1;
  --good: #15803d; --good-soft: #ecfdf3; --bad: #b91c1c; --bad-soft: #fef2f2; --warn: #b45309; --warn-soft: #fffbeb;
  --r-card: 14px; --r-ctl: 10px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(15, 23, 42, .06); --shadow-2: 0 8px 24px rgba(15, 23, 42, .10);
  --font: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Sora', 'DM Sans', system-ui, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}
.lang-ar { --font: 'Segoe UI', 'Noto Naskh Arabic', 'Noto Sans Arabic', Tahoma, 'Geeza Pro', sans-serif; --font-display: var(--font); }
.lang-zh { --font: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', 'Hiragino Sans GB', 'DM Sans', sans-serif; --font-display: var(--font); }
.lang-zh-Hant { --font: 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans TC', 'Heiti TC', 'DM Sans', sans-serif; --font-display: var(--font); }
/* The vendored DM Sans / Sora / DM Mono cover Latin + Latin Extended only: no Greek, and not the
   Vietnamese block (U+1EA0–1EF9). Mixing fonts inside a word looks broken, so these two languages use
   the system UI font (SF / Segoe UI / Roboto / Noto all cover both). */
.lang-vi, .lang-el { --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-display: var(--font); }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); overflow-x: hidden; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1.02rem; }
p { margin: 0 0 .6rem; }
a { color: var(--accent-strong); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); } .small { font-size: .88rem; } .center { text-align: center; }
.hp { position: absolute; inset-inline-start: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem 1rem;
  background: #0f172a; color: #e2e8f0; position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; font-family: var(--font-display);
  font-weight: 600; font-size: .98rem; min-width: 0; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang select { max-width: 10.5rem; background: #1e293b; color: #fff; border: 1px solid #334155; border-radius: var(--r-ctl); padding: .45rem .6rem;
  font: inherit; font-size: 15px; min-height: 40px; }

/* status bar */
.statusbar { position: sticky; top: 56px; z-index: 15; background: var(--surface); border-bottom: 1px solid var(--line);
  padding: .5rem 1rem .4rem; box-shadow: var(--shadow-1); }
.statusbar-row { display: flex; align-items: center; gap: .6rem; max-width: 760px; margin: 0 auto; }
.progress { flex: 1; display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.progress-meta { display: flex; gap: .6rem; align-items: baseline; min-width: 0; }
.link-btn { flex: none; }
progress { width: 100%; height: 8px; appearance: none; -webkit-appearance: none; border: 0; border-radius: var(--r-pill);
  background: var(--line); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--line); border-radius: var(--r-pill); }
progress::-webkit-progress-value { background: var(--accent); border-radius: var(--r-pill); }
progress::-moz-progress-bar { background: var(--accent); border-radius: var(--r-pill); }
.progress-label { font-size: .82rem; color: var(--muted); white-space: nowrap; }
.save-state { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.save-state[data-state="saved"] { color: var(--good); }
.save-state[data-state="error"], .save-state[data-state="offline"] { color: var(--warn); }
.steps { display: flex; gap: .35rem; overflow-x: auto; max-width: 760px; margin: 0 auto; padding: .7rem 1rem 0;
  scrollbar-width: none; }
.steps::-webkit-scrollbar { display: none; }
.step { flex: none; font-size: .82rem; text-decoration: none; color: var(--ink-2); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-pill); padding: .25rem .7rem; white-space: nowrap; }
.step.current { background: var(--accent); border-color: var(--accent); color: #fff; }
.draft-banner { background: var(--warn-soft); color: var(--warn); border: 1px solid #fde68a; border-radius: var(--r-ctl);
  padding: .4rem .7rem; font-size: .88rem; max-width: 760px; margin: 0 auto .4rem; }
.draft-banner.closed { background: var(--bad-soft); color: var(--bad); border-color: #fecaca; }

/* layout */
.wrap { max-width: 760px; margin: 0 auto; padding: 1rem 1rem 6rem; }
.foot { max-width: 760px; margin: 0 auto; padding: 1rem; display: flex; justify-content: space-between; color: var(--muted);
  font-size: .85rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 1rem;
  margin-block-end: .9rem; box-shadow: var(--shadow-1); }
.hero { padding: .5rem 0 1rem; } .lead { font-size: 1.05rem; color: var(--ink-2); }
.notice { border-inline-start: 4px solid var(--accent); }
.notice.warn { border-inline-start-color: var(--warn); background: var(--warn-soft); }
.ticks { margin: 0; padding-inline-start: 1.2rem; } .ticks li { margin-block-end: .35rem; }
.page-head { margin-block-end: .8rem; }
.prose p { max-width: 60ch; }

/* survey choice */
.cards { display: grid; gap: .8rem; }
.survey-card { display: grid; grid-template-columns: auto 1fr; gap: .4rem .9rem; align-items: center; text-decoration: none;
  color: inherit; }
.survey-card:hover { border-color: var(--accent); }
.survey-icon { font-size: 2rem; grid-row: span 2; }
.survey-body { display: flex; flex-direction: column; gap: .2rem; }
.survey-body span { color: var(--ink-2); font-size: .95rem; }
.survey-card .btn { grid-column: 2; justify-self: start; }

/* forms */
.form h2 { margin-block-start: .2rem; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-block-end: .9rem; border: 0; padding: 0; min-width: 0; }
fieldset.field > legend { font-weight: 600; padding: 0; margin-block-end: .3rem; }
label, .group-label { font-weight: 600; font-size: .95rem; }
.group-label { margin: 0 0 .3rem; color: var(--ink-2); }
.req { color: var(--bad); } .opt { font-weight: 400; color: var(--muted); font-size: .88rem; }
.hint { color: var(--muted); font-size: .9rem; margin: 0; }
input[type=text], input[type=email], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl); padding: .7rem .8rem; min-height: 48px; }
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, summary:focus-visible { outline: 3px solid var(--accent-ring);
  outline-offset: 1px; border-color: var(--accent); }
.has-error input, .has-error select, input[aria-invalid=true] { border-color: var(--bad); background: var(--bad-soft); }
.err { color: var(--bad); font-size: .88rem; margin: 0; min-height: 0; }
.err:empty { display: none; }
.err-summary { background: var(--bad-soft); color: var(--bad); border-radius: var(--r-ctl); padding: .6rem .8rem; font-weight: 600; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 500; cursor: pointer; padding: .3rem 0; }
.check input { width: 22px; height: 22px; flex: none; margin-block-start: .1rem; accent-color: var(--accent); }
.grid2, .grid3 { display: grid; gap: 0 .7rem; grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tree-select-row { display: grid; gap: .5rem; grid-template-columns: 1fr; }
@media (min-width: 560px) { .tree-select-row { grid-template-columns: 1fr 1fr; } }
.privacy { background: var(--surface-2); border-radius: var(--r-ctl); padding: .8rem; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600;
  border-radius: var(--r-ctl); padding: .65rem 1.1rem; min-height: 48px; border: 1px solid transparent; cursor: pointer;
  text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; } .btn-primary:hover { background: var(--accent-strong); }
.btn-secondary { background: var(--surface); color: var(--accent-strong); border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line-strong); }
.btn-small { min-height: 36px; padding: .3rem .7rem; font-size: .88rem; }
.btn-big { width: 100%; font-size: 1.05rem; min-height: 54px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-block-start: 1rem; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 1rem 0 .8rem;
  z-index: 5; }
.sticky-actions .btn-big { flex: 1; width: auto; }

/* category tiles */
.tiles { border: 0; padding: 0; margin: 0; display: grid; gap: .6rem; grid-template-columns: 1fr 1fr; }
.tiles input { position: absolute; opacity: 0; pointer-events: none; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: .2rem; border: 2px solid var(--line);
  border-radius: var(--r-card); padding: .9rem; min-height: 96px; cursor: pointer; background: var(--surface); }
.tile-icon { font-size: 1.6rem; } .tile-count { font-weight: 400; font-size: .82rem; color: var(--muted); }
.tiles input:checked + .tile { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-ring); }
.tiles input:focus-visible + .tile { outline: 3px solid var(--accent-ring); }

/* item cards */
.item { padding: .9rem; }
.item-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem .6rem; margin-block-end: .6rem; }
.item-head h3 { flex: 1 1 100%; margin: 0; }
.code { font-family: var(--font-mono); font-size: .9em; color: var(--accent-strong); unicode-bidi: isolate; }
.badge { font-size: .75rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: .05rem .55rem; color: var(--ink-2); }
.badge-pending { background: var(--warn-soft); border-color: #fde68a; color: var(--warn); }
.card-state { font-size: .82rem; color: var(--muted); margin-inline-start: auto; }
.card-state[data-state="saved"] { color: var(--good); } .card-state[data-state="error"] { color: var(--bad); }
.seg { border: 0; padding: 0; margin: 0 0 .7rem; display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 48px; padding: .4rem .6rem;
  border: 2px solid var(--line-strong); border-radius: var(--r-ctl); cursor: pointer; font-size: .92rem; background: var(--surface); }
.seg input:checked + label { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.seg input[value=false]:checked + label { border-color: var(--muted); background: var(--surface-2); color: var(--ink-2); }
.seg input:focus-visible + label { outline: 3px solid var(--accent-ring); }
.fields { border: 0; padding: 0; margin: 0; min-width: 0; }
.item:has(.seg input[value=false]:checked) .fields { display: none; }
.item:has(.seg input[value=false]:checked) { background: var(--surface-2); }
.item:has(.seg input[value=false]:checked) .item-head h3 { color: var(--muted); }
.lab-item-collapsed .fields { display: none; }
.field-min, .field-int { margin-block-end: .5rem; }
.field-min label, .field-int label { font-size: .82rem; font-weight: 600; color: var(--ink-2); min-height: 2.4em; display: flex; align-items: flex-end; }
.input-suffix { position: relative; }
.input-suffix input { padding-inline-end: 2.6rem; text-align: end; font-family: var(--font-mono); font-size: 18px; }
.suffix { position: absolute; inset-inline-end: .65rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .8rem; pointer-events: none; }
.hint-hm { font-size: .78rem; color: var(--muted); min-height: 1.1em; }
.stepper { display: grid; grid-template-columns: 48px 1fr 48px; gap: .3rem; }
.stepper input { text-align: center; font-family: var(--font-mono); font-size: 18px; }
.step-btn { min-height: 48px; border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: var(--r-ctl);
  font-size: 1.3rem; cursor: pointer; color: var(--ink-2); }
.comment summary { cursor: pointer; color: var(--accent-strong); font-size: .9rem; padding: .3rem 0; }
.comment textarea { margin-block-start: .3rem; }
.is-pending { border-style: dashed; }

/* groups (lab) */
.group { margin-block-end: 1rem; }
.group > summary { list-style: none; cursor: pointer; padding: .4rem 0; }
.group > summary::-webkit-details-marker { display: none; }
.group > summary h2 { display: inline-flex; gap: .5rem; align-items: center; }
.group > summary h2::before { content: '▸'; color: var(--muted); }
.group[open] > summary h2::before { content: '▾'; }
[dir=rtl] .group > summary h2::before { content: '◂'; }
[dir=rtl] .group[open] > summary h2::before { content: '▾'; }
.count { font-size: .8rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 0 .5rem; font-weight: 600; }
.search { display: flex; gap: .5rem; margin-block-end: 1rem; }
.search input { flex: 1; }

/* add-an-item box */
.add { border-style: dashed; }
.add-cta { cursor: pointer; font-weight: 600; color: var(--accent-strong); list-style: none; min-height: 32px; display: flex; gap: .5rem; align-items: center; }
.add-cta::-webkit-details-marker { display: none; }
.add[open] .add-cta { margin-block-end: .8rem; }
.guidance { background: var(--surface-2); border-radius: var(--r-ctl); padding: .7rem .8rem; margin-block-end: .8rem; font-size: .92rem; }
.ex { margin: .2rem 0 0; } .ex.good { color: var(--good); } .ex.bad { color: var(--bad); text-decoration: line-through; text-decoration-thickness: 1px; }
.suggest-host { position: relative; }
.suggestions { border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--surface); box-shadow: var(--shadow-2);
  margin-block-start: .3rem; overflow: hidden; }
.sugg-title, .sugg-ignore { font-size: .8rem; color: var(--muted); margin: 0; padding: .45rem .7rem; }
.suggestions ul { list-style: none; margin: 0; padding: 0; }
.suggestions li button { display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; width: 100%; text-align: start;
  background: none; border: 0; border-top: 1px solid var(--line); padding: .6rem .7rem; font: inherit; cursor: pointer; min-height: 52px; color: var(--ink); }
.suggestions li button:hover, .suggestions li button:focus { background: var(--accent-soft); outline: none; }
.sugg-meta { font-size: .78rem; color: var(--muted); }
.sugg-meta .st-active { color: var(--good); font-weight: 600; } .sugg-meta .st-pending { color: var(--warn); font-weight: 600; }
.confirm-panel { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--r-ctl); padding: .8rem; margin-block-start: .5rem; }
.stored { font-size: 1.1rem; font-weight: 600; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: .5rem .7rem; }
.flags { margin: .3rem 0 .6rem; padding-inline-start: 1.2rem; color: var(--warn); font-size: .92rem; }
.dup-choice { margin-block-end: .6rem; }

/* resume link */
.copy-row { display: flex; gap: .5rem; margin: .6rem 0; }
.copy-row input { flex: 1; font-family: var(--font-mono); font-size: 14px; }
.welcome-back h2 { margin-top: 0; }
.welcome-back .not-you { margin-top: .4rem; }
.other-device { margin-top: 1rem; }
.other-device summary { cursor: pointer; color: var(--ink-2); }

/* review */
.summary { list-style: none; padding: 0; margin: .5rem 0; }
.summary li { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.summary li > div { display: flex; flex-wrap: wrap; gap: .3rem .5rem; align-items: center; }
.pill { font-size: .78rem; border-radius: var(--r-pill); padding: .05rem .55rem; background: var(--surface-2); border: 1px solid var(--line); }
.pill.good { background: var(--good-soft); color: var(--good); border-color: #bbf7d0; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.big-tick { font-size: 3rem; color: var(--good); }

@media (min-width: 720px) {
  h1 { font-size: 1.7rem; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .item { padding: 1.1rem 1.2rem; }
  .item-head h3 { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .tile, .seg label { transition: background-color .12s, border-color .12s; }
}

/* consent gate: full-screen card, only "agree" or "do not agree" leave it */
.gate-backdrop { min-height: calc(100vh - 140px); display: flex; align-items: center; justify-content: center; }
.gate { max-width: 620px; width: 100%; box-shadow: var(--shadow-2); border-top: 4px solid var(--accent); }
.gate-points { margin: .4rem 0 .8rem; padding-inline-start: 1.2rem; }
.gate-points li { margin-block-end: .45rem; }
.gate-check { background: var(--surface-2); border-radius: var(--r-ctl); padding: .7rem; font-weight: 600; }
.gate-actions { flex-direction: column; }
.gate-actions .btn-ghost { width: 100%; }

/* location search combobox (above the four cascading selects) */
.tree-picker { margin-block-end: .3rem; }
.tree-search { position: relative; margin-block-end: .6rem; }
.tree-results { list-style: none; margin: .3rem 0 0; padding: 0; border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  background: var(--surface); box-shadow: var(--shadow-2); max-height: calc(8 * 3.4rem); overflow-y: auto; }
.tree-results li { display: flex; flex-direction: column; gap: .1rem; padding: .6rem .8rem; min-height: 3.2rem; cursor: pointer;
  border-top: 1px solid var(--line); text-align: start; }
.tree-results li:first-child { border-top: 0; }
.tree-results li[aria-selected="true"], .tree-results li:hover { background: var(--accent-soft); }
.tree-res-site { font-weight: 600; }
.tree-res-path { font-size: .82rem; color: var(--muted); }
.tree-results mark { background: #fde68a; color: inherit; border-radius: 2px; padding: 0 1px; }
.tree-empty { font-size: .88rem; color: var(--warn); margin: .3rem 0 0; }

.tree-res-level { font-weight: 600; color: var(--accent-strong); }
