:root {
  --bg: #0f1115;
  --bg-elev: #151923;
  --card: #1a1f2b;
  --text: #e5e7eb;
  --muted: #a6adbb;
  --accent: #6ee7f9;
  --accent-2: #8b5cf6;
  --success: #22c55e;
  --danger: #f43f5e;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: radial-gradient(1200px 800px at 80% -20%, rgba(139,92,246,.15), transparent),
              radial-gradient(1000px 600px at -10% 20%, rgba(110,231,249,.08), transparent),
              var(--bg);
  color: var(--text);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top) 16px 12px 16px;
  background: linear-gradient(180deg, rgba(15,17,21,.9), rgba(15,17,21,.7) 60%, rgba(15,17,21,0));
  backdrop-filter: blur(8px);
}

h1 { margin: 10px 0; font-size: 22px; letter-spacing: .3px; }

main { padding: 8px 16px 80px; }

.actions { display: flex; gap: 10px; align-items: center; }

.btn {
  border: none;
  color: #0b0d12;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s ease, filter .2s ease, opacity .2s ease;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary { color: #0b0d12; }
.btn.ghost {
  color: var(--text);
  background: transparent;
  border: 1px solid rgba(255,255,255,.08);
}
.btn:disabled { opacity: .6; cursor: not-allowed; }

.habits-list { display: grid; gap: 12px; }

.card {
  background: linear-gradient(180deg, rgba(255,255,255,.03), transparent), var(--card);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  transform: translateZ(0);
}

.card .title { font-weight: 650; letter-spacing: .2px; }
.card .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }

.right {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.streak {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ffd166;
  font-weight: 700;
}
.streak .flame { display: inline-block; filter: drop-shadow(0 0 8px rgba(255,149,41,.45)); }
.streak.bump { animation: bump .6s ease; }

@keyframes bump {
  0% { transform: scale(1); }
  30% { transform: scale(1.12); }
  60% { transform: scale(0.98); }
  100% { transform: scale(1); }
}

.flame-wiggle { animation: wiggle 2.5s ease-in-out infinite; transform-origin: 50% 70%; }
@keyframes wiggle { 0%,100%{ transform: rotate(0deg) } 50%{ transform: rotate(-6deg) } }

.check-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.06);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  color: #cfe9d5;
  cursor: pointer;
  transition: transform .12s ease, background .2s ease, opacity .2s ease;
}
.check-btn:hover { background: linear-gradient(180deg, rgba(255,255,255,.1), rgba(255,255,255,.04)); }
.check-btn:active { transform: translateY(1px) scale(.98); }
.check-btn:disabled { opacity: .5; cursor: not-allowed; }

.modal-overlay {
  position: fixed; inset: 0; display: none; place-items: center; padding: 20px;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
}
.modal-overlay[aria-hidden="false"] { display: grid; }

.modal {
  width: 100%; max-width: 520px;
  background: var(--bg-elev);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.modal h2 { margin: 4px 2px 14px; }

.field { display: grid; gap: 8px; margin: 12px 0; }
.field span { color: var(--muted); font-size: 13px; }
.field input {
  width: 100%;
  background: var(--card);
  border: 1px solid rgba(255,255,255,.08);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  outline: none;
}
.field input:focus { border-color: rgba(110,231,249,.45); box-shadow: 0 0 0 3px rgba(110,231,249,.15); }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

.toast {
  position: fixed;
  left: 50%; bottom: 18px; transform: translateX(-50%) translateY(20px);
  background: #0b0f16;
  border: 1px solid rgba(255,255,255,.08);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: transform .25s ease, opacity .25s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Responsive tweaks */
@media (min-width: 720px) {
  main { padding-inline: 24px; }
  .card { grid-template-columns: 1fr auto; }
}
