/*
 * Thailand Post parcel pre-load LINE LIFF.
 *
 * Design goals:
 *  - Audience skews 35+ and elderly: large type, generous spacing, big
 *    touch targets (>= 52px), strong contrast.
 *  - Corporate identity follows Thailand Post (postal red).
 *  - Calm, single-column, one-thing-at-a-time flow.
 */

:root {
  /* This is a light-themed app. Force native controls (select popups, date
   * pickers, form fields) to render light even when the device/webview is in
   * dark mode — otherwise their OS-drawn popups appear dark grey and floating,
   * clashing with the white UI. */
  color-scheme: light;

  /* Thailand Post corporate identity */
  --post-red: #d9261c;        /* primary brand red */
  --post-red-dark: #b01e16;   /* pressed / emphasis */
  --post-red-soft: #fdeceb;   /* tinted backgrounds, focus glow */

  --ink: #1a1a1a;             /* near-black body text, high contrast */
  --muted: #4b5563;           /* darker than usual for readability */
  --line: #d6d9dd;            /* borders */
  --bg: #f5f6f8;
  --card: #ffffff;
  --success: #15803d;
  --success-soft: #dcfce7;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;

  --radius: 14px;
  --radius-lg: 16px;

  /* Comfortable tap target (compact, modern proportions). */
  --tap: 44px;

  --safe-top: env(safe-area-inset-top, 0px);

  /* Height of the sticky branch-notice bar (.branch-bar). The sticky .topbar
   * offsets itself by this so the two stack instead of overlapping, .screen
   * subtracts it from its 100vh, and the flash toast clears it. Keep in sync
   * with .branch-bar. */
  --branch-bar-h: 44px;

  /* Content column. Phones get the classic 480px single column; tablets and
   * desktops widen it (see the responsive block at the end of this file) so
   * an iPad isn't a phone-width strip in the middle of the screen. Every
   * width-capped shell element (.screen, .branch-bar, .action-bar,
   * .flash-stack) keys off this. --screen-x is the side gutter, which the
   * sticky .topbar also uses to bleed edge-to-edge. */
  --shell-w: 480px;
  --screen-x: 16px;
}

* { box-sizing: border-box; }

/* The [hidden] attribute must win over component display rules (e.g. .btn uses
 * display: inline-flex), otherwise JS-hidden wizard buttons stay visible. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    "Noto Sans Thai", "Sarabun", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

.screen {
  max-width: var(--shell-w);
  margin: 0 auto;
  padding: 14px var(--screen-x) 56px;
  /* The branch bar sits above .screen in flow, so subtract it to keep the
   * full-height (and vertically centred) screens from overflowing. */
  min-height: calc(100vh - var(--branch-bar-h) - var(--safe-top));
}

.screen--center {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Branch notice bar -------------------------------------------------- */
/* Rendered by the layout on every page, so it is the first thing in <body>
 * and sits above the .topbar. Sticky at the very top: the notice is a hard
 * constraint on where parcels can be dropped off, so it must not scroll away.
 * Solid postal red rather than a tint — the constraint should read as a
 * statement of scope, not as an error. Single line by design: the height is
 * fixed and shared via --branch-bar-h, which the .topbar, .screen and
 * .flash-stack offsets all depend on. */
.branch-bar {
  position: sticky;
  top: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  gap: 10px;
  /* Same 480px column as .screen and .topbar. Left unconstrained, the bar
   * bleeds to the viewport edges and reads as far wider than every card
   * below it on anything larger than a phone. */
  max-width: var(--shell-w);
  margin: 0 auto;
  /* The notch inset adds to the bar rather than eating into it, matching the
   * calc() used by .topbar / .screen. Kept on the default border-box so
   * max-width stays the outer width and lines up with .topbar exactly. */
  height: calc(var(--branch-bar-h) + var(--safe-top));
  padding: var(--safe-top) 16px 0;
  background: var(--post-red);
  color: #fff;
}

/* Two decorative diagonal slashes on the trailing edge: one broad, one narrow,
 * both leaning with the bar. Layered as hard-stop gradients rather than extra
 * elements, and non-interactive so they can never swallow a tap. */
.branch-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  /* A single faint diagonal wash lifting the trailing end of the bar. No crisp
   * highlight lines on top of it — just the wash, so the red stays flat. */
  background: linear-gradient(112deg, transparent 55%, rgba(255, 255, 255, 0.06) 80%, transparent 97%);
  pointer-events: none;
}

.branch-bar__pin {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.branch-bar__text {
  margin: 0;
  /* Hairline rule separating the pin from the copy. */
  padding-left: 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.45);
  font-weight: 700;
  line-height: 1.3;
  /* Scales down on narrow phones so the longer Thai copy stays on one line;
   * ellipsis is the last resort on very small screens. */
  font-size: clamp(0.7rem, 3.1vw, 0.84rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Top bar -------------------------------------------------------------- */
/* Pinned to the top of the viewport (mirror of .action-bar at the bottom)
 * so the title + actions stay reachable while the list/form scrolls. Uses
 * position: sticky so it keeps its place in flow — no content jump and no
 * manual padding compensation. Bleeds to the screen edges to read as an app
 * bar. Applies to every page that uses .topbar. */
.topbar {
  position: sticky;
  /* Pinned below the always-visible .branch-bar, not to the viewport top. */
  top: calc(var(--branch-bar-h) + var(--safe-top));
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  /* Negative side margins span the .screen horizontal padding. */
  margin: -14px calc(-1 * var(--screen-x)) 16px;
  padding: 12px var(--screen-x);
  background: rgba(255, 255, 255, 0.97);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.06);
}

.topbar h1 { font-size: 1.2rem; margin: 0; font-weight: 800; min-width: 0; }

.topbar__actions { display: flex; gap: 10px; align-items: center; }

/* Address book link in the top bar: icon + label so the destination is
 * obvious at a glance, not just a book emoji. */
.topbar__book {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}
.topbar__book-label { line-height: 1; }
/* Three controls plus a title do not fit a phone's top bar. The book icon is
 * recognisable on its own, so its label is the first thing to go. */
@media (max-width: 480px) {
  .topbar__book-label { display: none; }
  .topbar__book { padding: 0 10px; }
}

/* A page title never breaks across lines: "Address Book" splitting in two and
 * running under the controls is what reads as broken. The bar wraps instead,
 * giving the controls their own row, and only when they truly do not fit. */
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; row-gap: 6px; gap: 8px; }
  .topbar h1 { white-space: nowrap; }
  .topbar__actions { margin-left: auto; gap: 6px; }
  /* Trimmed so the title and the controls share one row on a phone; the pills
   * are still well over the 44px minimum target. */
  .lang-switch__btn { padding-left: 10px; padding-right: 10px; }
}

