/* ── Calendar page accent ───────────────────────────────────────────────── */
:root { --page-accent: #4DA6FF; }

/* ── Page layout ─────────────────────────────────────────────────────────── */
.cal-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem 0.5rem 5rem;
}

/* ── Month navigation ────────────────────────────────────────────────────── */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.25rem 1rem;
}

.cal-nav-btn {
  background: transparent;
  border: 1.5px solid rgba(77, 166, 255, 0.35);
  border-radius: 0.5rem;
  color: var(--page-accent);
  font-size: 1.4rem;
  min-width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
}
.cal-nav-btn:active { background: rgba(77, 166, 255, 0.15); }

.cal-month-label {
  font-family: 'Syne', sans-serif;
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--page-accent);
  margin: 0;
}

/* ── Day-of-week header ──────────────────────────────────────────────────── */
.cal-dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-family: 'Geist Mono', monospace;
  font-size: 0.65rem;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 0.3rem;
}

/* ── Calendar grid ───────────────────────────────────────────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

/* Day cell — entire cell is the tap target */
.cal-day {
  min-height: 72px;
  background: var(--bg-surface);
  border-radius: 0.4rem;
  padding: 0.3rem 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background 0.1s;
}
.cal-day:active { background: rgba(77, 166, 255, 0.15); }

.cal-day--other-month {
  opacity: 0.2;
  cursor: default;
  pointer-events: none;
}
.cal-day--today {
  background: rgba(77, 166, 255, 0.1);
  outline: 1.5px solid rgba(77, 166, 255, 0.5);
  outline-offset: -1px;
}
.cal-day--today:active { background: rgba(77, 166, 255, 0.22); }

.cal-day-num {
  font-family: 'Geist Mono', monospace;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1;
  margin-bottom: 0.25rem;
}
.cal-day--today .cal-day-num {
  color: var(--page-accent);
  font-weight: 700;
}

/* Event dots — compact visual indicators inside cells */
.cal-day-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: auto;
}
.cal-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cal-dot-more {
  font-family: 'Geist Mono', monospace;
  font-size: 0.52rem;
  color: var(--text-faint);
  line-height: 7px;
}

/* ── Device info row ─────────────────────────────────────────────────────── */
.cal-device-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0.25rem 0;
  font-family: 'Satoshi', sans-serif;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.cal-device-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  flex-shrink: 0;
}
.cal-device-name { font-weight: 600; color: var(--text-primary); }
.cal-device-change {
  background: transparent;
  border: none;
  color: var(--page-accent);
  font-family: 'Satoshi', sans-serif;
  font-size: 0.8rem;
  cursor: pointer;
  touch-action: manipulation;
  text-decoration: underline;
  padding: 0.25rem 0;
  margin-left: 0.25rem;
}

/* ── Modal overlay ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 7, 26, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.modal-overlay[hidden] { display: none; }

/* Sheet variant — anchored to bottom, slides up on mobile */
.modal-overlay--sheet {
  align-items: flex-end;
  padding: 0;
}
.modal-overlay--sheet .modal-card {
  border-radius: 1.25rem 1.25rem 0 0;
  border-bottom: none;
  max-width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
}
@media (min-width: 600px) {
  .modal-overlay--sheet { align-items: center; padding: 1rem; }
  .modal-overlay--sheet .modal-card {
    border-radius: 1rem;
    border: 1px solid rgba(77, 166, 255, 0.2);
    max-width: 440px;
    max-height: 72vh;
    padding-bottom: 1.5rem;
  }
}

