:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --primary: #4f46e5;
  --primary-light: #e0e7ff;
  --primary-dark: #4338ca;
  --border: #e5e7eb;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior-y: none;
  touch-action: manipulation;
}

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

header {
  text-align: center;
  margin-bottom: 24px;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.calendar-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.calendar-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  text-transform: capitalize;
}

.nav-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.nav-btn:active {
  background: var(--border);
}

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

.weekdays div {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  touch-action: none;
  -webkit-touch-callout: none;
}

.day {
  aspect-ratio: 1;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.1s, background 0.15s;
  position: relative;
}

.day:hover {
  background: var(--bg);
}

.day:active {
  transform: scale(0.92);
}

.day.other-month {
  color: var(--text-secondary);
  opacity: 0.5;
}

.day.selected {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

.day.today {
  color: var(--primary);
  font-weight: 700;
}

.day.today.selected {
  color: #fff;
}

.day.today::after {
  content: '';
  position: absolute;
  bottom: 6px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--primary);
}

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

.day.past {
  color: var(--text-secondary);
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.day.in-range {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.selected-panel {
  margin-top: 20px;
}

.selected-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
  margin-bottom: 10px;
}

.selected-label {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 36px;
}

.empty-hint {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-style: italic;
  padding: 6px 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 14px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  animation: chipIn 0.2s ease;
}

@keyframes chipIn {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

.chip-remove {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(67, 56, 202, 0.15);
  color: var(--primary-dark);
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 1px;
}

.chip-remove:active {
  background: rgba(67, 56, 202, 0.3);
}

.text-btn {
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 0.875rem;
  cursor: pointer;
  padding: 4px 8px;
}

.text-btn:active {
  color: var(--text);
}

.export-btn {
  margin-top: 16px;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(79, 70, 229, 0.25);
  transition: transform 0.1s, background 0.15s;
}

.export-btn:active {
  transform: scale(0.98);
  background: var(--primary-dark);
}

.export-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}
