:root {
  --bg: #f6f7e4;
  --ink: #172044;
  --navy: #1d2871;
  --green: #91c919;
  --paper: #ffffff;
  --paper-soft: #fbfcf1;
  --line: rgba(29, 40, 113, 0.14);
  --muted: #6d735d;
  --warm: #f3b35f;
  --rose: #e8897a;
  --shadow: 0 18px 50px rgba(29, 40, 113, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 90% 8%, rgba(145, 201, 25, 0.2), transparent 28rem),
    linear-gradient(180deg, var(--bg), #eef2d5 100%);
}

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

button {
  cursor: pointer;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 26px;
  min-height: 100vh;
  padding: 28px 22px;
  background: rgba(255, 255, 255, 0.56);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

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

.brand img {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.brand strong {
  display: block;
  font-size: 1.25rem;
  letter-spacing: 0;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.nav-link:hover,
.nav-link.active {
  background: var(--navy);
  color: #fff;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: inherit;
}

.side-note {
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(246, 247, 228, 0.8);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.side-note p {
  margin: 0;
}

.dot {
  width: 10px;
  height: 10px;
  margin-top: 6px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(145, 201, 25, 0.2);
}

main {
  width: min(1180px, 100%);
  min-width: 0;
  margin: 0 auto;
  padding: 24px clamp(18px, 4vw, 46px) 48px;
}

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

.topbar {
  margin-bottom: 24px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.demo-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(145, 201, 25, 0.45);
  border-radius: 999px;
  background: rgba(145, 201, 25, 0.18);
  color: var(--navy);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.topbar h1,
.section-heading h2,
.panel h2,
.hero-copy h2 {
  margin: 0;
  color: var(--navy);
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(1.9rem, 4vw, 3.25rem);
  line-height: 1.02;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(220px, 0.8fr);
  gap: clamp(24px, 5vw, 60px);
  align-items: center;
  min-height: 430px;
  padding: clamp(26px, 5vw, 58px);
  border: 1px solid rgba(29, 40, 113, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.42)),
    linear-gradient(110deg, rgba(145, 201, 25, 0.16), rgba(29, 40, 113, 0.08));
  box-shadow: var(--shadow);
}

.hero-copy {
  min-width: 0;
  max-width: 640px;
}

.hero-copy h2 {
  max-width: 11ch;
  font-size: clamp(2.3rem, 7vw, 5.6rem);
  line-height: 0.98;
  word-break: keep-all;
}

.hero-copy p:not(.eyebrow) {
  max-width: 620px;
  margin: 22px 0 0;
  color: #414937;
  font-size: clamp(1rem, 1.7vw, 1.2rem);
  line-height: 1.7;
  overflow-wrap: break-word;
  word-break: keep-all;
}

.proof-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-width: 680px;
  margin-top: 20px;
}

.proof-strip span {
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: #414937;
  line-height: 1.45;
  overflow-wrap: break-word;
  word-break: keep-all;
}

.proof-strip strong {
  display: block;
  margin-bottom: 4px;
  color: var(--navy);
  font-size: 0.82rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.progress-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-mark {
  display: grid;
  place-items: center;
  min-height: 240px;
}

.hero-mark img {
  width: min(310px, 72vw);
  max-height: 300px;
  object-fit: contain;
  filter: drop-shadow(0 28px 28px rgba(29, 40, 113, 0.16));
}

.button,
.icon-button {
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  padding: 0 18px;
  font-weight: 800;
}

.button.primary {
  background: var(--navy);
  color: #fff;
}

.button.secondary {
  background: var(--green);
  color: #172044;
}

.button.ghost {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--navy);
}

.button.wide {
  width: 100%;
}

.button.compact {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.86rem;
}

.button:focus-visible,
.nav-link:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(145, 201, 25, 0.55);
  outline-offset: 2px;
}

.dashboard-grid,
.routine-layout,
.insight-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 18px;
  margin-top: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 12px 35px rgba(29, 40, 113, 0.08);
}

.progress-panel,
.action-panel,
.reward-panel,
.timeline-panel,
.message-panel,
.chart-panel,
.history-panel {
  padding: 22px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(145, 201, 25, 0.2);
  color: var(--navy);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  margin: 24px 0 18px;
  border-radius: 999px;
  background: rgba(29, 40, 113, 0.1);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--navy));
  transition: width 0.25s ease;
}

.step-list {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.step-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) minmax(86px, auto);
  gap: 12px;
  align-items: center;
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
}

.step-item.active {
  border-color: rgba(145, 201, 25, 0.7);
  background: #fbffe9;
}

.step-item.completed {
  background: #fff9ec;
}

.step-number {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: rgba(145, 201, 25, 0.2);
  color: var(--navy);
  font-weight: 900;
}

.step-item h3,
.timeline h3,
.history-item h3 {
  margin: 0;
  color: var(--navy);
  font-size: 1rem;
}

.step-item p,
.timeline p,
.panel p,
.history-item p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.step-cue {
  font-weight: 800;
}

.step-action {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font-weight: 900;
}

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 26px 0;
}

.mini-metrics span {
  min-height: 82px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  color: var(--muted);
}

.mini-metrics strong {
  display: block;
  color: var(--navy);
  font-size: 1.8rem;
}

.reward-panel {
  grid-column: 1 / -1;
}

