:root {
  --bg: #120a0d;
  --bg-2: #1d0f14;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-2: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.1);
  --text: #f7eef1;
  --muted: #a9939b;
  --accent: #e4416b;
  --accent-2: #8e1032;
  --ok: #4ecb8c;
  --warn: #f0b23c;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior-y: none;
}

body {
  background:
    radial-gradient(1100px 620px at 85% -10%, rgba(228, 65, 107, 0.22), transparent 60%),
    radial-gradient(900px 500px at -10% 5%, rgba(142, 16, 50, 0.28), transparent 62%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 45%);
  background-attachment: fixed;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: #ff8098; font-size: 14px; margin: 4px 0 0; }

/* ─────────── Buttons & fields ─────────── */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, background .2s ease, opacity .2s;
}
.btn:active { transform: scale(.975); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; }
.btn.ghost { background: var(--surface); }
.btn.danger { color: #ff8098; border-color: rgba(255, 128, 152, .3); }
.btn.block { display: block; width: 100%; margin-top: 14px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.icon-btn {
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  width: 38px; height: 38px; border-radius: 12px; font-size: 18px; cursor: pointer;
}

.link { background: none; border: 0; color: var(--muted); font: inherit; padding: 8px 2px; cursor: pointer; }
.link.accent { color: var(--accent); font-weight: 700; }

.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea, textarea, .search {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .28);
  color: var(--text);
  font: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus, .search:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(228, 65, 107, .16);
}
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; margin: 12px 0; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* ─────────── Auth ─────────── */

.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 18px calc(24px + var(--safe-b)); }
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; padding: 26px 22px;
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
.brand { text-align: center; margin-bottom: 18px; }
.brand-mark { font-size: 44px; display: block; }
.brand h1 { margin: 6px 0 2px; font-size: 30px; letter-spacing: -.5px; }
.seg { display: flex; background: rgba(0, 0, 0, .3); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 8px; }
.seg-btn { flex: 1; border: 0; background: none; color: var(--muted); padding: 10px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; }
.seg-btn.active { background: var(--surface-2); color: var(--text); }

/* ─────────── App shell ─────────── */

.app { padding-bottom: calc(78px + var(--safe-b)); }
.page { min-height: 100dvh; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(12px + var(--safe-t)) 16px 10px;
  background: rgba(18, 10, 13, .82);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; }
.topbar h1 { margin: 0 0 8px; font-size: 26px; letter-spacing: -.4px; }
.search-wrap { margin-bottom: 8px; }