/* Round, clearly tappable close ("back to list") button. */
.topbar__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  text-decoration: none;
}
.topbar__close:active { background: var(--line); }

/* Language switcher (TH/EN segmented control) ------------------------- */
.lang-switch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: #eceef1;
  border-radius: 999px;
}
.lang-switch form { margin: 0; display: flex; }
.lang-switch__btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1;
}
.lang-switch__btn--active {
  background: #fff;
  color: var(--post-red);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.brand {
  color: var(--post-red);
  font-size: 1.9rem;
  font-weight: 800;
  margin: 0 0 6px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: var(--post-red);
}
.brand-mark__logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--post-red);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

/* Cards ---------------------------------------------------------------- */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.card--center { text-align: center; }
.card--error {
  border: 2px solid var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}
.card--error ul { margin: 0; padding-left: 20px; }
.card--error li { margin: 4px 0; }

.muted { color: var(--muted); }
.small { font-size: 0.95rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Customer address link ------------------------------------------------ */
.customer-link__result { margin-top: 12px; }

/* Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }

.btn--primary { background: var(--post-red); color: #fff; }
.btn--primary:active { background: var(--post-red-dark); }

/* "Not ready yet" state, e.g. the create-label button before the form is complete. */
.btn:disabled,
.btn[disabled] {
  background: #c9ccd1;
  color: #fff;
  cursor: not-allowed;
  opacity: 1;
}
.btn:disabled:active,
.btn[disabled]:active { transform: none; }

.btn--ghost {
  background: #fff;
  color: var(--ink);
  border: 2px solid var(--line);
}
.btn--ghost:active { background: var(--bg); }

.btn--sm {
  min-height: 36px;
  padding: 7px 14px;
  font-size: 0.85rem;
}
.btn--block { width: 100%; margin-top: 12px; }
.btn--danger { color: var(--danger); border-color: var(--danger); background: #fff; }

/* Fields --------------------------------------------------------------- */
.fields { display: flex; flex-direction: column; gap: 13px; }
.field { display: flex; flex-direction: column; gap: 5px; }

/* Labels: compact, bold, high contrast. */
.field__label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
}
.field__label em { color: var(--post-red); font-style: normal; font-weight: 800; }

.field__hint {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.4;
}
/* The per-service weight ceiling under the service picker, set a little
 * apart from the field. Only the amount is red and bold: that's the number
 * the user compares against; the words around it stay in body colour. */
.field__hint--limit {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-weight: 600;
}
.field__hint-amount { color: var(--post-red); font-weight: 800; }

.field__input {
  width: 100%;
  min-height: 32px;
  padding: 6px 10px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-size: 0.92rem;
  /* Stated rather than left to `normal`, which browsers work out differently
   * for an <input> than for the <span> inside the custom dropdown button: the
   * two controls then came out 4px apart in large-type mode and the pair of
   * boxes beside each other looked uneven. One value makes every control the
   * same height. */
  line-height: 1.4;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
}

.field__input:focus {
  outline: none;
  border-color: var(--post-red);
  box-shadow: 0 0 0 4px var(--post-red-soft);
}

/* Height is driven by the autogrow controller; max-height is the ceiling it
   grows to before the textarea starts scrolling internally. */
textarea.field__input {
  min-height: 56px;
  max-height: 180px;
  line-height: 1.45;
  resize: vertical;
  width: 100%;
  max-width: 100%;
}

/* The paste box should stay inviting while empty, so it keeps its 5-row look. */
textarea.field__input--tall { min-height: 120px; max-height: 320px; }

.field__input--invalid {
  border-color: var(--post-red);
  background: var(--post-red-soft);
}
.field__input--invalid:focus {
  border-color: var(--post-red);
  box-shadow: 0 0 0 4px var(--post-red-soft);
}

/* Custom dropdown (dropdown_controller.js) ------------------------------ */
/* The native select stays in the DOM for the form and validation but is
 * visually hidden (not display:none, so it can still be validated/focused);
 * the button + menu next to it are what the user sees. Same white panel and
 * black text on every platform, in place of the OS-drawn popup. */
.dropdown__native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: -1px !important;
  border: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0);
  opacity: 0;
  pointer-events: none;
}
.dropdown { position: relative; width: 100%; }
.dropdown__btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.dropdown__btn:disabled { opacity: 0.6; cursor: default; }
.dropdown__btn--placeholder .dropdown__label { color: #9aa1ab; }
.dropdown__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dropdown__chevron {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--muted);
  transition: transform 0.15s ease;
}
.dropdown__btn[aria-expanded="true"] .dropdown__chevron { transform: rotate(180deg); }
.dropdown__menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 70;
  margin: 0;
  padding: 6px;
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14);
}
.dropdown--up .dropdown__menu { top: auto; bottom: calc(100% + 6px); }
.dropdown__item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 12px 10px 36px;
  position: relative;
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--ink);
  cursor: pointer;
}
.dropdown__item:hover,
.dropdown__item:focus { background: var(--bg); }
.dropdown__item--selected {
  background: var(--post-red-soft);
  color: var(--post-red-dark);
  font-weight: 700;
}
/* Check mark on the chosen option. */
.dropdown__item--selected::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 50%;
  width: 6px;
  height: 11px;
  border: solid var(--post-red);
  border-width: 0 2.5px 2.5px 0;
  transform: translateY(-60%) rotate(45deg);
}
.dropdown__item--placeholder { color: var(--muted); }
.dropdown__item--disabled { opacity: 0.45; cursor: default; }

.field__error {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--post-red-dark);
  line-height: 1.4;
}

