@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

:root {
  --bg: #f6f2ec;
  --bg-card: #ffffff;
  --bg-hover: #ede8e0;
  --bg-elevated: #ffffff;
  --text-primary: #2d2a24;
  --text-secondary: #8c867e;
  --text-tertiary: #b8b1a7;
  --border: #e8e1d9;
  --border-light: #f0ebe3;
  --primary: #1e3a5f;
  --primary-light: #eef2f7;
  --primary-mid: #d4dfed;
  --accent: #c9775e;
  --accent-light: #faf0ec;
  --accent-mid: #f0d6cc;
  --success: #6b8f71;
  --success-light: #eef5ef;
  --success-mid: #d4e3d7;
  --danger: #c45a5a;
  --danger-light: #fdf0f0;
  --gold: #d4a84a;
  --gold-light: #faf3e2;
  --shadow-sm: 0 1px 3px rgba(45,42,36,0.06), 0 1px 2px rgba(45,42,36,0.04);
  --shadow-md: 0 4px 12px rgba(45,42,36,0.08), 0 2px 4px rgba(45,42,36,0.04);
  --shadow-lg: 0 8px 24px rgba(45,42,36,0.10), 0 4px 8px rgba(45,42,36,0.04);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  margin: 0;
}

/* nav */
.nav-bar {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px) saturate(1.2);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 1.25rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.nav-logo i { color: var(--primary); font-size: 1.1rem; }
.nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.nav-link {
  color: var(--text-tertiary);
  text-decoration: none;
  font-size: 1.05rem;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-link:hover { color: var(--text-primary); }
.nav-link.logout:hover { color: var(--danger); }

/* main */
.main-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* flash messages */
.flash-container {
  margin-bottom: 16px;
}
.flash-message {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: flashIn 0.35s ease;
  margin-bottom: 8px;
}
.flash-message.error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #f0d0d0;
}
.flash-message.success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid #d4e3d7;
}
@keyframes flashIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* page headings */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.flex { display: flex; }
.items-center { align-items: center; }
.gap-3 { gap: 12px; }
.shrink-0 { flex-shrink: 0; }
.page-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.5rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-title i { color: var(--primary); font-size: 1.3rem; }

/* view toggle */
.view-toggle {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}
.view-btn {
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 0.95rem;
}
.view-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* card */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.25s, transform 0.2s;
}
.card:hover { box-shadow: var(--shadow-md); }

/* button primary */
.btn-primary {
  background: var(--primary);
  color: #fff;
  padding: 10px 22px;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 2px 6px rgba(30,58,95,0.15);
}
.btn-primary:hover {
  background: #152d4a;
  box-shadow: 0 4px 12px rgba(30,58,95,0.2);
}
.btn-primary:active { transform: scale(0.97); }

/* button secondary */
.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-secondary);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}
.btn-secondary:hover { background: #dfd8ce; color: var(--text-primary); }

/* button ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-tertiary);
  border: none;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.2s, color 0.2s;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

/* button icon */
.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  font-size: 0.9rem;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

/* input */
.input-field {
  width: 100%;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--bg-card);
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: 'DM Sans', sans-serif;
  outline: none;
}
.input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,58,95,0.08);
}
.input-field::placeholder { color: var(--text-tertiary); }

select.input-field {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238c867e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

textarea.input-field { resize: vertical; min-height: 100px; }

/* label */
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* schedule item */
.schedule-list { display: flex; flex-direction: column; gap: 6px; }

.schedule-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  cursor: default;
  transition: all 0.25s ease;
  animation: fadeUp 0.3s ease both;
}
.schedule-item:nth-child(1) { animation-delay: 0s; }
.schedule-item:nth-child(2) { animation-delay: 0.04s; }
.schedule-item:nth-child(3) { animation-delay: 0.08s; }
.schedule-item:nth-child(4) { animation-delay: 0.12s; }
.schedule-item:nth-child(5) { animation-delay: 0.16s; }
.schedule-item:nth-child(6) { animation-delay: 0.20s; }
.schedule-item:nth-child(7) { animation-delay: 0.24s; }
.schedule-item:nth-child(8) { animation-delay: 0.28s; }

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

