:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans Thai", "Helvetica Neue", sans-serif;
  color: #282027;
  background: #fbf8f7;
  --ink: #282027;
  --muted: #6e6169;
  --line: #eadfe3;
  --primary: #783754;
  --primary-dark: #5d2440;
  --cream: #fbf8f7;
  --white: #fff;
  --brow: #f4e4ec;
  --brow-text: #632344;
  --wax: #e7f1ea;
  --wax-text: #28523a;
  --hour: 72px;
  font-size: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; }
button, input, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button {
  min-height: 44px;
  padding: 0 14px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 600;
}
button:disabled { cursor: default; opacity: .55; }
button:not(:disabled):hover { border-color: #bc9aab; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid #ba739e;
  outline-offset: 2px;
}
.topbar { background: #fffcfb; border-bottom: 1px solid var(--line); }
.topbar-inner {
  max-width: 1320px;
  margin: auto;
  padding: 14px 32px;
  min-height: 72px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.brand, .top-actions { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-family: Georgia, serif; font-size: 1.24rem; font-weight: 500; }
.brand div > span { display: block; font-size: .8rem; color: var(--muted); margin-top: 3px; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; background: #793f59; color: #fff2f5; font-size: 1.66rem; }
.sync { display: inline-flex; gap: 6px; align-items: center; font-size: .84rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.sync[data-status="live"] { color: #28523a; }
.sync[data-status="offline"] { color: #8b3845; }
.sync::before { content: ""; width: 8px; height: 8px; border-radius: 100%; background: currentColor; }
.language { padding: 0 10px; min-width: 44px; color: var(--primary); }
main { max-width: 1320px; margin: auto; padding: 33px 32px max(36px, env(safe-area-inset-bottom)); }
.intro { display: flex; justify-content: space-between; align-items: end; gap: 14px; margin-bottom: 25px; }
.eyebrow { color: var(--primary); font-size: .76rem; font-weight: 700; letter-spacing: .15em; margin: 0 0 8px; }
h1, h2, p { margin: 0; }
h1 { font: 500 clamp(2.12rem,4vw,3.38rem)/1.10 Georgia, serif; letter-spacing: -.05em; }
html[lang="th"] h1 { font-family: inherit; font-size: clamp(1.85rem,4vw,3rem); letter-spacing: 0; }
.primary { border-color: var(--primary); color: white; background: var(--primary); min-height: 46px; padding: 0 17px; }
.primary:not(:disabled):hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.new-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; flex-shrink: 0; }
.new-button > span:first-child { font-size: 1.28rem; }
.calendar { background: var(--white); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 9px 26px #55243d08; overflow: clip; }
.calendar-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 21px 23px 16px; }
.date-info h2 { font-size: clamp(1.16rem,2.2vw,1.48rem); font-weight: 700; letter-spacing: -.025em; }
.date-info p { font-size: .89rem; color: var(--muted); margin-top: 4px; }
.date-controls, .date-nav { display: flex; gap: 6px; align-items: center; }
.date-controls button { font-size: .9rem; }
.square { display: grid; place-items: center; width: 44px; min-width: 44px; padding: 0; }
.date-nav button { font-size: 1.4rem; }
.jump-date { position: relative; display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.jump-date:focus-within { outline: 3px solid #ba739e; outline-offset: 2px; }
.jump-date input { position: absolute; inset: 0; width: 100%; min-width: 0; opacity: .01; cursor: pointer; }
.jump-date input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: auto; height: auto; padding: 0; margin: 0; cursor: pointer; }
.calendar-icon { position: relative; width: 16px; height: 15px; border: 1.5px solid currentColor; border-radius: 3px; pointer-events: none; }
.calendar-icon::before { content: ""; position: absolute; top: 3px; inset-inline: 0; border-top: 1px solid currentColor; }
.week { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 8px; padding: 0 23px 16px; }
.week button { min-height: 59px; padding: 7px 3px; display: grid; gap: 2px; justify-items: center; background: #fcf8fa; }
.week button span { font-size: .82rem; color: var(--muted); }
.week button strong { font-size: 1.12rem; font-variant-numeric: tabular-nums; }
.week button[aria-pressed="true"] { background: #f2e3eb; color: #602745; border-color: #c892ad; }
.week button[aria-current="date"] strong { text-decoration: underline; text-underline-offset: 3px; }
.viewbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 23px; border-block: 1px solid var(--line); background: #fffdfd; }
.filters, .views { display: flex; gap: 5px; align-items: center; }
.filters button, .views button { padding-inline: 11px; font-size: .87rem; border-color: transparent; background: transparent; }
.filters button[aria-pressed="true"], .views button[aria-pressed="true"] { border-color: #e6cfdc; background: #f6eaf1; color: var(--primary-dark); }
.schedule { min-height: 250px; }
.timeline { display: grid; grid-template-columns: 66px repeat(var(--columns), minmax(0,1fr)); position: relative; }
.resource-header { display: flex; align-items: center; gap: 7px; padding: 10px 12px; min-height: 51px; font-size: .89rem; font-weight: 700; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); background: #fcf9fa; overflow-wrap: anywhere; }
.resource-header:first-child { border-left: 0; padding-inline: 7px; justify-content: center; color: var(--muted); font-size: .78rem; }
.resource-badge { width: 9px; height: 9px; border-radius: 50%; background: #a66487; flex: 0 0 9px; }
.resource-badge.wax { background: #58856a; }
.time-column, .lane { position: relative; height: calc(var(--hours) * var(--hour)); }
.time-column { background: #fdfafb; }
.time-column span { position: absolute; top: calc(var(--position) * var(--hour)); inset-inline: 0; padding: 7px 0 0; text-align: center; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.lane { border-left: 1px solid var(--line); }
.slot {
  position: absolute; top: calc(var(--position) * var(--hour)); width: 100%; height: calc(var(--hour) / 2);
  min-height: 0; border: 0; border-radius: 0; border-top: 1px solid var(--line); background: white; color: var(--primary);
}
.slot.half { border-top-style: dashed; border-top-color: #f3eaf0; }
.slot span { opacity: 0; }
.slot:hover span, .slot:focus-visible span { opacity: 1; }
.slot:not(:disabled):hover { background: #fbf2f7; }
.slot:focus-visible { outline-offset: -3px; z-index: 1; }
.event {
  text-align: left; min-width: 0; background: var(--brow); color: var(--brow-text); border: 0; border-left: 3px solid #a16183; border-radius: 9px;
}
.event.wax { background: var(--wax); color: var(--wax-text); border-left-color: #5a886a; }
.event strong, .event span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.event strong { font-weight: 750; font-size: .91rem; }
.event span { font-size: .78rem; font-weight: 550; }
.timeline .event {
  z-index: 2; position: absolute; top: calc(var(--position) * var(--hour) + 2px); left: 4px; width: calc(100% - 8px);
  height: max(18px,calc(var(--duration) * var(--hour) - 4px)); min-height: 0; padding: 2px 8px; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; align-items: stretch; gap: 2px;
}
.timeline .event.tiny { flex-direction: row; justify-content: start; align-items: center; }
.timeline .event.short .event-service, .timeline .event.tiny .event-service { display: none; }
.now { position: absolute; inset-inline: 0; top: calc(var(--position) * var(--hour)); z-index: 3; pointer-events: none; border-top: 2px solid #a24270; }
.now::before { content: ""; position: absolute; left: 62px; width: 8px; height: 8px; border-radius: 50%; background: #a24270; top: -5px; }
.agenda { list-style: none; padding: 14px 23px; margin: 0; display: grid; gap: 8px; }
.agenda li { display: grid; grid-template-columns: 63px minmax(0, 1fr); gap: 9px; align-items: center; }
.agenda time { font-size: .92rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.agenda .event { width: 100%; min-height: 63px; padding: 9px 12px; }
.agenda .event strong { margin-bottom: 4px; }
.empty { display: grid; place-items: center; text-align: center; align-content: center; min-height: 250px; padding: 26px; gap: 9px; }
.empty-symbol { place-self: center; background: #f7eaf1; color: #875370; padding: 12px; border-radius: 12px; margin-bottom: 2px; }
.empty strong { font-size: 1.08rem; }
.empty p { color: var(--muted); font-size: .9rem; max-width: 320px; }
.empty button { margin-top: 7px; }
.calendar-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 15px; padding: 12px 23px; border-top: 1px solid var(--line); color: var(--muted); font-size: .83rem; background: #fffdfd; }
.legend, .legend > span { display: flex; align-items: center; gap: 7px; }
.legend { gap: 13px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; background: #a16183; }
.legend-dot.wax { background: #5a886a; }
dialog { color: var(--ink); border: 1px solid var(--line); border-radius: 18px; width: min(480px,calc(100% - 26px)); max-height: calc(100% - 28px); padding: 20px; box-shadow: 0 16px 55px #33202c38; }
dialog::backdrop { background: #33202c69; }
.dialog-top, .dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-top h2 { font: 500 1.68rem/1.15 Georgia, serif; }
html[lang="th"] .dialog-top h2 { font-family: inherit; font-size: 1.45rem; }
.close-button { font-size: 1.47rem; }
fieldset { display: grid; gap: 11px; border: 0; margin: 10px 0 0; padding: 0; min-width: 0; }
fieldset label { display: flex; flex-direction: column; min-width: 0; gap: 4px; }
fieldset label span { font-size: .9rem; font-weight: 650; }
fieldset input, fieldset select { width: 100%; min-width: 0; min-height: 44px; border: 1px solid #d9c9d1; border-radius: 9px; padding: 8px; background: white; }
.form-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; }
.availability { color: var(--muted); font-size: .85rem; min-height: 19px; margin-top: 10px; }
.error, .cancel-confirm { color: #892739; background: #fceef0; padding: 9px 11px; border-radius: 8px; margin-top: 8px; font-size: .9rem; }
.cancel-confirm div { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.danger { background: #892739; color: white; border-color: #892739; }
.dialog-actions { margin-top: 13px; justify-content: flex-end; }
.cancel-link { margin-right: auto; background: transparent; border-color: transparent; color: #8b3845; padding-inline: 7px; }
.toast { position: fixed; z-index: 5; bottom: max(18px,env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: #493243; color: #fff; border-radius: 10px; padding: 11px 15px; box-shadow: 0 3px 14px #39203735; width: max-content; max-width: 90vw; }
@media (max-width: 740px) {
  .topbar-inner { padding: 10px 14px; min-height: 63px; }
  main { padding: 22px 12px max(22px,env(safe-area-inset-bottom)); }
  .intro { align-items: center; margin-bottom: 15px; }
  .calendar { border-radius: 14px; }
  .calendar-top { padding: 12px 10px; gap: 5px; }
  .date-controls { gap: 4px; }
  .date-controls button { padding-inline: 7px; }
  .date-nav { gap: 2px; }
  .date-nav .square { width: 44px; min-width: 44px; }
  .week { padding: 0 9px 10px; gap: 4px; }
  .week button { min-height: 53px; }
  .viewbar { flex-wrap: wrap; padding: 6px 8px; gap: 3px; }
  .filters { flex: 1 0 auto; justify-content: start; gap: 2px; }
  .views { gap: 2px; margin-left: auto; }
  .filters button, .views button { padding-inline: 8px; }
  .calendar-footer { padding: 10px; }
  .timeline { grid-template-columns: 44px repeat(var(--columns),minmax(0,1fr)); }
  .resource-header { padding-inline: 6px; }
  .resource-header:first-child { padding-inline: 4px; }
  .now::before { left: 40px; }
  .agenda { padding: 12px 10px; }
}
@media (max-width: 450px) {
  .brand, .top-actions { gap: 7px; }
  .brand strong { font-size: 1.04rem; }
  .topbar-inner:has([data-hosted-signout]:not([hidden])) { flex-wrap: wrap; }
  .topbar-inner:has([data-hosted-signout]:not([hidden])) .top-actions { margin-left: auto; }
  .brand-mark { width: 36px; height: 36px; border-radius: 10px; }
  .brand div > span { font-size: .74rem; }
  .sync { font-size: .76rem; }
  .intro { flex-wrap: wrap; }
  .intro .new-button { flex: 1 0 100%; }
  .calendar-top { flex-wrap: wrap; }
  .date-controls { margin-left: auto; }
  .date-info { flex: 1 1 100%; }
  .availability { font-size: .83rem; }
}
@media (max-height: 660px) {
  dialog { padding: 14px; }
  fieldset { gap: 8px; }
}