.modal-card {
  background: var(--bg-elevated);
  border: 1px solid rgba(77, 166, 255, 0.2);
  border-radius: 1rem;
  padding: 1.5rem 1.25rem;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* ── Day view sheet content ──────────────────────────────────────────────── */
.day-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.day-view-title {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 900;
  color: var(--text-primary);
  margin: 0;
  flex: 1;
}
.day-view-close-btn {
  background: rgba(255,255,255,0.06);
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  width: 2.2rem;
  height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.day-view-close-btn:active { background: rgba(255,255,255,0.15); }

.day-view-events {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 32px;
}
.day-view-empty {
  font-family: 'Satoshi', sans-serif;
  font-size: 0.9rem;
  color: var(--text-faint);
  text-align: center;
  padding: 0.75rem 0 0.25rem;
  font-style: italic;
  margin: 0;
}

.day-view-event-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 0.625rem;
  padding: 0.8rem 0.9rem;
  cursor: pointer;
  touch-action: manipulation;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}
.day-view-event-item:active { background: rgba(77,166,255,0.1); }

.day-view-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}
.day-view-event-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.day-view-event-name {
  font-family: 'Satoshi', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.day-view-event-time {
  font-family: 'Geist Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-secondary);
}
.day-view-arrow {
  color: var(--text-faint);
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* ── Modal shared elements ───────────────────────────────────────────────── */
.modal-icon {
  font-size: 2rem;
  color: var(--page-accent);
  text-align: center;
}
.modal-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--text-primary);
  margin: 0;
  text-align: center;
}
.modal-sub {
  font-family: 'Satoshi', sans-serif;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-align: center;
  margin: 0;
  line-height: 1.5;
}
.modal-date-label {
  font-family: 'Geist Mono', monospace;
  font-size: 0.8rem;
  color: var(--page-accent);
  margin: 0;
  text-align: center;
}

.cal-text-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-surface);
  border: 1.5px solid rgba(77, 166, 255, 0.3);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-family: 'Satoshi', sans-serif;
  font-size: 1rem;
  padding: 0.75rem 0.9rem;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
.cal-text-input:focus { border-color: var(--page-accent); }

.cal-textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-surface);
  border: 1.5px solid rgba(77, 166, 255, 0.3);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-family: 'Satoshi', sans-serif;
  font-size: 0.95rem;
  line-height: 1.5;
  padding: 0.75rem 0.9rem;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
.cal-textarea:focus { border-color: var(--page-accent); }

/* ── Color palette (device setup) ────────────────────────────────────────── */
.color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  padding: 0.25rem 0;
}
.color-swatch {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s, border-color 0.15s;
  outline: none;
}
.color-swatch:active { transform: scale(1.15); }
.color-swatch.selected {
  border-color: #fff;
  transform: scale(1.12);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
}
.setup-color-label {
  font-family: 'Satoshi', sans-serif;
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-align: center;
  margin: 0;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.15rem;
}
.btn-cal-primary {
  font-family: 'Satoshi', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #07071A;
  background: var(--page-accent);
  border: none;
  border-radius: 0.625rem;
  padding: 0.8rem 1rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: opacity 0.12s;
}
.btn-cal-primary:active { opacity: 0.8; }
.btn-cal-primary:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-cal-cancel {
  font-family: 'Satoshi', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: 0.625rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
  transition: border-color 0.12s;
}
.btn-cal-cancel:active { border-color: rgba(255,255,255,0.3); }

.btn-cal-danger {
  font-family: 'Satoshi', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  background: transparent;
  border: 1.5px solid var(--neon-pink);
  border-radius: 0.625rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
  transition: background 0.12s, color 0.12s;
}
.btn-cal-danger:active { background: var(--neon-pink); color: #07071A; }

/* ── View event details ──────────────────────────────────────────────────── */
.view-event-color-bar {
  height: 5px;
  border-radius: 3px;
  margin-bottom: 0.1rem;
}
.view-event-meta {
  font-family: 'Geist Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin: 0;
  text-align: center;
}
.view-event-desc {
  font-family: 'Satoshi', sans-serif;
  font-size: 0.9rem;
  color: var(--text-primary);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

/* ── Larger screens ──────────────────────────────────────────────────────── */
@media (min-width: 600px) {
  .cal-day { min-height: 90px; }
  .cal-day-num { font-size: 0.8rem; }
  .cal-dot { width: 8px; height: 8px; }
  .cal-month-label { font-size: 1.4rem; }
  .cal-page { padding: 1.5rem 1rem 5rem; }
}
