/* =====================================================================
   style.css — หน้าตาแอปจอง
   อยากเปลี่ยนสี → แก้ในกล่อง :root ข้างล่างจุดเดียว
   ===================================================================== */
:root {
  --ink: #18181B;          /* ตัวหนังสือหลัก + ปุ่มที่เลือกแล้ว */
  --muted: #6B6B70;        /* ตัวหนังสือรอง */
  --faint: #A1A1A8;        /* วันที่กดไม่ได้ */
  --bg: #F4F4F5;           /* พื้นหลังหน้า */
  --card: #FFFFFF;         /* พื้นการ์ด */
  --raised: #EDEDF0;       /* พื้นปุ่มที่ยังไม่เลือก */
  --line: #DCDCE0;         /* เส้นขอบ */
  --green: #06C755;        /* เขียว LINE — ใช้กับปุ่มส่งเท่านั้น */
  --green-dark: #05A847;
  --warn-bg: #FFF5E0;      /* กล่องข้อความแนะนำ */
  --warn-ink: #8A5300;
  --err: #C62828;
  --radius: 16px;
  --font: "IBM Plex Sans Thai", "Sukhumvit Set", "Thonburi", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* ของที่สั่งซ่อน ต้องซ่อนจริงเสมอ */
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }

.mock-banner {
  background: #FFE9A8; color: #5C4300;
  font-size: 12.5px; text-align: center; padding: 6px 16px;
}

