:root {
  --brown-900: #3f2c22;
  --brown-800: #4e3729;
  --brown-700: #6f4e37;
  --brown-600: #846247;
  --brown-500: #9b7653;
  --cream-100: #fbf7f0;
  --cream-200: #f4eadc;
  --cream-300: #ead8c2;
  --white: #ffffff;
  --ink: #3c332e;
  --muted: #7d7169;
  --danger: #b23a2f;
  --danger-soft: #fff0ed;
  --success: #48765d;
  --success-soft: #edf6f0;
  --warning: #9a6828;
  --warning-soft: #fff6e5;
  --shadow: 0 18px 50px rgba(73, 47, 30, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --transition: 260ms cubic-bezier(.2, .8, .2, 1);
}

* {
  box-sizing: border-box;
  font-family: 'Noto Sans Thai', Thonburi, Tahoma, 'Leelawadee UI', sans-serif;
}

/* แก้ไขการตรึงหน้าจอให้รองรับมือถือ 100% */
html,
body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--cream-100);
  margin: 0;
  color: var(--ink);
  font-family: 'Noto Sans Thai', Thonburi, Tahoma, 'Leelawadee UI', sans-serif;
  background: radial-gradient(circle at 20% 0%, rgba(234, 216, 194, 0.75), transparent 34%), linear-gradient(145deg, #fbf8f2 0%, #f5eadc 100%);
}

button,
input,
select,
textarea {
  font-family: 'Noto Sans Thai', Thonburi, Tahoma, 'Leelawadee UI', sans-serif;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.background-orb {
  position: fixed;
  z-index: 0;
  border-radius: 50%;
  filter: blur(2px);
  pointer-events: none;
}

.orb-one {
  width: 260px;
  height: 260px;
  top: -100px;
  right: -100px;
  background: rgba(155, 118, 83, 0.18);
}

.orb-two {
  width: 220px;
  height: 220px;
  bottom: -90px;
  left: -100px;
  background: rgba(111, 78, 55, 0.10);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 960px);
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.brand-small {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--brown-800);
  font-size: 0.85rem;
  font-weight: 600;
}

.mini-logo {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--white);
  border: 1px solid rgba(111, 78, 55, 0.2);
  flex-shrink: 0;
}

.step-counter {
  color: var(--muted);
  font-size: 0.82rem;
}

.progress-track {
  width: 100%;
  height: 5px;
  margin-bottom: 20px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(111, 78, 55, 0.10);
  flex-shrink: 0;
}

.progress-value {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brown-700), var(--brown-500));
  transition: width 450ms cubic-bezier(.2, .8, .2, 1);
}

.fullscreen-mode .topbar,
.fullscreen-mode .progress-track {
  display: none !important;
}

/* จัดการหน้าย่อยและแก้ปัญหาปุ่มล้นจอ */
.screen {
  display: none;
  animation: screenIn 420ms var(--transition) both;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.screen.active {
  display: flex;
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.99);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.hero-card,
.content-card,
.thankyou-card {
  border: 1px solid rgba(111, 78, 55, 0.10);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.hero-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 32px 24px 28px;
  text-align: center;
}

.hero-center-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  margin: auto 0;
}

.content-card {
  padding: 24px 18px 28px;
}

.thankyou-card {
  justify-content: center;
  align-items: center;
  padding: 36px 22px;
  text-align: center;
}

.logo-wrap {
  display: grid;
  place-items: center;
  width: 116px;
  height: 116px;
  margin-bottom: 22px;
  border: 1px solid rgba(111, 78, 55, 0.15);
  border-radius: 50%;
  background: linear-gradient(145deg, var(--white), var(--cream-200));
  box-shadow: 0 14px 30px rgba(70, 45, 28, 0.12);
  flex-shrink: 0;
}

.logo-fallback {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  color: var(--white);
  background: linear-gradient(145deg, var(--brown-600), var(--brown-800));
  font-size: 1.35rem;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brown-500);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-align: center;
  width: 100%;
  flex-shrink: 0;
}

