:root {
  --purple-deep: #2D1B4E;
  --purple: #5B2C8E;
  --purple-light: #8B5FC7;
  --gold: #C9A84C;
  --gold-glow: rgba(201, 168, 76, 0.15);
  --bg: #F5F0EB;
  --card: #FFFFFF;
  --text: #2C2C2C;
  --text-secondary: #6B6B6B;
  --border: #E8E0D8;
  --check-bg: #F0EBE3;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ========== HEADER ========== */

header {
  background: linear-gradient(135deg, var(--purple-deep) 0%, #3D2066 100%);
  color: #fff;
  padding: 24px 16px 16px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.subtitle {
  font-size: 0.82rem;
  opacity: 0.65;
  margin-top: 2px;
}

.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
}

.date-nav button {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.date-nav button:active {
  background: rgba(255, 255, 255, 0.25);
}

.date-nav button:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.date-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 180px;
}

#current-date {
  font-size: 1.05rem;
  font-weight: 600;
}

#lent-day {
  font-size: 0.78rem;
  opacity: 0.6;
  margin-top: 2px;
}

.today-indicator {
  background: var(--gold);
  color: var(--purple-deep);
  padding: 2px 12px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: 0.3px;
}

#today-btn {
  background: var(--gold);
  color: var(--purple-deep);
  border: none;
  padding: 5px 18px;
  border-radius: 14px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 10px;
  letter-spacing: 0.3px;
  transition: opacity 0.15s;
}

#today-btn:active {
  opacity: 0.8;
}

/* ========== PROGRESS ========== */

.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.progress-bar {
  flex: 1;
  height: 5px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 3px;
  transition: width 0.35s ease;
  width: 0;
}

#progress-text {
  font-size: 0.78rem;
  opacity: 0.7;
  min-width: 36px;
  text-align: right;
}

/* ========== MAIN ========== */

main {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 40px;
}

/* ========== CATEGORY ========== */

.category {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}

.category-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.category-header h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--purple);
}

/* ========== ITEM ROW ========== */

.item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--border);
  -webkit-user-select: none;
  user-select: none;
}

.item:last-child {
  border-bottom: none;
}

.item:active {
  background: var(--check-bg);
}

.item.checked {
  background: var(--gold-glow);
}

/* ========== CHECKBOX ========== */

.item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  min-width: 26px;
  border: 2.5px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  margin-top: 1px;
  transition: all 0.2s;
  position: relative;
  background: transparent;
}

.item input[type="checkbox"]:checked {
  background: var(--gold);
  border-color: var(--gold);
}

.item input[type="checkbox"]:checked::after {
  content: '\2713';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

/* ========== ITEM TEXT ========== */

.item-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.item-label {
  font-size: 0.92rem;
  line-height: 1.4;
  transition: opacity 0.2s;
}

.item.checked .item-label {
  opacity: 0.55;
}

.item-hint {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.weekly-badge {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--purple-light);
  margin-top: 2px;
  font-weight: 500;
}

.weekly-badge.complete {
  color: var(--gold);
  font-weight: 700;
}

/* ========== EXPANDABLE DETAILS ========== */

.details-toggle {
  background: none;
  border: none;
  color: var(--purple-light);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 4px 0 0;
  text-align: left;
  font-weight: 500;
}

.details-toggle:active {
  opacity: 0.7;
}

.item-details {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.6;
  padding: 6px 0 2px;
}

.item-details p {
  margin-bottom: 4px;
}

/* ========== MESSAGE ========== */

.message {
  text-align: center;
  color: var(--text-secondary);
  padding: 48px 16px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.all-done {
  text-align: center;
  padding: 20px 16px 8px;
  font-size: 0.95rem;
  color: var(--gold);
  font-weight: 600;
}

/* ========== NOTES ========== */

.notes-section {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 14px;
  padding: 13px 16px 16px;
}

.notes-label {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 8px;
}

.notes-textarea {
  width: 100%;
  min-height: 80px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  resize: vertical;
  transition: border-color 0.15s;
}

.notes-textarea::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

.notes-textarea:focus {
  outline: none;
  border-color: var(--purple-light);
}

/* ========== ACCOUNT ========== */

.account-section-wrapper {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

.account-toggle {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--purple-light);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 14px 0;
  text-align: center;
}

.account-toggle:active {
  opacity: 0.7;
}

.account-form-container {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.account-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.15s;
}

.account-input:focus {
  outline: none;
  border-color: var(--purple-light);
}

.account-btn {
  width: 100%;
  padding: 11px 16px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--purple);
  color: #fff;
  transition: opacity 0.15s;
}

.account-btn:active {
  opacity: 0.85;
}

.account-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sign-out-btn {
  background: none;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.82rem;
  padding: 6px 0;
}

.account-switch {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--purple-light);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0 0;
  text-align: center;
}

.account-switch:active {
  opacity: 0.7;
}

.account-error {
  background: #fef2f2;
  color: #b91c1c;
  font-size: 0.82rem;
  padding: 8px 12px;
  border-radius: 6px;
  line-height: 1.4;
}

.account-info {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 8px 0 4px;
}

.account-success {
  background: #f0fdf4;
  color: #166534;
  font-size: 0.82rem;
  padding: 8px 12px;
  border-radius: 6px;
  line-height: 1.4;
}

.reset-heading {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--purple);
  text-align: center;
  padding-bottom: 4px;
}

.forgot-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.forgot-container[hidden] {
  display: none;
}

/* ========== SETTINGS ========== */

.settings-section-wrapper {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px;
}

.settings-toggle {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--purple-light);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 14px 0 6px;
  text-align: center;
}

.settings-toggle:active {
  opacity: 0.7;
}

.settings-panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px 0;
  margin-top: 8px;
  margin-bottom: 8px;
}

.settings-category {
  padding: 4px 0;
}

.settings-category + .settings-category {
  border-top: 1px solid var(--border);
}

.settings-category-header {
  padding: 10px 16px 4px;
  font-size: 0.85rem;
  color: var(--purple);
}

.settings-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.settings-item:active {
  background: var(--check-bg);
}

.settings-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 40px;
  height: 22px;
  min-width: 40px;
  background: var(--border);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  border: none;
}

.settings-item input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.settings-item input[type="checkbox"]:checked {
  background: var(--gold);
}

.settings-item input[type="checkbox"]:checked::after {
  transform: translateX(18px);
}

.settings-item-label {
  font-size: 0.88rem;
  line-height: 1.3;
  flex: 1;
}

.settings-optional-badge {
  display: inline-block;
  font-size: 0.68rem;
  color: var(--purple-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ========== FOOTER ========== */

footer {
  text-align: center;
  padding: 0 16px 32px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  opacity: 0.6;
}

footer a {
  color: inherit;
}

/* ========== RESPONSIVE ========== */

@media (min-width: 600px) {
  header {
    padding: 28px 24px 20px;
  }

  main {
    padding: 24px;
    padding-bottom: 48px;
  }
}
