:root { color-scheme: light dark; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, #1e3a8a, #7c3aed);
  color: #fff;
  min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: rgba(20, 20, 40, 0.85);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255,255,255,0.12);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 40;
}
.nav-btn {
  flex: 1;
  background: none;
  border: none;
  color: rgba(255,255,255,0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 0 8px;
  font-size: 0.68rem;
  cursor: pointer;
}
.nav-btn .nav-icon { font-size: 1.25rem; }
.nav-btn.active { color: #fff; }

.options-card {
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 16px;
  padding: 16px;
}
.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9rem;
  margin: 12px 0;
}
.option-row select, .option-row input {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  width: 130px;
  font-family: inherit;
}
.option-row select option { color: #111; }
.option-hint { font-size: 0.75rem; opacity: 0.6; margin: 0; }

.full-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #1e3a8a, #7c3aed);
  z-index: 100;
  overflow-y: auto;
}

.auth-box {
  width: 100%;
  max-width: 360px;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
}
.auth-logo { font-size: 1.6rem; margin: 0 0 4px; }
.auth-sub { font-size: 0.8rem; opacity: 0.7; margin: 0 0 20px; }

.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-tab {
  flex: 1;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  padding: 8px;
  border-radius: 10px;
  font-size: 0.85rem;
  cursor: pointer;
}
.auth-tab.active { background: rgba(255,255,255,0.9); color: #1e3a8a; font-weight: 600; }

.auth-form { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.auth-form input {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  padding: 10px 12px;
  color: #fff;
  font-size: 0.9rem;
  font-family: inherit;
}
.auth-form input::placeholder { color: rgba(255,255,255,0.5); }
.auth-submit { width: 100%; padding: 10px; }

.auth-error {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.4);
  color: #fecaca;
  font-size: 0.8rem;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.group-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
}
.group-item:hover { background: rgba(255,255,255,0.12); }
.group-item .g-name { font-weight: 600; }
.group-item .g-meta { font-size: 0.72rem; opacity: 0.65; margin-top: 2px; }
.group-item .g-arrow { opacity: 0.5; }
.group-empty-hint { font-size: 0.8rem; opacity: 0.55; padding: 8px 0; }

.option-divider { height: 1px; background: rgba(255,255,255,0.12); margin: 16px 0; }
.option-static { font-size: 0.82rem; opacity: 0.8; }

.topbar-left { display: flex; align-items: center; gap: 10px; }
.group-chip {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) 20px 12px;
}
.topbar h1 { font-size: 1.4rem; margin: 0; }

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.calendar-card, .day-panel, .pomodoro-card {
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 16px;
  padding: 16px;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.month-label { font-weight: 600; font-size: 1.1rem; }

.cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.view-toggle { display: flex; gap: 6px; }
.view-btn {
  border: 1px solid rgba(255,255,255,0.25);
  background: transparent;
  color: #fff;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  cursor: pointer;
}
.view-btn.active { background: rgba(255,255,255,0.9); color: #1e3a8a; font-weight: 600; }
.collapse-btn {
  padding: 5px 10px;
  font-size: 0.75rem;
  transition: transform 0.2s;
}
.collapse-btn.collapsed { transform: rotate(180deg); }

#calendarBody.collapsed { display: none; }

.lunar-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  opacity: 0.8;
  margin-bottom: 10px;
  cursor: pointer;
  width: fit-content;
}
.lunar-toggle input { accent-color: #fff; cursor: pointer; }

.cal-day .lunar-label {
  font-size: 0.48rem;
  opacity: 0.6;
  line-height: 1;
}
.day-list-date .lunar { font-size: 0.6rem; opacity: 0.55; display: block; }

.day-list-view { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; }
.day-list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  cursor: pointer;
}
.day-list-row.today { background: rgba(255,255,255,0.14); }
.day-list-row.has-items { background: rgba(255,255,255,0.09); }
.day-list-date {
  width: 44px;
  flex-shrink: 0;
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.2;
}
.day-list-date .dow { font-size: 0.65rem; opacity: 0.7; display: block; }
.day-list-row.sunday .day-list-date, .day-list-row.holiday .day-list-date { color: #f87171; }
.day-list-row.saturday .day-list-date { color: #60a5fa; }
.day-list-info { flex: 1; min-width: 0; }
.day-list-info .holiday-name { font-size: 0.72rem; color: #f87171; }
.day-list-info .sched-titles { font-size: 0.78rem; opacity: 0.85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-list-info .empty { font-size: 0.75rem; opacity: 0.35; }
.day-list-study { font-size: 0.72rem; opacity: 0.75; flex-shrink: 0; text-align: right; }

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.75rem;
  opacity: 0.7;
  margin-bottom: 6px;
}
.weekdays .wd-sun { color: #f87171; }
.weekdays .wd-sat { color: #60a5fa; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}
.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 0.85rem;
  cursor: pointer;
  position: relative;
  background: rgba(255,255,255,0.04);
}
.cal-day.other-month { opacity: 0.3; }
.cal-day.today { border: 1px solid rgba(255,255,255,0.6); }
.cal-day.selected { background: rgba(255,255,255,0.25); }
.cal-day.sunday { color: #f87171; }
.cal-day.saturday { color: #60a5fa; }
.cal-day.holiday { color: #f87171; }
.cal-day .dot-row { display: flex; gap: 2px; margin-top: 2px; }
.cal-day .dot { width: 4px; height: 4px; border-radius: 50%; background: #fbbf24; }
.cal-day .study-bar { position: absolute; bottom: 5px; left: 8px; right: 8px; height: 3px; border-radius: 2px; background: rgba(74,222,128,0.7); }
.cal-day .span-underline { position: absolute; bottom: 1px; left: 2px; right: 2px; height: 2px; border-radius: 1px; background: #fbbf24; }
.cal-day .holiday-label {
  font-size: 0.48rem;
  opacity: 0.85;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1;
  text-align: center;
}

.day-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.day-panel-header h2 { font-size: 1rem; margin: 0; opacity: 0.9; }

.schedule-list { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.schedule-item {
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}
.schedule-item .time { font-size: 0.75rem; opacity: 0.7; }
.schedule-item .title { font-weight: 600; margin-top: 2px; }
.owner-badge {
  margin-top: 4px;
  align-self: flex-start;
  font-size: 0.7rem;
  opacity: 0.8;
  background: rgba(255,255,255,0.1);
  padding: 2px 8px;
  border-radius: 999px;
}
.empty-hint { font-size: 0.8rem; opacity: 0.5; padding: 8px 0; }

.pomodoro-card { text-align: center; }
.pomo-display { font-size: 2.6rem; font-weight: 700; margin: 12px 0; font-variant-numeric: tabular-nums; }
.pomo-controls { display: flex; gap: 8px; justify-content: center; margin-bottom: 12px; }
.pomo-modes { display: flex; gap: 8px; justify-content: center; margin-bottom: 12px; }
.mode-btn {
  border: 1px solid rgba(255,255,255,0.25);
  background: transparent;
  color: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
}
.mode-btn.active { background: rgba(255,255,255,0.25); }
.pomo-today { font-size: 0.85rem; opacity: 0.8; }

.category-tabs { display: flex; gap: 8px; justify-content: center; margin-bottom: 8px; }
.cat-btn {
  border: 1px solid rgba(255,255,255,0.25);
  background: transparent;
  color: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
}
.cat-btn.active { background: rgba(255,255,255,0.9); color: #1e3a8a; font-weight: 600; }

.pomo-phase-label {
  font-size: 0.85rem;
  opacity: 0.75;
  letter-spacing: 0.02em;
}

.pomo-slider-group { margin: 10px 0 4px; display: flex; flex-direction: column; gap: 8px; }
.pomo-slider-row { display: flex; align-items: center; gap: 10px; }
.pomo-slider-tag { font-size: 0.78rem; width: 56px; text-align: left; opacity: 0.85; flex-shrink: 0; }
.pomo-slider-val { font-size: 0.78rem; width: 34px; text-align: right; opacity: 0.85; flex-shrink: 0; }
.pomo-slider {
  flex: 1;
  accent-color: #fff;
}
.pomo-slider:disabled { opacity: 0.4; }

.day-study-summary {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 0.85rem;
}
.day-study-summary .chip {
  background: rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 8px 12px;
  flex: 1;
  text-align: center;
}
.day-study-summary .chip .num { font-size: 1.2rem; font-weight: 700; display: block; }
.day-study-summary .chip .lbl { font-size: 0.7rem; opacity: 0.7; }

button { font-family: inherit; }
.primary-btn {
  background: #fff;
  color: #1e3a8a;
  border: none;
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}
.ghost-btn {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  cursor: pointer;
}
.danger-btn {
  background: rgba(239,68,68,0.2);
  color: #fecaca;
  border: 1px solid rgba(239,68,68,0.4);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  cursor: pointer;
  margin-right: auto;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #1e293b;
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal h3 { margin: 0 0 6px; }
.modal label { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; opacity: 0.85; }
.modal input, .modal textarea {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 8px 10px;
  color: #fff;
  font-size: 0.9rem;
  font-family: inherit;
}
.modal textarea { min-height: 50px; resize: vertical; }
.notify-toggle-row {
  flex-direction: row !important;
  align-items: center;
  justify-content: space-between;
}
.notify-toggle-row input { accent-color: #fff; width: 18px; height: 18px; }
.modal label.notify-disabled input#fNotify,
#fNotify:disabled { opacity: 0.4; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
