/* Habits — mobile-first PWA */

:root {
  --bg0: #e8edf2;
  --bg1: #f4f7fa;
  --ink: #10141a;
  --muted: #5c6775;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --stroke: rgba(16, 20, 26, 0.08);
  --good: #0f8a72;
  --good-soft: rgba(15, 138, 114, 0.14);
  --bad: #d9482b;
  --bad-soft: rgba(217, 72, 43, 0.14);
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --shadow: 0 12px 40px rgba(16, 20, 26, 0.08);
  --radius: 22px;
  --radius-sm: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-display: "Figtree", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.45, 0.64, 1);
}

:root[data-theme="dark"] {
  --bg0: #0b0d10;
  --bg1: #12161c;
  --ink: #eef2f6;
  --muted: #8b95a3;
  --surface: rgba(22, 27, 34, 0.78);
  --surface-solid: #161b22;
  --stroke: rgba(238, 242, 246, 0.08);
  --good: #2dd4bf;
  --good-soft: rgba(45, 212, 191, 0.14);
  --bad: #fb7185;
  --bad-soft: rgba(251, 113, 133, 0.14);
  --accent: #2dd4bf;
  --accent-ink: #06110f;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg0);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
  touch-action: manipulation;
}

body.sheet-open {
  overflow: hidden;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(15, 138, 114, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 45% at 100% 0%, rgba(217, 72, 43, 0.12), transparent 50%),
    radial-gradient(ellipse 60% 40% at 50% 110%, rgba(15, 118, 110, 0.1), transparent 55%),
    linear-gradient(180deg, var(--bg0), var(--bg1) 40%, var(--bg0));
}

:root[data-theme="dark"] .ambient {
  background:
    radial-gradient(ellipse 70% 45% at 0% 0%, rgba(45, 212, 191, 0.16), transparent 50%),
    radial-gradient(ellipse 60% 40% at 100% 10%, rgba(251, 113, 133, 0.1), transparent 45%),
    radial-gradient(ellipse 50% 35% at 50% 100%, rgba(45, 212, 191, 0.08), transparent 50%),
    linear-gradient(180deg, #0b0d10, #10141a 50%, #0b0d10);
}

.app {
  position: relative;
  z-index: 1;
  width: min(480px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  padding:
    calc(12px + var(--safe-top))
    18px
    calc(36px + var(--safe-bottom));
}

/* Header */

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
  animation: rise 0.55s var(--ease-out) both;
}

.brand-block .eyebrow {
  margin: 0 0 2px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 8vw, 2.4rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.theme-toggle,
.back-btn,
.apps-btn,
.btn-add {
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
  transition: transform 0.15s var(--ease-out), background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  font: inherit;
}

.theme-toggle,
.back-btn,
.apps-btn {
  width: 44px;
}

.btn-add {
  grid-auto-flow: column;
  gap: 6px;
  padding: 0 14px 0 12px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: -0.02em;
  background: var(--ink);
  color: var(--bg0);
  border-color: transparent;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}

.btn-add svg {
  display: block;
}

.theme-toggle:active,
.back-btn:active,
.apps-btn:active,
.btn-add:active {
  transform: scale(0.92);
}

:root[data-theme="light"] .icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }

.detail-header {
  margin-bottom: 8px;
}

/* Habit cards */

.habit-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.habit-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: stretch;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  overflow: hidden;
  animation: rise 0.55s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 55ms + 80ms);
}

.habit-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
}

.habit-card.good::before { background: var(--good); }
.habit-card.bad::before { background: var(--bad); }

.habit-card.pulse {
  animation: card-pulse 0.45s var(--ease-spring);
}

.habit-link {
  color: inherit;
  text-decoration: none;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-tap-highlight-color: transparent;
}

.habit-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.habit-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.habit-icon {
  font-size: 1.55rem;
  line-height: 1;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--surface-solid);
  border: 1px solid var(--stroke);
  flex-shrink: 0;
}

.habit-icon.muted {
  color: var(--muted);
  font-size: 1.2rem;
}

.habit-icon.lg {
  width: 52px;
  height: 52px;
  font-size: 1.8rem;
  border-radius: 16px;
}

.habit-name {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag {
  display: inline-flex;
  align-items: center;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
}

.tag.good { background: var(--good-soft); color: var(--good); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }

.today-count {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.85rem;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: transform 0.25s var(--ease-spring), color 0.2s ease;
}

.today-count.pop {
  transform: scale(1.18);
  color: var(--accent);
}

.habit-card.good .today-count.pop { color: var(--good); }
.habit-card.bad .today-count.pop { color: var(--bad); }

.habit-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.habit-meta strong {
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.badge-chip {
  font-weight: 600;
  white-space: nowrap;
}

.badge-chip.done { color: var(--good); }

.progress {
  height: 4px;
  border-radius: 999px;
  background: var(--stroke);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, white));
  transition: width 0.45s var(--ease-out);
}

.habit-card.good .progress-fill,
.detail-hero.good .progress-fill {
  background: linear-gradient(90deg, var(--good), color-mix(in srgb, var(--good) 55%, white));
}

