:root {
  --black: #070808;
  --ink: #090b0a;
  --paper: #f4efe3;
  --orange: #ff5424;
  --green: #08dc70;
  --yellow: #ffd426;
  --danger: #ff6b53;
  --display: "Avenir Next Condensed", "Arial Narrow", "Roboto Condensed", Impact, sans-serif;
  --body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --focus: #fff8dc;
}

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

html {
  min-width: 320px;
  background: #000;
  color-scheme: dark;
  font-family: var(--body);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--paper);
  background:
    radial-gradient(circle at 18% 12%, rgb(255 255 255 / 0.035), transparent 32rem),
    #000;
}

button,
input {
  font: inherit;
}

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

button {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.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;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.9rem;
  color: var(--ink);
  background: var(--paper);
  font-weight: 850;
  transform: translateY(-180%);
  transition: transform 140ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

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

.dashboard-shell {
  width: min(calc(100% - 2rem), 96rem);
  min-height: calc(100vh - 2rem);
  margin: 1rem auto;
  padding: 0.85rem;
  background:
    radial-gradient(circle at 62% 18%, rgb(255 255 255 / 0.045) 0 1px, transparent 1.5px) 0 0 / 5px 5px,
    #0b0c0c;
  border: 1px solid #171919;
  box-shadow: 0 1.5rem 5rem rgb(0 0 0 / 0.7);
}

.topbar {
  min-height: 4.75rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.25rem;
  padding: 0 0.45rem 0.85rem;
}

.brand-mark {
  display: grid;
  width: 3.45rem;
  aspect-ratio: 1;
  place-items: center;
  color: var(--ink);
  background: var(--orange);
  font-family: var(--display);
  font-size: 2.25rem;
  font-stretch: condensed;
  font-weight: 950;
  line-height: 1;
  letter-spacing: -0.09em;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.12);
}

.month-navigation {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--orange);
}

.month-navigation h1 {
  min-width: 6.8ch;
  margin: 0;
  text-align: center;
  font-family: var(--display);
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  font-stretch: condensed;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.icon-button,
.text-action,
.details-toggle,
.status-banner button {
  border: 0;
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 2.6rem;
  aspect-ratio: 1;
  padding: 0;
  place-items: center;
  color: inherit;
  background: transparent;
}

.icon-button svg,
.text-action svg,
.details-toggle svg,
.status-dismiss svg,
.login-submit svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: square;
  stroke-linejoin: miter;
  stroke-width: 2.4;
}

.icon-button:hover:not(:disabled),
.text-action:hover,
.status-banner button:hover {
  background: rgb(255 255 255 / 0.1);
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.topbar-actions form {
  margin: 0;
}

.text-action {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 0.72rem;
  color: var(--paper);
  background: transparent;
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-decoration: none;
  text-transform: uppercase;
}

.status-banner {
  position: relative;
  display: flex;
  min-height: 3.35rem;
  align-items: center;
  gap: 0.8rem;
  margin: 0 0 0.85rem;
  padding: 0.7rem 3.4rem 0.7rem 1rem;
  color: var(--paper);
  background: #242827;
  border-left: 0.35rem solid var(--paper);
}

.status-banner[data-tone="error"] {
  color: var(--ink);
  background: var(--danger);
  border-color: var(--ink);
}

.status-banner[data-tone="success"] {
  color: var(--ink);
  background: var(--green);
  border-color: var(--ink);
}

.status-banner p {
  flex: 1;
  margin: 0;
  font-size: 0.88rem;
  font-weight: 720;
}

.status-banner button {
  padding: 0.45rem 0.65rem;
  color: inherit;
  background: transparent;
  border: 1.5px solid currentColor;
  font-size: 0.75rem;
  font-weight: 850;
  text-transform: uppercase;
}

.status-banner .status-dismiss {
  position: absolute;
  top: 50%;
  right: 0.65rem;
  display: grid;
  width: 2rem;
  height: 2rem;
  padding: 0;
  place-items: center;
  border: 0;
  transform: translateY(-50%);
}

.habit-list {
  display: grid;
  gap: 0.9rem;
}

.habit-card {
  --card-color: var(--orange);
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: clamp(12.5rem, 20vw, 18rem) minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(3.75rem, auto) auto;
  grid-template-areas:
    "title spacer toggle"
    "title days days"
    "details details details";
  min-height: 12rem;
  overflow: hidden;
  padding: clamp(1.25rem, 2.4vw, 2.15rem);
  color: var(--ink);
  background-color: var(--card-color);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.09);
}