.schedule-item:hover { border-color: #ddd5ca; box-shadow: var(--shadow-sm); }
.schedule-item.past { opacity: 0.55; }
.schedule-item.completed { opacity: 0.45; }

/* checkbox */
.checkbox-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  flex-shrink: 0;
  position: relative;
}
.checkbox-btn:hover { border-color: var(--accent); }
.checkbox-btn.checked {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox-btn.checked i {
  color: #fff;
  font-size: 0.6rem;
  animation: checkPop 0.25s ease;
}
@keyframes checkPop {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.checkbox-btn input { position: absolute; opacity: 0; width: 0; height: 0; }

/* schedule info */
.schedule-info {
  flex: 1;
  min-width: 0;
}
.schedule-info a { text-decoration: none; color: inherit; }
.schedule-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.schedule-meta {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.schedule-meta span { display: inline-flex; align-items: center; gap: 3px; }

/* tags */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.tag-repeat { background: var(--primary-light); color: var(--primary); }
.tag-daily { background: var(--accent-light); color: var(--accent); }
.tag-weekdays { background: var(--success-light); color: var(--success); }
.tag-bell { color: var(--gold); }

/* schedule actions */
.schedule-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-state i {
  font-size: 3.5rem;
  color: var(--border);
  margin-bottom: 16px;
}
.empty-state p {
  color: var(--text-tertiary);
  font-size: 0.9rem;
}

/* completed section */
.completed-section { margin-top: 40px; }
.completed-heading {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.completed-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  opacity: 0.45;
}
.completed-item i { color: var(--success); font-size: 0.8rem; }
.completed-item .schedule-title {
  font-size: 0.85rem;
  text-decoration: line-through;
  color: var(--text-tertiary);
}
.completed-item .schedule-meta { color: var(--text-tertiary); opacity: 0.6; }

/* form section */
.form-section {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.form-section h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.05rem;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { margin-bottom: 14px; }

/* ai parse box */
.ai-box {
  background: var(--primary-light);
  border: 1px solid var(--primary-mid);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
}
.ai-box h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.05rem;
  color: var(--text-primary);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-box textarea {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--primary-mid);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-primary);
  background: #fff;
  resize: vertical;
  min-height: 100px;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: border-color 0.2s;
}
.ai-box textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,58,95,0.06); }
.ai-box textarea::placeholder { color: var(--text-tertiary); }
.ai-parse-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  padding: 6px 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background 0.2s;
}
.ai-parse-btn:hover { background: #152d4a; }
.ai-parse-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ai-box .input-wrap { position: relative; }
.ai-status {
  margin-top: 10px;
  font-size: 0.85rem;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
.ai-status.loading { display: flex; color: var(--primary); }
.ai-status.error { display: flex; color: var(--danger); background: var(--danger-light); }
.ai-status.success { display: flex; color: var(--success); background: var(--success-light); }
.ai-status.hint { display: flex; color: var(--text-tertiary); font-size: 0.8rem; background: transparent; padding: 4px 0; }

/* detail page */
.detail-card { margin-bottom: 16px; }
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.detail-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.4rem;
  color: var(--text-primary);
  line-height: 1.3;
}
.detail-sub {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.detail-status {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
}
.detail-status.active { background: var(--primary-light); color: var(--primary); }
.detail-status.completed { background: var(--success-light); color: var(--success); }
.detail-status.cancelled { background: var(--bg-hover); color: var(--text-tertiary); }

.detail-divider { border: none; border-top: 1px solid var(--border-light); margin: 20px 0; }

.detail-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  padding: 6px 0;
}
.detail-row .label {
  color: var(--text-tertiary);
  width: 80px;
  flex-shrink: 0;
}
.detail-row .value { color: var(--text-primary); }

.detail-actions {
  display: flex;
  gap: 8px;
  padding-top: 4px;
}

/* notification log */
.notif-list { margin-top: 16px; }
.notif-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.85rem;
}
.notif-item:last-child { border-bottom: none; }
.notif-item .left { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); }
.notif-item .left i { color: var(--text-tertiary); }
.notif-status {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}
.notif-status.sent { background: var(--success-light); color: var(--success); }
.notif-status.failed { background: var(--danger-light); color: var(--danger); }