.field__input--locked {
  background: #f1f2f4;
  color: var(--muted);
  cursor: not-allowed;
}

.field-row { display: flex; gap: 12px; align-items: stretch; }
/* Side-by-side fields share the height of the tallest, and each one packs its
 * label and input to the bottom. A label that wraps to two lines on a narrow
 * phone ("น้ำหนักโดยประมาณ (กรัม) *" at 360px) would otherwise push its own
 * input below its neighbour's, leaving the two boxes visibly out of step.
 * Packing downwards lines the inputs up and sits every label right above its
 * own box, whatever the wrapping, with nothing shortened to make it fit. */
.field-row .field { flex: 1; min-width: 0; justify-content: flex-end; }

/* Quick address search dropdown ------------------------------------------ */
.address-suggest { position: relative; }
.address-suggest__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  max-height: 300px;
  overflow-y: auto;
}
.address-suggest__list[hidden] { display: none; }
.address-suggest__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 14px;
  cursor: pointer;
}
.address-suggest__item:hover { background: var(--post-red-soft); }
.address-suggest__name { font-weight: 700; color: var(--ink); }
.address-suggest__meta { font-size: 0.82rem; color: var(--muted); }
/* The same place in the other language, so a reader can match either spelling. */
.address-suggest__alt { font-size: 0.76rem; color: #9aa1ab; }

/* ID document (national ID / passport) -------------------------------- */
.id-document { gap: 8px; }
.field__input--id-type { font-weight: 600; }
/* .field sets display:flex, which would otherwise beat the [hidden] attribute. */

/* Hint banner for required fields, etc. */
.hint {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--post-red-soft);
  color: var(--post-red-dark);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 14px;
}
.hint__icon { flex: none; display: inline-flex; color: var(--post-red); }
.hint__icon svg { width: 18px; height: 18px; display: block; }

.price-estimate {
  background: var(--info-soft);
  color: var(--info);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 1.02rem;
  font-weight: 700;
  margin: 4px 0 12px;
}

/* Prominent result card on the new-parcel form (same info/blue tone). */
.price-estimate--card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}
.price-estimate__icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
}
.price-estimate__icon svg { width: 100%; height: 100%; display: block; }
.price-estimate__body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.price-estimate__label { font-size: 0.84rem; font-weight: 700; }
.price-estimate__amount { font-size: 1.9rem; font-weight: 800; line-height: 1.15; }
.price-estimate__remote { font-size: 0.8rem; font-weight: 600; }
.price-estimate__note {
  font-size: 0.76rem;
  font-weight: 500;
  line-height: 1.35;
  opacity: 0.8;
  margin-top: 2px;
}
.price-estimate--unavailable .price-estimate__amount { font-size: 1rem; font-weight: 700; }
.price-estimate--unavailable .price-estimate__label,
.price-estimate--unavailable .price-estimate__note,
.price-estimate--unavailable .price-estimate__remote { display: none; }

.more { margin-top: 4px; border-top: 1px solid var(--line); }
.more__title {
  margin: 0;
  color: var(--post-red);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 12px 0;
  display: flex;
  align-items: center;
}
.more__body {
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding-bottom: 6px;
}

/* Stepper -------------------------------------------------------------- */
.wizard-progress {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--post-red);
  margin: 0 0 8px;
}

/* Segmented stepper: each step is a bordered card with a number badge and a
 * title. The active step is outlined red. The first item has an
 * arrow on the right, middle items a notch on the left plus an arrow on the
 * right, and the last item just the notch. */
.stepper {
  display: flex;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
}

.stepper__item {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px;
  min-width: 0;
}
/* The arrow / notch is drawn by a stretching SVG, so its depth grows with the
 * item's width (24/200 of it). Pad by the same proportion (percent padding is
 * relative to the stepper's width; an item is about a third of it, so 4% of
 * the stepper ≈ 12% of the item) plus a fixed gap, so the badge never sits on
 * the notch, on a narrow phone or a wide tablet alike. */
.stepper__item--arrow { padding-right: calc(4% + 10px); }
.stepper__item--notch { padding-left: calc(4% + 10px); }
.stepper__item--middle { padding-left: calc(4% + 10px); padding-right: calc(4% + 10px); }

/* Arrow-ribbon / notch shape drawn as a stretching SVG behind the content. */
.stepper__shape {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  fill: #fff;
  stroke: var(--line);
  stroke-width: 1.5;
}
.stepper__item--active .stepper__shape {
  fill: var(--post-red-soft);
  stroke: var(--post-red);
  stroke-width: 2;
}
.stepper__item--done .stepper__shape {
  fill: #fff;
  stroke: var(--success);
}
.stepper__badge,
.stepper__body { position: relative; z-index: 1; }

.stepper__badge {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #c9ccd1;
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.stepper__item--active .stepper__badge { background: var(--post-red); }
.stepper__item--done .stepper__badge { background: var(--success); }

.stepper__body { display: flex; flex-direction: column; min-width: 0; }
.stepper__title {
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.25;
  color: var(--muted);
}
.stepper__item--active .stepper__title { color: var(--ink); }

/* Narrow phones: tighten padding, the arrow overlap, and type so the Thai
 * titles fit without cramped multi-line wrapping. */
/* Narrow phones: the number and the label cannot sit side by side inside an
 * arrow this narrow - an English label ("Recipient") ran straight over the
 * notch into the next step. Stack them instead, which hands the label the
 * item's full width, and trim the side padding to the notch's own depth. */
@media (max-width: 430px) {
  .stepper { gap: 6px; }
  .stepper__item {
    flex-direction: column;
    justify-content: center;
    padding-top: 10px;
    padding-bottom: 10px;
    gap: 4px;
    text-align: center;
  }
  .stepper__item--arrow { padding-right: calc(3% + 6px); padding-left: 8px; }
  .stepper__item--notch { padding-left: calc(3% + 6px); padding-right: 8px; }
  .stepper__item--middle { padding-left: calc(3% + 6px); padding-right: calc(3% + 6px); }
  .stepper__badge { width: 24px; height: 24px; font-size: 0.78rem; }
  .stepper__body { align-items: center; }
  .stepper__title { font-size: 0.74rem; line-height: 1.15; }
}

.step__title { font-size: 1.1rem; margin: 0 0 14px; font-weight: 800; }

/* Lists ---------------------------------------------------------------- */
.screen .parcels__results { margin-top: 16px; }
.list { list-style: none; padding: 0; margin: 0; }
.list__item { margin-bottom: 14px; }
.list__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 18px;
  min-height: 76px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.07);
  border: 1px solid transparent;
}
.list__link:active { border-color: var(--post-red); }
.list__main { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.list__title { font-weight: 700; font-size: 1.15rem; }
.list__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: none;
  text-align: right;
}
/* The status line is the point of the card, so it keeps its own line; the
 * barcode and the "as of" time sit under it, one line each. */
