/* ═══════════════════════════════════════════════════════════
   อายุร่างกาย — Luxury & Clean (ปรับสำหรับผู้ใช้ 40+ / 60+)
   ตัวอักษรใหญ่ขึ้น · ปุ่มสูงขึ้น · contrast สูงขึ้น
   ═══════════════════════════════════════════════════════════ */

:root {
  /* ── สี ── */
  --brand-primary: #0B7CFF;
  --brand-dark:    #0757B3;
  --brand-soft:    #E8F2FF;
  --accent-gold:   #C9A961;

  --ink-900: #0F1720;
  --ink-700: #33414F;
  --ink-500: #5B6B7B;
  --ink-300: #93A1AF;
  --ink-100: #D8DFE6;
  --ink-50:  #EDF1F5;

  --bg:        #FFFFFF;
  --bg-soft:   #F6F8FA;
  --surface:   #FFFFFF;

  --ok:      #0B7A44;
  --ok-soft: #E4F5EC;
  --warn:      #9A6200;
  --warn-soft: #FDF2DC;
  --bad:      #B3261E;
  --bad-soft: #FCEAE9;

  /* ── ตัวอักษร (18px ฐาน ปรับได้ด้วย --font-scale) ── */
  --font-scale: 1;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Sarabun', -apple-system, 'Segoe UI', sans-serif;

  --fs-xs:  calc(0.8125rem * var(--font-scale));
  --fs-sm:  calc(0.9375rem * var(--font-scale));
  --fs-md:  calc(1.125rem  * var(--font-scale));
  --fs-lg:  calc(1.3125rem * var(--font-scale));
  --fs-xl:  calc(1.625rem  * var(--font-scale));
  --fs-2xl: calc(2.125rem  * var(--font-scale));
  --fs-3xl: calc(3.25rem   * var(--font-scale));

  /* ── ระยะ ── */
  --sp-1: 0.25rem; --sp-2: 0.5rem;  --sp-3: 0.75rem; --sp-4: 1rem;
  --sp-5: 1.25rem; --sp-6: 1.5rem;  --sp-8: 2rem;    --sp-10: 2.5rem;
  --sp-12: 3rem;   --sp-16: 4rem;

  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 18px; --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgba(15,23,32,.06), 0 1px 3px rgba(15,23,32,.05);
  --shadow-md: 0 4px 12px rgba(15,23,32,.07), 0 2px 4px rgba(15,23,32,.04);
  --shadow-lg: 0 12px 32px rgba(15,23,32,.10), 0 4px 8px rgba(15,23,32,.05);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  /* ── ขนาดที่แตะได้ (สำคัญสำหรับผู้สูงวัย) ── */
  --tap-min: 52px;

  --topbar-h: 60px;
  --tabbar-h: 68px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-md);
  font-weight: 400;
  line-height: 1.7;
  color: var(--ink-900);
  background: var(--bg-soft);
  -webkit-font-smoothing: antialiased;
}

h1,h2,h3,h4 { margin: 0; line-height: 1.35; font-weight: 600; }
p { margin: 0 0 var(--sp-4); }
a { color: var(--brand-dark); }

.display {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  letter-spacing: .01em;
}

/* ═══ หน้าจอโหลด ═══ */
.boot-screen {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-6); background: var(--bg);
}
.boot-mark { font-family: var(--font-display); font-style: italic; font-size: var(--fs-2xl); color: var(--brand-primary); }
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--ink-100); border-top-color: var(--brand-primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ โครงหลัก ═══ */
.shell { min-height: 100dvh; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--sp-4);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--ink-50);
}
.brand {
  display: flex; align-items: center; gap: var(--sp-2);
  font-family: var(--font-display); font-style: italic; font-weight: 600;
  font-size: var(--fs-lg); color: var(--brand-primary); text-decoration: none;
}
.topbar-actions { display: flex; gap: var(--sp-1); }
.font-mark { font-size: .8em; }
.font-mark-lg { font-size: 1.15em; margin-left: 1px; }

