:root {
  color-scheme: dark;
  --bg: #0f0d12;
  --card: #1a1720;
  --card-2: #231f2b;
  --line: #2f2a38;
  --text: #f3eff7;
  --muted: #9d95aa;
  --flame: #ff7a3d;
  --flame-2: #ffb547;
  --ok: #4ade9a;
  --danger: #ff5d6c;
  --radius: 18px;
  font-family: Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) 0 calc(84px + env(safe-area-inset-bottom));
}
main { max-width: 640px; margin: 0 auto; padding: 20px 16px; }
h1, h2, h3, .num { font-family: "Space Grotesk", sans-serif; }
h1 { font-size: 28px; margin: 8px 0 18px; }
h2 { font-size: 18px; margin: 26px 0 10px; color: var(--muted); font-weight: 500; }
h3 { margin: 0; font-size: 17px; }
p { line-height: 1.5; }
a { color: inherit; }
.muted { color: var(--muted); font-size: 14px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.card.hero {
  background: linear-gradient(135deg, #3a1d14, #26131c 60%, var(--card));
  border-color: #5a2c1d;
}
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 10px; text-align: center; }
.stat .num { font-size: 26px; font-weight: 700; }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.flame .num { color: var(--flame-2); }

.action { display: flex; gap: 12px; align-items: flex-start; }
.action .body { flex: 1; min-width: 0; }
.action .goal-name { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.pill {
  display: inline-block; font-size: 12px; padding: 3px 9px; border-radius: 99px;
  background: var(--card-2); color: var(--muted); margin: 6px 6px 0 0;
}
.pill.gain { color: var(--flame-2); background: #3a2412; }

.check {
  appearance: none; flex: none; width: 28px; height: 28px; margin: 0;
  border: 2px solid var(--muted); border-radius: 9px; cursor: pointer;
  display: grid; place-content: center;
}
.check:checked { background: var(--ok); border-color: var(--ok); }
.check:checked::after { content: "✓"; color: #0b1a12; font-weight: 700; }
.check:disabled { opacity: .5; }

button, .btn {
  font: inherit; font-weight: 600; border: 0; border-radius: 14px; cursor: pointer;
  padding: 12px 16px; background: var(--card-2); color: var(--text);
  text-decoration: none; display: inline-block; text-align: center;
}
button.primary { background: linear-gradient(135deg, var(--flame), var(--flame-2)); color: #1d0d05; }
button.danger { background: transparent; color: var(--danger); border: 1px solid #4a2128; }
button.small { padding: 8px 12px; font-size: 14px; }
button:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }

input, textarea, select {
  font: inherit; width: 100%; color: var(--text); background: var(--card-2);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 6px 0 12px;
}
textarea { min-height: 90px; resize: vertical; }
label { font-size: 14px; color: var(--muted); }

.progress { height: 8px; background: var(--card-2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--flame), var(--flame-2)); }
.goal-link { display: block; text-decoration: none; }
.goal-link.done { opacity: .55; }
.why { font-style: italic; color: var(--flame-2); margin: 4px 0 0; }

details { margin-top: 8px; }
summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.key { background: var(--card-2); border-radius: 12px; padding: 10px 12px; margin-top: 8px; font-size: 14px; line-height: 1.5; }
.key b { color: var(--flame-2); }

#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  background: rgba(15, 13, 18, .92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
#tabs[hidden] { display: none; }
#tabs a { flex: 1; text-align: center; padding: 10px 0 12px; font-size: 12px; color: var(--muted); text-decoration: none; }
#tabs a span { display: block; font-size: 20px; margin-bottom: 2px; }
#tabs a.on { color: var(--text); }

#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--card-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 99px;
  opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; text-align: center;
}
#toast.on { opacity: 1; }

.focus {
  position: fixed; inset: 0; background: var(--bg); z-index: 10;
  display: grid; place-content: center; text-align: center; padding: 16px;
}
.focus .num { font-size: 72px; font-weight: 700; color: var(--flame-2); }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
