:root {
  --paper: #f4f0e8;
  --paper-deep: #eae3d8;
  --ink: #18342e;
  --ink-muted: #69756f;
  --accent: #f26a3d;
  --accent-soft: #f8d5c8;
  --line: rgba(24, 52, 46, 0.16);
  --white: #fffdf8;
  --shadow: 0 24px 70px rgba(45, 50, 43, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.9), transparent 26rem),
    var(--paper);
  font-family: "DM Sans", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.2;
  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='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.12'/%3E%3C/svg%3E");
}

.site-header,
main,
footer {
  width: min(1100px, calc(100% - 48px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0;
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--ink);
  font-weight: 700;
  font-size: 18px;
  text-decoration: none;
}

.brand-icons {
  display: flex;
}

.brand-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
}

.brand-icon + .brand-icon {
  margin-left: -8px;
}

.brand-icon svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.55;
}

.brand-icon--strength {
  z-index: 1;
  border-color: var(--accent);
  color: white;
  background: var(--accent);
}

.streak-pill {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.56);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: 180ms ease;
}

.streak-pill:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.streak-pill span:first-child {
  color: var(--accent);
}

.hero {
  max-width: 760px;
  margin: 84px auto 44px;
  text-align: center;
  animation: rise 700ms both;
}

.eyebrow,
.section-kicker {
  margin: 0 0 18px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.hero h1 {
  margin: 0;
  color: #111111;
  font-family: "DM Serif Display", serif;
  font-size: clamp(56px, 8vw, 92px);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 0.92;
}

.hero h1 em {
  color: inherit;
  font-weight: inherit;
}

.intro {
  max-width: 510px;
  margin: 28px auto 0;
  color: var(--ink-muted);
  font-size: 17px;
  line-height: 1.65;
}

.goal-shell {
  position: relative;
  max-width: 720px;
  min-height: 230px;
  margin: 0 auto;
  animation: rise 700ms 120ms both;
}

.goal-form,
.active-goal {
  padding: 32px;
  border: 1px solid rgba(24, 52, 46, 0.12);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.goal-form label {
  display: block;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 700;
}

.input-wrap {
  display: flex;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1.5px solid var(--ink);
}

.input-wrap:focus-within {
  border-color: var(--accent);
}

.input-wrap input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-family: "DM Serif Display", serif;
  font-size: clamp(22px, 4vw, 30px);
}

.input-wrap input::placeholder {
  color: #b6b6ad;
}

.arrow-button {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: white;
  background: var(--accent);
  cursor: pointer;
  font-size: 24px;
  transition: 180ms ease;
}

.arrow-button:hover {
  transform: rotate(-5deg) scale(1.05);
}

.form-meta,
.goal-topline {
  display: flex;
  justify-content: space-between;
  margin-top: 15px;
  color: var(--ink-muted);
  font-size: 11px;
}

.active-goal {
  overflow: hidden;
  background: var(--ink);
  color: var(--white);
}

.goal-topline {
  margin: 0;
  color: rgba(255, 255, 255, 0.52);
  font-weight: 700;
  letter-spacing: 0.12em;
}

.text-button {
  padding: 0;
  border: 0;
  color: rgba(255, 255, 255, 0.7);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  letter-spacing: 0;
}

.text-button:hover {
  color: white;
}

.goal-content {
  display: flex;
  gap: 20px;
  align-items: center;
  min-height: 94px;
}

.goal-content p {
  margin: 0;
  font-family: "DM Serif Display", serif;
  font-size: clamp(26px, 5vw, 38px);
  line-height: 1.12;
  overflow-wrap: anywhere;
  transition: 250ms ease;
}

.goal-status-mark {
  display: grid;
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  place-items: center;
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  transition: 220ms ease;
}

.goal-status-mark svg {
  grid-area: 1 / 1;
  width: 25px;
  fill: none;
  stroke: white;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  opacity: 0;
  transform: scale(0.4);
  transition: 220ms ease;
}

.goal-status-mark > span {
  grid-area: 1 / 1;
  font-size: 27px;
  line-height: 1;
  opacity: 0;
  transform: scale(0.4);
  transition: 220ms ease;
}

.active-goal.is-done .goal-status-mark {
  border-color: var(--accent);
  background: var(--accent);
}

.active-goal.is-done .goal-status-mark svg,
.active-goal.is-missed .goal-status-mark > span {
  opacity: 1;
  transform: scale(1);
}

.active-goal.is-missed .goal-status-mark {
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.12);
}

.active-goal.is-done .goal-content p,
.active-goal.is-missed .goal-content p {
  color: rgba(255, 255, 255, 0.55);
  text-decoration: line-through;
}

.active-goal.is-done .goal-content p {
  text-decoration-color: var(--accent);
}

.checkin {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-top: 12px;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
}

.checkin[hidden] {
  display: none;
}

.checkin-kicker {
  margin: 0 0 5px;
  color: rgba(255, 255, 255, 0.42);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.checkin h3 {
  margin: 0;
  font-family: "DM Serif Display", serif;
  font-size: 22px;
  font-weight: 400;
}

.status-actions {
  display: flex;
  gap: 8px;
}

.status-button {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  padding: 10px 13px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  color: white;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: 180ms ease;
}

.status-button:hover {
  border-color: rgba(255, 255, 255, 0.55);
  transform: translateY(-1px);
}

.status-button--done {
  border-color: var(--accent);
  background: var(--accent);
}

.status-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 12px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
}

