/* a brick. — calming, neurodivergent-friendly design */

:root {
  --bg: #f5f0eb;
  --bg-card: #ffffff;
  --bg-sidebar: #ebe4dc;
  --text: #3d3a36;
  --text-muted: #7a756e;
  --accent: #7eb8da;
  --accent-soft: #c5e0f0;
  --accent-hover: #5a9fc9;
  --success: #8fbc8f;
  --success-soft: #d4ead4;
  --border: #ddd6cc;
  --shadow: rgba(61, 58, 54, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Nunito', system-ui, sans-serif;
}

[data-theme="sunset"] {
  --bg: #fdf6f0;
  --bg-card: #fffaf5;
  --bg-sidebar: #f5e8dc;
  --text: #4a3f38;
  --text-muted: #8a7a6e;
  --accent: #e8a87c;
  --accent-soft: #f5d5bc;
  --accent-hover: #d4895a;
  --success: #c38d9e;
  --success-soft: #e8cdd5;
  --border: #e8ddd2;
}

[data-theme="forest"] {
  --bg: #f0f4f0;
  --bg-card: #f8fbf8;
  --bg-sidebar: #dce8dc;
  --text: #2d3b2d;
  --text-muted: #6b7a6b;
  --accent: #6b9b7a;
  --accent-soft: #b8d4be;
  --accent-hover: #4f8260;
  --success: #8fbc8f;
  --success-soft: #d4ead4;
  --border: #cdd8cd;
}

[data-theme="lavender"] {
  --bg: #f5f2f8;
  --bg-card: #faf8fc;
  --bg-sidebar: #e8e0f0;
  --text: #3d3648;
  --text-muted: #7a728a;
  --accent: #9b8ec4;
  --accent-soft: #d4cce8;
  --accent-hover: #7a6aad;
  --success: #a8c4a8;
  --success-soft: #dce8dc;
  --border: #ddd6e8;
}

[data-theme="night"] {
  --bg: #1e1e24;
  --bg-card: #2a2a32;
  --bg-sidebar: #24242c;
  --text: #e8e6e3;
  --text-muted: #a09a94;
  --accent: #7eb8da;
  --accent-soft: #3a5060;
  --accent-hover: #9ccce8;
  --success: #6b9b7a;
  --success-soft: #2a4030;
  --border: #3a3a44;
  --shadow: rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  transition: background 0.4s ease, color 0.4s ease;
}

.hidden { display: none !important; }

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.points-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent-soft);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: 1.1rem;
}

.points-icon {
  color: var(--accent);
}

/* Buttons */
.btn {
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}

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

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

.btn-primary:hover { background: var(--accent-hover); }

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

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

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover { color: var(--text); background: var(--bg-sidebar); }

.btn-icon {
  background: var(--bg-sidebar);
  border: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-icon:hover { background: var(--accent-soft); }

/* Layout */
.main {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  max-width: 1200px;
  margin: 0 auto;
  min-height: calc(100vh - 80px);
}

.sidebar {
  background: var(--bg-sidebar);
  padding: 1.5rem;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.section-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.75rem;
}

/* Pet */
.pet-display {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--shadow);
}

.pet-sprite {
  font-size: 4.5rem;
  animation: pet-idle 3s ease-in-out infinite;
}

.pet-sprite.happy { animation: pet-bounce 0.6s ease; }

@keyframes pet-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes pet-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-12px) scale(1.08); }
  70% { transform: translateY(-4px) scale(1.02); }
}

.pet-message {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  min-height: 2.5em;
}

/* Progress chart */
.progress-area canvas {
  width: 100%;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
}

.progress-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.stat {
  text-align: center;
  background: var(--bg-card);
  padding: 0.6rem;
  border-radius: var(--radius-sm);
}

.stat-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Content */
.content {
  padding: 1.5rem 2rem;
}

.sections-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.section-tab {
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 6px var(--shadow);
}

