:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --panel: #ffffff;
  --ink: #20201d;
  --muted: #68665f;
  --line: #d8d3c8;
  --accent: #136c62;
  --accent-2: #b44d2f;
  --steel: #385e7a;
  --apple: #5e8d2f;
  --gold: #b98217;
  --shadow: 0 10px 24px rgba(41, 35, 25, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button, input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 6px;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 24px clamp(16px, 4vw, 48px) 14px;
}

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

h1 {
  font-size: clamp(2rem, 4vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 { font-size: 1.35rem; }
h3 { font-size: 1rem; line-height: 1.25; }

.eyebrow {
  color: var(--accent-2);
  text-transform: uppercase;
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

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

main {
  padding: 0 clamp(16px, 4vw, 48px) 48px;
}

.brief-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 420px);
  gap: 20px;
  align-items: end;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 22px 0;
  margin-bottom: 20px;
}

.brief {
  max-width: 820px;
  font-size: clamp(1.25rem, 2vw, 2rem);
  line-height: 1.18;
  font-weight: 750;
}

.status-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.72);
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.pill.live { color: var(--accent); border-color: rgba(19,108,98,0.35); }
.pill.error { color: var(--accent-2); border-color: rgba(180,77,47,0.35); }

.lineup-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 28px;
}

.lineup-tile {
  min-height: 128px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.lineup-tile strong {
  display: block;
  margin: 8px 0 6px;
  line-height: 1.15;
}

.lineup-tile span {
  color: var(--muted);
  font-size: 0.85rem;
}

.content-band {
  padding: 24px 0;
  border-top: 1px solid var(--line);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 14px;
}

.section-head p {
  color: var(--muted);
  max-width: 620px;
}

.section-head.inline {
  align-items: center;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.card-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card {
  min-height: 178px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.card p {
  color: var(--muted);
  line-height: 1.42;
}

.card-meta {
  color: var(--gold);
  font-size: 0.78rem;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
}

.tag {
  padding: 3px 7px;
  background: #f0ede5;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.76rem;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.card-actions a,
.card-actions button {
  min-height: 32px;
  font-size: 0.85rem;
}

.card-actions a {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  text-decoration: none;
  background: var(--panel);
}

.streak-panel {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(260px, 1fr) minmax(210px, 0.7fr);
  gap: 12px;
  align-items: stretch;
  margin-bottom: 12px;
}

.streak-summary,
.ritual-checks,
.heatmap {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.streak-summary > div {
  padding: 14px;
  border-right: 1px solid var(--line);
}

.streak-summary > div:last-child {
  border-right: 0;
}

.streak-summary strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
  color: var(--accent);
}

.streak-summary span {
  color: var(--muted);
  font-size: 0.82rem;
}

.ritual-checks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
}

.check-button {
  justify-content: center;
  min-width: 0;
  padding: 0 10px;
  gap: 8px;
  background: #fbfaf6;
}

.check-button.checked {
  border-color: rgba(94, 141, 47, 0.5);
  background: rgba(94, 141, 47, 0.1);
}

.check-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--panel);
}

.check-button.checked .check-dot {
  border-color: var(--apple);
  background: var(--apple);
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 18px;
  gap: 5px;
  padding: 12px;
}

.heat-cell {
  border-radius: 4px;
  border: 1px solid #ddd8ce;
  background: #eeeae1;
}

.heat-cell.checked {
  border-color: rgba(94, 141, 47, 0.45);
  background: var(--apple);
}

.heat-cell.today {
  outline: 2px solid var(--accent-2);
  outline-offset: 1px;
}

.deal-card {
  min-height: 304px;
}

.deal-head {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.deal-rank {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 850;
}

.price-viz {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
}

.price-row {
  display: grid;
  grid-template-columns: 68px minmax(80px, 1fr) 58px;
  gap: 8px;
  align-items: center;
  font-size: 0.82rem;
}

.price-row span,
.price-row strong,
.spark-wrap span {
  color: var(--muted);
}

.price-row strong {
  text-align: right;
  font-size: 0.78rem;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #e6e0d5;
  overflow: hidden;
}

.bar {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.bar.list { background: var(--steel); opacity: 0.42; }
.bar.observed { background: var(--accent); }
.bar.savings { background: var(--gold); }

.spark-wrap {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 112px;
  gap: 10px;
  align-items: center;
}

.spark-wrap span {
  font-size: 0.78rem;
}

.sparkline {
  width: 112px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfaf6;
}

.sparkline polyline {
  stroke: var(--accent-2);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings {
  position: fixed;
  z-index: 10;
  top: 16px;
  right: 16px;
  width: min(390px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.18);
}

.settings-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.toggle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.toggle-grid label,
.field {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.field {
  align-items: stretch;
  flex-direction: column;
  margin-bottom: 12px;
}

input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}

.search {
  width: min(280px, 100%);
}

.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  padding: 16px;
  border-radius: 8px;
}

@media (max-width: 980px) {
  .brief-band,
  .section-head {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: flex-start;
  }

  .status-row {
    justify-content: flex-start;
  }

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

  .streak-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .lineup-grid,
  .card-grid,
  .card-grid.compact {
    grid-template-columns: 1fr;
  }

  .streak-summary,
  .ritual-checks {
    grid-template-columns: 1fr;
  }

  .streak-summary > div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .streak-summary > div:last-child {
    border-bottom: 0;
  }

  .price-row {
    grid-template-columns: 58px minmax(70px, 1fr) 52px;
  }
}