.section-heading .eyebrow {
  text-align: left;
  margin-top: 2px;
  margin-bottom: 0;
  word-break: break-word;
  overflow-wrap: break-word;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 640px;
  margin-bottom: 14px;
  color: var(--brown-900);
  font-size: clamp(2rem, 7vw, 3.6rem);
  line-height: 1.18;
}

h2 {
  margin-bottom: 8px;
  color: var(--brown-900);
  font-size: clamp(1.55rem, 5vw, 2.25rem);
  line-height: 1.25;
}

.section-heading h2 {
  margin-bottom: 2px;
  line-height: 1.2;
}

.hero-description {
  max-width: 590px;
  margin-bottom: 30px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.85;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 26px;
  flex-shrink: 0;
}

.section-heading p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.7;
}

.section-number {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--white);
  background: var(--brown-700);
  font-size: 0.82rem;
  font-weight: 700;
}

.field-grid {
  display: grid;
  gap: 16px;
}

.field-grid.two-columns {
  grid-template-columns: 1.6fr 1fr;
}

@media (max-width: 480px) {
  .field-grid.two-columns {
    grid-template-columns: 1.5fr 1fr;
    gap: 12px;
  }
}

.field-group {
  display: block;
  margin-bottom: 18px;
}

.field-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 9px;
}

.field-header .field-label {
  margin-bottom: 0;
}

.field-label,
.choice-field legend {
  display: block;
  margin-bottom: 9px;
  color: var(--brown-800);
  font-size: 0.96rem;
  font-weight: 600;
}

.field-label b,
.choice-field legend b {
  color: var(--danger);
}

.error-text {
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 600;
}

input[type="text"],
input[type="number"],
input[type="email"] {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid #ded2c5;
  border-radius: var(--radius-md);
  outline: none;
  font-size: 1rem;
  color: var(--ink);
  background: #fffdfa;
  transition: border-color var(--transition);
}

input::placeholder {
  color: #a39587;
  font-size: 0.95rem;
  opacity: 1;
}

input:focus {
  border-color: var(--brown-600);
  box-shadow: 0 0 0 4px rgba(111, 78, 55, 0.10);
}

input.input-error {
  border-color: var(--danger) !important;
  background: var(--danger-soft) !important;
}

.choice-field {
  min-width: 0;
  margin: 0 0 22px;
  padding: 0;
  border: 0;
  flex-shrink: 0;
}

.segmented-control {
  display: grid;
  gap: 10px;
}

.three-options {
  grid-template-columns: repeat(3, 1fr);
}

.four-options {
  grid-template-columns: repeat(2, 1fr);
}

.choice-button {
  min-height: 50px;
  padding: 10px 8px;
  border: 1px solid #ded2c5;
  border-radius: 12px;
  color: var(--brown-800);
  background: #fffdfa;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.choice-button.selected {
  border-color: var(--brown-700);
  color: var(--white);
  background: var(--brown-700);
  box-shadow: 0 8px 18px rgba(111, 78, 55, 0.18);
}

.other-input-wrap {
  margin-top: 12px;
  animation: fadeInOtherField 240ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes fadeInOtherField {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.btn {
  position: relative;
  z-index: 50;
  min-height: 54px;
  padding: 12px 24px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}

.btn-primary {
  color: var(--white);
  background: linear-gradient(145deg, var(--brown-600), var(--brown-800));
  box-shadow: 0 12px 24px rgba(86, 58, 40, 0.22);
}

.btn-secondary {
  color: var(--brown-800);
  border-color: #d8cbbb;
  background: var(--white);
}

.btn-outline {
  color: var(--brown-700);
  border: 1.5px solid #cbbeaf;
  background: transparent;
  box-shadow: none;
}

.btn-outline:hover {
  border-color: var(--brown-600);
  background: rgba(111, 78, 55, 0.06);
  color: var(--brown-900);
}

.btn-large {
  min-width: 200px;
  font-size: 1.05rem;
  padding: 14px 28px;
}

.btn-full {
  width: 100%;
  flex-shrink: 0;
}

.btn:disabled,
.btn-primary:disabled {
  background: #cfc5b8 !important;
  color: #7d7268 !important;
  box-shadow: none !important;
  cursor: not-allowed !important;
  opacity: 0.8 !important;
  transform: none !important;
}

.mt-auto {
  margin-top: auto;
}

.text-button {
  display: block;
  margin: 12px auto 0;
  padding: 6px 14px;
  border: 0;
  color: var(--brown-600);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 0.9rem;
  transition: color var(--transition);
}

.text-button.no-underline {
  text-decoration: none !important;
}

.text-button.no-underline:hover {
  text-decoration: none !important;
  color: var(--brown-800);
}

.text-button+.text-button {
  margin-top: 4px;
}

/* ==========================================
   Expandable Scroll-Box Component
   ========================================== */
.scroll-box-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  margin-bottom: 16px;
  position: relative;
  box-sizing: border-box;
}

/* Placeholder รักษากล่องข้อความในหน้าเดิมตลอดเวลา ไม่ให้วาบหาย */
.scroll-box-placeholder {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 140px;
  width: 100%;
  max-width: 100%;
  margin-bottom: 16px;
  position: relative;
  box-sizing: border-box;
  pointer-events: none;
}

.scroll-box-placeholder .scroll-box {
  pointer-events: none;
  user-select: none;
  scroll-behavior: auto !important;
}

.scroll-box-content-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  position: relative;
  box-sizing: border-box;
}

