/* Respondent page. Mobile first; no web fonts or external assets (they'd be slow or blocked in China).
 * Targets: iPhone Safari 15+, Android Chrome, WeChat in-app browser. Everything here has a plain fallback
 * for older WebViews (no inset shorthand, aspect-ratio fallback, dvh fallback, :focus-visible fallback). */
:root {
  --bg: #f4f3ef; --card: #ffffff; --ink: #17191e; --muted: #5a5f6b; --faint: #666b78; --line: #e2e0d8;
  --chip: #ebe9e2;          /* neutral badge background */
  --seg: #d0cec5;           /* unfinished progress segment */
  --field-line: #7f8490;    /* border of inputs: >= 3:1 so fields are findable in bright sun */
  --accent: #2350d8; --accent-ink: #ffffff; --accent-soft: #e9eefc; --accent-line: #b9c8f5;
  --good: #137a3f; --good-soft: #e5f4ea; --bad: #b3261e; --bad-soft: #fbeae8; --warn-soft: #fff5e0;
  --shadow: 0 1px 2px rgba(20, 22, 30, .06), 0 4px 16px rgba(20, 22, 30, .05);
  --radius: 18px; --gutter: 16px; --footer-h: 84px; --maxw: 600px; --btn-h: 54px;
  --pl: 16px; --pr: 16px;   /* side padding; grows on notched phones held sideways (see @supports below) */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214; --card: #1c1d21; --ink: #eceef2; --muted: #a8adb8; --faint: #9298a4; --line: #2e3036;
    --chip: #2a2c33; --seg: #3d404a; --field-line: #6f7581;
    --accent: #7f9dff; --accent-ink: #0c0e14; --accent-soft: #1f2640; --accent-line: #3b4a80;
    --good: #6fd394; --good-soft: #17301f; --bad: #ff8a80; --bad-soft: #3a1c1a; --warn-soft: #33290f;
    --shadow: none;
    color-scheme: dark;
  }
}
/* Safe areas left/right (iPhone in landscape). Only where max() exists; otherwise 16px stays. */
@supports (padding: max(1px, 2px)) {
  :root { --pl: max(var(--gutter), env(safe-area-inset-left)); --pr: max(var(--gutter), env(safe-area-inset-right)); }
}

* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  background: var(--bg);                       /* overscroll bounce shows the page colour, also in dark mode */
  scroll-padding: 92px 0 112px;               /* focused fields / scrollIntoView never end up under the bars */
}
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: break-word; word-wrap: break-word;
  -webkit-hyphens: auto; hyphens: auto;        /* long German words break with a hyphen (page sets lang="de") */
}
:lang(zh) body, body:lang(zh) { line-height: 1.6; }
:lang(zh) h1, :lang(zh) .badge, :lang(zh) .missing-step { letter-spacing: 0; text-transform: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-hyphens: manual; hyphens: manual; }
.btn, .lang, .badge, .review-state, .missing-step { -webkit-hyphens: manual; hyphens: manual; }
.ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

main {
  max-width: var(--maxw); margin: 0 auto; min-height: 100vh; min-height: 100dvh;   /* dvh: no phantom scroll under iOS toolbars */
  padding: 0 var(--pr) calc(var(--footer-h) + 24px + env(safe-area-inset-bottom)) var(--pl);
}
.loading { color: var(--muted); text-align: center; margin-top: 35vh; }

h1 { font-size: 27px; line-height: 1.2; letter-spacing: -.01em; margin: 20px 0 8px; font-weight: 750; }
.lead { color: var(--muted); margin: 0 0 18px; }

/* ----- header: step + progress ----- */
.top {
  position: -webkit-sticky; position: sticky; top: 0; z-index: 5;
  margin: 0 calc(-1 * var(--pr)) 0 calc(-1 * var(--pl));
  padding: calc(10px + env(safe-area-inset-top)) var(--pr) 10px var(--pl);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) { .top, .bottom { background: var(--bg); } }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .top, .bottom { background: var(--bg); } }
