:root {
  color-scheme: light;
  --ink: #1d2421;
  --muted: #65706a;
  --paper: #f3f1eb;
  --surface: #fcfbf7;
  --line: #d8d8d0;
  --line-strong: #b9beb7;
  --accent: #b4573b;
  --accent-deep: #873b28;
  --accent-soft: #f1ddd5;
  --before: #e8e5dd;
  --after: #dce8df;
  --success: #3f6f50;
  --shadow: 0 18px 50px rgba(41, 46, 43, 0.08);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background:
    linear-gradient(90deg, transparent 0 48px, rgba(180, 87, 59, 0.08) 48px 49px, transparent 49px),
    var(--paper);
  color: var(--ink);
  font-family: "Aptos", "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }

button, select, input[type="checkbox"] { cursor: pointer; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(180, 87, 59, 0.42);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 100;
  transform: translateY(-150%);
  background: var(--ink);
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
}

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

.masthead {
  width: min(100% - 48px, 1440px);
  margin: 0 auto;
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line-strong);
}

.masthead__brand { display: flex; align-items: center; gap: 14px; }
.masthead__brand p { margin: 0 0 3px; font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; }
.masthead__brand span { color: var(--muted); font-size: 0.88rem; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  aspect-ratio: 1;
  color: var(--surface) !important;
  background: var(--accent);
  border-radius: 50% 50% 50% 12px;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.masthead__meta { display: flex; gap: 24px; color: var(--muted); font-size: 0.82rem; }

main { width: min(100% - 48px, 1440px); margin: 0 auto; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  gap: clamp(42px, 7vw, 110px);
  align-items: end;
  padding: clamp(56px, 8vw, 112px) 0 48px;
}

.eyebrow,
.dialog__label {
  margin: 0 0 16px;
  color: var(--accent-deep);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 12ch;
  margin: 0;
  font-size: clamp(2.8rem, 6vw, 5.75rem);
  line-height: 0.96;
  letter-spacing: -0.065em;
}

.hero__copy > p:last-child {
  max-width: 58ch;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.16rem);
  line-height: 1.75;
}

.progress-panel {
  padding: 22px 0 8px;
  border-top: 3px solid var(--ink);
  border-bottom: 1px solid var(--line-strong);
}

.progress-panel__topline { display: flex; align-items: baseline; justify-content: space-between; }
.progress-panel__topline span { color: var(--muted); }
.progress-panel__topline strong { font-size: 2.25rem; letter-spacing: -0.05em; }