.view {
  max-width: 720px; margin: 0 auto;
  padding: var(--sp-6) var(--sp-4) var(--sp-12);
  outline: none;
}
/* มีแถบย้อนกลับอยู่แล้ว จึงไม่ต้องเว้นบนซ้ำ */
#backbar-mount:not(:empty) + .view { padding-top: var(--sp-3); }
@media (min-width: 900px) {
  .view { padding-top: var(--sp-10); }
}

/* ═══ Tab bar ═══ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--ink-50);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; text-decoration: none; color: var(--ink-500);
  font-size: var(--fs-xs); font-weight: 500;
  transition: color .2s var(--ease);
}
.tab svg { width: 23px; height: 23px; }
.tab span { font-size: calc(0.75rem * var(--font-scale)); line-height: 1.2; }
.tab[aria-current="page"] { color: var(--brand-primary); font-weight: 600; }

/* ═══ ปุ่ม ═══ */
.btn-primary, .btn-secondary, .btn-ghost, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--tap-min); padding: 0 var(--sp-6);
  font-family: inherit; font-size: var(--fs-md); font-weight: 600;
  border-radius: var(--radius-md); border: 1px solid transparent;
  cursor: pointer; text-decoration: none;
  transition: background .2s var(--ease), border-color .2s var(--ease), transform .1s var(--ease);
}
.btn-primary { background: var(--brand-primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-secondary { background: var(--surface); color: var(--ink-900); border-color: var(--ink-100); }
.btn-secondary:hover:not(:disabled) { border-color: var(--ink-300); background: var(--bg-soft); }
.btn-ghost { background: transparent; color: var(--ink-700); padding: 0 var(--sp-3); }
.btn-ghost:hover:not(:disabled) { background: var(--ink-50); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #8E1E17; }
.btn-icon { min-width: var(--tap-min); padding: 0; }
.btn-block { display: flex; width: 100%; }
.btn-lg { min-height: 60px; font-size: var(--fs-lg); }

button:disabled { opacity: .45; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--brand-primary); outline-offset: 2px; border-radius: var(--radius-sm); }

/* ═══ การ์ด ═══ */
.card {
  background: var(--surface);
  border: 1px solid var(--ink-50);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: var(--sp-4);
}
.card-header {
  padding: var(--sp-5) var(--sp-5) 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3);
}
.card-title { font-size: var(--fs-lg); font-weight: 600; }
.card-body { padding: var(--sp-5); }
.card-soft { background: var(--brand-soft); border-color: #CFE3FF; }

/* ═══ หัวหน้าเพจ ═══ */
.page-header { margin-bottom: var(--sp-6); }
.page-title { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -.01em; }
.page-subtitle { color: var(--ink-500); font-size: var(--fs-sm); margin-top: var(--sp-1); }

/* ═══ ฟอร์ม ═══ */
.form-field { margin-bottom: var(--sp-5); }
.form-field > label {
  display: block; margin-bottom: var(--sp-2);
  font-weight: 600; font-size: var(--fs-md);
}
.form-hint { color: var(--ink-500); font-size: var(--fs-sm); margin-top: var(--sp-1); }
/* ⚠️ ต้องระบุ type ให้ครบทุกชนิดที่ใช้จริง
   ถ้าลืมชนิดใด ช่องนั้นจะตกไปใช้สไตล์เริ่มต้นของเบราว์เซอร์
   ซึ่งเล็กกว่ามากจนดูเหมือนคนละระบบ (เคยพลาดกับ password มาแล้ว) */
input[type="text"], input[type="number"], input[type="email"], input[type="date"],
input[type="password"], input[type="tel"], input[type="search"], input[type="url"],
select, textarea {
  width: 100%; min-height: var(--tap-min);
  padding: var(--sp-3) var(--sp-4);
  font-family: inherit; font-size: var(--fs-md); color: var(--ink-900);
  background: var(--surface);
  border: 2px solid var(--ink-100); border-radius: var(--radius-md);
  transition: border-color .2s var(--ease);
}
input:focus, select:focus, textarea:focus { border-color: var(--brand-primary); outline: none; }

/* ช่องรหัสผ่านในบางเบราว์เซอร์ใช้ฟอนต์ระบบซึ่งเล็กกว่า ต้องบังคับให้เท่ากัน */
input[type="password"] {
  font-family: var(--font-body);
  letter-spacing: .08em;
}
input[type="password"]::placeholder { letter-spacing: normal; }
.form-row { display: grid; gap: var(--sp-4); grid-template-columns: 1fr 1fr; }
@media (max-width: 520px) { .form-row { grid-template-columns: 1fr; } }

/* ตัวเลือกแบบการ์ด (แตะง่ายกว่า radio) */
.choice-grid { display: grid; gap: var(--sp-3); }
.choice-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.choice {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: var(--tap-min); padding: var(--sp-3) var(--sp-4);
  background: var(--surface); border: 2px solid var(--ink-100);
  border-radius: var(--radius-md); cursor: pointer;
  font-size: var(--fs-md); font-weight: 500; text-align: left;
  transition: all .18s var(--ease);
}
.choice:hover { border-color: var(--ink-300); }
.choice[aria-pressed="true"] {
  border-color: var(--brand-primary); background: var(--brand-soft); font-weight: 600;
}
.choice[aria-pressed="true"]::before {
  content: "✓"; color: var(--brand-primary); font-weight: 700; font-size: 1.1em;
}

/* checkbox ยินยอม */
.consent-item {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-4); margin-bottom: var(--sp-3);
  border: 2px solid var(--ink-100); border-radius: var(--radius-md);
  cursor: pointer; transition: all .18s var(--ease);
}
.consent-item:hover { border-color: var(--ink-300); }
.consent-item.checked { border-color: var(--brand-primary); background: var(--brand-soft); }
.consent-item input[type="checkbox"] {
  width: 26px; height: 26px; margin: 2px 0 0; flex: none; accent-color: var(--brand-primary); cursor: pointer;
}
.consent-item span { font-size: var(--fs-sm); line-height: 1.6; }

/* ═══ ป้ายสถานะ ═══ */
.badge {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3); border-radius: var(--radius-full);
  font-size: var(--fs-xs); font-weight: 600;
}
.badge.ok   { background: var(--ok-soft);   color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad  { background: var(--bad-soft);  color: var(--bad); }
.badge.neutral { background: var(--ink-50); color: var(--ink-700); }

/* ═══ กล่องข้อความสำคัญ ═══ */
.notice {
  display: flex; gap: var(--sp-3);
  padding: var(--sp-4); border-radius: var(--radius-md);
  font-size: var(--fs-sm); line-height: 1.65;
  margin-bottom: var(--sp-4);
  border: 1px solid transparent;
}
.notice svg { flex: none; width: 22px; height: 22px; margin-top: 2px; }
.notice.info { background: var(--brand-soft); border-color: #CFE3FF; color: var(--ink-900); }
.notice.warn { background: var(--warn-soft); border-color: #F0DCB0; color: #6B4400; }
.notice.danger { background: var(--bad-soft); border-color: #F2C9C6; color: #7A1A14; }
.notice.muted { background: var(--bg-soft); border-color: var(--ink-50); color: var(--ink-500); }

/* ═══ ผลลัพธ์ ═══ */
.result-hero {
  text-align: center; padding: var(--sp-8) var(--sp-5);
  background: linear-gradient(160deg, #fff 0%, var(--brand-soft) 100%);
  border-radius: var(--radius-lg); border: 1px solid #CFE3FF;
  margin-bottom: var(--sp-5);
}
.result-label { font-size: var(--fs-sm); color: var(--ink-500); font-weight: 500; }
.result-age {
  font-family: var(--font-display); font-style: italic;
  font-size: var(--fs-3xl); font-weight: 600; line-height: 1.05;
  color: var(--brand-primary); margin: var(--sp-2) 0;
}
.result-delta { font-size: var(--fs-md); font-weight: 600; }
.result-delta.ok  { color: var(--ok); }
.result-delta.bad { color: var(--warn); }

.domain-row {
  display: grid; grid-template-columns: 1fr auto; gap: var(--sp-2) var(--sp-4);
  align-items: center; padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--ink-50);
}
.domain-row:last-child { border-bottom: none; }
.domain-name { font-weight: 600; font-size: var(--fs-md); }
.domain-meta { font-size: var(--fs-sm); color: var(--ink-500); }
.bar { grid-column: 1 / -1; height: 10px; border-radius: var(--radius-full); background: var(--ink-50); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: var(--radius-full); transition: width .6s var(--ease); }
.bar > i.ok   { background: var(--ok); }
.bar > i.warn { background: #D89A1E; }
.bar > i.bad  { background: var(--bad); }

/* ═══ Wizard ═══ */
.wizard-progress {
  display: flex; align-items: center; gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.wizard-progress .bar { flex: 1; grid-column: auto; height: 8px; }
.wizard-progress .bar > i { background: var(--brand-primary); }
.wizard-step-num { font-size: var(--fs-sm); color: var(--ink-500); font-weight: 600; white-space: nowrap; }

.timer-display {
  font-family: var(--font-display); font-style: italic;
  font-size: var(--fs-3xl); font-weight: 600; text-align: center;
  color: var(--brand-primary); line-height: 1; margin: var(--sp-4) 0;
  font-variant-numeric: tabular-nums;
}
.counter-display {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-5);
  margin: var(--sp-4) 0;
}
.counter-value {
  font-family: var(--font-display); font-style: italic;
  font-size: var(--fs-3xl); font-weight: 600; min-width: 90px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.counter-btn {
  width: 62px; height: 62px; border-radius: 50%;
  border: 2px solid var(--ink-100); background: var(--surface);
  font-size: var(--fs-xl); font-weight: 600; color: var(--ink-700); cursor: pointer;
}
.counter-btn:hover { border-color: var(--brand-primary); color: var(--brand-primary); }

.tap-target {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 190px; border-radius: var(--radius-lg);
  border: none; cursor: pointer; font-size: var(--fs-lg); font-weight: 600;
  background: var(--ink-50); color: var(--ink-500);
  transition: background .05s linear;
}
.tap-target.armed { background: var(--ink-700); color: #fff; }
.tap-target.go { background: var(--ok); color: #fff; }

.word-chip {
  display: inline-block; padding: var(--sp-2) var(--sp-5); margin: var(--sp-1);
  background: var(--brand-soft); border-radius: var(--radius-full);
  font-size: var(--fs-lg); font-weight: 600; color: var(--brand-dark);
}

/* ═══ กราฟแนวโน้ม ═══ */
.trend-wrap { position: relative; width: 100%; overflow-x: auto; }
.trend-svg { display: block; width: 100%; height: auto; min-width: 280px; }

/* ═══ รายการประวัติ ═══ */
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--ink-50);
  text-decoration: none; color: inherit;
  min-height: var(--tap-min);
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--bg-soft); }
.list-item-main { min-width: 0; }
.list-item-title { font-weight: 600; }
.list-item-sub { font-size: var(--fs-sm); color: var(--ink-500); }

/* ═══ Modal ═══ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,23,32,.5);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4);
  animation: fade .18s var(--ease);
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; max-height: 88dvh;
  display: flex; flex-direction: column;
  animation: rise .22s var(--ease);
}
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
.modal.large { max-width: 760px; }
/* Camera modal: เต็มจอแนวตั้งบนมือถือ เพื่อให้เห็นภาพใหญ่ชัด */
.modal.camera-modal {
  max-width: 520px;
  max-height: 96dvh;
  height: auto;
}
@media (max-width: 520px) {
  .modal-backdrop { padding: var(--sp-2); align-items: flex-end; }
  .modal.camera-modal {
    max-width: 100%;
    max-height: 96dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    height: auto;
  }
}
.modal-header { padding: var(--sp-5) var(--sp-5) var(--sp-3); font-size: var(--fs-lg); font-weight: 600; }
.modal.camera-modal .modal-header {
  padding: var(--sp-4) var(--sp-4) var(--sp-2);
  font-size: var(--fs-xl);
  font-weight: 700;
  text-align: center;
  flex-shrink: 0;
}
.modal-body { padding: 0 var(--sp-5) var(--sp-5); overflow-y: auto; }
.modal.camera-modal .modal-body {
  padding: 0 var(--sp-3) var(--sp-3);
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.modal-footer {
  padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--ink-50);
  display: flex; gap: var(--sp-3); justify-content: flex-end; flex-wrap: wrap;
  flex-shrink: 0;
}
.modal.camera-modal .modal-footer {
  padding: var(--sp-3) var(--sp-3) calc(var(--sp-3) + env(safe-area-inset-bottom, 0px));
  gap: var(--sp-2);
}
.modal.camera-modal .modal-footer > * {
  flex: 1 1 0;
  min-height: 56px;
  font-size: var(--fs-md);
  font-weight: 700;
  padding: 0 var(--sp-3);
}
.modal-footer > * { flex: 1 1 auto; }
@media (min-width: 520px) { .modal-footer > * { flex: 0 0 auto; } }

/* ═══ Toast ═══ */
.toast-mount {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--sp-4) + env(safe-area-inset-bottom));
  z-index: 150; display: flex; flex-direction: column; gap: var(--sp-2);
  width: min(92vw, 460px); pointer-events: none;
}
.toast {
  padding: var(--sp-4) var(--sp-5); border-radius: var(--radius-md);
  background: var(--ink-900); color: #fff; font-size: var(--fs-sm); font-weight: 500;
  box-shadow: var(--shadow-lg); animation: rise .22s var(--ease);
}
.toast.success { background: var(--ok); }
.toast.error   { background: var(--bad); }
.toast.warn    { background: var(--warn); }

/* ═══ หน้าขอความยินยอม ═══ */
.consent-screen {
  position: fixed; inset: 0; z-index: 180;
  background: var(--bg-soft); overflow-y: auto;
}
.consent-inner { max-width: 640px; margin: 0 auto; padding: var(--sp-8) var(--sp-4) var(--sp-12); }

/* ═══ Utility ═══ */
.stack > * + * { margin-top: var(--sp-4); }
.center { text-align: center; }
.muted { color: var(--ink-500); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.strong { font-weight: 600; }
.mt-2 { margin-top: var(--sp-2); } .mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); } .mt-8 { margin-top: var(--sp-8); }
.mb-0 { margin-bottom: 0; }
.row-gap { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.row-gap > * { flex: 1 1 160px; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--ink-50); margin: var(--sp-5) 0; }
.kv { display: flex; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-2) 0; font-size: var(--fs-sm); }
.kv > span:first-child { color: var(--ink-500); }
.kv > span:last-child { font-weight: 600; text-align: right; }

.prose h3 { font-size: var(--fs-lg); margin: var(--sp-6) 0 var(--sp-2); }
.prose h4 { font-size: var(--fs-md); margin: var(--sp-5) 0 var(--sp-2); }
.prose p, .prose li { font-size: var(--fs-sm); line-height: 1.75; }
.prose ul { padding-left: var(--sp-5); margin: 0 0 var(--sp-4); }
.prose table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); margin-bottom: var(--sp-4); }
.prose th, .prose td { padding: var(--sp-2) var(--sp-3); border: 1px solid var(--ink-100); text-align: left; }
.prose th { background: var(--bg-soft); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}


