:root {
  color-scheme: light;
  --background: 210 40% 98%;
  --foreground: 222 47% 11%;
  --card: 0 0% 100%;
  --card-foreground: 222 47% 11%;
  --primary: 243 75% 59%;
  --primary-foreground: 0 0% 98%;
  --secondary: 214 32% 96%;
  --secondary-foreground: 222 47% 11%;
  --muted: 214 32% 96%;
  --muted-foreground: 215 16% 47%;
  --accent: 238 100% 97%;
  --accent-foreground: 243 75% 59%;
  --destructive: 0 84% 60%;
  --destructive-foreground: 0 0% 98%;
  --border: 214 32% 91%;
  --input: 214 32% 91%;
  --ring: 243 75% 59%;
  --amber: 38 92% 50%;
  --radius: 0.75rem;
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
  border-color: hsl(var(--border));
}

body {
  min-height: 100vh;
  margin: 0;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 1fr;
}

.auth-aside {
  display: none;
}

.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-panel {
  width: min(24rem, 100%);
}

.auth-title {
  margin-top: 1.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 2rem;
}

.auth-copy {
  margin-top: 0.25rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  line-height: 1.35rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-mark {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 0.25rem;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 0.75rem;
  font-weight: 800;
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 700;
}

.space-y-1 {
  display: grid;
  gap: 0.25rem;
}

.auth-quote {
  display: grid;
  gap: 0.5rem;
  color: white;
}

.auth-quote p {
  font-size: 1.125rem;
  line-height: 1.75rem;
}

.auth-quote footer {
  color: rgb(161 161 170);
  font-size: 0.875rem;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  margin-top: 1.5rem;
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--muted));
  padding: 0.25rem;
}

.tab {
  height: 2.25rem;
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  font-weight: 500;
}

.tab.active {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.08);
}

.form {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

.field {
  display: grid;
  gap: 0.5rem;
}

.field span {
  font-size: 0.875rem;
  font-weight: 500;
}

.input,
.textarea,
.select {
  width: 100%;
  min-height: 2.25rem;
  border: 1px solid hsl(var(--input));
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  color: hsl(var(--foreground));
  outline: none;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.05);
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.textarea {
  min-height: 5rem;
  resize: vertical;
}

.input::placeholder,
.textarea::placeholder {
  color: hsl(var(--muted-foreground));
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 1px hsl(var(--ring));
}

.primary,
.secondary,
.ghost,
.danger {
  display: inline-flex;
  min-height: 2.25rem;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  border-radius: calc(var(--radius) - 4px);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  transition:
    background 150ms ease,
    color 150ms ease,
    border-color 150ms ease;
}

.primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.1);
}

.primary:hover {
  background: hsl(243 75% 54%);
}

.secondary {
  border: 1px solid hsl(var(--input));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.05);
}

.secondary:hover,
.ghost:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.ghost {
  background: transparent;
  color: hsl(var(--muted-foreground));
}

.danger {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.app-shell {
  min-height: 100vh;
  background: hsl(var(--background));
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: none;
  width: 13rem;
  border-right: 1px solid hsl(var(--border));
  background: hsl(var(--card));
}

.sidebar-inner {
  display: flex;
  height: 100%;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  height: 4rem;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid hsl(var(--border));
  padding: 0 1rem;
}

.nav-list {
  display: grid;
  gap: 0.25rem;
  padding: 0.75rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 2.25rem;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  padding: 0.5rem 0.75rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
}

.nav-item.active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.nav-icon {
  display: grid;
  width: 1rem;
  height: 1rem;
  place-items: center;
  font-size: 0.85rem;
}

.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid hsl(var(--border));
  padding: 1rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
}

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 30;
  display: flex;
  height: 4rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  padding: 0 1rem;
}

.topbar-left {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.75rem;
}

.topbar-title {
  min-width: 0;
}

.topbar-title h1 {
  overflow: hidden;
  font-size: 1rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-title p {
  overflow: hidden;
  max-width: 13rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.credit-chip {
  display: none;
  min-width: 0;
  align-items: center;
  gap: 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  background: hsl(48 96% 89%);
  padding: 0.375rem 0.75rem;
  color: hsl(32 95% 34%);
  font-size: 0.875rem;
  font-weight: 600;
}

.avatar {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 999px;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  font-size: 0.75rem;
  font-weight: 600;
}

.icon-button {
  display: inline-flex;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  color: hsl(var(--foreground));
  font-size: 1rem;
}

.icon-button:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.content {
  padding: 5rem 1rem 2rem;
}

.page-head {
  display: grid;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
}

.page-head h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 2rem;
}

.page-head p {
  color: hsl(var(--muted-foreground));
}

.stats-grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  box-shadow: 0 1px 3px rgb(15 23 42 / 0.08), 0 1px 2px rgb(15 23 42 / 0.04);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.5rem 1.5rem 0.5rem;
}

