:root {
  --bg: #f7f3ed;
  --bg-card: #fffcf7;
  --text: #3d4543;
  --text-muted: #7a8481;
  --accent: #8ba888;
  --accent-soft: #dce8da;
  --line: #e8e2d8;
  --shadow: 0 8px 32px rgba(61, 69, 67, 0.06);
  --radius: 16px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

[data-theme="blue"] {
  --bg: #eef2f5;
  --bg-card: #f8fafb;
  --accent: #7a96ab;
  --accent-soft: #d5e2eb;
  --line: #d8e0e6;
}

[data-font="large"] {
  font-size: 17px;
}

[data-quiet="1"] * {
  animation: none !important;
  transition-duration: 0.05s !important;
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image: radial-gradient(circle at 20% 10%, rgba(196, 168, 130, 0.08), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(155, 181, 201, 0.1), transparent 35%);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 72px;
}

.app-header {
  padding: 20px 20px 12px;
}

.brand h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.header-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.quiet-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.app-main {
  flex: 1;
  padding: 0 16px 24px;
}

.page { display: none; }
.page.active { display: block; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.hint, .muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.status-bar strong {
  color: var(--accent);
}

.task-slots {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-card {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.task-card.done {
  opacity: 0.65;
}

.task-card.done h3 {
  text-decoration: line-through;
}

.task-check {
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 0.85rem;
}

.task-card.done .task-check {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.task-body h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 500;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text-muted);
}

.tag.energy {
  border-color: var(--c, var(--line));
  color: var(--text);
}

.task-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.empty-slots {
  text-align: center;
  padding: 32px 16px;
  background: var(--bg-card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.empty-slots p { margin: 0 0 8px; }

.templates-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 20px;
}

.template-chip {
  flex: 0 0 auto;
  min-width: 140px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-card);
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.template-chip strong {
  font-size: 0.9rem;
}

.template-chip span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s, opacity 0.15s;
}

.btn:active { transform: scale(0.98); }

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.secondary {
  background: var(--accent-soft);
  color: var(--text);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.btn.block { width: 100%; }
.btn.small { padding: 6px 12px; font-size: 0.8rem; }
.btn.danger { color: #a65; border-color: #dcc; }

.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
  padding: 2px 6px;
}

.icon-btn.muted { color: var(--text-muted); }
.icon-btn.fav-on { color: #c4a882; }
.icon-btn:disabled { opacity: 0.3; cursor: default; }

.library-filters { margin-bottom: 14px; }

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.filter-chip {
  border: 1px solid var(--line);
  background: var(--bg-card);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
}

.filter-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-card {
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.activity-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.cat-badge {
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.activity-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.activity-card .desc {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.activity-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.activity-actions {
  display: flex;
  gap: 8px;
}

.activity-actions .btn { flex: 1; }

.review-block, .review-form {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.review-list {
  margin: 8px 0 0;
  padding-left: 18px;
  line-height: 1.6;
}

.review-form label {
  display: block;
  margin: 12px 0 6px;
  font-size: 0.9rem;
}

.review-form textarea,
.review-form input[type="text"],
#add-task-form input,
#add-task-form select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
}

.mood-row {
  display: flex;
  gap: 12px;
  font-size: 1.4rem;
}

.mood-row label { cursor: pointer; margin: 0; }

.quiet-card {
  background: linear-gradient(145deg, var(--bg-card), var(--accent-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 12px;
}

.card-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0 0 4px;
}

.quiet-card h3 { margin: 0 0 16px; }

.card-section {
  margin-bottom: 12px;
}

.card-section span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-section p { margin: 4px 0 0; }

.card-footer {
  margin: 16px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.stats-panel {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  text-align: center;
}

.stat-num {
  display: block;
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--accent);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.energy-chart { margin-top: 16px; }

.bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 60px;
  margin-top: 8px;
}

.bar {
  flex: 1;
  min-height: 8px;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  opacity: 0.7;
}

.settings-group {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.settings-group h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.option-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.option-btn {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.82rem;
  cursor: pointer;
}

.option-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 252, 247, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 100;
}

[data-theme="blue"] .bottom-nav {
  background: rgba(248, 250, 251, 0.92);
}

.nav-item {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px;
  font-size: 0.7rem;
  color: var(--text-muted);
  cursor: pointer;
}

.nav-item.active {
  color: var(--accent);
}

.nav-icon { font-size: 1.1rem; }

.overlay, .timer-overlay, .modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
}

.overlay.active, .timer-overlay.active, .modal.active {
  display: flex;
}

.onboard-card {
  margin: auto;
  max-width: 360px;
  padding: 28px 24px;
  background: var(--bg-card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.onboard-card h2 { margin-top: 0; }

.onboard-card ul {
  padding-left: 18px;
  line-height: 1.7;
  color: var(--text-muted);
}

.overlay {
  background: rgba(61, 69, 67, 0.35);
  padding: 20px;
}

.timer-overlay {
  background: var(--bg);
  align-items: center;
  justify-content: center;
  text-align: center;
}

.timer-inner { padding: 24px; width: 100%; max-width: 360px; }

.timer-display {
  font-size: 4rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  margin: 20px 0;
  font-variant-numeric: tabular-nums;
}

.timer-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  min-height: 1.4em;
  margin-bottom: 24px;
}

.timer-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal {
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(61, 69, 67, 0.3);
}

.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-sheet h3 { margin: 0 0 8px; }

#add-task-form label {
  display: block;
  margin: 10px 0 4px;
  font-size: 0.85rem;
}

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(61, 69, 67, 0.88);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 300;
  max-width: 90%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.section-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 12px 0 8px;
}

.optional-tasks { margin-top: 8px; }

@media (min-width: 481px) {
  .bottom-nav {
    border-radius: 16px 16px 0 0;
  }
}
