/* =========================================================
   日迹 · DAYMARK
   A quiet home for dates, rituals, tasks and gentle nudges.
   ========================================================= */

:root {
  --bg: #f4f0e7;
  --bg-deep: #ebe4d6;
  --surface: #fffdf8;
  --surface-soft: #f8f4eb;
  --surface-sunk: #efe9dd;
  --ink: #1f2b23;
  --ink-soft: #485347;
  --muted: #6d7467;
  --muted-2: #9b9e91;
  --line: #e7dfd1;
  --line-strong: #d4cab9;
  --strong: #2a3b30;
  --strong-ink: #faf4e6;
  --panel: #26382d;
  --panel-2: #203026;
  --panel-ink: #f7f1e3;
  --panel-muted: #adb9a8;
  --gold: #dfb660;
  --gold-deep: #a77c2d;
  --gold-soft: #f4ead2;
  --gold-line: #e7d6ad;
  --hint-bg: #f5ecd8;
  --hint-ink: #5d4b29;
  --terracotta: #c66a46;
  --terracotta-soft: #f7e5da;
  --danger: #b64d40;
  --danger-soft: #f7e3df;
  --sage: #6b8060;
  --sage-soft: #e7ecdf;
  --focus: rgba(45, 63, 51, .22);
  --shadow: 0 24px 60px -42px rgba(34, 42, 32, .45);
  --shadow-soft: 0 12px 34px -30px rgba(34, 42, 32, .35);
  --radius-xl: 28px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 13px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-display: "Iowan Old Style", "Baskerville", "Bodoni 72", "Didot", "Times New Roman", "Songti SC", serif;
  --ease: cubic-bezier(.22, .82, .3, 1);
  --nav-active-bg: #2a3b30;
  --nav-active-ink: #fbf5e8;
}

:root[data-theme="dark"] {
  --bg: #171b17;
  --bg-deep: #1e231d;
  --surface: #20261f;
  --surface-soft: #272e25;
  --surface-sunk: #1c211b;
  --ink: #f1eee2;
  --ink-soft: #cdd2c5;
  --muted: #939a8c;
  --muted-2: #6e766a;
  --line: #333b31;
  --line-strong: #4a5545;
  --strong: #dde7d4;
  --strong-ink: #192017;
  --panel: #26352b;
  --panel-2: #1f2c23;
  --panel-ink: #f5f0e2;
  --panel-muted: #a9b5a4;
  --gold: #dfb968;
  --gold-deep: #e2bd70;
  --gold-soft: #34301f;
  --gold-line: #4a4129;
  --hint-bg: #2d2b1e;
  --hint-ink: #d9cfb2;
  --terracotta: #e39572;
  --terracotta-soft: #392820;
  --danger: #ec9587;
  --danger-soft: #3a2521;
  --sage: #a9b99c;
  --sage-soft: #2b3528;
  --focus: rgba(221, 231, 212, .22);
  --shadow: 0 24px 60px -40px rgba(0, 0, 0, .7);
  --shadow-soft: 0 12px 34px -28px rgba(0, 0, 0, .65);
  --nav-active-bg: #dce6d3;
  --nav-active-ink: #182016;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 300px;
  min-height: 100vh;
  min-height: 100svh;
  color: var(--ink);
  background:
    radial-gradient(1100px 560px at 88% -8%, rgba(226, 189, 120, .17), transparent 64%),
    radial-gradient(800px 500px at -12% 20%, rgba(163, 184, 157, .11), transparent 60%),
    var(--bg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color .25s ease, color .25s ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] body::before { opacity: .05; }

.no-scroll {
  overflow: hidden;
  overscroll-behavior: none;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
::selection { background: rgba(223, 182, 96, .34); }

:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 3px;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- app shell ---------- */

.app-shell {
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.topbar {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: calc(15px + env(safe-area-inset-top)) clamp(16px, 4vw, 28px) 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: none;
  display: block;
  color: var(--strong);
  filter: drop-shadow(0 6px 12px rgba(38, 56, 45, .16));
}

:root[data-theme="dark"] .brand-mark { color: #314838; filter: drop-shadow(0 8px 15px rgba(0, 0, 0, .3)); }

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.brand-copy strong {
  font-size: 19px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: .1em;
}

.brand-copy small {
  font-size: 9.5px;
  line-height: 1.3;
  color: var(--muted);
  letter-spacing: .06em;
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.today-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, .38);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .03em;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

:root[data-theme="dark"] .today-chip { background: rgba(32, 38, 31, .5); }
.today-chip .icon { width: 14px; height: 14px; }

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: transparent;
  color: var(--ink-soft);
  display: inline-grid;
  place-items: center;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}

.icon-btn:hover { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.icon-btn:active { transform: scale(.94); }
.icon-btn .icon { width: 18px; height: 18px; }

.topbar-settings { width: 36px; height: 36px; border-radius: 50%; }

.main {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 8px clamp(16px, 4vw, 28px) calc(116px + env(safe-area-inset-bottom));
}

.view { display: none; }
.view.is-active {
  display: block;
  animation: view-in .38s var(--ease) both;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}

/* ---------- shared type ---------- */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--terracotta);
  font-size: 9.5px;
  font-weight: 750;
  letter-spacing: .19em;
  line-height: 1.4;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 15px;
  height: 1px;
  background: currentColor;
  opacity: .65;
}

.eyebrow.no-rule::before { display: none; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 2px 20px;
}

.page-heading { min-width: 0; }

.page-head h1 {
  margin-top: 7px;
  font-size: clamp(30px, 8.5vw, 40px);
  font-weight: 830;
  line-height: 1.12;
  letter-spacing: -.055em;
}

.page-head .lede {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
  letter-spacing: .005em;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: none;
  padding-bottom: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: .015em;
  text-decoration: none;
  white-space: nowrap;
  transition: transform .18s var(--ease), background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease;
}

.btn .icon { width: 16px; height: 16px; }
.btn:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }

.btn-primary {
  border-color: transparent;
  background: var(--strong);
  color: var(--strong-ink);
  box-shadow: 0 9px 22px -14px rgba(34, 50, 39, .65);
}

:root[data-theme="dark"] .btn-primary { box-shadow: 0 9px 22px -16px rgba(0, 0, 0, .9); }
.btn-primary:hover { background: var(--strong); border-color: transparent; }

.btn-ghost { background: transparent; }
.btn-quiet { background: var(--surface-soft); }
.btn-danger { border-color: transparent; background: var(--danger); color: #fff7f4; }
.btn-icon { width: 42px; padding: 0; }
.btn-icon .icon { width: 18px; height: 18px; }
.btn-sm { height: 36px; padding: 0 12px; border-radius: 12px; font-size: 11.5px; }

.btn-add .icon { width: 15px; height: 15px; stroke-width: 2; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 2px 11px;
}

.section-head h2 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--ink-soft);
}

