:root {
  --bg: #e4ebe6;
  --bg2: #d5e0d9;
  --ink: #1e2c26;
  --muted: #5a6d64;
  --accent: #b87333;
  --accent-soft: rgba(184, 115, 51, 0.18);
  --accent-ink: #fff8f0;
  --flame: #e8a54b;
  --wick: #3d4f46;
  --dot-off: rgba(30, 44, 38, 0.14);
  --dot-on: #b87333;
  --line: rgba(30, 44, 38, 0.12);
  --surface: rgba(255, 255, 255, 0.55);
  --font: "Figtree", system-ui, sans-serif;
  --display: "Fraunces", "Figtree", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 70% 55% at 85% 5%, rgba(232, 165, 75, 0.28), transparent 55%),
    radial-gradient(ellipse 55% 45% at 5% 90%, rgba(90, 130, 110, 0.22), transparent 50%),
    linear-gradient(168deg, var(--bg), var(--bg2));
}
.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  pointer-events: none;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  background: rgba(228, 235, 230, 0.72);
}
.brand {
  font-family: var(--display);
  font-weight: 700;
  font-variation-settings: "SOFT" 50, "WONK" 0;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
  font-size: 1.15rem;
}
.top nav { display: flex; gap: 0.75rem; align-items: center; }
.top nav a:not(.btn) { color: var(--muted); text-decoration: none; font-size: 0.95rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  text-decoration: none;
  font: inherit;
  font-weight: 600;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.btn.buy {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 18px rgba(184, 115, 51, 0.28);
}
.btn.buy:hover { transform: translateY(-1px); }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.hero {
  min-height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 1.5rem 4rem;
  max-width: 42rem;
  position: relative;
}
.wick-plane {
  position: absolute;
  right: -2rem;
  top: 18%;
  width: min(42vw, 280px);
  height: min(55vh, 420px);
  pointer-events: none;
  opacity: 0.9;
}
.wick-plane svg { width: 100%; height: 100%; }
.flame-glow {
  transform-origin: 50% 85%;
  animation: breathe 3.6s ease-in-out infinite;
}
.flame-tip {
  animation: flicker 2.4s ease-in-out infinite;
  transform-origin: 50% 100%;
}
@keyframes breathe {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.06); }
}
@keyframes flicker {
  0%, 100% { transform: scaleY(1) translateX(0); }
  30% { transform: scaleY(1.05) translateX(1px); }
  60% { transform: scaleY(0.96) translateX(-1px); }
}

.brand-hero {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.6rem, 9vw, 4.4rem);
  letter-spacing: -0.035em;
  margin: 0 0 1rem;
  line-height: 0.95;
  font-variation-settings: "SOFT" 60, "WONK" 0;
}
.hero h1 {
  font-size: clamp(1.2rem, 2.8vw, 1.55rem);
  font-weight: 600;
  margin: 0 0 0.75rem;
  max-width: 24ch;
}
.lede { color: var(--muted); margin: 0 0 1.75rem; max-width: 34ch; }
.cta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.strip {
  padding: 2.5rem 1.5rem 3rem;
  border-top: 1px solid var(--line);
  max-width: 40rem;
}
.strip h2 {
  font-family: var(--display);
  margin: 0 0 1rem;
  font-weight: 650;
}
.strip ul { margin: 0; padding-left: 1.1rem; color: var(--muted); }
.strip li { margin-bottom: 0.4rem; }

.foot {
  padding: 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}
.foot a { color: var(--accent); }

/* ——— App ——— */
.app-body .atmosphere {
  background:
    radial-gradient(ellipse 50% 40% at 90% 0%, rgba(232, 165, 75, 0.2), transparent 55%),
    radial-gradient(ellipse 40% 35% at 0% 100%, rgba(90, 130, 110, 0.18), transparent 50%),
    linear-gradient(168deg, var(--bg), var(--bg2));
}

.workspace {
  max-width: 34rem;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}
.status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge.on {
  background: rgba(61, 79, 70, 0.14);
  color: var(--wick);
}

.add-row {
  display: flex;
  gap: 0.55rem;
}
.add-row input {
  flex: 1;
  min-width: 0;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}
input, textarea, select {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.habit-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.habit {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.95rem 1rem 1.05rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem 0.9rem;
  align-items: start;
  animation: rise-in 0.35s ease both;
}
@keyframes rise-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.check {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  flex-shrink: 0;
  padding: 0;
  color: transparent;
}
.check:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.check.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 4px 14px rgba(184, 115, 51, 0.35);
}
.check svg { width: 1.1rem; height: 1.1rem; }

.habit-body { min-width: 0; }
.habit-name {
  font-family: var(--display);
  font-weight: 650;
  font-size: 1.1rem;
  margin: 0 0 0.15rem;
  letter-spacing: -0.02em;
}
.streak {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 0.65rem;
}
.streak strong { color: var(--accent); font-weight: 700; }

.dots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  align-items: center;
}
.dots-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  width: 1.6rem;
  flex-shrink: 0;
}
.dot {
  width: 0.52rem;
  height: 0.52rem;
  border-radius: 50%;
  background: var(--dot-off);
}
.dot.lit {
  background: var(--dot-on);
  box-shadow: 0 0 6px rgba(232, 165, 75, 0.55);
}
.dot-row {
  display: flex;
  align-items: center;
  gap: 0.28rem;
  width: 100%;
  margin-bottom: 0.28rem;
}
.dot-row:last-child { margin-bottom: 0; }

.habit-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}
.remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  padding: 0.2rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.remove:hover { color: var(--ink); }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 2rem 1rem;
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.28);
}

.packs {
  border-top: 1px solid var(--line);
  padding-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.packs h2 {
  font-family: var(--display);
  font-size: 1.15rem;
  margin: 0;
  font-weight: 650;
}
.packs p.hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.pack-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.pack {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.pack-info strong {
  display: block;
  font-size: 0.95rem;
}
.pack-info span {
  font-size: 0.8rem;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding-top: 0.25rem;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #eef3ef;
  color: var(--ink);
  padding: 1.25rem;
  max-width: 22rem;
  width: calc(100% - 2rem);
}
dialog::backdrop { background: rgba(30, 44, 38, 0.45); }
dialog h2 {
  font-family: var(--display);
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}
dialog p { color: var(--muted); font-size: 0.9rem; }
.err { color: #b33a3a; font-size: 0.85rem; }

@media (max-width: 560px) {
  .top { flex-wrap: wrap; gap: 0.75rem; }
  .wick-plane { opacity: 0.45; right: -4rem; top: 8%; }
  .habit {
    grid-template-columns: auto 1fr;
  }
  .habit-meta {
    grid-column: 2;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
  }
}
