@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700&display=swap');
body { font-family: 'Noto Sans TC', sans-serif; }

/* ── Skeleton shimmer ── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}

/* ── Progress bar ── */
#progress-bar-track { transition: opacity .3s; }
#progress-bar-fill  { transition: width .4s ease; }

/* ── FAB ── */
#fab {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  font-size: 1.75rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(37,99,235,.45);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  z-index: 50;
}
#fab:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(37,99,235,.55); }

/* ── Modal backdrop ── */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-bg.hidden {
  display: none !important;
}
.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  width: min(520px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

/* ── Toast ── */
#toast-container {
  position: fixed; bottom: 5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: .5rem;
  z-index: 200;
}
.toast {
  padding: .75rem 1.25rem;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  animation: slideIn .2s ease;
  min-width: 220px;
}
@keyframes slideIn {
  from { transform: translateX(60px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.toast-success { background: #dcfce7; color: #166534; }
.toast-error   { background: #fee2e2; color: #991b1b; }
.toast-info    { background: #dbeafe; color: #1e40af; }

/* ── Event card color strip ── */
.event-card { position: relative; padding-left: 14px; }
.event-card::before {
  content: '';
  position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 4px; border-radius: 4px;
}
.color-tomato::before    { background: #ef4444; }
.color-flamingo::before  { background: #f97316; }
.color-tangerine::before { background: #fb923c; }
.color-banana::before    { background: #eab308; }
.color-sage::before      { background: #84cc16; }
.color-basil::before     { background: #22c55e; }
.color-peacock::before   { background: #06b6d4; }
.color-blueberry::before { background: #3b82f6; }
.color-lavender::before  { background: #8b5cf6; }
.color-grape::before     { background: #a855f7; }
.color-graphite::before  { background: #6b7280; }
.color-default::before   { background: #2563eb; }

/* ── Color picker swatches ── */
.color-swatch {
  width: 28px; height: 28px; border-radius: 50%;
  cursor: pointer; border: 3px solid transparent;
  transition: border-color .15s;
}
.color-swatch.selected, .color-swatch:hover { border-color: #1e3a8a; }

/* ── Tooltip ── */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: #1e293b; color: #fff;
  font-size: .75rem; white-space: nowrap;
  padding: 4px 10px; border-radius: 6px;
  pointer-events: none; opacity: 0;
  transition: opacity .15s;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ── Minimum tap target ── */
button, [role=button] { min-height: 44px; min-width: 44px; }

/* ── Sync log ── */
#sync-log-body { max-height: 200px; overflow-y: auto; }

/* ── Autocomplete ── */
#autocomplete-list {
  position: absolute; left: 0; right: 0; top: 100%;
  background: #fff; border: 1px solid #e5e7eb;
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.1);
  z-index: 300; max-height: 220px; overflow-y: auto;
}
#autocomplete-list li {
  padding: .6rem 1rem; cursor: pointer; font-size: .9rem;
}
#autocomplete-list li:hover { background: #eff6ff; }

/* ════════════════════════════════════════════════════════════
   ── 30-Day Sliding Calendar View Styles ──
════════════════════════════════════════════════════════════ */

/* DOW header row */
.cal-dow-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: .75rem;
  color: #9ca3af;
  font-weight: 600;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: .4rem;
  margin-bottom: .3rem;
}

/* Calendar day grid – fills visible area */
.cal-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

/* Single day cell */
.cal-day {
  min-height: clamp(80px, 9vh, 130px);
  border: 1px solid #f0f0f0;
  border-radius: 6px;
  padding: 4px 5px 3px;
  font-size: .78rem;
  color: #374151;
  background: #fff;
  position: relative;
  overflow: hidden;
  transition: background .1s;
}
.cal-day:hover { background: #f8faff; }
.cal-day.cal-other-month {
  background: #f9fafb;
}
.cal-day.cal-other-month .cal-day-num { color: #d1d5db; }
.cal-day.cal-today {
  background: #eff6ff;
  border-color: #2563eb;
}
.cal-day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  font-size: .78rem;
  font-weight: 600;
  border-radius: 50%;
  margin-bottom: 2px;
}
.cal-day.cal-today .cal-day-num {
  background: #2563eb;
  color: #fff !important;
}
.cal-day.cal-sunday .cal-day-num  { color: #ef4444; }
.cal-day.cal-saturday .cal-day-num { color: #3b82f6; }

/* Event bar inside day cell */
.cal-ev-bar {
  display: block;
  font-size: .64rem;
  line-height: 1.35;
  border-radius: 3px;
  padding: 1px 5px;
  margin-top: 2px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  max-width: 100%;
}
.cal-ev-bar:hover { opacity: .82; }
.cal-ev-more {
  font-size: .6rem;
  color: #6b7280;
  padding-left: 3px;
  cursor: pointer;
}
.cal-ev-more:hover { color: #2563eb; }

/* Loading overlay */
#ov-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  font-size: .95rem;
  color: #6b7280;
  gap: .5rem;
}
/* Fix: CSS ID selector overrides .hidden class — must override explicitly */
#ov-loading.hidden {
  display: none !important;
}
.ov-spinner {
  width: 20px; height: 20px;
  border: 3px solid #e5e7eb;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive: large screens (1920px+) ── */
@media (min-width: 1920px) {
  #cal-overview-box { padding: 1.75rem; }
  .cal-day { min-height: 130px; font-size: .82rem; padding: 6px 7px 4px; }
  .cal-ev-bar { font-size: .7rem; padding: 2px 6px; margin-top: 3px; }
  .cal-day-num { width: 26px; height: 26px; font-size: .82rem; }
}

/* ── Responsive: mobile (≤640px) ── */
@media (max-width: 640px) {
  #calendar-overview-modal .modal-box,
  #cal-overview-box {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
    height: 100dvh !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  #calendar-overview-modal {
    align-items: flex-start;
  }
  #cal-overview-box > div:first-child {
    padding-right: max(1.25rem, env(safe-area-inset-right, 0px)) !important;
  }
  .cal-day { min-height: 60px; font-size: .7rem; padding: 3px 3px 2px; }
  .cal-day-num { width: 18px; height: 18px; font-size: .7rem; }
  .cal-ev-bar { font-size: .58rem; padding: 1px 3px; }
  .cal-days-grid { gap: 2px; }
}

/* ── Protect nav buttons from Android edge-swipe gesture zone (≤1024px) ── */
@media (max-width: 1024px) {
  #cal-overview-box > div:first-child {
    padding-right: max(1.25rem, env(safe-area-inset-right, 0px));
  }
}


/* ── Scrollbar hide utility (for tab bar) ── */
.scrollbar-hide { scrollbar-width: none; -ms-overflow-style: none; }
.scrollbar-hide::-webkit-scrollbar { display: none; }

/* ── Week view: taller cells so the single row fills the same vertical space as a month grid ── */
.cal-days-grid.week-view .cal-day {
  min-height: clamp(300px, 50vh, 600px);
}
@media (min-width: 1920px) {
  .cal-days-grid.week-view .cal-day { min-height: 480px; }
}
@media (max-width: 640px) {
  .cal-days-grid.week-view .cal-day { min-height: 200px; }
}

#ov-view-menu button:active { background: #eff6ff; }

/* ── Calendar Overview Search Panel ── */
.ov-search-panel {
  margin: 0 0 0.75rem;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #f8faff;
  overflow: hidden;
}
.ov-search-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0.875rem;
  background: #eff6ff;
  border-bottom: 1px solid #bfdbfe;
}
.ov-search-close {
  color: #9ca3af;
  font-size: 0.9rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color .15s, background .15s;
}
.ov-search-close:hover { color: #374151; background: #e5e7eb; }
.ov-search-body {
  padding: 0.75rem 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.ov-search-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.ov-search-label {
  font-size: 0.75rem;
  color: #6b7280;
  font-weight: 500;
  width: 3.5rem;
  flex-shrink: 0;
  text-align: right;
}
.ov-search-input {
  flex: 1;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.8rem;
  background: #fff;
  color: #374151;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.ov-search-input:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 2px rgba(59,130,246,.15);
}
.ov-date-input { cursor: pointer; }
.ov-search-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem 0.75rem;
}
.ov-search-btn-reset {
  font-size: 0.8rem;
  color: #6b7280;
  padding: 5px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  transition: background .15s;
}
.ov-search-btn-reset:hover { background: #f9fafb; }
.ov-search-btn-go {
  font-size: 0.8rem;
  color: #1d4ed8;
  padding: 5px 16px;
  border: 1px solid #93c5fd;
  border-radius: 6px;
  background: #eff6ff;
  cursor: pointer;
  font-weight: 600;
  transition: background .15s;
}
.ov-search-btn-go:hover { background: #dbeafe; }

/* Search Results */
.ov-search-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.875rem;
  background: #f1f5f9;
  border-top: 1px solid #e5e7eb;
}
.ov-search-results-list {
  max-height: 240px;
  overflow-y: auto;
  padding: 0.375rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.ov-search-result-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  border: 1px solid transparent;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.ov-search-result-item:hover {
  border-color: #bfdbfe;
  background: #eff6ff;
}
.ov-result-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ov-result-body {
  flex: 1;
  min-width: 0;
}
.ov-result-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ov-result-loc {
  font-size: 0.7rem;
  color: #9ca3af;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ov-result-actions {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}
.ov-result-time {
  font-size: 0.7rem;
  color: #2563eb;
  background: #eff6ff;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  white-space: nowrap;
}
.ov-result-edit-btn {
  color: #d1d5db;
  font-size: 0.8rem;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color .15s;
}
.ov-result-edit-btn:hover { color: #3b82f6; }
.ov-search-mark {
  background: #fef08a;
  color: #92400e;
  border-radius: 2px;
  padding: 0 1px;
}

@media (max-width: 640px) {
  .ov-search-label { width: 2.75rem; font-size: 0.7rem; }
  .ov-search-input { font-size: 0.75rem; }
  .ov-search-results-list { max-height: 180px; }
}