:root {
  color-scheme: dark;
  --ink: #0b0904;
  --surface: #11100e;
  --surface-strong: #171510;
  --gold: #f1b440;
  --paper: #faf7f1;
  --muted: rgba(250, 247, 241, 0.58);
  --line: rgba(250, 247, 241, 0.11);
  --gold-soft: rgba(241, 180, 64, 0.14);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

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

.site-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--paper);
  text-decoration: none;
}

.brand-logo {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 15px;
  background-image: url("./assets/cwd-logo-reference.jpeg");
  background-repeat: no-repeat;
  background-position: -17px -127px;
  background-size: 450px 974px;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-name {
  color: var(--gold);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.brand-product {
  color: var(--paper);
  font-size: 0.86rem;
  font-weight: 750;
  letter-spacing: 0.01em;
}

.topbar-date {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.page-intro {
  padding: 34px 0 24px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 7px;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.page-intro h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.35rem, 5vw, 4.4rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.045em;
}

.page-intro > p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(350px, 0.92fr);
  gap: 18px;
  align-items: stretch;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.daily-panel {
  min-height: 622px;
  display: flex;
  flex-direction: column;
  padding: 26px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.panel-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  font-weight: 500;
  line-height: 1.15;
}

.progress-ring {
  --progress: 0deg;
  width: 66px;
  height: 66px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  position: relative;
  border-radius: 50%;
  background: conic-gradient(var(--gold) var(--progress), rgba(250, 247, 241, 0.1) 0);
  transition: background 240ms ease;
}

.progress-ring::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: inherit;
  background: var(--surface);
}

.progress-ring strong {
  position: relative;
  z-index: 1;
  font-size: 0.85rem;
}

.add-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
  margin: 25px 0 18px;
}

.add-form input {
  min-width: 0;
  height: 50px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--ink);
  color: var(--paper);
}

.add-form input::placeholder {
  color: rgba(250, 247, 241, 0.4);
}

.add-form button {
  height: 50px;
  padding: 0 21px;
  border: 0;
  border-radius: 13px;
  background: var(--gold);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.add-form button:hover {
  filter: brightness(1.06);
}

.past-day-notice {
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 50px;
  margin: 25px 0 18px;
  padding: 10px 13px 10px 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--muted);
  font-size: 0.9rem;
}

.past-day-notice:not([hidden]) {
  display: flex;
}

.past-day-notice button {
  border: 0;
  background: transparent;
  color: var(--gold);
  font-weight: 700;
  cursor: pointer;
}

.habit-list {
  display: grid;
  gap: 9px;
}

.habit-item {
  min-height: 58px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 9px 10px 9px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
  transition: border-color 180ms ease, opacity 180ms ease;
}

.habit-item.is-complete {
  border-color: rgba(241, 180, 64, 0.4);
}

.habit-check {
  appearance: none;
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  margin: 0;
  border: 1px solid rgba(250, 247, 241, 0.28);
  border-radius: 7px;
  background: var(--ink);
  cursor: pointer;
}

.habit-check::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: translateY(-1px) rotate(-45deg) scale(0);
  transition: transform 150ms ease;
}

.habit-check:checked {
  border-color: var(--gold);
  background: var(--gold);
}

.habit-check:checked::after {
  transform: translateY(-1px) rotate(-45deg) scale(1);
}

.habit-title {
  overflow-wrap: anywhere;
  color: var(--paper);
  font-weight: 650;
}

.habit-item.is-complete .habit-title {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--gold);
}

.remove-habit {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  cursor: pointer;
}

.remove-habit:hover {
  background: var(--gold-soft);
  color: var(--gold);
}

.empty-state {
  flex: 1;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 34px 16px;
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-icon {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  margin-bottom: 15px;
  border: 1px solid rgba(241, 180, 64, 0.45);
  border-radius: 50%;
  color: var(--gold);
  font-size: 1.7rem;
  font-weight: 300;
}

.empty-state h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  font-weight: 500;
}

.empty-state p {
  max-width: 360px;
  margin: 8px 0 18px;
  color: var(--muted);
  font-size: 0.92rem;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
}

.suggestions button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--paper);
  font-size: 0.84rem;
  cursor: pointer;
}

.suggestions button:hover {
  border-color: rgba(241, 180, 64, 0.5);
  color: var(--gold);
}

.daily-summary {
  margin-top: auto;
  padding-top: 18px;
  color: var(--muted);
  font-size: 0.88rem;
}

.side-column {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 18px;
}

