/* ═══════════════════════════════════════════════════════════════
   CohabApp — "Ink & Paper" Editorial Calendar
   Standalone CSS Design System
   Typography: Playfair Display (serif) + DM Sans (sans)
   Palette: Warm off-white, charcoal, terracotta accent
   ═══════════════════════════════════════════════════════════════ */

/* ─── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --paper: #FAF8F5;
  --card: #FFFFFF;
  --charcoal: #1A1A1A;
  --foreground: #2C2C2C;
  --muted: #8A8680;
  --rule: #E5E0DA;
  --terracotta: #C45D3E;
  --terracotta-light: #C45D3E22;
  --terracotta-hover: #B34E32;
  --accent-bg: #F5F2EE;
  --amber: #D97706;
  --amber-light: #FEF3C7;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 3px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --transition: 150ms ease;
}

/* ─── Dark Theme ───────────────────────────────────────────── */
[data-theme="dark"] {
  --paper: #1A1A1E;
  --card: #242428;
  --charcoal: #E8E6E1;
  --foreground: #D4D2CD;
  --muted: #8A8680;
  --rule: #3A3A3E;
  --terracotta: #D4714E;
  --terracotta-light: #D4714E22;
  --terracotta-hover: #E07D58;
  --accent-bg: #2A2A2E;
  --amber: #F0A030;
  --amber-light: #3A3020;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.25);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.35);
}
[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--paper); }
[data-theme="dark"] .form-input,
[data-theme="dark"] select,
[data-theme="dark"] textarea { background: var(--paper); color: var(--foreground); }
[data-theme="dark"] .auth-btn { background: var(--terracotta); color: #fff; }
[data-theme="dark"] .auth-btn:hover { background: var(--terracotta-hover); }
[data-theme="dark"] .new-event-btn { background: var(--terracotta); color: #fff; }
[data-theme="dark"] .view-btn.active { background: var(--terracotta); color: #fff; }
[data-theme="dark"] .cat-btn.active { border-color: var(--terracotta); background: var(--terracotta); color: #fff; }
[data-theme="dark"] .cal-toggle .dot.personal { background: var(--foreground); }
[data-theme="dark"] .toast.info { background: var(--card); color: var(--foreground); }

html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--foreground);
  line-height: 1.5;
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ─── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ─── Auth Page ─────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
}
.auth-left {
  display: none;
  width: 45%;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  border-right: 1px solid var(--rule);
}
.auth-left img { max-width: 320px; width: 100%; opacity: 0.9; }
.auth-left p {
  margin-top: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
  letter-spacing: 0.02em;
  line-height: 1.6;
}
.auth-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.auth-form-wrap { width: 100%; max-width: 360px; }
.auth-form-wrap h1 {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--charcoal);
}
.auth-form-wrap .subtitle {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.875rem;
  letter-spacing: 0.02em;
}
.auth-mobile-img {
  display: flex;
  justify-content: center;
  margin-bottom: 2rem;
}
.auth-mobile-img img { width: 180px; opacity: 0.8; }
.auth-form { margin-top: 2.5rem; }
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.form-input {
  width: 100%;
  height: 2.75rem;
  border: none;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  padding: 0;
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition);
}
.form-input:focus { border-color: var(--terracotta); }
.form-input::placeholder { color: var(--muted); opacity: 0.5; }
.password-wrap { position: relative; }
.password-wrap .form-input { padding-right: 2.5rem; }
.password-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.5rem;
  color: var(--muted);
  transition: color var(--transition);
}
.password-toggle:hover { color: var(--foreground); }
.password-toggle svg { width: 16px; height: 16px; }
.strength-bar { margin-top: 0.5rem; }
.strength-track {
  height: 3px;
  background: var(--rule);
  border-radius: 2px;
  overflow: hidden;
}
.strength-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 300ms ease, background 300ms ease;
}
.strength-label { font-size: 0.65rem; color: var(--muted); margin-top: 0.25rem; }
.match-error { font-size: 0.65rem; color: var(--terracotta); margin-top: 0.25rem; }
.auth-btn {
  width: 100%;
  height: 2.75rem;
  margin-top: 0.5rem;
  background: var(--charcoal);
  color: var(--paper);
  font-weight: 500;
  font-size: 0.875rem;
  letter-spacing: 0.03em;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.auth-btn:hover { background: #333; }
.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.auth-error {
  color: var(--terracotta);
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}
.auth-pw-req {
  font-size: 0.7rem;
  color: var(--muted);
  margin: -0.25rem 0 0.5rem;
  line-height: 1.4;
}
.auth-links-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
}
.auth-switch {
  font-size: 0.8rem;
  color: var(--muted);
  transition: color var(--transition);
}
.auth-switch:hover { color: var(--terracotta); }
.auth-forgot {
  font-size: 0.8rem;
  color: var(--muted);
  transition: color var(--transition);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
}
.auth-forgot:hover { color: var(--terracotta); }

.forgot-form { margin-top: 1.5rem; }
.forgot-desc {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
  line-height: 1.4;
}
.forgot-success {
  font-size: 0.8rem;
  color: #22C55E;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.settings-section-title {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--charcoal);
  margin: 1.25rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
}

@media (min-width: 1024px) {
  .auth-left { display: flex; flex-direction: column; }
  .auth-mobile-img { display: none; }
}

/* ─── App Layout ────────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  min-width: 220px;
  border-right: 1px solid var(--rule);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1rem;
  transition: transform 300ms ease;
  z-index: 50;
}
.sidebar-header {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
}
.sidebar-logo {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--charcoal);
}
.sidebar-email {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: -0.5rem;
  margin-bottom: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Sidebar footer (theme toggle + logout) */
.sidebar-footer {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logout-link {
  font-size: 0.75rem;
  color: var(--muted);
  transition: color var(--transition);
  text-decoration: none;
}
.logout-link:hover { color: var(--terracotta); }

/* Theme toggle */
.theme-toggle-row { display: flex; align-items: center; }
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}
.theme-icon {
  width: 14px;
  height: 14px;
  color: var(--muted);
  transition: color var(--transition);
}
.theme-toggle:hover .theme-icon { color: var(--foreground); }
.toggle-track {
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: var(--rule);
  position: relative;
  transition: background var(--transition);
}
.toggle-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--card);
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform var(--transition);
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
[data-theme="dark"] .toggle-track { background: var(--terracotta); }
[data-theme="dark"] .toggle-thumb { transform: translateX(14px); }