.token-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.token-lane {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.routine-token {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 8px;
  min-height: 104px;
  padding: 12px 8px;
  border: 1px dashed rgba(29, 40, 113, 0.24);
  border-radius: 8px;
  background: var(--paper-soft);
  color: var(--muted);
  text-align: center;
}

.routine-token:disabled {
  opacity: 1;
}

.routine-token small {
  min-height: 32px;
  color: inherit;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.3;
}

.token-disc {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: rgba(29, 40, 113, 0.08);
  color: var(--navy);
  font-weight: 950;
}

.routine-token.earned {
  border-style: solid;
  border-color: rgba(243, 179, 95, 0.72);
  background: #fff9ec;
  color: var(--navy);
}

.routine-token.earned .token-disc {
  background: var(--warm);
  box-shadow: 0 8px 18px rgba(243, 179, 95, 0.28);
}

.reward-summary {
  display: grid;
  gap: 4px;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
}

.reward-summary strong {
  color: var(--navy);
}

.reward-summary span {
  color: var(--muted);
  line-height: 1.5;
}

.reward-board {
  display: grid;
  grid-template-columns: repeat(7, minmax(42px, 1fr));
  gap: 8px;
}

.board-day {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 8px;
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
}

.board-day.today {
  border-color: rgba(29, 40, 113, 0.32);
}

.board-day.earned {
  background: #fff9ec;
}

.board-token {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(29, 40, 113, 0.08);
  color: rgba(29, 40, 113, 0.42);
  font-size: 1.3rem;
  line-height: 1;
}

.board-day.earned .board-token {
  background: var(--warm);
  color: var(--navy);
}

.board-day small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

@media (prefers-reduced-motion: no-preference) {
  .reward-panel.complete .board-day.today.earned .board-token {
    animation: tokenSettle 0.42s ease;
  }
}

@keyframes tokenSettle {
  0% {
    transform: translateY(-8px);
    box-shadow: 0 0 0 rgba(243, 179, 95, 0);
  }
  100% {
    transform: translateY(0);
    box-shadow: 0 8px 18px rgba(243, 179, 95, 0.28);
  }
}

.section-heading {
  margin: 10px 0 18px;
}

.timeline {
  display: grid;
  gap: 12px;
}

.routine-total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  color: var(--muted);
}

.routine-total strong {
  color: var(--navy);
}

.routine-total.invalid {
  border-color: rgba(232, 137, 122, 0.7);
  background: #fff3ef;
}

.routine-editor {
  display: grid;
  gap: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 14px;
  min-height: 92px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.timeline-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.time-badge {
  display: grid;
  place-items: center;
  height: 42px;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 900;
}

.routine-edit-item {
  min-height: 0;
}

.routine-edit-fields {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 96px;
  gap: 12px;
}

.wide-field {
  grid-column: 1 / -1;
}

.reorder-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.reorder-controls .button {
  min-height: 38px;
}

.routine-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.routine-form-actions .button {
  min-width: 140px;
}

.message-stack {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.message-bubble {
  padding: 14px;
  border-radius: 8px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
}

.checkin-form {
  display: grid;
  gap: 22px;
  padding: 22px;
}

fieldset {
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
}

legend,
label {
  display: grid;
  gap: 8px;
  color: var(--navy);
  font-weight: 800;
}

legend {
  margin-bottom: 10px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

input,
select {
  min-height: 46px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 120px;
  padding: 12px;
  line-height: 1.55;
}

.rating-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.rating-grid button,
.segmented button {
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  color: var(--navy);
  font-weight: 900;
}

.rating-grid button.selected,
.segmented button.selected {
  background: var(--navy);
  color: #fff;
}

.form-grid,
.yesno-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
}

.checkbox-line input {
  width: 20px;
  height: 20px;
  accent-color: var(--green);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.toggle-card {
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
}

.toggle-card.quiet {
  opacity: 0.78;
}

.settings-checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: #9f3327;
  font-weight: 800;
}

.weekly-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}

.metric-card {
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 12px 35px rgba(29, 40, 113, 0.08);
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  color: var(--navy);
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  line-height: 1.15;
}

.metric-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.35;
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(24px, 1fr));
  align-items: end;
  gap: 12px;
  min-height: 260px;
}

.bar {
  display: grid;
  align-items: end;
  min-height: 220px;
  gap: 8px;
}

.bar-fill {
  min-height: 8px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, var(--green), var(--navy));
}

.bar span {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

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

.history-item {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
}

.score-chip {
  display: grid;
  place-items: center;
  height: 58px;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font-size: 1.3rem;
  font-weight: 900;
}

dialog {
  width: min(720px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

dialog::backdrop {
  background: rgba(23, 32, 68, 0.36);
}

.settings-card {
  display: grid;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  min-height: 42px;
  padding: 0;
  background: var(--navy);
  color: #fff;
  font-size: 1.4rem;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .nav-link {
    justify-content: center;
    font-size: 0.9rem;
  }

  .side-note {
    display: none;
  }

  .hero-band,
  .dashboard-grid,
  .routine-layout,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .hero-band {
    min-height: auto;
  }

  .hero-copy h2 {
    max-width: 12ch;
  }

  .token-lane {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

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

@media (max-width: 620px) {
  main {
    padding: 18px 14px 36px;
  }

  .topbar,
  .section-heading,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

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

  .hero-actions,
  .form-grid,
  .yesno-grid,
  .segmented,
  .rating-grid,
  .mini-metrics,
  .settings-checks,
  .weekly-metrics,
  .routine-edit-fields {
    grid-template-columns: 1fr;
  }

  .routine-total {
    display: grid;
  }

  .proof-strip {
    grid-template-columns: 1fr;
  }

  .reward-board {
    grid-template-columns: repeat(7, minmax(32px, 1fr));
    gap: 6px;
  }

  .board-day {
    min-height: 76px;
  }

  .hero-actions {
    display: grid;
  }

  .hero-mark {
    min-height: 150px;
  }

  .step-item,
  .timeline-item,
  .history-item {
    grid-template-columns: 1fr;
  }

  .step-action {
    width: 100%;
  }

  .checkbox-line {
    margin-top: 0;
  }
}
