:root {
  --bg: #0b1220;
  --bg-2: #111a2e;
  --card: #16203a;
  --card-2: #1c294a;
  --line: #26324f;
  --text: #eaf1ff;
  --muted: #93a1c4;
  --brand: #10b981;
  --brand-2: #34d399;
  --accent: #38bdf8;
  --warn: #f59e0b;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-synthesis: none;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win over author display rules
   (e.g. .overlay { display: grid }). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.app-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(16, 185, 129, 0.18), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(56, 189, 248, 0.12), transparent 55%),
    var(--bg);
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top));
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(8px);
  background: linear-gradient(to bottom, rgba(11, 18, 32, 0.85), rgba(11, 18, 32, 0.4));
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { border-radius: 8px; }
.brand-name { font-weight: 700; letter-spacing: -0.02em; font-size: 18px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.streak {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  font-weight: 700;
  font-size: 14px;
}
.streak-flame { filter: saturate(1.2); }
.icon-btn {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  display: grid;
  place-items: center;
  transition: transform 0.1s ease, background 0.15s ease;
}
.icon-btn:hover { background: var(--card-2); }
.icon-btn:active { transform: scale(0.94); }

/* Layout */
.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 18px 18px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.intro h1 { margin: 0 0 8px; font-size: 24px; letter-spacing: -0.02em; }
.intro p { margin: 0 0 16px; color: var(--muted); line-height: 1.5; }
.intro-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.summary-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.summary-head h2 { margin: 0; font-size: 18px; }
.muted { color: var(--muted); font-size: 13px; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 10px; }
.stat {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 8px;
  text-align: center;
}
.stat .emoji { font-size: 20px; }
.stat .count { font-weight: 800; font-size: 20px; margin-top: 2px; }
.stat .label { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Reminder cards */
.reminders { display: flex; flex-direction: column; gap: 12px; }
.rcard {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, opacity 0.2s ease;
}
.rcard.off { opacity: 0.55; }
.rcard.due { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), var(--shadow); }
.rcard .r-emoji { font-size: 28px; width: 40px; text-align: center; }
.rcard .r-main { flex: 1; min-width: 0; }
.rcard .r-title { font-weight: 700; font-size: 16px; }
.rcard .r-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.rcard .r-next { font-variant-numeric: tabular-nums; }
.toggle {
  position: relative;
  width: 46px;
  height: 28px;
  flex: none;
  cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .track {
  position: absolute;
  inset: 0;
  background: var(--line);
  border-radius: 999px;
  transition: background 0.15s ease;
}
.toggle .thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s ease;
}
.toggle input:checked + .track { background: var(--brand); }
.toggle input:checked + .track + .thumb { transform: translateX(18px); }

.pause-wrap { text-align: center; margin: 4px 0 0; }
.share-wrap { text-align: center; margin: 2px 0 0; }
.share-wrap .hint { display: block; margin-top: 6px; min-height: 18px; }

/* Install promo card */
.install-promo { border-color: rgba(16, 185, 129, 0.45); }
.ip-row { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.ip-emoji { font-size: 30px; }
.ip-title { font-weight: 700; font-size: 15px; }
.ip-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.ip-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.settings-link { color: var(--brand-2); text-decoration: none; font-weight: 600; font-size: 14px; }

/* Install guide panel */
.guide-intro { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 6px; }
.guide h3 { text-transform: none; letter-spacing: 0; color: var(--text); font-size: 16px; margin: 18px 0 8px; }
.guide ol { margin: 0; padding-left: 22px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.guide strong { color: var(--text); }

/* Buttons */
.btn {
  font: inherit;
  font-weight: 700;
  border-radius: 12px;
  padding: 12px 18px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #05241a; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--card-2); }
.btn.small { padding: 8px 14px; font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }

/* Overlay nudge */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.72);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
}
.nudge-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 30px 26px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
  animation: pop 0.25s ease;
}
@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.nudge-emoji { font-size: 56px; animation: bob 2s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.nudge-card h2 { margin: 10px 0 6px; font-size: 22px; }
.nudge-card p { color: var(--muted); margin: 0 0 22px; font-size: 15px; line-height: 1.5; }
.nudge-actions { display: flex; flex-direction: column; gap: 10px; }

/* Slide-up panels */
.panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}
.panel.open { transform: translateY(0); }
.panel-inner {
  max-width: 640px;
  margin: 0 auto;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  padding: 20px 20px calc(28px + env(safe-area-inset-bottom));
  max-height: 82vh;
  overflow-y: auto;
  box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.4);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 20px; }
.panel h3 { font-size: 15px; margin: 4px 0 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.panel hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }

.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; }
.range-inline { display: flex; align-items: center; gap: 10px; }
.range-inline span { color: var(--muted); }
input[type="time"], input[type="email"], .num {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}
.switch-row { display: flex; align-items: center; justify-content: space-between; }
.switch-row input { width: 20px; height: 20px; accent-color: var(--brand); }

.days { display: flex; gap: 6px; flex-wrap: wrap; }
.day-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
}
.day-btn.on { background: var(--brand); color: #05241a; border-color: var(--brand); }

.set-reminder {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.set-reminder:last-child { border-bottom: none; }
.set-reminder .sr-emoji { font-size: 22px; width: 30px; text-align: center; }
.set-reminder .sr-main { flex: 1; }
.set-reminder .sr-title { font-weight: 600; font-size: 14px; }
.set-reminder .sr-int { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.set-reminder .num { width: 66px; padding: 6px 8px; }
.set-reminder .sr-int span { color: var(--muted); font-size: 13px; }

/* Email */
.email-form { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.email-form input { width: 100%; }
.fineprint { color: var(--muted); font-size: 11px; margin-top: 14px; line-height: 1.4; }

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.55);
  z-index: 55;
  animation: fade 0.2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Footer */
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px 18px calc(28px + env(safe-area-inset-bottom));
}
.footer a { color: var(--brand-2); text-decoration: none; font-weight: 600; }

@media (min-width: 560px) {
  .intro-actions { flex-wrap: nowrap; }
  .nudge-actions { flex-direction: row; }
  .nudge-actions .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