/* Mini Calendar */
.mini-cal { margin-bottom: 1.25rem; }
.mini-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.mini-cal-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--foreground);
}
.mini-cal-nav { display: flex; gap: 0.25rem; }
.mini-cal-nav button {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--muted);
  transition: all var(--transition);
  font-size: 0.75rem;
}
.mini-cal-nav button:hover { background: var(--accent-bg); color: var(--foreground); }
.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
}
.mini-cal-dayname {
  text-align: center;
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--muted);
  padding: 0.15rem 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.mini-cal-day {
  text-align: center;
  font-size: 0.7rem;
  padding: 0.2rem 0;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  transition: all var(--transition);
}
.mini-cal-day:hover { background: var(--accent-bg); }
.mini-cal-day.outside { color: var(--rule); }
.mini-cal-day.today {
  background: var(--terracotta);
  color: white;
  font-weight: 600;
}
.mini-cal-day.selected {
  border: 1px solid var(--terracotta);
  font-weight: 600;
}

/* Sidebar Sections */
.sidebar-section {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
}
.sidebar-section:last-child { border-bottom: none; }
.sidebar-section-title {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.cal-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  font-size: 0.8rem;
  width: 100%;
  transition: opacity var(--transition);
}
.cal-toggle .dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.cal-toggle .dot.shared { background: var(--terracotta); }
.cal-toggle .dot.personal { background: var(--charcoal); }
.cal-toggle.off { opacity: 0.4; }
.cal-toggle .lock-icon {
  width: 11px;
  height: 11px;
  color: var(--muted);
  opacity: 0.5;
  flex-shrink: 0;
}
.cal-toggle .eye {
  margin-left: auto;
  color: var(--muted);
  width: 14px;
  height: 14px;
}