/* ---------- หัวหน้า ---------- */
.top { padding: 22px 16px 10px; }
.brand { font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.top h1 { font-size: 26px; line-height: 1.25; margin: 2px 0 4px; font-weight: 700; }
.lead { margin: 0; color: var(--muted); font-size: 14.5px; }

main { padding: 6px 12px 0; max-width: 520px; margin: 0 auto; }

/* ---------- การ์ดแต่ละขั้น ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.card h2 {
  font-size: 16px; font-weight: 600; margin: 0 0 12px;
  display: flex; align-items: center; gap: 8px;
}
.card h2 small { font-weight: 400; color: var(--muted); font-size: 13px; }
.card h2:not(:first-child) { margin-top: 18px; }
.num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); color: #fff;
  font-size: 12px; font-weight: 600;
  display: inline-grid; place-items: center; flex: none;
}
.empty { margin: 0; color: var(--faint); font-size: 14px; }
.note { margin: 10px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- 1 แพ็กเกจ ---------- */
.pkg-list { display: grid; gap: 8px; }
.pkg {
  text-align: left; width: 100%;
  border: 1.5px solid var(--line); background: var(--card);
  border-radius: 12px; padding: 12px 14px;
  display: grid; grid-template-columns: 34px 1fr auto; gap: 2px 10px; align-items: center;
}
.pkg .emo { grid-row: span 2; font-size: 24px; text-align: center; }
.pkg .name { font-weight: 600; line-height: 1.3; }
.pkg .name small { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.pkg .from { font-size: 13px; color: var(--muted); white-space: nowrap; grid-row: span 2; align-self: start; padding-top: 2px; }
.pkg .from b { color: var(--ink); font-size: 15px; }
.pkg .perks { grid-column: 2 / 4; font-size: 12.5px; color: var(--muted); line-height: 1.4; margin-top: 4px; }
.pkg[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

.link-btn {
  margin-top: 12px; background: none; border: 0; padding: 4px 0;
  font-size: 14px; color: var(--muted); text-align: left;
}
.link-btn b { color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 2 ชั่วโมง ---------- */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  border: 1.5px solid var(--line); background: var(--card);
  border-radius: 12px; padding: 10px 14px; min-width: 96px; text-align: left;
}
.pill .t { display: block; font-weight: 600; }
.pill .p { display: block; font-size: 13px; color: var(--muted); }
.pill[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.pill[aria-pressed="true"] .p { color: #D4D4D8; }

/* ---------- 4 สีฉาก ---------- */
/* แบบ cards: การ์ดมีรูป 3 คอลัมน์ */
.scene-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.scene-card {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 12px;
  padding: 4px 4px 6px; text-align: center; position: relative;
}
.scene-card img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 8px; background: var(--raised); border: 1px solid var(--line); }
.scene-card .nm { display: block; font-weight: 600; font-size: 13px; margin-top: 4px; line-height: 1.25; }
.scene-card .th { display: block; font-size: 11.5px; color: var(--muted); }
.scene-card[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.scene-card[aria-pressed="true"]::after {
  content: "✓"; position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 13px; line-height: 22px; font-weight: 700;
}
/* ป้าย "ค่าเริ่มต้น" บนสีปกติของสตู */
.def {
  display: inline-block; margin-top: 4px; padding: 1px 7px; border-radius: 999px;
  background: var(--warn-bg); color: var(--warn-ink); font-size: 11px; font-weight: 600;
}
.scene-card .def { position: absolute; left: 9px; top: 9px; margin: 0; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
/* แบบ dots: วงกลมสี 4 คอลัมน์ */
.scene-dots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 6px; }
.scene-dot { border: 0; background: none; padding: 0; text-align: center; }
.scene-dot .sw {
  display: block; width: 48px; height: 48px; margin: 0 auto; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
}
.scene-dot .nm { display: block; font-size: 12px; margin-top: 4px; line-height: 1.25; }
.scene-dot[aria-pressed="true"] .sw { box-shadow: 0 0 0 2.5px var(--card), 0 0 0 4.5px var(--ink); }
.scene-dot[aria-pressed="true"] .nm { font-weight: 700; }
/* ปุ่ม "ให้ทีมแนะนำ" */
.scene-team { margin-top: 10px; width: 100%; }

/* ---------- 3 จำนวนคน ---------- */
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1.5px solid var(--line); background: var(--card);
  font-size: 22px; line-height: 1;
}
.stepper button:disabled { color: var(--faint); background: var(--raised); border-color: var(--raised); }
.stepper output { font-size: 26px; font-weight: 700; min-width: 34px; text-align: center; }
.stepper .unit { color: var(--muted); }
.hint {
  margin: 10px 0 0; padding: 10px 12px; border-radius: 10px;
  background: var(--warn-bg); color: var(--warn-ink); font-size: 14px;
}

/* ---------- 4 ปฏิทิน ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-head button {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--raised); font-size: 20px;
}
.cal-head button:disabled { opacity: .35; }
#cal-title { font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow span { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-dow .tue { color: var(--faint); }
.day {
  aspect-ratio: 1 / 1; border: 0; border-radius: 10px; background: var(--raised);
  font-size: 15px; font-weight: 500; position: relative; padding: 0;
}
.day.off { background: transparent; color: var(--faint); font-weight: 400; }
.day.closed::after {
  content: "หยุด"; position: absolute; left: 0; right: 0; bottom: 2px;
  font-size: 9px; color: var(--faint);
}
.day.today { box-shadow: inset 0 0 0 1.5px var(--line); }
.day[aria-pressed="true"] { background: var(--ink); color: #fff; }
.day.blank { visibility: hidden; }

.times { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.times-label { font-weight: 600; font-size: 14.5px; margin-bottom: 8px; }
.time-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.time {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 9px 0; font-size: 14.5px; font-variant-numeric: tabular-nums;
}
.time[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- 5–7 ช่องกรอก ---------- */
.field { display: block; }
.field input, .field textarea {
  width: 100%; font: inherit; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--card);
  outline: none; resize: vertical;
}
.field input:focus, .field textarea:focus { border-color: var(--ink); }
.field input.bad { border-color: var(--err); }
.tag-line { display: inline-block; margin-top: 6px; font-size: 12px; color: var(--green-dark); }
.tag-line::before { content: "● "; }
.err { display: block; margin-top: 6px; font-size: 13px; color: var(--err); }

/* ---------- 8 สรุป ---------- */
.sum-rows { display: grid; gap: 6px; font-size: 14.5px; }
.sum-row { display: flex; justify-content: space-between; gap: 12px; }
.sum-row span:first-child { color: var(--muted); }
.sum-row span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.sum-rows hr { border: 0; border-top: 1px dashed var(--line); margin: 6px 0; width: 100%; }
.sum-total span:last-child { font-weight: 700; font-size: 17px; }
.sum-dep {
  margin-top: 8px; padding: 12px 14px; border-radius: 12px; background: var(--ink); color: #fff;
  display: flex; justify-content: space-between; align-items: baseline;
}
.sum-dep b { font-size: 22px; font-variant-numeric: tabular-nums; }
.missing { margin: 10px 0 0; font-size: 13px; color: var(--err); }
.missing:empty { display: none; }
.pay-note { margin: 12px 0 0; font-size: 13px; color: var(--muted); }

.spacer { height: 96px; }

/* ---------- แถบล่าง ---------- */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,.96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px;
}
.bar-sum { flex: 1; min-width: 0; }
.bar-total { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.bar-dep { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.send {
  border: 0; border-radius: 999px; padding: 13px 22px;
  background: var(--green); color: #fff; font-weight: 600; font-size: 16px; white-space: nowrap;
}
.send:disabled { background: var(--raised); color: var(--faint); }

/* ---------- หน้าต่างตัวอย่างข้อความ ---------- */
.sheet-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 10;
}
.sheet-bg[hidden] { display: none; }
.sheet {
  background: var(--card); width: 100%; max-width: 520px;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
}
.sheet-title { font-weight: 600; margin-bottom: 12px; }
.chat { background: #8CABD8; border-radius: 14px; padding: 14px; display: flex; justify-content: flex-end; }
.bubble {
  background: #A8E27A; color: #111; border-radius: 16px 4px 16px 16px;
  padding: 10px 12px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; max-width: 92%;
}
.sheet-msg { margin: 12px 0 0; font-size: 14px; color: var(--muted); }
.sheet-msg:empty { display: none; }
.sheet-msg.bad { color: var(--err); }
.primary {
  display: block; margin-top: 14px; width: 100%; padding: 13px; border-radius: 999px;
  border: 0; background: var(--green); color: #fff; font-weight: 600; font-size: 16px;
  text-align: center; text-decoration: none;
}
.primary:disabled, .primary.disabled { background: var(--raised); color: var(--faint); pointer-events: none; }
.ghost {
  display: block; margin-top: 10px; width: 100%; padding: 12px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--card); font-weight: 600;
}
.primary + .ghost, .ghost + .ghost { margin-top: 8px; }
