/* ===== Base ===== */
* { box-sizing: border-box; }
:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e5e5e5;
  --text: #1a1a1a;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #10b981;
  --error: #ef4444;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
               "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 12px; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; margin-bottom: 4px; }

p { margin: 0 0 12px; }
small { font-size: 13px; }

/* ===== Layout ===== */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}
.container.narrow { max-width: 520px; }
.container.wide { max-width: 880px; }
.container.center { text-align: center; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.brand { font-size: 18px; }

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero {
  text-align: center;
  margin-bottom: 32px;
  padding: 16px 0;
}
.hero.compact { padding: 8px 0; margin-bottom: 16px; }
.hero .logo {
  font-size: 48px;
  margin-bottom: 12px;
}

.subtitle {
  color: var(--muted);
  font-size: 16px;
}

.muted { color: var(--muted); }
.center { text-align: center; }
.hidden { display: none !important; }

/* ===== Card ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card.alert {
  border-color: var(--error);
  background: #fef2f2;
}
.card.alert p { margin: 0 0 16px; }

/* ===== Form ===== */
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.field .req { color: var(--error); }

input[type="text"],
input[type="email"],
input[type="time"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
textarea { resize: vertical; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
@media (max-width: 560px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #f5f5f5; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-block {
  display: flex;
  width: 100%;
  padding: 12px 20px;
  font-size: 15px;
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 6px 8px;
}
.btn-text:hover { background: #f5f5f5; color: var(--text); }

/* ===== URL box ===== */
.url-box {
  display: flex;
  gap: 8px;
  margin: 8px 0;
}
.url-box input {
  flex: 1;
  background: #f9fafb;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

/* ===== Slots (旧) ===== */
.slots-area {
  margin-top: 12px;
  min-height: 60px;
}

.no-slots {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  background: #f9fafb;
  border-radius: 8px;
}

/* ===== カレンダーレイアウト ===== */
.duration-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.duration-bar label {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}
.duration-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.duration-btn {
  padding: 8px 18px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.duration-btn + .duration-btn {
  border-left: 1px solid var(--border);
}
.duration-btn:hover { background: #f5f5f5; }
.duration-btn.active {
  background: var(--primary);
  color: #fff;
}

.cal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 720px) {
  .cal-layout { grid-template-columns: 1fr; }
}

/* === カレンダー本体 === */
.cal-pane {
  user-select: none;
}
.cal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.cal-month-label {
  font-size: 16px;
  font-weight: 600;
}
.cal-nav {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.cal-nav:hover:not(:disabled) {
  background: #f5f5f5;
  border-color: var(--primary);
}
.cal-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.cal-weekday {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 0;
}
.cal-weekday.sun { color: #ef4444; }
.cal-weekday.sat { color: #2563eb; }

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

.cal-cell {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.cal-cell.empty {
  cursor: default;
  pointer-events: none;
}
.cal-cell.available {
  background: #eff6ff;
  color: var(--primary);
  font-weight: 500;
}
.cal-cell.available:hover {
  background: var(--primary);
  color: #fff;
}
.cal-cell.disabled {
  color: #d1d5db;
  cursor: not-allowed;
  background: transparent;
  font-weight: 400;
}
.cal-cell.today {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.cal-cell.selected {
  background: var(--primary) !important;
  color: #fff !important;
  font-weight: 600;
}
.cal-cell.sun.disabled { color: #fca5a5; }
.cal-cell.sat.disabled { color: #93c5fd; }
.cal-cell-num {
  line-height: 1;
}

/* === 時間スロットパネル === */
.cal-slots-pane {
  border-left: 1px solid var(--border);
  padding-left: 24px;
  min-height: 300px;
}
@media (max-width: 720px) {
  .cal-slots-pane {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 20px;
    margin-top: 8px;
  }
}
.cal-slots-heading {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}
.cal-slots-area {
  min-height: 200px;
}
.cal-slots-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 4px;
}
.cal-slot-btn {
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.12s, color 0.12s;
}
.cal-slot-btn:hover {
  background: var(--primary);
  color: #fff;
}

/* ===== Selected time ===== */
.selected-time {
  background: #eff6ff;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  border-left: 3px solid var(--primary);
}

/* ===== Result ===== */
.success-icon {
  width: 56px;
  height: 56px;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.result {
  margin-top: 16px;
}
.result-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.result-row:last-child { border-bottom: none; }
.result-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}
.result-value {
  display: block;
  font-size: 16px;
  font-weight: 500;
}

/* ===== Messages ===== */
.msg {
  font-size: 13px;
  color: var(--muted);
}
.msg.success { color: var(--success); }
.msg.error { color: var(--error); }

/* ===== Bookings list ===== */
.booking-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.booking-item:last-child { border-bottom: none; }
.booking-when { font-weight: 500; }
.booking-meta { color: var(--muted); font-size: 13px; }

/* ===== Features ===== */
.features {
  margin-top: 24px;
  text-align: left;
}
.feature {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px;
  border-radius: 8px;
}
.feature-icon { font-size: 24px; }
.feature p { margin: 4px 0 0; font-size: 14px; }
.feature h3 { font-size: 15px; }

/* ===== Loading ===== */
.loading {
  text-align: center;
  padding: 24px;
  color: var(--muted);
}
.loading::after {
  content: "...";
  animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots {
  0%, 20% { content: "."; }
  40% { content: ".."; }
  60%, 100% { content: "..."; }
}