.expanded-sticky-header {
  display: none;
}

.expanded-bottom-action {
  display: none;
}

/* ไอคอนขยายขนาดเล็กมุมบนขวา ไม่รบกวนข้อความ (ลอยอยู่หน้าสุดเสมอ) */
.expand-icon-indicator {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 30;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.9);
  border: 1.5px solid rgba(111, 78, 55, 0.25);
  display: grid;
  place-items: center;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(73, 47, 30, 0.12);
  backdrop-filter: blur(4px);
  transition: all 200ms ease;
}

.expand-icon-indicator svg {
  stroke: var(--brown-700);
  transition: stroke var(--transition);
}

.expand-icon-indicator:hover,
.scroll-box-container:hover .expand-icon-indicator:hover {
  background: var(--brown-700);
  border-color: var(--brown-700);
  transform: scale(1.08);
}

.expand-icon-indicator:hover svg,
.scroll-box-container:hover .expand-icon-indicator:hover svg {
  stroke: var(--white);
}

.scroll-box-container.is-expanded .expand-icon-indicator {
  display: none !important;
}

/* ป้ายบอกให้เลื่อนลงอ่านก่อน (ลอยอยู่หน้าสุดเสมอ) */
.scroll-bottom-prompt {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(63, 44, 34, 0.92);
  color: var(--white);
  font-size: 0.76rem;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  transition: opacity 300ms ease, transform 300ms ease;
  white-space: nowrap;
  backdrop-filter: blur(4px);
}

.scroll-bottom-prompt.hidden-fade {
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
}

.scroll-box-container.is-expanded .scroll-bottom-prompt {
  display: none !important;
}

.scroll-box {
  flex: 1;
  min-height: 140px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 16px 24px;
  border: 1.5px solid #e5d8c8;
  border-radius: 14px;
  background: #fffdfa;
  font-size: 0.9rem;
  line-height: 1.68;
  color: var(--ink);
  -webkit-overflow-scrolling: touch;
  scroll-behavior: auto;
  cursor: pointer;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  word-break: break-word;
  overflow-wrap: break-word;
  transition: border-color 200ms ease, box-shadow 200ms ease, background-color 200ms ease;
  position: relative;
}

.scroll-box:hover {
  border-color: var(--brown-600);
  background-color: #fffcf7;
  box-shadow: 0 4px 16px rgba(73, 47, 30, 0.08);
}

.scroll-box h1,
.scroll-box h2,
.scroll-box h3,
.scroll-box p,
.scroll-box ul,
.scroll-box ol,
.scroll-box li,
.scroll-box span,
.scroll-box div {
  max-width: 100%;
  box-sizing: border-box;
  word-break: break-word;
  overflow-wrap: break-word;
}

.scroll-box h3 {
  color: var(--brown-900);
  font-size: 1rem;
  margin-top: 18px;
  margin-bottom: 8px;
  line-height: 1.4;
}

.scroll-box h3:first-child {
  margin-top: 0;
}