/* repeat selectors */
.repeat-weekdays {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.repeat-weekday-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
  user-select: none;
}
.repeat-weekday-label:hover { border-color: var(--primary); color: var(--primary); }
.repeat-weekday-label input { position: absolute; opacity: 0; width: 0; height: 0; }
.repeat-weekday-label:has(input:checked) {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* checkbox toggle */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.toggle-track {
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: var(--border);
  position: relative;
  transition: background 0.25s;
  flex-shrink: 0;
}
.toggle-track:has(input:checked) { background: var(--accent); }
.toggle-track input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.25s ease;
}
.toggle-track:has(input:checked) .toggle-knob { transform: translateX(18px); }
.toggle-label {
  font-size: 0.9rem;
  color: var(--text-primary);
}

/* password field */
.password-wrap { position: relative; }
.password-wrap .input-field { padding-right: 40px; }
.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  font-size: 0.9rem;
}
.password-toggle:hover { color: var(--text-primary); }

/* back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-tertiary);
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 16px;
  transition: color 0.2s;
}
.back-link:hover { color: var(--text-primary); }

/* number input compact */
.input-number {
  width: 80px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}
.input-number:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,58,95,0.08); }

/* login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-icon {
  font-size: 2.8rem;
  color: var(--primary);
  margin-bottom: 12px;
}
.login-heading {
  font-family: 'DM Serif Display', serif;
  font-size: 1.6rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.login-sub {
  font-size: 0.9rem;
  color: var(--text-tertiary);
  margin-bottom: 28px;
}

/* auth pages (register, forgot, reset) */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.auth-container {
  width: 100%;
  max-width: 400px;
}
.auth-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  padding: 40px 36px 32px;
}
.auth-header {
  text-align: center;
  margin-bottom: 28px;
}
.auth-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  font-size: 1.4rem;
  color: var(--primary);
}
.auth-header h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.5rem;
  color: var(--text-primary);
  margin: 0 0 4px;
}
.auth-header p {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  margin: 0;
}
.auth-form .form-group {
  margin-bottom: 16px;
}
.auth-form .form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.auth-form .form-group label i {
  margin-right: 4px;
}
.auth-form .form-group input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-card);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.auth-form .form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,58,95,0.08);
}
.auth-form .form-group input::placeholder {
  color: var(--text-tertiary);
}
.auth-btn {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
  padding: 12px 22px;
  font-size: 0.9rem;
}
.auth-footer {
  text-align: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.auth-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
.auth-footer a:hover {
   text-decoration: underline;
 }

/* toast notifications */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 14px 18px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 400px;
  animation: toastIn 0.35s ease;
}
.toast.error { border-left: 3px solid var(--danger); }
.toast.success { border-left: 3px solid var(--success); }
.toast.info { border-left: 3px solid var(--primary); }
.toast i { font-size: 1rem; flex-shrink: 0; }
.toast.error i { color: var(--danger); }
.toast.success i { color: var(--success); }
.toast.info i { color: var(--primary); }
.toast-close {
  margin-left: auto;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 0.8rem;
  background: none;
  border: none;
  padding: 2px;
  flex-shrink: 0;
}
.toast-close:hover { color: var(--text-primary); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
.toast-out {
  animation: toastOut 0.3s ease forwards;
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* week calendar */
.cal-container {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.cal-week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
}
.cal-nav-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.cal-nav-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 0.8rem;
  transition: background 0.15s;
}
.cal-nav-btn:hover { background: var(--bg-hover); }
.cal-week-range {
  font-family: 'DM Serif Display', serif;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin: 0 8px;
  white-space: nowrap;
}
.cal-today-btn {
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-primary);
  font-weight: 500;
  transition: background 0.15s;
}
.cal-today-btn:hover { background: var(--bg-hover); }
.cal-date-input {
  width: 0;
  height: 0;
  opacity: 0;
  position: absolute;
  pointer-events: none;
}