.list__meta .badge { font-size: 0.82rem; padding: 4px 11px; }
.list__meta .mono,
.list__meta .muted { white-space: nowrap; font-size: 0.78rem; }

/* Badges --------------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 700;
  background: var(--line);
  color: var(--ink);
  /* Delivery labels are long in Thai ("อยู่ระหว่างนำจ่าย"); let the card's
   * main column give up width instead of breaking the label mid-word. */
  white-space: nowrap;
}
.badge--labeled { background: var(--success-soft); color: var(--success); }
.badge--submitted { background: var(--info-soft); color: var(--info); }
.badge--draft { background: #eef0f2; color: #374151; }
.badge--failed { background: var(--danger-soft); color: var(--danger); }
/* Delivery journey, in order: handed over (purple), moving (blue), at the
 * door (amber), arrived (green). Returned and exception share the alert red
 * because both mean "this one needs attention". */
.badge--unknown { background: #eef0f2; color: #374151; }
.badge--dropped_off { background: #ede9fe; color: #5b21b6; }
.badge--in_transit { background: var(--info-soft); color: var(--info); }
.badge--out_for_delivery { background: #fef3c7; color: #92400e; }
.badge--delivered { background: var(--success-soft); color: var(--success); }
.badge--returned { background: var(--danger-soft); color: var(--danger); }
.badge--exception { background: var(--danger-soft); color: var(--danger); }

/* Tracking timeline ---------------------------------------------------- */
.tracking-timeline__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tracking-timeline__item {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 10px;
}
.tracking-timeline__dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--post-red);
  box-shadow: 0 0 0 4px var(--post-red-soft);
}
.tracking-timeline__body { min-width: 0; }
.tracking-timeline__body p { margin: 0 0 3px; }
.tracking-timeline__title { font-weight: 800; }
/* Label / QR ----------------------------------------------------------- */
/* Sized so each QR module stays around 3.7px: a version 15 (77x77) code inside
 * a 320px box. The 16px of white padding is the spec's 4-module quiet zone,
 * which scanners need to find the code at all. */
.label .qr {
  width: 320px;
  height: 320px;
  max-width: 88vw;
  margin: 18px auto;
  background: #fff;
  padding: 16px;
  border-radius: 12px;
  box-sizing: border-box;
  cursor: pointer;
}
.label .qr svg { width: 100%; height: 100%; }
/* Collapsed, the QR keeps no box of its own - only its caption stays visible,
 * so the hidden code leaves no empty white square behind. */
.label .qr.barcode--collapsed {
  width: auto;
  height: auto;
  margin: 12px auto 0;
  background: none;
  padding: 0;
}
.label .barcode-1d {
  margin: 12px auto 0;
  max-width: 90%;
  background: #fff;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}
.label .barcode-1d svg { width: 100%; height: auto; display: block; }
.barcode__caption { display: block; text-align: center; margin-top: 6px; }
.label .qr .barcode__caption { margin-bottom: 24px; }
.label__barcode { margin-top: 12px; }
.label__barcode .mono { font-size: 1.4rem; letter-spacing: 2px; font-weight: 700; }

/* Flash ---------------------------------------------------------------- */
/* Flash messages are shown as a toast that floats over the top of the screen,
 * animates in, then fades out on its own (see flash_controller.js). It is
 * pinned above the sticky topbar (z-index 50) so it reads as an overlay, not
 * part of the page. */
.flash-stack {
  position: fixed;
  top: calc(10px + var(--branch-bar-h) + var(--safe-top));
  left: 50%;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: calc(var(--shell-w) - 20px);
  /* Hidden + lifted until the controller adds .is-visible. */
  transform: translateX(-50%) translateY(-16px);
  opacity: 0;
  transition: opacity 0.28s ease, transform 0.28s ease;
  pointer-events: none;
}
.flash-stack.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.flash {
  margin: 0;
  padding: 13px 18px;
  border-radius: 12px;
  text-align: center;
  font-weight: 600;
  font-size: 1.02rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  pointer-events: auto;
}
.flash--notice { background: var(--success-soft); color: var(--success); }
.flash--alert { background: var(--danger-soft); color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  .flash-stack { transition: opacity 0.2s ease; transform: translateX(-50%); }
}

/* Spinner -------------------------------------------------------------- */
.spinner {
  width: 44px;
  height: 44px;
  margin: 18px auto;
  border: 4px solid var(--line);
  border-top-color: var(--post-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status { font-size: 1.1rem; margin: 4px 0 0; }

/* Search box ----------------------------------------------------------- */
.address-search {
  position: relative;
  margin: 4px 0 18px;
}

/* Parcel list filters: search box and status picker side by side, stacking on
 * narrow phones so neither gets squeezed below a usable width. */
.list-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.list-filters .address-search { flex: 1 1 15rem; margin: 0; }
.list-filters__status { flex: 0 1 13rem; }
/* Same shape as the search box beside it - pill, 2px border, same height and
 * type size - so the two read as one row of controls. Covers both the native
 * select and the custom dropdown button that replaces it. */
.list-filters__status select.field__input,
.list-filters__status .dropdown__btn {
  min-height: var(--tap);
  padding: 13px 18px;
  border: 2px solid var(--line);
  border-radius: 999px;
  font-size: 1.05rem;
}
.list-filters__status .dropdown__btn:focus-visible,
.list-filters__status select.field__input:focus {
  outline: none;
  border-color: var(--post-red);
  box-shadow: 0 0 0 4px var(--post-red-soft);
}
.list-filters__status .dropdown__menu { border-radius: 16px; }
/* Below this the two controls cramp each other: the search placeholder gets
 * cut off and a long Thai status ("อยู่ระหว่างนำจ่าย") ellipses. Give each a
 * full-width row instead. */
@media (max-width: 560px) {
  .list-filters .address-search,
  .list-filters__status { flex: 1 1 100%; }
}
.address-search__icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  opacity: 0.6;
  pointer-events: none;
}
.address-search__input {
  width: 100%;
  min-height: var(--tap);
  padding: 13px 16px 13px 46px;
  border: 2px solid var(--line);
  border-radius: 999px;
  font-size: 1.05rem;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
}
.address-search__input:focus {
  outline: none;
  border-color: var(--post-red);
  box-shadow: 0 0 0 4px var(--post-red-soft);
}
.address-search__input::-webkit-search-cancel-button { cursor: pointer; }

/* Tabs ----------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  background: #eceef1;
  border-radius: 999px;
}
.tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.tab--active {
  background: #fff;
  color: var(--post-red);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.tab__count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
  font-size: 0.75rem;
  font-weight: 700;
}
.tab--active .tab__count { background: var(--post-red-soft); color: var(--post-red); }

/* Panels --------------------------------------------------------------- */
.address-panel__head {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}
.address-panel__empty {
  text-align: center;
  color: var(--muted);
  padding: 24px 8px;
  margin: 0;
}

/* Address card --------------------------------------------------------- */
.address-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.07);
  border: 1px solid transparent;
}
.address-card__body { display: flex; flex-direction: column; gap: 4px; }
.address-card__head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.address-card__label { font-weight: 800; font-size: 1.15rem; }
.address-card__line { margin: 0; }

.address-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
/* Default toggle grows to fill the row; edit/delete are compact icon buttons. */
.address-card__default { flex: 1 1 auto; }
.address-card__secondary { display: flex; gap: 10px; flex: 0 0 auto; }

/* Edit / delete: equal-weight round icon buttons, tinted by intent
 * (edit = neutral grey, delete = postal danger red). */
.address-card__icon-btn {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border-width: 1.5px;
  border-color: var(--line);
  color: var(--muted);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.address-card__icon-btn svg { width: 18px; height: 18px; }
.address-card__icon-btn:active { background: var(--bg); color: var(--ink); }
.address-card__icon-btn.btn--danger {
  color: var(--danger);
  border-color: var(--line);
  background: #fff;
}
.address-card__icon-btn.btn--danger:active {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.address-card__default {
  background: #fff;
  color: var(--muted);
  border: 2px solid var(--line);
}
.address-card__default .address-card__star { font-size: 1.15rem; line-height: 1; }
.address-card__default:active { background: var(--bg); }
.address-card__default.is-active {
  background: var(--info-soft);
  border-color: var(--info);
  color: var(--info);
}
.address-card__default.is-active .address-card__star { color: var(--info); }

.badge--default {
  padding: 3px 12px;
  font-size: 0.82rem;
  background: var(--info-soft);
  color: var(--info);
}

/* Role toggle ---------------------------------------------------------- */
.role-toggle { border: none; padding: 0; margin: 0 0 18px; }
.role-toggle legend { margin-bottom: 10px; }
/* Pill segmented control, matching the address-book tabs (.tabs) and the
   wizard segmented control (.seg) for a consistent single-select look. */
.role-toggle__options {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #eceef1;
  border-radius: 999px;
}
.role-toggle__option {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
/* The pill selection conveys the choice; hide the native radio dot but keep it
   in the DOM so the form still submits and screen readers announce it. */
.role-toggle__option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.role-toggle__option:has(input:checked) {
  background: #fff;
  color: var(--post-red);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
/* Same look, set by role_toggle_controller for engines without :has()
   (Safari < 15.4, Chrome < 105). Kept as its own rule on purpose: an
   unsupported selector anywhere in a selector list drops the whole rule. */
.role-toggle__option--selected {
  background: #fff;
  color: var(--post-red);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.role-toggle__option:has(input:focus-visible) {
  box-shadow: 0 0 0 3px var(--post-red-soft);
}

/* Address book picker (inside parcel wizard) --------------------------- */
.address-picker {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 16px;
}
.address-picker .field { flex: 1; margin: 0; }

/* Address-label photo scan -------------------------------------------- */
.address-scan { margin-bottom: 16px; }
.address-scan__btn { width: 100%; }
.address-scan--loading .address-scan__btn { opacity: 0.6; cursor: progress; }
.address-scan__status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 0;
}
.address-scan__status--error { color: var(--danger); }
.address-scan__spinner {
  flex: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--post-red-soft);
  border-top-color: var(--post-red);
  border-radius: 50%;
  animation: address-scan-spin 0.7s linear infinite;
}
@keyframes address-scan-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .address-scan__spinner { animation-duration: 1.6s; }
}

.field--inline {
  flex-direction: row;
  align-items: center;
  gap: 9px;
  min-height: 32px;
}
.field--inline input { width: 16px; height: 16px; accent-color: var(--post-red); }
/* The tick for an address that came out of the address book: already answered,
 * so it reads as a statement rather than a question waiting on the customer. */
.field--settled { opacity: 0.65; cursor: default; }
.field--settled input { cursor: default; }
.field--inline span { font-size: 0.82rem; }

/* Sticky bottom action bar (Shopee-style) ------------------------------ */
/* Primary actions live in a fixed bar pinned to the bottom of the viewport
 * so the main CTA is always within thumb reach on mobile / inside LIFF. */
.action-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  gap: 12px;
  max-width: calc(var(--shell-w) + 40px);
  margin: 0 auto;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 14px rgba(0, 0, 0, 0.08);
}
.action-bar .btn { flex: 1; margin-top: 0; }
.action-bar form.button_to { flex: 1; display: flex; }
.action-bar form.button_to .btn { width: 100%; }
/* Keep page content clear of the fixed bar. */
.screen--with-action-bar { padding-bottom: 92px; }

/* Topbar overflow ("kebab") menu — holds a parcel's edit/delete actions ---- */
.menu { position: relative; display: inline-flex; }

.kebab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}
.kebab:active { background: var(--line); }

.menu__panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  padding: 6px;
  z-index: 60;
}
.menu__panel[hidden] { display: none; }
.menu__panel form.button_to { display: block; margin: 0; }

.menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  background: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu__item:active { background: #f3f4f6; }
.menu__item--danger { color: var(--danger); }
.menu__icon { width: 18px; height: 18px; flex: none; }

/* Card section header with leading icon (Shopee-style section blocks) --- */
.card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.card__icon {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--post-red-soft);
  color: var(--post-red);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
}
/* Sized so "ผู้ส่ง / ผู้รับ" read as section headings on a phone; customers
   found 0.95rem too small to scan while filling the form. */
.card__title { font-size: 1.2rem; font-weight: 800; margin: 0; }

/* Field with a leading icon ------------------------------------------- */
.field__control { position: relative; display: flex; }
.field__control .field__input { width: 100%; }
.field__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
  line-height: 1;
  opacity: 0.55;
  pointer-events: none;
}
.field__input--icon { padding-left: 36px; }
.field__input::placeholder { color: #9aa1ab; }

/* ID document: the type select on its own line above the number input.
 * Stacked (not side by side) so the number field keeps its full width even
 * when the user's phone has enlarged text, which otherwise squeezed the
 * number input down to a sliver next to the wide Thai select label. */
.id-document__row { display: flex; flex-direction: column; gap: 8px; }
.id-document__row .field__input--id-type,
.id-document__row .id-document__number { width: 100%; min-width: 0; }

/* Scan label call-to-action, rendered as one tappable card row. -------- */
.scan-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.scan-row:active { transform: translateY(1px); }
.scan-row__icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--post-red-soft);
  color: var(--post-red);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.scan-row__cam { width: 22px; height: 22px; display: block; }
