:root {
  color-scheme: dark;
  --bg: #070909;
  --panel: rgba(18, 22, 26, 0.96);
  --panel-soft: rgba(24, 29, 35, 0.9);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f5f7fb;
  --muted: rgba(245, 247, 251, 0.66);
  --purple: #8b5cf6;
  --purple-soft: rgba(139, 92, 246, 0.22);
  --green: #84cc16;
  --green-soft: rgba(132, 204, 22, 0.28);
  --red: #f97316;
  --red-soft: rgba(249, 115, 22, 0.4);
  --shadow: 0 24px 72px rgba(0, 0, 0, 0.34);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(139, 92, 246, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(132, 204, 22, 0.12), transparent 26%),
    linear-gradient(180deg, #060707 0%, #0b0e11 100%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.preview-app {
  width: min(100%, 520px);
  height: 100vh;
  margin: 0 auto;
  padding: 10px 8px;
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
  gap: 8px;
  overflow: hidden;
}

.app-bar,
.room-card,
.date-card,
.duration-card,
.timeline-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.app-bar,
.section-head,
.room-card,
.room-meta,
.date-actions,
.legend,
.summary-meta {
  display: flex;
  align-items: center;
}

.app-bar,
.section-head {
  justify-content: space-between;
  gap: 10px;
}

.app-bar,
.date-card,
.duration-card,
.timeline-card {
  padding: 10px;
}

.back-link,
.ghost-button,
.confirm-button,
.duration-button {
  appearance: none;
  border: 0;
  text-decoration: none;
}

.back-link,
.ghost-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.eyebrow,
.summary-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.1rem;
}

h2 {
  font-size: 0.92rem;
}

#selected-date-label {
  min-height: 1.25rem;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-card {
  padding: 8px 10px;
  gap: 8px;
}