.section-head .count {
  margin-left: 5px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: .02em;
}

.section-head .quiet-action {
  border: 0;
  background: transparent;
  padding: 3px 0;
  color: var(--muted);
  font-size: 11px;
}

.section-head .quiet-action:hover { color: var(--ink); }

.chip-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  height: 33px;
  padding: 0 13px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 550;
  transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}

.chip b {
  margin-left: 4px;
  font-weight: 600;
  opacity: .65;
  font-variant-numeric: tabular-nums;
}

.chip:hover { border-color: var(--line-strong); color: var(--ink-soft); }
.chip.is-active { background: var(--strong); border-color: var(--strong); color: var(--strong-ink); }
.chip.is-active b { opacity: .7; }

/* ---------- countdown ---------- */

.event-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 13px;
}

.event-card {
  --card-bg: #f7e7d8;
  --card-line: #efd8c4;
  --card-ink: #4b3427;
  --card-soft: rgba(255, 255, 255, .42);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 218px;
  padding: 18px 18px 17px;
  border: 1px solid var(--card-line);
  border-radius: var(--radius-xl);
  background: var(--card-bg);
  color: var(--card-ink);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  animation: card-in .46s var(--ease) both;
  transition: transform .24s var(--ease), box-shadow .24s ease;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(.992); }
  to { opacity: 1; transform: none; }
}

@media (hover: hover) {
  .event-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
}

.event-card::after {
  content: "";
  position: absolute;
  right: -74px;
  bottom: -112px;
  z-index: -1;
  width: 214px;
  height: 214px;
  border-radius: 50%;
  border: 1px solid var(--card-line);
  box-shadow:
    0 0 0 28px rgba(255, 255, 255, .075),
    0 0 0 57px rgba(255, 255, 255, .045);
  opacity: .9;
}

