/* Same tokens as the syllabus app so both feel like one product. */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0efea;
  --ink: #1b1d21;
  --muted: #6b6f76;
  --line: #e2e0d9;
  --accent: #2f6fd6;
  --accent-soft: rgba(47, 111, 214, 0.12);
  --good: #2f8f5b;
  --good-soft: rgba(47, 143, 91, 0.12);
  --warn: #b7791f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --surface: #1e2126;
    --surface-2: #262a30;
    --ink: #eceae4;
    --muted: #9aa0a8;
    --line: #30343b;
    --accent: #6b9ff0;
    --accent-soft: rgba(107, 159, 240, 0.16);
    --good: #5cc28a;
    --good-soft: rgba(92, 194, 138, 0.14);
    --warn: #e0a84a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input { font: inherit; color: inherit; }
.muted { color: var(--muted); font-weight: 400; }

.wrap {
  max-width: 820px; margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-left)) calc(48px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-right));
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 820px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
}
.topbar h1 { font-size: 18px; margin: 0; letter-spacing: -0.01em; }
#tally { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* Fair */
.fair { padding: 16px; margin-bottom: 14px; }
.fair h2 { margin: 0 0 2px; font-size: 17px; }
.fair p { margin: 6px 0; font-size: 14px; }
.hours { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 2px; }
.hours li { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 4px 8px; border-radius: 8px; }
.hours li.today { background: var(--accent-soft); font-weight: 600; }
.fair details { margin-top: 8px; font-size: 14px; }
.fair summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.fair ul ul, .fair details ul { padding-left: 18px; margin: 6px 0; }

/* Filters */
.filters { margin-bottom: 8px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-btn {
  flex: none; cursor: pointer; white-space: nowrap;
  padding: 6px 12px; border-radius: 999px; font-size: 13.5px; font-weight: 550;
  background: var(--surface); border: 1px solid var(--line);
}
.chip-btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.toggles { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13.5px; color: var(--muted); }
.toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; padding: 4px 0; }
.toggle input { width: 16px; height: 16px; accent-color: var(--accent); }

/* Books */
.topic h2 { font-size: 15px; margin: 22px 2px 8px; }
.topic h2 .muted { font-size: 13px; margin-left: 4px; }
.book { padding: 14px 16px; margin-bottom: 10px; }
.book.bought { opacity: 0.62; }
.b-top { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip {
  font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.chip.pri[data-p="kluczowa"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.stand { background: var(--good-soft); color: var(--good); border-color: transparent; }
.book h3 { margin: 0; font-size: 16.5px; line-height: 1.3; letter-spacing: -0.005em; }
.orig { font-size: 13px; color: var(--muted); margin-top: 2px; }
.why { margin: 8px 0 6px; font-size: 14.5px; }
.rec { font-size: 12.5px; color: var(--muted); }

.offers { list-style: none; margin: 10px 0 0; padding: 0; border-top: 1px solid var(--line); }
.offers li {
  display: grid; grid-template-columns: 112px 1fr auto; gap: 2px 10px; align-items: baseline;
  padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.fmt { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.price { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; text-align: right; }
.price.free { color: var(--good); }
/* Foreign prices come with a description ("$32.99 (regular $54.99)"), so they wrap. */
.price.muted { white-space: normal; max-width: 11em; font-size: 12.5px; font-weight: 500; }
.o-note { grid-column: 2 / -1; font-size: 12px; color: var(--muted); }

.b-actions { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--good); }
.fair-price {
  flex: 1; min-width: 0; max-width: 180px; margin-left: auto;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font-size: 14px;
}
.fair-price:focus { outline: 2px solid var(--accent-soft); outline-offset: 1px; }
.hint { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }

/* Route */
.route h2 { font-size: 15px; margin: 28px 2px 8px; }
.stops { list-style: none; margin: 0; padding: 4px 16px; }
.stops li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.stops li:last-child { border-bottom: 0; }
.r-head { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.r-books { font-size: 13px; color: var(--muted); margin-top: 2px; }

@media (max-width: 420px) {
  .offers li { grid-template-columns: 92px 1fr auto; }
}