/* Holiday picker */
.holiday-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  font-size: 0.8rem;
  width: 100%;
}
.holiday-toggle .star { color: var(--amber); width: 14px; height: 14px; }
.holiday-check {
  width: 14px;
  height: 14px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.holiday-check.checked {
  background: var(--amber);
  border-color: var(--amber);
}
.holiday-check svg { width: 10px; height: 10px; color: white; }
.holiday-picker {
  margin-top: 0.5rem;
  max-height: 0;
  overflow: hidden;
  transition: max-height 300ms ease;
}
.holiday-picker.open { max-height: 600px; overflow-y: auto; }
.holiday-picker-btn {
  font-size: 0.7rem;
  color: var(--muted);
  padding: 0.25rem 0;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  transition: color var(--transition);
}
.holiday-picker-btn:hover { color: var(--foreground); }
.holiday-picker-btn svg { width: 12px; height: 12px; transition: transform var(--transition); }
.holiday-picker-btn.open svg { transform: rotate(180deg); }
.holiday-cat-title {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0.5rem 0 0.25rem;
  cursor: pointer;
  transition: color var(--transition);
}
.holiday-cat-title:hover { color: var(--terracotta); }
.holiday-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0;
  font-size: 0.75rem;
  width: 100%;
  transition: color var(--transition);
}
.holiday-item:hover { color: var(--terracotta); }
.holiday-item .hcheck {
  width: 12px;
  height: 12px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.holiday-item .hcheck.on {
  background: var(--amber);
  border-color: var(--amber);
}

/* People section */
.person-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.8rem;
}
.person-row-me {
  background: rgba(255, 243, 176, 0.45);
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius);
}
[data-theme="dark"] .person-row-me {
  background: rgba(255, 243, 176, 0.1);
}
.person-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--charcoal);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 600;
  flex-shrink: 0;
}
.person-info { flex: 1; min-width: 0; }
.person-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-name.editable-name { cursor: pointer; border-bottom: 1px dashed var(--rule); display: inline-block; }
.person-name.editable-name:hover { color: var(--terracotta); border-color: var(--terracotta); }
.name-edit-input {
  font-family: var(--font-sans);
  font-size: inherit;
  font-weight: 500;
  color: var(--foreground);
  background: var(--paper);
  border: 1px solid var(--terracotta);
  border-radius: var(--radius);
  padding: 0.1rem 0.25rem;
  width: 100%;
  outline: none;
}
.person-role { font-size: 0.65rem; color: var(--muted); }
.invite-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0.25rem 0;
  transition: color var(--transition);
}
.invite-btn:hover { color: var(--terracotta); }
.invite-btn svg { width: 14px; height: 14px; }
.manage-btn {
  font-size: 0.7rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0;
  transition: color var(--transition);
}
.manage-btn:hover { color: var(--terracotta); }
.manage-btn svg { width: 12px; height: 12px; }

/* Import / Export sidebar buttons */
.sidebar-action-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0.3rem 0;
  transition: color var(--transition);
}
.sidebar-action-btn:hover { color: var(--terracotta); }
.sidebar-action-btn svg { width: 14px; height: 14px; }

/* Timezone picker */
.tz-picker {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}
.tz-picker svg {
  width: 14px;
  height: 14px;
  color: var(--muted);
  flex-shrink: 0;
}
.tz-select {
  flex: 1;
  min-width: 0;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  color: var(--foreground);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.25rem 0.35rem;
  cursor: pointer;
  appearance: auto;
}

/* Mobile sidebar */
@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 49;
  }
  .sidebar-overlay.show { display: block; }
}

