:root {
  --bg: #f5f0eb;
  --bg-gradient: linear-gradient(165deg, #f5f0eb 0%, #ebe4dc 50%, #f0e8e0 100%);
  --card: rgba(255,255,255,0.85);
  --card-border: rgba(255,255,255,0.5);
  --primary: #7c9a92;
  --primary-dark: #5d7d75;
  --primary-light: #e8f0ee;
  --primary-glow: rgba(124,154,146,0.15);
  --accent: #d4a574;
  --accent-dark: #c08e5a;
  --accent-light: #f5ede4;
  --accent-glow: rgba(212,165,116,0.15);
  --purple: #a88dc8;
  --purple-light: #ede8f5;
  --green: #8db580;
  --green-light: #e8f5e8;
  --danger: #d18e8e;
  --danger-light: #f8eeee;
  --text: #3d3d3d;
  --text-secondary: #8a8a8a;
  --text-muted: #b8b0a8;
  --border: rgba(0,0,0,0.06);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow: 0 4px 20px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.08);
  --shadow-hover: 0 8px 30px rgba(0,0,0,0.12);
  --transition: 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-linear: 0.2s ease;
}

/* ── Tool theme variables ── */
[data-theme="decompose"] { --theme: var(--primary); --theme-light: var(--primary-light); --theme-glow: var(--primary-glow); }
[data-theme="timer"] { --theme: var(--accent); --theme-light: var(--accent-light); --theme-glow: var(--accent-glow); }
[data-theme="braindump"] { --theme: var(--purple); --theme-light: var(--purple-light); }
[data-theme="todo"] { --theme: var(--green); --theme-light: var(--green-light); }

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg-gradient);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0;
}

/* ── Layout ── */
.container {
  max-width: 520px;
  margin: 0 auto;
  padding: 28px 16px 80px;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  padding-top: 8px;
}

.page-header h1 { font-size: 1.35rem; font-weight: 700; }

/* ── Back button ── */
.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  background: var(--card);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--card-border);
}
.back-btn:hover { transform: scale(1.1) translateX(-2px); box-shadow: var(--shadow); }
.back-btn:active { transform: scale(0.92); }

/* ── Cards ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 14px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  transition: box-shadow var(--transition-linear);
}

/* ── Home page ── */
.home-top {
  text-align: center;
  padding: 16px 0 24px;
}

.home-avatar {
  font-size: 2.8rem;
  margin-bottom: 4px;
  display: block;
}

.home-greeting {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
  font-weight: 500;
}

.home-title {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.2;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.home-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

.tool-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tool-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  text-decoration: none;
  color: var(--text);
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  position: relative;
  overflow: hidden;
}

.tool-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 0 2px 2px 0;
  transition: width var(--transition);
}

.tool-card.decompose-card::before { background: var(--primary); }
.tool-card.timer-card::before { background: var(--accent); }
.tool-card.braindump-card::before { background: var(--purple); }
.tool-card.todo-card::before { background: var(--green); }

.tool-card:hover {
  transform: translateY(-3px) scale(1.01);
  box-shadow: var(--shadow-hover);
}

.tool-card:hover::before { width: 6px; }

.tool-card:active { transform: scale(0.98) translateY(0); }

.tool-icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  transition: transform var(--transition);
}

.tool-card:hover .tool-icon { transform: scale(1.08) rotate(-3deg); }

.tool-icon.decompose-icon { background: var(--primary-light); }
.tool-icon.timer-icon { background: var(--accent-light); }
.tool-icon.braindump-icon { background: var(--purple-light); }
.tool-icon.todo-icon { background: var(--green-light); }

.tool-info { flex: 1; min-width: 0; }
.tool-name { font-weight: 700; font-size: 1rem; margin-bottom: 1px; }
.tool-desc { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.4; }

.tool-arrow {
  font-size: 1.1rem;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--transition);
}

.tool-card:hover .tool-arrow {
  transform: translateX(4px);
  color: var(--text-secondary);
}

