:root {
  color-scheme: dark;
  --bg: #0d0f15;
  --surface: rgba(27, 30, 41, 0.78);
  --surface-strong: #1b1e29;
  --surface-soft: rgba(255, 255, 255, 0.055);
  --border: rgba(255, 255, 255, 0.09);
  --text: #f5f6f8;
  --muted: #9fa5b4;
  --accent: #8b7cff;
  --accent-2: #5ed8b8;
  --danger: #ff7d8d;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% -10%, rgba(139, 124, 255, 0.18), transparent 34%),
    radial-gradient(circle at 100% 18%, rgba(94, 216, 184, 0.1), transparent 30%),
    var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.ambient {
  position: fixed;
  width: 260px;
  height: 260px;
  border-radius: 999px;
  filter: blur(90px);
  pointer-events: none;
  opacity: .22;
}
.ambient-one { top: -100px; left: -100px; background: var(--accent); }
.ambient-two { top: 320px; right: -150px; background: var(--accent-2); }

.app-shell {
  position: relative;
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px 0;
}

.topbar, .section-head, .sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.eyebrow, .section-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(25px, 6vw, 34px); letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 20px; letter-spacing: -.025em; }

.avatar, .icon-button {
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface-soft);
  cursor: pointer;
}
.avatar {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  font-weight: 700;
  box-shadow: inset 0 1px rgba(255,255,255,.08);
}
.icon-button { width: 38px; height: 38px; border-radius: 13px; font-size: 26px; }

.hero-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin: 22px 0 14px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 26px;
  background:
    linear-gradient(135deg, rgba(139, 124, 255, .16), rgba(94, 216, 184, .06)),
    var(--surface);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}
.hero-copy p { display: inline; margin: 0; color: #c7cad4; font-size: 13px; }
.hero-copy h2 { margin-top: 10px; max-width: 430px; font-size: clamp(21px, 5vw, 29px); }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 99px; background: var(--accent-2); box-shadow: 0 0 14px var(--accent-2); }
.progress-ring {
  --progress: 0deg;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--progress), rgba(255,255,255,.08) 0);
  position: relative;
}
.progress-ring::after { content: ""; position: absolute; inset: 7px; border-radius: inherit; background: #171a24; }
.progress-ring span { position: relative; z-index: 1; font-size: 13px; font-weight: 700; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card {
  min-width: 0;
  padding: 15px 13px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface-soft);
}
.stat-card strong { display: block; margin: 8px 0 2px; font-size: 22px; }
.stat-card small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-icon { font-size: 15px; color: var(--accent-2); }

.section-tabs {
  display: flex;
  gap: 6px;
  margin: 22px 0 18px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255,255,255,.035);
}
.tab-button {
  flex: 1;
  padding: 10px 8px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}
.tab-button.active { color: var(--text); background: var(--surface-strong); box-shadow: 0 8px 22px rgba(0,0,0,.18); }

.content-section { display: none; animation: reveal .2s ease; }
.content-section.active { display: block; }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } }
.filter-row { display: flex; gap: 6px; }
.filter-chip, .soft-badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
}
.filter-chip { cursor: pointer; }
.filter-chip.active { color: var(--text); border-color: rgba(139,124,255,.38); background: rgba(139,124,255,.13); }

.item-list { display: grid; gap: 10px; margin-top: 14px; }
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 19px;
  background: var(--surface);
  backdrop-filter: blur(15px);
}
.list-item.done { opacity: .58; }
.item-check {
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 9px;
  background: transparent;
  color: transparent;
  cursor: pointer;
}
.item-check.checked { border-color: var(--accent-2); color: #08130f; background: var(--accent-2); }
.item-main { min-width: 0; flex: 1; }
.item-title { margin: 0; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; }
.done .item-title { text-decoration: line-through; }
.item-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; color: var(--muted); font-size: 12px; }
.item-pill { padding: 3px 7px; border-radius: 8px; background: rgba(255,255,255,.045); }
.item-delete {
  width: 33px;
  height: 33px;
  border: 0;
  border-radius: 11px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 18px;
}
.item-delete:hover { color: var(--danger); background: rgba(255,125,141,.08); }
.subscription-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: 0 0 auto; border-radius: 14px; color: var(--accent); background: rgba(139,124,255,.12); font-weight: 800; }
.empty-state { padding: 30px 18px; text-align: center; border: 1px dashed var(--border); border-radius: 22px; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 6px; color: var(--text); }

.bottom-spacer { height: 130px; }
.bottom-nav {
  position: fixed;
  z-index: 15;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(calc(100% - 24px), 500px);
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(24, 27, 37, .9);
  backdrop-filter: blur(22px);
  box-shadow: 0 20px 50px rgba(0,0,0,.4);
}
.nav-button { padding: 7px; border: 0; border-radius: 15px; color: var(--muted); background: transparent; cursor: pointer; }
.nav-button span, .nav-button small { display: block; }
.nav-button span { margin-bottom: 2px; font-size: 17px; }
.nav-button small { font-size: 10px; }
.nav-button.active { color: var(--text); background: var(--surface-soft); }
.fab {
  position: fixed;
  z-index: 17;
  right: max(20px, calc((100vw - 760px) / 2 + 20px));
  bottom: calc(max(10px, env(safe-area-inset-bottom)) + 78px);
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 20px;
  color: white;
  background: linear-gradient(145deg, #998cff, #7566ed);
  box-shadow: 0 16px 36px rgba(117,102,237,.35);
  cursor: pointer;
}
.fab span { font-size: 30px; line-height: 1; }

.sheet-backdrop {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px 12px max(12px, env(safe-area-inset-bottom));
  background: rgba(0,0,0,.57);
  backdrop-filter: blur(8px);
}
.sheet-backdrop[hidden] { display: none; }
.bottom-sheet {
  width: min(100%, 620px);
  max-height: 90vh;
  overflow-y: auto;
  padding: 10px 18px 20px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: #171a23;
  box-shadow: var(--shadow);
  animation: sheetUp .25s ease;
}
@keyframes sheetUp { from { transform: translateY(30px); opacity: .6; } }
.sheet-handle { width: 42px; height: 5px; margin: 0 auto 15px; border-radius: 9px; background: rgba(255,255,255,.15); }
.entry-form { display: grid; gap: 14px; margin-top: 20px; }
.entry-form label > span { display: block; margin-bottom: 7px; color: #c5c9d3; font-size: 13px; }
.entry-form input, .entry-form textarea, .entry-form select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 13px;
  outline: none;
  color: var(--text);
  background: rgba(255,255,255,.045);
}
.entry-form input:focus, .entry-form textarea:focus, .entry-form select:focus { border-color: rgba(139,124,255,.72); box-shadow: 0 0 0 3px rgba(139,124,255,.1); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.primary-button { margin-top: 4px; padding: 13px 16px; border: 0; border-radius: 15px; color: white; background: var(--accent); font-weight: 700; cursor: pointer; }
.primary-button:disabled { opacity: .55; cursor: wait; }
.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  top: max(18px, env(safe-area-inset-top));
  transform: translate(-50%, -20px);
  max-width: calc(100% - 32px);
  padding: 11px 15px;
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--text);
  background: #232733;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: .22s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 460px) {
  .hero-card { padding: 18px; }
  .progress-ring { width: 66px; height: 66px; }
  .stats-grid { gap: 7px; }
  .stat-card { padding: 12px 9px; }
  .stat-card small { font-size: 10px; }
  .section-tabs { display: none; }
  .content-section { margin-top: 24px; }
  .form-grid { grid-template-columns: 1fr; }
}