/* ─── Main Content ──────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── Calendar Header ───────────────────────────────────────── */
.cal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  flex-wrap: wrap;
}
.hamburger {
  display: none;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.hamburger:hover { background: var(--accent-bg); }
.hamburger svg { width: 18px; height: 18px; }
@media (max-width: 767px) { .hamburger { display: flex; } }
.cal-nav { display: flex; align-items: center; gap: 0.25rem; }
.cal-nav button {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--muted);
  transition: all var(--transition);
}
.cal-nav button:hover { background: var(--accent-bg); color: var(--foreground); }
.cal-nav svg { width: 16px; height: 16px; }
.today-btn {
  padding: 0.3rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  transition: all var(--transition);
}
.today-btn:hover { border-color: var(--terracotta); color: var(--terracotta); }
.cal-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--charcoal);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
}
@media (max-width: 767px) { .cal-title { font-size: 1.1rem; } }
.header-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.new-event-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius);
  transition: all var(--transition);
}
.new-event-btn {
  background: var(--charcoal);
  color: var(--paper);
}
.new-event-btn:hover { background: #333; }
.new-event-btn svg { width: 14px; height: 14px; }
.view-switcher { display: flex; gap: 0; border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.view-btn {
  padding: 0.3rem 0.6rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  transition: all var(--transition);
  border-right: 1px solid var(--rule);
}
.view-btn:last-child { border-right: none; }
.view-btn:hover { color: var(--foreground); background: var(--accent-bg); }
.view-btn.active { background: var(--charcoal); color: var(--paper); }

/* ─── Calendar Body ─────────────────────────────────────────── */
.cal-body {
  flex: 1;
  overflow: auto;
  position: relative;
}

/* ─── Month View ────────────────────────────────────────────── */
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  height: 100%;
  min-height: 600px;
}
.month-dayname {
  padding: 0.5rem;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
}
.month-dayname:last-child { border-right: none; }
.month-cell {
  border-bottom: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
  padding: 0.25rem;
  min-height: 80px;
  cursor: pointer;
  transition: background var(--transition);
  overflow: hidden;
}
.month-cell:nth-child(7n) { border-right: none; }
.month-cell:hover { background: var(--accent-bg); }
.month-cell.outside { background: var(--paper); }
.month-cell.outside * { opacity: 0.3 !important; }
.month-date {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.1rem 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
}
.month-date.today {
  background: var(--terracotta);
  color: white;
  font-weight: 700;
}
.month-event {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.25rem;
  margin-top: 0.1rem;
  font-size: 0.7rem;
  border-radius: 2px;
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.month-event:hover { background: var(--accent-bg); }
.month-event .edot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.month-event .edot.shared { background: var(--terracotta); }
.month-event .edot.personal { background: var(--charcoal); }
.month-event .etime { color: var(--muted); font-size: 0.65rem; }
.month-holiday {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.1rem 0.25rem;
  font-size: 0.65rem;
  color: var(--amber);
}
.month-holiday svg { width: 10px; height: 10px; }
.month-more { font-size: 0.6rem; color: var(--muted); padding: 0.1rem 0.25rem; }

/* ─── Week & Day Views ──────────────────────────────────────── */
.time-grid {
  display: grid;
  position: relative;
}
.time-grid-header {
  display: grid;
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 10;
}
.time-grid-header .corner {
  width: 60px;
  min-width: 60px;
  border-right: 1px solid var(--rule);
}
.time-grid-header .day-col-header {
  padding: 0.5rem;
  text-align: center;
  border-right: 1px solid var(--rule);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.time-grid-header .day-col-header:last-child { border-right: none; }
.time-grid-header .day-col-header .day-num {
  display: block;
  font-size: 1.25rem;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--foreground);
  margin-top: 0.15rem;
}
.time-grid-header .day-col-header .day-num.today {
  background: var(--terracotta);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.time-grid-body {
  display: grid;
  position: relative;
}
.time-gutter {
  width: 60px;
  min-width: 60px;
}
.time-slot-label {
  height: 60px;
  padding: 0 0.5rem;
  font-size: 0.65rem;
  color: var(--muted);
  text-align: right;
  position: relative;
  top: -0.5em;
}
.time-col {
  position: relative;
  border-right: 1px solid var(--rule);
}
.time-col:last-child { border-right: none; }
.time-slot {
  height: 60px;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: background var(--transition);
}
.time-slot:hover { background: var(--accent-bg); }
.time-event {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: var(--radius);
  padding: 0.2rem 0.35rem;
  font-size: 0.7rem;
  cursor: pointer;
  overflow: hidden;
  z-index: 5;
  transition: opacity var(--transition);
}
.time-event:hover { opacity: 0.85; }
.time-event.shared {
  background: var(--terracotta-light);
  border-left: 3px solid var(--terracotta);
  color: var(--terracotta);
}
.time-event.personal {
  background: rgba(26,26,26,0.08);
  border-left: 3px solid var(--charcoal);
  color: var(--charcoal);
}
.time-event .te-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.time-event .te-time { font-size: 0.6rem; opacity: 0.7; }
.time-now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--terracotta);
  z-index: 8;
  pointer-events: none;
}
.time-now-line::before {
  content: '';
  position: absolute;
  left: -4px;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--terracotta);
}
/* All-day events bar */
.allday-bar {
  border-bottom: 1px solid var(--rule);
  padding: 0.25rem 0.25rem 0.25rem 60px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  min-height: 28px;
  background: var(--paper);
}
.allday-chip {
  padding: 0.15rem 0.5rem;
  font-size: 0.7rem;
  border-radius: 2px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--transition);
}
.allday-chip:hover { opacity: 0.8; }
.allday-chip.shared { background: var(--terracotta-light); color: var(--terracotta); }
.allday-chip.personal { background: rgba(26,26,26,0.08); color: var(--charcoal); }