.event-card.tone-apricot { --card-bg: #f7e5d5; --card-line: #edd5c0; --card-ink: #4f3627; }
.event-card.tone-sage { --card-bg: #e8ecdf; --card-line: #d8e0cc; --card-ink: #34422e; }
.event-card.tone-sky { --card-bg: #e3eae6; --card-line: #d2ddd7; --card-ink: #2e4541; }
.event-card.tone-butter { --card-bg: #f4ecd5; --card-line: #e8ddbf; --card-ink: #4e4124; }
.event-card.tone-rose { --card-bg: #f3e4df; --card-line: #ead3cc; --card-ink: #573531; }

:root[data-theme="dark"] .event-card.tone-apricot { --card-bg: #393025; --card-line: #4c3d2d; --card-ink: #f1dfcf; --card-soft: rgba(255, 255, 255, .06); }
:root[data-theme="dark"] .event-card.tone-sage { --card-bg: #2b3529; --card-line: #3b4737; --card-ink: #e0ead8; --card-soft: rgba(255, 255, 255, .055); }
:root[data-theme="dark"] .event-card.tone-sky { --card-bg: #263331; --card-line: #354542; --card-ink: #dbe9e5; --card-soft: rgba(255, 255, 255, .055); }
:root[data-theme="dark"] .event-card.tone-butter { --card-bg: #373224; --card-line: #4b432d; --card-ink: #f0e6cb; --card-soft: rgba(255, 255, 255, .055); }
:root[data-theme="dark"] .event-card.tone-rose { --card-bg: #382b28; --card-line: #4d3934; --card-ink: #f2ded8; --card-soft: rgba(255, 255, 255, .055); }

.event-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.event-kind {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 25px;
  padding: 0 9px;
  border: 1px solid rgba(0, 0, 0, .045);
  border-radius: 999px;
  background: var(--card-soft);
  color: currentColor;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .11em;
  opacity: .85;
}

.event-kind::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: .5;
}

.event-tools {
  display: flex;
  align-items: center;
  gap: 3px;
}

.card-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: currentColor;
  opacity: .58;
  transition: background-color .18s ease, opacity .18s ease, transform .18s ease;
}

.card-icon .icon { width: 16px; height: 16px; }
.card-icon:hover { background: var(--card-soft); opacity: 1; }
.card-icon:active { transform: scale(.92); }
.card-icon.is-on { opacity: 1; }
.card-icon.is-on .icon { fill: currentColor; stroke-width: 1.4; }

.event-title-row { margin-top: 17px; }

.event-title {
  padding-right: 8px;
  font-size: 19px;
  font-weight: 730;
  line-height: 1.38;
  letter-spacing: -.025em;
  word-break: break-word;
}

.event-date {
  margin-top: 5px;
  font-size: 10.5px;
  font-weight: 520;
  letter-spacing: .06em;
  opacity: .6;
  font-variant-numeric: tabular-nums;
}

.event-note {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 9px;
  font-size: 11.5px;
  line-height: 1.55;
  opacity: .7;
  word-break: break-word;
}

.event-count {
  margin-top: auto;
  padding-top: 24px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.event-count .prefix {
  padding-bottom: 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  opacity: .6;
}

.event-count .num {
  font-family: var(--font-display);
  font-size: clamp(58px, 15vw, 72px);
  font-weight: 500;
  line-height: .77;
  letter-spacing: -.065em;
  font-variant-numeric: lining-nums tabular-nums;
}

.event-count .unit {
  padding-bottom: 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  opacity: .7;
}

.event-card.is-today .event-count .num {
  font-family: var(--font-sans);
  font-size: 45px;
  font-weight: 820;
  line-height: .92;
  letter-spacing: -.06em;
}

.event-card.is-today .event-count .prefix { padding-bottom: 4px; }

@media (min-width: 680px) {
  .event-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
  .event-card { min-height: 232px; padding: 20px; }
  .event-title { font-size: 20px; }
}

.filter-empty {
  padding: 30px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--muted);
  text-align: center;
  font-size: 12.5px;
}

.filter-empty button {
  display: block;
  margin: 10px auto 0;
  border: 0;
  background: none;
  color: var(--terracotta);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ---------- empty state ---------- */

.empty {
  position: relative;
  overflow: hidden;
  padding: 38px 24px 34px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-xl);
  background: rgba(255, 253, 248, .32);
  text-align: center;
}

:root[data-theme="dark"] .empty { background: rgba(32, 38, 31, .38); }

.empty-art {
  width: 118px;
  margin: 0 auto 18px;
  color: var(--ink-soft);
}

.empty-art svg { width: 100%; height: auto; overflow: visible; }

.empty h2 {
  font-size: 18px;
  font-weight: 760;
  letter-spacing: -.025em;
}

.empty p {
  max-width: 280px;
  margin: 7px auto 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.65;
}

.empty .btn { margin-top: 19px; }
.empty.compact { padding: 28px 20px; border-style: solid; background: var(--surface); }
.empty.compact .empty-art { width: 82px; margin-bottom: 13px; }

/* ---------- habits ---------- */

.overview {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  margin-bottom: 15px;
  padding: 21px 20px;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(440px 240px at 100% -20%, rgba(223, 182, 96, .14), transparent 64%),
    var(--panel);
  color: var(--panel-ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  box-shadow: 0 22px 46px -34px rgba(18, 29, 21, .8);
}

.overview::after {
  content: "";
  position: absolute;
  right: -60px;
  bottom: -128px;
  z-index: -1;
  width: 210px;
  height: 210px;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 50%;
  box-shadow:
    0 0 0 28px rgba(255, 255, 255, .035),
    0 0 0 56px rgba(255, 255, 255, .022);
}

.overview-copy { min-width: 0; }
.overview .eyebrow { color: var(--gold); font-size: 9px; }
.overview .eyebrow::before { opacity: .7; }

.overview h2 {
  margin-top: 7px;
  font-size: clamp(19px, 5.5vw, 23px);
  font-weight: 750;
  line-height: 1.35;
  letter-spacing: -.035em;
}

.overview .overview-sub {
  margin-top: 5px;
  color: var(--panel-muted);
  font-size: 11.5px;
  line-height: 1.55;
}

.progress-ring {
  --pct: 0;
  position: relative;
  width: 76px;
  height: 76px;
  flex: none;
  padding: 5px;
  border-radius: 50%;
  background: conic-gradient(var(--gold) calc(var(--pct) * 1%), rgba(255, 255, 255, .13) 0);
  transition: background .3s ease;
}

.progress-ring-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.progress-ring-inner strong {
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 500;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}

.progress-ring-inner small {
  margin-top: 4px;
  color: var(--panel-muted);
  font-size: 8.5px;
  letter-spacing: .04em;
}

.habit-list {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.habit-card {
  --tint: #687f5c;
  --tint-soft: #e7ecdf;
  padding: 16px 16px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  transition: border-color .2s ease, transform .2s var(--ease);
}

@media (hover: hover) {
  .habit-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
}

:root[data-theme="dark"] .habit-card { box-shadow: none; }

.habit-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.habit-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.habit-emoji {
  width: 46px;
  height: 46px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: var(--tint-soft);
  font-size: 21px;
  line-height: 1;
}

:root[data-theme="dark"] .habit-emoji { background: var(--surface-soft); background: color-mix(in srgb, var(--tint) 24%, var(--surface)); }

.habit-copy { min-width: 0; flex: 1; }

.habit-name {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.habit-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -.015em;
}

.habit-name .icon {
  width: 13px;
  height: 13px;
  color: var(--muted-2);
  stroke-width: 1.8;
}

.habit-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.habit-meta .sep { color: var(--line-strong); }
.habit-meta b { color: var(--ink-soft); font-weight: 700; font-variant-numeric: tabular-nums; }

.habit-action {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.habit-check {
  position: relative;
  width: 46px;
  height: 46px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--muted);
  transition: background-color .22s var(--ease), border-color .22s ease, color .22s ease, transform .18s var(--ease);
}

.habit-check .icon { width: 20px; height: 20px; stroke-width: 2; }
.habit-check:hover { border-color: var(--tint); color: var(--tint); }
.habit-check:active { transform: scale(.92); }
.habit-check.is-done { border-color: transparent; background: var(--tint); color: #fffdf7; }
.habit-check.is-done:hover { border-color: transparent; color: #fffdf7; }
.habit-action-label { color: var(--muted-2); font-size: 9.5px; letter-spacing: .04em; }
.habit-check.is-done + .habit-action-label { color: var(--tint); font-weight: 600; }

.habit-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
  margin-top: 13px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

.hweek {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: var(--muted-2);
  font-size: 9px;
  line-height: 1;
}

.hweek-dot {
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 50%;
  color: transparent;
  transition: background-color .2s ease, border-color .2s ease;
}

.hweek-dot .icon { width: 10px; height: 10px; stroke-width: 2.3; }
.hweek.is-done .hweek-dot { border-style: solid; border-color: var(--tint); background: var(--tint); color: #fffdf7; }
.hweek.is-today { color: var(--ink-soft); font-weight: 700; }
.hweek.is-today .hweek-dot { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--tint); }
.hweek.is-today.is-done .hweek-dot { border-color: var(--tint); }

.habit-card.is-done-today { background: var(--surface); background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--tint-soft) 46%, var(--surface))); }
:root[data-theme="dark"] .habit-card.is-done-today { background: var(--surface); background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--tint) 9%, var(--surface))); }

/* ---------- tasks ---------- */

.quick-add {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  transition: border-color .18s ease, box-shadow .18s ease;
}

.quick-add:focus-within { border-color: var(--line-strong); box-shadow: 0 0 0 3px var(--focus); }

.quick-add > .icon { width: 18px; height: 18px; color: var(--muted-2); }
.quick-add input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  outline: 0;
  font-size: 16px;
  color: var(--ink);
}
.quick-add input::placeholder { color: var(--muted-2); font-size: 13.5px; }
.quick-add button {
  width: 38px;
  height: 38px;
  flex: none;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: var(--strong);
  color: var(--strong-ink);
  transition: transform .16s ease, opacity .16s ease;
}
.quick-add button:active { transform: scale(.92); }
.quick-add button .icon { width: 17px; height: 17px; stroke-width: 2; }

.task-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.task-summary {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.task-summary b {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 500;
  margin-right: 2px;
  letter-spacing: -.03em;
}

.task-summary .overdue-note { color: var(--danger); font-weight: 600; }

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.segmented button {
  height: 29px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color .18s ease, color .18s ease, box-shadow .18s ease;
}

.segmented button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 3px 9px -6px rgba(29, 38, 30, .5);
}

:root[data-theme="dark"] .segmented button.is-active { background: var(--line); color: var(--ink); box-shadow: none; }

.task-list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

:root[data-theme="dark"] .task-list { box-shadow: none; }

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 15px 15px 14px;
  border-top: 1px solid var(--line);
  animation: row-in .32s var(--ease) both;
}

.task-row:first-child { border-top: 0; }

@keyframes row-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.task-check {
  width: 27px;
  height: 27px;
  flex: none;
  margin-top: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .18s var(--ease);
}

.task-check .icon { width: 14px; height: 14px; stroke-width: 2.3; }
.task-check:hover { border-color: var(--sage); color: var(--sage); }
.task-check:active { transform: scale(.9); }
.task-check.is-done { border-color: var(--strong); background: var(--strong); color: var(--strong-ink); }
.task-check.is-done:hover { color: var(--strong-ink); }

.task-main {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.task-title {
  display: block;
  font-size: 14px;
  font-weight: 620;
  line-height: 1.5;
  letter-spacing: -.005em;
  word-break: break-word;
}

.task-note {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
  word-break: break-word;
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 550;
  line-height: 1;
  white-space: nowrap;
}

.meta-pill .icon { width: 11px; height: 11px; }
.meta-pill.is-today { background: var(--terracotta-soft); color: var(--terracotta); }
.meta-pill.is-overdue { background: var(--danger-soft); color: var(--danger); }
.meta-pill.is-soon { background: var(--gold-soft); color: var(--gold-deep); }
.meta-pill.is-important { background: var(--gold-soft); color: var(--gold-deep); }
.meta-pill.is-urgent { background: var(--danger-soft); color: var(--danger); }

.task-row.is-done .task-title { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.task-row.is-done .task-note { opacity: .65; }
.task-row.is-done .task-meta { opacity: .55; }

.task-list-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.task-list-foot button {
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
}

.task-list-foot button:hover { color: var(--danger); }

/* ---------- reminders ---------- */

.hint-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 36px 13px 13px;
  margin-bottom: 15px;
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-md);
  background: var(--hint-bg);
  color: var(--hint-ink);
}

.hint-icon {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: rgba(255, 255, 255, .32);
}

:root[data-theme="dark"] .hint-icon { background: rgba(255, 255, 255, .06); }
.hint-icon .icon { width: 15px; height: 15px; }

.hint-card p {
  font-size: 11px;
  line-height: 1.6;
}

.hint-card strong { font-weight: 700; }
.hint-card .hint-close {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--hint-ink);
  opacity: .5;
}
.hint-card .hint-close:hover { opacity: .9; background: rgba(255, 255, 255, .2); }
.hint-close .icon { width: 13px; height: 13px; }

.reminder-list {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.reminder-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  animation: row-in .34s var(--ease) both;
  transition: border-color .2s ease;
}

:root[data-theme="dark"] .reminder-card { box-shadow: none; }
.reminder-card.is-due { border-color: color-mix(in srgb, var(--terracotta) 48%, var(--line)); }
.reminder-card.is-done { opacity: .7; }
.reminder-card.is-done:hover { opacity: .85; }

.reminder-main {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.reminder-date {
  width: 57px;
  flex: none;
  padding: 7px 3px 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  text-align: center;
}

.reminder-date .month {
  display: block;
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: .09em;
}

.reminder-date .day {
  display: block;
  margin: 2px 0 1px;
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}

.reminder-date .weekday { display: block; color: var(--muted-2); font-size: 8.5px; line-height: 1.3; }

.reminder-card.is-due .reminder-date { background: var(--terracotta-soft); border-color: transparent; }
.reminder-card.is-due .reminder-date .month,
.reminder-card.is-due .reminder-date .weekday { color: var(--terracotta); }

.reminder-copy { flex: 1; min-width: 0; padding-top: 2px; }

.reminder-time {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--terracotta);
  font-size: 10.5px;
  font-weight: 650;
  line-height: 1.4;
  letter-spacing: .02em;
}

.reminder-time .time { font-variant-numeric: tabular-nums; letter-spacing: .05em; }
.reminder-time .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .45; }
.reminder-time .relative { color: var(--muted); font-weight: 500; }

.reminder-copy-title {
  display: block;
  margin-top: 3px;
  font-size: 15px;
  font-weight: 690;
  line-height: 1.45;
  letter-spacing: -.015em;
  word-break: break-word;
}

.reminder-copy .reminder-note {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
  word-break: break-word;
}

.reminder-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 11px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.reminder-state {
  color: var(--muted-2);
  font-size: 10px;
  line-height: 1.4;
}

.reminder-state.is-due { color: var(--terracotta); font-weight: 600; }

.rem-actions { display: flex; align-items: center; gap: 5px; }

.mini-btn {
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 550;
  white-space: nowrap;
  transition: background-color .16s ease, color .16s ease, border-color .16s ease;
}

.mini-btn .icon { width: 13px; height: 13px; }
.mini-btn:hover { background: var(--surface-soft); color: var(--ink-soft); border-color: var(--line-strong); }
.mini-btn.is-accent { border-color: transparent; background: var(--terracotta-soft); color: var(--terracotta); }
.mini-btn.is-done-btn { border-color: transparent; background: var(--strong); color: var(--strong-ink); }
.mini-btn.is-done-btn:hover { background: var(--strong); color: var(--strong-ink); }

.done-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 23px 2px 10px;
  color: var(--muted-2);
  font-size: 10px;
  letter-spacing: .08em;
}

.done-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------- bottom navigation ---------- */

.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 40;
  width: min(calc(100% - 24px), 520px);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 23px;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: 0 18px 45px -24px rgba(28, 38, 29, .55);
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
}

