:root {
  --bg: #0b1220;
  --card: rgba(12, 18, 32, 0.72);
  --card-solid: rgba(18, 26, 44, 0.88);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f4f7fb;
  --muted: #a9b4c7;
  --accent: #3ec7c2;
  --accent-2: #f0a35a;
  --danger: #ff7b7b;
  --ok: #5dde9a;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

.bg {
  position: fixed; inset: 0;
  background:
    linear-gradient(180deg, rgba(8,12,22,.35) 0%, rgba(8,12,22,.78) 48%, rgba(8,12,22,.92) 100%),
    url("assets/bg.png") center/cover no-repeat;
  filter: saturate(1.05);
  z-index: 0;
}

.app {
  position: relative; z-index: 1;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 12px 14px calc(10px + var(--safe-b));
}

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 2px 10px;
}
.brand { font-weight: 800; letter-spacing: .02em; font-size: 18px; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.ghost-btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.06);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
}

main {
  overflow: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.card {
  background: var(--card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}
.card.highlight {
  border-color: rgba(62, 199, 194, .55);
  box-shadow: 0 0 0 1px rgba(62,199,194,.2), var(--shadow);
}

.h-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.h1 { font-size: 26px; font-weight: 800; margin: 0; }
.h2 { font-size: 15px; font-weight: 700; margin: 0; }
.muted { color: var(--muted); font-size: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(62,199,194,.15);
  color: var(--accent);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}

.stats {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 12px;
  align-items: center;
}
.streak-num { font-size: 22px; font-weight: 800; }
.ring-wrap { display: grid; place-items: center; }
.ring {
  --p: 66;
  width: 84px; height: 84px; border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), rgba(255,255,255,.12) 0);
  display: grid; place-items: center;
}
.ring > span {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(10,14,24,.92);
  display: grid; place-items: center;
  text-align: center;
  font-size: 13px; font-weight: 700; line-height: 1.15;
}

.task {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid transparent;
  margin-top: 8px;
}
.task.done { opacity: .55; }
.task.done .title { text-decoration: line-through; }
.check {
  width: 24px; height: 24px; border-radius: 8px;
  border: 2px solid var(--accent);
  background: transparent;
  color: #041016;
  font-weight: 800;
  display: grid; place-items: center;
  padding: 0;
}
.task.done .check { background: var(--accent); }
.title { font-weight: 650; font-size: 14px; }
.desc { color: var(--muted); font-size: 11px; margin-top: 3px; }
.time-pill {
  font-size: 11px;
  color: #ffe0b8;
  background: rgba(240,163,90,.18);
  border-radius: 999px;
  padding: 5px 8px;
  white-space: nowrap;
}

.bar {
  height: 8px; border-radius: 999px;
  background: rgba(255,255,255,.1);
  overflow: hidden;
  margin-top: 8px;
}
.bar > i {
  display: block; height: 100%;
  width: var(--w, 0%);
  background: linear-gradient(90deg, var(--accent), #7be7e2);
}

.list-row {
  display: flex; gap: 10px; align-items: center;
  padding: 11px 4px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.list-row:last-child { border-bottom: 0; }
.buf {
  border: 1px dashed rgba(255,255,255,.22);
  border-radius: 12px;
  color: var(--muted);
  padding: 12px;
  margin-top: 8px;
  text-align: center;
  font-size: 13px;
}

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btn {
  border: 0; border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: #06201f; }
.btn.ghost {
  background: rgba(255,255,255,.08);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn.danger { background: rgba(255,123,123,.18); color: #ffc9c9; }

.field { margin-top: 10px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.28);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}
.field textarea { min-height: 72px; resize: vertical; }

.tabbar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 8px 4px;
  border-radius: 18px;
  background: rgba(8, 12, 22, .82);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.tabbar button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 4px;
  border-radius: 12px;
  font-size: 11px;
  display: grid;
  gap: 2px;
  place-items: center;
}
.tabbar button span { font-size: 15px; }
.tabbar button.active {
  color: var(--accent);
  background: rgba(62,199,194,.12);
}

.modal {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0,0,0,.55);
  display: grid; place-items: end center;
  padding: 12px;
}
.modal.hidden { display: none; }
.modal-card {
  width: min(480px, 100%);
  background: var(--card-solid);
  border: 1px solid var(--line);
  border-radius: 20px 20px 14px 14px;
  padding: 16px;
  max-height: 80vh;
  overflow: auto;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.quote {
  text-align: center;
  color: #d7e0ef;
  font-size: 13px;
  line-height: 1.55;
  margin: 8px 4px 6px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
}
.quote .src {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}
.badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: middle;
}
.badge.habit { background: rgba(240,163,90,.2); color: #ffd19a; }
.badge.extra { background: rgba(62,199,194,.18); color: #9eefe9; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 30;
  background: rgba(20, 28, 44, .94);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 90vw;
}
.toast.hidden { display: none; }
.toast button {
  border: 0;
  background: var(--accent);
  color: #06201f;
  font-weight: 700;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
}

.quote-card {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  margin-top: 8px;
}
.quote-card.starred {
  border-color: rgba(240,163,90,.45);
}
.quote-card .qtext {
  font-size: 14px;
  line-height: 1.55;
  font-weight: 650;
}
.quote-card .qmeta {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
}
.quote-actions {
  display: flex;
  gap: 6px;
}
.edit-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
  margin-top: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.edit-item .field { margin-top: 0; }

@media (min-width: 900px) {
  .app { max-width: 430px; border-left: 1px solid rgba(255,255,255,.05); border-right: 1px solid rgba(255,255,255,.05); }
}