/* ═══ Phase 2–3 ═══ */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--ink-50);
}
.toggle-row:last-child { border-bottom: none; }
.switch { position: relative; width: 60px; height: 34px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--ink-300); border-radius: var(--radius-full);
  transition: background .2s var(--ease);
}
.switch span::before {
  content: ""; position: absolute; left: 4px; top: 4px;
  width: 26px; height: 26px; border-radius: 50%; background: #fff;
  transition: transform .2s var(--ease); box-shadow: var(--shadow-sm);
}
.switch input:checked + span { background: var(--brand-primary); }
.switch input:checked + span::before { transform: translateX(26px); }
.switch input:focus-visible + span { outline: 3px solid var(--brand-primary); outline-offset: 2px; }
.switch input:disabled + span { opacity: .45; cursor: not-allowed; }

.step-list { counter-reset: s; padding-left: 0; list-style: none; margin: 0; }
.step-list li {
  counter-increment: s; position: relative;
  padding: var(--sp-3) 0 var(--sp-3) 44px;
  font-size: var(--fs-sm); line-height: 1.65;
}
.step-list li::before {
  content: counter(s); position: absolute; left: 0; top: var(--sp-3);
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--fs-sm);
}

/* ═══════════════════════════════════════════════════════════
   Phase 4 — กล้อง · รายงานพิมพ์
   ═══════════════════════════════════════════════════════════ */