.scan-row__body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.scan-row__title { font-weight: 800; font-size: 0.88rem; color: var(--ink); }
.scan-row__sub { font-size: 0.72rem; color: var(--muted); line-height: 1.3; }
.scan-row__chev { flex: none; color: var(--muted); font-size: 1.3rem; line-height: 1; }

/* Recipient quick-actions: two pills side by side (paste / ask customer). */
/* Recipient mode segmented control (fill it yourself / ask the customer) */
.recipient-mode { margin-bottom: 12px; }
.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #eceef1;
  border-radius: 999px;
}
.seg__btn {
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.2;
  min-height: var(--tap);
}
.seg__btn--active {
  background: #fff;
  color: var(--post-red);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* Paste-to-fill hint bar (opens the paste modal) */
.address-parse { margin-bottom: 0; }
.paste-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--post-red);
  border-radius: var(--radius);
  background: var(--post-red-soft);
  color: var(--post-red);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
}
.paste-bar:active { background: #fbdedc; }
.paste-bar__text { flex: 1; }
/* Looks like a button; the whole bar is the actual <button> that opens the modal. */
.paste-bar__cta {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--post-red);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
}
.paste-bar:active .paste-bar__cta { background: var(--post-red-dark); }

/* The headless customer-link (opened by the segmented control) contributes no
 * visible box, so strip the .address-scan spacing that would leave a gap. */