/* week grid */
.cal-week-grid {
  display: flex;
  gap: 6px;
  padding: 16px 20px 12px;
  justify-content: center;
}
.cal-wday {
  flex: 1;
  max-width: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
}
.cal-wday:hover { background: var(--bg-hover); }
.cal-wday-sel {
  background: var(--primary-light) !important;
  border-color: var(--primary);
}
.cal-wday-today {
  background: var(--primary) !important;
  border-color: var(--primary);
  color: #fff;
}
.cal-wday-today:hover { background: #1a3355 !important; }
.cal-wday-name {
  font-size: 0.65rem;
  color: var(--text-tertiary);
  font-weight: 600;
  margin-bottom: 1px;
}
.cal-wday-today .cal-wday-name { color: rgba(255,255,255,0.7); }
.cal-wday-num {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}
.cal-wday-today .cal-wday-num { color: #fff; }
.cal-wday-count {
  font-size: 0.6rem;
  color: var(--accent);
  margin-top: 3px;
  font-weight: 600;
}
.cal-wday-today .cal-wday-count { color: rgba(255,255,255,0.8); }

/* day schedules panel */
.cal-day-schedules {
  padding: 0 20px 16px;
}
.cal-day-head {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  padding-top: 4px;
  border-top: 1px solid var(--border-light);
  padding: 12px 0 8px;
}
.cal-day-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.15s;
}
.cal-day-item:hover { background: var(--bg-hover); }
.cal-day-time {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  min-width: 48px;
}
.cal-day-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  text-decoration: none;
}
.cal-day-title:visited { color: var(--text-primary); }
.cal-day-bell {
  color: var(--gold);
  font-size: 0.7rem;
  flex-shrink: 0;
}
.cal-check-form {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.cal-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--primary-mid);
  background: var(--bg-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
}
.cal-checkbox:hover { border-color: var(--primary); }
.cal-checked-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cal-checked-icon i { color: #fff; font-size: 0.6rem; }
.cal-day-done .cal-day-title {
  color: var(--text-tertiary);
  text-decoration: line-through;
}
.cal-day-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  text-decoration: none;
  min-width: 0;
}
.cal-detail-empty {
  text-align: center;
  padding: 24px 20px;
  color: var(--text-tertiary);
  font-size: 0.85rem;
}

/* repeat type badges */
.schedule-rtype { display: flex; align-items: center; flex-shrink: 0; }
.rtype-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.rtype-badge.daily { background: #e8f5e9; color: #2e7d32; }
.rtype-badge.weekdays { background: #e3f2fd; color: #1565c0; }
.rtype-badge.weekly { background: #fce4ec; color: #c62828; }
.rtype-badge.monthly { background: #f3e5f5; color: #6a1b9a; }
.rtype-badge.custom { background: #fff3e0; color: #e65100; }
.rtype-badge.once { background: #f5f5f5; color: #616161; }

/* completed section */
.completed-section { margin-top: 32px; }
.section-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.completed-list { display: flex; flex-direction: column; gap: 4px; }
.completed-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.completed-item:hover { background: var(--bg-hover); }
.completed-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.completed-icon i { color: #fff; font-size: 0.7rem; }
.completed-info { display: flex; align-items: center; gap: 12px; flex: 1; text-decoration: none; min-width: 0; }
.completed-title { font-size: 0.85rem; color: var(--text-tertiary); text-decoration: line-through; }
.completed-meta { font-size: 0.75rem; color: var(--text-tertiary); opacity: 0.6; }
.completed-more { text-align: center; padding: 8px 0; }
.completed-reuse { flex-shrink: 0; margin-left: auto; }
.completed-reuse .btn-icon { color: var(--text-tertiary); }
.completed-reuse .btn-icon:hover { color: var(--primary); }

/* responsive */
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .main-wrap { padding: 20px 16px 40px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .schedule-item { padding: 12px 14px; }
  .detail-header { flex-direction: column; }
  .cal-wday { flex: 1; min-width: 0; padding: 8px 2px 10px; }
  .cal-wday-num { font-size: 0.95rem; }
  .cal-week-grid { padding: 12px 12px 8px; gap: 4px; }
  .cal-day-schedules { padding: 0 12px 12px; }
  .cal-week-nav { padding: 10px 12px; }
}