.status-result[hidden] {
  display: none;
}

.status-result p {
  margin: 0;
  color: rgba(255, 255, 255, 0.66);
  font-size: 13px;
}

.status-result-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 14px;
  align-items: center;
}

.text-button--reset {
  color: rgba(255, 255, 255, 0.45);
}

.routine-note {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  max-width: 720px;
  margin: 20px auto 0;
  color: var(--ink-muted);
  font-size: 10px;
}

.routine-note > span {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.12em;
}

.routine-note i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--line);
}

.week-section {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: flex-end;
  max-width: 720px;
  margin: 78px auto 0;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  animation: rise 700ms 240ms both;
}

.week-section .section-kicker {
  margin-bottom: 8px;
}

.week-section h2,
.history-dialog h2 {
  margin: 0;
  font-family: "DM Serif Display", serif;
  font-size: 28px;
  font-weight: 400;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 32px);
  gap: 9px;
}

.week-legend {
  display: flex;
  grid-column: 1 / -1;
  gap: 16px;
  justify-content: flex-end;
  margin-top: 18px;
  color: var(--ink-muted);
  font-size: 9px;
}

.week-legend span {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line);
}

.legend-dot--done {
  background: var(--accent);
}

.legend-dot--missed {
  background: #9da49f;
}

.day {
  text-align: center;
}

.day-dot {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-muted);
  font-size: 10px;
}

.day.done .day-dot {
  border-color: var(--accent);
  color: white;
  background: var(--accent);
}

.day.missed .day-dot {
  border-color: #9da49f;
  color: white;
  background: #9da49f;
}

.day.today .day-dot {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.day-label {
  display: block;
  margin-top: 7px;
  color: var(--ink-muted);
  font-size: 9px;
  text-transform: uppercase;
}

footer {
  display: flex;
  justify-content: space-between;
  margin-top: 100px;
  padding: 24px 0 34px;
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 12px;
}

footer p {
  margin: 0;
}

.history-dialog {
  width: min(560px, calc(100% - 32px));
  max-height: min(680px, calc(100vh - 40px));
  padding: 28px;
  border: 0;
  border-radius: 20px;
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 30px 100px rgba(24, 52, 46, 0.3);
}

.history-dialog::backdrop {
  background: rgba(24, 52, 46, 0.42);
  backdrop-filter: blur(4px);
}

.history-dialog[open] {
  animation: dialog-in 220ms ease-out both;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.dialog-heading .section-kicker {
  margin-bottom: 6px;
}

.close-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.history-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.history-stat {
  padding: 12px;
  border-radius: 11px;
  background: var(--paper);
}

.history-stat strong,
.history-stat span {
  display: block;
}

.history-stat strong {
  font-family: "DM Serif Display", serif;
  font-size: 22px;
  font-weight: 400;
}

.history-stat span {
  margin-top: 2px;
  color: var(--ink-muted);
  font-size: 9px;
  text-transform: uppercase;
}

.history-list {
  display: grid;
  gap: 10px;
  overflow-y: auto;
}

.history-item {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.history-status {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--accent);
}

.history-item.is-missed .history-status {
  background: #9da49f;
}

.history-item p {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.history-item time,
.empty-history {
  color: var(--ink-muted);
  font-size: 11px;
}

.empty-history {
  padding: 28px 0;
  text-align: center;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 10;
  padding: 12px 18px;
  border-radius: 999px;
  color: white;
  background: var(--ink);
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: 220ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.confetti-piece {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 20;
  width: 7px;
  height: 12px;
  border-radius: 2px;
  pointer-events: none;
  animation: burst 900ms cubic-bezier(0.1, 0.7, 0.2, 1) forwards;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@keyframes burst {
  to {
    opacity: 0;
    transform: translate(var(--x), var(--y)) rotate(var(--r));
  }
}

@media (max-width: 640px) {
  .site-header,
  main,
  footer {
    width: min(100% - 28px, 1100px);
  }

  .site-header {
    padding-top: 18px;
  }

  .hero {
    margin-top: 58px;
  }

  .hero h1 {
    font-size: clamp(50px, 17vw, 72px);
  }

  .intro {
    font-size: 15px;
  }

  .goal-form,
  .active-goal {
    padding: 24px 20px;
  }

  .checkin {
    display: block;
  }

  .status-actions {
    margin-top: 16px;
  }

  .status-button {
    flex: 1;
  }

  .status-result {
    align-items: flex-start;
    flex-direction: column;
  }

  .routine-note {
    flex-wrap: wrap;
    gap: 6px 9px;
    padding-inline: 16px;
    line-height: 1.5;
    text-align: center;
  }

  .week-section {
    display: block;
    margin-top: 54px;
  }

  .week-grid {
    grid-template-columns: repeat(7, 1fr);
    margin-top: 24px;
  }

  .week-legend {
    justify-content: flex-start;
  }

  .day-dot {
    width: 30px;
    height: 30px;
    margin: auto;
  }
}

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