.top-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; }
.stepof { flex: 1 1 auto; min-width: 0; font-size: 15px; font-weight: 650; color: var(--muted); line-height: 1.25; overflow-wrap: break-word; }
.brief-link { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-right: -6px; padding: 0 8px; background: none; border: 0; border-radius: 10px; color: var(--accent); font-size: 15px; font-weight: 700; -webkit-hyphens: manual; hyphens: manual; }
.brief-link .ic { width: 20px; height: 20px; }
.segs { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.seg { flex: 1; height: 6px; border-radius: 3px; background: var(--seg); transition: background .2s; }
.seg.done { background: var(--good); }
.seg.now { background: var(--accent); height: 9px; }   /* taller as well as blue: readable without colour */

.langs { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; max-width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 2px; flex: none; }
.lang { border: 0; background: transparent; border-radius: 999px; padding: 4px 14px; font-size: 15px; color: var(--muted); min-height: 44px; min-width: 44px; }
.lang.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

/* ----- welcome ----- */
.welcome-top { display: flex; justify-content: flex-end; padding-top: calc(10px + env(safe-area-inset-top)); }
.welcome h1 { font-size: 32px; margin-top: 14px; }
.welcome { padding-bottom: calc(var(--footer-h) + 56px + env(safe-area-inset-bottom)); }   /* room for a two-line button (large text) */
.welcome .look { width: 100%; margin: 4px 0 6px; height: auto; padding-top: 10px; padding-bottom: 10px; text-align: center; }
.time-callout { display: flex; gap: 10px; align-items: flex-start; background: var(--accent-soft); border-radius: 14px; padding: 12px 14px; margin: 0 0 14px; font-weight: 650; }
.time-callout .ic { color: var(--accent); margin-top: 2px; }

/* how it works: 3 numbered steps */
.how-steps { list-style: none; margin: 10px 0 8px; padding: 0; counter-reset: how; }
.how-steps li { display: flex; gap: 12px; align-items: flex-start; padding: 7px 0; counter-increment: how; }
.how-steps li::before { content: counter(how); flex: none; width: 32px; height: 32px; border-radius: 16px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 750; font-size: 16px; }
.how-steps li span { padding-top: 3px; }
.how-note { color: var(--muted); margin: 6px 0 0; font-size: 16px; }

/* the checklist, grouped by section */
.brief-h { font-size: 20px; line-height: 1.3; margin: 24px 2px 4px; font-weight: 750; }
.brief-intro { color: var(--muted); margin: 0 2px 12px; font-size: 16px; }
.b-section { padding: 6px 14px; }
.b-title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin: 10px 0 2px; font-size: 17px; line-height: 1.3; font-weight: 750; }
.b-title .badge { margin: 0; color: var(--accent); background: var(--accent-soft); }
.b-list { list-style: none; margin: 0; padding: 0; }
.b-item + .b-item { border-top: 1px solid var(--line); }
.b-row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 0; list-style: none; }
summary.b-row { cursor: pointer; }
summary.b-row::-webkit-details-marker { display: none; }
summary.b-row:focus { outline-offset: -2px; }
.b-ic { width: 36px; height: 36px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.b-ic .ic { width: 20px; height: 20px; }
.b-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.b-label { font-weight: 650; line-height: 1.3; }
.b-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; color: var(--muted); font-size: 14px; line-height: 1.4; }
.b-meta .badge { margin: 0; }
.badge.req { color: var(--accent); background: var(--accent-soft); }
.b-chev { width: 18px; height: 18px; color: var(--faint); transition: transform .15s; }
details[open] > summary .b-chev { transform: rotate(180deg); }
.b-more { padding: 0 0 12px 48px; color: var(--muted); font-size: 15px; }
.b-more p { margin: 0 0 8px; }
.b-full { color: var(--ink); font-weight: 600; }
.b-tips { list-style: none; margin: 0; padding: 0; }
.b-tips li { display: flex; gap: 8px; align-items: flex-start; margin: 5px 0; }
.b-tips .ic { color: var(--good); width: 18px; height: 18px; margin-top: 3px; stroke-width: 2.4; }
.brief-tips { margin-top: 10px; }
/* English text in narrow boxes reads badly with automatic hyphens ("work-days"); German keeps them for its long words. */
:lang(en) .time-callout, :lang(en) .how-steps, :lang(en) .how-note, :lang(en) .brief-tips li, :lang(en) .b-main, :lang(en) .b-more, :lang(en) .brief-intro, :lang(en) .lead { -webkit-hyphens: manual; hyphens: manual; }
.sheet-body .brief-h:first-child { margin-top: 4px; }
.privacy { color: var(--faint); font-size: 14px; margin: 14px 2px; }
.notice { background: var(--good-soft); border-radius: 12px; padding: 12px 14px; margin: 0 0 16px; }

