/* Wine Hub — the cellar.
   Mistral Offshore frame, wine-ledger interior: the navy sidebar and the
   offshore-blue interactive colour are the brand anchor, and everything inside
   the content area is warm — cream ground, a display serif for wine names,
   gold for ratings, burgundy for wine itself. */

:root {
  /* Brand — unchanged, this is still a Mistral Offshore property */
  --primary-navy:  #002B49;
  --offshore-blue: #005596;
  --mistral-teal:  #007A33;

  /* Cellar palette */
  --burgundy:  #7C2D3A;
  --burgundy-deep: #5C1A2B;
  --gold:      #B08850;
  --gold-soft: #D4B378;

  /* Warm neutrals replace the cold slate greys */
  --bg:           #F7F3EC;
  --surface:      #FFFDFA;
  --surface-alt:  #FBF7F0;
  --border:       #E9E1D4;
  --border-solid: #D6CAB6;
  --text-primary: #2C2621;
  --text-muted:   #8A7F70;

  --ok:    #4B7F52;
  --warn:  #B07A1E;
  --alert: #A33028;

  /* Wine type identity — warmer, still instantly separable */
  --type-red:       #7C2D3A;
  --type-white:     #C9A227;
  --type-rose:      #D98C9E;
  --type-sparkling: #4E9DB5;
  --type-dessert:   #9A6B2F;

  --sidebar-w: 264px;
  --radius: 4px;
  --serif: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px; line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.mono, .num {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

/* Cormorant defaults to old-style figures, which drop 3/4/7/9 below the
   baseline. Lovely in running prose, but in a headline figure like "972" the
   2 reads as a rendering fault rather than a choice. Force lining figures
   everywhere the serif carries a number. */
.stat .value, .view-head h2, .brand h1, .intro,
.window .yrs, .rate .readout, .card-name, .ledger-name .n, .modal-head h3 {
  font-variant-numeric: lining-nums;
  font-feature-settings: "lnum" 1;
}

/* ---------- shell ------------------------------------------------------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--primary-navy); color: #fff;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}

.brand { padding: 22px 22px 18px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-mark { height: 26px; width: auto; display: block; margin-bottom: 16px; opacity: .95; }
.brand h1 {
  margin: 0; font-family: var(--serif); font-size: 27px; font-weight: 600;
  letter-spacing: .01em; line-height: 1.1;
}
.brand p { margin: 3px 0 0; font-size: 11.5px; color: rgba(255,255,255,.52); letter-spacing: .02em; }

.nav { padding: 14px 0; flex: 1; }
.nav button {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 10px 22px;
  background: none; border: 0; border-left: 2px solid transparent;
  color: rgba(255,255,255,.70); font: inherit; font-size: 14px;
  text-align: left; cursor: pointer;
}
.nav button:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav button[aria-current="true"] {
  background: rgba(255,255,255,.08); color: #fff;
  border-left-color: var(--gold); font-weight: 500;
}
.nav .count { font-size: 11px; color: rgba(255,255,255,.42); }

.sidebar-foot { padding: 14px 22px; border-top: 1px solid rgba(255,255,255,.12); font-size: 11px; color: rgba(255,255,255,.5); line-height: 1.45; }
.sidebar-foot .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.sidebar-foot .dot.ok   { background: #5FBF6B; box-shadow: 0 0 0 3px rgba(95,191,107,.18); }
.sidebar-foot .dot.warn { background: #E0A72E; box-shadow: 0 0 0 3px rgba(224,167,46,.18); }

.main { flex: 1; min-width: 0; padding: 30px 34px 72px; }

.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.view-head h2 { margin: 0; font-family: var(--serif); font-size: 34px; font-weight: 600; line-height: 1; letter-spacing: .005em; }
.view-head .sub { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; }

/* ---------- stats ------------------------------------------------------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 1px; margin-bottom: 26px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.stat { background: var(--surface); padding: 16px 18px 15px; min-width: 0; }
.stat .label { font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); }
.stat .value { font-family: var(--serif); font-size: 38px; font-weight: 600; margin-top: 4px; line-height: 1; }
.stat .value .unit { font-size: 17px; color: var(--text-muted); font-weight: 500; margin-left: 1px; }
.stat .foot { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* ---------- warnings ---------------------------------------------------- */

.warnings { background: var(--surface); border: 1px solid var(--border); border-left: 2px solid var(--gold); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 26px; }
.warnings h3 { margin: 0 0 12px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); }
.warnings ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.warnings li { display: flex; align-items: baseline; gap: 10px; font-size: 13px; flex-wrap: wrap; }
.warnings .where { font-size: 11.5px; color: var(--text-muted); }
.warnings button { background: none; border: 0; padding: 0; font: inherit; font-family: var(--serif); font-size: 17px; color: var(--burgundy); cursor: pointer; text-align: left; }
.warnings button:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ---------- controls ---------------------------------------------------- */

.controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--surface); border: 1px solid var(--border); border-radius: 100px;
  padding: 6px 13px; font: inherit; font-size: 13px; color: var(--text-primary);
  cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
}
.chip:hover { border-color: var(--border-solid); }
.chip[aria-pressed="true"] { background: var(--primary-navy); border-color: var(--primary-navy); color: #fff; }
.chip[aria-pressed="true"] .chip-n { color: rgba(255,255,255,.6); }
.chip-n { font-size: 11px; color: var(--text-muted); }

input[type="text"], input[type="search"], input[type="number"], input[type="date"], select, textarea {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 11px; font: inherit; font-size: 14px; color: var(--text-primary); min-width: 0;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: none; border-color: var(--offshore-blue); box-shadow: 0 0 0 3px rgba(0,85,150,.14);
}
.search { flex: 1 1 260px; min-width: 0; }

.btn { background: var(--offshore-blue); border: 1px solid var(--offshore-blue); color: #fff; border-radius: var(--radius); padding: 9px 16px; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; }
.btn:hover { background: #004a83; }
.btn.secondary { background: transparent; border-color: var(--border-solid); color: var(--text-primary); }
.btn.secondary:hover { border-color: var(--offshore-blue); color: var(--offshore-blue); }
.btn.danger { background: transparent; border-color: var(--border-solid); color: var(--alert); }
.btn.danger:hover { border-color: var(--alert); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- wine cards -------------------------------------------------- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 17px 19px 15px; cursor: pointer; text-align: left; font: inherit; color: inherit;
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
  transition: border-color .12s, transform .12s;
}
.card:hover { border-color: var(--border-solid); transform: translateY(-1px); }
.card.consumed { background: var(--surface-alt); }
.card.consumed .card-name { color: #6E655A; }
.card.flawed { border-style: dashed; }
.card.flawed .card-name { text-decoration: line-through; }

.card-top { display: flex; align-items: center; gap: 9px; min-width: 0; }
.type-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }
.type-red { background: var(--type-red); } .type-white { background: var(--type-white); }
.type-rose { background: var(--type-rose); } .type-sparkling { background: var(--type-sparkling); }
.type-dessert { background: var(--type-dessert); }

.loc { font-size: 10px; font-weight: 500; letter-spacing: .09em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; }
.card-name { font-family: var(--serif); font-size: 21px; font-weight: 600; line-height: 1.15; min-width: 0; overflow-wrap: anywhere; }
.card-producer { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.card-meta { font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 9px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.price { font-size: 13px; font-weight: 500; color: var(--text-muted); }

.tags { display: flex; gap: 5px; flex-wrap: wrap; }
.tag { font-size: 11px; color: var(--text-muted); background: var(--surface-alt); border: 1px solid var(--border); border-radius: 100px; padding: 1px 8px; }

.pill { font-size: 9.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; border-radius: 100px; padding: 3px 9px; white-space: nowrap; }
.pill.past_peak        { background: rgba(163,48,40,.10);  color: var(--alert); }
.pill.drink_now        { background: rgba(176,122,30,.13); color: var(--warn); }
.pill.peak             { background: rgba(75,127,82,.12);  color: var(--ok); }
.pill.still_developing { background: rgba(0,85,150,.08);   color: var(--offshore-blue); }
.pill.too_young        { background: var(--surface-alt);   color: var(--text-muted); }

.rating { display: inline-flex; align-items: baseline; gap: 5px; font-size: 13px; }
.rating .stars { color: var(--gold); letter-spacing: 1.5px; font-size: 12px; }
.rating .n { font-weight: 600; }
.rating.community { color: var(--text-muted); }
.rating.community .stars { color: var(--border-solid); }

.empty { background: var(--surface); border: 1px dashed var(--border-solid); border-radius: var(--radius); padding: 40px 28px; text-align: center; color: var(--text-muted); line-height: 1.6; }
.empty strong { display: block; font-family: var(--serif); font-size: 22px; color: var(--text-primary); font-weight: 600; margin-bottom: 8px; }

/* ---------- quick rate -------------------------------------------------- */

.ledger { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ledger-row { display: grid; grid-template-columns: 8px minmax(0,1fr) auto; align-items: center; gap: 13px; padding: 11px 16px; border-bottom: 1px solid var(--border); }
.ledger-row:last-child { border-bottom: 0; }
.ledger-row:hover { background: var(--surface-alt); }
.ledger-name { min-width: 0; }
.ledger-name .n { font-family: var(--serif); font-size: 17px; font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ledger-name .m { font-size: 11px; color: var(--text-muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quickstars { display: inline-flex; gap: 2px; }
.quickstars button { background: none; border: 0; padding: 2px; font-size: 18px; line-height: 1; cursor: pointer; color: var(--border-solid); }
.quickstars button.on, .quickstars button:hover { color: var(--gold); }
.ledger-row .clear { background: none; border: 0; font: inherit; font-size: 12px; color: var(--text-muted); cursor: pointer; padding: 2px 5px; }
.ledger-row .clear:hover { color: var(--alert); }

/* ---------- profile ----------------------------------------------------- */

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; }
.panel h3 { margin: 0 0 14px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); }
.intro { font-family: var(--serif); font-size: 26px; line-height: 1.4; margin: 0; font-weight: 500; }
.intro em { font-style: normal; font-weight: 600; color: var(--burgundy); }

.bars { display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: minmax(92px, 148px) minmax(0,1fr) 32px; align-items: center; gap: 12px; }
.bar-row .k { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 2px; height: 15px; min-width: 0; }
.bar-fill { background: linear-gradient(90deg, var(--burgundy-deep), var(--burgundy)); height: 100%; min-width: 2px; }
.bar-row .v { font-size: 12px; color: var(--text-muted); text-align: right; }

/* ---------- shelf map: an actual cabinet -------------------------------- */

.fridges { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }

.fridge { min-width: 0; }
.fridge-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.fridge-head h3 { margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 600; }
.fridge-head .cap { font-size: 11px; color: var(--text-muted); }

/* The cabinet: a cool metal-and-glass box deliberately contrasting the warm
   page, so it reads as an appliance sitting in the room rather than a panel. */
.cabinet {
  background: linear-gradient(180deg, #2B3540 0%, #222B34 100%);
  border: 1px solid #1A222A; border-radius: 7px;
  padding: 13px; box-shadow: inset 0 1px 0 rgba(255,255,255,.07);
  min-width: 0;
}
.shelf { min-width: 0; }
.shelf-label { font-size: 9.5px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.35); margin-bottom: 3px; display: flex; justify-content: space-between; gap: 8px; }
.shelf-label .n { color: rgba(255,255,255,.28); }

/* Bottles stand ON the rail: flex-end alignment plus a rail drawn under them. */
.bottles { display: flex; gap: 4px; flex-wrap: wrap; align-items: flex-end; min-height: 68px; padding: 0 2px; }
.rail {
  height: 4px; border-radius: 2px; margin: 0 0 15px;
  background: linear-gradient(180deg, #6E7C8A 0%, #47525C 55%, #333C45 100%);
  box-shadow: 0 2px 5px rgba(0,0,0,.38);
}
.shelf:last-child .rail { margin-bottom: 2px; }

.bottle { background: none; border: 0; padding: 0; cursor: pointer; line-height: 0; flex: 0 0 auto; position: relative; }
.bottle svg { display: block; filter: drop-shadow(0 2px 3px rgba(0,0,0,.35)); transition: transform .12s; }
.bottle:hover svg { transform: translateY(-4px); }
.bottle:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 3px; }
/* Urgency reads as a band around the neck — a merchant's tag, not a CSS ring. */
.bottle .flag { display: none; }
.bottle.urgent .flag, .bottle.over .flag { display: block; }

.shelf .none { font-size: 11px; color: rgba(255,255,255,.3); font-style: italic; height: 68px; display: flex; align-items: flex-end; padding-bottom: 6px; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-muted); margin-top: 20px; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 9px; height: 9px; border-radius: 50%; }

/* ---------- modal ------------------------------------------------------- */

.backdrop { position: fixed; inset: 0; background: rgba(44,38,33,.45); display: flex; align-items: flex-start; justify-content: center; padding: 28px 16px; overflow-y: auto; z-index: 50; }
.modal { background: var(--surface); border: 1px solid var(--border-solid); border-radius: var(--radius); width: 100%; max-width: 580px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 16px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-family: var(--serif); font-size: 27px; font-weight: 600; line-height: 1.15; }
.modal-head .m { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.modal-head .x { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--text-muted); cursor: pointer; padding: 0 4px; }
.modal-body { padding: 18px 22px; display: grid; gap: 17px; }
.modal-foot { display: flex; gap: 8px; flex-wrap: wrap; padding: 16px 22px; border-top: 1px solid var(--border); background: var(--surface-alt); }
.modal-foot .spacer { flex: 1; }

.field { display: grid; gap: 7px; min-width: 0; }
.field > label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); }
.field .hint { font-size: 11.5px; color: var(--text-muted); }
.row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 13px; }

.rate { display: flex; align-items: center; gap: 13px; flex-wrap: wrap; }
.rate input[type="range"] { flex: 1 1 180px; min-width: 0; accent-color: var(--burgundy); }
.rate .readout { font-family: var(--serif); font-size: 30px; font-weight: 600; min-width: 50px; line-height: 1; }
.rate .stars { color: var(--gold); font-size: 16px; letter-spacing: 2px; }

.tagpick { display: flex; gap: 5px; flex-wrap: wrap; }
.tagpick button { background: var(--surface); border: 1px solid var(--border); border-radius: 100px; padding: 5px 11px; font: inherit; font-size: 12px; color: var(--text-muted); cursor: pointer; }
.tagpick button[aria-pressed="true"] { background: var(--burgundy); border-color: var(--burgundy); color: #fff; font-weight: 500; }

.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { margin-top: 3px; accent-color: var(--burgundy); }
.check .t { font-size: 13px; }
.check .h { font-size: 11.5px; color: var(--text-muted); }

.window { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 15px; font-size: 11.5px; }
.window .yrs { font-family: var(--serif); font-size: 22px; font-weight: 600; margin-top: 2px; }

/* ---------- toast ------------------------------------------------------- */

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--primary-navy); color: #fff; border-radius: var(--radius); padding: 11px 18px; font-size: 13px; z-index: 80; max-width: calc(100vw - 32px); box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.toast.err { background: var(--alert); }

/* ---------- responsive -------------------------------------------------- */

@media (max-width: 880px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .brand { padding: 15px 16px 13px; display: flex; align-items: center; gap: 13px; }
  .brand-mark { height: 22px; margin: 0; }
  .brand h1 { font-size: 21px; }
  .brand p { display: none; }
  .nav { display: flex; overflow-x: auto; padding: 0; }
  .nav button { border-left: 0; border-bottom: 2px solid transparent; white-space: nowrap; padding: 12px 16px; justify-content: center; }
  .nav button[aria-current="true"] { border-left: 0; border-bottom-color: var(--gold); }
  .nav .count { display: none; }
  .sidebar-foot { display: none; }
  .main { padding: 20px 15px 60px; }
  .view-head h2 { font-size: 27px; }
  .grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .stat .value { font-size: 30px; }
  .fridges { grid-template-columns: 1fr; }
  .backdrop { padding: 0; }
  .modal { max-width: none; border: 0; border-radius: 0; min-height: 100vh; }
}