.habit-card::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  opacity: 0.34;
  background-image:
    radial-gradient(circle at 20% 40%, rgb(255 255 255 / 0.24) 0 0.7px, transparent 0.9px),
    radial-gradient(circle at 80% 22%, rgb(0 0 0 / 0.18) 0 0.6px, transparent 0.85px),
    linear-gradient(105deg, transparent 15%, rgb(255 255 255 / 0.06) 45%, transparent 68%);
  background-position: 0 0, 2px 3px, 0 0;
  background-size: 5px 5px, 7px 7px, 100% 100%;
  pointer-events: none;
}

.habit-card--music {
  --card-color: var(--orange);
}

.habit-card--drawing {
  --card-color: var(--green);
}

.habit-card--sport {
  --card-color: var(--yellow);
}

.habit-card[aria-busy="true"] {
  cursor: progress;
}

.habit-card :focus-visible {
  outline-color: var(--ink);
}

.habit-card h2 {
  grid-area: title;
  align-self: center;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(4.25rem, 7.6vw, 8.4rem);
  font-stretch: condensed;
  font-weight: 950;
  letter-spacing: -0.07em;
  line-height: 0.76;
  text-transform: uppercase;
}

.details-toggle {
  grid-area: toggle;
  align-self: start;
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.1rem 0.3rem 0.75rem;
  color: var(--ink);
  background: transparent;
}

.details-toggle:hover {
  background: rgb(0 0 0 / 0.08);
}

.details-toggle svg {
  transition: transform 170ms ease;
}

.details-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.monthly-progress {
  display: flex;
  align-items: baseline;
  font-family: var(--display);
  font-size: 1.18rem;
  font-stretch: condensed;
  font-weight: 900;
}

.day-scroller {
  grid-area: days;
  align-self: end;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.2rem 0.2rem 0.6rem;
  scrollbar-color: rgb(0 0 0 / 0.58) transparent;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}

.day-scroller:focus-visible {
  outline-color: var(--ink);
}

.day-scroller::-webkit-scrollbar {
  height: 0.35rem;
}

.day-scroller::-webkit-scrollbar-thumb {
  background: rgb(0 0 0 / 0.55);
}

.day-list {
  display: grid;
  width: max-content;
  min-width: 100%;
  grid-auto-columns: 1.9rem;
  grid-auto-flow: column;
  gap: 0.44rem;
  align-items: end;
}

.loading-days {
  grid-column: span 6;
  align-self: center;
  padding: 0.75rem 0;
  font-size: 0.73rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  animation: loading-pulse 1s ease-in-out infinite alternate;
}

.day-control {
  display: grid;
  gap: 0.28rem;
  justify-items: center;
  scroll-snap-align: start;
}

.day-number {
  font-family: var(--display);
  font-size: 0.92rem;
  font-stretch: condensed;
  font-weight: 900;
  line-height: 1;
}

.day-control.is-today .day-number {
  text-decoration: underline;
  text-decoration-thickness: 0.16em;
  text-underline-offset: 0.18em;
}

.day-button {
  position: relative;
  display: grid;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0.16rem;
  place-items: center;
  color: var(--ink);
  background: transparent;
  border: 1.8px solid currentColor;
  border-radius: 0;
  cursor: pointer;
  transition: background-color 110ms ease, transform 110ms ease;
}

.day-button:hover:not(:disabled) {
  background: rgb(255 255 255 / 0.23);
  transform: translateY(-1px);
}

.day-button:focus-visible {
  z-index: 2;
  outline-color: var(--ink);
  outline-offset: 2px;
}

.day-button .checkmark {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  stroke-linecap: square;
  stroke-linejoin: miter;
  stroke-width: 3.5;
  transition: stroke-dashoffset 140ms ease;
}

.day-button[aria-pressed="true"] {
  background: rgb(0 0 0 / 0.08);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.22);
}

.day-button[aria-pressed="true"] .checkmark {
  stroke-dashoffset: 0;
}

.day-button:disabled {
  cursor: not-allowed;
  opacity: 0.33;
}

.day-control.is-future .day-button {
  border-style: dotted;
}

.day-button[data-pending="true"]::after {
  position: absolute;
  width: 0.82rem;
  height: 0.82rem;
  content: "";
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 550ms linear infinite;
}