.habit-card.bad .progress-fill,
.detail-hero.bad .progress-fill {
  background: linear-gradient(90deg, var(--bad), color-mix(in srgb, var(--bad) 55%, white));
}

/* Actions */

.habit-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.habit-actions.centered {
  flex-direction: row;
  margin-top: 8px;
}

.habit-actions form { margin: 0; }

.btn-plus {
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 22px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  cursor: pointer;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform 0.15s var(--ease-out), box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}

.habit-card.good .btn-plus,
.detail-hero.good .btn-plus {
  background: var(--good);
  color: #04120f;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--good) 35%, transparent);
}

.habit-card.bad .btn-plus,
.detail-hero.bad .btn-plus {
  background: var(--bad);
  color: #fff;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--bad) 35%, transparent);
}

.btn-plus.xl {
  width: 88px;
  height: 88px;
  border-radius: 28px;
  font-size: 1.45rem;
}

.btn-plus:active {
  transform: scale(0.9);
}

.btn-plus.burst::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.55) 0%, transparent 65%);
  animation: burst 0.45s var(--ease-out) forwards;
}

.btn-undo {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.15s var(--ease-out), color 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-undo.lg {
  width: 52px;
  height: 52px;
  border-radius: 16px;
}

.btn-undo:active {
  transform: scale(0.9);
  color: var(--ink);
}

/* Sheet */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 12, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 50;
  animation: fade-in 0.2s ease;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(480px, 100%);
  max-height: min(88dvh, 640px);
  overflow: auto;
  z-index: 60;
  background: var(--surface-solid);
  border-radius: 28px 28px 0 0;
  padding: 10px 20px calc(24px + var(--safe-bottom));
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.25);
  animation: sheet-up 0.35s var(--ease-out);
}

.sheet[hidden],
.sheet-backdrop[hidden] {
  display: none !important;
}

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--stroke);
  margin: 4px auto 16px;
}

.sheet h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}

.sheet-sub {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.add-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field span,
.check-row {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.field input,
.field select,
.day-picker input,
.day-picker button {
  width: 100%;
  padding: 14px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: var(--bg1);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus,
.day-picker input:focus {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.field-row {
  display: flex;
  gap: 10px;
}

.field.grow { flex: 1; min-width: 0; }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 4px 0;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.btn-primary {
  margin-top: 4px;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 16px;
  background: var(--ink);
  color: var(--bg0);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform 0.15s var(--ease-out);
}

.btn-primary:active { transform: scale(0.98); }

/* Empty */

.empty-state {
  text-align: center;
  padding: 72px 12px 40px;
  animation: rise 0.55s var(--ease-out) both;
}

.empty-orb {
  width: 88px;
  height: 88px;
  margin: 0 auto 20px;
  border-radius: 28px;
  background:
    radial-gradient(circle at 30% 30%, rgba(45, 212, 191, 0.5), transparent 55%),
    radial-gradient(circle at 70% 70%, rgba(217, 72, 43, 0.35), transparent 50%),
    var(--surface-solid);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  animation: float 4s ease-in-out infinite;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: -0.03em;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

/* Detail */

.detail-hero {
  padding: 22px 18px 20px;
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  margin-bottom: 28px;
  animation: rise 0.55s var(--ease-out) both;
  position: relative;
  overflow: hidden;
}

.detail-hero::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -40px;
  top: -50px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%);
  pointer-events: none;
}

.detail-hero.good::after {
  background: radial-gradient(circle, color-mix(in srgb, var(--good) 22%, transparent), transparent 70%);
}

.detail-hero.bad::after {
  background: radial-gradient(circle, color-mix(in srgb, var(--bad) 22%, transparent), transparent 70%);
}

.detail-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  position: relative;
  z-index: 1;
}

.detail-title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.55rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.hero-count {
  text-align: center;
  position: relative;
  z-index: 1;
  margin: 8px 0 18px;
}

.hero-value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3.6rem, 15vw, 4.75rem);
  letter-spacing: -0.04em;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
  transition: transform 0.25s var(--ease-spring);
}

.hero-value.pop {
  transform: scale(1.08);
}

.hero-label {
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}

.hero-badge {
  position: relative;
  z-index: 1;
  margin-bottom: 16px;
}

.hero-badge-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.section {
  margin-bottom: 28px;
  animation: rise 0.55s var(--ease-out) both;
  animation-delay: 0.1s;
}

