:root {
  --paper: #f6f3ec;
  --surface: #fffdf8;
  --ink: #1c1a17;
  --muted: #6c675d;
  --line: #ded8ca;
  --tag: #ffd84a;
  --tag-ink: #1c1a17;
  --alert: #b8321f;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #151412;
    --surface: #1e1c19;
    --ink: #f1ede4;
    --muted: #a09a8d;
    --line: #35322b;
    --alert: #ff8a75;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
}

a {
  color: inherit;
}

.top,
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
}

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-top: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.mark {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

nav {
  display: flex;
  gap: 18px;
}

nav a {
  color: var(--muted);
  text-decoration: none;
  padding-bottom: 14px;
  margin-bottom: -15px;
  border-bottom: 2px solid transparent;
}

nav a.on {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

main {
  padding-top: 28px;
  padding-bottom: 80px;
}

h1 {
  font-size: clamp(30px, 7vw, 42px);
  line-height: 1.08;
  letter-spacing: -0.025em;
  margin: 0 0 6px;
}

h2 {
  font-size: 19px;
  letter-spacing: -0.01em;
  margin: 0;
}

h3 {
  font-size: 15px;
  margin: 26px 0 8px;
}

p {
  margin: 0 0 12px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13.5px;
}

.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tag {
  display: inline-block;
  background: var(--tag);
  color: var(--tag-ink);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 3px;
  white-space: nowrap;
}

/* Controls */

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

.btn {
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 6px;
  padding: 9px 16px;
  font-weight: 600;
  cursor: pointer;
}

.btn.quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
  font-weight: 500;
}

.btn.small {
  padding: 5px 11px;
  font-size: 14px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link:hover {
  color: var(--ink);
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
}

textarea {
  min-height: 132px;
  resize: vertical;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

input[type="checkbox"] {
  accent-color: var(--ink);
  width: 20px;
  height: 20px;
  margin: 0;
  flex: none;
}

label.field {
  display: block;
  font-size: 13.5px;
  color: var(--muted);
}

label.field > * {
  margin-top: 4px;
  color: var(--ink);
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.grow {
  flex: 1 1 0;
  min-width: 0;
}

/* Panels */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 18px;
}

.notice {
  border-left: 3px solid var(--ink);
  padding: 8px 0 8px 12px;
  margin: 0 0 16px;
}

.notice.bad {
  border-left-color: var(--alert);
  color: var(--alert);
}

.progress {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  margin: 10px 0 4px;
}

.progress > i {
  display: block;
  height: 100%;
  background: var(--ink);
  transition: width 0.4s ease;
}

/* This week */

.hero {
  margin-bottom: 26px;
}

.route {
  font-size: 19px;
  margin: 0 0 14px;
}

.figure {
  font-size: 17px;
  margin: 0 0 14px;
}

.figure .tag {
  font-size: 22px;
  padding: 2px 10px;
  margin-right: 6px;
}

.brief {
  max-width: 56ch;
}

.store {
  margin-top: 30px;
}

.store-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--ink);
}

.store-head .stop {
  font-family: var(--mono);
  color: var(--muted);
}

.line {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.line-main {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.line-main input {
  margin-top: 2px;
}

.line-body {
  flex: 1 1 0;
  min-width: 0;
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.line-name {
  font-weight: 600;
}

.line-detail {
  color: var(--muted);
  font-size: 14.5px;
  overflow-wrap: anywhere;
}

.line-price {
  text-align: right;
  flex: none;
}

.line-price .num {
  font-weight: 600;
}

.line-price .tag {
  font-size: 12.5px;
  margin-top: 3px;
}

.line.done .line-name,
.line.done .line-price .num {
  text-decoration: line-through;
}

.line.done,
.line.skipped {
  color: var(--muted);
}

.line-more {
  margin: 10px 0 2px 32px;
  font-size: 14.5px;
}

.alts {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 10px;
}

.alts td {
  padding: 5px 8px 5px 0;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

.alts td:last-child {
  text-align: right;
  padding-right: 0;
}

details.later {
  margin-top: 30px;
}

details.later summary {
  cursor: pointer;
  font-weight: 600;
}

.later-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
}

.later-list li {
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

/* Receipt-style totals */

.receipt {
  margin-top: 34px;
  font-family: var(--mono);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.receipt div {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 0;
}

.receipt div::after {
  content: "";
  order: 1;
  flex: 1 1 0;
  border-bottom: 1px dotted var(--muted);
  transform: translateY(-3px);
}

.receipt span:first-child {
  order: 0;
  color: var(--muted);
}

.receipt span:last-child {
  order: 2;
  text-align: right;
}

/* Pantry */

.item {
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}

.item-top {
  display: flex;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
}

.meter {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  margin: 8px 0 6px;
  overflow: hidden;
}

.meter > i {
  display: block;
  height: 100%;
  background: var(--ink);
}

.meter.low > i {
  background: var(--tag);
}

.meter.out > i {
  background: var(--alert);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.draft {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
}

.draft td {
  padding: 8px 8px 8px 0;
  border-top: 1px solid var(--line);
  vertical-align: baseline;
}

.draft td:last-child {
  text-align: right;
  padding-right: 0;
}

/* Settings */

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

.chip {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer;
}

.chip.on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.setting {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.setting > div:first-child {
  flex: 1 1 0;
}

.setting select,
.setting input[type="number"] {
  width: auto;
  min-width: 96px;
}

@media (max-width: 480px) {
  nav {
    gap: 14px;
    font-size: 15px;
  }
  .line-more {
    margin-left: 0;
  }
}