.scroll-box p {
  margin-bottom: 12px;
  text-align: left;
  line-height: 1.65;
}

.scroll-box ul,
.scroll-box ol {
  padding-left: 20px;
  margin-left: 0;
  margin-bottom: 14px;
}

.scroll-box li {
  margin-bottom: 6px;
  text-align: left;
  line-height: 1.65;
}

.scroll-box table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  margin: 12px 0 16px;
  background: #fbf7f0;
  border-radius: 10px;
  overflow: hidden;
  font-size: 0.86rem;
  border: 1px solid #e7dacb;
  word-break: break-word;
  overflow-wrap: break-word;
  box-sizing: border-box;
}

.scroll-box th,
.scroll-box td {
  padding: 9px 12px;
  border-bottom: 1px solid #ede3d7;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: break-word;
}

.scroll-box tr:last-child td {
  border-bottom: none;
}

.scroll-box td:first-child {
  width: 36%;
  color: var(--brown-800);
  background: rgba(111, 78, 55, 0.05);
  font-weight: 600;
}

.scroll-box td:last-child {
  width: 64%;
}

.scroll-box a {
  color: var(--brown-700);
  text-decoration: underline;
  text-underline-offset: 3px;
  word-break: break-all;
}

/* Custom Scrollbar for scroll-box */
.scroll-box::-webkit-scrollbar {
  width: 6px;
}

.scroll-box::-webkit-scrollbar-track {
  background: rgba(111, 78, 55, 0.05);
  border-radius: 8px;
}

.scroll-box::-webkit-scrollbar-thumb {
  background: rgba(111, 78, 55, 0.25);
  border-radius: 8px;
}

.scroll-box::-webkit-scrollbar-thumb:hover {
  background: rgba(111, 78, 55, 0.45);
}

/* ------------------------------------------
   Expanded Fullscreen Modal State & Scroll Lock
   ------------------------------------------ */
/* ล็อค Scroll ของพื้นหลังเพื่อไม่ให้เกิด Scrollbar ซ้อน 2 อัน */
body.scroll-box-expanded-active {
  overflow: hidden !important;
}

body.scroll-box-expanded-active .app-shell,
body.scroll-box-expanded-active .content-card,
body.scroll-box-expanded-active .screen {
  overflow: hidden !important;
}

.scroll-box-container.is-expanded {
  position: fixed;
  inset: 0;
  z-index: 99999;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)) 16px;
  background: rgba(35, 23, 16, 0.65);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: expandFadeIn 380ms cubic-bezier(0.16, 1, 0.3, 1) both;
  box-sizing: border-box;
  will-change: opacity, backdrop-filter;
}

