/* ============ HabitLoop AI — "The Ritual" ============
   A calm dawn for consistency. Warm paper, deep teal as the single
   accent, terracotta to mark "today". Day cells are circles forming
   an unbroken chain; streaks set in serif numerals. Quiet, rhythmic,
   meditative — the anti-dashboard. */
:root {
  --paper: #f7f4ee;
  --paper-2: #f0ebdf;
  --card: #fffdf8;
  --line: #e6ddc9;
  --line-soft: #f0e9d7;
  --ink: #2c2a25;
  --ink-soft: #5b554a;
  --muted: #948b77;
  --teal: #0f766e;
  --teal-deep: #115e59;
  --teal-soft: #ddf0ee;
  --teal-ring: rgba(15, 118, 110, .16);
  --terra: #c26a3d;
  --terra-soft: #f8e8da;
  --gold: #c09a4a;
  --gold-soft: #f7ecd4;
  --radius-was-20px;
  --radius-sm-was-12px;
  --shadow: 0 1px 2px rgba(44, 42, 37, .05), 0 14px 34px rgba(44, 42, 37, .07);
  --serif: "Fraunces", "Iowan Old Style", Charter, Georgia, serif;
  --sans: "Inter", -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.6;
  background: var(--paper);
  background-image: radial-gradient(ellipse 70% 30% at 50% 0%, #fffdf4 0%, transparent 65%);
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 900px; margin: 0 auto; padding: 0 24px; }

/* ---------- masthead ---------- */
.topbar { border-bottom: 1px solid var(--line); background: rgba(247, 244, 238, .94); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 50; }
.masthead { padding-top: 20px; padding-bottom: 16px; }
.brand { display: flex; gap: 14px; align-items: center; }
.brand-mark { width: 48px; height: 48px; border-radius: 50%; background: var(--teal); display: flex; align-items: center; justify-content: center; flex: none; box-shadow: 0 8px 18px rgba(15, 118, 110, .3); }
.brand-text h1 { margin: 0; font-family: var(--serif); font-size: 28px; font-weight: 600; letter-spacing: -.01em; }
.brand-text h1 .ai { color: var(--teal); font-size: 20px; }
.tagline { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; font-style: italic; font-family: var(--serif); }

/* ---------- layout ---------- */
main.wrap { padding-top: 28px; padding-bottom: 72px; }
.journal-head { display: flex; align-items: baseline; gap: 12px; margin: 36px 0 16px; }
.journal-head h2 { margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 600; }
.journal-sub { color: var(--muted); font-size: 13px; font-style: italic; font-family: var(--serif); }

/* ---------- milestone banner ---------- */
.banner {
  background: var(--gold-soft); border: 1px solid #ecd9ac; color: #7a5a1c;
  border-radius: 0; padding: 18px 24px; margin-bottom: 24px; font-size: 15px; line-height: 1.9;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
  animation: glow .5s ease both;
}
.banner::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--gold); }
@keyframes glow { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- stats ---------- */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 26px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 0;
  padding: 20px; text-align: center; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::after { content: ""; position: absolute; top: 0; left: 24%; right: 24%; height: 4px; border-radius: 0; background: var(--teal); opacity: .8; }
.stat .num { display: block; font-family: var(--serif); font-size: 44px; font-weight: 700; color: var(--teal-deep); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .lbl { font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }

/* ---------- form panel ---------- */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 0;
  padding: 24px; box-shadow: var(--shadow); margin-bottom: 8px;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 600; }
.panel-note { font-size: 12.5px; color: var(--muted); font-style: italic; font-family: var(--serif); }
.row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.flbl { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-soft); }
.flbl em { text-transform: none; letter-spacing: 0; font-style: normal; color: var(--muted); font-weight: 500; }
input, select {
  background: #fff; border: 1px solid var(--line); color: var(--ink);
  border-radius: 0; padding: 11px 14px; font: 500 14px var(--sans); width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-ring); }
