:root {
  color-scheme: light;
  --ink: #201b16;
  --muted: #71685e;
  --paper: #fff9ef;
  --panel: #ffffff;
  --line: #e2d7c7;
  --accent: #8a4f20;
  --accent-dark: #5b3418;
  --coast: #2f6f73;
  --peat: #59614f;
  --sweet: #8d4d61;
  --bad: #8f2d2d;
  --good: #2f6b4f;
  --shadow: 0 12px 28px rgba(45, 35, 22, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.35;
}

button, input, textarea { font: inherit; }

.app-shell {
  width: min(720px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  padding: 14px 12px 92px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: -14px -12px 12px;
  padding: 12px 12px 10px;
  background: rgba(255, 249, 239, .94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.05;
  letter-spacing: 0;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .92rem;
}

.search {
  width: 100%;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: white;
  color: var(--ink);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.tab {
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  border-radius: 8px;
  min-height: 38px;
  font-weight: 750;
}

.tab.active {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: white;
}

.profile {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.profile-card, .rec-card, .bottle-card, .detail-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.profile-card { padding: 12px; }

.profile-title {
  margin: 0 0 6px;
  font-size: 1rem;
}

.profile-tags, .tags, .actions, .reason-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  background: #fff7ea;
  color: var(--ink);
  font-size: .78rem;
  font-weight: 750;
}

.chip.good {
  background: #e9f5ef;
  color: var(--good);
  border-color: #b9d8c8;
}

.chip.bad {
  background: #fff0ed;
  color: var(--bad);
  border-color: #e5b5ad;
}

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

.bottle-card {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 10px;
  padding: 10px;
  text-align: left;
  border-color: var(--line);
  color: inherit;
}

.bottle-card:active { transform: scale(.995); }

.media {
  height: 112px;
  border-radius: 7px;
  background: linear-gradient(180deg, #f6efe4, #eadcc8);
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
}

.media img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.image-cue {
  padding: 8px;
  text-align: center;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 750;
}

.card-body {
  min-width: 0;
  display: grid;
  gap: 5px;
  align-content: start;
}

.name-row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  justify-content: space-between;
}

.bottle-name {
  margin: 0;
  font-size: 1rem;
  line-height: 1.13;
}

.status {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: .7rem;
  font-weight: 850;
  background: #f1e5d2;
  color: var(--accent-dark);
  white-space: nowrap;
}

.status.liked { background: #e4f4ec; color: var(--good); }
.status.disliked { background: #ffe9e5; color: var(--bad); }

.meta {
  color: var(--muted);
  font-size: .84rem;
}

.tag {
  color: white;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: .72rem;
  font-weight: 750;
  background: var(--accent);
}

.tag.coastal, .tag.briny, .tag.island { background: var(--coast); }
.tag.peat, .tag.smoke, .tag.smoky, .tag.charred { background: var(--peat); }
.tag.sweet, .tag.fruity, .tag.honey, .tag.vanilla { background: var(--sweet); }

.score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 30px;
  border-radius: 999px;
  background: var(--accent-dark);
  color: white;
  font-size: .82rem;
  font-weight: 850;
}

.rec-card {
  padding: 11px;
  display: grid;
  gap: 8px;
}

.rec-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rec-card h2 {
  margin: 0;
  font-size: 1.02rem;
}

.reason {
  margin: 0;
  color: var(--muted);
  font-size: .9rem;
}

.empty {
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.56);
}

.detail {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(32, 27, 22, .42);
  display: none;
  align-items: end;
}

.detail.open { display: flex; }

.detail-card {
  width: min(720px, 100%);
  max-height: 92vh;
  overflow: auto;
  margin: 0 auto;
  border-radius: 14px 14px 0 0;
  padding: 12px;
}

.detail-head {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  align-items: start;
}

.detail h2 {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.08;
}

.detail p { margin: 0; }

.detail-section {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.actions { margin-top: 12px; }

.action {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 9px 10px;
  font-weight: 800;
}

.action.good { background: #e7f5ed; color: var(--good); border-color: #b8dcc9; }
.action.bad { background: #ffebe7; color: var(--bad); border-color: #ebb5ad; }

textarea {
  width: 100%;
  min-height: 68px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
}

.reason-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  padding: 6px 9px;
  font-size: .82rem;
  font-weight: 750;
}

.reason-chip.active {
  background: var(--bad);
  color: white;
  border-color: var(--bad);
}

.close {
  position: sticky;
  top: 0;
  float: right;
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  width: 34px;
  height: 34px;
  font-weight: 900;
}

.nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(720px, 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px 12px max(8px, env(safe-area-inset-bottom));
  background: rgba(255, 249, 239, .96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.nav button {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  font-weight: 850;
}

.nav button.active {
  background: var(--accent-dark);
  color: white;
  border-color: var(--accent-dark);
}

@media (min-width: 680px) {
  .bottle-card { grid-template-columns: 96px 1fr; }
}
