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

:root,
[data-theme='light'] {
  color-scheme: light;
  --bg: #faf9f6;
  --bg-secondary: #f0ece4;
  --surface: #ffffff;
  --border: #ddd9d0;
  --border-light: #e8e4dd;
  --text: #1a1a1a;
  --text-secondary: #555555;
  --text-tertiary: #999999;
  --text-muted: #6b6b6b;
  --accent: #b45309;
  --accent-hover: #92400e;
  --accent-light: rgba(180, 83, 9, 0.06);
  --focus-ring: #b45309;
  --card-bg: #ffffff;
  --card-border: #ddd9d0;
  --card-shadow: rgba(0, 0, 0, 0.06);
  --card-hover-shadow: rgba(180, 83, 9, 0.15);
  --footer-bg: #f0ece4;
  --footer-border: #d5d0c7;
  --footer-text: #6b6b6b;
  --radius: 0.75rem;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --font-body: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-heading: 'Merriweather', Georgia, serif;
}

[data-theme='dark'] {
  color-scheme: dark;
  --bg: #171717;
  --bg-secondary: #1f1f1f;
  --surface: #1f1f1f;
  --border: #333333;
  --border-light: #2a2a2a;
  --text: #e5e5e5;
  --text-secondary: #a3a3a3;
  --text-tertiary: #737373;
  --text-muted: #d4d4d4;
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --accent-light: rgba(245, 158, 11, 0.1);
  --focus-ring: #f59e0b;
  --card-bg: #1f1f1f;
  --card-border: #333333;
  --card-shadow: rgba(0, 0, 0, 0.3);
  --card-hover-shadow: rgba(245, 158, 11, 0.2);
  --footer-bg: #111111;
  --footer-border: #262626;
  --footer-text: #a3a3a3;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-weight: 400;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---- Header ---- */
header {
  padding: 48px 0 8px;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

header h1 {
  font-family: var(--font-heading);
  font-size: 1.625rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}

header p {
  margin-top: 8px;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

header p strong {
  color: var(--text);
  font-weight: 600;
}

/* ---- Theme toggle ---- */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: color 0.2s ease;
  flex-shrink: 0;
  margin-top: 2px;
}

.theme-toggle:hover {
  color: var(--text);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme='dark'] .theme-toggle .icon-sun { display: block; }
[data-theme='dark'] .theme-toggle .icon-moon { display: none; }

/* ---- Duration toggle ---- */
.controls {
  padding: 24px 0 28px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}

.controls::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 16px;
  background: linear-gradient(to bottom, var(--bg), transparent);
  pointer-events: none;
  transform: translateY(100%);
}

.toggle-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.segmented-control {
  display: inline-flex;
  background: var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}

.segmented-control button {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 7px 18px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  line-height: 1.3;
}

.segmented-control button:hover:not(.active) {
  color: var(--text);
}

.segmented-control button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.segmented-control button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ---- Main content ---- */
main {
  flex: 1;
  padding-bottom: 48px;
}

/* ---- Day groups ---- */
.day-group {
  margin-bottom: 20px;
}

.day-header {
  font-family: var(--font-heading);
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  padding: 8px 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.day-date {
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-tertiary);
}

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

.slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.slot:hover {
  box-shadow: 0 2px 8px var(--card-hover-shadow);
}

.slot-time {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
}

.slot-duration {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---- States ---- */
.state-message {
  text-align: center;
  padding: 56px 20px;
}

.state-message .icon {
  font-size: 2rem;
  margin-bottom: 12px;
  display: block;
}

.state-message h2 {
  font-family: var(--font-heading);
  font-size: 1.0625rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.state-message p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  max-width: 280px;
  margin: 0 auto;
}

.state-message button {
  font-family: var(--font-body);
  margin-top: 16px;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.state-message button:hover {
  border-color: var(--accent);
}

.state-message button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Loading skeleton */
.skeleton-group {
  margin-bottom: 24px;
}

.skeleton-line {
  height: 14px;
  width: 100px;
  background: var(--border);
  border-radius: 4px;
  margin-bottom: 10px;
  animation: pulse 1.4s ease-in-out infinite;
}

.skeleton-slot {
  height: 48px;
  background: var(--border-light);
  border-radius: var(--radius);
  margin-bottom: 6px;
  animation: pulse 1.4s ease-in-out infinite;
}

.skeleton-slot:nth-child(2) { animation-delay: 0.1s; }
.skeleton-slot:nth-child(3) { animation-delay: 0.2s; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ---- Footer ---- */
footer {
  padding: 24px 0 32px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--footer-text);
  background: var(--footer-bg);
  border-top: 1px solid var(--footer-border);
}

footer a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

footer a:hover {
  color: var(--accent-hover);
}

/* ---- Responsive ---- */
@media (min-width: 480px) {
  header {
    padding-top: 64px;
  }

  header h1 {
    font-size: 1.875rem;
  }

  .slot {
    padding: 14px 18px;
  }
}

@media (min-width: 640px) {
  header {
    padding-top: 80px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .skeleton-slot,
  .skeleton-line {
    animation: none;
    opacity: 0.7;
  }
}
