:root {
  --bg: #000000;
  --bg2: #060608;
  --card: #0d0d0f;
  --card2: #141417;
  --line: #1a1a1f;
  --text: #e8e0d8;
  --muted: #6b6b72;
  --accent: #ff7b35;       /* Sunset orange — warm horizon glow */
  --accent-soft: rgba(255, 123, 53, 0.10);
  --done: #d68a5c;          /* Weathered gold — finished rep */
  --done-soft: rgba(214, 138, 92, 0.12);
  --radius: 6px;
  --quote-h: 64px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- header ---------- */
.app-header {
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 18px 0;
  background: linear-gradient(180deg, var(--bg2), var(--bg));
  flex: 0 0 auto;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 3px;
  background: var(--accent);
}
.brand-name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.2px;
}

/* Duolingo-style big streak pill */
.streak {
  display: flex; align-items: center; gap: 5px;
  background: linear-gradient(135deg, var(--accent-soft), rgba(251, 76, 42, 0.06));
  border: none;
  padding: 5px 11px 5px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
}
.streak-fire {
  font-size: 18px;
  line-height: 1;
  filter: drop-shadow(0 0 6px rgba(251, 76, 42, 0.5));
}
.streak-num {
  font-feature-settings: "tnum";
  font-size: 15px;
}
.streak.pop { animation: pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.header-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.3px;
}

/* ---------- tabs ---------- */
.tabs {
  position: relative;
  display: flex;
  margin-top: 14px;
  gap: 0;
}
.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 10px 0 11px;
  cursor: pointer;
  transition: color 0.2s;
  border-bottom: 2px solid var(--line);
  margin-bottom: -1px;
  position: relative;
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-ink { display: none; }  /* replaced by per-tab border in Attio style */

/* ---------- swipe pages ---------- */
.viewport {
  flex: 1 1 auto;
  overflow: hidden;
  position: relative;
  touch-action: pan-y;
}
.track {
  display: flex;
  height: 100%;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}
.track.dragging { transition: none; }
.page {
  flex: 0 0 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 18px 24px;
}

/* ---------- section labels ---------- */
.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--muted);
  margin: 0 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.section-count {
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- habit cards (Attio-clean) ---------- */
.card {
  display: flex;
  align-items: center;
  gap: 13px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px;
  margin-bottom: 10px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.2s, background 0.2s, transform 0.08s;
}
.card:active { transform: scale(0.986); }
.card.done {
  background: linear-gradient(0deg, var(--done-soft), var(--done-soft)), var(--card);
  border-color: rgba(88, 204, 113, 0.45);
}

.card-icon {
  font-size: 17px;
  width: 40px; height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  background: var(--card2);
  border-radius: var(--radius);
}

.card-body { flex: 1; min-width: 0; }
.card-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.1px;
}
.card.done .card-title { color: var(--done); }

/* Duolingo-style strike-through */
.card.done .card-title {
  text-decoration: line-through;
  text-decoration-color: var(--done);
  text-decoration-thickness: 1.5px;
}

.card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.45; }

/* Duolingo green checkbox — filled circle */
.check {
  width: 26px; height: 26px;
  flex: 0 0 26px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.check::after {
  content: "";
  width: 0;
  height: 0;
  border-radius: 50%;
  background: #fff;
  transition: width 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              height 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.card.done .check {
  background: var(--done);
  border-color: var(--done);
  box-shadow: 0 0 12px rgba(88, 204, 113, 0.35);
}
.card.done .check::after {
  width: 8px;
  height: 8px;
}

/* Attio-style rule card (minimal, no dashed border) */
.rule-card {
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--card2);
  border: none;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}
.rule-card b { color: var(--text); font-weight: 600; }

/* ---------- progress page (Attio meets Duolingo) ---------- */
.progress-wrap { padding-top: 4px; }

/* Big Duolingo-style streak hero */
.duo-streak-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: linear-gradient(135deg, var(--accent-soft), rgba(251, 76, 42, 0.03));
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.duo-streak-hero .fire {
  font-size: 42px;
  line-height: 1;
  filter: drop-shadow(0 0 16px rgba(251, 76, 42, 0.5));
}
.duo-streak-hero .num {
  font-size: 36px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
}
.duo-streak-hero .label {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-top: -2px;
}
.duo-streak-hero .best {
  font-size: 11px;
  color: var(--muted);
  margin-left: auto;
  text-align: right;
}

.ring-box { position: relative; width: 140px; margin: 0 auto 12px; }
.ring { width: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; stroke-linecap: round; }
.ring-bg { stroke: var(--line); }
.ring-fg {
  stroke: var(--accent);
  stroke-dasharray: 287.6;
  stroke-dashoffset: 287.6;
  transition: stroke-dashoffset 0.5s ease;
}
.ring-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ring-pct {
  font-size: 30px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.ring-sub {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.stat-num {
  display: block;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.3px;
  margin-top: 2px;
  display: block;
}

.week-strip {
  display: flex;
  gap: 6px;
  margin-top: 14px;
}
.day-dot {
  flex: 1;
  aspect-ratio: 1;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.2s, border-color 0.2s;
}
.day-dot.full {
  background: var(--done);
  border-color: var(--done);
  color: #e8e0d8;
}
.day-dot.partial {
  background: var(--accent-soft);
  border-color: rgba(220, 47, 47, 0.35);
  color: var(--accent);
}

.progress-note {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.55;
  text-align: center;
}

/* ---------- confetti overlay ---------- */
#confettiCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

/* ---------- quote bar ---------- */
.quote-bar {
  flex: 0 0 auto;
  padding: 10px 18px calc(env(safe-area-inset-bottom, 0px) + 12px);
  border-top: 1px solid var(--line);
  background: var(--bg2);
  min-height: var(--quote-h);
  display: flex;
  align-items: center;
}
.quote {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  line-height: 1.5;
}
.quote b {
  color: var(--text);
  font-style: normal;
  font-weight: 600;
}

/* ---------- Duolingo-style toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--quote-h) + 18px);
  transform: translateX(-50%) translateY(24px);
  background: var(--done);
  color: #e8e0d8;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.3px;
  padding: 12px 22px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 6px 24px rgba(88, 204, 113, 0.35);
  white-space: nowrap;
  z-index: 50;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 480px) {
  .card-title { font-size: 15px; }
  .brand-name { font-size: 15px; }
}