/* Daily Drift — calm habit tracker */
:root {
  --bg: #f6f3ee;
  --bg-elevated: #fffcf7;
  --surface: #ffffff;
  --ink: #2a2f2c;
  --ink-soft: #5c6560;
  --muted: #8a938d;
  --line: #e6e0d6;
  --line-strong: #d4cdc2;
  --sage: #6b8f71;
  --sage-deep: #4f7356;
  --sage-soft: #e4efe6;
  --sage-mid: #a8c4ad;
  --coral: #d4846a;
  --coral-soft: #f8e8e2;
  --sky: #7a9eae;
  --sky-soft: #e5eef2;
  --amber: #c9a227;
  --amber-soft: #f7f0d8;
  --danger: #b54a4a;
  --danger-soft: #f8e6e6;
  --shadow: 0 8px 28px rgba(42, 47, 44, 0.06);
  --shadow-sm: 0 2px 10px rgba(42, 47, 44, 0.05);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tap: 44px;
  --max: 960px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #eef5ef 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #f3eee6 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--sage-deep); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--ink); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.1rem;
  background: rgba(246, 243, 238, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--ink);
  font-weight: 650;
  letter-spacing: -0.02em;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background:
    linear-gradient(145deg, var(--sage-mid), var(--sage-deep));
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.25);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 8px 7px 7px 8px;
  border-radius: 3px;
  border: 2px solid rgba(255,255,255,0.9);
  border-top: 0;
  border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px);
}
.brand-name { font-size: 1.05rem; }
.topnav {
  margin-left: auto;
  display: none;
  gap: 0.25rem;
}
.nav-link {
  text-decoration: none;
  color: var(--ink-soft);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-pill);
  font-size: 0.92rem;
  font-weight: 500;
}
.nav-link:hover { background: rgba(107, 143, 113, 0.1); color: var(--ink); }
.nav-link.is-active {
  background: var(--sage-soft);
  color: var(--sage-deep);
}