.card-title {
  font-size: 0.875rem;
  font-weight: 500;
}

.card-icon {
  color: hsl(var(--muted-foreground));
}

.card-content {
  padding: 0 1.5rem 1.5rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 2rem;
}

.small,
.card-description {
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  line-height: 1rem;
}

.dashboard-grid {
  display: grid;
  gap: 1.5rem;
}

.section-card {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  box-shadow: 0 1px 3px rgb(15 23 42 / 0.08), 0 1px 2px rgb(15 23 42 / 0.04);
}

.hero-card {
  margin-bottom: 1.5rem;
}

.section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem;
}

.section-head h2 {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
}

.section-head p {
  margin-top: 0.375rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

.section-body {
  padding: 0 1.5rem 1.5rem;
}

.data-table {
  display: grid;
  overflow: hidden;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--background));
}

.data-row {
  display: grid;
  gap: 0.75rem;
  width: 100%;
  border-bottom: 1px solid hsl(var(--border));
  background: transparent;
  color: inherit;
  padding: 0.875rem;
  text-align: left;
  transition:
    background 150ms ease,
    border-color 150ms ease;
}

.data-row:last-child {
  border-bottom: 0;
}

button.data-row:hover,
.template-row:hover {
  background: hsl(var(--accent));
}

.data-row.active {
  background: hsl(var(--accent));
  box-shadow: inset 0.1875rem 0 0 hsl(var(--primary));
}

.data-head {
  display: none;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  font-weight: 700;
}

.data-cell {
  display: grid;
  min-width: 0;
  gap: 0.25rem;
}

.data-cell[data-label]::before {
  content: attr(data-label);
  color: hsl(var(--muted-foreground));
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
}

.data-title strong {
  overflow-wrap: anywhere;
  font-size: 0.875rem;
  font-weight: 600;
}

.data-title small {
  overflow-wrap: anywhere;
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  line-height: 1rem;
}

.sprint-row {
  cursor: pointer;
}

.pill {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 4px);
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.hero-card .card-header {
  align-items: start;
}

.progress-block {
  display: grid;
  gap: 0.75rem;
}

.progress-track {
  overflow: hidden;
  height: 0.625rem;
  border-radius: 999px;
  background: hsl(var(--secondary));
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: hsl(var(--primary));
  transition: width 180ms ease;
}

.sprint-timeline {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
}

.timeline-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 0.75rem;
}

.timeline-head h3 {
  font-size: 0.875rem;
  font-weight: 700;
}

.timeline-head span {
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  font-weight: 600;
}

.timeline-strip {
  display: grid;
  grid-auto-columns: 4.875rem;
  grid-auto-flow: column;
  gap: 0.5rem;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}

.timeline-day {
  position: relative;
  display: grid;
  min-height: 6.125rem;
  align-content: space-between;
  gap: 0.25rem;
  scroll-snap-align: start;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 3px);
  background: hsl(var(--card));
  padding: 0.625rem;
}

.timeline-day::before {
  content: "";
  width: 1.25rem;
  height: 0.1875rem;
  border-radius: 999px;
  background: hsl(var(--border));
}

.timeline-day strong {
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.1rem;
}

.timeline-index,
.timeline-weekday,
.timeline-status {
  color: hsl(var(--muted-foreground));
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 0.9rem;
}

.timeline-status {
  width: fit-content;
  border-radius: 999px;
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  padding: 0.125rem 0.375rem;
}

.timeline-day.is-today {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 1px hsl(var(--primary) / 0.18);
}

.timeline-day.is-today::before {
  background: hsl(var(--primary));
}

.timeline-day.is-complete {
  border-color: hsl(var(--primary) / 0.38);
  background: hsl(var(--accent));
}

.timeline-day.is-partial {
  border-color: hsl(var(--amber) / 0.45);
  background: hsl(48 96% 94%);
}

.timeline-day.has-resisted .timeline-status {
  background: hsl(var(--destructive) / 0.12);
  color: hsl(var(--destructive));
}

.timeline-day.is-future {
  background: hsl(var(--background));
  opacity: 0.72;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.stat-tile {
  display: grid;
  gap: 0.125rem;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--background));
  padding: 0.75rem;
}

.stat-tile strong {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.5rem;
}

.stat-tile span {
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
}

.habit-stack {
  display: grid;
  gap: 0.75rem;
}

.habit-card {
  display: grid;
  gap: 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--background));
  padding: 1rem;
}

