:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --primary: #16a34a;
  --primary-soft: #dcfce7;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--surface);
  padding: 20px 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  color: var(--text);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.app-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

.lang-switch {
  display: inline-flex;
  background: var(--surface-muted);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.lang-btn {
  border: none;
  background: transparent;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.lang-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Upcoming Banner */
.upcoming-section {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #86efac;
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.upcoming-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.upcoming-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: #15803d;
}

.upcoming-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #14532d;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.upcoming-meta {
  font-size: 0.9rem;
  color: #166534;
}

.countdown-pill {
  background: #16a34a;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 8px 16px;
  border-radius: 999px;
  white-space: nowrap;
}

.countdown-pill.soon {
  background: #dc2626;
}

/* Categories Section */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.text-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.text-btn:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

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

.category-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  text-align: left;
  min-width: 0;
}

.category-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.category-card.active {
  border-color: var(--cat-color, var(--primary));
  background: var(--cat-bg, #f8fafc);
}

.category-card.dimmed {
  opacity: 0.55;
}

.cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.cat-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cat-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cat-mono-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.cat-name {
  font-weight: 700;
  font-size: 0.94rem;
  color: var(--text);
  white-space: nowrap;
}

.cat-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.cat-link-icon {
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.cat-link-icon:hover {
  color: var(--text);
  border-color: var(--text-secondary);
  background: var(--surface-muted);
}

/* Calendar Toolbar */
.calendar-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--surface);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.month-title {
  font-size: 1.15rem;
  font-weight: 700;
  min-width: 170px;
  text-align: center;
  text-transform: capitalize;
}

.nav-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
}

.nav-btn:hover {
  background: var(--surface-muted);
}

.view-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.secondary-btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.secondary-btn:hover {
  background: var(--surface-muted);
}

.view-toggle {
  display: inline-flex;
  background: var(--surface-muted);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.view-btn {
  border: none;
  background: transparent;
  padding: 5px 12px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
}

.view-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Calendar Grid */
.calendar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.weekdays-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}

.weekday-cell {
  padding: 10px 6px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}

.days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.day-cell {
  min-height: 104px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  transition: background 0.12s ease;
}

.day-cell:nth-child(7n) {
  border-right: none;
}

.day-cell.other-month {
  background: #f8fafc;
  color: var(--text-muted);
}

.day-cell.today {
  background: #fefce8;
}

.day-cell.has-event {
  background: #f0fdf4;
}

.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.day-number {
  font-size: 0.88rem;
  font-weight: 600;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.day-cell.today .day-number {
  background: var(--text);
  color: #ffffff;
  font-weight: 700;
}

.day-events {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.event-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 7px;
  border-radius: 6px;
  background: var(--badge-bg, #dcfce7);
  color: var(--badge-color, #166534);
  border-left: 3px solid var(--badge-border, #16a34a);
  line-height: 1.25;
  word-break: break-word;
}

/* List View */
.list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}

.list-item.past {
  opacity: 0.55;
  background: var(--surface-muted);
}

.list-item.next-up {
  border-color: #22c55e;
  background: #f0fdf4;
}

.list-date-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.list-date {
  font-weight: 700;
  font-size: 0.98rem;
}

.list-weekday {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.list-cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-secondary);
}

/* Footer */
.app-footer {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

@media (max-width: 860px) {
  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  .categories-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .day-cell {
    min-height: 76px;
    padding: 5px;
  }

  .event-badge {
    font-size: 0.68rem;
    padding: 3px 5px;
  }

  .app-header {
    padding: 16px;
  }
}