.scroll-box-container.is-expanded .scroll-box-content-wrapper {
  width: min(100%, 860px);
  height: 100%;
  max-height: 100%;
  background: #ffffff;
  border-radius: var(--radius-xl);
  box-shadow: 0 28px 70px rgba(35, 20, 10, 0.4);
  border: 1px solid rgba(111, 78, 55, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: expandScaleIn 380ms cubic-bezier(0.16, 1, 0.3, 1) both;
  will-change: transform, opacity;
}

.scroll-box-container.is-expanded .expanded-sticky-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: #fffdfa;
  border-bottom: 1px solid rgba(111, 78, 55, 0.12);
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

.expanded-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.expanded-title-wrap>div {
  min-width: 0;
  flex: 1;
}

.section-number.small {
  width: 36px;
  height: 36px;
  font-size: 0.76rem;
  flex-shrink: 0;
}

.expanded-sticky-header h3 {
  margin: 0;
  color: var(--brown-900);
  font-size: 1.12rem;
  line-height: 1.25;
  word-break: break-word;
  overflow-wrap: break-word;
}

.expanded-sticky-header .eyebrow {
  margin: 0;
  text-align: left;
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  word-break: break-word;
  overflow-wrap: break-word;
}

.btn-close-expanded {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid #d8c8b6;
  background: var(--cream-200);
  color: var(--brown-800);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 180ms ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-close-expanded:hover {
  background: var(--cream-300);
  color: var(--brown-900);
  transform: translateY(-1px);
}

.btn-close-expanded:active {
  transform: translateY(0);
}

.scroll-box-container.is-expanded .scroll-box {
  flex: 1 1 0%;
  min-height: 0;
  height: auto;
  overflow-y: auto !important;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior-y: contain;
  padding: 24px 22px max(80px, calc(50px + env(safe-area-inset-bottom)));
  font-size: 0.98rem;
  line-height: 1.78;
  border: none;
  border-radius: 0;
  background: #ffffff;
  margin-bottom: 0;
  cursor: default;
  box-shadow: none;
  box-sizing: border-box;
}

.scroll-box-container.is-expanded .tap-to-expand-badge {
  display: none !important;
}

.scroll-box-container.is-expanded .scroll-box h3 {
  font-size: 1.1rem;
  margin-top: 24px;
}

.scroll-box-container.is-expanded .scroll-box table {
  font-size: 0.92rem;
  margin: 16px 0 20px;
}

.scroll-box-container.is-expanded .scroll-box td {
  padding: 11px 16px;
}

.scroll-box-container.is-expanded .expanded-bottom-action {
  display: block;
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px dashed #e2d4c5;
  text-align: center;
}

.scroll-box-container.is-expanded .expanded-bottom-action .btn {
  max-width: 320px;
  margin: 0 auto;
}

/* Animation ปิดหน้าต่างขยาย (Collapse Out + Scale Down) */
.scroll-box-container.is-expanded.is-closing {
  animation: expandFadeOut 340ms cubic-bezier(0.25, 1, 0.5, 1) both;
  pointer-events: none;
}

.scroll-box-container.is-expanded.is-closing .scroll-box-content-wrapper {
  animation: expandScaleOut 340ms cubic-bezier(0.25, 1, 0.5, 1) both;
}

@keyframes expandFadeIn {
  0% {
    opacity: 0;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
  }
  100% {
    opacity: 1;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
}

@keyframes expandScaleIn {
  0% {
    opacity: 0;
    transform: scale(0.92) translateY(26px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes expandFadeOut {
  0% {
    opacity: 1;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
  100% {
    opacity: 0;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
  }
}

@keyframes expandScaleOut {
  0% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  100% {
    opacity: 0;
    transform: scale(0.92) translateY(24px);
  }
}

/* Mobile full-bleed for expanded mode & responsive table */
@media (max-width: 600px) {
  .scroll-box-container.is-expanded {
    padding: 0;
  }

  .scroll-box-container.is-expanded .scroll-box-content-wrapper {
    border-radius: 0;
    border: none;
    height: 100dvh;
    max-height: 100dvh;
  }

  .scroll-box-container.is-expanded .expanded-sticky-header {
    padding: max(14px, env(safe-area-inset-top)) 16px 14px;
  }

  .scroll-box-container.is-expanded .scroll-box {
    padding: 18px 16px max(24px, env(safe-area-inset-bottom));
  }

  .scroll-box table,
  .scroll-box tbody,
  .scroll-box tr,
  .scroll-box td {
    display: block;
    width: 100% !important;
    max-width: 100%;
  }

  .scroll-box tr {
    border-bottom: 1px solid #ede3d7;
    padding: 6px 0;
  }

  .scroll-box tr:last-child {
    border-bottom: none;
  }

  .scroll-box td {
    padding: 4px 10px;
    border-bottom: none;
  }

  .scroll-box td:first-child {
    background: transparent;
    padding-bottom: 0;
    color: var(--brown-700);
    font-size: 0.84rem;
  }

  .scroll-box td:last-child {
    padding-top: 2px;
  }
}

/* ส่วนการให้ความยินยอมและการกดยืนยันด้านล่างของข้อความ */
.consent-agreement-section {
  margin-top: 50px;
  padding-top: 18px;
  border-top: 1.5px dashed #e2d4c5;
}

.consent-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.consent-divider span {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--brown-700);
  background: var(--cream-200);
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid rgba(111, 78, 55, 0.15);
}

.consent-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  width: 100%;
}

.confirm-check {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: start;
  gap: 12px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid #e7dacb;
  border-radius: 14px;
  background: #fffdfa;
  color: var(--brown-800);
  font-size: 0.96rem;
  line-height: 1.55;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 180ms ease;
  position: relative;
  z-index: 2;
  box-sizing: border-box;
  box-shadow: 0 2px 6px rgba(73, 47, 30, 0.03);
}

.confirm-check:hover {
  border-color: var(--brown-600);
  background: #fbf6ef;
}

.confirm-check:has(input:checked) {
  border-color: var(--brown-700);
  background: #fcf7f1;
  box-shadow: 0 3px 10px rgba(111, 78, 55, 0.08);
}

.confirm-check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.custom-checkbox {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border: 1.5px solid #c7b7a7;
  border-radius: 6px;
  background: var(--white);
  transition: var(--transition);
  flex-shrink: 0;
}

.confirm-check input:checked+.custom-checkbox {
  border-color: var(--brown-700);
  background: var(--brown-700);
}

.confirm-check input:checked+.custom-checkbox::after {
  content: "✓";
  color: var(--white);
  font-size: 0.8rem;
  font-weight: 700;
}

.instruction-panel {
  display: grid;
  gap: 13px;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.instruction-item {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 13px;
  padding: 16px;
  border: 1px solid #e5d8c8;
  border-radius: 16px;
  background: linear-gradient(145deg, #fffdfa, #faf3e9);
}

.instruction-icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  color: var(--brown-800);
  background: var(--cream-300);
  font-size: 1.15rem;
}

.instruction-icon img {
  width: 45px;
  height: 45px;
  object-fit: contain;
}

.instruction-item h3 {
  margin-bottom: 5px;
  font-size: 1rem;
}

.instruction-item p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.65;
}

/* กล้องถ่ายภาพ */
#page6 .content-card {
  padding: 15px;
}

/* เมื่อถ่ายภาพครบ 3 รูปแล้ว (สถานะสแกนสำเร็จ) ให้แสดงเนื้อหาทั้งหมดอยู่กึ่งกลาง */
#page6.scan-complete .content-card,
#page6:has(#analyzeWrapper:not(.hidden)) .content-card {
  justify-content: center;
  align-items: center;
  padding: 28px 20px;
}

#page6.scan-complete .content-card > *,
#page6:has(#analyzeWrapper:not(.hidden)) .content-card > * {
  max-width: 480px;
  width: 100%;
}

.camera-stage {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 40vh;
  overflow: hidden;
  border: 2px solid var(--cream-300);
  border-radius: 24px;
  background: #000;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  position: absolute;
  top: 0;
  left: 0;
}

canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
}

.face-guide {
  position: absolute;
  z-index: 20;
  top: 5%;
  left: 50%;
  width: 78%;
  height: 88%;
  border: 3px solid var(--danger);
  border-radius: 45% 45% 42% 42% / 48% 48% 44% 44%;
  transform: translateX(-50%);
  box-shadow: 0 0 0 999px rgba(30, 24, 20, 0.6);
  transition: border-color 180ms ease;
  pointer-events: none;
}

.face-guide.valid {
  border-color: #67c184;
}

.face-guide.warning {
  border-color: var(--warning);
}

.camera-status {
  display: grid;
  gap: 7px;
  margin: 10px 0;
  z-index: 30;
  flex-shrink: 0;
}

.status-line {
  padding: 10px 12px;
  border-radius: 11px;
  font-size: 0.84rem;
  line-height: 1.45;
  text-align: center;
  transition: 0.3s;
}

.status-line.neutral {
  color: var(--muted);
  background: var(--cream-100);
}

.status-line.good {
  color: var(--success);
  background: var(--success-soft);
}

.status-line.bad {
  color: var(--danger);
  background: var(--danger-soft);
  font-weight: 600;
}

.status-line.warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.shutter-btn-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 10px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.capture-btn {
  width: 70px;
  height: 70px;
  background: var(--brown-700);
  border: 4px solid var(--white);
  border-radius: 50%;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: 0.3s;
}

.capture-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.capture-btn:not(:disabled):active {
  transform: scale(0.9);
}

.photo-thumbnails {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
  flex-shrink: 0;
}

.photo-card {
  position: relative;
  overflow: hidden;
  height: 80px;
  border: 1px dashed #cdbdad;
  border-radius: 13px;
  background: var(--cream-100);
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-card-label {
  position: absolute;
  bottom: 5px;
  width: 80%;
  padding: 3px;
  border-radius: 5px;
  color: var(--white);
  background: rgba(50, 36, 27, 0.8);
  font-size: 0.65rem;
  text-align: center;
}

.success-mark {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  margin-bottom: 22px;
  border-radius: 50%;
  color: var(--white);
  background: var(--success);
  font-size: 2.25rem;
  transition: 0.3s;
}

.shop-links {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
  margin-top: 20px;
}

.shop-link {
  padding: 12px 10px;
  border: 1px solid #ddcfbf;
  border-radius: 12px;
  color: var(--brown-800);
  background: var(--white);
  text-decoration: none;
  transition: 0.3s;
}

/* แสง Flash */
.screen-flash {
  position: fixed;
  z-index: 99999;
  inset: 0;
  opacity: 0;
  background: #FFF5EC;
  pointer-events: none;
}

.screen-flash.active {
  animation: screenFlashAnim 400ms ease-out both;
}

@keyframes screenFlashAnim {
  0% {
    opacity: 0;
  }

  20% {
    opacity: 0.95;
  }

  100% {
    opacity: 0;
  }
}

/* SweetAlert2 Theme */
.earth-swal {
  border-radius: 24px !important;
  font-family: 'Noto Sans Thai', Thonburi, Tahoma, 'Leelawadee UI', sans-serif !important;
  padding: 1.5em !important;
  box-shadow: 0 18px 50px rgba(73, 47, 30, 0.15) !important;
}

.earth-swal * {
  font-family: 'Noto Sans Thai', Thonburi, Tahoma, 'Leelawadee UI', sans-serif !important;
}

.earth-swal .swal2-title {
  color: #3f2c22 !important;
  font-size: 1.5rem !important;
}

.earth-swal .swal2-html-container {
  color: #7d7169 !important;
}

.earth-swal .swal2-confirm {
  border-radius: 14px !important;
  font-weight: 600 !important;
}

/* แอนิเมชันหันหน้า (ปรับแต่งแล้ว) */
.scene {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  perspective: 500px;
  z-index: 25;
  pointer-events: none;
  opacity: 0.6;
}

.head {
  width: 160px;
  height: 210px;
  border: 2px solid #fff;
  border-radius: 80px 80px 95px 95px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.face {
  width: 100%;
  height: 100%;
  position: relative;
}

.anim-eyebrow {
  width: 35px;
  height: 12px;
  border-top: 2px solid #fff;
  border-radius: 50%;
  position: absolute;
  top: 50px;
}

.anim-eyebrow.left {
  left: 25px;
  transform: rotate(10deg);
}

.anim-eyebrow.right {
  right: 25px;
  transform: rotate(-10deg);
}

.eye {
  width: 30px;
  height: 23px;
  border: 1.5px solid #fff;
  border-radius: 50%;
  position: absolute;
  top: 65px;
  overflow: hidden;
}

.eye.left {
  left: 28px;
}

.eye.right {
  right: 28px;
}

.nose {
  width: 10px;
  height: 28px;
  border: 2px solid #fff;
  border-bottom: none;
  border-radius: 5px;
  position: absolute;
  top: 92px;
  left: calc(50% - 5px);
}

.mouth {
  width: 40px;
  height: 10px;
  border-bottom: 2px solid #fff;
  border-radius: 0 0 20px 20px;
  position: absolute;
  bottom: 45px;
  left: calc(50% - 20px);
}

@keyframes turnHeadLeft {

  0%,
  100% {
    transform: rotateY(0deg);
  }

  50% {
    transform: rotateY(-50deg);
  }
}

@keyframes shiftFeaturesLeft {

  0%,
  100% {
    transform: translateX(0px);
  }

  50% {
    transform: translateX(-10px);
  }
}

@keyframes turnHeadRight {

  0%,
  100% {
    transform: rotateY(0deg);
  }

  50% {
    transform: rotateY(50deg);
  }
}

@keyframes shiftFeaturesRight {

  0%,
  100% {
    transform: translateX(0px);
  }

  50% {
    transform: translateX(10px);
  }
}