.calendar-panel,
.progress-panel {
  padding: 22px;
}

.compact-heading h2 {
  font-size: 1.25rem;
}

.calendar-controls {
  display: flex;
  gap: 6px;
}

.calendar-controls button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--paper);
  font-size: 1.35rem;
  cursor: pointer;
}

.calendar-controls button:hover:not(:disabled) {
  border-color: rgba(241, 180, 64, 0.48);
  color: var(--gold);
}

.calendar-controls button:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

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

.weekdays {
  margin: 20px 0 7px;
  color: rgba(250, 247, 241, 0.42);
  font-size: 0.68rem;
  text-align: center;
}

.calendar-day,
.calendar-blank {
  min-width: 0;
  aspect-ratio: 1;
}

.calendar-day {
  position: relative;
  border: 1px solid transparent;
  border-radius: 9px;
  background: rgba(250, 247, 241, 0.045);
  color: var(--muted);
  font-size: 0.76rem;
  cursor: pointer;
}

.calendar-day[data-level="1"] { background: rgba(241, 180, 64, 0.16); color: var(--paper); }
.calendar-day[data-level="2"] { background: rgba(241, 180, 64, 0.31); color: var(--paper); }
.calendar-day[data-level="3"] { background: rgba(241, 180, 64, 0.52); color: var(--paper); }
.calendar-day[data-level="4"] { background: var(--gold); color: var(--ink); font-weight: 800; }

.calendar-day:hover:not(:disabled) {
  border-color: rgba(241, 180, 64, 0.72);
}

.calendar-day.is-selected {
  border-color: var(--paper);
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 3px var(--paper);
}

.calendar-day.is-today::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  transform: translateX(-50%);
}

.calendar-day:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.calendar-legend {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 12px;
  color: rgba(250, 247, 241, 0.42);
  font-size: 0.7rem;
}

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

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
}

.legend-dot.empty { background: rgba(250, 247, 241, 0.12); }
.legend-dot.complete { background: var(--gold); }

.weekly-rate {
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.6rem;
  font-weight: 500;
}

.bar-chart {
  height: 132px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 7px;
  margin-top: 23px;
  padding-top: 20px;
  border-bottom: 1px solid var(--line);
}

.bar-column {
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: end;
  gap: 7px;
  text-align: center;
}

.bar-track {
  width: min(26px, 70%);
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-self: center;
  border-radius: 7px 7px 0 0;
  background: rgba(250, 247, 241, 0.055);
  overflow: hidden;
}

.bar-fill {
  width: 100%;
  min-height: 2px;
  border-radius: 7px 7px 0 0;
  background: var(--gold);
  opacity: 0.9;
  transition: height 240ms ease;
}

.bar-column.is-empty .bar-fill {
  opacity: 0.16;
}

.bar-label {
  color: rgba(250, 247, 241, 0.43);
  font-size: 0.67rem;
}

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

.stats-grid div {
  min-width: 0;
  padding: 11px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.stats-grid span {
  display: block;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
  color: rgba(250, 247, 241, 0.46);
  font-size: 0.68rem;
  line-height: 1.25;
}

.stats-grid strong {
  display: block;
  font-size: 1rem;
}

footer {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: rgba(250, 247, 241, 0.38);
  font-size: 0.76rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border: 1px solid rgba(241, 180, 64, 0.38);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--paper);
  box-shadow: var(--shadow);
  font-size: 0.86rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

@media (max-width: 860px) {
  .site-shell {
    width: min(100% - 28px, 680px);
  }

  .dashboard {
    grid-template-columns: 1fr;
  }

  .daily-panel {
    min-height: 560px;
  }

  .side-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .site-shell {
    width: min(100% - 20px, 470px);
  }

  .topbar {
    min-height: 66px;
  }

  .topbar-date {
    font-size: 0.76rem;
  }

  .brand-product {
    display: none;
  }

  .page-intro {
    padding: 27px 3px 20px;
  }

  .page-intro h1 {
    font-size: clamp(2.2rem, 13vw, 3.25rem);
  }

  .daily-panel,
  .calendar-panel,
  .progress-panel {
    padding: 18px;
    border-radius: 18px;
  }

  .daily-panel {
    min-height: 530px;
  }

  .add-form button {
    padding: 0 17px;
  }

  .stats-grid {
    gap: 6px;
  }

  .stats-grid div {
    padding: 10px 7px;
  }

  footer {
    min-height: 78px;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    text-align: center;
  }
}

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