:root {
  --paper: #FFF6E8;
  --card: #FFFFFF;
  --ink: #2C2454;
  --muted: #6B6490;
  --mint: #7EE0C6;
  --lilac: #C9B6FF;
  --apricot: #FFB37A;
  --sky: #8EC5FF;
  --lemon: #FFE27A;
  --berry: #FF7AA2;
  --line: rgba(44, 36, 84, 0.14);
  --line-lilac: color-mix(in srgb, var(--lilac) 62%, var(--ink) 18%);
  --shadow: 0 1px 2px rgba(44, 36, 84, 0.05), 0 6px 18px rgba(44, 36, 84, 0.06);
  --shadow-lift: 0 4px 8px rgba(44, 36, 84, 0.06), 0 12px 28px rgba(44, 36, 84, 0.08);
  --radius: 8px;
  --display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --ui: "Figtree", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --space: 8px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--ui);
  background: var(--paper);
  color: var(--ink);
  min-height: 100dvh;
  line-height: 1.5;
  letter-spacing: -0.011em;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
a { color: #5A3FD6; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }

[hidden], .modal[hidden], .drawer[hidden] { display: none !important; }

.skip {
  position: absolute; left: 16px; top: -48px; z-index: 80;
  background: var(--card); color: var(--ink);
  padding: 8px 12px; border-radius: 4px;
  font-weight: 600; font-size: 0.875rem;
  border: 1px solid var(--line-lilac);
}
.skip:focus { top: 16px; }

.awning {
  position: fixed; top: 0; left: 0; right: 0; height: 6px; z-index: 70;
  background: repeating-linear-gradient(
    90deg,
    var(--mint) 0 18px,
    var(--lilac) 18px 36px,
    var(--apricot) 36px 54px,
    var(--sky) 54px 72px,
    var(--lemon) 72px 90px
  );
  opacity: 0.72;
}

.blobs { pointer-events: none; position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.blob {
  position: absolute; border-radius: 50%;
  filter: blur(48px);
  opacity: 0.18;
}
.blob.mint { width: 560px; height: 560px; background: var(--mint); top: -220px; right: -160px; }
.blob.lilac { width: 420px; height: 420px; background: var(--lilac); top: 36%; left: -180px; opacity: 0.14; }
.blob.apricot { width: 480px; height: 480px; background: var(--apricot); bottom: -180px; right: 6%; opacity: 0.12; }

.hero, .weeks, .rubric, .toolbar, main, .foot { position: relative; z-index: 1; }

/* Hero: quiet brand mark + title + dates on one horizontal band */
.hero {
  padding: calc(24px + var(--safe-top)) 24px 16px;
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
}
.logo {
  width: 40px; height: 40px; border-radius: 8px;
  flex: none;
}
.hero-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.kicker {
  margin: 0;
  font-family: var(--ui);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.6875rem;
  color: var(--muted);
  line-height: 1.2;
}
.hero-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
}
h1 {
  font-family: var(--display);
  font-size: clamp(1.5rem, 4vw, 1.875rem);
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.03em;
}
.pill {
  display: inline-block;
  background: transparent;
  color: var(--ink);
  font-family: var(--ui);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-lilac);
  line-height: 1.2;
}
.window {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.875rem;
  letter-spacing: 0;
}

/* Rubric: compact definition row, 8px colour squares */
.rubric {
  max-width: 880px;
  margin: 8px auto 0;
  padding: 16px 24px 0;
  background: transparent;
  border: none;
  box-shadow: none;
}
.rubric h2 {
  font-family: var(--ui);
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.rubric-lead { margin: 0 0 12px; color: var(--muted); font-size: 0.875rem; font-weight: 400; }
.weights {
  list-style: none;
  margin: 0;
  padding: 8px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  border-top: 1px solid var(--line);
}
.weights li {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-height: auto;
  border-radius: 0;
  padding: 4px 0;
  font-size: 0.875rem;
  border: none;
  background: none;
  flex: 0 1 auto;
}
.weights .weight::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex: none;
}
.weights .weight.recency::before { background: var(--lemon); }
.weights .weight.mindshare::before { background: var(--berry); }
.weights .weight.impact::before { background: var(--mint); }
.weights .total {
  margin-left: auto;
  padding-left: 16px;
  border-left: 1px solid var(--line);
}
.weights strong { font-weight: 600; font-family: var(--ui); letter-spacing: 0; }
.weights span { font-family: var(--mono); font-size: 0.8125rem; font-weight: 500; color: var(--muted); }

.toolbar {
  max-width: 880px;
  margin: 16px auto 0;
  padding: 0 24px;
}
.filters {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}
.filters button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 0;
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.01em;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--muted);
  box-shadow: none;
}
.filters button:hover { color: var(--ink); }
.filters button[aria-pressed="true"] {
  background: transparent;
  color: var(--ink);
  border-bottom-color: var(--mint);
  box-shadow: none;
}
.hint { margin: 12px 0 0; color: var(--muted); font-size: 0.8125rem; font-weight: 400; }