:root[data-theme="dark"] .tabbar { box-shadow: 0 18px 45px -22px rgba(0, 0, 0, .8); }

.tab {
  height: 50px;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  border-radius: 17px;
  background: transparent;
  color: var(--muted);
  transition: background-color .22s var(--ease), color .22s ease, transform .18s ease;
}

.tab .icon { width: 19px; height: 19px; stroke-width: 1.6; }
.tab span { font-size: 9px; font-weight: 600; line-height: 1.2; letter-spacing: .025em; }
.tab:hover { color: var(--ink-soft); }
.tab:active { transform: scale(.96); }
.tab[aria-selected="true"] { background: var(--nav-active-bg); color: var(--nav-active-ink); }
.tab[aria-selected="true"] .icon { stroke-width: 1.9; }

/* ---------- sheets ---------- */

.sheet-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  visibility: hidden;
  opacity: 0;
  transition: opacity .25s ease, visibility 0s linear .25s;
}

.sheet-layer.is-open {
  visibility: visible;
  opacity: 1;
  transition: opacity .25s ease;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 23, 17, .48);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .3s ease;
}

.sheet-layer.is-open .sheet-backdrop { opacity: 1; }

.sheet {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(100%, 620px);
  max-height: 92vh;
  max-height: min(92svh, 900px);
  transform: translate(-50%, 34px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 28px 28px 0 0;
  background: var(--surface);
  box-shadow: 0 -28px 80px rgba(15, 24, 17, .25);
  transition: transform .38s var(--ease);
}

.sheet-layer.is-open .sheet { transform: translate(-50%, 0); }
.sheet:focus { outline: none; }

.sheet-grab {
  width: 40px;
  height: 4px;
  flex: none;
  margin: 9px auto 0;
  border-radius: 999px;
  background: var(--line-strong);
  opacity: .7;
}

.sheet-head {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 20px 6px;
}

.sheet-titlebox { min-width: 0; }
.sheet-titlebox .eyebrow { font-size: 8.5px; }
.sheet-titlebox h2 {
  margin-top: 4px;
  font-size: 23px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -.045em;
  word-break: break-word;
}

.sheet-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-soft);
  border-color: transparent;
  color: var(--muted);
  flex: none;
}
.sheet-close .icon { width: 16px; height: 16px; }
.sheet-close:hover { background: var(--surface-sunk); border-color: transparent; color: var(--ink); }