/* ── ตัวเลือกใช้กล้อง ── */
.camera-offer {
  padding: var(--sp-4);
  background: var(--bg-soft);
  border: 1px dashed var(--ink-100);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-5);
}

.cam-wrap {
  position: relative;
  width: 100%;
  flex: 0 0 auto;
  /* กรอบแนวตั้ง 3:4 บนมือถือ — สูงสุดไม่เกิน ~62vh */
  aspect-ratio: 3 / 4;
  max-height: 62vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink-900);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.cam-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--ink-900);
  /* cover = เต็มกรอบแนวตั้ง (ตัดซ้าย-ขวาถ้าสตรีมเป็น landscape) ไม่มีแถบดำ */
  object-fit: cover;
  object-position: center center;
  transform-origin: center center;
  transition: transform .15s var(--ease);
}
@media (min-width: 520px) {
  .cam-wrap {
    aspect-ratio: 4 / 3;
    max-height: 56vh;
  }
}
.cam-readout {
  position: absolute;
  left: 50%;
  bottom: var(--sp-4);
  transform: translateX(-50%);
  padding: var(--sp-3) var(--sp-6);
  background: rgba(15,23,32,.88);
  color: #fff;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-2xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  transition: transform .15s var(--ease), background .2s var(--ease);
  z-index: 2;
  min-width: 4.5em;
  text-align: center;
}
.cam-readout.pop { transform: translateX(-50%) scale(1.2); }
.cam-readout.poor { background: rgba(154,98,0,.95); }

