:root {
  --paper:       #f5f1e8;
  --ink:         #1a1a1a;
  --ink-fade:    #6e6a5e;
  --rule:        #cfc8b3;
  --highlight:   #fff6a8;
  --legendary:   #d97706;
  --rare:        #2563eb;
  --epic:        #8b5cf6;
  --uncommon:    #16a34a;
  --red:         #dc2626;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --hand: 'Caveat', cursive;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--paper); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.6; min-height: 100vh;
  font-variant-numeric: tabular-nums;
}

/* ── Loading / Error ─────────────────────────────── */
.app-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 60vh; gap: 1.5rem;
}
.loading-prog {
  width: 120px; height: 3px; background: var(--rule); border-radius: 2px;
  position: relative; overflow: hidden;
}
.loading-prog::after {
  content: ''; position: absolute; left: -50%; top: 0; height: 100%;
  width: 50%; background: var(--legendary); border-radius: 2px;
  animation: prog-slide 1s ease infinite;
}
@keyframes prog-slide { 0%{left:-50%} 100%{left:150%} }
.loading-msg { font-size: .88rem; color: var(--ink-fade); font-family: var(--mono); }
.app-error { padding: 3rem; text-align: center; color: var(--red); font-family: var(--mono); font-size: .88rem; }

/* ── Masthead ─────────────────────────────────────── */
.masthead {
  border-bottom: 2px solid var(--ink);
  padding: 1.5rem 2rem 1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "eyebrow actions"
    "title   title"
    "sub     sub";
  gap: .15rem 0;
  background: var(--paper);
  position: sticky; top: 0; z-index: 100;
}
.masthead-eyebrow {
  grid-area: eyebrow;
  font-family: var(--mono); font-size: .68rem; color: var(--ink-fade);
  letter-spacing: .1em; text-transform: uppercase; align-self: end;
}
.masthead-title {
  grid-area: title;
  font-family: var(--hand); font-size: 3.2rem; font-weight: 700;
  color: var(--ink); line-height: 1; letter-spacing: -.02em;
}
.masthead-sub {
  grid-area: sub;
  font-size: .8rem; color: var(--ink-fade); font-style: italic;
}
.masthead-actions {
  grid-area: actions;
  display: flex; gap: .5rem; align-items: flex-end; padding-bottom: .1rem;
}
.masthead-action-dim {
  font-family: var(--mono); font-size: .7rem; color: var(--rule);
  letter-spacing: .04em; cursor: default;
}

/* ── Page content ────────────────────────────────── */
.page-content { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem 3rem; }

/* ── Section titles ──────────────────────────────── */
.section-title {
  font-family: var(--mono); font-size: .72rem; color: var(--ink-fade);
  text-transform: uppercase; letter-spacing: .12em;
  border-bottom: 1px solid var(--rule); padding-bottom: .4rem;
  margin-bottom: 1rem; margin-top: 2.5rem;
}
.section-title .appendix-count { font-size: .68rem; color: var(--rule); }