.sheet-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 11px 20px 18px;
}

.sheet-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 20px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.sheet-actions .btn { flex: 1; height: 46px; border-radius: 14px; }
.sheet-actions .btn-danger { flex: 0 0 auto; padding: 0 15px; }
.sheet-actions .btn-danger .icon { width: 16px; height: 16px; }

/* ---------- forms ---------- */

.form-intro {
  margin-bottom: 17px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.6;
}

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 3px; }

.field-label,
.field > label:not(.swatch):not(.emoji-swatch):not(.priority-card) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1.4;
}

.field-label .optional,
.field > label .optional {
  color: var(--muted-2);
  font-size: 9.5px;
  font-weight: 500;
}

.input,
.textarea,
.select {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.45;
  outline: 0;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.input::placeholder,
.textarea::placeholder { color: var(--muted-2); }
.input:focus,
.textarea:focus,
.select:focus { border-color: var(--line-strong); background: var(--surface); box-shadow: 0 0 0 3px var(--focus); }
.input:invalid:not(:placeholder-shown) { border-color: color-mix(in srgb, var(--danger) 52%, var(--line)); }

.textarea { min-height: 86px; resize: vertical; }

input[type="date"],
input[type="time"] {
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  opacity: .5;
  cursor: pointer;
}

:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
:root[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator { filter: invert(1); opacity: .6; }

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.field-hint {
  margin-top: 6px;
  color: var(--muted-2);
  font-size: 10px;
  line-height: 1.55;
}

.field-hint strong { color: var(--terracotta); font-weight: 650; }

.swatch-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  padding: 2px 0;
}

.swatch {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.2;
  cursor: pointer;
}

.swatch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.swatch-dot {
  width: 34px;
  height: 34px;
  display: block;
  border: 1px solid rgba(0, 0, 0, .06);
  border-radius: 11px;
  background: var(--sw-bg);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
  transition: transform .16s var(--ease), box-shadow .16s ease;
}

.swatch input:checked + .swatch-dot {
  transform: scale(.9);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink);
}