/* ปุ่มซูม เข้า/ออก — มุมขวาบนของกล้อง */
.cam-zoom {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.cam-zoom button,
.cam-switch {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(15,23,32,.78);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  -webkit-tap-highlight-color: transparent;
}
.cam-zoom button:active,
.cam-switch:active { background: rgba(15,23,32,.95); transform: scale(0.94); }
.cam-zoom button:disabled,
.cam-switch:disabled { opacity: .35; cursor: not-allowed; }
.cam-zoom-label {
  position: absolute;
  top: var(--sp-3);
  left: var(--sp-3);
  z-index: 3;
  padding: 4px 10px;
  background: rgba(15,23,32,.7);
  color: #fff;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
/* ปุ่มสลับกล้องหน้า/หลัง — มุมซ้ายล่าง */
.cam-switch {
  position: absolute;
  bottom: var(--sp-4);
  left: var(--sp-3);
  z-index: 3;
  font-size: 1.35rem;
}

/* สถานะและคำแนะนำใต้กล้อง — ตัวอักษรใหญ่ชัด */
.modal.camera-modal .notice {
  font-size: var(--fs-md);
  padding: var(--sp-3) var(--sp-4);
  margin-top: var(--sp-3);
  line-height: 1.55;
}
.modal.camera-modal .notice + .notice { margin-top: var(--sp-2); }

/* ═══ รายงานสำหรับพิมพ์ ═══ */

.print-sheet {
  background: #fff;
  border: 1px solid var(--ink-100);
  border-radius: var(--radius-md);
  padding: var(--sp-6);
  margin-top: var(--sp-5);
  font-size: calc(0.9375rem * var(--font-scale));
  line-height: 1.6;
}

.rp-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--sp-4); padding-bottom: var(--sp-4);
  border-bottom: 2px solid var(--ink-900);
}
.rp-title { font-size: 1.25em; font-weight: 700; line-height: 1.3; }
.rp-sub { font-size: .82em; color: var(--ink-500); margin-top: 2px; }
.rp-brand {
  text-align: right; font-family: var(--font-display); font-style: italic;
  font-weight: 600; font-size: 1.15em; color: var(--brand-primary); white-space: nowrap;
}
.rp-brand span { font-family: var(--font-body); font-style: normal;
  font-size: .58em; color: var(--ink-300); font-weight: 400; }