.progress-track { height: 7px; margin: 18px 0 24px; overflow: hidden; background: #deded7; border-radius: 100px; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); border-radius: inherit; transition: transform 350ms ease; transform: scaleX(0); transform-origin: left; }
.progress-panel__numbers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.progress-panel__numbers div { display: flex; align-items: baseline; gap: 8px; }
.progress-panel__numbers strong { font-size: 1.35rem; }
.progress-panel__numbers span { color: var(--muted); font-size: 0.78rem; }

.toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(170px, 0.5fr) minmax(140px, 0.35fr) auto;
  gap: 14px;
  align-items: end;
  padding: 16px;
  background: rgba(252, 251, 247, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.field { display: grid; gap: 7px; }
.field label { color: var(--muted); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; }
.field input, .field select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  padding: 0 12px;
}

.toolbar__actions { display: flex; gap: 8px; }
.button {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 14px;
  background: white;
  color: var(--ink);
  font-weight: 700;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}
.button:hover { border-color: var(--ink); background: #f7f6f1; }
.button:active { transform: scale(0.98); }
.button--danger { color: #8f3429; }
.button--danger-solid { border-color: #8f3429; background: #8f3429; color: white; }

.week-rail { margin: 22px 0 0; overflow-x: auto; scrollbar-width: thin; }
.week-tabs { display: grid; grid-template-columns: repeat(14, minmax(72px, 1fr)); min-width: 1010px; border-bottom: 1px solid var(--line-strong); }
.week-tab {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 13px 8px 12px;
  font-weight: 700;
  transition: color 180ms ease, background 180ms ease, transform 150ms ease;
}
.week-tab:hover { color: var(--ink); background: rgba(255,255,255,0.45); }
.week-tab:active { transform: scale(0.98); }
.week-tab.is-active { color: var(--accent-deep); background: var(--accent-soft); box-shadow: inset 0 -3px 0 var(--accent); }

.legend { display: flex; flex-wrap: wrap; gap: 18px 28px; align-items: center; padding: 22px 0 16px; color: var(--muted); font-size: 0.8rem; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend__swatch { width: 11px; height: 11px; border-radius: 2px; background: var(--before); }
.level-dot--1 { background: #e8e7e1; border: 1px solid #b9beb7; }
.level-dot--2 { background: #eadfd8; }
.level-dot--3 { background: #e6d1c8; }
.level-dot--4 { background: #d9e6dc; }
.level-dot--5 { background: #bcd2c3; }

.status-message { min-height: 22px; margin-bottom: 4px; color: var(--success); font-size: 0.84rem; }

.tracker-sections { display: grid; gap: 38px; padding: 10px 0 80px; }
.category-section { min-width: 0; scroll-margin-top: 112px; }
.category-heading {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 16px;
  align-items: baseline;
  margin: 0 0 12px;
  padding-top: 14px;
  border-top: 3px solid var(--ink);
}
.category-heading__number { color: var(--accent); font-size: 0.86rem; font-weight: 800; }
.category-heading h2 { margin: 0; font-size: clamp(1.35rem, 2.2vw, 2rem); letter-spacing: -0.035em; }
.category-heading span:last-child { color: var(--muted); font-size: 0.78rem; }

.table-shell { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 8px 28px rgba(41,46,43,0.05); }
.tracker-table { width: 100%; min-width: 2290px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.tracker-table th, .tracker-table td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tracker-table tr:last-child td { border-bottom: 0; }
.tracker-table th:last-child, .tracker-table td:last-child { border-right: 0; }

.tracker-table thead th {
  position: sticky;
  top: 0;
  z-index: 8;
  height: 52px;
  background: #eeece6;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-align: center;
}

.tracker-table .item-heading { left: 0; z-index: 12; width: 650px; padding-left: 18px; text-align: left; }
.tracker-table .week-heading { width: 116px; }
.tracker-table .week-heading.is-current { color: var(--accent-deep); background: var(--accent-soft); }

.state-cell {
  position: sticky;
  left: 0;
  z-index: 5;
  width: 650px;
  padding: 15px 18px;
  background: var(--surface);
  text-align: left;
}
.dimension-row .state-cell { box-shadow: inset 4px 0 0 var(--accent); }
.state-cell__topline { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.state-badge { padding: 3px 7px; border-radius: 4px; background: var(--before); color: #5e615d; font-size: 0.67rem; font-weight: 800; letter-spacing: 0.08em; }
.dimension-name { font-size: 0.83rem; font-weight: 800; }
.level-definitions { display: grid; gap: 7px; }
.level-definition { display: grid; grid-template-columns: 94px 1fr; gap: 10px; align-items: start; color: #4f5954; font-size: 0.74rem; font-weight: 400; line-height: 1.4; }
.level-definition b { display: flex; align-items: center; gap: 6px; min-height: 22px; border-radius: 4px; color: #555d58; font-size: 0.68rem; }
.level-definition b::before { content: ""; flex: 0 0 auto; width: 20px; height: 20px; border-radius: 4px; background: #e8e7e1; }
.level-definition--2 b::before { background: #eadfd8; }
.level-definition--3 b::before { background: #e6d1c8; }
.level-definition--4 b::before { background: #d9e6dc; }
.level-definition--5 b::before { background: #bcd2c3; }

.check-cell { padding: 0; background: rgba(255,255,255,0.7); text-align: center; transition: background 180ms ease; }
.check-cell.is-current { box-shadow: inset 0 0 0 2px rgba(180, 87, 59, 0.24); }
.check-cell.level-1 { background: rgba(232,231,225,0.72); }
.check-cell.level-2 { background: rgba(234,223,216,0.72); }
.check-cell.level-3 { background: rgba(230,209,200,0.72); }
.check-cell.level-4 { background: rgba(217,230,220,0.8); }
.check-cell.level-5 { background: rgba(188,210,195,0.88); }
.check-cell label { display: grid; place-items: center; min-height: 236px; }
.level-select {
  width: 106px;
  height: 44px;
  border: 1.5px solid #9da49f;
  border-radius: 7px;
  background: white;
  color: var(--ink);
  padding: 0 7px;
  text-align: left;
  font-weight: 800;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}
.level-select:hover { border-color: var(--accent); transform: scale(1.05); }
.level-select:active { transform: scale(0.98); }
.level-select.level-1 { background: #f4f3ef; }
.level-select.level-2 { background: #f1e8e2; }
.level-select.level-3 { border-color: #b88a78; background: #ecd9d1; }
.level-select.level-4 { border-color: #78917f; background: #e2ede4; color: #35523f; }
.level-select.level-5 { border-color: #557660; background: #cce0d1; color: #284734; }

.empty-state { padding: 72px 24px 100px; text-align: center; border-top: 1px solid var(--line-strong); }
.empty-state strong { font-size: 1.4rem; }
.empty-state p { color: var(--muted); }

.loading-state { display: grid; gap: 12px; padding: 24px 0 80px; }
.loading-state span { display: block; height: 84px; background: linear-gradient(100deg, #e5e3dc 30%, #efede7 50%, #e5e3dc 70%); background-size: 250% 100%; animation: shimmer 1.4s infinite linear; }

footer {
  width: min(100% - 48px, 1440px);
  margin: 0 auto;
  padding: 28px 0 44px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  border-top: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.78rem;
}

dialog { width: min(92vw, 460px); border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); color: var(--ink); padding: 0; box-shadow: 0 30px 90px rgba(20,30,24,0.24); }
dialog::backdrop { background: rgba(29,36,33,0.46); backdrop-filter: blur(3px); }
dialog form { padding: 30px; }
dialog h2 { margin: 0; letter-spacing: -0.04em; }
dialog p:not(.dialog__label) { color: var(--muted); line-height: 1.6; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

@keyframes shimmer { to { background-position-x: -250%; } }

@media (max-width: 1040px) {
  .hero { grid-template-columns: 1fr; }
  .progress-panel { max-width: 560px; }
  .toolbar { grid-template-columns: 1fr 1fr 1fr; }
  .toolbar__actions { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  body { background: var(--paper); }
  .masthead, main, footer { width: min(100% - 28px, 1440px); }
  .masthead { min-height: 76px; }
  .masthead__brand p, .masthead__meta span:last-child { display: none; }
  .masthead__meta { gap: 0; }
  .hero { padding: 48px 0 34px; gap: 34px; }
  .hero h1 { font-size: clamp(2.65rem, 13vw, 4rem); }
  .toolbar { position: relative; grid-template-columns: 1fr 1fr; padding: 13px; }
  .field--search { grid-column: 1 / -1; }
  .toolbar__actions { overflow-x: auto; }
  .toolbar__actions .button { flex: 1 0 auto; }
  .legend { align-items: flex-start; }
  .category-heading { grid-template-columns: 44px 1fr; }
  .category-heading span:last-child { grid-column: 2; }
  .tracker-table .item-heading, .state-cell { width: 350px; }
  .tracker-table { min-width: 1980px; }
  .level-definition { grid-template-columns: 88px 1fr; font-size: 0.7rem; }
  footer { flex-direction: column; gap: 4px; }
}

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

@media print {
  body { background: white; }
  .masthead__meta, .toolbar, .week-rail, .legend, .status-message, footer { display: none; }
  main, .masthead { width: 100%; }
  .hero { padding: 30px 0; grid-template-columns: 1fr 320px; }
  .hero h1 { font-size: 3rem; }
  .table-shell { overflow: visible; box-shadow: none; }
  .tracker-table { min-width: 0; font-size: 8px; }
  .tracker-table .item-heading, .state-cell { width: 36%; position: static; }
  .category-section { break-before: page; }
}