.customer-link--headless { margin: 0; }

/* ─── Modal dialogs (paste address / customer link) ─────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
body.modal-open { overflow: hidden; }

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 20, 24, 0.45);
  opacity: 0;
  transition: opacity 0.16s ease;
}
.modal.is-open .modal__backdrop { opacity: 1; }

.modal__panel {
  position: relative;
  width: 100%;
  max-width: 360px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 26px 22px 20px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: 0 18px 48px rgba(17, 20, 24, 0.28);
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition: opacity 0.16s ease, transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.modal.is-open .modal__panel {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.modal__close:active { background: var(--bg); }

.modal__icon {
  width: 56px;
  height: 56px;
  margin: 4px auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--post-red-soft);
  color: var(--post-red);
  font-size: 1.5rem;
}
.modal__icon svg { width: 28px; height: 28px; }

.modal__title {
  margin: 0 0 6px;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ink);
  text-align: center;
}
.modal__desc {
  margin: 0 0 16px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
}
.modal__info {
  margin: 14px 0 0;
  padding: 10px 12px;
  background: var(--info-soft);
  color: var(--info);
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
}
/* Fields inside a modal aren't wrapped in the .fields grid, so space them here. */
.modal__panel .field + .field { margin-top: 14px; }
.modal__status { margin: 12px 0 0; }
.modal__status.address-scan__status--error { color: var(--danger); }
.modal .btn--block { margin-top: 16px; }

@media (prefers-reduced-motion: reduce) {
  .modal__backdrop,
  .modal__panel { transition: none; }
}

/* ─── Privacy notice pop-up ──────────────────────────────────────────────
 * A variant of .modal for the PDPA notice that opens on the rich-menu landing
 * page. Long legal copy, so the panel is a fixed-height column — header and
 * footer stay put while only .privacy__body scrolls. Kept deliberately small
 * (a card, not a full-screen takeover) so the page behind it still reads as
 * the app, but tall enough that the text is obviously scrollable. */
.modal--privacy { padding: 16px; }

.modal__panel--privacy {
  display: flex;
  flex-direction: column;
  max-width: 400px;
  /* dvh keeps the panel clear of the LINE webview's collapsing browser bars;
   * vh is the fallback for engines without it. The 640px cap stops the notice
   * from stretching into a wall of text on tall phones and tablets. */
  max-height: min(calc(100vh - 32px), 640px);
  max-height: min(calc(100dvh - 32px), 640px);
  /* The header/footer own the padding so the scroll area can run edge to edge. */
  padding: 0;
  overflow: hidden;
}

.privacy__header {
  position: relative;
  flex: none;
  padding: 16px 20px 14px;
  background: var(--card);
}
/* Divider between the title and the notice itself. Inset from both edges and
 * only 2px tall: enough to mark where the scrolling text starts without
 * drawing a full-width rule across the card. */