.rp-block { margin-top: var(--sp-5); break-inside: avoid; }
.rp-h2 {
  font-size: 1em; font-weight: 700; margin-bottom: var(--sp-2);
  padding-bottom: 4px; border-bottom: 1px solid var(--ink-100);
}

.rp-kv { width: 100%; border-collapse: collapse; font-size: .9em; }
.rp-kv th {
  text-align: left; font-weight: 600; color: var(--ink-500);
  padding: 4px 10px 4px 0; white-space: nowrap; width: 1%;
}
.rp-kv td { padding: 4px 20px 4px 0; }

.rp-highlight {
  background: var(--bg-soft); border: 1px solid var(--ink-100);
  border-radius: var(--radius-sm); padding: var(--sp-4);
}
.rp-big { text-align: center; }
.rp-big-label { font-size: .85em; color: var(--ink-500); }
.rp-big-value { font-size: 2.4em; font-weight: 700; line-height: 1.1; color: var(--brand-dark); }
.rp-big-note { font-size: .9em; font-weight: 600; }

.rp-table { width: 100%; border-collapse: collapse; font-size: .87em; }
.rp-table th, .rp-table td {
  border: 1px solid var(--ink-100); padding: 6px 10px; text-align: left;
}
.rp-table th { background: var(--bg-soft); font-weight: 600; }