.template-main {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  gap: 0.75rem;
}

.template-main h3 {
  overflow-wrap: anywhere;
  font-size: 0.9375rem;
  font-weight: 600;
}

.template-dot {
  width: 0.625rem;
  height: 0.625rem;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--habit-color, hsl(var(--primary)));
  margin-top: 0.25rem;
}

.template-cue {
  overflow-wrap: anywhere;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

.template-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.habit-main {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.habit-main h3 {
  overflow-wrap: anywhere;
  font-size: 1rem;
  font-weight: 600;
}

.habit-color-dot {
  display: inline-block;
  width: 0.625rem;
  height: 0.625rem;
  margin-right: 0.4rem;
  border-radius: 999px;
  background: var(--habit-color, hsl(var(--primary)));
}

.habit-actions {
  display: flex;
  flex-shrink: 0;
  gap: 0.25rem;
}

.complete-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.complete-button {
  width: auto;
  max-width: 100%;
  min-height: 2rem;
  padding: 0.425rem 0.75rem;
  white-space: normal;
  line-height: 1rem;
}

.complete-button[data-resist-habit] {
  max-width: min(100%, 15.5rem);
}

.complete-row .small {
  flex-basis: 100%;
}

.check-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.375rem;
}

.day {
  display: grid;
  min-width: 0;
  min-height: 2.75rem;
  place-items: center;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 4px);
  background: hsl(var(--card));
  color: hsl(var(--muted-foreground));
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 0.9rem;
}

.day:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.day.done {
  border-color: transparent;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.day.missed {
  border-color: hsl(var(--destructive) / 0.3);
  background: hsl(var(--destructive) / 0.12);
  color: hsl(var(--destructive));
}

.day.skipped {
  border-color: hsl(var(--amber) / 0.28);
  background: hsl(48 96% 89%);
  color: hsl(32 95% 34%);
}

.law-grid {
  display: grid;
  gap: 0.5rem;
}

.law {
  display: grid;
  gap: 0.25rem;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 4px);
  background: hsl(var(--card));
  padding: 0.75rem;
}

.law strong {
  font-size: 0.75rem;
  font-weight: 600;
}

.empty {
  border: 1px dashed hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 1.5rem 1rem;
  color: hsl(var(--muted-foreground));
  text-align: center;
  font-size: 0.875rem;
}

.modal-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  align-items: end;
  background: hsl(var(--foreground) / 0.4);
}

.modal {
  max-height: min(88vh, 820px);
  overflow: auto;
  border-top: 1px solid hsl(var(--border));
  border-radius: var(--radius) var(--radius) 0 0;
  background: hsl(var(--card));
  padding: 1.25rem;
  box-shadow: 0 -18px 38px rgb(15 23 42 / 0.18);
}

.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal-head h2 {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.modal-head p,
.eyebrow {
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

.grid-2 {
  display: grid;
  gap: 1rem;
}

.color-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}

.swatch {
  height: 2.25rem;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 4px);
  background: var(--swatch);
}

.swatch.active {
  box-shadow: 0 0 0 2px hsl(var(--ring));
}

.toast {
  position: fixed;
  z-index: 90;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  display: none;
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--foreground));
  color: hsl(var(--background));
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 10px 26px rgb(15 23 42 / 0.18);
}

.toast.show {
  display: block;
}

@media (min-width: 640px) {
  .credit-chip {
    display: inline-flex;
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .law-grid,
  .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .data-head {
    display: grid;
  }

  .data-cell[data-label]::before {
    display: none;
  }

  .sprint-table .data-row,
  .habit-table .data-row {
    align-items: center;
    grid-template-columns: minmax(0, 1.35fr) minmax(8rem, 0.9fr) auto;
  }

  .template-actions {
    justify-content: flex-end;
  }

  .complete-row .small {
    flex-basis: auto;
    margin-left: auto;
  }
}

@media (min-width: 768px) {
  .sidebar {
    display: block;
  }

  .topbar {
    left: 13rem;
    padding: 0 1.5rem;
  }

  .mobile-brand {
    display: none;
  }

  .content {
    margin-left: 13rem;
    padding: 5.5rem 1.5rem 2rem;
  }

  .dashboard-grid {
    grid-template-columns: 20rem minmax(0, 1fr);
    align-items: start;
  }

  .modal-backdrop {
    align-items: center;
    padding: 1.5rem;
  }

  .modal {
    width: min(48rem, 100%);
    margin: 0 auto;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
  }
}

@media (min-width: 1024px) {
  .auth-shell {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-aside {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: rgb(24 24 27);
    color: white;
    padding: 2.5rem;
  }

  .auth-main {
    padding: 2rem;
  }

  .habit-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