.privacy__header::after {
  content: "";
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--post-red);
}
.privacy__title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.35;
  color: var(--post-red-dark);
}
.privacy__subtitle {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.privacy__body {
  flex: 1 1 auto;
  min-height: 0; /* Without this the flex item refuses to shrink and scroll. */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* Don't hand the scroll off to the page once the notice hits its end. */
  overscroll-behavior: contain;
  padding: 14px 20px 16px;
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--ink);
}
/* The body is focusable so it can be scrolled with the keyboard, but it is
 * focused automatically when the pop-up opens — a ring there just draws a box
 * around the whole notice, so there is no focus styling at all. */
.privacy__body:focus,
.privacy__body:focus-visible { outline: none; }

.privacy__body p { margin: 0 0 10px; }
.privacy__heading {
  margin: 20px 0 8px;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.45;
  color: var(--post-red-dark);
}
/* Same short red rule as the header divider, marking the start of a section.
 * Deliberately a stub rather than a full-width line — it separates without
 * chopping the notice into boxes. */
.privacy__heading::before {
  content: "";
  display: block;
  width: 44px;
  height: 2px;
  margin-bottom: 10px;
  border-radius: 2px;
  background: var(--post-red);
}
.privacy__body > .privacy__heading:first-child { margin-top: 0; }

.privacy__list {
  margin: 0 0 10px;
  padding-left: 1.35em;
}
.privacy__list li { margin-bottom: 7px; }
.privacy__list li:last-child { margin-bottom: 0; }

.privacy__contact {
  margin: 0 0 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.privacy__contact p { margin: 0 0 6px; }
.privacy__contact p:last-child { margin-bottom: 0; }
.privacy__contact-name { font-weight: 700; }
/* Label above, value below. The Thai labels here are long enough that keeping
 * them on the same line as the value pushes the value onto a ragged second
 * line, which reads as if it belongs to the next entry. */
.privacy__pair-label { display: block; }
/* Never let a phone number break across lines. */
.privacy__pair a[href^="tel:"] { white-space: nowrap; }
.privacy__body a { color: var(--post-red-dark); }

.privacy__date {
  margin-top: 14px;
  text-align: right;
  color: var(--muted);
  font-size: 0.8rem;
}

.privacy__footer {
  flex: none;
  padding: 12px 20px;
  /* Clears the home indicator when the webview runs edge to edge. */
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--card);
  border-top: 1px solid var(--line);
  /* Soft lift under the footer, which doubles as a hint that the text above
   * continues past the fold. */
  box-shadow: 0 -10px 18px -14px rgba(17, 20, 24, 0.5);
}
.privacy__footer .btn--block { margin-top: 0; }

/* Narrow phones: reclaim the outer margin and tighten the copy so the notice
 * still shows several lines of text above the fold. */
@media (max-width: 430px) {
  .modal--privacy { padding: 12px; }
  .modal__panel--privacy {
    /* Keep the 640px cap: on a tall phone a full-height sheet reads as a
     * separate screen, and the notice should stay a card over the app. */
    max-height: min(calc(100vh - 24px), 640px);
    max-height: min(calc(100dvh - 24px), 640px);
  }
  .privacy__header { padding: 14px 16px 10px; }
  .privacy__title { font-size: 0.98rem; }
  .privacy__body { padding: 12px 16px 14px; font-size: 0.83rem; }
  .privacy__footer { padding-left: 16px; padding-right: 16px; }
}

/* Short viewports (landscape phones): a percentage cap leaves too little, so
 * take nearly the whole height and let the body do the scrolling. */
@media (max-height: 520px) {
  .modal__panel--privacy {
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }
  .modal--privacy { padding: 8px; }
}

/* ─── App-style confirm dialog ──────────────────────────────────────────
 * Replaces the browser-native confirm() Turbo would otherwise show, so a
 * destructive action inside the LIFF webview looks like the phone's own
 * dialogs (centered card, big taps) instead of "localhost:3000 says". */
.confirm-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
body.confirm-dialog-open { overflow: hidden; }

.confirm-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 20, 24, 0.45);
  opacity: 0;
  transition: opacity 0.16s ease;
}
.confirm-dialog.is-open .confirm-dialog__backdrop { opacity: 1; }

.confirm-dialog__panel {
  position: relative;
  width: 100%;
  max-width: 320px;
  padding: 26px 22px 18px;
  background: var(--card);
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 18px 48px rgba(17, 20, 24, 0.28);
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition: opacity 0.16s ease, transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.confirm-dialog.is-open .confirm-dialog__panel {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.confirm-dialog__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--post-red-soft);
  color: var(--post-red);
}
.confirm-dialog__panel--danger .confirm-dialog__icon {
  background: var(--danger-soft);
  color: var(--danger);
}
.confirm-dialog__icon svg { width: 28px; height: 28px; }

.confirm-dialog__title {
  margin: 0 0 6px;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ink);
}
.confirm-dialog__note {
  margin: 0 0 22px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--muted);
}

.confirm-dialog__actions {
  display: flex;
  gap: 10px;
}
.confirm-dialog__btn {
  flex: 1;
  min-height: var(--tap);
  padding: 12px 14px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}
