/* DMP Advance Solution Network — AIS Fibre3 document portal.
   T495: 6-step no-scroll wizard. One screen fills the viewport; the body of
   the card is the only flexible region and it never scrolls (overflow hidden).
   T498: visual polish (owner: "ตัวหนังสือ/การจัดวางดูแข็ง ทื่อ") — soft tinted
   surfaces instead of hairline borders everywhere, a clearer type scale on
   Noto Sans Thai variable (400–700), brand-tinted header with a pill step
   chip, gradient primary button, screen-enter fade. Card grid fixed rows now
   52 + 24 = 76px (was 48 + 32 = 80px). Design consult: GPT-5.6-sol-pro
   (scratchpad t498/gpt-polish.md) — diagnosis + tokens adopted, layout kept.
   Palette: AIS green (primary) + 3BB orange (accent); brand hex values are
   working assumptions, not verified official. */

@font-face {
  font-family: 'Noto Sans Thai';
  src: url('/assets/NotoSansThai.ttf') format('truetype');
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --green: #00A650;
  --green-deep: #008A43;
  --green-bright: #17B85F;
  --orange: #F47920;
  --orange-dark: #D9640E;
  --pale-orange: #FFF3E8;
  --ink: #1B1D23;
  --ink-2: #3A3F4A;
  --secondary: #6B7280;
  --muted: #9AA3AE;
  --surface: #F3F5F8;
  --surface-2: #F7F8FA;
  --pale-green: #E8F7EE;
  --pale-green-2: #F2FBF5;
  --white: #FFFFFF;
  --line: #E6E9EE;
  --line-soft: #EEF1F4;
  --seg: #E3E7EC;
  --ok: #1B9C5B;
  --error: #C62828;
  --pale-error: #FDECEC;
  --error-line: #F3B7C0;
  --radius-control: 14px;
  --radius-card: 18px;
  --radius-frame: 28px;
  --shadow-sm: 0 1px 2px rgba(27, 29, 35, 0.05), 0 2px 8px rgba(27, 29, 35, 0.05);
  --shadow-md: 0 8px 28px rgba(27, 29, 35, 0.10);
  --shadow-lg: 0 24px 64px rgba(16, 48, 30, 0.14);
  --shadow-btn: 0 8px 20px rgba(0, 166, 80, 0.26);
  --ring: 0 0 0 4px rgba(0, 166, 80, 0.16);
  --ring-accent: 0 0 0 4px rgba(244, 121, 32, 0.22);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0; height: 100%; overflow: hidden;
  font-family: 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink); background: var(--surface); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--green-deep); }
button { font: inherit; color: inherit; }

/* ---- shell ---------------------------------------------------------------- */
.app {
  height: 100vh; height: 100dvh; width: 100%;
  display: flex; justify-content: center; align-items: stretch;
  background:
    radial-gradient(900px 520px at -10% -10%, rgba(0, 166, 80, 0.14), transparent 60%),
    radial-gradient(760px 480px at 110% 110%, rgba(244, 121, 32, 0.12), transparent 60%),
    var(--surface);
}
.side { display: none; }
.card {
  flex: 1 1 auto; width: 100%; max-width: 680px; min-height: 0;
  display: grid; grid-template-rows: 52px 24px auto minmax(0, 1fr) auto;
  background: var(--white); overflow: hidden;
}
/* Explicit rows: the preview banner is display:none in live mode, and
   auto-placement would otherwise shift the body into the banner's row. */
.card > .top { grid-row: 1; }
.card > .progress { grid-row: 2; }
.card > .notice-bar { grid-row: 3; }
.card > .body { grid-row: 4; }
.card > .foot { grid-row: 5; }

