:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --border: #e8e8ea;
  --border-strong: #d4d4d8;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --accent: #1a1a1a;
  --accent-soft: #f4f4f5;
  --selected: #1a1a1a;
  --selected-text: #fff;
  --green-dot: #22c55e;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 24px rgba(0, 0, 0, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2.5rem;
}

.config-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.cal-layout {
  display: grid;
  grid-template-columns: minmax(200px, 240px) 1fr minmax(200px, 260px);
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 420px;
}

@media (max-width: 900px) {
  .cal-layout {
    grid-template-columns: 1fr;
  }
}

.cal-sidebar {
  padding: 1.5rem 1.25rem;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (max-width: 900px) {
  .cal-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

.host-block {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.host-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.host-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.service-wrap {
  margin-top: 0.25rem;
}

.field-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.service-select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  font: inherit;
  font-size: 0.88rem;
  background: var(--surface);
  color: var(--text);
}

.event-title {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0;
  letter-spacing: -0.02em;
}

.event-meta {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.event-meta-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.event-meta-item--tz {
  flex-wrap: wrap;
}

.meta-icon {
  display: flex;
  color: var(--muted);
  flex-shrink: 0;
}

.tz-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.tz-select {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.25rem;
  border: none;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sidebar-price {
  margin: auto 0 0;
  padding-top: 0.75rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  border-top: 1px solid var(--border);
}

.cal-main {
  position: relative;
  padding: 1.25rem 1rem 1.5rem;
  border-right: 1px solid var(--border);
}

@media (max-width: 900px) {
  .cal-main {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

.month-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.month-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.month-nav {
  display: flex;
  gap: 0.25rem;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--accent-soft);
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 0.35rem;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}

.day-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.day-cell {
  aspect-ratio: 1;
  max-height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  cursor: default;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.day-cell--muted {
  opacity: 0.35;
}

.day-cell--available {
  background: var(--accent-soft);
  color: var(--text);
  cursor: pointer;
}

.day-cell--available:hover {
  background: #e4e4e7;
}

.day-cell--selected {
  background: var(--selected);
  color: var(--selected-text);
}

.day-cell--selected:hover {
  background: #000;
}

.day-cell--today::after {
  content: "";
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text);
}

.day-cell--selected.day-cell--today::after {
  background: #fff;
}

.cal-loading {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.cal-loading[hidden] {
  display: none !important;
}

.cal-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.cal-times {
  padding: 1.25rem 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  min-height: 280px;
}

.times-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.times-day {
  font-weight: 600;
  font-size: 0.92rem;
}

.fmt-toggle {
  display: flex;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  overflow: hidden;
}

.fmt-btn {
  padding: 0.35rem 0.55rem;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  border: none;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.fmt-btn.is-active {
  background: var(--accent-soft);
  color: var(--text);
}

.times-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 320px;
  padding-right: 2px;
}

.time-slot-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.time-slot-btn:hover {
  border-color: var(--text);
  background: #fafafa;
}

.time-slot-btn::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green-dot);
  flex-shrink: 0;
}

.times-empty {
  font-size: 0.88rem;
  color: var(--muted);
  text-align: center;
  padding: 1.5rem 0.5rem;
}

.details-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 600px) {
  .details-overlay {
    align-items: center;
    padding: 1rem;
  }
}

.details-overlay[hidden] {
  display: none !important;
}

.details-panel {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.25rem 1.35rem 1.75rem;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.12);
  position: relative;
}

@media (min-width: 600px) {
  .details-panel {
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
}

.details-back {
  position: absolute;
  top: 1rem;
  left: 0.75rem;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.details-back:hover {
  background: var(--accent-soft);
}

.details-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  padding-left: 2.25rem;
}

.details-summary {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 1.25rem;
  line-height: 1.45;
  padding-left: 2.25rem;
}

.field-group {
  margin-bottom: 1rem;
}

.field-input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.92rem;
}

.field-input:focus {
  outline: 2px solid #a1a1aa;
  outline-offset: 1px;
}

.form-error {
  font-size: 0.85rem;
  color: #b91c1c;
  margin-bottom: 0.75rem;
}

.btn-pay {
  width: 100%;
  padding: 0.85rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  margin-top: 0.25rem;
}

.btn-pay:hover:not(:disabled) {
  background: #333;
}

.btn-pay:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-pay.is-loading {
  position: relative;
  color: transparent;
}

.btn-pay.is-loading::after {
  content: "";
  position: absolute;
  width: 1.1rem;
  height: 1.1rem;
  top: 50%;
  left: 50%;
  margin: -0.55rem 0 0 -0.55rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

/* Success page (light) */
.success-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  text-align: center;
  background: var(--bg);
}

.success-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #dcfce7;
  color: #16a34a;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.success-page h1 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: var(--text);
}

.success-page .sub {
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 32ch;
  margin: 0 0 1.5rem;
}

.success-actions .btn-primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}

.success-actions .btn-primary-link:hover {
  background: #333;
}