/* ── Tool cards (inside tool pages) ── */
.card-soft {
  background: linear-gradient(135deg, var(--theme-light) 0%, var(--card) 60%);
  border: 1px solid var(--card-border);
}

/* ── Forms ── */
input, textarea {
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  width: 100%;
  transition: border-color var(--transition-linear), box-shadow var(--transition-linear);
  outline: none;
}

input:focus, textarea:focus {
  border-color: var(--theme, var(--primary));
  box-shadow: 0 0 0 4px var(--theme-glow, var(--primary-glow));
  background: white;
}

textarea {
  resize: vertical;
  min-height: 140px;
  line-height: 1.6;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition-linear);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}

.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: linear-gradient(135deg, var(--theme, var(--primary)) 0%, var(--theme, var(--primary-dark)) 100%);
  color: white;
  box-shadow: 0 4px 14px var(--theme-glow, var(--primary-glow));
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--theme-glow, var(--primary-glow));
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.btn-accent:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 20px var(--accent-glow); }

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #c47a7a 100%);
  color: white;
}
.btn-danger:hover:not(:disabled) { transform: translateY(-2px); }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 2px solid var(--border);
  box-shadow: none;
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--text-muted);
  color: var(--text);
  background: rgba(0,0,0,0.02);
  transform: translateY(-1px);
}

.btn-sm { padding: 10px 16px; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* ── Special: The Big Button (ADHD: make it hard to miss) ── */
.btn-big {
  font-size: 1.1rem;
  padding: 18px 32px;
  border-radius: var(--radius);
  letter-spacing: 0.3px;
}

/* ── Utility ── */
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); font-size: 0.9rem; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-sm { gap: 8px; }
.gap-md { gap: 12px; }

/* ── Section title ── */
.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.section-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ── Timer ── */
.timer-display {
  text-align: center;
  padding: 20px 0 8px;
}

.timer-circle {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto;
}

.timer-circle svg {
  transform: rotate(-90deg);
  filter: drop-shadow(0 0 20px var(--accent-glow));
}

.timer-circle-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 6;
}

.timer-circle-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

.timer-circle-progress.running {
  stroke: var(--accent);
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

.timer-circle-progress.done {
  stroke: var(--green);
  filter: drop-shadow(0 0 12px rgba(141,181,128,0.5));
}

.timer-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.timer-number {
  font-size: 3.2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 3px;
  font-variant-numeric: tabular-nums;
  transition: color 0.3s ease;
}

.timer-number.running { color: var(--accent-dark); }
.timer-number.done { color: var(--green); }

.timer-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 6px;
  font-weight: 500;
}

.timer-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
}

.timer-controls .btn {
  min-width: 100px;
}

/* ── Mode switch ── */
.mode-switch {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.mode-btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.mode-btn.active {
  background: white;
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.mode-btn:hover:not(.active) { color: var(--text); }

/* ── Decompose ── */
.step-list { list-style: none; }

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  transition: opacity var(--transition-linear);
}

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

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all var(--transition);
}

.step-item.done .step-number {
  background: var(--green-light);
  color: var(--green);
}

.step-text {
  flex: 1;
  font-size: 0.92rem;
  line-height: 1.5;
  transition: color var(--transition-linear);
}

.step-item.done .step-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.step-checkbox {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  -webkit-appearance: none;
  appearance: none;
  position: relative;
}

.step-checkbox:checked {
  background: var(--green);
  border-color: var(--green);
  animation: pop 0.3s ease;
}

.step-checkbox:checked::after {
  content: '✓';
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ── Braindump ── */
.dump-counter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 16px;
}

.dump-stat {
  text-align: center;
}

.dump-stat-number {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.dump-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.dump-history { margin-top: 16px; }

.dump-entry {
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 0.88rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  border-left: 3px solid var(--purple);
}

.dump-entry-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Todo ── */
.todo-input-row {
  display: flex;
  gap: 8px;
}

.todo-input-row input { flex: 1; }

.todo-list { list-style: none; }

.todo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  transition: opacity var(--transition-linear);
}

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

