/* ── Loomie Public Calendar ─────────────────────────────────────────────── */
:root {
  --lpc-primary: #7c3aed;
}

.loomie-cal {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  color: #1a1a1a;
  max-width: 860px;
  margin: 0 auto;
  box-sizing: border-box;
}

.loomie-cal *,
.loomie-cal *::before,
.loomie-cal *::after {
  box-sizing: inherit;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.lpc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 8px;
  flex-wrap: wrap;
}

.lpc-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
}

.lpc-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lpc-btn {
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: #374151;
  transition: background 0.15s;
}

.lpc-btn:hover {
  background: #f3f4f6;
}

.lpc-btn-primary {
  background: var(--lpc-primary);
  border-color: var(--lpc-primary);
  color: #fff;
  padding: 5px 14px;
  font-size: 0.85rem;
  font-weight: 500;
}

.lpc-btn-primary:hover {
  filter: brightness(0.92);
}

.lpc-view-toggle {
  display: flex;
  gap: 4px;
}

.lpc-view-toggle .lpc-btn.active {
  background: var(--lpc-primary);
  border-color: var(--lpc-primary);
  color: #fff;
}

/* ── Calendar body — min-height prevents collapse during async fetch ──── */
.loomie-cal #lpc-body {
  min-height: 480px;
}

