:root {
  --paper: #f2f3ef;
  --surface: #fbfbf9;
  --ink: #1d2227;
  --muted: #5d666e;
  --line: #d3d6cf;
  --accent: #7c1d2e;
  --accent-ink: #ffffff;
  --brass: #8a6a1f;
  --danger: #a3262a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --page: 62rem; /* max content width on wide screens */
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15181b; --surface: #1b1f23; --ink: #e6e8e3; --muted: #9aa3a9;
    --line: #2e3439; --accent: #e0909c; --accent-ink: #1b1f23; --brass: #d1b25e;
    --danger: #ef8a8d;
  }
}
* { box-sizing: border-box; }
html { font-size: 17px; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); line-height: 1.5;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.bar {
  display: flex; align-items: baseline; gap: 1.5rem; flex-wrap: wrap;
  padding: .9rem max(1rem, calc((100vw - var(--page)) / 2));
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand { font-family: var(--serif); font-size: 1.25rem; font-weight: 700; color: var(--ink); text-decoration: none; margin-right: auto; }
.bar nav { display: flex; gap: 1.1rem; }
.bar nav a { color: var(--ink); text-decoration: none; }
.bar nav a:hover { color: var(--accent); }
.bar .who { color: var(--muted); margin-right: .6rem; font-size: .9rem; }
form.inline { display: inline; margin: 0; }

main { max-width: var(--page); margin: 0 auto; padding: 1.75rem 1rem 3rem; }
footer { max-width: var(--page); margin: 0 auto; padding: 0 1rem 2rem; color: var(--muted); font-size: .85rem; }

h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; margin-top: 2rem; }
h3 { font-size: 1.1rem; }
.lede { color: var(--muted); margin: 0 0 1.5rem; }
.muted { color: var(--muted); }

/* buttons and fields */
button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--accent); background: var(--accent);
  color: var(--accent-ink); padding: .45rem .95rem; border-radius: 4px; text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { filter: brightness(1.08); }
button.quiet, .btn.quiet { background: transparent; color: var(--accent); }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 4px; padding: .45rem .6rem; width: 100%;
}
textarea { min-height: 5rem; resize: vertical; }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .2rem; }
label.check { display: flex; gap: .5rem; align-items: center; color: var(--ink); }
label.check input { width: auto; }
.grid { display: grid; gap: .9rem 1rem; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); margin-bottom: 1rem; }
.grid .wide { grid-column: 1 / -1; }
.actions { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-top: 1rem; }
.error { border-left: 3px solid var(--danger); padding: .5rem .8rem; background: var(--surface); margin-bottom: 1rem; }

/* search bar */
.filters { display: grid; grid-template-columns: 1fr 13rem 9rem auto; gap: .6rem; margin-bottom: 1.25rem; align-items: end; }
@media (max-width: 40rem) { .filters { grid-template-columns: 1fr 1fr; } .filters .q { grid-column: 1 / -1; } }

/* the journal: date | what was tasted | score */
.journal { border-top: 1px solid var(--line); }
.entry {
  display: grid; grid-template-columns: 6.5rem 1fr 4rem; gap: 1rem;
  padding: 1rem 0; border-bottom: 1px solid var(--line);
}
.entry time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .9rem; padding-top: .2rem; }
.entry h3 { margin: 0 0 .15rem; }
.entry h3 a { color: var(--ink); text-decoration: none; }
.entry h3 a:hover { color: var(--accent); }
.entry .meta { margin: 0 0 .4rem; color: var(--muted); font-size: .9rem; }
.entry dl { margin: .4rem 0; display: grid; grid-template-columns: 4.5rem 1fr; gap: .1rem .75rem; font-size: .95rem; }
.entry dt { color: var(--muted); }
.entry dd { margin: 0; }
.entry .notes { margin: .4rem 0 0; white-space: pre-line; }
.entry .tools { margin-top: .5rem; display: flex; gap: 1rem; font-size: .85rem; }
.score {
  font-family: var(--serif); font-size: 2.1rem; line-height: 1; text-align: right;
  color: var(--brass); font-variant-numeric: lining-nums tabular-nums;
}
.score.none { color: var(--line); }
@media (max-width: 36rem) {
  .entry { grid-template-columns: 1fr 3.5rem; }
  .entry time { grid-column: 1 / -1; padding: 0; }
}

/* bottle list */
.bottle {
  display: grid; grid-template-columns: 1fr auto; gap: .25rem 1rem; padding: .85rem 0;
  border-bottom: 1px solid var(--line);
}
.bottles { border-top: 1px solid var(--line); }
.bottle h3 { margin: 0; }
.bottle h3 a { color: var(--ink); text-decoration: none; }
.bottle h3 a:hover { color: var(--accent); }
.bottle .meta { color: var(--muted); font-size: .9rem; grid-column: 1; }
.bottle .score { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-size: 1.7rem; }