/* Header block: top bar + progress share one soft green wash */
.top {
  display: flex; align-items: center; gap: 10px; padding: 0 12px 0 10px;
  background: linear-gradient(180deg, #EEF9F2 0%, #F6FCF8 100%);
}
.top-back {
  width: 38px; height: 38px; border: 0; background: rgba(255, 255, 255, 0.9); border-radius: 12px;
  display: grid; place-items: center; cursor: pointer; color: var(--ink-2); flex: none;
  box-shadow: var(--shadow-sm); transition: background .15s, transform .15s;
}
.top-back:hover { background: #fff; color: var(--ink); }
.top-back:active { transform: scale(.96); }
.top-back:focus-visible { outline: none; box-shadow: var(--ring-accent); }
.top-logo { height: 26px; width: auto; flex: none; margin-left: 4px; }
.top-back:not([hidden]) + .top-logo { display: none; }
.top-title {
  flex: 1 1 auto; min-width: 0; font-weight: 600; font-size: 15px; line-height: 20px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.step-chip {
  flex: none; display: inline-flex; align-items: center; height: 26px; padding: 0 11px;
  border-radius: 999px; background: #fff; color: var(--green-deep);
  font-size: 12px; font-weight: 600; letter-spacing: .1px; white-space: nowrap; box-shadow: var(--shadow-sm);
}

.progress { display: flex; align-items: flex-start; padding: 2px 16px 0; background: #F6FCF8; }
.segs { flex: 1; display: flex; gap: 5px; }
.segs i { flex: 1; height: 6px; border-radius: 999px; background: var(--seg); transition: background .25s; }
.segs i[data-state="done"] { background: var(--green); }
.segs i[data-state="current"] { background: linear-gradient(90deg, var(--orange), #FF9A4D); }

.notice-bar { background: #FFF8EA; color: #7A5A00; font-size: 13px; line-height: 18px; padding: 7px 16px; }
.notice-bar strong { font-weight: 600; }

.body { min-height: 0; overflow: hidden; padding: 14px 18px 10px; }
.screen { height: 100%; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.screen.center { text-align: center; align-items: center; }
.screen.center .hint, .screen.center .h1 { width: 100%; }

/* screen-enter: hidden→shown restarts the animation (display toggles) */
@keyframes screen-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.screen:not([hidden]), .sign-screen:not([hidden]) { animation: screen-in .26s cubic-bezier(.2, .7, .2, 1) both; }

.foot {
  display: flex; gap: 10px; padding: 10px 18px; padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, #fff 30%);
}
.foot #backBtn { flex: 0 0 auto; padding: 0 18px; }
.foot #nextBtn, .foot #submitBtn { flex: 1 1 auto; }

/* Desktop: step list beside a fixed-height card */
@media (min-width: 1024px) {
  .app { align-items: center; gap: 40px; padding: 24px; }
  .side { display: block; width: 300px; flex: none; }
  .side-logo { width: 150px; height: auto; margin-bottom: 14px; }
  .side-company { margin: 0 0 20px; font-weight: 700; font-size: 15px; line-height: 21px; color: var(--ink); }
  .side-company span { font-weight: 400; color: var(--secondary); font-size: 13px; }
  .side-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; position: relative; }
  .side-steps::before { /* connector line behind the step circles */
    content: ''; position: absolute; left: 25px; top: 24px; bottom: 24px; width: 2px; background: var(--line); z-index: 0;
  }
  .side-steps li {
    position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 14px;
    color: var(--secondary); font-size: 14px; line-height: 20px; font-weight: 500; transition: background .2s, color .2s;
  }
  .side-steps li .n {
    width: 28px; height: 28px; flex: none; border-radius: 50%;
    background: #fff; border: 2px solid var(--line); display: grid; place-items: center;
    font-size: 12px; font-weight: 700; color: var(--muted); transition: all .2s;
  }
  .side-steps li[data-state="done"] { color: var(--green-deep); }
  .side-steps li[data-state="done"] .n { background: var(--green); border-color: var(--green); color: #fff; }
  .side-steps li[data-state="current"] { background: #fff; color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }
  .side-steps li[data-state="current"] .n { border-color: var(--orange); color: var(--orange-dark); box-shadow: var(--ring-accent); }
  .side-verify { display: inline-flex; align-items: center; gap: 5px; margin-top: 18px; font-size: 13px; font-weight: 500; color: var(--green-deep); text-decoration: none; }
  .side-verify:hover { text-decoration: underline; }
  .side-trust { display: flex; align-items: center; gap: 8px; margin: 14px 0 0; font-size: 13px; line-height: 18px; color: var(--secondary); }
  .side-trust svg { flex: none; color: var(--green); }
  .top-logo { display: none; }
  .card { height: min(100%, 780px); border-radius: var(--radius-frame); box-shadow: var(--shadow-lg); border: 1px solid rgba(27, 29, 35, 0.04); }
  .body { padding: 18px 26px 12px; }
  .foot { padding-left: 26px; padding-right: 26px; }
  .top { padding: 0 20px 0 16px; }
  .progress { padding-left: 24px; padding-right: 24px; }
}

/* ---- type ----------------------------------------------------------------- */
.h1 { margin: 0; font-size: 23px; line-height: 30px; font-weight: 700; letter-spacing: -.2px; color: var(--ink); text-wrap: balance; outline: none; }
.hint { margin: 0; font-size: 14px; line-height: 21px; color: var(--secondary); }
.note { margin: 0; font-size: 12px; line-height: 17px; color: var(--muted); }
.req { color: var(--orange-dark); }

/* ---- controls ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 18px; border-radius: var(--radius-control);
  border: 1.5px solid transparent; font-weight: 600; font-size: 16px; line-height: 22px;
  cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .1s, filter .15s;
}
.btn:active:not([disabled]) { transform: translateY(1px) scale(.995); }
.btn:focus-visible { outline: none; box-shadow: var(--ring-accent); }
.btn svg { flex: none; }
.btn-primary { background: linear-gradient(135deg, var(--green-bright) 0%, var(--green-deep) 100%); color: #fff; box-shadow: var(--shadow-btn); }
.btn-primary:hover:not([disabled]) { filter: brightness(1.05); }
.btn-primary[disabled] { background: #E4E8ED; color: #9AA3AE; box-shadow: none; cursor: not-allowed; }
.btn-outline { background: #fff; color: var(--green-deep); border-color: #CFE6D8; }
.btn-outline:hover:not([disabled]) { background: var(--pale-green-2); border-color: var(--green); }
.btn-block { width: 100%; }
.btn-text { background: none; border: 0; padding: 4px 8px; color: var(--green-deep); font-weight: 600; font-size: 14px; cursor: pointer; border-radius: 10px; transition: background .15s; }
.btn-text:hover:not([disabled]) { background: var(--pale-green); }
.btn-text[disabled] { color: #B4B8C0; cursor: not-allowed; background: none; }
.btn-text-danger { color: var(--error); }
.btn-text-danger:hover:not([disabled]) { background: var(--pale-error); }
.btn-icon { width: 34px; height: 34px; border: 0; background: transparent; border-radius: 10px; display: grid; place-items: center; color: var(--secondary); cursor: pointer; }
.btn-icon:hover { background: var(--surface); color: var(--ink); }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.row2 .btn { padding: 0 8px; font-size: 15px; }

.field { display: block; }
.field-label { display: block; font-size: 13px; line-height: 18px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
input[type=text], input[type=tel] {
  width: 100%; min-height: 50px; padding: 0 16px; font: inherit; color: var(--ink);
  border: 1.5px solid transparent; border-radius: var(--radius-control); background: var(--surface);
  transition: background .15s, border-color .15s, box-shadow .15s;
}
input[type=text]::placeholder, input[type=tel]::placeholder { color: var(--muted); }
input[type=text]:hover, input[type=tel]:hover { background: #EEF1F5; }
input[type=text]:focus, input[type=tel]:focus { outline: none; background: #fff; border-color: var(--green); box-shadow: var(--ring); }

.checkbox { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; line-height: 21px; cursor: pointer; color: var(--ink-2); }
.checkbox input { width: 22px; height: 22px; margin: 0; accent-color: var(--green); flex: none; }
.consent { padding: 12px 14px; border-radius: var(--radius-control); background: var(--surface); border: 1.5px solid transparent; transition: background .15s, border-color .15s; }
.consent:has(input:checked) { background: var(--pale-green-2); border-color: #BFE6CF; }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap; width: max-content; max-width: 100%; }
.chip svg { flex: none; }
.chip-ok { background: #fff; color: var(--green-deep); box-shadow: var(--shadow-sm); }
/* T524: LINE identity chip on step 6 ("ส่งในนาม LINE: …"); hidden until LIFF login succeeds. */
.chip-line { background: #E6F6EA; color: #06C755; border: 1px solid #BFE6CF; margin-top: 8px; }
.chip-line .chip-text { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
/* Preview mode (upload closed): the 50px banner eats step 1's slack at 390x660, drop the decorative chip. */
.notice-bar:not([hidden]) ~ .body .chip-ok { display: none; }

/* ---- step 1 --------------------------------------------------------------- */
.dealer {
  background: linear-gradient(135deg, #EEF9F2 0%, #FFF7EF 100%);
  border-radius: var(--radius-card); padding: 14px; display: flex; flex-direction: column; gap: 10px;
  font-size: 13px; line-height: 18px;
}
.dealer-head { display: flex; gap: 12px; align-items: center; }
.dealer-logo-tile { flex: none; width: 92px; height: 48px; border-radius: 12px; background: #fff; box-shadow: var(--shadow-sm); display: grid; place-items: center; padding: 6px; }
.dealer-logo { width: 80px; height: auto; }
.dealer-head > div { min-width: 0; }
.dealer-head strong { display: block; font-size: 14px; line-height: 19px; color: var(--ink); }
.dealer-head span { color: var(--secondary); font-size: 12px; line-height: 17px; }
.dealer-facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; color: var(--ink-2); }
.dealer-facts .btn-text { padding: 0 6px; font-size: 13px; }
.verify-link { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; color: var(--orange-dark); text-decoration: none; }
.verify-link:hover { text-decoration: underline; }

/* ---- step 2 --------------------------------------------------------------- */
.seg { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; padding: 5px; border-radius: var(--radius-card); background: var(--surface); }
.seg-opt {
  position: relative; display: flex; flex-direction: column; justify-content: center; min-height: 58px;
  padding: 8px 32px 8px 12px; border: 1.5px solid transparent; border-radius: var(--radius-control); cursor: pointer;
  background: transparent; font-size: 12px; line-height: 16px; color: var(--secondary);
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.seg-opt b { font-size: 15px; line-height: 20px; color: var(--ink); font-weight: 600; }
.seg-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-check { position: absolute; top: 10px; right: 10px; width: 20px; height: 20px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; opacity: 0; transform: scale(.6); transition: opacity .15s, transform .15s; }
.seg-opt.is-on, .seg-opt:has(input:checked) { border-color: #BFE6CF; background: #fff; box-shadow: var(--shadow-sm); }
.seg-opt.is-on b, .seg-opt:has(input:checked) b { color: var(--green-deep); }
.seg-opt.is-on .seg-check, .seg-opt:has(input:checked) .seg-check { opacity: 1; transform: none; }
.seg-opt:has(input:focus-visible) { box-shadow: var(--ring-accent); }

.id-box {
  flex: 1 1 auto; min-height: 120px; position: relative; overflow: hidden;
  border: 2px dashed #CFE6D8; border-radius: var(--radius-card); background: var(--pale-green-2);
  display: flex; flex-direction: column;
}
.id-box:has(#idPreview:not([hidden])) { border: 1.5px solid var(--line); background: #fff; }
.id-box-img { border: 0; background: #14161B; align-items: center; justify-content: center; }
.id-box-img img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.id-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 12px; color: var(--secondary); font-size: 13px; line-height: 18px; text-align: center; }
.id-empty svg { color: var(--green); background: #fff; border-radius: 50%; padding: 12px; width: 64px; height: 64px; box-shadow: var(--shadow-sm); }
#idPreview:not([hidden]) + .id-empty { display: none; }
.id-preview { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.id-preview img { flex: 1 1 auto; min-height: 0; width: 100%; object-fit: contain; background: #14161B; }
.id-preview-bar { flex: none; display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 12px; background: #fff; font-size: 13px; line-height: 18px; }
.id-status { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; flex: 1 1 auto; min-width: 0; }
.id-status[data-signed="false"] { color: #8a5a00; }
.id-status[data-signed="false"] .id-status-icon { display: none; }
.id-status[data-signed="true"] { color: var(--ok); }
.id-preview-actions { display: flex; gap: 2px; flex: none; }

/* ---- step 3 --------------------------------------------------------------- */
.sign-screen { height: 100%; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.sign-screen.center { text-align: center; align-items: center; }
.sign-screen.center .h1, .sign-screen.center .hint { width: 100%; }
.sign-tools { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.sign-pad-wrap { position: relative; flex: 1 1 auto; min-height: 140px; }
.sign-pad {
  display: block; width: 100%; height: 100%;
  background: #fff; border: 2px dashed #CFE6D8; border-radius: var(--radius-card);
  touch-action: none; cursor: crosshair;
}
.sign-pad-hint { position: absolute; inset: 0; display: grid; place-items: center; color: #C3C8D0; font-size: 18px; font-weight: 500; pointer-events: none; }

/* Placement stage: the canvas is the exact export; the card guide box and the
   signature drag handle are DOM overlays positioned from the canvas's displayed
   size, so they never end up in the output image. */
.sign-stage {
  position: relative; flex: 1 1 auto; min-height: 120px; display: flex; justify-content: center; align-items: flex-start;
  background: #14161B; border-radius: var(--radius-card); overflow: hidden; touch-action: none; user-select: none;
}
.sign-stage-canvas { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; background: #fff; -webkit-user-select: none; user-select: none; }
.sign-card-box { position: absolute; left: 0; top: 0; pointer-events: none; border: 2px solid #E68A00; border-radius: 4px; }
.sign-card-box[data-detected="true"] { border-color: var(--ok); }
.sign-drag { position: absolute; left: 0; top: 0; border: 1.5px dashed var(--orange); border-radius: 6px; cursor: move; touch-action: none; background: rgba(244,121,32,0.08); }
.detect-status { margin: 0; font-size: 12px; font-weight: 600; line-height: 16px; padding: 7px 12px; border-radius: 999px; }
.detect-status[data-detected="false"] { color: #8a5a00; background: #FFF7E6; }
.detect-status[data-detected="true"] { color: var(--ok); background: var(--pale-green); }
.sign-size { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--secondary); }
.sign-size span { flex: none; }
.sign-size input[type="range"] { flex: 1 1 auto; min-height: 32px; accent-color: var(--green); margin: 0; }

/* Manual card bounds = bottom sheet driven by <details> so app.js can still
   open it programmatically (det.open = true) when detection is uncertain. */
.card-adjust { margin: 0; }
.card-adjust > summary { list-style: none; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--green-deep); padding: 4px 8px; border-radius: 10px; }
.card-adjust > summary::-webkit-details-marker { display: none; }
.card-adjust > summary:hover { background: var(--pale-green); }
.adjust-sheet { position: fixed; inset: 0; z-index: 90; background: rgba(27,29,35,0.4); display: flex; align-items: flex-end; justify-content: center; }
.adjust-panel { width: 100%; max-width: 680px; background: #fff; border-radius: var(--radius-frame) var(--radius-frame) 0 0; padding: 18px 18px calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 6px; }
.card-slider { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--secondary); }
.card-slider span { flex: none; width: 4.5em; }
.card-slider input[type="range"] { flex: 1 1 auto; min-height: 32px; accent-color: #E68A00; margin: 0; }
.adjust-panel .row2 { margin-top: 6px; }

/* ---- steps 4-5 ------------------------------------------------------------ */
.thumb-grid {
  list-style: none; margin: 0; padding: 0; flex: 1 1 auto; min-height: 120px;
  display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; align-items: flex-start;
}
.thumb-grid:empty { border: 2px dashed #CFE6D8; border-radius: var(--radius-card); background: var(--pale-green-2); display: grid; place-items: center; color: var(--secondary); font-size: 13px; }
.thumb-grid:empty::before { content: attr(data-empty); }
.thumb { position: relative; flex: none; width: calc((100% - 16px) / 3); aspect-ratio: 3 / 4; max-height: 100%; border-radius: var(--radius-control); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-sm); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-remove { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(27,29,35,0.7); color: #fff; display: grid; place-items: center; cursor: pointer; }
.thumb-remove:hover { background: var(--error); }

/* ---- step 6 --------------------------------------------------------------- */
.turnstile { display: grid; gap: 6px; }

/* ---- success + FAQ -------------------------------------------------------- */
.ok-icon {
  width: 72px; height: 72px; border-radius: 50%; color: #fff; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--green-bright), var(--green-deep)); box-shadow: 0 0 0 10px var(--pale-green), var(--shadow-btn);
}
.success-ref { margin: 0; font-size: 14px; color: var(--secondary); display: inline-flex; align-items: center; gap: 8px; }
.success-ref strong { color: var(--green-deep); font-size: 17px; letter-spacing: .6px; background: var(--pale-green); padding: 4px 12px; border-radius: 999px; }
.sent { width: 100%; margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 14px; text-align: left; font-size: 13px; line-height: 18px; background: var(--surface-2); border-radius: var(--radius-card); padding: 6px 14px; }
.sent dt { color: var(--secondary); padding: 5px 0; border-bottom: 1px solid var(--line-soft); }
.sent dd { margin: 0; font-weight: 600; color: var(--ink); padding: 5px 0; border-bottom: 1px solid var(--line-soft); overflow-wrap: anywhere; }
.sent dt:last-of-type, .sent dd:last-of-type { border-bottom: 0; }
.faq-list { display: grid; gap: 8px; align-content: start; min-height: 0; }
.faq-item { background: var(--surface-2); border-radius: var(--radius-control); padding: 0 14px; transition: background .15s; }
.faq-item[open] { background: var(--pale-green-2); }
.faq-item summary { cursor: pointer; font-weight: 600; font-size: 14px; line-height: 20px; min-height: 46px; display: flex; align-items: center; gap: 8px; list-style: none; color: var(--ink); }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: ''; margin-left: auto; flex: none; width: 8px; height: 8px; border-right: 2px solid var(--green); border-bottom: 2px solid var(--green); transform: rotate(45deg) translateY(-2px); transition: transform .2s; }
.faq-item[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
.faq-item p { margin: 0 0 12px; color: var(--ink-2); font-size: 13px; line-height: 19px; }

/* ---- status toast --------------------------------------------------------- */
.form-status {
  position: fixed; left: 16px; right: 16px; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 80;
  max-width: 640px; margin: 0 auto; padding: 12px 16px; border-radius: var(--radius-control);
  font-size: 14px; line-height: 20px; box-shadow: var(--shadow-md);
  animation: screen-in .2s ease-out both;
}
.form-status.error { background: var(--pale-error); color: var(--error); border: 1px solid var(--error-line); }
.form-status.info { background: #EAF3FF; color: #1b4f8a; border: 1px solid #BBD8F7; }

/* ---- full-screen viewers (policy, letter) --------------------------------- */
.viewer { position: fixed; inset: 0; z-index: 100; background: rgba(27,29,35,0.4); display: flex; justify-content: center; align-items: stretch; }
.viewer-inner { width: 100%; max-width: 680px; background: #fff; display: grid; grid-template-rows: 52px minmax(0, 1fr) auto; outline: none; }
@media (min-width: 1024px) { .viewer { padding: 24px; align-items: center; } .viewer-inner { height: min(100%, 780px); border-radius: var(--radius-frame); overflow: hidden; } }
.viewer-head { display: flex; align-items: center; gap: 8px; padding: 0 12px 0 10px; background: linear-gradient(180deg, #EEF9F2 0%, #F6FCF8 100%); }
.viewer-head h2 { flex: 1; margin: 0; font-size: 15px; line-height: 22px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-pg { font-size: 12px; font-weight: 600; color: var(--green-deep); white-space: nowrap; background: #fff; border-radius: 999px; padding: 4px 10px; box-shadow: var(--shadow-sm); }
.viewer-body { min-height: 0; overflow-y: auto; padding: 18px; }
.viewer-body:focus { outline: none; }
.viewer-img { display: flex; align-items: center; justify-content: center; background: #14161B; padding: 8px; overflow: hidden; }
.viewer-img img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.viewer-foot { display: flex; gap: 10px; padding: 10px 18px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(180deg, rgba(255,255,255,0) 0%, #fff 30%); }
.viewer-foot .btn { flex: 1 1 auto; }
.policy-page h3 { margin: 0 0 8px; font-size: 17px; line-height: 23px; font-weight: 700; letter-spacing: -.1px; }
.policy-page p, .policy-page li { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 21px; }
.policy-page ul { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.policy-preview-flag { background: #FFF8EA; color: #7a5a00; border-radius: 12px; padding: 8px 12px; font-size: 13px; line-height: 18px; margin-bottom: 12px; }

/* ---- bottom sheet --------------------------------------------------------- */
.sheet-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(27,29,35,0.4); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 680px; background: #fff; border-radius: var(--radius-frame) var(--radius-frame) 0 0; padding: 22px 18px calc(16px + env(safe-area-inset-bottom)); max-height: 80vh; overflow-y: auto; outline: none; }
.sheet-title { margin: 0 0 10px; font-size: 18px; line-height: 24px; font-weight: 700; }
.sheet-list { margin: 0 0 16px; padding-left: 20px; display: grid; gap: 8px; font-size: 14px; line-height: 21px; color: var(--ink-2); }

/* ---- misc ----------------------------------------------------------------- */
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.is-busy .btn-label { opacity: .8; }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.6s; }
  .btn, .segs i, .seg-opt, .seg-check, .side-steps li, .side-steps li .n, .faq-item summary::after { transition: none; }
  .screen:not([hidden]), .sign-screen:not([hidden]), .form-status { animation: none; }
}

/* ---- T526: LIFF bridge screen (additions only; shown inside the LIFF browser) ---- */
.bridge { overflow-y: auto; -webkit-overflow-scrolling: touch; justify-content: flex-start; gap: 10px; padding-bottom: 8px; outline: none; }
.bridge-avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 4px #fff, 0 0 0 8px var(--pale-green); background: var(--surface-2); flex: none; }
.bridge-avatar:not([hidden]) + .bridge-fallback { display: none; }
.bridge-fallback { flex: none; }
.bridge .h1 { font-size: 21px; line-height: 28px; }
.bridge .h1 #bridgeName { color: var(--green-deep); overflow-wrap: anywhere; }
.bridge .hint strong { color: var(--ink); font-weight: 600; }
.bridge-list { width: 100%; margin: 2px 0 0; padding: 10px 14px; list-style: none; text-align: left; background: var(--surface-2); border-radius: var(--radius-card); font-size: 14px; line-height: 20px; color: var(--ink-2); display: grid; gap: 6px; }
.bridge-list li { position: relative; padding-left: 24px; }
.bridge-list li::before { content: ''; position: absolute; left: 0; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--pale-green); border: 1.5px solid var(--green-bright); }
.bridge-list li::after { content: ''; position: absolute; left: 4px; top: 6px; width: 6px; height: 4px; border-left: 2px solid var(--green-deep); border-bottom: 2px solid var(--green-deep); transform: rotate(-45deg); }
.bridge-note { margin: 0; font-size: 13px; line-height: 19px; color: var(--secondary); }
.bridge-pdpa { margin: 0; font-size: 12px; line-height: 17px; color: var(--muted); }
.bridge-btn { margin-top: 4px; flex: none; }
.bridge-status { margin: 0; font-size: 13px; line-height: 19px; font-weight: 600; color: var(--green-deep); }

/* ---- T527: installation address step (additions only; every rule above is unchanged) ---- */
.addr { overflow-y: auto; -webkit-overflow-scrolling: touch; justify-content: flex-start; gap: 10px; padding-bottom: 8px; }
.addr-opts { display: grid; gap: 8px; }
/* T527 CR-1: options must read as tappable — white card, visible border, radio circle, chevron, press feedback */
.addr-opt { position: relative; display: grid; gap: 2px; padding: 12px 40px 12px 48px; min-height: 60px; align-content: center; border-radius: var(--radius-control); border: 1.5px solid #CBD2DB; cursor: pointer; background: #fff; box-shadow: var(--shadow-sm); -webkit-tap-highlight-color: transparent; user-select: none; transition: background .15s, border-color .15s, box-shadow .15s, transform .08s; }
.addr-opt::before { content: ''; position: absolute; left: 14px; top: 50%; width: 22px; height: 22px; margin-top: -11px; border-radius: 50%; border: 2px solid #9AA3AF; background: #fff; box-sizing: border-box; transition: border-color .15s, background .15s, box-shadow .15s; }
.addr-opt::after { content: ''; position: absolute; right: 16px; top: 50%; width: 9px; height: 9px; margin-top: -6px; border-right: 2.5px solid #9AA3AF; border-bottom: 2.5px solid #9AA3AF; transform: rotate(-45deg); transition: border-color .15s, opacity .15s; }
.addr-opt b { font-size: 15px; line-height: 20px; color: var(--ink); font-weight: 600; }
.addr-opt > span:not(.seg-check) { font-size: 12px; line-height: 16px; color: var(--secondary); }
.addr-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.addr-opt .seg-check { top: 50%; margin-top: -10px; right: 12px; }
@media (hover: hover) { .addr-opt:hover { border-color: var(--green); background: var(--pale-green-2); } }
.addr-opt:active { transform: scale(.985); background: var(--pale-green-2); }
.addr-opt.is-on, .addr-opt:has(input:checked) { border-color: var(--green); background: var(--pale-green-2); box-shadow: 0 0 0 1px var(--green), var(--shadow-sm); }
.addr-opt.is-on::before, .addr-opt:has(input:checked)::before { border-color: var(--green); background: var(--green); box-shadow: inset 0 0 0 4px #fff; }
.addr-opt.is-on::after, .addr-opt:has(input:checked)::after { opacity: 0; }
.addr-opt.is-on b, .addr-opt:has(input:checked) b { color: var(--green-deep); }
.addr-opt.is-on .seg-check, .addr-opt:has(input:checked) .seg-check { opacity: 1; transform: none; }
.addr-opt:has(input:focus-visible) { box-shadow: var(--ring-accent); }
.addr-form { display: grid; gap: 10px; }
.addr-form select {
  width: 100%; min-height: 50px; padding: 0 44px 0 16px; font: inherit; color: var(--ink);
  border: 1.5px solid transparent; border-radius: var(--radius-control); background: var(--surface);
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 20px 20px;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.addr-form select:hover { background-color: #EEF1F5; }
.addr-form select:focus { outline: none; background-color: #fff; border-color: var(--green); box-shadow: var(--ring); }
.addr-form select:disabled { color: var(--muted); opacity: 1; cursor: not-allowed; }
.addr-status { text-align: left; white-space: normal; line-height: 18px; color: var(--secondary); }
.addr-status[data-kind="error"] { color: #B42318; }

/* ---- T527 CR-2: success screen — "please report the reference number" notice (additions only) ---- */
.ok-notice { width: 100%; display: grid; gap: 6px; padding: 12px 14px; border-radius: var(--radius-card); background: #FFF8E6; border: 1.5px solid #F5D98B; text-align: left; }
.ok-notice b { font-size: 14px; line-height: 20px; color: #7A5200; }
.ok-notice > span { font-size: 13px; line-height: 19px; color: var(--ink-2); }
.ok-notice > span strong { color: var(--green-deep); letter-spacing: .6px; }
.ok-notice .ok-copy { min-height: 40px; padding: 0 14px; font-size: 14px; justify-self: start; }
.ok-notice .ok-copy.is-done { background: var(--pale-green-2); border-color: var(--green); }

/* ---- T731: selfie-with-ID empty-state vector ---------------------------- */
/* T731: empty selfie slot shows a vector of a person holding the ID card for the selfie.
   AIS: selfie arm with phone + card beside cheek (green/orange) — deliberately different from the other brand's portal. */
#selfieGrid:empty { place-items: end center; padding: 10px 10px 30px; background-image: url("/assets/selfie-with-id.png?v=20260930-selfiepng"); background-repeat: no-repeat; background-position: center; background-size: contain; background-origin: content-box; }
#selfieGrid:empty::before { transform: translateY(22px); }