/* ── Month Grid ─────────────────────────────────────────────────────────── */
.lpc-grid {
  border: 1px solid var(--cal-day-border, #e5e7eb);
  border-radius: 10px;
  overflow: hidden;
}

.lpc-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--cal-header-bg, #f9fafb);
  border-bottom: 1px solid var(--cal-day-border, #e5e7eb);
}

.lpc-weekday {
  padding: 8px 4px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--cal-header-text, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

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

.lpc-day {
  min-height: 80px;
  padding: 6px;
  border-right: 1px solid var(--cal-day-border, #e5e7eb);
  border-bottom: 1px solid var(--cal-day-border, #e5e7eb);
  background: var(--cal-day-bg, #ffffff);
  position: relative;
  vertical-align: top;
}

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

.lpc-day.other-month {
  background: #fafafa;
}

.lpc-day.today .lpc-day-num {
  background: var(--cal-today-bg, var(--lpc-primary));
  color: #fff;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lpc-day-num {
  font-size: 0.8rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 4px;
  display: block;
}

.lpc-day.other-month .lpc-day-num {
  color: var(--cal-past-day-color, #9ca3af);
}

/* ── Event Chips ─────────────────────────────────────────────────────────── */
.lpc-event {
  display: block;
  font-size: 0.72rem;
  padding: 2px 5px;
  border-radius: 4px;
  margin-bottom: 2px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  font-weight: 500;
  transition: filter 0.1s;
}

.lpc-event:hover {
  filter: brightness(0.9);
}

.lpc-event.public {
  background: color-mix(in srgb, var(--cal-event-bg, var(--lpc-primary)) 15%, transparent);
  color: var(--cal-event-text, var(--cal-event-bg, var(--lpc-primary)));
  border: 1px solid color-mix(in srgb, var(--cal-event-bg, var(--lpc-primary)) 35%, transparent);
}

.lpc-event.private {
  background: #f3f4f6;
  color: #6b7280;
  cursor: default;
  border: 1px solid #e5e7eb;
}

.lpc-event.closed {
  background: #fef2f2;
  color: #dc2626;
  cursor: default;
  border: 1px solid #fecaca;
}

.lpc-more {
  font-size: 0.68rem;
  color: #6b7280;
  cursor: pointer;
  padding: 1px 4px;
}

.lpc-more:hover {
  text-decoration: underline;
}

/* ── List View ──────────────────────────────────────────────────────────── */
.lpc-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 480px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.lpc-list::-webkit-scrollbar {
  width: 6px;
}

.lpc-list::-webkit-scrollbar-thumb {
  background: var(--cal-border, #ccc);
  border-radius: 3px;
}

.lpc-list::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 600px) {
  .lpc-list {
    max-height: 360px;
  }
}

.lpc-list-item {
  display: flex;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  align-items: flex-start;
}

.lpc-list-item:hover {
  border-color: var(--cal-hover-bg, var(--lpc-primary));
  background: color-mix(in srgb, var(--cal-hover-bg, var(--lpc-primary)) 4%, transparent);
}

.lpc-list-item.private,
.lpc-list-item.closed {
  cursor: default;
  opacity: 0.7;
}

.lpc-list-item.private:hover,
.lpc-list-item.closed:hover {
  border-color: #e5e7eb;
  background: transparent;
}

.lpc-list-date {
  text-align: center;
  min-width: 46px;
  flex-shrink: 0;
}

.lpc-list-date-day {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--lpc-primary);
}

.lpc-list-date-month {
  font-size: 0.72rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.lpc-list-info {
  flex: 1;
  min-width: 0;
}

.lpc-list-title {
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lpc-list-time {
  font-size: 0.82rem;
  color: #6b7280;
  margin-bottom: 2px;
}

.lpc-list-address {
  font-size: 0.82rem;
  color: #6b7280;
}

.lpc-list-address a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: #d1d5db;
}

.lpc-list-address a:hover {
  color: var(--lpc-primary);
  text-decoration-color: var(--lpc-primary);
}

.lpc-list-item.blocked {
  opacity: 0.6;
  cursor: default;
}

.lpc-list-item.blocked:hover {
  border-color: #e5e7eb;
  background: transparent;
}

.lpc-list-blocked {
  color: var(--cal-past-day-color, #888);
  font-style: italic;
}

.lpc-empty {
  text-align: center;
  padding: 40px 20px;
  color: #9ca3af;
  font-size: 0.9rem;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.lpc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: lpc-fadein 0.15s ease;
}

@keyframes lpc-fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.lpc-modal {
  background: #fff;
  border-radius: 12px;
  max-width: 460px;
  width: 100%;
  padding: 24px;
  position: relative;
  z-index: 9999;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: lpc-slidein 0.18s ease;
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes lpc-slidein {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.lpc-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: #9ca3af;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
}

.lpc-modal-close:hover {
  color: #374151;
  background: #f3f4f6;
}

.lpc-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 12px;
  padding-right: 32px;
}

.lpc-modal-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  color: #4b5563;
  margin-bottom: 14px;
}

.lpc-modal-meta-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.lpc-modal-meta-icon {
  flex-shrink: 0;
  margin-top: 1px;
}

.lpc-modal-meta a {
  color: var(--lpc-primary);
  text-decoration: none;
}

.lpc-modal-meta a:hover {
  text-decoration: underline;
}

.lpc-modal-desc {
  font-size: 0.88rem;
  color: #374151;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.lpc-modal-divider {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 14px 0;
}

/* ── Loading / Error ─────────────────────────────────────────────────────── */
.lpc-loading {
  text-align: center;
  padding: 40px;
  color: #9ca3af;
}

.lpc-spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid #e5e7eb;
  border-top-color: var(--lpc-primary);
  border-radius: 50%;
  animation: lpc-spin 0.7s linear infinite;
  margin-bottom: 10px;
}

@keyframes lpc-spin {
  to { transform: rotate(360deg); }
}

.lpc-error {
  text-align: center;
  padding: 24px;
  color: #dc2626;
  font-size: 0.88rem;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 540px) {
  .lpc-day {
    min-height: 54px;
    padding: 3px;
  }

  .lpc-day-num {
    font-size: 0.7rem;
  }

  .lpc-event {
    font-size: 0;
    width: 8px;
    height: 8px;
    padding: 0;
    border-radius: 50%;
    display: inline-block;
    margin-right: 2px;
    margin-bottom: 2px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: clip;
    flex-shrink: 0;
  }

  .lpc-more {
    display: none;
  }

  .lpc-day.today .lpc-day-num {
    width: 20px;
    height: 20px;
    font-size: 0.68rem;
  }

  .lpc-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

:root {
  --cal-header-bg: #a22a3c;
  --cal-header-text: #ffffff;
  --cal-day-bg: #ffffff;
  --cal-day-border: #000000;
  --cal-today-bg: #a22a3c;
  --cal-event-bg: #a22a3c;
  --cal-event-text: #000000;
  --cal-past-day-color: #9ca3af;
  --cal-hover-bg: #e65b70;
}