:root {
  --bg: #f6f6f4;
  --card: #ffffff;
  --text: #1c1c1a;
  --muted: #6b6b66;
  --line: #e3e2de;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --good: #0f7a3d;
  --warn: #a15c00;
  --bad: #b42318;
  --radius: 10px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514;
    --card: #1f1f1d;
    --text: #ecebe7;
    --muted: #a09f99;
    --line: #34332f;
    --accent: #6ea2ff;
    --accent-text: #0b1a33;
    --good: #5ccf8d;
    --warn: #f0b35a;
    --bad: #ff8a80;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

a {
  color: var(--accent);
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 12px 16px 40px;
}

footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 16px 24px;
  color: var(--muted);
  font-size: 12px;
}

.top {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.top nav {
  display: flex;
  gap: 2px;
  max-width: 880px;
  margin: 0 auto;
  overflow-x: auto;
}

.tab {
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

@media (max-width: 400px) {
  .tab {
    padding: 6px 7px;
    font-size: 14px;
  }

  .count {
    margin-left: 3px;
  }
}

.tab.active {
  background: var(--text);
  color: var(--bg);
}

.count {
  margin-left: 6px;
  font-size: 12px;
  opacity: 0.7;
}

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

button {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

button.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  text-align: left;
}

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

input,
select,
textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

input[type="checkbox"] {
  width: auto;
}

label {
  display: block;
  margin: 8px 0;
}

label.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 14px;
}

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

.small {
  font-size: 12px;
}

.flash {
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--line);
}

.flash.error {
  border-color: var(--bad);
  color: var(--bad);
}

.status-line {
  margin: 4px 0 12px;
  font-size: 13px;
}

.empty {
  padding: 40px 0;
  text-align: center;
  color: var(--muted);
}

.rows {
  display: grid;
  gap: 10px;
}

.row {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: opacity 0.2s;
}

.row.leaving {
  opacity: 0;
}

.thumb {
  display: block;
  width: 112px;
  height: 84px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--line);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.info {
  min-width: 0;
}

.price {
  font-size: 18px;
  font-weight: 650;
}

.price small {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 12px;
  font-weight: 500;
  vertical-align: 2px;
}

.badge.good {
  color: var(--good);
}

.badge.warn {
  color: var(--warn);
}

.mentions .badge {
  margin: 2px 6px 2px 0;
}

.address,
.dist {
  overflow-wrap: anywhere;
}

.dist {
  font-size: 13px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.chip {
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
}

.chip.gone {
  text-decoration: line-through;
  color: var(--muted);
}

.notes {
  margin-top: 6px;
  font-size: 13px;
}

.notes summary {
  cursor: pointer;
  color: var(--muted);
}

.notes-form {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}

.notes-form button {
  justify-self: start;
}

.saved {
  color: var(--good);
  font-size: 12px;
}

.actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

@media (min-width: 640px) {
  .row {
    grid-template-columns: 160px 1fr auto;
  }

  .thumb {
    width: 160px;
    height: 120px;
  }

  .actions {
    grid-column: auto;
    flex-direction: column;
    justify-content: flex-start;
  }

  .actions button {
    width: 100%;
  }
}

.card {
  margin-bottom: 14px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card h2 {
  margin: 4px 0 8px;
  font-size: 16px;
}

.login {
  max-width: 360px;
  margin: 12vh auto 0;
}

.login h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.inline {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline input {
  flex: 1;
}

.card form + form {
  margin-top: 12px;
}

.card form > .primary {
  margin-top: 6px;
}

.health + form {
  margin-top: 10px;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0 12px;
}

fieldset {
  margin: 10px 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.area {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0 8px;
  align-items: end;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
}

.area:last-child {
  border-bottom: 0;
}

.area-label {
  font-weight: 600;
  margin: 8px 0;
}

.health {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.health th,
.health td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.warn-text {
  color: var(--warn);
}

.error-text {
  white-space: pre-wrap;
  color: var(--bad);
  font-size: 12px;
}
