:root {
  --cream: #f7f1e7;
  --paper: #fffdf8;
  --ink: #241c14;
  --muted: #7c7165;
  --line: #ded4c5;
  --amber: #e9a932;
  --amber-soft: #f8dfae;
  --green: #247450;
  --green-soft: #e8f6ef;
  --green-line: #a7d9bf;
  --red: #a54e47;
  --red-soft: #f8ece9;
  --red-line: #e9bbb5;
  --gray: #91897f;
  --gray-soft: #f0ece5;
  --shadow: 3px 4px 0 rgba(36, 28, 20, .92);
}

* { box-sizing: border-box; }

html { background: var(--cream); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 100% 0, rgba(233,169,50,.13), transparent 25rem),
    var(--cream);
  font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, system-ui, sans-serif;
  line-height: 1.4;
}

button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.topbar {
  min-height: 72px;
  padding: 10px max(14px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: 76px 1fr 42px;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(255,253,248,.88);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}

.logo {
  width: 72px;
  height: 52px;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.topbar strong {
  display: block;
  font-size: 1rem;
  font-weight: 900;
}

.topbar span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: .72rem;
}

.icon-button,
.nav-button,
.close-button {
  border: 1.5px solid var(--ink);
  color: var(--ink);
  background: var(--paper);
  cursor: pointer;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 1.25rem;
  font-weight: 900;
}

.icon-button.loading { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 16px 12px 48px;
}

.date-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,253,248,.82);
  overflow: hidden;
}

.selected-date {
  padding: 12px 15px 8px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.selected-date span {
  color: var(--amber);
  font-weight: 900;
  font-size: .82rem;
}

.selected-date strong {
  font-size: 1.1rem;
  font-weight: 900;
}

.week-control {
  padding: 0 8px 10px;
  display: grid;
  grid-template-columns: 38px minmax(0,1fr) 38px;
  gap: 7px;
  align-items: stretch;
}

.nav-button {
  border-color: var(--line);
  border-radius: 12px;
  font-size: 1.8rem;
  line-height: 1;
}

.date-strip {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(49px, 1fr));
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
}

.date-strip::-webkit-scrollbar { display: none; }

.date-button {
  min-width: 49px;
  min-height: 64px;
  padding: 6px 3px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  text-align: center;
  cursor: pointer;
}

.date-button .day-label {
  display: block;
  font-size: .63rem;
}

.date-button .day-number {
  display: block;
  margin: 2px 0;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 950;
  line-height: 1.1;
}

.date-button .month-label {
  display: block;
  font-size: .6rem;
}

.date-button.active {
  border: 2px solid var(--ink);
  color: var(--ink);
  background: var(--amber);
  box-shadow: 2px 3px 0 var(--ink);
  transform: translate(-1px,-1px);
}

.room-tabs {
  margin-top: 12px;
  padding: 5px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #eee7dc;
}

.room-tab {
  min-height: 54px;
  padding: 7px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.room-tab strong,
.room-tab span { display: block; }

.room-tab strong {
  color: var(--ink);
  font-weight: 950;
}

.room-tab span {
  margin-top: 1px;
  font-size: .7rem;
}

.room-tab.active {
  background: var(--paper);
  box-shadow: 0 2px 8px rgba(36,28,20,.08);
}

.schedule-card {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,253,248,.88);
}

.schedule-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}

.schedule-head h1 {
  margin: 0;
  font-size: 1.2rem;
}

.schedule-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: .75rem;
}

.legend {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: .68rem;
  white-space: nowrap;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.available-dot { background: var(--green); }
.booked-dot { background: var(--red); }

.schedule {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 7px;
}

.slot {
  min-height: 48px;
  padding: 7px 10px;
  border: 1px solid;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
}

button.slot { cursor: pointer; }

.slot-time {
  font-size: .9rem;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.slot-status {
  font-size: .66rem;
  font-weight: 850;
}

.slot.available {
  color: var(--green);
  border-color: var(--green-line);
  background: var(--green-soft);
}

.slot.available:active {
  transform: scale(.98);
}

.slot.booked {
  color: var(--red);
  border-color: var(--red-line);
  background: var(--red-soft);
}

.slot.closed,
.slot.unknown {
  color: var(--gray);
  border-color: var(--line);
  background: var(--gray-soft);
}

.schedule-hint {
  margin: 11px 2px 0;
  color: var(--muted);
  font-size: .71rem;
  text-align: center;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 32px 12px;
  color: var(--muted);
  text-align: center;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  padding: 18px 10px max(10px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(36,28,20,.48);
}

.booking-sheet {
  width: min(100%, 580px);
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  padding: 11px 16px 18px;
  border: 2px solid var(--ink);
  border-radius: 24px 24px 18px 18px;
  background: var(--paper);
  box-shadow: 0 -8px 35px rgba(36,28,20,.2);
  position: relative;
  animation: slideUp .2s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(24px); opacity: .5; }
}

.sheet-handle {
  width: 42px;
  height: 5px;
  margin: 0 auto 10px;
  border-radius: 999px;
  background: #c9c0b4;
}

.close-button {
  position: absolute;
  top: 13px;
  right: 13px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
}

.eyebrow {
  margin: 0;
  color: var(--amber);
  font-size: .75rem;
  font-weight: 950;
}

.booking-sheet h2 {
  margin: 3px 40px 0 0;
  font-size: 1.35rem;
}

.sheet-summary {
  margin: 4px 0 14px;
  color: var(--muted);
  font-size: .83rem;
}

.field {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
}

.field label {
  font-size: .76rem;
  font-weight: 900;
}

input,
select {
  width: 100%;
  min-height: 43px;
  padding: 8px 11px;
  border: 1.5px solid var(--ink);
  border-radius: 11px;
  background: #fff;
  outline: none;
}

input:focus,
select:focus {
  box-shadow: 0 0 0 3px rgba(233,169,50,.22);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 9px;
}

.form-grid .field:first-child {
  grid-column: 1 / -1;
}

.price-box {
  margin: 4px 0 12px;
  padding: 10px 12px;
  border: 1px dashed var(--ink);
  border-radius: 11px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  background: var(--amber-soft);
  font-size: .82rem;
}

.price-box strong { font-size: 1rem; }

.line-button {
  width: 100%;
  min-height: 48px;
  border: 2px solid var(--ink);
  border-radius: 13px;
  color: #fff;
  background: #06c755;
  box-shadow: var(--shadow);
  font-weight: 950;
  cursor: pointer;
}

.line-button:active {
  transform: translate(3px,4px);
  box-shadow: none;
}

.privacy-note {
  margin: 11px 4px 0;
  color: var(--muted);
  font-size: .68rem;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 150;
  max-width: calc(100% - 24px);
  padding: 9px 14px;
  border-radius: 999px;
  color: #fff;
  background: var(--ink);
  font-size: .78rem;
  font-weight: 850;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 680px) {
  .schedule {
    grid-template-columns: repeat(4, minmax(0,1fr));
  }
}

@media (max-width: 390px) {
  .topbar {
    grid-template-columns: 62px 1fr 38px;
  }

  .logo {
    width: 60px;
    height: 44px;
  }

  .topbar span { display: none; }

  .week-control {
    grid-template-columns: 34px minmax(0,1fr) 34px;
    gap: 4px;
    padding-left: 5px;
    padding-right: 5px;
  }

  .date-strip { gap: 3px; }

  .date-button {
    min-width: 43px;
    padding-left: 1px;
    padding-right: 1px;
  }

  .schedule {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
}