.rp-list { padding-left: 1.2em; margin: 0; }
.rp-list li { font-size: .88em; margin-bottom: 4px; }

.rp-note { font-size: .8em; color: var(--ink-500); margin: var(--sp-2) 0 0; line-height: 1.55; }

.rp-foot { margin-top: var(--sp-6); padding-top: var(--sp-4); border-top: 1px solid var(--ink-100); }
.rp-disclaim {
  font-size: .78em; line-height: 1.6; color: var(--ink-700);
  background: var(--warn-soft); border: 1px solid #F0DCB0;
  border-radius: var(--radius-sm); padding: var(--sp-3); margin: 0;
}
.rp-foot-meta {
  display: flex; flex-wrap: wrap; gap: var(--sp-4);
  font-size: .72em; color: var(--ink-300); margin-top: var(--sp-3);
}

/* ── โหมดพิมพ์ ── */
@media print {
  @page { size: A4; margin: 14mm 12mm; }

  body { background: #fff; font-size: 11pt; }
  .topbar, .tabbar, .no-print, #toast-mount, #modal-mount,
  #backbar-mount, .boot-screen, .consent-screen { display: none !important; }

  .shell { padding-bottom: 0; }
  .view { max-width: none; padding: 0; }

  .print-sheet {
    border: none; border-radius: 0; padding: 0; margin: 0;
    font-size: 10.5pt;
  }
  .rp-block { margin-top: 10mm; }
  .rp-highlight { background: #F6F8FA !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rp-table th { background: #F6F8FA !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rp-disclaim { background: #FDF2DC !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rp-foot { break-inside: avoid; }
  a[href]::after { content: none !important; }
}

/* ═══ แถบย้อนกลับสำหรับหน้าที่ไม่มีแท็บของตัวเอง ═══ */
#backbar-mount:empty { display: none; }
.backbar {
  max-width: 720px; margin: 0 auto;
  padding: var(--sp-4) var(--sp-4) 0;
}
@media (min-width: 900px) { .backbar { padding-top: var(--sp-6); } }
.backbar-btn {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  min-height: 44px; padding: 0 var(--sp-3) 0 var(--sp-2);
  margin-left: calc(var(--sp-2) * -1);
  font-size: var(--fs-md); font-weight: 600; color: var(--brand-dark);
}
.backbar-btn:hover { background: var(--brand-soft); }
.backbar-btn svg { flex: none; }