input::placeholder { color: #b7ad97; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23948b77' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.primary {
  background: var(--teal); color: #fff; border: 0; border-radius: 0;
  font: 700 14px var(--sans); padding: 12px 28px; cursor: pointer;
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
  box-shadow: 0 8px 18px rgba(15, 118, 110, .28);
}
.primary:hover { background: var(--teal-deep); transform: translateY(-1px); }
.primary:active { transform: scale(.98); }
.primary.small { padding: 9px 20px; font-size: 13px; }
.error { color: #b3402e; font-size: 13.5px; margin-bottom: 10px; font-weight: 600; }

/* ---------- habit list tools: sort, edit, archive ---------- */
.sort-wrap { margin-left: auto; }
.sort-lbl { font: 600 12.5px var(--sans); color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.sort-lbl select { width: auto; min-width: 150px; margin-bottom: 0; padding: 8px 32px 8px 12px; font-size: 13px; }
.card-actions { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.ghost-btn {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: 600 12.5px var(--sans); color: var(--muted);
  text-decoration: underline; text-underline-offset: 3px;
}
.ghost-btn:hover { color: var(--teal-deep); }
.edit-form { margin-top: 12px; }
.card.archived { opacity: .75; border-style: dashed; }
.hint { color: var(--muted); font-size: 13px; font-style: italic; font-family: var(--serif); margin: 14px 0 0; }

/* ---------- habit cards ---------- */
.habits { display: grid; gap: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 0;
  padding: 24px; box-shadow: var(--shadow);
  transition: transform .16s ease, box-shadow .16s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(44,42,37,.06), 0 20px 44px rgba(44,42,37,.1); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.card-head h3 { margin: 0; font-family: var(--serif); font-size: 23px; font-weight: 600; }
.meta { font-size: 12.5px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.streak { text-align: center; flex: none; background: var(--teal-soft); border-radius: 0; padding: 12px 20px; }
.streak .num { display: block; font-family: var(--serif); font-size: 38px; font-weight: 700; color: var(--teal-deep); line-height: 1; font-variant-numeric: tabular-nums; }
.streak .lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--teal-deep); font-weight: 800; }

/* the chain: circles, not squares */
.grid { display: flex; gap: 10px; justify-content: space-between; margin-bottom: 14px; }
.day {
  flex: 1; aspect-ratio: 1; max-width: 74px; border-radius: 50%;
  border: 1.5px solid var(--line); background: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font: 700 10px var(--sans); color: var(--muted); letter-spacing: .04em; text-transform: uppercase;
  transition: all .18s ease; padding: 0;
}
.day span { font: 800 17px var(--sans); color: var(--ink); font-variant-numeric: tabular-nums; }
.day:hover { border-color: var(--teal); transform: scale(1.07); }
.day.done { background: var(--teal); border-color: var(--teal); color: #d7efec; box-shadow: 0 6px 14px rgba(15, 118, 110, .35); }
.day.done span { color: #fff; }
.day.today { border-color: var(--terra); border-width: 2.5px; box-shadow: 0 0 0 4px var(--terra-soft); }
.day.done.today { border-color: var(--terra); }

.grid-nav { display: flex; gap: 8px; margin-bottom: 12px; }
.grid-nav button {
  background: transparent; border: 1px solid var(--line); color: var(--ink-soft);
  font: 600 12.5px var(--sans); padding: 8px 16px; border-radius: 0; cursor: pointer;
  transition: all .15s ease;
}
.grid-nav button:hover { border-color: var(--teal); color: var(--teal-deep); }
.stats { font-size: 13.5px; color: var(--muted); margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.stats strong { color: var(--ink); }
.next { font-size: 13.5px; color: var(--teal-deep); font-weight: 600; margin-bottom: 6px; }
.notes { font-size: 13.5px; color: var(--ink-soft); font-style: italic; font-family: var(--serif); margin-bottom: 4px; }
.reminder { font-size: 12.5px; color: var(--muted); }
.card-actions { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.danger { background: none; border: 0; color: var(--muted); font: 600 12.5px var(--sans); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; padding: 0; }
.danger:hover { color: #b3402e; }
.empty {
  border: 1.5px dashed var(--line); border-radius: 0; padding: 36px; text-align: center;
  color: var(--muted); font-size: 14.5px; background: rgba(255, 253, 248, .6); font-family: var(--serif); font-style: italic;
}

/* ---------- footer ---------- */
.foot { padding: 26px 0 8px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); margin-top: 30px; }
.foot p { margin: 0; }

/* ---------- responsive ---------- */
@media (max-width: 700px) {
  .row { grid-template-columns: 1fr; }
  .stats-row { gap: 10px; }
  .stat .num { font-size: 34px; }
  .grid { gap: 6px; }
  .day span { font-size: 14px; }
  .card-head { flex-direction: column; }
  .streak { align-self: flex-start; display: flex; align-items: baseline; gap: 8px; padding: 8px 16px; }
  .streak .num { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* year heatmap + starter packs */
.heatmap-scroll { overflow-x: auto; }
.heatmap { display: flex; gap: 3px; min-width: 700px; }
.hm-week { display: flex; flex-direction: column; gap: 3px; }
.hm { width: 11px; height: 11px; background: var(--line-soft); display: inline-block; }
.hm-l1 { background: #bfe0dc; }
.hm-l2 { background: #63b8ae; }
.hm-l3 { background: var(--teal); }
.hm-future { background: transparent; }
.hm-legend { display: flex; align-items: center; gap: 4px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.packs { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.pack { text-align: left; background: var(--card); border: 1px solid var(--line); padding: 14px 16px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; border-radius: 0; font: inherit; color: inherit; }
.pack:hover { border-color: var(--teal); }
.pack strong { font-size: 15px; }
.pack span { font-size: 12.5px; color: var(--muted); }

/* weekday rhythm */
.rhythm-bars { display: flex; gap: 10px; align-items: stretch; margin-bottom: 12px; }
.rhythm-day { flex: 1; text-align: center; }
.rhythm-bar { height: 90px; background: var(--paper-2); border: 1px solid var(--line-soft); display: flex; align-items: flex-end; }
.rhythm-bar span { display: block; width: 100%; background: #9fc6c1; }
.rhythm-day.strong .rhythm-bar span { background: var(--teal); }
.rhythm-day.weak .rhythm-bar span { background: var(--terra); }
.rhythm-lbl { font-size: 12px; color: var(--muted); margin-top: 6px; }
.rhythm-pct { font-size: 14px; font-weight: 700; font-family: var(--serif); }
.rhythm-note { color: var(--ink-soft); font-size: 13.5px; margin: 4px 0 0; }

/* flexible weekly target */
.week-target { font-size: 14px; color: var(--ink-soft); margin: 8px 0 0; padding: 8px 12px; background: var(--paper-2); border: 1px solid var(--line); }
.week-target.met { border-color: var(--teal); background: var(--teal-soft); color: var(--teal-deep); font-weight: 600; }

/* effort rating */
.effort-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 14px; }
.effort-row .flbl { color: var(--muted); margin-right: 4px; }
.eff-btn { width: 34px; height: 34px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font: inherit; color: var(--ink-soft); border-radius: 0; }
.eff-btn:hover { border-color: var(--teal); color: var(--teal); }
.eff-btn.sel { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 700; }
.eff-avg { margin-left: 8px; color: var(--muted); font-size: 13px; }

/* ---------- 2026 redesign: Streaks-style big check circles + today band ---------- */
.today-band {
  display: flex; align-items: center; gap: 18px;
  background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow); padding: 16px 22px; margin-bottom: 16px;
}
.tb-ring { position: relative; width: 60px; height: 60px; flex: none; }
.tb-ring .ring-bg { fill: none; stroke: var(--line-soft); stroke-width: 7; }
.tb-ring .ring-fg { fill: none; stroke: var(--teal); stroke-width: 7; stroke-linecap: square; }
.tb-num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 800 14px var(--sans); color: var(--ink); font-variant-numeric: tabular-nums;
}
.tb-text { display: flex; flex-direction: column; gap: 2px; }
.tb-text strong { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.tb-text span { font-size: 13.5px; color: var(--muted); }

/* big tap-to-complete circle — the Streaks signature */
.big-check {
  width: 68px; height: 68px; flex: none; cursor: pointer;
  border-radius: 50%;
  border: 2.5px solid var(--hc, var(--teal)); background: #fff;
  color: var(--hc, var(--teal));
  font: 800 28px/1 var(--sans);
  display: grid; place-items: center;
  transition: transform .12s ease, background .15s ease, color .15s ease, box-shadow .15s ease;
}
.big-check:hover { transform: scale(1.06); box-shadow: 0 0 0 6px rgba(0,0,0,.05); }
.big-check:active { transform: scale(.96); }
.big-check.done { background: var(--hc, var(--teal)); border-color: var(--hc, var(--teal)); color: #fff; box-shadow: 0 8px 18px rgba(0,0,0,.18); }
.card-head .ch-title { flex: 1 1 auto; min-width: 0; }
/* habit-colored streak numerals */
.streak { background: transparent; padding: 8px 4px; }
.streak .num { color: var(--hc, var(--teal-deep)); }
.streak .lbl { color: var(--hc, var(--teal-deep)); }