/* ── Cover pick ──────────────────────────────────── */
.cover-pick {
  margin-top: 2rem; padding: 1.5rem;
  border: 1.5px solid var(--ink); border-radius: 2px;
  background: var(--paper);
  position: relative;
}
.cover-stamp {
  position: absolute; top: -11px; left: 1.2rem;
  font-family: var(--mono); font-size: .66rem; font-weight: 600;
  background: var(--ink); color: var(--paper);
  padding: 1px 8px; letter-spacing: .08em; text-transform: uppercase;
}
.cover-layout { display: flex; gap: 2rem; align-items: flex-start; }
.cover-photo {
  width: 130px; flex-shrink: 0; aspect-ratio: 2/3;
  border: 1.5px solid var(--rule); border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  background: #ede9de; overflow: hidden;
}
.cover-photo-name {
  font-family: var(--hand); font-size: .9rem; color: var(--ink-fade);
  text-align: center; padding: .5rem; word-break: break-word; line-height: 1.3;
}
.cover-photo.ph-beer    { border-color: var(--rare);   background: #eff4ff; }
.cover-photo.ph-wine    { border-color: var(--epic);   background: #f5f0ff; }
.cover-photo.ph-spirit  { border-color: var(--legendary); background: #fffbeb; }
.cover-photo.ph-cider   { border-color: var(--uncommon); background: #f0fdf4; }
.cover-body { flex: 1; min-width: 0; }
.cover-rating { margin-bottom: .25rem; font-size: 1.1rem; }
.rating-legendary { color: var(--legendary); font-weight: 600; }
.rating-epic      { color: var(--epic);      font-weight: 600; }
.rating-rare      { color: var(--rare);      font-weight: 600; }
.rating-dim       { color: var(--ink-fade); }
.cover-name { font-size: 1.4rem; font-weight: 700; margin-bottom: .5rem; line-height: 1.2; }
.cover-blurb {
  font-size: .88rem; color: var(--ink); line-height: 1.7;
  margin-bottom: 1rem; max-width: 60ch;
}
.cover-stats { display: flex; gap: 1.5rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.cstat { display: flex; flex-direction: column; gap: .1rem; }
.cstat-val { font-family: var(--mono); font-size: 1.2rem; font-weight: 700; }
.cstat-lbl { font-size: .68rem; color: var(--ink-fade); text-transform: uppercase; letter-spacing: .07em; }
.cover-actions { display: flex; gap: .75rem; }
.cover-cta {
  display: inline-block; padding: .4rem 1rem;
  background: var(--ink); color: var(--paper);
  font-size: .82rem; font-weight: 600; text-decoration: none; letter-spacing: .03em;
  border-radius: 2px; transition: opacity .12s;
}
.cover-cta:hover { opacity: .82; }

/* ── Category boards ─────────────────────────────── */
.category-section { margin-top: 2.5rem; }
.boards-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem;
}
.boards-mobile { display: none; }
.category-board {
  border-top: 3px solid var(--board-color, var(--rule));
  border-left: 1px solid var(--rule); border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  border-radius: 0 0 2px 2px;
  overflow: hidden;
}
.board-header {
  font-family: var(--mono); font-size: .64rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  padding: .5rem .75rem; background: var(--paper);
  border-bottom: 1px solid var(--rule); color: var(--board-color, var(--ink-fade));
}
.board-rows { display: flex; flex-direction: column; }
.board-row {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem .75rem; text-decoration: none; color: var(--ink);
  border-bottom: 1px solid var(--rule); font-size: .82rem;
  transition: background .1s;
}
.board-row:last-child { border-bottom: none; }
.board-row:hover { background: #ede9de; }
.board-row-top { background: var(--highlight); font-weight: 600; }
.board-row-top:hover { background: #fff2a0; }
.board-rank { font-family: var(--mono); font-size: .7rem; color: var(--ink-fade); width: 1.2rem; flex-shrink: 0; }
.board-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-std { font-family: var(--mono); font-size: .78rem; color: var(--ink-fade); white-space: nowrap; }
.board-tabs { display: flex; gap: .4rem; margin-bottom: .75rem; flex-wrap: wrap; }
.board-tab {
  padding: .3rem .75rem; border: 1.5px solid var(--rule); border-radius: 2px;
  background: transparent; color: var(--ink-fade); font-size: .8rem;
  font-family: inherit; cursor: pointer; transition: all .1s;
}
.board-tab.active { font-weight: 700; }

/* ── Snippets ─────────────────────────────────────── */
.snippets-section {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem;
  margin-top: 2.5rem;
}
.snippet-card {
  border: 1.5px solid var(--rule); border-radius: 2px;
  padding: 1rem 1.1rem;
}
.snippet-climber { border-top-color: var(--uncommon); }
.snippet-watch   { border-top-color: var(--legendary); }
.snippet-dont    { border-top-color: var(--red); }
.snippet-label {
  font-family: var(--mono); font-size: .64rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .12em; color: var(--ink-fade);
  margin-bottom: .4rem;
}
.snippet-text { font-size: .86rem; color: var(--ink); line-height: 1.5; }

/* ── Scatter ─────────────────────────────────────── */
.scatter-section { margin-top: 2.5rem; }
.scatter-layout { display: flex; gap: 1.5rem; align-items: flex-start; }
.scatter-main { flex: 1; min-width: 0; }
.scatter-type-chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .6rem; }
.scatter-chip {
  padding: .2rem .65rem; border: 1.5px solid var(--chip-color, var(--rule));
  border-radius: 20px; background: transparent;
  color: var(--chip-color, var(--ink-fade)); font-size: .74rem; font-family: inherit;
  cursor: pointer; transition: opacity .1s;
}
.scatter-chip.hidden { opacity: .3; }
.scatter-svg {
  width: 100%; max-width: 600px; cursor: crosshair;
  border: 1px solid var(--rule); border-radius: 2px;
  background: var(--paper);
  touch-action: none;
}
.scatter-axis-labels {
  display: flex; justify-content: space-between; margin-top: .25rem;
  font-family: var(--mono); font-size: .66rem; color: var(--ink-fade);
}
.scatter-clear-brush {
  margin-top: .5rem;
  font-family: var(--mono); font-size: .68rem;
  background: none; border: 1px solid var(--rule); border-radius: 2px;
  color: var(--ink-fade); cursor: pointer; padding: .2rem .5rem;
}
.scatter-clear-brush:hover { color: var(--ink); border-color: var(--ink); }
.scatter-rail {
  width: 180px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: .75rem;
}
.rail-stats { display: flex; flex-wrap: wrap; gap: .75rem; }
.rail-stat { display: flex; flex-direction: column; }
.rail-stat-val { font-family: var(--mono); font-size: 1.1rem; font-weight: 700; }
.rail-stat-lbl { font-size: .66rem; color: var(--ink-fade); text-transform: uppercase; letter-spacing: .06em; }
.rail-type-mix { display: flex; flex-direction: column; gap: .15rem; width: 100%; }
.rail-type-row { font-size: .78rem; font-weight: 600; display: flex; justify-content: space-between; }
.rail-type-n { font-family: var(--mono); font-weight: 400; color: var(--ink-fade); }
.rail-detail {
  border: 1.5px solid var(--rule); border-radius: 2px;
  padding: .75rem; background: #ede9de; position: relative;
  font-size: .82rem;
}
.detail-name { font-weight: 700; margin-bottom: .25rem; line-height: 1.3; word-break: break-word; }
.detail-meta { font-size: .74rem; color: var(--ink-fade); margin-bottom: .3rem; }
.detail-std { font-family: var(--mono); font-size: 1.1rem; font-weight: 700; color: var(--legendary); }
.detail-rating { font-size: .9rem; color: var(--epic); font-weight: 600; }
.detail-link {
  display: inline-block; margin-top: .4rem;
  font-family: var(--mono); font-size: .7rem; color: var(--rare);
  text-decoration: none;
}
.detail-link:hover { text-decoration: underline; }
.detail-dismiss {
  position: absolute; top: .4rem; right: .5rem;
  background: none; border: none; cursor: pointer;
  color: var(--ink-fade); font-size: .8rem; padding: 2px 4px;
}

/* ── Appendix ─────────────────────────────────────── */
.appendix-section { margin-top: 2.5rem; }
.appendix-layout { display: flex; gap: 1.5rem; align-items: flex-start; }
.appendix-sidebar {
  width: 180px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: .75rem;
  position: sticky; top: 80px;
}
.appendix-sidebar-inner { display: flex; flex-direction: column; gap: .75rem; }
.sidebar-backdrop-app { display: none; }
.drawer-close-btn { display: none; }
.filter-group { display: flex; flex-direction: column; gap: .35rem; }
.filter-group-label {
  font-family: var(--mono); font-size: .65rem; text-transform: uppercase;
  letter-spacing: .12em; color: var(--ink-fade);
}
.filter-chips-row { display: flex; flex-wrap: wrap; gap: 4px; }
.filter-chip {
  padding: 2px 9px; border-radius: 20px; border: 1.5px solid var(--rule);
  background: transparent; color: var(--ink-fade); font-size: .72rem;
  font-family: inherit; cursor: pointer; transition: all .1s;
}
.filter-chip:hover { border-color: var(--ink); color: var(--ink); }
.filter-chip.active { font-weight: 600; background: var(--highlight); border-color: var(--ink); color: var(--ink); }
.chip-n { font-size: .62rem; color: var(--rule); }
.filter-reset {
  font-size: .72rem; background: none; border: none; cursor: pointer;
  color: var(--ink-fade); font-family: inherit; padding: 2px 0;
  text-decoration: underline; text-decoration-color: transparent; text-align: left;
}
.filter-reset:hover { color: var(--ink); text-decoration-color: currentColor; }
.appendix-table-wrap { flex: 1; min-width: 0; }
.appendix-toolbar {
  display: flex; gap: .6rem; margin-bottom: .75rem; align-items: center;
}
.appendix-search-wrap { flex: 1; }
.appendix-search {
  width: 100%; border: 1.5px solid var(--rule); border-radius: 2px;
  background: var(--paper); color: var(--ink); font-family: inherit; font-size: .88rem;
  padding: .35rem .65rem; outline: none;
}
.appendix-search:focus { border-color: var(--ink); }
.appendix-search::placeholder { color: var(--rule); }
.appendix-filter-btn {
  display: none; padding: .35rem .75rem;
  border: 1.5px solid var(--rule); border-radius: 2px; background: transparent;
  color: var(--ink-fade); font-family: var(--mono); font-size: .75rem; cursor: pointer;
}
.table-scroll { overflow-x: auto; }
.appendix-table {
  width: 100%; border-collapse: collapse;
  font-size: .84rem;
}
.appendix-table thead th {
  background: var(--paper);
  font-family: var(--mono); font-size: .65rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; color: var(--ink-fade);
  padding: .5rem .65rem; border-bottom: 1.5px solid var(--ink);
  white-space: nowrap; position: sticky; top: 76px; z-index: 5;
}
.th-sort { cursor: pointer; user-select: none; }
.th-sort:hover { color: var(--ink); }
.th-sort.active { color: var(--ink); }
.th-rank { width: 2.5rem; text-align: right; }
.appendix-table td {
  padding: .38rem .65rem; border-bottom: 1px solid var(--rule);
  white-space: nowrap; vertical-align: middle;
}
.td-rank { text-align: right; font-family: var(--mono); font-size: .72rem; color: var(--ink-fade); }
.td-name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.td-type { font-size: .78rem; font-weight: 600; }
.td-source { font-size: .78rem; color: var(--ink-fade); }
.td-std, .td-rating, .td-score { text-align: right; }
.row-name-link { color: var(--ink); text-decoration: none; font-weight: 600; }
.row-name-link:hover { text-decoration: underline; }
tr.row-top1 td { background: var(--highlight) !important; }
.appendix-table tbody tr:hover td { background: #ede9de; }
tr.row-top1:hover td { background: #fff2a0 !important; }
.cell-dim { color: var(--ink-fade); }
.appendix-empty {
  text-align: center; padding: 2.5rem; color: var(--ink-fade); font-size: .88rem;
}
.appendix-empty-reset {
  background: none; border: 1px solid var(--rule); border-radius: 2px;
  color: var(--ink-fade); font-family: inherit; font-size: .8rem;
  padding: .3rem .75rem; cursor: pointer; margin-left: .5rem;
}
.appendix-empty-reset:hover { color: var(--ink); border-color: var(--ink); }

/* ── Value heatmap badges ─────────────────────────── */
.std-badge {
  font-family: var(--mono); font-size: .84rem; font-weight: 700;
  padding: 1px 5px; border-radius: 2px; display: inline-block;
}
.std-legendary { color: var(--uncommon); background: #d1fae5; }
.std-uncommon  { color: #065f46;         background: #ecfdf5; }
.std-rare      { color: var(--ink-fade); background: #f3f0e8; }
.std-common    { color: var(--legendary); background: #fef3c7; }
.std-poor      { color: var(--red);      background: #fee2e2; }
.value-score { font-family: var(--mono); font-size: .82rem; font-weight: 600; }
.value-score.pos { color: var(--uncommon); }
.value-score.neg { color: var(--ink-fade); }

/* ── Footer ──────────────────────────────────────── */
.site-footer {
  margin-top: 3rem; border-top: 1px solid var(--rule);
  padding: 1rem 0; font-style: italic; font-size: .72rem;
  color: var(--ink-fade); line-height: 1.8;
}
.site-footer a { color: var(--ink-fade); }
.site-footer a:hover { color: var(--ink); }
.footer-flavor { font-size: .68rem; color: var(--rule); }

/* ── Focus ───────────────────────────────────────── */
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--legendary); outline-offset: 2px;
}

/* ── Mobile ──────────────────────────────────────── */
@media (max-width: 900px) {
  .boards-grid { grid-template-columns: repeat(2, 1fr); }
  .scatter-rail { display: none; }
}

@media (max-width: 680px) {
  .masthead { padding: 1rem 1rem .75rem; }
  .masthead-title { font-size: 2.4rem; }
  .page-content { padding: 0 .85rem 2rem; }

  .cover-layout { flex-direction: column; }
  .cover-photo { width: 100%; aspect-ratio: 16/7; }

  .boards-grid { display: none; }
  .boards-mobile { display: block; }

  .snippets-section { grid-template-columns: 1fr; }

  .scatter-layout { flex-direction: column; }
  .scatter-rail { display: flex; flex-direction: row; flex-wrap: wrap; width: 100%; }

  .appendix-layout { flex-direction: column; }
  .appendix-sidebar {
    width: 100%; position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    z-index: 200; max-height: 75vh;
    background: var(--paper); border-top: 2px solid var(--ink);
    border-radius: 12px 12px 0 0; padding: .75rem 1rem 1.5rem;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform .25s ease;
  }
  .appendix-sidebar.open { transform: translateY(0); }
  .sidebar-backdrop-app {
    display: block; position: fixed; inset: 0;
    background: rgba(0,0,0,0.4); z-index: 199;
    pointer-events: none; opacity: 0; transition: opacity .25s;
  }
  .appendix-sidebar.open .sidebar-backdrop-app {
    pointer-events: auto; opacity: 1;
  }
  .drawer-close-btn {
    display: block; position: absolute; top: .75rem; right: .85rem;
    background: none; border: none; font-size: 1rem; cursor: pointer;
    color: var(--ink-fade); padding: 4px 8px;
  }
  .appendix-filter-btn { display: flex; align-items: center; }
}