.chips { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chips.subtle { margin-top: 8px; align-items: center; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; }
.mini-select { background: var(--surface); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 7px 10px; font-size: 13px; font-weight: 600; }
.count { margin-left: auto; font-size: 13px; color: var(--muted); }

/* ─────────── Wine list ─────────── */

.list { padding: 12px 16px 20px; display: flex; flex-direction: column; gap: 10px; }

.card {
  display: grid; grid-template-columns: 58px 1fr auto; gap: 12px; align-items: center;
  padding: 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  cursor: pointer; transition: transform .12s ease, background .2s;
}
.card:active { transform: scale(.99); background: var(--surface-2); }
.thumb {
  width: 58px; height: 74px; border-radius: 10px; object-fit: cover;
  background: rgba(0, 0, 0, .35); display: grid; place-items: center; font-size: 24px; overflow: hidden;
}
.card-main { min-width: 0; }
.card-title { font-weight: 650; font-size: 15px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; display: flex; gap: 6px; flex-wrap: wrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; vertical-align: middle; margin-right: 5px; }
.c-red { background: #b3123f; } .c-white { background: #ecd98b; } .c-rose { background: #f2879f; }
.c-sparkling { background: #cfe6ff; } .c-sweet { background: #d9a13b; } .c-fortified { background: #7a3b1e; }
.c-orange { background: #e08a3c; } .c-none { background: #6b5a60; }

.score {
  min-width: 46px; text-align: center; padding: 7px 8px; border-radius: 12px;
  background: rgba(0, 0, 0, .3); border: 1px solid var(--line);
}
.score b { display: block; font-size: 17px; line-height: 1; }
.score span { font-size: 10px; color: var(--muted); }
.score.good { border-color: rgba(78, 203, 140, .5); color: #a7f0c9; }
.score.mid { border-color: rgba(240, 178, 60, .45); }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-size: 46px; margin: 0; }

/* ─────────── FAB + tabs ─────────── */

.fab {
  position: fixed; right: 18px; bottom: calc(84px + var(--safe-b));
  width: 58px; height: 58px; border-radius: 50%; border: 0; z-index: 30;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 30px; line-height: 1; cursor: pointer;
  box-shadow: 0 10px 28px rgba(228, 65, 107, .45);
}
.fab:active { transform: scale(.94); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 8px 8px calc(8px + var(--safe-b));
  background: rgba(18, 10, 13, .92); backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.tab { background: none; border: 0; color: var(--muted); font: inherit; font-size: 11px; font-weight: 600; padding: 6px 0; cursor: pointer; }
.tab span { display: block; font-size: 20px; margin-bottom: 1px; filter: grayscale(1) opacity(.7); }
.tab.active { color: var(--text); }
.tab.active span { filter: none; }

/* ─────────── Sheets ─────────── */

.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 50; backdrop-filter: blur(2px); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; top: 0; z-index: 60;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #1d1014, #120a0d 30%);
  animation: rise .24s cubic-bezier(.22, 1, .36, 1);
}
@keyframes rise { from { transform: translateY(3%); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + var(--safe-t)) 14px 10px;
  border-bottom: 1px solid var(--line); background: rgba(18, 10, 13, .8); backdrop-filter: blur(14px);
}
.sheet-head strong { font-size: 15px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 14px 16px calc(30px + var(--safe-b)); -webkit-overflow-scrolling: touch; }

/* ─────────── Lookup ─────────── */

.lookup { background: rgba(0, 0, 0, .22); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 12px 8px; margin-bottom: 14px; }
.lookup .field { margin-top: 0; }
.lookup-results { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 4px; max-height: 320px; overflow-y: auto; }
.lookup-item { display: grid; grid-template-columns: 42px 1fr auto; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; }
.lookup-item:active { background: var(--surface-2); }
.lookup-item img { width: 42px; height: 54px; object-fit: contain; border-radius: 6px; background: rgba(255, 255, 255, .05); }
.lookup-item .t { font-size: 13px; font-weight: 600; line-height: 1.25; }
.lookup-item .s { font-size: 11.5px; color: var(--muted); }
.lookup-item .p { font-size: 13px; font-weight: 700; white-space: nowrap; }

/* ─────────── Photo ─────────── */

.photo-row { display: flex; gap: 14px; align-items: center; margin-bottom: 6px; }
.photo-box {
  width: 96px; height: 124px; border-radius: 14px; flex: 0 0 auto;
  border: 1px dashed var(--line); background: rgba(0, 0, 0, .25);
  display: grid; place-items: center; text-align: center; font-size: 11px; color: var(--muted); overflow: hidden;
}
.photo-box img { width: 100%; height: 100%; object-fit: cover; }
.photo-actions { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.photo-actions .btn { text-align: center; }

/* ─────────── Rating ─────────── */

.rate-block { background: rgba(0, 0, 0, .22); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 16px 0; }
.rate-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 14px; }
.score-pill { background: linear-gradient(135deg, var(--accent), var(--accent-2)); padding: 4px 12px; border-radius: 999px; font-weight: 800; font-size: 15px; }
.rate-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: -4px; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 30px; }
.rate-block textarea { margin-top: 6px; }

/* ─────────── Detail ─────────── */

.hero { width: 100%; max-height: 46dvh; object-fit: contain; border-radius: var(--radius); background: rgba(0, 0, 0, .3); margin-bottom: 14px; }
.detail-title { font-size: 21px; font-weight: 700; line-height: 1.25; margin: 0 0 4px; }
.detail-sub { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.avg-row { display: flex; align-items: center; gap: 12px; margin: 14px 0; }
.avg-big { font-size: 34px; font-weight: 800; line-height: 1; }
.meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.meta div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; }
.meta dt { font-size: 11px; color: var(--muted); margin: 0 0 2px; }
.meta dd { margin: 0; font-size: 14px; font-weight: 600; word-break: break-word; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 20px 0 8px; font-weight: 700; }
.note { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 14px; white-space: pre-wrap; }
.review { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; margin-bottom: 8px; }
.review-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.review-head b { font-weight: 700; }
.review p { margin: 6px 0 0; font-size: 14px; color: #e6d7db; white-space: pre-wrap; }
.bg-info { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.bg-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; font-size: 13.5px; }
.bg-card b { display: block; margin-bottom: 3px; }
.bg-card a { color: var(--accent); }
.vendor-desc { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; margin-top: 12px; }
.vendor-desc summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.vendor-desc p { font-size: 13.5px; color: #ded0d4; white-space: pre-wrap; }
.tagrow { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tag { background: var(--surface-2); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: #ecdfe3; }

/* ─────────── Stats / account ─────────── */

.stats, .stack { padding: 16px 16px 30px; display: flex; flex-direction: column; gap: 14px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 10px; text-align: center; }
.kpi b { display: block; font-size: 22px; }
.kpi span { font-size: 11px; color: var(--muted); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.panel h3 { margin: 0 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.bar-row { display: grid; grid-template-columns: 92px 1fr 34px; gap: 8px; align-items: center; margin-bottom: 7px; font-size: 13px; }
.bar { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.rank { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.rank:last-child { border-bottom: 0; }

/* ─────────── Toast ─────────── */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(96px + var(--safe-b)); z-index: 90;
  background: rgba(30, 16, 21, .97); border: 1px solid var(--line);
  padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5); animation: rise .2s ease;
  max-width: 90vw; text-align: center;
}
.toast.bad { border-color: rgba(255, 128, 152, .5); color: #ffb3c3; }

/* ─────────── Language switch ─────────── */

.tab em { font-style: normal; display: block; }
.lang-seg { margin-bottom: 14px; }
.lang-seg .seg-btn { padding: 8px; font-size: 13px; }
.panel .lang-seg { margin: 0; }

@media (min-width: 720px) {
  .list, .stats, .stack, .sheet-body { max-width: 720px; margin: 0 auto; }
  .topbar > * { max-width: 720px; margin-left: auto; margin-right: auto; }
  .meta { grid-template-columns: repeat(3, 1fr); }
}