.section-tab:hover { border-color: var(--accent-soft); }

.section-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.section-tab .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
}

.tasks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.tasks-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
}

/* Task list */
.task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: 0 2px 8px var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  border-left: 4px solid var(--accent);
}

.task-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--shadow);
}

.task-item.completed {
  opacity: 0.75;
  border-left-color: var(--success);
}

.task-item.completed .task-name {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-check {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 3px solid var(--border);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

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

.task-item.completed .task-check {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.task-info {
  flex: 1;
  min-width: 0;
}

.task-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.task-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.task-points {
  font-weight: 800;
  color: var(--accent);
  font-size: 0.95rem;
  white-space: nowrap;
}

.task-actions {
  display: flex;
  gap: 0.25rem;
}

.task-actions button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 6px;
  opacity: 0.5;
  font-size: 0.9rem;
  transition: opacity 0.2s, background 0.2s;
}

.task-actions button:hover {
  opacity: 1;
  background: var(--bg-sidebar);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
  font-size: 1.05rem;
}

/* Modals */
.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px var(--shadow);
  background: var(--bg-card);
  color: var(--text);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
}

.modal-wide { max-width: 520px; }

.modal form,
.settings-content {
  padding: 1.75rem;
}

.modal h3 {
  font-size: 1.3rem;
  margin-bottom: 1.25rem;
}

.modal label {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
}

.modal input[type="text"],
.modal input[type="number"],
.modal select {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.7rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
}

.modal input:focus,
.modal select:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* Color picker */
.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.color-swatch {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.15s;
}

.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: var(--text); }

/* Theme grid */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.theme-option {
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 3px solid transparent;
  cursor: pointer;
  text-align: center;
  font-weight: 700;
  font-size: 0.85rem;
  transition: border-color 0.2s, transform 0.15s;
}

.theme-option:hover { transform: scale(1.03); }
.theme-option.selected { border-color: var(--accent); }