.menu-toggle {
  margin-left: auto;
  width: var(--tap);
  height: var(--tap);
  border: 0;
  background: transparent;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  border-radius: 10px;
}
.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: transform 0.2s var(--ease), opacity 0.2s;
}
.menu-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.mobile-drawer {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem 1rem 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--line);
}
.mobile-drawer[hidden] { display: none !important; }
.drawer-link {
  text-decoration: none;
  color: var(--ink);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.drawer-link:hover, .drawer-link.is-active {
  background: var(--sage-soft);
  color: var(--sage-deep);
}

@media (min-width: 760px) {
  .topnav { display: flex; }
  .menu-toggle { display: none; }
  .mobile-drawer { display: none !important; }
  .topbar { padding: 0.85rem 1.75rem; }
}

/* Page */
.page {
  width: min(100% - 2rem, var(--max));
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
  flex: 1;
}
.page-narrow { width: min(100% - 2rem, 440px); }

.eyebrow {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sage-deep);
}
h1 {
  margin: 0 0 0.6rem;
  font-size: clamp(1.7rem, 4.5vw, 2.35rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
  font-weight: 700;
}
h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.lede {
  margin: 0 0 1.25rem;
  color: var(--ink-soft);
  font-size: 1.05rem;
  max-width: 36ch;
}
.muted { color: var(--muted); }
.optional { color: var(--muted); font-weight: 400; font-size: 0.85em; }
.center-text { text-align: center; }
.section-title {
  margin: 1.75rem 0 0.85rem;
  font-size: 1rem;
  color: var(--ink-soft);
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--tap);
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: background 0.18s var(--ease), transform 0.15s var(--ease), box-shadow 0.18s;
  box-shadow: var(--shadow-sm);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.btn-primary {
  background: linear-gradient(180deg, #7a9d80, var(--sage-deep));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(79, 115, 86, 0.25);
}
.btn-primary:hover { background: linear-gradient(180deg, #6b8f71, #456548); color: #fff; }
.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
  box-shadow: none;
  color: var(--ink-soft);
}
.btn-ghost:hover { background: rgba(255,255,255,0.7); color: var(--ink); }
.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 6px 16px rgba(181, 74, 74, 0.22);
}
.btn-danger:hover { background: #9e3d3d; color: #fff; }
.btn-block { width: 100%; }
.btn-sm {
  min-height: 38px;
  padding: 0.4rem 0.9rem;
  font-size: 0.88rem;
}
.btn-icon {
  width: var(--tap);
  min-height: var(--tap);
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

/* Hero */
.hero {
  display: grid;
  gap: 1.75rem;
  align-items: center;
  margin-bottom: 2.5rem;
}
.hero-art {
  border-radius: calc(var(--radius) + 4px);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--sage-soft);
  aspect-ratio: 3 / 2;
}
.hero-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.hero-status {
  margin: 0.9rem 0 0;
  min-height: 1.25em;
  font-size: 0.92rem;
  color: var(--ink-soft);
}
@media (min-width: 820px) {
  .hero {
    grid-template-columns: 1.05fr 0.95fr;
    gap: 2.5rem;
    margin-bottom: 3rem;
  }
}

/* Features */
.features {
  display: grid;
  gap: 0.9rem;
  margin-bottom: 2.5rem;
}
@media (min-width: 640px) {
  .features { grid-template-columns: 1fr 1fr; }
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.25rem 1.35rem;
  box-shadow: var(--shadow-sm);
}
.feature-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 0.75rem;
}
.feature-card h2 { margin-bottom: 0.35rem; }
.feature-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* How */
.how {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem 1.35rem;
  box-shadow: var(--shadow-sm);
}
.how h2 { margin-bottom: 0.85rem; }
.steps {
  margin: 0 0 1.25rem;
  padding-left: 1.2rem;
  color: var(--ink-soft);
}
.steps li { margin-bottom: 0.45rem; }
.steps strong { color: var(--ink); font-weight: 600; }

/* Footer */
.site-footer {
  padding: 1.25rem 1rem 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}
.site-footer p { margin: 0; }

/* Account */
.account-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem 1.6rem;
  box-shadow: var(--shadow);
}
.panel-head { margin-bottom: 1.25rem; }
.panel-head h1 { font-size: 1.55rem; }
.panel-head .muted { margin: 0; }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  padding: 0.3rem;
  background: var(--bg);
  border-radius: var(--radius-pill);
  margin-bottom: 1.25rem;
}
.tab {
  border: 0;
  background: transparent;
  min-height: 40px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  color: var(--ink-soft);
}
.tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.auth-form { display: grid; gap: 0.85rem; }
.auth-form[hidden] { display: none !important; }

.field {
  display: grid;
  gap: 0.35rem;
}
.field > span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.field input,
.field select {
  min-height: var(--tap);
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(107, 143, 113, 0.2);
  background: #fff;
}
.field input::placeholder { color: #b0b8b2; }

.form-msg {
  margin: 0;
  min-height: 1.25em;
  font-size: 0.9rem;
}
.form-msg.is-error { color: var(--danger); }
.form-msg.is-success { color: var(--sage-deep); }
.form-msg.is-pending { color: var(--ink-soft); }

.session-row {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  margin-bottom: 1.25rem;
  padding: 0.9rem;
  background: var(--sage-soft);
  border-radius: var(--radius-sm);
}
.session-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface);
  flex-shrink: 0;
}
.session-label {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sage-deep);
}
.session-id {
  margin: 0.15rem 0 0;
  font-weight: 600;
  word-break: break-all;
  font-size: 0.92rem;
}
.session-meta {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.session-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.auth-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 1.5rem;
  color: var(--muted);
}
.auth-loading[hidden] { display: none !important; }
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--sage);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Gate */
.gate-card {
  text-align: center;
  padding: 2.5rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.gate-card .lede {
  margin-left: auto;
  margin-right: auto;
}
.gate-card .hero-actions { justify-content: center; }
.gate-card[hidden] { display: none !important; }

/* Dashboard */
#dash-root[hidden] { display: none !important; }
.dash-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.15rem;
}
.dash-header h1 { margin-bottom: 0; }
.dash-header-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.view-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.3rem;
  padding: 0.3rem;
  background: rgba(255,255,255,0.65);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  margin-bottom: 1.25rem;
}
.view-tab {
  border: 0;
  background: transparent;
  min-height: 40px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.view-tab.is-active {
  background: var(--surface);
  color: var(--sage-deep);
  box-shadow: var(--shadow-sm);
}

.banner {
  margin: 0 0 1rem;
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  background: var(--amber-soft);
  color: #6a5710;
  border: 1px solid #eadba0;
}
.banner.is-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #efc4c4;
}
.banner.is-success {
  background: var(--sage-soft);
  color: var(--sage-deep);
  border-color: var(--sage-mid);
}
.banner[hidden] { display: none !important; }

