:root {
  --ink: #2c2740; --muted: #8b86a0;
  --accent: #8b7fd6; --accent-deep: #6f63bf; --accent-soft: #efecfb;
  --done: #4caf7d; --done-soft: #e3f3ea; --danger: #d56a57;
  --card: #ffffff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f1edfb 0%, #f8f4f1 55%, #f6f1f5 100%);
  background-attachment: fixed;
  min-height: 100vh;
  padding-bottom: 7rem;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; font-family: inherit; }
button:active { transform: scale(.94); }
input {
  padding: .75rem .85rem; border: 1.5px solid #ece9f4; border-radius: 14px;
  font-size: 1rem; background: #faf9fd; width: 100%; font-family: inherit;
}
input:focus { outline: none; border-color: var(--accent); background: #fff; }

.wrap { max-width: 600px; margin: 0 auto; padding: 0 1.1rem; }

/* App bar */
.appbar {
  max-width: 600px; margin: 0 auto; padding: 1.4rem 1.2rem .6rem;
  display: flex; align-items: center; justify-content: space-between;
}
.appbar .hello { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.appbar .today { color: var(--muted); font-size: .85rem; margin-top: 2px; font-weight: 500; }
.appbar .badge {
  width: 44px; height: 44px; border-radius: 15px; font-size: 1.5rem;
  display: flex; align-items: center; justify-content: center;
  background: #fff; box-shadow: 0 4px 12px rgba(90,75,160,.12);
}

/* Hero with progress ring */
.hero {
  position: relative; border-radius: 30px; margin-top: .3rem;
  padding: 1.4rem 1.2rem 1.5rem; text-align: center; color: #fff; overflow: hidden;
  background: linear-gradient(157deg, #9d8fff 0%, #7a6dce 58%, #6a5cc0 100%);
  box-shadow: 0 18px 38px rgba(108,92,200,.34);
}
.hero::before, .hero::after {
  content: ""; position: absolute; border-radius: 50%;
  background: rgba(255,255,255,.12); pointer-events: none;
}
.hero::before { width: 180px; height: 180px; top: -70px; right: -50px; }
.hero::after { width: 130px; height: 130px; bottom: -60px; left: -30px; }

.streak {
  position: absolute; top: 16px; left: 16px; z-index: 2;
  background: rgba(255,255,255,.22); color: #fff; font-weight: 700; font-size: .8rem;
  padding: .3rem .7rem; border-radius: 99px; backdrop-filter: blur(6px);
}

.ring-wrap { position: relative; width: 216px; height: 216px; margin: .8rem auto .3rem; }
.ring-wrap svg.ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring-wrap .cat {
  position: absolute; inset: 26px; display: flex; align-items: center; justify-content: center;
  animation: float 3.6s ease-in-out infinite;
}
.ring-wrap .cat svg { width: 150px; height: 142px; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.pct-big { font-size: 2.9rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.pct-label { font-size: .8rem; opacity: .85; margin-top: .15rem; }
.cat-msg { font-weight: 600; margin: .65rem auto 0; max-width: 22rem; opacity: .96; }

.cat-toggle {
  display: inline-flex; gap: .25rem; margin-top: 1.1rem;
  background: rgba(255,255,255,.18); padding: .25rem; border-radius: 99px;
}
.cat-toggle button {
  background: transparent; color: rgba(255,255,255,.85); font-size: .82rem; font-weight: 700;
  padding: .35rem .85rem; border-radius: 99px;
}
.cat-toggle button.on { background: #fff; color: var(--accent-deep); }

/* Section heading */
.section-title {
  font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 1.5rem .3rem .7rem;
}

/* Habit cards */
.habit {
  position: relative; display: flex; align-items: center; gap: .85rem;
  background: var(--card); border-radius: 22px; padding: .85rem; margin-bottom: .7rem;
  box-shadow: 0 6px 18px rgba(90,75,160,.07);
}
.habit .icon {
  width: 48px; height: 48px; border-radius: 16px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 1.55rem;
  background: var(--accent-soft);
}
.habit.done .icon { background: var(--done-soft); }
.habit .info { flex: 1; min-width: 0; }
.habit .name { font-weight: 700; font-size: 1rem; }
.habit.done .name { color: var(--done); }
.mini { height: 5px; background: #efecf6; border-radius: 99px; overflow: hidden; margin: .45rem 0 .35rem; }
.mini > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s ease; }
.habit.done .mini > span { background: var(--done); }
.sub { font-size: .78rem; color: var(--muted); font-weight: 500; }

.stepper {
  display: flex; align-items: center; gap: 0; flex: 0 0 auto;
  background: #f4f1fb; border-radius: 16px; padding: 4px;
}
.stepper.done { background: var(--done-soft); }
.stepper button {
  width: 38px; height: 38px; border-radius: 12px; font-size: 1.35rem; line-height: 1;
  display: flex; align-items: center; justify-content: center; background: transparent;
  color: var(--accent-deep);
}
.stepper.done button.dec { color: var(--done); }
.stepper .num { min-width: 1.5rem; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.stepper .plus { background: var(--accent); color: #fff; box-shadow: 0 3px 8px rgba(111,99,191,.35); }
.stepper.done .plus { background: var(--done); box-shadow: 0 3px 8px rgba(76,175,125,.35); }

.del {
  position: absolute; top: -7px; right: -7px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; color: #c9c3d6; font-size: .75rem; box-shadow: 0 2px 6px rgba(0,0,0,.12);
  display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .2s;
}
.habit:hover .del, .del:focus { opacity: 1; }
.del:hover { color: var(--danger); }

.empty {
  text-align: center; color: var(--muted); background: #fff; border-radius: 22px;
  padding: 2rem 1.2rem; box-shadow: 0 6px 18px rgba(90,75,160,.07);
}
.notice { text-align: center; color: var(--danger); background:#fff; border-radius:22px; padding:1.5rem; }

/* Floating action button */
.fab {
  position: fixed; right: max(1.1rem, calc(50% - 300px + 1.1rem)); bottom: 6.2rem;
  width: 60px; height: 60px; border-radius: 20px; z-index: 30; color: #fff; font-size: 2rem;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #9d8fff, #6f63bf);
  box-shadow: 0 12px 26px rgba(111,99,191,.5);
}

/* Bottom tab bar */
.tabbar {
  position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 25;
  display: flex; gap: 4px; padding: 6px;
  background: rgba(255,255,255,.82); backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.7); border-radius: 24px;
  box-shadow: 0 10px 28px rgba(70,55,130,.2);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: .55rem 1.25rem; border-radius: 18px; color: var(--muted);
  font-size: .68rem; font-weight: 700;
}
.tabbar a .ico { font-size: 1.3rem; }
.tabbar a.active { background: var(--accent-soft); color: var(--accent-deep); }

/* Bottom sheet */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end;
  background: rgba(35,28,65,.45); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.sheet-overlay.open { opacity: 1; pointer-events: auto; }
.sheet {
  background: #fff; width: 100%; max-width: 600px; margin: 0 auto;
  border-radius: 28px 28px 0 0; padding: 1rem 1.3rem 2rem;
  transform: translateY(100%); transition: transform .32s cubic-bezier(.2,.85,.25,1);
}
.sheet-overlay.open .sheet { transform: translateY(0); }
.grabber { width: 42px; height: 4px; background: #e6e2f0; border-radius: 99px; margin: 0 auto 1rem; }
.sheet h2 { margin: 0 0 1rem; font-size: 1.25rem; }
.sheet .row { display: flex; gap: .6rem; margin-bottom: .7rem; }
.sheet .row .emoji-in { width: 4rem; text-align: center; flex: 0 0 auto; }
.sheet .submit {
  width: 100%; margin-top: .4rem; padding: .9rem; border-radius: 16px; font-size: 1.05rem;
  font-weight: 700; color: #fff; background: linear-gradient(145deg, #9d8fff, #6f63bf);
  box-shadow: 0 8px 18px rgba(111,99,191,.4);
}

/* Coming-soon pages */
.soon {
  text-align: center; color: var(--muted); background: #fff; border-radius: 24px;
  padding: 3rem 1.5rem; box-shadow: 0 8px 22px rgba(90,75,160,.08); margin-top: 1rem;
}
.soon h2 { margin-top: 0; color: var(--ink); }

/* ---- Calendar ---- */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin: .4rem .2rem 1.1rem; }
.cal-nav .month { font-weight: 800; font-size: 1.2rem; }
.cal-nav button {
  width: 42px; height: 42px; border-radius: 14px; background: #fff; color: var(--accent-deep);
  font-size: 1.2rem; box-shadow: 0 4px 12px rgba(90,75,160,.1);
  display: flex; align-items: center; justify-content: center;
}
.weekdays, .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.weekdays { margin-bottom: 6px; }
.weekdays div { text-align: center; font-size: .68rem; color: var(--muted); font-weight: 700; }
.cell {
  aspect-ratio: 1; border-radius: 14px; background: #fff; cursor: pointer; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-weight: 600; font-size: .9rem; box-shadow: 0 3px 9px rgba(90,75,160,.05);
}
.cell.out { background: transparent; color: #c7c1d6; box-shadow: none; }
.cell.today { color: var(--accent-deep); border: 2px solid var(--accent); }
.cell.selected { background: var(--accent); color: #fff; box-shadow: 0 7px 16px rgba(111,99,191,.42); border-color: transparent; }
.dots { display: flex; gap: 3px; height: 5px; }
.dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.cell.selected .dot { background: #fff; }
.cell.out .dot { background: #d8d2e6; }

.day-head { font-weight: 800; font-size: 1.05rem; margin: 1.6rem .3rem .8rem; }

.task {
  position: relative; display: flex; align-items: center; gap: .85rem;
  background: #fff; border-radius: 20px; padding: .8rem .9rem; margin-bottom: .6rem;
  box-shadow: 0 6px 18px rgba(90,75,160,.07);
}
.task .icon {
  width: 44px; height: 44px; border-radius: 15px; flex: 0 0 auto; font-size: 1.4rem;
  display: flex; align-items: center; justify-content: center; background: var(--accent-soft);
}
.task .info { flex: 1; min-width: 0; }
.task .title { font-weight: 700; }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.task .rep { font-size: .72rem; color: var(--muted); font-weight: 600; margin-top: 2px; }
.check {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto; background: #fff;
  border: 2px solid #e1dcef; color: transparent; font-size: .9rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.check.on { background: var(--done); border-color: var(--done); color: #fff; }
.task .del {
  position: absolute; top: -7px; right: -7px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; color: #c9c3d6; font-size: .75rem; box-shadow: 0 2px 6px rgba(0,0,0,.12);
  display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .2s;
}
.task:hover .del { opacity: 1; }
.task .del:hover { color: var(--danger); }

select {
  padding: .75rem .85rem; border: 1.5px solid #ece9f4; border-radius: 14px;
  font-size: 1rem; background: #faf9fd; width: 100%; font-family: inherit; color: var(--ink);
}

/* ---- Progress ---- */
.appbar .badge.link { cursor: pointer; }
.back {
  width: 44px; height: 44px; border-radius: 15px; background: #fff; color: var(--accent-deep);
  font-size: 1.3rem; box-shadow: 0 4px 12px rgba(90,75,160,.12);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.appbar.with-back { gap: .9rem; justify-content: flex-start; }
.appbar.with-back > div:not(.badge) { flex: 1; }

.seg {
  display: flex; gap: 4px; background: #eceaf6; padding: 4px; border-radius: 16px; margin: .2rem 0 1.1rem;
}
.seg button {
  flex: 1; padding: .55rem; border-radius: 12px; background: transparent; color: var(--muted);
  font-weight: 700; font-size: .9rem;
}
.seg button.on { background: #fff; color: var(--accent-deep); box-shadow: 0 2px 6px rgba(0,0,0,.07); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin-bottom: 1.2rem; }
.stat {
  background: #fff; border-radius: 20px; padding: 1rem .6rem; text-align: center;
  box-shadow: 0 6px 18px rgba(90,75,160,.07);
}
.stat .v { font-size: 1.7rem; font-weight: 800; line-height: 1; }
.stat .l { font-size: .68rem; color: var(--muted); font-weight: 600; margin-top: .35rem; }

.panel { background: #fff; border-radius: 22px; padding: 1.1rem; box-shadow: 0 6px 18px rgba(90,75,160,.07); }
.panel h3 { margin: 0 0 1rem; font-size: .95rem; }

/* Week bars */
.week { display: flex; gap: .5rem; align-items: flex-end; }
.wk { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .35rem; }
.wk-track {
  width: 100%; max-width: 34px; height: 110px; background: #f1eef8; border-radius: 11px;
  display: flex; align-items: flex-end; overflow: hidden;
}
.wk-fill { width: 100%; background: linear-gradient(180deg, var(--accent), var(--accent-deep)); border-radius: 11px; transition: height .4s; }
.wk-fill.done { background: linear-gradient(180deg, #6ad29a, var(--done)); }
.wk-d { font-size: .68rem; color: var(--muted); font-weight: 700; }
.wk-n { font-size: .8rem; font-weight: 700; }
.wk.today .wk-n { color: var(--accent-deep); }

/* Month heatmap */
.hm-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: .9rem; }
.hm-nav .m { font-weight: 800; }
.hm-nav button { width: 36px; height: 36px; border-radius: 11px; background: #f1eef8; color: var(--accent-deep); font-size: 1.1rem; }
.hmgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.hmgrid .wd { text-align: center; font-size: .62rem; color: var(--muted); font-weight: 700; }
.hcell {
  aspect-ratio: 1; border-radius: 11px; display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 600; color: var(--ink); background: #f1eef8;
}
.hcell.out { visibility: hidden; }
.hcell.today { outline: 2px solid var(--accent-deep); outline-offset: -2px; }
.legend { display: flex; align-items: center; gap: 6px; justify-content: flex-end; margin-top: .9rem; font-size: .68rem; color: var(--muted); }
.legend .sw { width: 14px; height: 14px; border-radius: 5px; }

/* ---- Reading & Travel shared ---- */
.del { opacity: 1; } /* keep delete tappable on touch (no hover) */

.rate { display: flex; gap: 2px; font-size: 1.15rem; line-height: 1; }
.rate .s { cursor: pointer; color: #e2ddee; user-select: none; }
.rate .s.on { color: #f5b13c; }
.rate.pep .s { filter: grayscale(1); opacity: .35; }
.rate.pep .s.on { filter: none; opacity: 1; }
.rates { display: flex; flex-wrap: wrap; gap: .35rem 1rem; margin: .45rem 0 .1rem; }

/* Books */
.book {
  position: relative; display: flex; gap: .9rem; background: #fff; border-radius: 20px;
  padding: .9rem; margin-bottom: .7rem; box-shadow: 0 6px 18px rgba(90,75,160,.07);
}
.book .cover {
  width: 54px; height: 76px; border-radius: 9px; flex: 0 0 auto; color: #fff; font-weight: 800;
  font-size: 1.5rem; display: flex; align-items: center; justify-content: center;
  box-shadow: inset -4px 0 0 rgba(0,0,0,.13); text-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.binfo { flex: 1; min-width: 0; }
.btitle { font-weight: 700; }
.bauthor { color: var(--muted); font-size: .82rem; }
.bnotes {
  font-size: .8rem; color: var(--muted); margin-top: .35rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Trips */
.trip {
  position: relative; display: flex; gap: .9rem; align-items: center; background: #fff;
  border-radius: 20px; padding: .9rem; margin-bottom: .7rem; box-shadow: 0 6px 18px rgba(90,75,160,.07);
}
.trip .cover {
  width: 54px; height: 54px; border-radius: 16px; flex: 0 0 auto; font-size: 1.7rem;
  display: flex; align-items: center; justify-content: center; background: var(--accent-soft);
}
.tinfo { flex: 1; min-width: 0; }
.tplace { font-weight: 700; }
.tmeta { color: var(--muted); font-size: .8rem; margin-top: 1px; }
.tnotes {
  font-size: .8rem; color: var(--muted); margin-top: .35rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Rating input inside the add sheet */
.field-label { font-size: .8rem; color: var(--muted); font-weight: 600; margin: .3rem .2rem -.2rem; }
.rate.big { font-size: 1.7rem; gap: 4px; margin: .2rem 0 .3rem; }