.theme-option[data-theme="calm"] { background: #c5e0f0; color: #3d3a36; }
.theme-option[data-theme="sunset"] { background: #f5d5bc; color: #4a3f38; }
.theme-option[data-theme="forest"] { background: #b8d4be; color: #2d3b2d; }
.theme-option[data-theme="lavender"] { background: #d4cce8; color: #3d3648; }
.theme-option[data-theme="night"] { background: #2a2a32; color: #e8e6e3; }
.theme-option[data-theme="brick"] { background: #d4a574; color: #3d2f24; }

[data-theme="brick"] {
  --bg: #f7f0e8;
  --bg-card: #fff8f0;
  --bg-sidebar: #ede0d0;
  --text: #3d2f24;
  --text-muted: #8a7560;
  --accent: #c4784a;
  --accent-soft: #e8c9a8;
  --accent-hover: #a85f32;
  --success: #8fbc8f;
  --success-soft: #d4ead4;
  --border: #ddd0c0;
}

/* Pet picker */
.pet-picker {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.pet-option {
  flex: 1;
  min-width: 100px;
  padding: 1rem;
  background: var(--bg);
  border: 3px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, transform 0.15s;
}

.pet-option:hover { transform: scale(1.03); }
.pet-option.selected { border-color: var(--accent); }

.pet-option-icon { font-size: 2.5rem; display: block; margin-bottom: 0.4rem; }
.pet-option-name { font-weight: 700; font-size: 0.85rem; }

/* Section manage */
.settings-group {
  margin-bottom: 1.5rem;
}

.settings-group h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.section-manage-list {
  list-style: none;
  margin-bottom: 0.75rem;
}

.section-manage-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.section-manage-item .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.section-manage-item span { flex: 1; font-weight: 600; }

.section-manage-item button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  opacity: 0.6;
  font-size: 0.85rem;
}

.section-manage-item button:hover {
  opacity: 1;
  background: var(--bg-sidebar);
}

/* Welcome overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.welcome-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2.5rem;
  max-width: 440px;
  width: 90%;
  text-align: center;
  box-shadow: 0 24px 80px var(--shadow);
}

.welcome-pet {
  font-size: 5rem;
  margin-bottom: 1rem;
  animation: pet-idle 2s ease-in-out infinite;
}

.welcome-card h2 {
  font-size: 1.6rem;
  margin-bottom: 0.75rem;
  color: var(--accent);
}

.welcome-card p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 1.05rem;
  line-height: 1.6;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 1rem 1.75rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 8px 30px var(--shadow);
  z-index: 50;
  animation: toast-in 0.4s ease;
  max-width: 90%;
  text-align: center;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
  .main {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
  }

  .pet-area, .progress-area {
    flex: 1;
    min-width: 200px;
  }

  .header {
    padding: 1rem;
  }

  .content {
    padding: 1rem;
  }
}

/* Header nav */
.header-nav {
  display: flex;
  gap: 0.35rem;
  background: var(--bg-sidebar);
  padding: 0.3rem;
  border-radius: 999px;
}

.nav-tab {
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.45rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.nav-tab:hover { color: var(--text); }
.nav-tab.active { background: var(--bg-card); color: var(--accent); box-shadow: 0 2px 6px var(--shadow); }

/* Pet care */
.pet-care-bars {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.care-bar-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 0.2rem;
}

.care-bar-track {
  height: 8px;
  background: var(--bg-card);
  border-radius: 999px;
  overflow: hidden;
}

.care-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s ease;
}

.care-bar-fill.happiness { background: var(--accent); }
.care-bar-fill.energy { background: var(--success); }

.pet-mood {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
}

/* Task types */
.task-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.task-type-icon {
  font-size: 1.4rem;
  width: 2rem;
  text-align: center;
  flex-shrink: 0;
}

.task-type-badge {
  font-weight: 700;
}

.task-preview {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

.task-item.task-type-group {
  flex-direction: column;
  align-items: stretch;
}

.subtask-list {
  list-style: none;
  margin: 0.75rem 0 0 3rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.subtask-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.subtask-item.completed .subtask-name {
  text-decoration: line-through;
  color: var(--text-muted);
}

.subtask-check {
  width: 1.5rem;
  height: 1.5rem;
  font-size: 0.75rem;
}

.subtask-name {
  font-size: 0.95rem;
  font-weight: 600;
}

.group-progress {
  margin-left: 3rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
}

/* Subtask editor */
.subtask-editor {
  list-style: none;
  margin: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.subtask-edit-item {
  display: flex;
  gap: 0.5rem;
}

.subtask-edit-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

.subtask-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.5;
  padding: 0.3rem 0.5rem;
}

.subtask-remove-btn:hover { opacity: 1; }

.subtask-edit-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
}

.task-type-fields {
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
  margin-top: 0.25rem;
}

.label-hint {
  font-weight: 400;
  opacity: 0.7;
}

.modal-hint {
  color: var(--text-muted);
  margin: -0.5rem 0 1rem;
  font-size: 0.95rem;
}

.modal textarea {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.7rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  min-height: 120px;
}

.modal textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-error {
  color: #c45;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.settings-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.backup-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.import-label {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.lock-status {
  background: var(--accent-soft);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

/* Log view */
.log-view {
  max-width: 800px;
  grid-template-columns: 1fr;
}

.log-content {
  padding: 1.5rem 2rem;
  width: 100%;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.log-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
}

.log-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

.log-header-actions {
  display: flex;
  gap: 0.5rem;
}

.log-entries {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.log-entry {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 2px 8px var(--shadow);
}

.log-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.log-entry-header time {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.log-entry-actions button {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.5;
  padding: 0.25rem 0.4rem;
}

.log-entry-actions button:hover { opacity: 1; }

.log-entry-body {
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 768px) {
  .header { flex-wrap: wrap; gap: 0.75rem; }
  .header-nav { order: 3; width: 100%; justify-content: center; }
}