/* Today summary */
.today-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-bottom: 1.15rem;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.summary-pill {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}
.summary-num {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--sage-deep);
}
.summary-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}
.summary-bar {
  flex: 1;
  min-width: 120px;
  height: 8px;
  background: var(--bg);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.summary-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--sage-mid), var(--sage));
  border-radius: var(--radius-pill);
  transition: width 0.35s var(--ease);
}

/* Habit list */
.habit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}
.habit-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.habit-card.is-done {
  background: linear-gradient(180deg, #f7fbf8, var(--surface));
  border-color: var(--sage-mid);
}
.habit-card.is-pending-op {
  opacity: 0.65;
  pointer-events: none;
}

.check-btn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 2px solid var(--line-strong);
  background: var(--bg-elevated);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.18s, border-color 0.18s, transform 0.12s;
  padding: 0;
  color: transparent;
}
.check-btn:hover {
  border-color: var(--sage);
  background: var(--sage-soft);
}
.check-btn:active { transform: scale(0.94); }
.check-btn.is-checked {
  background: linear-gradient(180deg, #8fb896, var(--sage-deep));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 115, 86, 0.28);
}
.check-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.habit-body { min-width: 0; }
.habit-title {
  margin: 0;
  font-weight: 650;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  word-break: break-word;
}
.habit-card.is-done .habit-title {
  color: var(--sage-deep);
}
.habit-meta {
  margin: 0.2rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.priority-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.priority-chip.high {
  background: var(--coral-soft);
  color: #a05540;
}
.priority-chip.medium {
  background: var(--sky-soft);
  color: #3d6575;
}
.priority-chip.low {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--line);
}
.streak-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: var(--coral);
  font-weight: 600;
}
.streak-chip::before {
  content: "✦";
  font-size: 0.7em;
}