.confirm-dialog__btn--cancel {
  background: var(--bg);
  color: var(--ink);
  border: 1.5px solid var(--line);
}
.confirm-dialog__btn--cancel:active { background: var(--line); }
.confirm-dialog__btn--ok {
  background: var(--post-red);
  color: #fff;
}
.confirm-dialog__btn--ok:active { background: var(--post-red-dark); }
.confirm-dialog__btn--danger { background: var(--danger); }
.confirm-dialog__btn--danger:active { background: #991b1b; }

@media (prefers-reduced-motion: reduce) {
  .confirm-dialog__backdrop,
  .confirm-dialog__panel { transition: none; }
}

/* ─── Responsive layout ──────────────────────────────────────────────────
 * The app was designed phone-first as one column. These rules keep that
 * flow but scale it: a narrower gutter on small phones, and on tablets a
 * wider column, slightly larger type and controls, roomier cards, and the
 * parcel / address-book lists in two columns. The wizard, forms and modals
 * stay single-column so the one-thing-at-a-time flow is unchanged. */

/* Small phones (iPhone SE / mini, compact Androids): tighter gutters so the
 * three-up field rows and stepper still fit. */
@media (max-width: 360px) {
  :root { --screen-x: 12px; }
  .card { padding: 12px; }
  .field-row { gap: 8px; }
  .action-bar { padding-left: 12px; padding-right: 12px; gap: 8px; }
}

/* Tablets (iPad portrait, large phones in landscape, small laptops). */
@media (min-width: 700px) {
  :root {
    --shell-w: 680px;
    --screen-x: 24px;
    --tap: 48px;
  }
  html, body { font-size: 16px; }
  .screen { padding-top: 20px; }
  .topbar { margin-top: -20px; padding-top: 14px; padding-bottom: 14px; }
  .topbar h1 { font-size: 1.35rem; }

  .card { padding: 20px 22px; margin-bottom: 14px; }
  .field__input { min-height: 40px; padding-top: 8px; padding-bottom: 8px; font-size: 1rem; }
  .field__input--icon { padding-left: 38px; }
  .field__label { font-size: 0.86rem; }
  .fields { gap: 16px; }
  .field-row { gap: 16px; }

  .stepper__item { padding-top: 20px; padding-bottom: 20px; }
  .stepper__badge { width: 34px; height: 34px; }
  .stepper__title { font-size: 1.05rem; }

  /* Lists: two cards per row. Filtered-out items are [hidden], which the
   * grid simply skips. */
  .list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
  .list__item,
  .list .address-card { margin-bottom: 0; }
  .list__link { height: 100%; }

  .modal__panel { max-width: 440px; }
  .modal__panel--privacy { max-width: 520px; }
  .dropdown__menu { max-height: 320px; }
}

/* Large tablets and desktop (iPad landscape, laptops): a touch wider still,
 * but capped so line lengths stay comfortable to read. */
@media (min-width: 1024px) {
  :root { --shell-w: 760px; }
}

/* Landscape phones: the fixed action bar and sticky top bar eat a lot of a
 * short viewport, so trim their padding. */
@media (max-height: 480px) and (orientation: landscape) {
  .topbar { padding-top: 8px; padding-bottom: 8px; }
  .action-bar { padding-top: 8px; }
  .screen--with-action-bar { padding-bottom: 76px; }
}

/* ─── Large type ─────────────────────────────────────────────────────────
 * For customers who find the default hard to read. Everything sized in rem
 * grows with the root, which is most of the UI; the handful of fixed
 * measurements that would otherwise crowd or clip the bigger text are lifted
 * to match. Deliberately not the browser's own zoom: the page keeps its
 * single-column shape and nothing has to be scrolled sideways.
 *
 * The attribute is rendered server-side from the saved preference, so the
 * page never paints small and then jumps.
 */
html[data-text-size="large"] {
  font-size: 18px;
  --tap: 52px;
  /* The branch notice is one fixed-height line that the sticky bars and the
   * screen height all measure against; without this its text would ellipsis. */
  --branch-bar-h: 52px;
}
html[data-text-size="large"] body { font-size: 18px; }

/* Fixed paddings and heights, lifted proportionally. */
html[data-text-size="large"] .field__input { min-height: 38px; padding-top: 9px; padding-bottom: 9px; }
html[data-text-size="large"] textarea.field__input { min-height: 68px; }
html[data-text-size="large"] .address-search__input { padding-top: 15px; padding-bottom: 15px; }
html[data-text-size="large"] .list__link { padding: 20px; min-height: 84px; }
html[data-text-size="large"] .card { padding: 16px; }
html[data-text-size="large"] .topbar__close { width: 44px; height: 44px; }
html[data-text-size="large"] .dropdown__item { min-height: 52px; }
html[data-text-size="large"] .stepper__badge { width: 34px; height: 34px; }
/* The action bar grows with its buttons, so the page needs more room under it. */
html[data-text-size="large"] .screen--with-action-bar { padding-bottom: 104px; }

/* At this size a title and three controls may not share a line on a phone.
 * Let the bar wrap only when it actually has to: the title keeps to one line
 * at its natural width, and the controls drop to a second row only if what is
 * left is too narrow for them. Pages with a short title and one or two
 * controls - the label page, for one - stay on a single row. */
@media (max-width: 560px) {
  /* The preference controls keep their normal size. They are buttons carrying
   * one character each, not text anyone reads, and letting them grow was what
   * pushed the whole row over the edge and dropped it onto a second line. */
  html[data-text-size="large"] .lang-switch__btn { font-size: 14px; padding: 6px 9px; }
  html[data-text-size="large"] .text-size-switch__btn--normal { font-size: 12px; }
  html[data-text-size="large"] .text-size-switch__btn--large { font-size: 17px; }
  html[data-text-size="large"] .topbar__book { font-size: 13px; }
  /* The page title is a landmark, not something anyone reads a sentence of,
   * and at full scale it was what pushed the controls onto a second row. Held
   * just above its normal size so the bar stays one line. */
  html[data-text-size="large"] .topbar h1 { font-size: 19px; }

  /* Tighter spacing between the bar's pieces, which buys back the last few
   * pixels the controls need to stay beside the title. */
}

@media (max-width: 560px) {
  /* The stepper is a position indicator, not reading matter, and its labels
   * have to fit inside the arrow shapes. It keeps close to its normal size:
   * the "Step 1 of 3" line right above it is large and says the same thing.
   * Without this, a long label ("Recipient") wraps and spills across the
   * notch into the next step. */
  html[data-text-size="large"] .stepper__badge { width: 26px; height: 26px; font-size: 0.72rem; }
  html[data-text-size="large"] .stepper__title { font-size: 0.68rem; }

  /* Two long labels cannot share a phone's width at this size - "Duplicate
   * this order" wrapped inside its button. One per row instead: no wrapped
   * text, and a full-width target to aim at. */
  html[data-text-size="large"] .action-bar { flex-wrap: wrap; row-gap: 8px; }
  html[data-text-size="large"] .action-bar .btn,
  html[data-text-size="large"] .action-bar form.button_to { flex: 1 0 100%; }
  html[data-text-size="large"] .screen--with-action-bar { padding-bottom: 160px; }
}

/* The two choices show their own effect: a small letter and a big one. */
.text-size-switch__btn--normal { font-size: 0.8rem; }
.text-size-switch__btn--large { font-size: 1.15rem; }
.text-size-switch .lang-switch__btn { padding-left: 11px; padding-right: 11px; }