main { max-width: 880px; margin: 16px auto 0; padding: 0 24px 24px; }
.status {
  background: var(--card);
  color: var(--ink);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-weight: 500;
  border: 1px solid var(--line-lilac);
  box-shadow: var(--shadow);
}

/* Leaderboard: white cards, 1px border, soft shadow, rank column + 3px bar */
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.row {
  width: 100%;
  text-align: left;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line-lilac);
  box-shadow: var(--shadow);
  padding: 16px 16px 16px 20px;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  grid-template-areas:
    "rank name score"
    "rank meta score"
    "bar  bar  bar"
    "why  why  why";
  gap: 4px 12px;
  min-height: 80px;
  align-items: start;
  position: relative;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.row::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--lilac);
  border-radius: 2px;
}
.row.gold::before { background: var(--lemon); }
.row.silver::before { background: var(--apricot); }
.row.bronze::before { background: var(--mint); }
.row:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}
.row:active { transform: translateY(0); box-shadow: var(--shadow); }

.rank {
  grid-area: rank;
  font-family: var(--ui);
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.4;
  width: auto; height: auto;
  display: block;
  color: var(--ink);
  background: none;
  border: none;
  box-shadow: none;
  transform: none;
  margin: 2px 0 0;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}
.rank.gold,
.rank.silver,
.rank.bronze {
  background: none;
  transform: none;
}

.name {
  grid-area: name;
  font-family: var(--ui);
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.018em;
  margin: 0;
  line-height: 1.25;
}
.meta {
  grid-area: meta;
  display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center;
  color: var(--muted); font-size: 0.8125rem; font-weight: 500;
}
.badge {
  display: inline-flex; align-items: center;
  padding: 0;
  border-radius: 0;
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase;
  border: none;
  background: none;
  color: var(--muted);
}
.badge.new { color: var(--berry); background: none; }
.badge.update { color: var(--ink); background: none; }

.score {
  grid-area: score;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1.125rem;
  font-variant-numeric: tabular-nums;
  background: none;
  color: var(--ink);
  border-radius: 0;
  padding: 0;
  min-width: 2.5ch;
  text-align: right;
  border: none;
  box-shadow: none;
  transform: none;
  line-height: 1.3;
}

.bar {
  grid-area: bar;
  display: flex;
  height: 6px;
  border-radius: 2px;
  overflow: hidden;
  background: rgba(44, 36, 84, 0.08);
  margin-top: 8px;
  border: none;
}
.bar i { display: block; height: 100%; }
.bar .recency { background: var(--lemon); }
.bar .mindshare { background: var(--berry); }
.bar .impact { background: var(--mint); }
.why {
  grid-area: why;
  margin: 8px 0 0;
  font-size: 0.875rem;
  color: var(--muted);
  font-weight: 400;
}

