:root {
  --brand: #0e5a52;
  --brand-2: #127a6f;
  --brand-soft: #e7f2ef;
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #15211f;
  --ink-2: #47524f;
  --muted: #8a9491;
  --line: #e6e3dc;
  --danger: #c0352b;
  --line-green: #06c755;
  --r: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 22, .06), 0 8px 24px rgba(16, 24, 22, .06);
  --safe: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Sukhumvit Set", "Noto Sans Thai", "Segoe UI", sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.top { position: sticky; top: 0; z-index: 20; background: rgba(246, 245, 241, .92); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); }
.top-in { max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 12px 16px 8px; min-height: 56px; }
.brand { flex: 1; min-width: 0; }
.brand-name { font-weight: 700; letter-spacing: .02em; color: var(--brand); font-size: 17px; line-height: 1.2; }
.brand-sub { font-size: 13px; color: var(--muted); }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--ink); flex: none; }
.pill-btn { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 600; color: var(--brand); flex: none; }
.steps { max-width: 560px; margin: 0 auto; padding: 0 16px 10px; display: flex; gap: 6px; }
.steps i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); transition: background .3s; }
.steps i.on { background: var(--brand); }

/* ---------- layout ---------- */
.view { max-width: 560px; margin: 0 auto; padding: 6px 16px calc(120px + var(--safe)); animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
h1.title { font-size: 26px; line-height: 1.25; margin: 10px 0 4px; letter-spacing: -.01em; }
.lead { color: var(--ink-2); margin: 0 0 18px; }
.sec { margin: 22px 0 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.sec h2 { font-size: 17px; margin: 0; }
.sec small { color: var(--muted); font-size: 13px; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; }

/* segmented control (length) */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: #ebe8e1; border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 10px 4px; font-weight: 600; font-size: 15px; color: var(--ink-2); transition: background .2s, color .2s; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* therapist avatars */
.people { display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 8px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.people::-webkit-scrollbar, .days::-webkit-scrollbar { display: none; }
.person { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 68px; flex: none; padding: 0; }
.ava { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 20px; color: #fff; background: var(--c, var(--brand-2)); box-shadow: 0 0 0 3px var(--bg), 0 0 0 3px transparent; transition: box-shadow .2s, transform .15s; }
.person .nm { font-size: 13px; color: var(--ink-2); max-width: 68px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person.on .ava { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--brand); }
.person.on .nm { color: var(--ink); font-weight: 600; }
.person:active .ava { transform: scale(.94); }
.ava.any { background: linear-gradient(135deg, var(--brand), #3aa695); font-size: 22px; }

/* date strip */
.monthrow { display: flex; align-items: center; justify-content: space-between; }
.days { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 10px; margin: 0 -16px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.day { flex: none; width: 58px; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 8px 0 7px; text-align: center; scroll-snap-align: start; transition: background .2s, border-color .2s, color .2s; }
.day .dw { font-size: 12px; color: var(--muted); }
.day .dn { font-size: 20px; font-weight: 700; line-height: 1.25; }
.day .dot { display: block; width: 5px; height: 5px; border-radius: 50%; background: var(--brand-2); margin: 3px auto 0; }
.day.off { opacity: .38; background: transparent; }
.day.off .dot { visibility: hidden; }
.day.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.day.on .dw { color: rgba(255, 255, 255, .8); }
.day.on .dot { background: #fff; }

/* time slots */
.part { margin: 16px 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.slot { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 0; font-weight: 600; font-size: 15px; transition: background .15s, border-color .15s, color .15s, transform .1s; }
.slot:active { transform: scale(.96); }
.slot.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.empty { text-align: center; color: var(--ink-2); padding: 26px 12px; }
.empty .big { font-size: 34px; }
.skel { height: 44px; border-radius: 12px; background: linear-gradient(90deg, #ece9e2 25%, #f4f2ed 50%, #ece9e2 75%); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* summary / ticket */
.ticket { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.ticket-head { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; padding: 16px; }
.ticket-head .k { font-size: 13px; opacity: .85; }
.ticket-head .v { font-size: 22px; font-weight: 700; line-height: 1.3; }
.ticket-body { padding: 4px 16px; }
.trow { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.trow:last-child { border-bottom: 0; }
.trow .ic { width: 36px; height: 36px; border-radius: 10px; background: var(--brand-soft); display: grid; place-items: center; flex: none; font-size: 18px; }
.trow .k { font-size: 12px; color: var(--muted); }
.trow .v { font-weight: 600; }
.chg { margin-left: auto; border: 0; background: none; color: var(--brand); font-weight: 600; font-size: 14px; padding: 6px; }

/* form */
.fld { display: block; margin: 14px 0; }
.fld .lb { font-size: 14px; font-weight: 600; margin-bottom: 6px; display: block; }
.fld .lb small { font-weight: 400; color: var(--muted); }
.fld input, .fld textarea { width: 100%; border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; padding: 14px; font: inherit; font-size: 17px; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.fld textarea { font-size: 16px; resize: none; }
.fld input:focus, .fld textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(14, 90, 82, .12); }
.fld.bad input { border-color: var(--danger); }
.hint { font-size: 13px; color: var(--danger); margin-top: 4px; min-height: 0; }
.consent { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border-radius: 12px; padding: 14px; border: 1.5px solid var(--line); font-size: 14px; color: var(--ink-2); }
.consent input { width: 22px; height: 22px; margin: 0; accent-color: var(--brand); flex: none; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.alert { background: #fdecea; color: var(--danger); border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-top: 12px; }

/* sticky bottom bar */
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255, 255, 255, .96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 12px 16px calc(12px + var(--safe)); animation: up .25s ease; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
.bar-in { max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.bar-txt { flex: 1; min-width: 0; font-size: 14px; line-height: 1.35; }
.bar-txt b { display: block; font-size: 15px; }
.bar-txt span { color: var(--muted); }
.cta { border: 0; background: var(--brand); color: #fff; border-radius: 14px; padding: 14px 22px; font-weight: 700; font-size: 16px; flex: none; transition: transform .1s, opacity .2s; }
.cta:active { transform: scale(.97); }
.cta:disabled { opacity: .45; }
.cta.block { display: block; width: 100%; }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 14px; font-weight: 600; text-decoration: none; color: var(--ink); margin-top: 10px; }
.btn.line { background: var(--line-green); border-color: var(--line-green); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.ghost { border: 0; background: none; color: var(--brand); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two .btn { margin-top: 0; flex-direction: column; gap: 2px; font-size: 14px; padding: 12px 8px; }
.two .btn .e { font-size: 22px; }

/* done */
.done-hero { text-align: center; padding: 18px 0 8px; }
.check { width: 72px; height: 72px; border-radius: 50%; background: var(--brand); display: grid; place-items: center; margin: 0 auto 12px; animation: pop .45s cubic-bezier(.2, 1.4, .4, 1); }
.check svg { width: 36px; height: 36px; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: none; opacity: 1; } }
.muted { color: var(--muted); font-size: 14px; }
.linkbox { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px dashed #cfcac0; border-radius: 12px; padding: 8px 8px 8px 12px; margin-top: 8px; }
.linkbox code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--ink-2); }
.linkbox button { border: 0; background: var(--brand-soft); color: var(--brand); border-radius: 9px; padding: 8px 12px; font-weight: 600; font-size: 14px; flex: none; }
.status { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 600; background: var(--brand-soft); color: var(--brand); }
.status.cancelled { background: #fdecea; color: var(--danger); }

/* bottom sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-bg { position: absolute; inset: 0; background: rgba(10, 20, 18, .4); animation: fade .2s ease; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow-y: auto; background: var(--card); border-radius: 22px 22px 0 0; padding: 8px 20px calc(20px + var(--safe)); animation: up .28s cubic-bezier(.2, .9, .3, 1); max-width: 560px; margin: 0 auto; }
.grab { width: 40px; height: 5px; border-radius: 5px; background: var(--line); margin: 4px auto 12px; }
.sheet h2 { margin: 4px 0 2px; font-size: 21px; }
.sheet .sub { color: var(--ink-2); margin: 0 0 12px; font-size: 14px; }
.pgrp { font-size: 13px; font-weight: 700; color: var(--brand); margin: 14px 0 4px; text-transform: uppercase; letter-spacing: .04em; }
.prow { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.prow b { font-weight: 600; display: block; }
.prow small { color: var(--muted); font-size: 13px; }
.prow span { font-weight: 700; white-space: nowrap; }
.prow.hl { background: var(--brand-soft); border-radius: 12px; padding: 11px 12px; border: 0; }
.fine { color: var(--muted); font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 60; animation: fade .2s ease; }
@media (min-width: 600px) {
  .slots { grid-template-columns: repeat(5, 1fr); }
}