.habit-actions {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.icon-action {
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-action:hover {
  background: var(--bg);
  color: var(--ink);
}
.icon-action.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Empty */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}
.empty-state[hidden] { display: none !important; }
.empty-state img {
  width: min(100%, 260px);
  margin: 0 auto 1rem;
  border-radius: var(--radius-sm);
}
.empty-state h2 { margin-bottom: 0.35rem; }
.empty-state p {
  margin: 0 0 1.1rem;
  color: var(--ink-soft);
}

/* Week grid */
.week-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.week-head h2 {
  margin: 0;
  font-size: 1rem;
  text-align: center;
  flex: 1;
  color: var(--ink-soft);
  font-weight: 600;
}
.week-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.week-grid {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
  font-size: 0.85rem;
}
.week-grid th,
.week-grid td {
  padding: 0.65rem 0.4rem;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
.week-grid th {
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
}
.week-grid th.is-today {
  color: var(--sage-deep);
}
.week-grid th.habit-col,
.week-grid td.habit-col {
  text-align: left;
  padding-left: 0.9rem;
  padding-right: 0.6rem;
  min-width: 120px;
  max-width: 160px;
  font-weight: 600;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
  box-shadow: 4px 0 8px -6px rgba(0,0,0,0.08);
}
.week-grid th.habit-col { background: var(--bg-elevated); z-index: 2; }
.week-grid tr:last-child td { border-bottom: 0; }
.week-grid .habit-col-name {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.day-dot {
  width: 28px;
  height: 28px;
  margin: 0 auto;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  padding: 0;
  cursor: pointer;
}
.day-dot:hover:not(:disabled) {
  border-color: var(--sage);
  transform: scale(1.08);
}
.day-dot:disabled {
  cursor: default;
  opacity: 0.45;
}
.day-dot.is-done {
  background: linear-gradient(180deg, #8fb896, var(--sage));
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(107, 143, 113, 0.3);
}
.day-dot.is-done::after {
  content: "";
  width: 8px;
  height: 5px;
  border: 2px solid #fff;
  border-top: 0;
  border-right: 0;
  transform: rotate(-45deg) translate(0.5px, -0.5px);
}
.day-dot.is-future {
  border-style: dashed;
  opacity: 0.35;
  cursor: default;
}
.day-dot.is-today-col:not(.is-done) {
  border-color: var(--sage-mid);
  background: var(--sage-soft);
}

/* Stats */
.stats-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr 1fr;
}
@media (min-width: 640px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 0.95rem;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.stat-value {
  margin: 0.35rem 0 0.15rem;
  font-size: 1.75rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--sage-deep);
  line-height: 1.1;
}
.stat-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.per-habit-stats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}
.per-stat {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 1rem;
  align-items: center;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.per-stat-name {
  margin: 0;
  font-weight: 650;
  font-size: 0.95rem;
}
.per-stat-sub {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  grid-column: 1 / -1;
}
.per-stat-nums {
  text-align: right;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.per-stat-nums strong {
  display: block;
  font-size: 1.1rem;
  color: var(--sage-deep);
  font-weight: 700;
}
.mini-bar {
  grid-column: 1 / -1;
  height: 6px;
  background: var(--bg);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-top: 0.15rem;
}
.mini-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--sage-mid), var(--sage));
  border-radius: var(--radius-pill);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(42, 47, 44, 0.38);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn 0.18s var(--ease);
}
.modal-backdrop[hidden] { display: none !important; }
@media (min-width: 560px) {
  .modal-backdrop {
    align-items: center;
    padding: 1.25rem;
  }
}
.modal {
  width: min(100%, 440px);
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 1.25rem 1.2rem 1.5rem;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.12);
  max-height: 92vh;
  overflow-y: auto;
  animation: slideUp 0.22s var(--ease);
}
@media (min-width: 560px) {
  .modal {
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
}
.modal-sm { width: min(100%, 360px); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.modal-head h2 { margin: 0; font-size: 1.2rem; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
#habit-form {
  display: grid;
  gap: 0.85rem;
}

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

/* Skeleton loading rows */
.skeleton-card {
  height: 76px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--line) 25%, #efeae2 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border: 1px solid var(--line);
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

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

/* Safe areas & touch polish */
@supports (padding: max(0px)) {
  .topbar {
    padding-left: max(1.1rem, env(safe-area-inset-left));
    padding-right: max(1.1rem, env(safe-area-inset-right));
  }
  .site-footer {
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
  }
  .modal-backdrop {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Selection */
::selection {
  background: var(--sage-soft);
  color: var(--ink);
}

/* Utility hidden */
[hidden] {
  display: none !important;
}

/* Print */
@media print {
  .topbar,
  .mobile-drawer,
  .menu-toggle,
  .site-footer,
  .modal-backdrop,
  .dash-header-actions,
  .view-tabs {
    display: none !important;
  }
  body {
    background: #fff;
  }
  .habit-card,
  .stat-card,
  .feature-card {
    box-shadow: none;
    break-inside: avoid;
  }
}