.swatch input:focus-visible + .swatch-dot { outline: 2px solid var(--terracotta); outline-offset: 4px; }
.swatch:hover .swatch-dot { transform: scale(1.06); }
.swatch input:checked:hover + .swatch-dot { transform: scale(.92); }

.emoji-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.emoji-swatch {
  position: relative;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: transform .16s var(--ease), border-color .16s ease, background-color .16s ease;
}

.emoji-swatch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.emoji-swatch:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.emoji-swatch:has(input:checked) { border-color: var(--ink); background: var(--surface); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--ink); }
.emoji-swatch input:focus-visible { outline: 2px solid var(--terracotta); outline-offset: 3px; }

.preset-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.preset-chip {
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 9.5px;
}
.preset-chip:hover { background: var(--surface-soft); color: var(--ink-soft); }

.priority-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }

.priority-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 40px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
  text-align: center;
  cursor: pointer;
  transition: border-color .16s ease, background-color .16s ease, color .16s ease;
}

.priority-card input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.priority-card:has(input:checked) { border-color: var(--ink-soft); background: var(--surface); color: var(--ink); }
.priority-card:has(input:focus-visible) { outline: 2px solid var(--terracotta); outline-offset: 2px; }

.priority-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.priority-card[data-priority="important"] .priority-dot { background: var(--gold); }
.priority-card[data-priority="urgent"] .priority-dot { background: var(--danger); }
.priority-card:has(input:checked) .priority-dot { box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 12%, transparent); }