.room-image {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.room-card h2 { font-size: 1rem; margin-bottom: 2px; }
.room-kicker { display: none; }

.room-meta {
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.76rem;
}

.room-meta strong {
  color: #b794ff;
  font-size: 0.84rem;
}

.date-card input[type="date"] {
  width: 126px;
  min-height: 38px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 0 10px;
}

.duration-buttons {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.duration-buttons-wide {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.duration-button {
  min-height: 38px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0 10px;
  white-space: nowrap;
}

.duration-button.is-active {
  background: linear-gradient(135deg, #7c3aed, #8b5cf6);
  box-shadow: 0 10px 24px rgba(139, 92, 246, 0.28);
}

.status-pill {
  padding: 8px 10px;
  min-height: 32px;
  border-radius: 999px;
  background: rgba(132, 204, 22, 0.12);
  color: #d9f99d;
  font-size: 0.78rem;
  font-weight: 700;
}

.helper-text {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
  margin-top: 8px;
  margin-bottom: 10px;
}

.hidden {
  display: none !important;
}

.legend {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 10px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.74rem;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  display: inline-block;
}

.swatch.free {
  background: var(--green-soft);
  border: 1px solid rgba(132, 204, 22, 0.8);
}

.swatch.booked {
  background: var(--red-soft);
  border: 1px solid rgba(249, 115, 22, 0.8);
}

.swatch.selected {
  background: var(--purple-soft);
  border: 1px solid rgba(139, 92, 246, 0.9);
}

.timeline-card {
  min-height: 0;
  display: grid;
  overflow: hidden;
}

.timeline-stage {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 8px;
  align-items: stretch;
}

.timeline-summary-rail {
  order: 2;
  border-radius: 18px;
  background: var(--panel-soft);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 10px 8px;
  display: grid;
  align-content: start;
  gap: 10px;
}

.timeline-summary-rail h2 { font-size: 0.94rem; line-height: 1.25; }

.summary-meta {
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.78rem;
}

.summary-price strong {
  display: block;
  font-size: 1rem;
  color: #c4b5fd;
}

.confirm-button {
  min-height: 44px;
  border-radius: 16px;
  background: linear-gradient(135deg, #7c3aed, #8b5cf6);
  color: white;
  font-weight: 800;
  font-size: 0.9rem;
  box-shadow: 0 14px 28px rgba(124, 58, 237, 0.34);
}

.confirm-button:disabled {
  opacity: 0.48;
}

.timeline-shell {
  order: 1;
  position: relative;
  min-width: 0;
  min-height: 0;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.timeline-scroll {
  height: 338px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 6px 0 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.timeline-scroll::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.timeline-grid {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
}

.time-labels {
  display: grid;
}

.time-label {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding-top: 1px;
  color: rgba(245, 247, 251, 0.84);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}

.time-label.day-start {
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  color: #f5f7fb;
}

.time-label.day-start strong {
  font-size: 0.66rem;
  line-height: 1.1;
}

.time-label.day-start span {
  color: rgba(245, 247, 251, 0.7);
}

.time-label.past {
  color: rgba(148, 163, 184, 0.72);
}

.time-label.day-start.past {
  color: rgba(203, 213, 225, 0.82);
}

.time-label.day-start.past span {
  color: rgba(148, 163, 184, 0.72);
}

.time-label.continuation {
  color: rgba(148, 163, 184, 0.72);
}

.time-label.day-start.continuation {
  color: rgba(203, 213, 225, 0.86);
}

.time-label.day-start.continuation span {
  color: rgba(148, 163, 184, 0.72);
}

.timeline-column-wrap {
  position: relative;
  min-width: 0;
}

.timeline-column {
  position: relative;
  width: 112px;
  min-width: 112px;
  border-radius: 18px;
  overflow: hidden;
}

.slot-layer,
.booking-layer {
  position: absolute;
  inset: 0;
}

.slot-layer {
  position: absolute;
  inset: 0;
}

.timeline-fill {
  position: absolute;
  left: 0;
  width: 100%;
  pointer-events: none;
}

.timeline-fill.base {
  border-left: 1px solid rgba(132, 204, 22, 0.74);
  border-right: 1px solid rgba(132, 204, 22, 0.16);
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.08) 0,
      rgba(255, 255, 255, 0.08) 1px,
      transparent 1px,
      transparent 30px
    ),
    rgba(132, 204, 22, 0.18);
}

.timeline-fill.past {
  border-left: 1px solid rgba(148, 163, 184, 0.34);
  border-right: 1px solid rgba(148, 163, 184, 0.16);
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.06) 0,
      rgba(255, 255, 255, 0.06) 1px,
      transparent 1px,
      transparent 30px
    ),
    rgba(100, 116, 139, 0.16);
}

.timeline-fill.continuation {
  border-left: 1px solid rgba(148, 163, 184, 0.34);
  border-right: 1px solid rgba(148, 163, 184, 0.16);
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.06) 0,
      rgba(255, 255, 255, 0.06) 1px,
      transparent 1px,
      transparent 30px
    ),
    rgba(100, 116, 139, 0.16);
}

.timeline-guide {
  position: absolute;
  width: 100%;
  border-left: 0;
  border-right: 0;
  background: transparent;
}

.timeline-guide.major {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.timeline-guide.day-start {
  border-top: 1px solid rgba(196, 181, 253, 0.55);
}

.timeline-guide.continuation {
  border-left-color: rgba(148, 163, 184, 0.34);
  border-right-color: rgba(148, 163, 184, 0.16);
  background: transparent;
}

.timeline-guide.continuation.day-start {
  border-top-color: rgba(148, 163, 184, 0.42);
}

.timeline-guide:first-child {
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
}

.timeline-guide:last-child {
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.booking-segment,
.selection-segment {
  position: absolute;
  left: 0;
  width: 100%;
  border-radius: 18px;
}

.booking-segment {
  background: linear-gradient(180deg, rgba(249, 115, 22, 0.86), rgba(249, 115, 22, 0.6));
  border: 1px solid rgba(255, 183, 119, 0.68);
}

.selection-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.selection-segment {
  left: 20px;
  width: calc(100% - 20px);
  background: linear-gradient(180deg, rgba(91, 33, 182, 0.58), rgba(76, 29, 149, 0.38));
  border: 2px solid rgba(167, 139, 250, 0.9);
  box-shadow: 0 12px 28px rgba(76, 29, 149, 0.24);
  transition: transform 100ms linear, height 100ms linear, border-color 100ms linear, background 100ms linear;
}

.selection-segment.is-warning {
  border-color: rgba(249, 115, 22, 0.95);
  background: linear-gradient(180deg, rgba(194, 65, 12, 0.62), rgba(154, 52, 18, 0.42));
}

.drag-handle {
  position: absolute;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #f8fafc;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.35);
}

.drag-handle::before {
  content: "◎";
  display: grid;
  place-items: center;
  color: #111827;
  font-size: 0.84rem;
  font-weight: 900;
  line-height: 22px;
}

.drag-tooltip {
  position: absolute;
  right: 8px;
  min-width: 118px;
  padding: 6px 8px;
  border-radius: 14px;
  background: rgba(10, 13, 16, 0.92);
  border: 1px solid rgba(167, 139, 250, 0.38);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.drag-tooltip.is-warning {
  border-color: rgba(249, 115, 22, 0.6);
}

.timeline-day-stamp {
  position: absolute;
  left: 8px;
  right: 8px;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(7, 9, 9, 0.78);
  border: 1px solid rgba(196, 181, 253, 0.28);
  color: rgba(245, 247, 251, 0.88);
  font-size: 0.68rem;
  font-weight: 700;
  pointer-events: none;
  z-index: 1;
}

.timeline-day-stamp.continuation {
  background: rgba(51, 65, 85, 0.72);
  border-color: rgba(148, 163, 184, 0.22);
  color: rgba(226, 232, 240, 0.74);
}

.ghost-button:disabled {
  opacity: 0.35;
}

@media (max-width: 420px) {
  .preview-app {
    padding: 10px 8px;
    gap: 8px;
  }

  .app-bar,
  .date-card,
  .duration-card,
  .timeline-card {
    padding: 10px;
    border-radius: 18px;
  }

  .room-card {
    padding: 8px;
    border-radius: 18px;
  }

  .room-image {
    width: 68px;
    height: 68px;
  }

  .duration-button {
    font-size: 0.76rem;
    min-height: 34px;
  }

  .timeline-stage {
    grid-template-columns: minmax(0, 1fr) 104px;
    gap: 8px;
  }

  .timeline-scroll {
    height: 328px;
  }

  .timeline-column {
    width: 94px;
    min-width: 94px;
  }

  .selection-segment {
    left: 18px;
  }

  .drag-tooltip {
    min-width: 102px;
    font-size: 0.68rem;
  }
}
.icon-only {
  width: 38px;
  min-width: 38px;
  padding: 0;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 9, 9, 0.72);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
  z-index: 50;
}

.modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: min(100%, 420px);
  max-height: 78vh;
  overflow: auto;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(18,22,26,0.98);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.tos-content {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.tos-content p,
.tos-content ul,
.tos-content h3,
.tos-content h4 {
  margin: 0;
}

.tos-content ul {
  padding-left: 18px;
}

.tos-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.tos-check input {
  margin-top: 2px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-confirm {
  flex: 1;
}

.status-pill.is-error {
  background: rgba(249,115,22,0.14);
  color: #fed7aa;
}
