:root {
  --bg: #f3f5f9;
  --bg-grad-a: #eef2ff;
  --bg-grad-b: #f3f5f9;
  --card-bg: #ffffff;
  --text: #12172b;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --free: #16a34a;
  --free-bg: #dcfce7;
  --busy: #dc2626;
  --busy-bg: #fee2e2;
  --now: #2563eb;
  --accent: #4f46e5;
  --shadow: 0 10px 30px -12px rgba(15, 23, 42, 0.15);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f1a;
    --bg-grad-a: #121a2e;
    --bg-grad-b: #0b0f1a;
    --card-bg: #151c2e;
    --text: #e7ebf5;
    --text-muted: #93a0b8;
    --border: #232c44;
    --free: #34d399;
    --free-bg: rgba(52, 211, 153, 0.12);
    --busy: #f87171;
    --busy-bg: rgba(248, 113, 113, 0.12);
    --now: #60a5fa;
    --accent: #818cf8;
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(circle at 20% 0%, var(--bg-grad-a), var(--bg-grad-b) 60%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 4px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
}

.brand-icon { font-size: 1.4rem; }

.clock {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.95rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
}

/* ---------- Status card ---------- */
.status-card {
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow);
  text-align: center;
  transition: background 0.4s ease;
  background: var(--card-bg);
  border: 1px solid var(--border);
}

.status-card.status-free {
  background: linear-gradient(160deg, var(--free-bg), var(--card-bg) 70%);
}

.status-card.status-busy {
  background: linear-gradient(160deg, var(--busy-bg), var(--card-bg) 70%);
}

.status-badge {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.status-free .status-badge { color: var(--free); }
.status-busy .status-badge { color: var(--busy); }

.status-detail {
  font-size: 1.05rem;
  color: var(--text);
  font-weight: 500;
}

.status-sub {
  margin-top: 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ---------- Day tabs ---------- */
.day-tabs {
  display: flex;
  gap: 6px;
  margin: 18px 0 14px;
  overflow-x: auto;
  scrollbar-width: none;
}
.day-tabs::-webkit-scrollbar { display: none; }

.day-tab {
  flex: 1 0 auto;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.day-tab:hover { border-color: var(--accent); }

.day-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.day-tab.is-today::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  margin-left: 6px;
  vertical-align: middle;
}

/* ---------- Timeline card ---------- */
.timeline-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 16px 20px;
  box-shadow: var(--shadow);
}

.timeline-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.timeline-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.timeline-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slot {
  display: grid;
  grid-template-columns: 78px 1fr;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease;
  background: transparent;
}

.slot:hover { transform: translateX(2px); }

.slot-time {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-weight: 600;
}

.slot-bar {
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.slot-bar.free {
  background: var(--free-bg);
  color: var(--free);
}

.slot-bar.busy {
  background: var(--busy-bg);
  color: var(--busy);
}

.slot.is-now {
  border-color: var(--now);
}

.slot.is-now .slot-time {
  color: var(--now);
}

.slot.is-now::before {
  content: "●";
  color: var(--now);
  margin-right: -4px;
}

/* ---------- Slot detail ---------- */
.slot-detail {
  position: relative;
  margin-top: 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 40px 16px 16px;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  animation: fade-in 0.15s ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.slot-detail-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

.slot-detail strong { color: var(--text); }

/* ---------- Legend ---------- */
.legend {
  display: flex;
  gap: 18px;
  justify-content: center;
  margin: 18px 0 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.dot-free { background: var(--free); }
.dot-busy { background: var(--busy); }
.dot-now { background: var(--now); }

/* ---------- Footer ---------- */
.footer {
  margin-top: auto;
  padding-top: 24px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.muted { opacity: 0.7; }

/* ---------- Loading state ---------- */
.status-loading .status-badge {
  color: var(--text-muted);
}

@media (min-width: 640px) {
  .status-badge { font-size: 2.3rem; }
}

/* ---------- Holiday overlay ---------- */
.holiday-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(3px);
}

.holiday-card {
  max-width: 380px;
  text-align: center;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.holiday-icon {
  font-size: 2.4rem;
  margin-bottom: 10px;
}

.holiday-card h2 {
  margin: 0 0 10px;
  font-size: 1.3rem;
}

.holiday-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}