.form-divider { height: 1px; margin: 18px 0; background: var(--line); }

.danger-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 17px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: 11px;
  font-weight: 550;
}

.danger-link .icon { width: 14px; height: 14px; }
.danger-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.form-note {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-top: 13px;
  padding: 10px 11px;
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}
.form-note .icon { width: 13px; height: 13px; margin-top: 1px; color: var(--muted-2); }

/* ---------- habit detail ---------- */

.detail-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 0 16px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.detail-emoji {
  width: 52px;
  height: 52px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--tint-soft);
  font-size: 24px;
}

.detail-hero-copy h3 { font-size: 17px; font-weight: 750; line-height: 1.35; letter-spacing: -.02em; }
.detail-hero-copy p { margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.5; }

.detail-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  margin-bottom: 19px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.detail-stat {
  padding: 12px 6px 11px;
  border-left: 1px solid var(--line);
  background: var(--surface);
  text-align: center;
}
.detail-stat:first-child { border-left: 0; }
.detail-stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}
.detail-stat span { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; letter-spacing: .02em; }

.calendar { margin-top: 2px; }

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.calendar-title { font-size: 13px; font-weight: 700; letter-spacing: .01em; }
.calendar-nav { display: flex; align-items: center; gap: 4px; }

.cal-nav {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
}
.cal-nav:hover { background: var(--surface-soft); color: var(--ink); }
.cal-nav:disabled { opacity: .28; }
.cal-nav .icon { width: 14px; height: 14px; }

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin-bottom: 3px;
  color: var(--muted-2);
  font-size: 8.5px;
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
}

.cal-day {
  position: relative;
  aspect-ratio: 1;
  min-height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  transition: background-color .16s ease, color .16s ease, transform .14s ease;
}

.cal-day.is-blank { visibility: hidden; }
.cal-day:hover:not(:disabled) { background: var(--surface-soft); }
.cal-day:active:not(:disabled) { transform: scale(.9); }
.cal-day.is-checked { background: var(--tint); color: #fffdf7; font-weight: 650; }
.cal-day.is-checked:hover { background: var(--tint); }
.cal-day.is-today { box-shadow: inset 0 0 0 1.5px var(--terracotta); font-weight: 750; }
.cal-day.is-checked.is-today { box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 3.5px var(--terracotta); }
.cal-day:disabled { color: var(--muted-2); opacity: .4; }
.cal-day:disabled:hover { background: transparent; }

.calendar-tip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 11px;
  color: var(--muted-2);
  font-size: 9.5px;
  line-height: 1.5;
  text-align: center;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 19px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.text-danger-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: 10.5px;
}
.text-danger-btn .icon { width: 13px; height: 13px; }

/* ---------- settings ---------- */

.settings-list { margin-top: -3px; }

.setting-group {
  padding: 15px 0;
  border-top: 1px solid var(--line);
}
.setting-group:first-child { border-top: 0; padding-top: 4px; }

.setting-title {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.setting-row-main { min-width: 0; }
.setting-row h3 { font-size: 13px; font-weight: 620; line-height: 1.4; }
.setting-row p { margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.5; }

.theme-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.theme-switch button {
  height: 31px;
  padding: 0 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 550;
}
.theme-switch button.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 3px 9px -7px rgba(0, 0, 0, .5); }
:root[data-theme="dark"] .theme-switch button.is-active { background: var(--line); }

.setting-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.setting-btn {
  height: 35px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 550;
}
.setting-btn:hover { border-color: var(--line-strong); background: var(--surface); }
.setting-btn .icon { width: 13px; height: 13px; }
.setting-btn.is-danger { color: var(--danger); }

.data-summary {
  padding: 11px 12px;
  margin-top: 10px;
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.65;
}

.about-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 7px;
  padding: 12px;
  border-radius: 13px;
  background: var(--surface-soft);
}

.about-mark .brand-mark { width: 34px; height: 34px; }
.about-mark h3 { font-size: 12.5px; font-weight: 700; letter-spacing: .08em; }
.about-mark p { margin-top: 1px; color: var(--muted); font-size: 9px; letter-spacing: .02em; }

.version-line {
  margin-top: 12px;
  color: var(--muted-2);
  font-size: 9px;
  line-height: 1.6;
  text-align: center;
}

.install-steps {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 4px;
}
.install-step {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 11px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.install-step-num {
  width: 20px;
  height: 20px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--terracotta);
  font-size: 9px;
  font-weight: 700;
}

/* ---------- dialogs ---------- */

.dialog-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 22px;
  visibility: hidden;
  opacity: 0;
  transition: opacity .22s ease, visibility 0s linear .22s;
}

.dialog-layer.is-open {
  visibility: visible;
  opacity: 1;
  transition: opacity .22s ease;
}

.dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 21, 15, .54);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.dialog-card {
  position: relative;
  width: min(100%, 370px);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 23px;
  background: var(--surface);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .5);
  transform: translateY(10px) scale(.98);
  transition: transform .26s var(--ease);
}

.dialog-layer.is-open .dialog-card { transform: none; }

