:root {
  --paper: #f6f3ee;
  --paper-deep: #ebe6de;
  --ink: #263035;
  --ink-soft: #68727a;
  --ink-faint: #a6aaa9;
  --line: rgba(38, 48, 53, .11);
  --coral: #ee8067;
  --coral-dark: #d96851;
  --lilac: #e9e5fb;
  --lilac-deep: #9585d2;
  --peach: #f6e0d5;
  --mint: #dcefe7;
  --white: #fffdfa;
  --shadow: 0 18px 50px rgba(54, 44, 34, .07);
  --shadow-small: 0 7px 20px rgba(54, 44, 34, .08);
  --radius-lg: 26px;
  --radius-md: 17px;
  --radius-sm: 11px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "DM Sans", "Avenir Next", Avenir, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(238, 128, 103, .35); outline-offset: 3px; }
[hidden] { display: none !important; }

.ambient { position: fixed; z-index: -1; pointer-events: none; border-radius: 50%; filter: blur(1px); opacity: .55; }
.ambient-one { width: 380px; height: 380px; top: -160px; right: -80px; background: radial-gradient(circle, rgba(238,128,103,.18), transparent 68%); }
.ambient-two { width: 460px; height: 460px; left: -220px; bottom: 4%; background: radial-gradient(circle, rgba(148,133,210,.11), transparent 68%); }
.app-shell { max-width: 1220px; margin: 0 auto; padding: 0 34px 34px; }
.topbar { min-height: 84px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 28px; height: 28px; display: inline-flex; align-items: end; gap: 3px; padding: 5px; border-radius: 9px; background: var(--ink); transform: rotate(-8deg); }
.brand-mark span { display: block; width: 4px; border-radius: 4px; background: var(--coral); }
.brand-mark span:nth-child(1) { height: 8px; opacity: .75; }
.brand-mark span:nth-child(2) { height: 13px; }
.brand-mark span:nth-child(3) { height: 17px; opacity: .85; }
.brand-name { font-size: 20px; letter-spacing: -.05em; font-weight: 800; }
.topbar-meta { display: flex; align-items: center; gap: 19px; color: var(--ink-soft); font-size: 11px; letter-spacing: .03em; }
.save-state { display: inline-flex; align-items: center; gap: 7px; }
.save-dot { width: 7px; height: 7px; border-radius: 50%; background: #51b995; box-shadow: 0 0 0 4px rgba(81,185,149,.13); }
.today-chip { color: var(--ink); font-weight: 700; }
.main-content { padding-top: 64px; }
.hero-row { display: flex; align-items: end; justify-content: space-between; gap: 35px; margin-bottom: 49px; }
.eyebrow, .section-kicker { margin: 0 0 14px; color: var(--ink-soft); font-size: 10px; font-weight: 800; letter-spacing: .17em; }
.eyebrow { display: flex; align-items: center; gap: 10px; }
.eyebrow-line { width: 29px; height: 2px; background: var(--coral); border-radius: 4px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 19px; font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: clamp(49px, 7vw, 83px); line-height: .91; letter-spacing: -.075em; }
h1 em { color: var(--coral); font-style: italic; }
.hero-copy { max-width: 465px; margin-bottom: 0; color: var(--ink-soft); font-size: 15px; line-height: 1.7; }
.button { border: 0; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 45px; padding: 0 18px; font-size: 12px; font-weight: 800; letter-spacing: .01em; transition: transform .2s ease, box-shadow .2s ease, background .2s ease; }
.button:hover { transform: translateY(-2px); }
.button:active { transform: translateY(0) scale(.98); }
.button-primary { color: var(--white); background: var(--ink); box-shadow: 0 9px 16px rgba(38,48,53,.14); }
.button-primary:hover { background: #111b1e; box-shadow: 0 12px 24px rgba(38,48,53,.19); }
.button-secondary { color: var(--ink); background: var(--peach); }
.button-ghost { color: var(--ink-soft); background: var(--paper-deep); }
.button-danger { color: #fff; background: #c96054; }
.button-plus { font-size: 21px; line-height: 0; font-weight: 400; margin-top: -2px; }
.hero-button { min-height: 52px; padding: 0 22px; flex-shrink: 0; }
.stats-grid { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 15px; margin-bottom: 62px; }
.stat-card { min-height: 170px; padding: 25px 26px; border-radius: var(--radius-md); background: var(--white); box-shadow: var(--shadow-small); position: relative; overflow: hidden; }
.stat-card::after { content: ""; position: absolute; width: 130px; height: 130px; right: -42px; bottom: -57px; border: 1px solid rgba(38,48,53,.07); border-radius: 50%; box-shadow: 0 0 0 15px rgba(38,48,53,.025), 0 0 0 30px rgba(38,48,53,.018); }
.stat-card-main { background: var(--ink); color: var(--white); }
.stat-card-main::after { border-color: rgba(255,255,255,.11); box-shadow: 0 0 0 15px rgba(255,255,255,.035), 0 0 0 30px rgba(255,255,255,.025); }
.stat-card-lilac { background: var(--lilac); }
.stat-card-peach { background: var(--peach); }
.stat-label { display: flex; align-items: center; gap: 7px; font-size: 9px; font-weight: 800; letter-spacing: .14em; opacity: .72; }
.stat-icon { font-size: 16px; font-weight: 400; letter-spacing: 0; }
.stat-number { margin-top: 16px; font-family: Georgia, "Times New Roman", serif; font-size: 48px; line-height: 1; letter-spacing: -.07em; }
.stat-denom { font-family: "DM Sans", sans-serif; font-size: 14px; font-weight: 700; letter-spacing: 0; opacity: .56; }
.stat-foot { margin: 9px 0 0; font-size: 11px; opacity: .63; }
.progress-track { height: 5px; max-width: 260px; margin-top: 21px; background: rgba(255,255,255,.16); border-radius: 20px; overflow: hidden; }
.progress-fill { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--coral); transition: width .55s cubic-bezier(.2,.9,.25,1); }
.section-block { margin-bottom: 64px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 21px; }
.section-heading h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(27px, 3vw, 36px); font-weight: 400; letter-spacing: -.06em; line-height: 1.05; }
.heading-spark { color: var(--coral); font-family: "DM Sans", sans-serif; font-size: .55em; vertical-align: top; margin-left: 4px; }
.section-date { color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.today-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.today-item { display: flex; align-items: center; gap: 14px; min-height: 77px; padding: 12px 16px 12px 13px; border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(255,253,250,.56); transition: border-color .2s, background .2s, transform .2s; }
.today-item:hover { border-color: rgba(38,48,53,.22); transform: translateY(-2px); background: var(--white); }
.today-item.is-done { background: var(--white); }
.today-item.is-done .today-name { color: var(--ink-soft); text-decoration: line-through; text-decoration-color: var(--coral); text-decoration-thickness: 2px; }
.habit-emoji { display: grid; place-items: center; flex-shrink: 0; width: 50px; height: 50px; border-radius: 15px; background: color-mix(in srgb, var(--habit-color) 16%, white); font-size: 25px; }
.today-copy { min-width: 0; flex: 1; }
.today-name { margin-bottom: 5px; font-size: 14px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today-sub { margin: 0; color: var(--ink-soft); font-size: 10px; }
.check-button { position: relative; display: grid; place-items: center; flex-shrink: 0; width: 42px; height: 42px; border: 2px solid var(--habit-color); border-radius: 50%; background: transparent; color: var(--white); transition: background .22s, transform .22s, box-shadow .22s; }
.check-button:hover { transform: scale(1.06); }
.check-button.is-done { border-color: var(--habit-color); background: var(--habit-color); box-shadow: 0 6px 14px color-mix(in srgb, var(--habit-color) 28%, transparent); }
.check-button svg { width: 19px; height: 19px; stroke: currentColor; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; transform: scale(0); transition: transform .22s cubic-bezier(.2,1.7,.4,1); }
.check-button.is-done svg { transform: scale(1); }
.empty-state { padding: 59px 20px 52px; border: 1px dashed rgba(38,48,53,.18); border-radius: var(--radius-lg); text-align: center; background: rgba(255,253,250,.38); }
.empty-orbit { display: flex; justify-content: center; align-items: center; gap: 15px; height: 50px; color: var(--coral); font-size: 22px; }
.empty-orbit span:nth-child(2) { color: var(--ink-faint); font-size: 15px; }
.empty-orbit span:nth-child(3) { color: var(--lilac-deep); font-size: 28px; }
.empty-state h3 { margin: 15px 0 7px; font-family: Georgia, "Times New Roman", serif; font-size: 26px; font-weight: 400; letter-spacing: -.04em; }
.empty-state p { max-width: 330px; margin: 0 auto 20px; color: var(--ink-soft); font-size: 13px; line-height: 1.6; }
.text-button { display: block; margin: 16px auto 0; padding: 4px; border: 0; color: var(--ink-soft); background: transparent; font-size: 11px; text-decoration: underline; text-underline-offset: 4px; }
.text-button:hover { color: var(--coral-dark); }
.week-section { padding: 28px 30px 27px; border-radius: var(--radius-lg); background: var(--lilac); position: relative; overflow: hidden; }
.week-section::after { content: ""; position: absolute; width: 240px; height: 240px; right: -90px; top: -125px; border: 1px solid rgba(113,98,179,.12); border-radius: 50%; box-shadow: 0 0 0 20px rgba(113,98,179,.035), 0 0 0 40px rgba(113,98,179,.025); }
.week-heading { position: relative; z-index: 1; }
.week-total { padding: 8px 11px; border-radius: 9px; color: #6f61a8; background: rgba(255,255,255,.45); font-size: 10px; font-weight: 800; }
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; position: relative; z-index: 1; }
.week-day { padding: 13px 8px 10px; border: 1px solid rgba(113,98,179,.12); border-radius: 12px; background: rgba(255,255,255,.38); text-align: center; }
.week-day.is-today { border-color: rgba(238,128,103,.6); background: rgba(255,253,250,.65); box-shadow: 0 6px 16px rgba(91,79,140,.08); }
.week-day-name { color: #756da0; font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.week-day-date { margin: 4px 0 10px; color: #7b759e; font-family: Georgia, serif; font-size: 17px; }
.week-dot { width: 27px; height: 27px; margin: auto; border-radius: 9px; background: rgba(113,98,179,.11); }
.week-dot.level-1 { background: #cdc4f1; }
.week-dot.level-2 { background: #aaa0e6; }
.week-dot.level-3 { background: #8373cc; }
.week-dot.level-4 { background: #6354ae; }
.week-count { margin-top: 8px; color: #766c9f; font-size: 9px; font-weight: 700; }
.week-message { position: relative; z-index: 1; margin: 19px 0 0; color: #70659d; font-size: 12px; }
.habit-heading { align-items: center; }
.filter-group { display: flex; gap: 4px; padding: 4px; border-radius: 11px; background: var(--paper-deep); }
.filter-button { border: 0; border-radius: 8px; padding: 8px 10px; color: var(--ink-soft); background: transparent; font-size: 10px; font-weight: 800; transition: background .2s, color .2s; }
.filter-button span { margin-left: 3px; opacity: .55; }
.filter-button.is-active { color: var(--ink); background: var(--white); box-shadow: 0 2px 5px rgba(38,48,53,.08); }
.habit-list { display: flex; flex-direction: column; gap: 15px; }
.habit-card { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); box-shadow: var(--shadow-small); overflow: hidden; animation: card-in .45s both; }
@keyframes card-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.habit-card-top { display: flex; align-items: center; gap: 15px; padding: 19px 22px 17px; border-left: 5px solid var(--habit-color); }
.habit-card-copy { min-width: 0; flex: 1; }
.habit-card-name { margin: 0 0 5px; font-size: 16px; font-weight: 800; letter-spacing: -.02em; }
.habit-card-meta { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); font-size: 10px; }
.meta-dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5; }
.streak-pills { display: flex; gap: 6px; }
.streak-pill { padding: 7px 8px; border-radius: 9px; background: var(--paper); text-align: center; min-width: 55px; }
.streak-pill strong { display: block; font-family: Georgia, serif; font-size: 18px; line-height: 1; font-weight: 400; letter-spacing: -.04em; }
.streak-pill span { display: block; margin-top: 3px; color: var(--ink-soft); font-size: 8px; font-weight: 800; letter-spacing: .05em; }
.card-actions { display: flex; gap: 4px; margin-left: 4px; }
.icon-button { width: 29px; height: 29px; padding: 0; border: 0; border-radius: 8px; color: var(--ink-faint); background: transparent; font-size: 14px; transition: color .2s, background .2s; }
.icon-button:hover { color: var(--ink); background: var(--paper); }
.icon-button.delete-button:hover { color: #c96054; background: #fae6e2; }
.heatmap-wrap { padding: 0 22px 21px; }
.heatmap-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.heatmap-label { color: var(--ink-soft); font-size: 9px; font-weight: 800; letter-spacing: .1em; }
.heatmap-legend { display: flex; align-items: center; gap: 4px; color: var(--ink-faint); font-size: 9px; }
.legend-cell { width: 9px; height: 9px; border-radius: 2px; background: color-mix(in srgb, var(--habit-color) 13%, var(--paper)); }
.legend-cell.level-1 { background: color-mix(in srgb, var(--habit-color) 34%, var(--paper)); }
.legend-cell.level-2 { background: color-mix(in srgb, var(--habit-color) 59%, var(--paper)); }
.legend-cell.level-3 { background: var(--habit-color); }
.heatmap-scroll { overflow-x: auto; padding-bottom: 5px; scrollbar-color: rgba(38,48,53,.2) transparent; }
.heatmap { display: grid; grid-template-rows: repeat(7, 10px); grid-auto-flow: column; grid-auto-columns: 10px; gap: 3px; width: max-content; }
.heat-cell { width: 10px; height: 10px; border-radius: 3px; background: color-mix(in srgb, var(--habit-color) 11%, var(--paper)); }
.heat-cell.level-1 { background: color-mix(in srgb, var(--habit-color) 36%, var(--paper)); }
.heat-cell.level-2 { background: color-mix(in srgb, var(--habit-color) 64%, var(--paper)); }
.heat-cell.level-3 { background: var(--habit-color); }
.heat-cell.future { opacity: .25; }
.heat-cell:hover { outline: 2px solid var(--habit-color); outline-offset: 1px; }
.heat-cell:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.habit-empty-filter { padding: 35px; color: var(--ink-soft); text-align: center; font-size: 13px; }
.closing-note { display: flex; justify-content: center; align-items: center; gap: 22px; padding: 15px 20px 55px; color: var(--ink-soft); text-align: center; }
.closing-note p { margin: 0; font-family: Georgia, serif; font-size: 15px; line-height: 1.5; letter-spacing: -.015em; }
.closing-note strong { color: var(--ink); font-weight: 400; }
.closing-star { color: var(--coral); font-size: 19px; }
.footer { display: flex; justify-content: space-between; padding: 20px 0 5px; border-top: 1px solid var(--line); color: var(--ink-faint); font-size: 10px; }
.footer span:first-child { color: var(--ink); font-weight: 800; }
.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(38,48,53,.36); backdrop-filter: blur(7px); animation: fade-in .2s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-card { position: relative; width: min(100%, 490px); max-height: calc(100vh - 40px); overflow-y: auto; padding: 33px 34px 31px; border-radius: 24px; background: var(--white); box-shadow: 0 25px 80px rgba(38,48,53,.25); animation: modal-in .3s cubic-bezier(.2,.9,.25,1); }
@keyframes modal-in { from { opacity: 0; transform: translateY(17px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-small { width: min(100%, 420px); text-align: center; }
.modal-close { position: absolute; top: 14px; right: 15px; width: 30px; height: 30px; border: 0; border-radius: 50%; color: var(--ink-soft); background: var(--paper); font-size: 20px; line-height: 1; }
.modal-card h2 { margin: 0 0 8px; font-family: Georgia, serif; font-size: 34px; font-weight: 400; letter-spacing: -.06em; }
.modal-copy { margin-bottom: 25px; color: var(--ink-soft); font-size: 12px; line-height: 1.6; }
.field-label { display: block; margin-bottom: 8px; color: var(--ink-soft); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.text-input { width: 100%; height: 47px; margin-bottom: 22px; padding: 0 14px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: var(--paper); font-size: 13px; }
.text-input::placeholder { color: var(--ink-faint); }
.form-field { margin-bottom: 21px; }
.emoji-grid { display: flex; flex-wrap: wrap; gap: 5px; }
.emoji-option { width: 34px; height: 34px; padding: 0; border: 1px solid transparent; border-radius: 9px; background: var(--paper); font-size: 18px; transition: transform .15s, background .15s, border .15s; }
.emoji-option:hover { transform: translateY(-2px); }
.emoji-option.is-selected { border-color: var(--coral); background: #fff0eb; box-shadow: 0 4px 9px rgba(238,128,103,.13); }
.color-row { display: flex; align-items: center; gap: 9px; }
.color-option { width: 27px; height: 27px; padding: 3px; border: 2px solid transparent; border-radius: 50%; background: transparent; }
.color-option span { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--swatch); }
.color-option.is-selected { border-color: var(--ink); }
.color-picker-wrap { display: grid; place-items: center; width: 27px; height: 27px; border: 1px dashed var(--ink-faint); border-radius: 50%; color: var(--ink-soft); font-size: 17px; cursor: pointer; }
.color-picker-wrap input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.modal-submit { width: 100%; min-height: 51px; margin-top: 4px; }
.delete-mark { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 17px; border-radius: 17px; color: #c96054; background: #fae6e2; font-size: 31px; font-weight: 300; }
.modal-actions { display: flex; gap: 9px; justify-content: center; }
.modal-actions .button { flex: 1; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 24px; display: flex; align-items: center; gap: 9px; min-width: 230px; max-width: calc(100vw - 32px); padding: 12px 17px; border-radius: 13px; color: var(--white); background: var(--ink); box-shadow: 0 13px 30px rgba(38,48,53,.2); font-size: 12px; font-weight: 700; transform: translate(-50%, 130%); transition: transform .35s cubic-bezier(.2,.9,.25,1); }
.toast.is-visible { transform: translate(-50%, 0); }
.toast-icon { color: var(--coral); }
.celebration { position: fixed; inset: 0; z-index: 25; pointer-events: none; overflow: hidden; }
.confetti { position: absolute; top: 47%; left: 50%; width: 8px; height: 13px; border-radius: 3px; background: var(--piece-color); animation: confetti-fall .9s ease-out forwards; transform: translate(-50%, -50%) rotate(0); }
@keyframes confetti-fall { 0% { opacity: 1; transform: translate(-50%, -50%) rotate(0) scale(1); } 100% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(var(--r)) scale(.7); } }
.bounce-once { animation: bounce .55s ease; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 35% { transform: translateY(-5px); } 65% { transform: translateY(1px); } }

@media (max-width: 800px) {
  .app-shell { padding: 0 20px 25px; }
  .main-content { padding-top: 46px; }
  .hero-row { align-items: start; flex-direction: column; gap: 25px; margin-bottom: 38px; }
  .hero-button { width: 100%; }
  .stats-grid { grid-template-columns: 1fr 1fr; margin-bottom: 48px; }
  .stat-card-main { grid-column: span 2; min-height: 155px; }
  .stat-card { min-height: 143px; padding: 20px; }
  .stat-number { font-size: 42px; }
  .today-list { grid-template-columns: 1fr; }
  .section-block { margin-bottom: 48px; }
  .week-section { padding: 24px 16px 22px; }
  .week-grid { gap: 5px; }
  .week-day { padding-left: 3px; padding-right: 3px; }
  .habit-heading { align-items: start; flex-direction: column; }
  .filter-group { width: 100%; }
  .filter-button { flex: 1; }
}

@media (max-width: 520px) {
  .topbar { min-height: 70px; }
  .topbar-meta { gap: 0; }
  .save-state { display: none; }
  .today-chip { font-size: 10px; }
  h1 { font-size: 55px; }
  .hero-copy { font-size: 13px; }
  .stats-grid { gap: 9px; }
  .stat-card { padding: 17px; border-radius: 14px; }
  .stat-label { font-size: 8px; letter-spacing: .1em; }
  .stat-number { margin-top: 13px; font-size: 35px; }
  .stat-foot { font-size: 10px; }
  .section-heading { align-items: start; flex-direction: column; gap: 8px; }
  .week-heading { flex-direction: row; align-items: center; }
  .week-heading h2 { max-width: 220px; }
  .week-day-name { font-size: 8px; }
  .week-day-date { font-size: 15px; }
  .week-dot { width: 23px; height: 23px; }
  .week-count { font-size: 8px; }
  .habit-card-top { flex-wrap: wrap; padding: 16px 14px 14px; gap: 10px; }
  .habit-card-name { font-size: 14px; }
  .streak-pills { gap: 4px; }
  .streak-pill { min-width: 47px; padding: 6px 5px; }
  .streak-pill strong { font-size: 16px; }
  .streak-pill span { font-size: 7px; }
  .card-actions { display: flex; width: calc(100% - 60px); justify-content: flex-end; margin: -2px 0 0 60px; padding-top: 5px; border-top: 1px solid var(--line); }
  .heatmap-wrap { padding: 0 14px 17px; }
  .modal-card { padding: 29px 22px 24px; }
  .footer { gap: 10px; flex-wrap: wrap; line-height: 1.5; }
  .closing-note { gap: 10px; padding-bottom: 35px; }
  .closing-note p { font-size: 13px; }
}