/* ─── Year View (mini month-view cards) ────────────────────── */
.year-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  padding: 1rem;
}
@media (max-width: 767px) { .year-grid { grid-template-columns: 1fr; } }
.year-month-panel {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
}
.year-month-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: background var(--transition);
}
.year-month-header:hover { background: var(--accent-bg); }
.year-month-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--charcoal);
}
.year-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.year-month-dayname {
  padding: 0.35rem 0.15rem;
  text-align: center;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
}
.year-month-dayname:nth-child(7n) { border-right: none; }
.year-month-cell {
  border-bottom: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
  padding: 0.15rem;
  min-height: 52px;
  cursor: pointer;
  transition: background var(--transition);
  overflow: hidden;
}
.year-month-cell:nth-child(7n) { border-right: none; }
.year-month-cell:hover { background: var(--accent-bg); }
.year-month-cell.outside { background: var(--paper); }
.year-month-cell.outside * { opacity: 0.3 !important; }
.year-month-panel.past-month { opacity: 0.45; }
.year-month-cell.past { opacity: 0.4; }
.ym-date {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.05rem 0.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  border-radius: 50%;
}
.ym-date.today {
  background: var(--terracotta);
  color: white;
  font-weight: 700;
}
.ym-event {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0 0.15rem;
  margin-top: 0.05rem;
  font-size: 0.6rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 1px;
  cursor: pointer;
  transition: background var(--transition);
}
.ym-event:hover { background: var(--accent-bg); }
.ym-event .edot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ym-event .edot.shared { background: var(--terracotta); }
.ym-event .edot.personal { background: var(--charcoal); }
.ym-holiday {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  padding: 0 0.15rem;
  font-size: 0.55rem;
  color: var(--amber);
}
.ym-holiday svg { width: 8px; height: 8px; }
.ym-more { font-size: 0.5rem; color: var(--muted); padding: 0 0.15rem; }