.section h2 {
  margin: 0 0 12px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.stat-rail {
  display: grid;
  grid-template-columns: repeat(5, minmax(64px, 1fr));
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.stat-rail::-webkit-scrollbar { display: none; }

.stat-tile {
  min-width: 64px;
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--stroke);
  text-align: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.stat-tile .value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-tile .label {
  margin-top: 2px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 128px;
  padding: 14px 12px 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.chart-bar {
  flex: 1;
  height: calc(var(--h, 2) * 1%);
  min-height: 3px;
  border-radius: 4px 4px 2px 2px;
  background: var(--accent);
  opacity: 0.85;
  transform-origin: bottom;
  animation: bar-in 0.55s var(--ease-out) both;
  animation-delay: calc(var(--d, 0) * 12ms);
}

.chart-bar.good { background: var(--good); }
.chart-bar.bad { background: var(--bad); }

.chart-caption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.75rem;
}

.day-picker {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.day-picker input { flex: 1; }

.day-picker button {
  width: auto;
  padding-inline: 18px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-solid);
}

.day-result {
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--stroke);
}

.day-result .value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.day-result .label {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.day-result .times {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.badge {
  padding: 16px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--stroke);
  text-align: center;
  opacity: 0.38;
  filter: grayscale(0.4);
  animation: rise 0.45s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}

.badge.achieved {
  opacity: 1;
  filter: none;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--stroke));
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 12%, transparent);
}

.badge .icon {
  display: block;
  font-size: 1.7rem;
  margin-bottom: 6px;
}

.badge .label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.25;
}

.badge.achieved .label { color: var(--ink); }

.danger-zone {
  margin: 8px 0 20px;
  text-align: center;
}

.btn-danger {
  background: transparent;
  border: none;
  color: var(--bad);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 12px 16px;
  cursor: pointer;
  opacity: 0.8;
}

.messages {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
}

.messages li {
  background: var(--bad-soft);
  color: var(--bad);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  transform: translateX(-50%) translateY(12px);
  z-index: 80;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg0);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.25s var(--ease-out);
  max-width: calc(100% - 40px);
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Standalone PWA polish */
@media (display-mode: standalone) {
  .app {
    padding-top: calc(8px + var(--safe-top));
  }
}

/* Desktop comfort */
@media (min-width: 720px) {
  .app {
    padding-top: 28px;
  }

  .habit-card:hover {
    border-color: color-mix(in srgb, var(--ink) 14%, transparent);
  }

  .btn-plus:hover {
    transform: translateY(-1px);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sheet-up {
  from { transform: translateX(-50%) translateY(100%); }
  to { transform: translateX(-50%) translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes burst {
  from { opacity: 0.9; transform: scale(0.4); }
  to { opacity: 0; transform: scale(1.6); }
}

@keyframes card-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.015); }
  100% { transform: scale(1); }
}

@keyframes bar-in {
  from { transform: scaleY(0); opacity: 0; }
  to { transform: scaleY(1); opacity: 0.85; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.login-wrap {
  min-height: calc(100dvh - 40px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  background: var(--surface-solid);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  animation: rise 0.55s var(--ease-out) both;
}

.login-card .eyebrow {
  margin: 0 0 2px;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.login-card .brand {
  margin: 0 0 18px;
  font-size: 1.6rem;
  font-weight: 800;
}

.login-error {
  color: var(--bad);
  font-size: 0.9rem;
  margin: -8px 0 14px;
}

/* Ghost button + breadcrumb */

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: var(--surface-solid);
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}

.btn-ghost:active { transform: scale(0.98); }

.breadcrumb {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
}

.breadcrumb:hover { color: var(--accent); }

.hero-value.frac {
  font-size: clamp(2.4rem, 10vw, 3.2rem);
}

.empty-hint {
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
  padding: 20px 0;
}

/* Group habit cards */

.habit-card.group {
  display: block;
  padding: 0;
}

.group-toggle {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.group-pill {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface-solid);
  border: 1px solid var(--stroke);
  flex-shrink: 0;
}

.sub-habit-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px 12px;
}

.sub-habit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
}

.sub-habit-row:hover { background: var(--surface-solid); }

.sub-habit-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  color: inherit;
  text-decoration: none;
}

.habit-icon.sm {
  width: 30px;
  height: 30px;
  font-size: 1.05rem;
  border-radius: 10px;
  flex-shrink: 0;
}

.sub-habit-name {
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sub-habit-count {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  padding-right: 4px;
}

.sub-habit-row .habit-actions {
  flex-direction: row;
  gap: 6px;
}

.btn-plus.sm,
.btn-undo.sm {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  font-size: 0.8rem;
}

.btn-edit {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: var(--surface-solid);
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-edit:active { transform: scale(0.94); }

.btn-add-child {
  margin-top: 4px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--stroke);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-add-child:hover { border-color: var(--accent); color: var(--accent); }

/* Reminder banner */

.reminder-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface-solid));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--stroke));
  animation: rise 0.55s var(--ease-out) both;
}

.reminder-banner-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.reminder-banner-text a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.reminder-banner-text a:hover { text-decoration: underline; }

.banner-dismiss {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
}

/* Reminder fields */

.remind-field summary {
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  list-style: none;
}

.remind-field summary::-webkit-details-marker { display: none; }

.remind-field[open] summary { margin-bottom: 10px; }

.remind-field > .field { margin-top: 10px; }

.weekday-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.weekday-chip {
  position: relative;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--bg1);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.weekday-chip input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  margin: 0;
}

.weekday-chip:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.field-hint {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
}

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