:root {
  color-scheme: dark;
  --bg: #0f172a;
  --panel: rgba(15, 23, 42, 0.82);
  --panel-2: rgba(30, 41, 59, 0.78);
  --border: rgba(148, 163, 184, 0.16);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #22c55e;
  --danger: #ef4444;
  --yellow: #facc15;
  --shadow: 0 18px 60px rgba(2, 6, 23, 0.45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { min-height: 100%; margin: 0; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.22), transparent 32rem),
    radial-gradient(circle at 90% 8%, rgba(34, 197, 94, 0.12), transparent 20rem),
    linear-gradient(180deg, #08111f 0%, var(--bg) 46%, #020617 100%);
  color: var(--text);
}

button, input, select { font: inherit; }
button { cursor: pointer; border: none; }

.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px 34px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 18px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.82), rgba(15, 23, 42, 0.76));
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.eyebrow {
  display: inline-block;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, h3 { margin: 0; }
h1 { margin-top: 4px; font-size: 28px; line-height: 1.05; letter-spacing: -0.04em; }
h2 { margin-top: 2px; font-size: 21px; letter-spacing: -0.025em; }
h3 { font-size: 20px; letter-spacing: -0.02em; }

.fire-badge {
  min-width: 74px;
  height: 74px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  gap: 0;
  background: rgba(2, 6, 23, 0.56);
  border: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: inset 0 0 28px rgba(56, 189, 248, 0.08), 0 12px 30px rgba(0,0,0,.2);
}
.fire { font-size: 25px; line-height: 1; filter: drop-shadow(0 0 10px rgba(250, 204, 21, .45)); animation: flame 1.5s ease-in-out infinite; }
.fire-badge.burnt .fire { filter: grayscale(1); opacity: .7; animation: none; }
.fire-badge strong { font-size: 20px; margin-top: -2px; }

@keyframes flame { 0%,100%{ transform: scale(1) rotate(-2deg);} 50%{ transform: scale(1.12) rotate(3deg);} }

.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.summary-card {
  padding: 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.64);
}
.label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.summary-card strong { font-size: 24px; }

.panel {
  margin-top: 12px;
  padding: 16px;
  border-radius: 28px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 12px 44px rgba(2, 6, 23, .30);
  backdrop-filter: blur(14px);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.round-btn, .primary-btn {
  color: #04111f;
  background: linear-gradient(135deg, var(--accent), #67e8f9);
  box-shadow: 0 8px 24px rgba(56, 189, 248, .24);
}
.round-btn { width: 46px; height: 46px; border-radius: 17px; font-size: 25px; font-weight: 700; }
.ghost-btn {
  color: var(--text);
  background: rgba(148, 163, 184, .10);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 14px;
}
.primary-btn { padding: 11px 15px; border-radius: 14px; font-weight: 800; }

.todo-list, .habit-list { display: grid; gap: 10px; }
.todo {
  display: grid;
  grid-template-columns: 42px 1fr 38px;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 19px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  transition: transform .18s ease, opacity .18s ease, border-color .18s ease;
}
.todo.done { opacity: .58; }
.todo.done .todo-text { text-decoration: line-through; color: var(--muted); }
.todo.pop { animation: pop .42s ease; }
@keyframes pop { 0%{ transform: scale(.98);} 52%{ transform: scale(1.025);} 100%{ transform: scale(1);} }

.check {
  width: 36px; height: 36px; border-radius: 14px;
  display: grid; place-items: center;
  color: transparent;
  background: rgba(2, 6, 23, .44);
  border: 1px solid rgba(148, 163, 184, .24);
}
.todo.done .check { color: #032314; background: var(--accent-2); border-color: transparent; }
.todo-text { font-weight: 750; line-height: 1.25; }
.todo-meta { margin-top: 4px; color: var(--muted); font-size: 12px; }
.delete-btn { width: 38px; height: 38px; color: var(--muted); background: transparent; border-radius: 12px; }
.delete-btn:active { background: rgba(239, 68, 68, .16); color: var(--danger); }

.priority-high { border-left: 3px solid var(--danger); }
.priority-med { border-left: 3px solid var(--yellow); }
.priority-low { border-left: 3px solid var(--accent-2); }

.week-header { display: grid; grid-template-columns: 1fr repeat(7, 32px); gap: 7px; color: var(--muted); font-size: 11px; text-align: center; margin-bottom: 9px; }
.week-header span:first-child { text-align: left; }
.habit-row { display: grid; grid-template-columns: 1fr repeat(7, 32px); gap: 7px; align-items: center; }
.habit-name {
  min-width: 0;
  padding: 10px 0;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.day-cell {
  width: 32px; height: 32px; border-radius: 12px;
  display: grid; place-items: center;
  color: transparent;
  background: rgba(2, 6, 23, .42);
  border: 1px solid rgba(148, 163, 184, .18);
  transition: transform .16s ease, background .16s ease;
}
.day-cell.active { color: #04111f; background: var(--accent); box-shadow: 0 0 18px rgba(56, 189, 248, .28); }
.day-cell.today { border-color: rgba(56, 189, 248, .58); }
.day-cell:active { transform: scale(.92); }
.empty { color: var(--muted); padding: 18px 4px; text-align: center; }

.modal { border: none; padding: 0; background: transparent; color: var(--text); width: min(92vw, 440px); }
.modal::backdrop { background: rgba(2, 6, 23, .72); backdrop-filter: blur(8px); }
.modal-card {
  display: grid; gap: 12px;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: #0f172a;
  box-shadow: var(--shadow);
}
input, select {
  width: 100%;
  padding: 14px 13px;
  border-radius: 16px;
  border: 1px solid var(--border);
  outline: none;
  background: rgba(2, 6, 23, .58);
  color: var(--text);
}
input:focus, select:focus { border-color: rgba(56, 189, 248, .62); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%) translateY(24px);
  max-width: min(92vw, 460px);
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(15, 23, 42, .96);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.auth-panel p {
  color: var(--muted);
  line-height: 1.55;
  margin: 12px 0 0;
}
.auth-hint {
  padding: 12px;
  border-radius: 16px;
  background: rgba(56, 189, 248, .08);
  border: 1px solid rgba(56, 189, 248, .18);
}
.login-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 14px;
}
.login-form input {
  min-width: 0;
}
@media (max-width: 380px) {
  .login-form { grid-template-columns: 1fr; }
}