/* ─── Modals ────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.5rem;
  position: relative;
  animation: modalIn 200ms ease;
  -webkit-overflow-scrolling: touch;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--muted);
  transition: all var(--transition);
}
.modal-close:hover { background: var(--accent-bg); color: var(--foreground); }
.modal-close svg { width: 16px; height: 16px; }
.modal h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 0.25rem;
}
.modal .modal-desc {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
}
.modal-section-title {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35rem;
  margin-top: 1rem;
}
.modal-input {
  width: 100%;
  height: 2.5rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0 0.75rem;
  font-size: 0.875rem;
  background: var(--paper);
  outline: none;
  transition: border-color var(--transition);
}
.modal-input:focus { border-color: var(--terracotta); }
.modal-textarea {
  width: 100%;
  min-height: 60px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  background: var(--paper);
  outline: none;
  resize: vertical;
  transition: border-color var(--transition);
}
.modal-textarea:focus { border-color: var(--terracotta); }
.modal-select {
  width: 100%;
  height: 2.5rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0 0.75rem;
  font-size: 0.875rem;
  background: var(--paper);
  outline: none;
  appearance: none;
  cursor: pointer;
  transition: border-color var(--transition);
}
.modal-select:focus { border-color: var(--terracotta); }
.modal-row { display: flex; gap: 0.75rem; }
.modal-row > * { flex: 1; }
.modal-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.modal-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--terracotta);
  cursor: pointer;
}
.cat-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.import-cat-btns { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.cat-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  transition: all var(--transition);
}
.cat-btn .cdot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.cat-btn.active { border-color: var(--charcoal); background: var(--charcoal); color: var(--paper); }
.cat-btn.active .cdot { background: var(--paper); }
.cat-btn .cdot.shared { background: var(--terracotta); }
.cat-btn .cdot.personal { background: var(--charcoal); }
.cat-btn.active .cdot.shared { background: var(--terracotta); }
.modal-submit {
  width: 100%;
  height: 2.5rem;
  margin-top: 1rem;
  background: var(--charcoal);
  color: var(--paper);
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.modal-submit:hover { background: #333; }
.modal-delete {
  width: 100%;
  height: 2.5rem;
  margin-top: 0.5rem;
  background: transparent;
  color: var(--terracotta);
  font-weight: 500;
  font-size: 0.8rem;
  border: 1px solid var(--terracotta);
  border-radius: var(--radius);
  transition: all var(--transition);
}
.modal-delete:hover { background: var(--terracotta); color: white; }
.advanced-toggle {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.75rem;
  transition: color var(--transition);
}
.advanced-toggle:hover { color: var(--foreground); }
.advanced-toggle svg { width: 14px; height: 14px; transition: transform var(--transition); }
.advanced-toggle.open svg { transform: rotate(180deg); }
.advanced-fields {
  max-height: 0;
  overflow: hidden;
  transition: max-height 300ms ease;
}
.advanced-fields.open { max-height: 500px; }

/* Role select in invite/manage */
.role-select {
  height: 2rem;
  font-size: 0.75rem;
  padding: 0 0.5rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  outline: none;
  cursor: pointer;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  padding: 0.75rem 1rem;
  border-radius: 4px;
  font-size: 0.8rem;
  box-shadow: var(--shadow-md);
  animation: toastIn 200ms ease, toastOut 200ms ease 2.8s forwards;
  max-width: 320px;
}
.toast.success { background: #065F46; color: white; }
.toast.error { background: var(--terracotta); color: white; }
.toast.info { background: var(--charcoal); color: var(--paper); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ─── Utility ───────────────────────────────────────────────── */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* Multi-day color palette for year view */
.multi-bg-0 { background: rgba(196,93,62,0.12) !important; }
.multi-bg-1 { background: rgba(59,130,246,0.10) !important; }
.multi-bg-2 { background: rgba(16,185,129,0.10) !important; }
.multi-bg-3 { background: rgba(139,92,246,0.10) !important; }
.multi-bg-4 { background: rgba(245,158,11,0.12) !important; }
.multi-bg-5 { background: rgba(244,63,94,0.10) !important; }
.multi-bg-6 { background: rgba(6,182,212,0.10) !important; }
.multi-bg-7 { background: rgba(236,72,153,0.10) !important; }
.multi-text-0 { color: var(--terracotta); }
.multi-text-1 { color: #2563EB; }
.multi-text-2 { color: #059669; }
.multi-text-3 { color: #7C3AED; }
.multi-text-4 { color: #D97706; }
.multi-text-5 { color: #E11D48; }
.multi-text-6 { color: #0891B2; }
.multi-text-7 { color: #DB2777; }

/* ─── Mobile Optimizations ─────────────────────────────────── */
@media (max-width: 767px) {
  /* Compact header for mobile */
  .cal-header { padding: 0.5rem; gap: 0.35rem; }
  .cal-title { font-size: 1rem; }
  .new-event-btn span { display: none; }
  .new-event-btn { padding: 0.4rem; }
  .view-switcher { order: 10; width: 100%; justify-content: center; }
  .view-btn { flex: 1; text-align: center; }
  .today-btn { font-size: 0.6rem; padding: 0.25rem 0.5rem; }

  /* Month cells shorter on mobile */
  .month-cell { min-height: 60px; }
  .month-date { font-size: 0.7rem; }
  .month-event { font-size: 0.6rem; }
  .month-holiday { font-size: 0.55rem; }

  /* Year view cells shorter on mobile */
  .year-month-cell { min-height: 42px; }
  .ym-date { font-size: 0.6rem; min-width: 18px; height: 18px; }
  .ym-event { font-size: 0.5rem; }

  /* Touch-friendly tap targets */
  .cal-nav button { width: 36px; height: 36px; }
  .mini-cal-day { width: 28px; height: 28px; }
}

@media (max-width: 479px) {
  .header-actions { gap: 0.25rem; }
  .month-dayname { font-size: 0.6rem; padding: 0.35rem 0.15rem; }
}