.todo-check {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.todo-check:checked {
  background: var(--green);
  border-color: var(--green);
  animation: pop 0.3s ease;
}

.todo-check:checked::after {
  content: '✓';
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
}

.todo-text {
  flex: 1;
  font-size: 0.95rem;
  transition: color var(--transition-linear);
}

.todo-item.done .todo-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.todo-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  transition: all var(--transition-linear);
  opacity: 0.3;
  border-radius: 6px;
}

.todo-item:hover .todo-delete { opacity: 1; }
.todo-delete:hover {
  color: var(--danger);
  background: var(--danger-light);
  opacity: 1;
}

.todo-limit-hint {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.8rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

.todo-empty {
  text-align: center;
  padding: 40px 0;
}

.todo-empty-icon { font-size: 3rem; margin-bottom: 12px; display: block; }
.todo-empty-text { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }

.todo-archived { margin-top: 20px; }

.todo-archived-header {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
  user-select: none;
  padding: 4px 0;
  transition: color var(--transition-linear);
}

.todo-archived-header:hover { color: var(--text-secondary); }
.todo-archived-header .arrow { transition: transform var(--transition); }
.todo-archived-header.open .arrow { transform: rotate(90deg); }

.todo-archived-list {
  margin-top: 12px;
  display: none;
}

.todo-archived-list.open { display: block; }

.todo-celebration {
  text-align: center;
  padding: 32px 16px;
  animation: fadeIn 0.5s ease;
}

.todo-celebration-icon { font-size: 3.5rem; display: block; margin-bottom: 12px; }
.todo-celebration-text { font-size: 1.2rem; font-weight: 700; color: var(--green); margin-bottom: 4px; }
.todo-celebration-sub { font-size: 0.85rem; color: var(--text-secondary); }

/* ── Celebration overlay ── */
.celebration-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: confettiFall var(--duration, 3s) ease-out forwards;
  opacity: 0;
}

@keyframes confettiFall {
  0% {
    transform: translateY(-20px) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg) scale(0.3);
    opacity: 0;
  }
}

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

@keyframes pulse-soft {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

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

@keyframes sparkle {
  0%, 100% { opacity: 0; transform: scale(0) rotate(0deg); }
  50% { opacity: 1; transform: scale(1) rotate(180deg); }
}

@keyframes bounceIn {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

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

.fade-in { animation: fadeIn 0.4s ease both; }
.fade-in-up { animation: fadeInUp 0.5s ease both; }
.bounce-in { animation: bounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.slide-up { animation: slideUp 0.3s ease both; }
.pulse-soft { animation: pulse-soft 2s ease-in-out infinite; }
.float { animation: float 3s ease-in-out infinite; }

/* ── Star decorations ── */
.star-deco {
  position: fixed;
  pointer-events: none;
  font-size: 0.6rem;
  color: var(--text-muted);
  opacity: 0.3;
  animation: float 4s ease-in-out infinite;
}

/* ── Footer ── */
.footer-note {
  text-align: center;
  margin-top: 48px;
  padding: 16px 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--border);
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .container { padding: 20px 14px 60px; }
  .home-title { font-size: 1.5rem; }
  .timer-circle { width: 180px; height: 180px; }
  .timer-number { font-size: 2.6rem; }
  .tool-card { padding: 14px 16px; gap: 14px; }
  .tool-icon { width: 44px; height: 44px; font-size: 1.3rem; }
  .card { padding: 20px; }
  .page-header h1 { font-size: 1.2rem; }
  .mode-btn { font-size: 0.8rem; padding: 10px 10px; }
}

@media (max-width: 380px) {
  .container { padding: 16px 12px 48px; }
  .tool-icon { width: 40px; height: 40px; font-size: 1.1rem; }
  .timer-circle { width: 150px; height: 150px; }
  .timer-number { font-size: 2.2rem; }
}