.day-button[data-pending="true"] .checkmark {
  opacity: 0;
}

.habit-details {
  grid-area: details;
  display: grid;
  grid-template-columns: minmax(10rem, 0.75fr) minmax(14rem, 2fr) minmax(10rem, 0.75fr);
  gap: clamp(1rem, 3vw, 3.5rem);
  align-items: stretch;
  min-height: 10.5rem;
  margin-top: 1.35rem;
  padding-top: 1.4rem;
  border-top: 1.5px solid rgb(0 0 0 / 0.22);
}

.stat-block {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto 1fr;
  align-items: end;
  padding-right: clamp(1rem, 2vw, 2rem);
  border-right: 1.5px solid rgb(0 0 0 / 0.35);
}

.stat-block--end {
  padding-right: 0;
  padding-left: clamp(0rem, 1vw, 1rem);
  border-right: 0;
}

.stat-label {
  grid-column: 1 / -1;
  align-self: start;
  font-family: var(--display);
  font-size: 0.8rem;
  font-stretch: condensed;
  font-weight: 900;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.stat-block strong {
  align-self: end;
  font-family: var(--display);
  font-size: clamp(3.8rem, 6vw, 6rem);
  font-stretch: condensed;
  font-weight: 950;
  letter-spacing: -0.055em;
  line-height: 0.78;
}

.stat-unit {
  align-self: end;
  margin: 0 0 0.18rem 0.5rem;
  font-size: 0.69rem;
  font-weight: 850;
  text-transform: uppercase;
}

.month-rhythm {
  display: grid;
  grid-auto-columns: minmax(3px, 1fr);
  grid-auto-flow: column;
  gap: clamp(2px, 0.4vw, 7px);
  align-items: end;
  min-height: 7.3rem;
  padding: 0.4rem 0;
}

.rhythm-bar {
  min-height: 0.3rem;
  background: rgb(0 0 0 / 0.2);
}

.rhythm-bar.is-complete {
  background: var(--ink);
}

.rhythm-bar[data-level="0"] {
  height: 0.35rem;
}

.rhythm-bar[data-level="1"] {
  height: 22%;
}

.rhythm-bar[data-level="2"] {
  height: 34%;
}

.rhythm-bar[data-level="3"] {
  height: 46%;
}

.rhythm-bar[data-level="4"] {
  height: 58%;
}

.rhythm-bar[data-level="5"] {
  height: 70%;
}

.rhythm-bar[data-level="6"] {
  height: 80%;
}

.rhythm-bar[data-level="7"] {
  height: 90%;
}

.rhythm-bar[data-level="8"] {
  height: 100%;
}

.noscript-message {
  padding: 1rem;
  color: var(--ink);
  background: var(--danger);
  font-weight: 800;
}

/* Login */
.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1rem;
}

.login-shell {
  width: min(68rem, 100%);
}

.login-card {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(16rem, 1.15fr) minmax(18rem, 0.85fr);
  gap: clamp(2rem, 8vw, 7rem);
  min-height: min(42rem, calc(100vh - 2rem));
  align-items: end;
  padding: clamp(1.5rem, 5vw, 4.5rem);
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 22% 27%, rgb(255 255 255 / 0.2) 0 0.8px, transparent 1px) 0 0 / 6px 6px,
    var(--orange);
  box-shadow: 0 2rem 7rem rgb(0 0 0 / 0.7);
}

.brand-mark--large {
  position: absolute;
  top: clamp(1.5rem, 5vw, 4.5rem);
  left: clamp(1.5rem, 5vw, 4.5rem);
  width: 4.2rem;
  color: var(--orange);
  background: var(--ink);
}

.login-copy,
.login-form {
  position: relative;
  z-index: 1;
}