.dialog-icon {
  width: 42px;
  height: 42px;
  margin-bottom: 13px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--terracotta-soft);
  color: var(--terracotta);
}

.dialog-icon.is-warm { background: var(--gold-soft); color: var(--gold-deep); }
.dialog-icon.is-danger { background: var(--danger-soft); color: var(--danger); }
.dialog-icon .icon { width: 20px; height: 20px; }

.dialog-card h2 { font-size: 18px; font-weight: 760; line-height: 1.35; letter-spacing: -.025em; }
.dialog-card > p { margin-top: 7px; color: var(--muted); font-size: 11.5px; line-height: 1.65; }

.dialog-extra:empty { display: none; }
.dialog-extra { margin-top: 12px; }

.dialog-reminder-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 190px;
  overflow-y: auto;
}

.dialog-reminder-item {
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
}
.dialog-reminder-item strong { display: block; font-size: 12px; font-weight: 650; line-height: 1.4; }
.dialog-reminder-item span { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }

.dialog-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}
.dialog-actions .btn { flex: 1; height: 43px; border-radius: 13px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 120;
  max-width: calc(100% - 38px);
  padding: 10px 14px 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 13px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: 0 16px 36px -18px rgba(0, 0, 0, .55);
  font-size: 11.5px;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity .22s ease, transform .28s var(--ease);
}

:root[data-theme="dark"] .toast { background: #f0ecdf; color: #1a2219; }

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast-dot { width: 5px; height: 5px; flex: none; border-radius: 50%; background: var(--gold); }
.toast.is-error .toast-dot { background: #ef9c7b; }
.toast.is-success .toast-dot { background: #b9d39f; }

/* ---------- confetti ---------- */

.confetti {
  position: fixed;
  z-index: 130;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  pointer-events: none;
  background: var(--gold);
  animation: confetti-pop .72s var(--ease) forwards;
}

@keyframes confetti-pop {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.4) rotate(130deg); }
}

/* ---------- small screens ---------- */

@media (max-width: 390px) {
  .brand-copy small { display: none; }
  .topbar { padding-top: calc(12px + env(safe-area-inset-top)); }
  .page-head { padding-top: 4px; gap: 10px; }
  .page-head h1 { font-size: 31px; }
  .page-head .lede { font-size: 12.5px; }
  .head-actions .btn-label { display: none; }
  .head-actions .btn { width: 42px; padding: 0; }
  .head-actions .btn.btn-export { width: 36px; height: 38px; border-radius: 12px; }
  .overview { padding: 18px 16px; border-radius: 24px; gap: 12px; }
  .overview h2 { font-size: 19px; }
  .overview .overview-sub { font-size: 10.5px; }
  .progress-ring { width: 68px; height: 68px; }
  .progress-ring-inner strong { font-size: 22px; }
  .event-card { min-height: 205px; padding: 16px 16px 15px; border-radius: 24px; }
  .event-title { font-size: 18px; margin-top: 15px; }
  .event-count .num { font-size: 58px; }
  .habit-card { padding: 14px 14px 12px; border-radius: 21px; }
  .habit-emoji { width: 42px; height: 42px; border-radius: 14px; font-size: 19px; }
  .habit-check { width: 43px; height: 43px; }
  .habit-title { font-size: 14.5px; }
  .habit-week { margin-top: 11px; padding-top: 10px; }
  .hweek-dot { width: 18px; height: 18px; }
  .quick-add { padding-left: 12px; }
  .task-summary b { font-size: 19px; }
  .segmented button { padding: 0 8px; font-size: 10px; }
  .reminder-card { padding: 13px; border-radius: 21px; }
  .reminder-date { width: 52px; border-radius: 12px; }
  .reminder-date .day { font-size: 24px; }
  .reminder-copy h3 { font-size: 14px; }
  .mini-btn { padding: 0 7px; }
  .sheet-head, .sheet-body { padding-left: 17px; padding-right: 17px; }
  .sheet-actions { padding-left: 17px; padding-right: 17px; }
  .sheet-titlebox h2 { font-size: 21px; }
  .tabbar { width: calc(100% - 20px); }
}

@media (max-width: 345px) {
  .habit-week { gap: 1px; }
  .hweek-dot { width: 17px; height: 17px; }
  .reminder-foot { align-items: flex-start; flex-direction: column; }
  .rem-actions { align-self: flex-end; }
  .field-row { grid-template-columns: 1fr; }
}

@media (min-width: 720px) {
  .main { padding-top: 14px; }
  .page-head { padding-top: 12px; padding-bottom: 24px; }
  .page-head .lede { font-size: 13px; }
  .event-card { min-height: 238px; }
  .event-count .num { font-size: 74px; }
  .habit-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .habit-card { padding: 18px 18px 15px; }
  .reminder-card { padding: 17px; }
  .sheet { border-radius: 28px 28px 0 0; }
}

@media (min-width: 1000px) {
  .topbar { padding-top: 24px; }
  .main { padding-bottom: 130px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- no script ---------- */

.noscript {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 30px;
  background: var(--bg);
  color: var(--ink);
  text-align: center;
  font-size: 14px;
}
