/* Cellar — wine-app design system
   Dark, warm, deferential to your bottles. Mobile-first. */

:root {
  --bg:           #14090c;
  --bg-elev:      #1f1216;
  --bg-card:      #281519;
  --bg-input:     #1a0d10;
  --border:       #3a1e24;
  --border-soft:  #2a161a;
  --text:         #f5ece2;
  --text-mute:    #b9a59a;
  --text-dim:     #8b756a;
  --accent:       #b03a4a;   /* bordeaux */
  --accent-soft:  #722f37;
  --accent-hot:   #e0506a;
  --gold:         #c89b3a;
  --green:        #6aa66a;
  --amber:        #d18a3a;
  --red-warn:     #c14a4a;
  --shadow:       0 6px 18px rgba(0,0,0,0.4);
  --radius:       14px;
  --radius-sm:    10px;
  --tap:          44px;     /* iOS hit target */
  --safe-bottom:  env(safe-area-inset-bottom, 0);
  --safe-top:     env(safe-area-inset-top, 0);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

h1,h2,h3,h4 { font-family: 'New York', 'Times New Roman', Georgia, serif; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 .4em; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
p  { margin: 0 0 .8em; }
small, .muted { color: var(--text-mute); font-size: 13px; }
.dim   { color: var(--text-dim); }
.gold  { color: var(--gold); }
.green { color: var(--green); }
.amber { color: var(--amber); }
.warn  { color: var(--red-warn); }

/* App layout: top bar, scrolling content, bottom nav */
#app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  max-width: 540px;
  margin: 0 auto;
  background: var(--bg);
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 18px 12px;
  background: linear-gradient(180deg, #1a0d10 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 10;
}
.topbar .title { font-family: 'New York', Georgia, serif; font-size: 22px; font-weight: 600; }
.topbar .title small { display:block; color: var(--text-dim); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; font-family: -apple-system, sans-serif; }
.topbar .icon-btn { background:none; border:none; color: var(--text); width: var(--tap); height: var(--tap); display:flex; align-items:center; justify-content:center; cursor:pointer; }

.content { overflow-y: auto; padding: 16px 18px 32px; -webkit-overflow-scrolling: touch; }

/* Bottom nav */
.tabbar {
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--bg-elev);
  border-top: 1px solid var(--border-soft);
  padding-bottom: var(--safe-bottom);
}
.tabbar button {
  background: none; border: none; color: var(--text-dim);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px; cursor: pointer; font-size: 11px;
}
.tabbar button.active { color: var(--accent-hot); }
.tabbar button .icon { font-size: 20px; line-height: 1; }
.tabbar .add-btn {
  background: var(--accent); color: white; width: 48px; height: 48px;
  border-radius: 50%; align-self: center; justify-self: center;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; margin: -6px 0 4px; box-shadow: var(--shadow);
}
.tabbar .add-btn-wrap { display:flex; flex-direction:column; align-items:center; }

/* Section header */
.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 22px 0 10px;
}
.section-title h2 { margin: 0; }
.section-title .count { color: var(--text-dim); font-size: 13px; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.card.warn  { border-color: var(--red-warn); }
.card.ready { border-color: var(--accent-soft); }

/* Bottle row */
.bottle-row {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 12px;
  align-items: center; padding: 12px;
  background: var(--bg-card); border-radius: var(--radius);
  margin-bottom: 8px; border: 1px solid var(--border-soft);
  cursor: pointer; transition: transform .08s ease;
}
.bottle-row:active { transform: scale(0.98); }
.bottle-thumb {
  width: 48px; height: 48px; border-radius: 8px;
  background: linear-gradient(135deg, #2a161a, #3a1e24);
  display: flex; align-items: center; justify-content: center;
  font-family: 'New York', Georgia, serif; font-size: 18px; color: var(--gold);
  overflow: hidden;
}
.bottle-thumb img { width: 100%; height: 100%; object-fit: cover; }
.bottle-info .name { font-weight: 600; font-size: 15px; line-height: 1.2; }
.bottle-info .meta { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.bottle-info .meta .sep { margin: 0 6px; opacity: 0.5; }
.bottle-qty {
  font-family: 'New York', serif; font-size: 18px; color: var(--gold);
  min-width: 24px; text-align: center;
}

/* Status badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
}
.badge.now      { background: rgba(106,166,106,0.15); color: var(--green); }
.badge.cellar   { background: rgba(200,155,58,0.15);  color: var(--gold); }
.badge.past     { background: rgba(193,74,74,0.18);   color: var(--red-warn); }

/* Sort/filter chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; margin: 0 -18px; padding-left: 18px; padding-right: 18px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  background: var(--bg-input); color: var(--text-mute); border: 1px solid var(--border-soft);
  padding: 7px 14px; border-radius: 999px; font-size: 13px; white-space: nowrap;
  cursor: pointer; flex-shrink: 0;
}
.chip.active { background: var(--accent); color: white; border-color: var(--accent); }

/* Search */
.search {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border-soft);
  color: var(--text); padding: 11px 14px; border-radius: var(--radius);
  font-size: 15px; margin-bottom: 10px;
}
.search:focus { outline: none; border-color: var(--accent); }

/* Forms */
.field { margin-bottom: 14px; }
.field label { display: block; color: var(--text-mute); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border-soft);
  color: var(--text); padding: 11px 12px; border-radius: var(--radius-sm); font-size: 16px;
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field textarea { min-height: 70px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: white; border: none;
  padding: 13px 18px; border-radius: var(--radius); font-size: 15px; font-weight: 600;
  cursor: pointer; min-height: var(--tap);
}
.btn.full { width: 100%; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: var(--red-warn); }
.btn.gold { background: var(--gold); color: #14090c; }

/* Add-bottle entry buttons */
.entry-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.entry-grid .entry {
  background: var(--bg-card); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 18px 8px; text-align: center; cursor: pointer;
}
.entry .icon { font-size: 26px; }
.entry .label { font-size: 12px; color: var(--text-mute); margin-top: 6px; }

/* Auth screen */
.auth-wrap { padding: 40px 24px; max-width: 360px; margin: 0 auto; }
.auth-wrap h1 { text-align: center; }
.auth-wrap .tagline { text-align: center; color: var(--text-dim); margin-bottom: 32px; }

/* Bottle detail */
.detail-hero {
  position: relative;
  margin: -16px -18px 16px; padding: 28px 18px 22px;
  background: linear-gradient(180deg, #2a161a 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border-soft);
}
.detail-hero .vintage { font-family: 'New York', Georgia, serif; font-size: 44px; color: var(--gold); line-height: 1; }
.detail-hero .producer { font-size: 13px; color: var(--text-mute); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 8px; }
.detail-hero .wine-name { font-family: 'New York', serif; font-size: 22px; margin-top: 2px; }
.detail-hero .region { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

.fact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border-soft); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.fact { background: var(--bg-card); padding: 12px 14px; }
.fact .k { font-size: 11px; color: var(--text-dim); letter-spacing: 0.08em; text-transform: uppercase; }
.fact .v { font-size: 15px; color: var(--text); margin-top: 3px; font-weight: 500; }

.label-photo { width: 100%; border-radius: var(--radius); margin-bottom: 16px; }

/* Drink-now hero card */
.now-hero {
  background: linear-gradient(135deg, var(--accent-soft), var(--accent));
  color: white; border-radius: var(--radius); padding: 18px;
  margin-bottom: 16px; box-shadow: var(--shadow);
}
.now-hero h2 { color: white; margin: 0 0 6px; }
.now-hero p { margin: 0; opacity: 0.9; font-size: 14px; }

/* Toast */
.toast {
  position: fixed; bottom: calc(80px + var(--safe-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--bg-elev); color: var(--text); padding: 10px 16px;
  border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border);
  z-index: 100; max-width: 90%; font-size: 14px;
}
.toast.error { border-color: var(--red-warn); }

/* Loading spinner */
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--text-dim); border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty { text-align: center; padding: 48px 20px; color: var(--text-dim); }
.empty h3 { color: var(--text-mute); }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--bg-elev); width: 100%; max-width: 540px; border-radius: var(--radius) var(--radius) 0 0; padding: 18px; max-height: 90dvh; overflow-y: auto; }
.modal h3 { margin-top: 0; }

/* Barcode scanner viewport */
#scanner-video { width: 100%; max-height: 380px; border-radius: var(--radius); background: black; }

/* Drink-window chip on row */
.window-chip { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.window-chip.now { background: rgba(106,166,106,0.18); color: var(--green); }
.window-chip.cellar { background: rgba(200,155,58,0.15); color: var(--gold); }
.window-chip.past { background: rgba(193,74,74,0.18); color: var(--red-warn); }

/* Utility */
.row { display: flex; align-items: center; gap: 8px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.mt-16 { margin-top: 16px; } .mb-16 { margin-bottom: 16px; }
.center { text-align: center; }
.hidden { display: none !important; }