.eyebrow,
.login-form label {
  font-family: var(--display);
  font-size: 0.83rem;
  font-stretch: condensed;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.login-copy h1 {
  margin: 0.4rem 0 1rem;
  font-family: var(--display);
  font-size: clamp(5.4rem, 10vw, 9.8rem);
  font-stretch: condensed;
  font-weight: 950;
  letter-spacing: -0.07em;
  line-height: 0.72;
  text-transform: uppercase;
}

.login-intro {
  max-width: 32rem;
  margin: 0;
  font-size: clamp(0.9rem, 1.6vw, 1.1rem);
  font-weight: 650;
}

.login-form {
  align-self: end;
}

.login-form label {
  display: block;
  margin-bottom: 0.5rem;
}

.password-field {
  display: grid;
  grid-template-columns: 1fr auto;
  border: 2px solid var(--ink);
}

.password-field input {
  min-width: 0;
  min-height: 3.65rem;
  padding: 0.8rem 1rem;
  color: var(--ink);
  background: rgb(255 255 255 / 0.15);
  border: 0;
  border-radius: 0;
  font-size: 1rem;
}

.password-field input:focus-visible {
  position: relative;
  z-index: 1;
  outline-color: var(--ink);
  outline-offset: -5px;
}

.login-submit {
  display: inline-flex;
  min-width: 9rem;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.8rem 1rem;
  color: var(--orange);
  background: var(--ink);
  border: 0;
  border-radius: 0;
  cursor: pointer;
  font-family: var(--display);
  font-size: 0.9rem;
  font-stretch: condensed;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-submit:hover {
  background: #202321;
}

.login-submit:focus-visible {
  outline-color: var(--ink);
}

.login-error {
  min-height: 1.4em;
  margin: 0.65rem 0 0;
  font-size: 0.82rem;
  font-weight: 800;
}

.login-error:empty {
  visibility: hidden;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes loading-pulse {
  to {
    opacity: 0.35;
  }
}

@media (max-width: 60rem) {
  .habit-card {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "title toggle"
      "days days"
      "details details";
    min-height: 0;
  }

  .habit-card h2 {
    padding: 0.3rem 0 1.5rem;
  }

  .habit-details {
    grid-template-columns: minmax(8rem, 0.75fr) minmax(12rem, 1.5fr) minmax(8rem, 0.75fr);
  }
}

@media (max-width: 44rem) {
  .dashboard-shell {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    padding: 0.65rem;
    border: 0;
  }

  .topbar {
    grid-template-columns: auto 1fr;
    gap: 0.65rem;
    padding: 0 0 0.65rem;
  }

  .brand-mark {
    width: 3rem;
    font-size: 2rem;
  }

  .month-navigation {
    justify-self: end;
  }

  .month-navigation h1 {
    min-width: 5.7ch;
    font-size: 1.75rem;
  }

  .icon-button {
    width: 2.35rem;
  }

  .topbar-actions {
    grid-column: 1 / -1;
    justify-self: stretch;
    justify-content: flex-end;
    border-top: 1px solid #252828;
  }

  .habit-list {
    gap: 0.62rem;
  }

  .habit-card {
    padding: 1rem;
  }

  .habit-card h2 {
    overflow-wrap: anywhere;
    font-size: clamp(3.6rem, 19vw, 5.7rem);
  }

  .details-toggle {
    gap: 0.25rem;
  }

  .day-scroller {
    width: calc(100% + 1rem);
    margin-right: -1rem;
    padding-right: 1rem;
  }

  .habit-details {
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem 0.75rem;
    min-height: 0;
  }

  .month-rhythm {
    grid-column: 1 / -1;
    grid-row: 1;
    min-height: 5rem;
    padding-bottom: 0.85rem;
    border-bottom: 1.5px solid rgb(0 0 0 / 0.28);
  }

  .stat-block {
    min-height: 6.8rem;
    padding-right: 0.75rem;
  }

  .stat-block--end {
    padding-left: 0.5rem;
  }

  .stat-block strong {
    font-size: 4rem;
  }

  .login-card {
    grid-template-columns: 1fr;
    gap: 3rem;
    min-height: calc(100vh - 2rem);
    align-content: end;
  }

  .login-copy h1 {
    font-size: clamp(4.8rem, 23vw, 7rem);
  }
}

@media (max-width: 26rem) {
  .topbar-actions .text-action {
    padding-inline: 0.5rem;
  }

  .text-action span {
    font-size: 0.68rem;
  }

  .habit-card h2 {
    font-size: 3.4rem;
  }

  .monthly-progress {
    font-size: 1rem;
  }

  .password-field {
    grid-template-columns: 1fr;
  }

  .login-submit {
    min-height: 3.3rem;
  }
}

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

@media (forced-colors: active) {
  .habit-card,
  .brand-mark,
  .status-banner,
  .login-card,
  .login-submit {
    border: 2px solid CanvasText;
  }

  .day-button[aria-pressed="true"] {
    outline: 3px solid Highlight;
    outline-offset: -5px;
  }
}
