/* Invintory: wine fridges, phone-first. Same bones as sullivan, cellar palette. */
:root {
  color-scheme: light;
  --bg: #f7f3ef;
  --surface: #fffdfb;
  --surface-2: #efe8e1;
  --text: #1c1512;
  --text-2: #4f4540;
  --text-3: #7a6e67;
  --line: #e6ddd4;
  --accent: #7b2335;
  --accent-ink: #6b1d2a;
  --danger: #b3261e;
  --red: #7b2335; --white: #d9c27a; --rose: #e59aa4; --sparkling: #c9b45b;
  --orange: #d9822b; --dessert: #b5762f; --fortified: #5a2a1d; --unknown: #b9ada4;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(40, 20, 10, .05), 0 6px 20px -12px rgba(40, 20, 10, .3);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Fraunces", Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #16110f;
    --surface: #211a17;
    --surface-2: #2c2420;
    --text: #f3ece6;
    --text-2: #cfc3ba;
    --text-3: #a3958b;
    --line: #382e29;
    --accent: #d36b80;
    --accent-ink: #e894a4;
    --danger: #f2827a;
    --red: #b03a52;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--sans); }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.2; margin: 0 0 .4rem; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.15rem; }
a { color: var(--accent-ink); }
.muted { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: calc(.7rem + env(safe-area-inset-top)) 1.1rem .7rem; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--serif); font-weight: 700; font-size: 1.25rem; color: var(--text); text-decoration: none; }
.brand-mark { color: var(--accent); }
.tabs { display: flex; gap: .2rem; background: var(--surface-2); border-radius: 999px; padding: .2rem; }
.tabs a { color: var(--text-2); text-decoration: none; font-size: .9rem; font-weight: 600; padding: .35rem .75rem; border-radius: 999px; }
.tabs a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
@media (max-width: 480px) { .brand { font-size: 0; } .brand-mark { font-size: 1.3rem; } }

.page { max-width: 1100px; margin: 0 auto; padding: 1.2rem 1rem 6rem; }
.page-head { margin: .3rem 0 1rem; }
.footer { text-align: center; padding: 0 0 2rem; }
.footer form { display: inline; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--text-3); text-decoration: underline; cursor: pointer; }
.flash { max-width: 1100px; margin: 1rem auto 0; padding: .7rem 1rem; border-radius: 12px; background: var(--surface); border-left: 4px solid var(--accent); width: calc(100% - 2rem); }
.flash-alert { border-left-color: var(--danger); }
.errors { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); padding: .6rem .8rem; border-radius: 10px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.stack { display: grid; gap: .9rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: .7rem; }
label { display: block; font-size: .85rem; font-weight: 600; color: var(--text-2); margin-bottom: .25rem; }
input[type=text], input[type=number], input[type=password], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: .6rem .7rem;
}
.btn { display: inline-flex; justify-content: center; align-items: center; gap: .4rem; font: 600 1rem var(--sans); padding: .75rem 1.1rem;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); text-decoration: none; cursor: pointer; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }

.fab {
  position: fixed; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 6; display: inline-flex; align-items: center; gap: .35rem;
  background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; padding: .85rem 1.2rem; border-radius: 999px;
  box-shadow: 0 8px 24px -8px rgba(80, 20, 30, .55);
}