/* bottle detail */
.detail { display: grid; grid-template-columns: 1fr; gap: 1.25rem; margin-bottom: 1rem; }
.detail.has-photo { grid-template-columns: 1fr 13rem; }
@media (max-width: 36rem) { .detail.has-photo { grid-template-columns: 1fr; } }
.detail img { width: 100%; border-radius: 4px; border: 1px solid var(--line); }
.facts { display: grid; grid-template-columns: 7rem 1fr; gap: .25rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 1.1rem 1.2rem; }
.narrow { max-width: 24rem; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .45rem .5rem .45rem 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; }
.sso { display: block; text-align: center; padding: .6rem 1rem; }
.divider { color: var(--muted); text-align: center; margin: 1rem 0; font-size: .9rem; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* bottle form: type subtypes and component rows */
td.subtype { padding-left: 1.5rem; color: var(--muted); }
fieldset.components, fieldset.photos { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.components legend, fieldset.photos legend { font-size: .9rem; color: var(--muted); margin-bottom: .2rem; padding: 0; }
fieldset.components legend .muted, fieldset.photos legend .muted { font-size: .85rem; margin-left: .35rem; }
.component { display: grid; grid-template-columns: 1fr 6rem; gap: .5rem; margin-bottom: .5rem; }

/* home: all bottles (main, with a find box) | recently added + recent tastings (side) */
.home { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: 2.5rem; align-items: start; }
.home h2 { margin-top: 0; }
.catalog h2 { font-size: 1.08rem; } /* 80% of the usual 1.35rem h2 */
.find input { font-size: .84rem; padding: .48rem .6rem; margin-bottom: 1.75rem; }
.none-found { margin: 0 0 1rem; }
.catalog .group { margin-bottom: 1.5rem; }
/* type headings: centered between rules so each group stands out while scanning */
.catalog .group h3 {
  display: flex; align-items: center; gap: .9rem; margin: 0 0 .1rem;
  font-family: var(--serif); font-size: 1.15rem; font-weight: 700; color: var(--accent); text-align: center;
}
.catalog .group h3::before, .catalog .group h3::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.catalog .bottle h4 { margin: 0; font-family: var(--serif); font-size: 1.05rem; }
.catalog .bottle h4 a { color: var(--ink); text-decoration: none; }
.catalog .bottle h4 a:hover { color: var(--accent); }
.recent h2 { font-size: 1.05rem; margin-bottom: .4rem; }
.recent h2 + * { margin-bottom: 1.75rem; }
.compact { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.compact li { padding: .35rem 0; border-bottom: 1px solid var(--line); line-height: 1.35; }
.compact a { color: var(--ink); text-decoration: none; display: block; }
.compact a:hover { color: var(--accent); }
.compact span { color: var(--muted); font-size: .8rem; }
@media (max-width: 48rem) { .home { grid-template-columns: 1fr; gap: 1.5rem; } }
fieldset.plain { border: 0; padding: 0; margin: .75rem 0 0; min-width: 0; }

/* photos: big first photo, the rest as thumbnails; edit form gallery */
.detail .photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; align-content: start; }
.detail .photos a:first-child { grid-column: 1 / -1; }
.detail .photos .thumb img { aspect-ratio: 1; object-fit: cover; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); gap: .75rem; margin-bottom: .75rem; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); display: block; }
.gallery figcaption { font-size: .85rem; color: var(--muted); margin-top: .25rem; }
.gallery figcaption .check { font-size: .85rem; margin: .15rem 0 0; }
fieldset.photos > .grid { margin-bottom: 0; }

/* inventory: one line per physical bottle */
.owned { list-style: none; margin: 0 0 .75rem; padding: 0; }
.owned-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .75rem; padding: .35rem 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.owned-row .tools { margin-left: auto; display: flex; gap: .9rem; font-size: .85rem; }
.status { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: .05rem .45rem; border-radius: 3px; border: 1px solid currentColor; }
.status.sealed { color: var(--brass); }
.status.open { color: var(--accent); }
.status.finished { color: var(--muted); }
.add-owned { margin: .5rem 0 1rem; }
.add-owned summary { cursor: pointer; color: var(--accent); }
.add-owned[open] summary { margin-bottom: .75rem; }
.shelves { color: var(--muted); }
.inv-item { padding: .5rem 0 .25rem; }
.inv-item h4 { margin: 0 0 .25rem; font-family: var(--serif); font-size: 1.05rem; }
.inv-item h4 a { color: var(--ink); text-decoration: none; }
.inv-item h4 a:hover { color: var(--accent); }
.own-line { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: center; }
.notice { border-left: 3px solid var(--brass); padding: .5rem .8rem; background: var(--surface); }
.bar a.who { text-decoration: none; }
.bar a.who:hover { color: var(--accent); }
.narrow-wide { max-width: 36rem; }

/* bottles page: All / My inventory tabs and the "in inventory" marker */
.tabs { display: flex; gap: 1.5rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs a { color: var(--muted); text-decoration: none; padding: .35rem 0; margin-bottom: -1px; border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .count { font-size: .8rem; color: var(--muted); font-weight: 400; margin-left: .2rem; }
.bottle h3 a.have { font-family: var(--sans); font-size: .72rem; font-weight: 600; vertical-align: middle; white-space: nowrap;
  color: var(--brass); border: 1px solid currentColor; border-radius: 3px; padding: .05rem .4rem; margin-left: .4rem; text-decoration: none; }
.bottle h3 a.have:hover { color: var(--accent); }