/* ----- cards ----- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; box-shadow: var(--shadow); }
.card-head { display: flex; gap: 12px; align-items: flex-start; }
.card-ic { position: relative; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; transition: background .2s, color .2s; }
.card-ok { position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: none; place-items: center; }
.card.complete .card-ic { background: var(--good-soft); color: var(--good); }
.card.complete .card-ic > .ic { visibility: hidden; }
.card.complete .card-ok { display: grid; }
.card-ok .ic { stroke-width: 2.6; }
.card-headtext { flex: 1; min-width: 0; padding-top: 2px; }
.card-title { font-size: 18px; line-height: 1.3; font-weight: 700; margin: 0; }
/* "Optional": a quiet neutral chip, readable (4.5:1) but clearly not a warning */
.badge { display: inline-block; margin-top: 4px; font-size: 12px; line-height: 1.5; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); background: var(--chip); border-radius: 999px; padding: 1px 9px; }
.help { color: var(--muted); font-size: 16px; margin: 10px 0 0; }
.checklist { list-style: none; margin: 10px 0 0; padding: 0; }
.checklist li { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; font-size: 16px; }
.checklist .ic { color: var(--good); width: 20px; height: 20px; margin-top: 2px; stroke-width: 2.4; }

/* photo tips */
.tips { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tips li { display: flex; min-width: 0; overflow-wrap: break-word; align-items: center; gap: 8px; background: var(--warn-soft); border-radius: 12px; padding: 9px 10px; font-size: 14px; font-weight: 600; line-height: 1.3; }
.tips .ic { width: 20px; height: 20px; }
.tips li span { min-width: 0; overflow-wrap: anywhere; }

/* ----- media tiles ----- */
.tiles { margin-top: 14px; display: grid; grid-template-columns: 1fr; gap: 10px; }
.tiles.has { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* The main action on a media card: a solid, full-width button. "Add another" (compact) is the quieter sibling. */
.add {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 68px; padding: 14px 16px; border-radius: 14px; border: 2px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 18px; line-height: 1.25; text-align: center; cursor: pointer;
  box-shadow: 0 2px 6px rgba(35, 80, 216, .28);
  touch-action: manipulation;
}
.add .ic { width: 28px; height: 28px; stroke-width: 2; }
.add.compact {
  flex-direction: column; gap: 6px; min-height: 96px; aspect-ratio: 4 / 3; font-size: 16px;
  background: var(--accent-soft); color: var(--accent); border: 2px dashed var(--accent); box-shadow: none;
}
.add.compact .ic { width: 26px; height: 26px; }
.add:active { transform: scale(.99); }
.add:focus-within { outline: 3px solid var(--accent); outline-offset: 3px; }
/* The real <input type=file> covers the whole button, so a tap lands on it directly (most reliable in WeChat). */
.file-in { position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }

.tile { position: relative; aspect-ratio: 4 / 3; border-radius: 14px; overflow: hidden; background: var(--seg); }
.thumb-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.queued .thumb-img, .tile.uploading .thumb-img { filter: brightness(.82); }   /* white progress text stays legible on pale photos */
.thumb-ph { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 13px; padding: 8px 8px 34px; text-align: center; word-break: break-all; }
.thumb-ph .ic { width: 30px; height: 30px; }
/* Remove button: 44px tap area, 30px dark disc. */
.tile .rm {
  position: absolute; top: 0; right: 0; width: 44px; height: 44px; border: 0; padding: 0; border-radius: 0;
  background: radial-gradient(circle at center, rgba(0, 0, 0, .72) 0, rgba(0, 0, 0, .72) 15px, rgba(0, 0, 0, 0) 16px);
  color: #fff; display: grid; place-items: center;
}
.tile .rm .ic { width: 18px; height: 18px; stroke-width: 2.6; filter: drop-shadow(0 0 1px rgba(0, 0, 0, .5)); }
.tile .dur { position: absolute; left: 8px; top: 8px; background: rgba(0, 0, 0, .7); color: #fff; font-size: 13px; font-weight: 650; border-radius: 6px; padding: 1px 7px; }
.tile-status { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 10px; color: #fff; font-size: 13px; line-height: 1.2; font-weight: 700; font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
  background: linear-gradient(to top, rgba(0, 0, 0, .78), rgba(0, 0, 0, 0)); display: flex; align-items: center; gap: 8px; min-height: 38px; }
.tile-status .prog { flex: 1; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .4); overflow: hidden; }
.tile-status .prog > div { height: 100%; background: #fff; transition: width .3s; }
.tile.done .tile-status { background: none; text-shadow: none; justify-content: flex-end; }
.tile-status .ok { width: 30px; height: 30px; border-radius: 15px; background: var(--good); color: #fff; display: grid; place-items: center; box-shadow: 0 0 0 2px #fff, 0 1px 4px rgba(0, 0, 0, .3); }
.tile-status .ok .ic { width: 18px; height: 18px; stroke-width: 2.8; }
.tile.failed { outline: 3px solid var(--bad); outline-offset: -3px; cursor: pointer; }
.tile.failed .thumb-img { opacity: .55; }
.tile.failed .tile-status { background: rgba(160, 30, 24, .95); text-shadow: none; align-items: center; }
.tile.failed .tile-status .ic { width: 18px; height: 18px; }
.card-msg { margin: 8px 0 0; font-size: 15px; color: var(--muted); }
.card-msg:empty { display: none; }
.card-msg.bad { color: var(--bad); font-weight: 650; }

/* ----- text + date ----- */
textarea {
  display: block; width: 100%; min-height: 112px; margin-top: 12px; padding: 12px 14px; font-size: 17px; line-height: 1.45;
  background: var(--bg); border: 1.5px solid var(--field-line); border-radius: 12px; resize: none; overflow: hidden;
  -webkit-appearance: none; appearance: none;
}
input[type="date"] {
  position: relative; display: block; width: 100%; margin-top: 12px; min-height: 50px; padding: 10px 46px 10px 14px; font-size: 17px; line-height: 1.3; text-align: left;
  background-color: var(--bg); border: 1.5px solid var(--field-line); border-radius: 12px; -webkit-appearance: none; appearance: none;
  /* calendar glyph (inline, no external asset): tells iPhone users the blank field is tappable */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237f8490' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='5' width='17' height='15.5' rx='2.5'/%3E%3Cpath d='M3.5 10h17M8 3v4M16 3v4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 22px 22px;
}
input[type="date"]::-webkit-date-and-time-value { text-align: left; min-height: 1.3em; }
input[type="date"]::-webkit-calendar-picker-indicator { position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: auto; height: auto; opacity: 0; cursor: pointer; }
.field-card input, .field-card select {
  display: block; width: 100%; margin-top: 12px; min-height: 50px; padding: 10px 14px; font-size: 17px;
  background-color: var(--bg); border: 1.5px solid var(--field-line); border-radius: 12px;
  -webkit-appearance: none; appearance: none;
}
.field-card select { padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.field-card .help { margin-top: 6px; }
.field-msg { margin: 6px 0 0; font-size: 15px; color: var(--bad); font-weight: 650; }
.field-msg:empty { display: none; }
.field-card input:focus, .field-card select:focus,
textarea:focus, input[type="date"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 0 5px var(--accent-soft); }
.dictation { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; color: var(--muted); margin: 10px 0 0; }
.dictation .ic { width: 18px; height: 18px; margin-top: 3px; color: var(--accent); }

/* ----- review ----- */
.review { list-style: none; margin: 0 0 14px; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.review li + li { border-top: 1px solid var(--line); }
.review-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: none; border: 0; text-align: left; min-height: 58px; }
.review-ic { width: 30px; height: 30px; border-radius: 15px; display: grid; place-items: center; flex: none; background: var(--bad-soft); color: var(--bad); }
.review-row.ok .review-ic { background: var(--good-soft); color: var(--good); }
.review-ic .ic { width: 18px; height: 18px; stroke-width: 2.4; }
.review-name { flex: 1; min-width: 0; font-weight: 650; }
.review-state { font-size: 15px; color: var(--muted); white-space: nowrap; }
.review-row:not(.ok) .review-state { color: var(--bad); font-weight: 700; }
.review .chev { width: 18px; height: 18px; color: var(--faint); }
.missing { border-color: var(--bad); }
.missing-list { list-style: none; margin: 8px 0 0; padding: 0; }
.missing-list li + li { border-top: 1px solid var(--line); }
.missing-row { width: 100%; display: grid; grid-template-columns: 1fr auto; column-gap: 8px; align-items: center; text-align: left; background: none; border: 0; padding: 10px 0; min-height: 56px; }
.missing-step { grid-column: 1; font-size: 13px; font-weight: 700; color: var(--bad); text-transform: uppercase; letter-spacing: .02em; }
.missing-label { grid-column: 1; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.missing-row .chev { grid-column: 2; grid-row: 1 / span 2; width: 18px; height: 18px; color: var(--faint); }
.card.need { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.need-badge { color: var(--bad); background: var(--bad-soft); margin-left: 6px; }
.ready { display: flex; align-items: center; gap: 10px; background: var(--good-soft); color: var(--good); font-weight: 700; border-radius: 14px; padding: 14px 16px; margin: 0 0 14px; }
.consent { display: flex; gap: 14px; align-items: flex-start; background: var(--card); border: 1.5px solid var(--field-line); border-radius: 14px; padding: 16px; cursor: pointer; }
.consent input { width: 28px; height: 28px; margin: 0; flex: none; accent-color: var(--accent); }
.consent:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 0 5px var(--accent-soft); }
.status { font-weight: 650; min-height: 1.5em; margin: 12px 2px; }
.status.bad { color: var(--bad); }

/* ----- bottom bar ----- */
.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 10px var(--pr) calc(10px + env(safe-area-inset-bottom)) var(--pl);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--line);
}
body.typing .bottom { display: none; }
.nav { max-width: var(--maxw); margin: 0 auto; display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.nav.single { grid-template-columns: 1fr; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--btn-h); border-radius: 14px; font-weight: 700; font-size: 17px; border: 0; padding: 0 14px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--card); border: 1.5px solid var(--field-line); color: var(--ink); }
.btn:disabled { opacity: .55; }
.btn:active:not(:disabled) { transform: scale(.985); }
/* Focus ring: shown by default, hidden for mouse/touch only where :focus-visible exists (Safari < 15.4 keeps the ring). */
button:focus, .lang:focus { outline: 3px solid var(--accent); outline-offset: 2px; }
button:focus:not(:focus-visible), .lang:focus:not(:focus-visible) { outline: none; }
.upbar { max-width: var(--maxw); margin: 0 auto 8px; display: flex; align-items: center; gap: 8px; font-size: 14px; line-height: 1.3; font-weight: 650; color: var(--muted); }
.upbar[hidden] { display: none; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent-line); border-top-color: var(--accent); animation: spin .9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- messages and done ----- */
.msg-page .message, .done-wrap { text-align: center; padding-top: 22vh; }
.message-icon { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 32px; background: var(--bad-soft); color: var(--bad); display: grid; place-items: center; }
.message-icon .ic { width: 34px; height: 34px; }
.done-mark { width: 88px; height: 88px; margin: 0 auto 8px; border-radius: 44px; background: var(--good-soft); color: var(--good); display: grid; place-items: center; }
.done-mark .ic { width: 50px; height: 50px; stroke-width: 2.6; }

.link { display: inline-flex; align-items: center; min-height: 44px; background: none; border: 0; padding: 0 2px; color: var(--accent); font-weight: 650; text-decoration: underline; text-underline-offset: 3px; }
.sending-as { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 14px; margin: 0 0 14px; font-weight: 600; }
.sending-as .ic { color: var(--accent); }
.sending-as span { flex: 1; min-width: 0; word-break: break-word; padding: 4px 0; }

/* "About you": one form card, fields stacked */
.form-card { padding: 18px 16px 4px; }
.form-card .field-card { border: 0; box-shadow: none; background: none; padding: 0; margin: 0 0 18px; border-radius: 0; }
.form-card .card-ic { display: none; }
.form-card .card-title { font-size: 16px; font-weight: 650; }
.form-card .badge { margin: 0 0 0 6px; vertical-align: 1px; }
.form-card .card-headtext { display: flex; flex-wrap: wrap; align-items: center; padding: 0; }
.form-card .field-card.need input, .form-card .field-card.need select { border-color: var(--bad); }
.form-card .field-card.need { box-shadow: none; }
.form-card .field-card input, .form-card .field-card select { margin-top: 8px; }
.form-card .field-card .help { margin: 2px 0 0; font-size: 14px; }
.form-card .need-badge { display: none; }

.not-you { font-size: 15px; color: var(--muted); margin: 6px 2px; }
.own-link-box { background: var(--accent-soft); border-radius: 14px; padding: 12px 14px; margin: 0 0 16px; font-size: 15px; }
.own-link-box p { margin: 0 0 8px; }
.own-link-row { display: flex; gap: 8px; }
.own-link { flex: 1; min-width: 0; font-size: 16px; /* >=16px: iOS zooms the page on smaller inputs */ padding: 8px 10px; border: 1px solid var(--accent-line); border-radius: 10px; background: var(--card); color: var(--ink); -webkit-appearance: none; appearance: none; }
.own-link-box .return-hint { margin: 8px 0 0; color: var(--muted); }
.message-icon.soft { background: var(--accent-soft); color: var(--accent); }
.entry-btn { margin-top: 22px; width: 100%; max-width: 360px; text-decoration: none; }
.btn.small { min-height: 44px; font-size: 15px; padding: 0 14px; flex: none; }

/* ----- wider phones / landscape width ----- */
@media (min-width: 560px) {
  .tiles.has { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  h1 { font-size: 30px; }
}
@media (min-width: 700px) {
  :root { --maxw: 680px; }
  .tips { grid-template-columns: repeat(4, 1fr); }
  .tips li { flex-direction: column; text-align: center; justify-content: center; }
}

/* ----- phone held sideways (or any very short window): the bars must not eat the screen -----
 * 390px tall: header ~68px + footer ~84px would be 39% of the screen. Here the header scrolls away
 * (JS scrolls to top on every step change, so it is visible when a step opens) and the footer shrinks
 * to ~56px, so ~85% of the height is content. */
@media (max-height: 520px) {
  :root { --footer-h: 60px; --btn-h: 44px; }
  html { scroll-padding: 8px 0 84px; }
  .top { position: static; padding-top: calc(6px + env(safe-area-inset-top)); padding-bottom: 6px; background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; border-bottom: 0; }
  .top-row { min-height: 26px; }
  .segs { margin-top: 4px; }
  .bottom { padding-top: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .btn { font-size: 16px; border-radius: 12px; }
  .upbar { margin-bottom: 4px; font-size: 13px; }
  h1 { font-size: 24px; margin: 10px 0 6px; }
  .welcome h1 { font-size: 26px; margin-top: 6px; }
  .welcome-top { padding-top: calc(4px + env(safe-area-inset-top)); }
  .lead { margin-bottom: 12px; }
  .tips { grid-template-columns: repeat(4, 1fr); margin-bottom: 12px; }
  .tips li { flex-direction: column; text-align: center; justify-content: center; font-size: 13px; }
  .tiles.has { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .add { min-height: 56px; }
  .msg-page .message, .done-wrap { padding-top: 6vh; }
  .loading { margin-top: 18vh; }
  textarea { min-height: 96px; }
}
@media (min-width: 740px) and (max-height: 520px) {
  :root { --maxw: 720px; }
  .tiles.has { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ----- old WebView fallbacks ----- */
@supports not (aspect-ratio: 1 / 1) {
  .tile { height: 0; padding-top: 75%; }                 /* 4:3 box via padding */
  .tile > .thumb-img, .tile > .thumb-ph { position: absolute; top: 0; left: 0; }
  .add.compact { min-height: 110px; aspect-ratio: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .spin { border-color: var(--accent); }   /* still visible as a ring when it does not turn */
}
@media (forced-colors: active) {
  .add, .btn.primary { border: 2px solid ButtonText; }
  .seg.now { outline: 2px solid Highlight; }
}

/* A file that was still uploading when the page closed */
.lost-msg { margin: 10px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--bad-soft); color: var(--bad); font-weight: 600; font-size: 15px; }
/* Inline "same person or someone else?" question on About you */
.status.ask { display: flex; flex-direction: column; gap: 10px; background: var(--card); border: 1.5px solid var(--accent-line); border-radius: 14px; padding: 12px 14px; font-weight: 600; }
.status.ask .ask-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.status.ask .ask-buttons .btn { flex: 1; min-width: 130px; }

/* ----- "What you'll need" sheet: the brief over whatever step you are on ----- */
body.sheet-open { overflow: hidden; }
.sheet-wrap { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0, 0, 0, .55); }
.sheet {
  position: relative; width: 100%; max-width: var(--maxw); max-height: 92vh; max-height: 92dvh;
  display: flex; flex-direction: column; background: var(--bg); color: var(--ink);
  border-radius: 22px 22px 0 0; box-shadow: 0 -8px 32px rgba(0, 0, 0, .3); outline: none;
  animation: sheet-rise .22s ease-out;
}
@keyframes sheet-rise { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 6px 6px var(--pl); border-bottom: 1px solid var(--line); flex: none; }
.sheet-head h2 { margin: 0; font-size: 20px; line-height: 1.3; font-weight: 750; }
.sheet-x { width: 48px; height: 48px; flex: none; display: grid; place-items: center; background: none; border: 0; border-radius: 24px; color: var(--ink); }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 14px var(--pr) 16px var(--pl); }
.sheet-foot { flex: none; padding: 10px var(--pr) calc(10px + env(safe-area-inset-bottom)) var(--pl); border-top: 1px solid var(--line); background: var(--bg); }
.sheet-foot .btn { width: 100%; }
@media (max-height: 520px) { .sheet { max-height: 100vh; max-height: 100dvh; border-radius: 0; } }
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 22px; } }

/* ----- adding to a diary that was already sent ----- */
.sent-box { display: flex; flex-direction: column; gap: 10px; }
.sent-box p { margin: 0; }
.sent-line { font-weight: 650; }
.reopen-box { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.reopen-box .forgot { color: var(--muted); }
.reopen-box .ask-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.reopen-box .ask-buttons .btn { flex: 1; min-width: 130px; }
.reopen-box .status { margin: 0; min-height: 0; }
.reopen-box > .btn { width: 100%; }
.reopen-banner { display: flex; align-items: flex-start; gap: 10px; background: var(--accent-soft); border: 1.5px solid var(--accent-line); border-radius: 14px; padding: 12px 14px; margin: 0 0 16px; font-weight: 600; }
.reopen-banner .ic { flex: none; color: var(--accent); margin-top: 2px; }
.reopen-banner span { min-width: 0; overflow-wrap: anywhere; }
.tile.locked::after { content: ""; position: absolute; inset: 0; border-radius: 14px; box-shadow: inset 0 0 0 2px var(--good); pointer-events: none; }