/* Fridge overview */
.fridges { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.fridge-card { color: inherit; text-decoration: none; }
.big { font: 700 2.2rem/1 var(--serif); margin: .2rem 0 .6rem; }
.big .muted { font: 500 1rem var(--sans); }
.meter { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: .5rem; }
.meter span { display: block; height: 100%; background: var(--accent); }
.pending-card { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }

/* Shelves and tiles */
.shelf { margin-bottom: 1.1rem; }
.shelf-label { font: 600 .8rem var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin: 0 0 .4rem; }
.shelf-row { display: grid; grid-template-columns: repeat(var(--slots), minmax(0, 1fr)); gap: .45rem; }
@media (max-width: 640px) { .shelf-row { grid-template-columns: repeat(min(var(--slots), 4), minmax(0, 1fr)); } }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; }
.tile {
  position: relative; display: flex; flex-direction: column; min-height: 118px; border-radius: 12px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); color: inherit; text-decoration: none; font-size: .78rem; line-height: 1.25;
}
.tile-img { width: 100%; height: 76px; object-fit: cover; display: block; }
.tile-cap { display: block; height: 10px; background: var(--unknown); }
.tile-red .tile-cap { background: var(--red); } .tile-white .tile-cap { background: var(--white); }
.tile-rose .tile-cap { background: var(--rose); } .tile-sparkling .tile-cap { background: var(--sparkling); }
.tile-orange .tile-cap { background: var(--orange); } .tile-dessert .tile-cap { background: var(--dessert); }
.tile-fortified .tile-cap { background: var(--fortified); }
.tile-text { padding: .4rem .5rem .5rem; display: grid; gap: .15rem; }
.tile-text strong { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tile-pending { border-style: dashed; border-color: var(--accent); }
.tile-empty { align-items: center; justify-content: center; border-style: dashed; background: transparent; color: var(--text-3); }
.tile-empty .slot-num { position: absolute; top: .3rem; left: .45rem; font-size: .7rem; }
.tile-empty .plus { font-size: 1.3rem; opacity: .5; }

/* Add bottle */
.form-card { max-width: 560px; margin: 0 auto 1rem; }
.camera { display: grid; place-items: center; min-height: 260px; border: 2px dashed var(--line); border-radius: var(--radius);
  background: var(--surface-2); cursor: pointer; overflow: hidden; margin: 0; }
.camera img { width: 100%; max-height: 420px; object-fit: contain; }
.camera-prompt { display: grid; gap: .2rem; justify-items: center; text-align: center; padding: 1rem; font-weight: 500; }
.camera-icon { font-size: 2.4rem; }

/* Bottle page */
.bottle-hero { display: grid; grid-template-columns: minmax(0, 200px) 1fr; gap: 1rem; align-items: start; margin-bottom: 1rem; }
@media (max-width: 520px) { .bottle-hero { grid-template-columns: 1fr; } }
.bottle-photo { width: 100%; border-radius: 12px; display: block; }
.pill { display: inline-block; font-size: .78rem; font-weight: 600; padding: .2rem .6rem; border-radius: 999px; background: var(--surface-2); margin: 0 0 .5rem; }
.pill-pending { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-ink); }
.pill-past-window { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.pill-drink-now { background: #f6e3b5; color: #6d4b00; }
.pill-ready { background: #d8ecd9; color: #1f5a2c; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem 1rem; margin: 0 0 1rem; }
.facts dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.facts dd { margin: 0; font-weight: 500; }
.profile { display: grid; gap: .3rem; max-width: 320px; margin-bottom: 1rem; }
.profile-row { display: flex; justify-content: space-between; font-size: .9rem; }
.dots { display: inline-flex; gap: 4px; align-items: center; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); }
.dots i.on { background: var(--accent); border-color: var(--accent); }
.reasons { display: flex; flex-wrap: wrap; gap: .4rem; }
.reason { display: inline-flex; align-items: center; gap: .3rem; margin: 0; padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 999px; font-weight: 500; }

/* Lists */
.search { margin: .6rem 0 .3rem; }
.list { display: grid; gap: .35rem; }
.row { display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: inherit; text-decoration: none; }
.row-main { flex: 1; min-width: 0; display: grid; }
.row-main strong, .row-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { font-size: .85rem; white-space: nowrap; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--unknown); }
.dot-red { background: var(--red); } .dot-white { background: var(--white); } .dot-rose { background: var(--rose); }
.dot-sparkling { background: var(--sparkling); } .dot-orange { background: var(--orange); } .dot-dessert { background: var(--dessert); }
.dot-fortified { background: var(--fortified); }

/* Sign in */
.signin .page { display: grid; place-items: center; min-height: 80vh; }
.signin-card { width: min(380px, 100%); text-align: center; }
.signin-mark { font-size: 2rem; color: var(--accent); }