.foot {
  max-width: 880px;
  margin: 0 auto;
  padding: 8px 24px calc(32px + var(--safe-bot));
  color: var(--muted);
  font-size: 0.8125rem;
}
.foot p { margin: 0 0 8px; }
.gaps {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.gaps li {
  background: var(--card);
  border: 1px solid var(--line-lilac);
  border-left: 3px solid var(--lemon);
  padding: 12px 16px;
  border-radius: var(--radius);
  color: var(--muted);
  box-shadow: none;
}

/* Modal: white sheet, quiet close, type hierarchy */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(44, 36, 84, 0.4);
  padding: 16px 16px calc(16px + var(--safe-bot));
}
.sheet {
  background: var(--card);
  width: min(720px, 100%);
  max-height: min(92dvh, 900px);
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--line-lilac);
  box-shadow: var(--shadow-lift);
  padding: 24px 24px 32px;
  position: relative;
}
.close {
  position: sticky;
  top: 0;
  float: right;
  min-height: 44px;
  min-width: 64px;
  padding: 0 12px;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.875rem;
  z-index: 2;
  border: 1px solid var(--line);
  box-shadow: none;
  letter-spacing: 0.02em;
}
.close:hover { color: var(--ink); border-color: var(--line-lilac); background: var(--paper); }
.modal h2 {
  font-family: var(--ui);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 8px 0 4px;
  letter-spacing: -0.025em;
  padding-right: 80px;
}
.modal .vendor {
  margin: 0 0 4px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: center;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
}
.modal-meta .score-inline {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--ink);
}
.chips { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0 0 16px; }
.chip {
  background: none;
  border-radius: 0;
  padding: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  border: none;
  color: var(--muted);
}
.chip.score { background: none; color: var(--ink); font-family: var(--mono); font-weight: 600; }
.breakdown {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 16px;
  margin: 0 0 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.breakdown div {
  background: none;
  border-radius: 0;
  padding: 0;
  text-align: left;
  border: none;
}
.breakdown dt {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.breakdown dt::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex: none;
}
.breakdown div:nth-child(1) dt::before { background: var(--lemon); }
.breakdown div:nth-child(2) dt::before { background: var(--berry); }
.breakdown div:nth-child(3) dt::before { background: var(--mint); }
.breakdown dd { margin: 4px 0 0; font-family: var(--mono); font-size: 1.125rem; font-weight: 600; }
.modal h3 {
  font-family: var(--ui);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 24px 0 8px;
}
.modal p { margin: 0 0 8px; }
.links { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.links a {
  display: block;
  background: none;
  border-radius: 4px;
  padding: 12px 0;
  min-height: 44px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.9375rem;
  border: none;
  border-bottom: 1px solid var(--line);
  box-shadow: none;
}
.links a:hover { background: transparent; color: #5A3FD6; }
.links li:last-child a { border-bottom: none; }
.stars {
  display: inline;
  background: none;
  color: var(--muted);
  font-weight: 500;
  padding: 0;
  border-radius: 0;
  font-family: var(--ui);
  font-size: 0.875rem;
  border: none;
}

/* Week index: horizontal date tabs, mint underline for selected */
.weeks {
  max-width: 880px;
  margin: 8px auto 0;
  padding: 8px 24px 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  border: none;
}
.weeks-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 8px;
}
.weeks-head h2 {
  font-family: var(--ui);
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.weeks-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 400;
}
#all-weeks-btn {
  margin-left: auto;
  flex: none;
  min-height: 44px;
  padding: 0 8px;
  border-radius: 0;
  font-weight: 600;
  font-size: 0.875rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  box-shadow: none;
  color: var(--ink);
  letter-spacing: 0.01em;
}
#all-weeks-btn:hover { color: #5A3FD6; border-bottom-color: var(--lilac); }
.week-scroller {
  display: flex;
  gap: 0;
  overflow-x: auto;
  padding: 0;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  border-bottom: 1px solid var(--line);
}
.week-chip {
  flex: none;
  scroll-snap-align: start;
  min-width: 0;
  min-height: 48px;
  padding: 8px 16px 10px;
  border-radius: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  text-align: left;
  display: grid;
  align-content: center;
  gap: 2px;
  color: var(--muted);
  position: relative;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.week-chip::before { display: none; }
.week-chip[aria-current="true"] {
  background: transparent;
  color: var(--ink);
  outline: none;
  box-shadow: none;
  border-bottom-color: var(--mint);
}
.week-chip:hover { transform: none; color: var(--ink); }
.week-chip:active { transform: none; box-shadow: none; }
.week-chip-flag {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.week-chip[aria-current="true"] .week-chip-flag { color: var(--ink); }
.week-chip-date {
  font-family: var(--ui);
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: -0.01em;
}
.week-chip-window {
  display: none;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 65;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(44, 36, 84, 0.4);
  padding: 16px 16px calc(16px + var(--safe-bot));
}
.drawer-sheet {
  background: var(--card);
  width: min(560px, 100%);
  max-height: min(88dvh, 860px);
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--line-lilac);
  box-shadow: var(--shadow-lift);
  padding: 24px 24px 32px;
  position: relative;
}
.drawer-lead {
  margin: 8px 80px 16px 0;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.875rem;
}
.drawer h2 {
  font-family: var(--ui);
  font-size: 1.25rem;
  font-weight: 700;
  margin: 8px 0 0;
  letter-spacing: -0.02em;
  padding-right: 80px;
}
.weeks-full {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}
.weeks-full button {
  width: 100%;
  text-align: left;
  min-height: 56px;
  padding: 12px 12px 12px 16px;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  box-shadow: none;
  display: grid;
  gap: 2px;
  position: relative;
}
.weeks-full button::before {
  content: "";
  position: absolute;
  left: 0; top: 10px; bottom: 10px;
  width: 0;
  border-radius: 0;
  background: transparent;
}
.weeks-full button[aria-current="true"] {
  background: transparent;
  outline: none;
  box-shadow: none;
}
.weeks-full button[aria-current="true"]::before {
  width: 3px;
  background: var(--lilac);
}
.weeks-full strong {
  font-family: var(--ui);
  font-size: 0.9375rem;
  font-weight: 600;
}
.weeks-full span {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 400;
}

@media (min-width: 720px) {
  .modal { align-items: center; }
  .sheet { border-radius: 12px; }
  .drawer { align-items: center; }
  .drawer-sheet { border-radius: 12px; }
}

@media (max-width: 520px) {
  .hero { padding-left: 16px; padding-right: 16px; gap: 12px; }
  .weeks, .rubric, .toolbar, main, .foot { padding-left: 16px; padding-right: 16px; }
  .row {
    grid-template-columns: 32px 1fr auto;
    padding-left: 16px;
  }
  .name { font-size: 1rem; }
  .breakdown { grid-template-columns: 1fr; }
  h1 { font-size: 1.375rem; }
  .weights .total { margin-left: 0; padding-left: 0; border-left: none; }
  .sheet, .drawer-sheet { padding: 20px 16px 28px; }
}
