/* ==========================================================================
   Wine IQ — White Wine & Magenta Cellar Theme
   Edit the CSS variables in :root below to customize colors, fonts & spacing.
   ========================================================================== */

:root {
  /* Palette — White Wine Ivory to Deep Magenta */
  --bg: #faf7f0;
  --surface: #ffffff;
  --surface-alt: #f4eee3;
  --header-bg: #f5efe1;
  --ink: #2c1721;
  --border: #dfd2d7;
  --border-soft: #eadfe3;
  --text: #2c1721;
  --text-muted: #705561;

  /* Accent (Mature Magenta-Burgundy + Rosé Blush) */
  --accent: #8c1d4a;
  --accent-hover: #6e1439;
  --accent-soft: #f8eaf0;
  --rose-mid: #c25982;
  --gold: #f4ebd8;

  /* Status Colors (Muted Sommelier Spectrum) */
  --peak-bg: #e7f3eb;
  --peak-text: #1f5c37;
  --soon-bg: #f8ecd4;
  --soon-text: #7a4b0a;
  --hold-bg: #eee9f4;
  --hold-text: #4c3b66;
  --past-bg: #f8dfe9;
  --past-text: #8c1d4a;

  /* Wine Type Dot Colors */
  --wine-red: #8c1d4a;
  --wine-white: #dfd098;
  --wine-rose: #d982a1;
  --wine-sparkling: #e8dbb0;
  --wine-dessert: #b87c3a;

  /* Layout & Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 2px 12px rgba(60, 18, 36, 0.06);
  --shadow-sm: 0 1px 4px rgba(60, 18, 36, 0.06);
  --max-width: 100%;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.38;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 clamp(10px, 1.8vw, 24px);
}

.hidden {
  display: none !important;
}

/* Header */
.site-header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  padding: 9px 0;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 6px rgba(60, 18, 36, 0.05);
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}

.brand-mark {
  font-size: 1.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.24rem;
  letter-spacing: -0.015em;
  color: var(--accent);
  white-space: nowrap;
}

.subtitle {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-shadow: var(--shadow-sm);
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-alt);
  border-color: var(--border);
  color: var(--ink);
}

.btn-secondary:hover {
  background: var(--accent-soft);
  border-color: var(--rose-mid);
  color: var(--accent);
}

.btn-ghost {
  background: var(--surface);
  color: var(--text-muted);
  border-color: var(--border-soft);
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--surface-alt);
  color: var(--ink);
}

.btn-sm {
  padding: 5px 9px;
  font-size: 0.79rem;
}

.icon-btn {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  padding: 3px 9px;
}

/* Main Layout */
.main-layout {
  padding-top: 12px;
  padding-bottom: 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-header h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.12rem;
}

.jtbd-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--gold);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 1px 8px;
  margin-bottom: 4px;
}

/* Meal Recommender */
.meal-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.meal-chip {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.81rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--ink);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.meal-chip:hover,
.meal-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.meal-search-row {
  display: flex;
  gap: 8px;
}

.meal-search-row input,
.filters-bar input,
.filters-bar select,
.lookup-row input,
.add-form input,
.add-form select {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.89rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}

.recommendations-list {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
}

.rec-card {
  border: 1px solid var(--rose-mid);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.rec-card h3 {
  margin: 0;
  font-size: 0.96rem;
}

.rec-reasons {
  margin: 0;
  padding-left: 17px;
  font-size: 0.81rem;
  color: var(--text);
}

/* Inventory Controls */
.inventory-header {
  align-items: flex-end;
}

.view-toggle {
  display: flex;
  gap: 6px;
}

.tab-btn {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
}

.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.filters-bar {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

/* Location-grouped Cellar View */
.location-groups {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.location-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.location-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.location-title-group {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.location-title-group h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--accent);
}

.location-subtitle {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.location-empty {
  padding: 12px 14px;
  border: 2px dashed var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.84rem;
}

wine-card {
  display: flex;
  min-width: 0;
}

wine-card > .wine-card {
  width: 100%;
}

wine-peak-chart,
wine-origin-map {
  display: block;
}

/* Dense Desktop Grid */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  gap: 10px;
}

.wine-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px 10px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.wine-card-eyebrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.wine-eyebrow-left {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.eyebrow-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(44, 23, 33, 0.18);
}

.wine-eyebrow-producer {
  font-size: 0.71rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.wine-eyebrow-right {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.wine-vintage-pill {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  line-height: 1.3;
}

.card-tag-private {
  font-size: 0.75rem;
  line-height: 1;
}

.wine-card-body {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.wine-card-text {
  min-width: 0;
  flex: 1;
}

.wine-title {
  margin: 0;
  font-size: 1.02rem;
  font-family: var(--font-serif);
  line-height: 1.24;
  color: var(--text);
}

.wine-status-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  font-size: 0.77rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.status-sep {
  opacity: 0.45;
}

.card-window {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: currentColor;
}

.card-window-peak { color: #1b6b3a; }
.card-window-drink_soon { color: #9c5b00; }
.card-window-past_peak { color: #b42318; }
.card-window-approaching { color: #4b5563; }
.card-window-hold { color: #5b4b8a; }

.card-status-loc {
  color: var(--text-muted);
  font-weight: 500;
}

.card-status-open {
  color: #b42318;
  font-weight: 700;
}

.card-status-rating {
  color: #b7791f;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.card-status-unrated {
  color: var(--accent);
  font-weight: 600;
}

.card-status-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
}

.wine-card-footer {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-link-btn {
  padding-left: 6px;
  padding-right: 8px;
  border-color: transparent;
  color: var(--text-muted);
}

.card-link-btn:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.card-more-btn {
  padding-left: 8px;
  padding-right: 8px;
  border-color: transparent;
  color: var(--text-muted);
}

.color-dot {
  display: inline-block;
  vertical-align: middle;
  margin-right: 5px;
  margin-top: -2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(44, 23, 33, 0.25);
}

.color-Red { background: var(--wine-red); }
.color-White { background: var(--wine-white); }
.color-Rosé { background: var(--wine-rose); }
.color-Sparkling { background: var(--wine-sparkling); }
.color-Dessert { background: var(--wine-dessert); }

.qty-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.wine-meta {
  font-size: 0.81rem;
  color: var(--text-muted);
}

.wine-producer {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 2px;
  line-height: 1.25;
}

.wine-thumb {
  width: 44px;
  height: 62px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--ink);
  background: var(--bg);
  flex-shrink: 0;
}

.badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 600;
  border: 1px solid rgba(44, 23, 33, 0.12);
}

.badge-peak { background: var(--peak-bg); color: var(--peak-text); }
.badge-drink_soon { background: var(--soon-bg); color: var(--soon-text); }
.badge-approaching,
.badge-hold { background: var(--hold-bg); color: var(--hold-text); }
.badge-past_peak { background: var(--past-bg); color: var(--past-text); }

.badge-id {
  background: var(--surface-alt);
  color: var(--text-muted);
  border-color: var(--border-soft);
  font-family: monospace;
  font-weight: 600;
}

.wine-notes {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text);
  background: var(--bg);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wine-card-actions {
  margin-top: auto;
  padding-top: 7px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.wine-card-actions .card-btn-group {
  flex-wrap: wrap;
  min-width: 0;
}

.wine-card-actions .btn-sm {
  padding: 5px 8px;
  font-size: 0.77rem;
  white-space: nowrap;
}

.location-select {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--ink);
  min-width: 0;
  flex: 1;
  max-width: 145px;
}

.card-btn-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

/* Modals */
dialog.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  max-width: 640px;
  width: calc(100% - 20px);
  box-shadow: 0 16px 40px rgba(44, 23, 33, 0.22);
  background: var(--surface);
}

dialog.modal.modal-sm {
  max-width: 440px;
}

dialog.modal::backdrop {
  background: rgba(36, 17, 24, 0.58);
}

.modal-card {
  width: 100%;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  font-family: var(--font-serif);
}

.scan-box {
  background: var(--accent-soft);
  border: 1px dashed var(--rose-mid);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.scan-btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.scan-btn {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.9rem;
}

.photo-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.photo-input-row input[type="text"] {
  flex: 1;
  min-width: 0;
}

.card-remove-btn {
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  padding: 3px 6px;
  cursor: pointer;
  flex-shrink: 0;
}

.card-remove-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.scan-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.lookup-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
}

.lookup-box label {
  display: block;
  font-size: 0.83rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.lookup-row {
  display: flex;
  gap: 8px;
}

.field-hint {
  margin: 5px 0 0;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.lookup-results {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.lookup-item {
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.lookup-item:hover {
  background: var(--accent-soft);
}

.lookup-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lookup-thumb {
  width: 30px;
  height: 42px;
  object-fit: contain;
  border-radius: 4px;
  border: 1px solid var(--ink);
  background: var(--bg);
  flex-shrink: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.field-wide {
  grid-column: 1 / -1;
}

.modal-footer {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 28px 16px;
  color: var(--text-muted);
}

/* Drink & Rating Overlay */
.drink-wine-name {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.02rem;
  color: var(--accent);
}

.star-picker {
  display: flex;
  align-items: center;
  gap: 6px;
}

.star-btn {
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-sm);
  font-size: 1.3rem;
  line-height: 1;
  padding: 5px 8px;
  cursor: pointer;
  color: #ccc2b6;
}

.star-btn.active,
.star-btn:hover {
  color: #c88a1e;
  background: #fdf6e7;
}

.rating-badge {
  background: #fdf6e7;
  color: #6b4100;
  cursor: pointer;
}

.rating-unrated {
  background: var(--surface-alt);
  color: var(--text-muted);
  border-style: dashed;
  cursor: pointer;
}

/* Find & Buy Again Modal */
.buy-links-section,
.buy-again-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.buy-section-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.buy-links-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.buy-link-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 11px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 700;
}

.buy-link-btn:hover {
  background: var(--gold);
}

.buy-again-box {
  padding-top: 10px;
  border-top: 1.5px dashed var(--border-soft);
}

.buy-again-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.buy-again-row select {
  flex: 1;
  padding: 8px 10px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.88rem;
  background: var(--surface);
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.header-actions .btn {
  white-space: nowrap;
}

/* Account Avatar & Dropdown */
.account-menu-wrap {
  position: relative;
}

.avatar-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--rose-mid);
  background: var(--accent);
  color: #fff;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  overflow: visible;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.avatar-btn:hover {
  box-shadow: 0 2px 10px rgba(140, 29, 74, 0.28);
}

.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.avatar-initials {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
}

.avatar-notif-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d92d20;
  border: 2px solid var(--header-bg);
}

.account-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(44, 23, 33, 0.18);
  padding: 6px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.account-dropdown-head {
  padding: 8px 10px 9px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.account-dropdown-head strong {
  font-size: 0.9rem;
  color: var(--ink);
}

.dropdown-item {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dropdown-item:hover {
  background: var(--surface-alt);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-soft);
  margin: 4px 0;
}

.dropdown-item-danger {
  color: var(--accent);
}

.friend-row-id {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.mini-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
}

/* Desktop Top Navigation */
.desktop-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  box-shadow: var(--shadow-sm);
}

.nav-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s ease, color 0.14s ease;
}

.nav-tab:hover {
  background: var(--surface-alt);
  color: var(--ink);
}

.nav-tab.active {
  background: var(--accent);
  color: #fff;
}

.screen-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.log-filters-bar {
  grid-template-columns: 2fr 1fr;
}

.cellar-filters-bar {
  grid-template-columns: 2fr 1fr 1fr;
}

.cellar-loc-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.swap-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--gold);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 10px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--ink);
}

.wine-card-clickable {
  cursor: pointer;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.wine-card-clickable:hover {
  border-color: var(--rose-mid);
  box-shadow: var(--shadow);
}

.badge-storage {
  background: var(--surface-alt);
  color: var(--ink);
  border-color: var(--border);
}

.detail-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.detail-notes-box {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
}

.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}

.detail-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.buy-next-snapshot {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.buy-next-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.buy-next-card strong {
  font-family: var(--font-serif);
  font-size: 0.96rem;
  color: var(--accent);
}

.buy-next-card p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text);
}

.swap-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* Wine Origin Map (Leaflet + OpenStreetMap FOSS) */
.map-stats-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.wine-map-canvas {
  width: 100%;
  height: 440px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  z-index: 1;
  overflow: hidden;
}

.wine-map-canvas .leaflet-tile-pane {
  filter: grayscale(42%) sepia(14%) brightness(1.04) contrast(0.95);
}

.wine-map-pin {
  background: var(--accent);
  color: #fff;
  border: 2.5px solid #faf7f0;
  border-radius: 50%;
  box-shadow: 0 3px 10px rgba(44, 23, 33, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 0.78rem;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.wine-map-pin:hover,
.wine-map-pin.active {
  transform: scale(1.14);
  box-shadow: 0 0 0 4px rgba(140, 29, 74, 0.28), 0 4px 12px rgba(44, 23, 33, 0.4);
  background: var(--accent-hover);
}

/* Friends Cellar Switcher & Read-Only Banner */
.cellar-switcher-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.cellar-switcher-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.readonly-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--accent-soft);
  border: 1px solid var(--rose-mid);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--accent);
}

.badge-private {
  background: var(--surface-alt);
  color: var(--text-muted);
  border-color: var(--border);
}

.badge-friend {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--rose-mid);
}

#friends-favorites-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.share-bottle-picker {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 170px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--bg);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 4px 3px 12px;
}

.user-email {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
}

.auth-gate {
  display: flex;
  justify-content: center;
  padding-top: 56px;
}

.auth-card {
  max-width: 420px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 22px;
}

.auth-card h2 {
  margin: 0;
  font-family: var(--font-serif);
}

.google-signin-slot {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-error {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--accent);
}

.pending-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
}

.shared-chip {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 0.7rem;
  font-weight: 700;
}

.serving-tip {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
}

.price-badge {
  background: var(--surface-alt);
  color: var(--text-muted);
  border-color: var(--border-soft);
}

.admin-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  flex-wrap: wrap;
}

.day-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.day-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-alt);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.day-chip input {
  width: auto;
  margin: 0;
}

.open-now-section {
  background: var(--accent-soft);
  border: 1px solid var(--rose-mid);
  border-radius: var(--radius);
  padding: 12px;
}

.open-now-section .location-header {
  border-bottom-color: rgba(140, 29, 74, 0.2);
}

.cook-dishes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dish-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.dish-card strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 0.94rem;
  color: var(--ink);
  margin-bottom: 3px;
}

.dish-card p {
  margin: 0;
  font-size: 0.81rem;
  color: var(--text-muted);
}

/* Peak Window Summed Normal Distribution View */
.timeline-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.timeline-chart-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 0;
  overflow: hidden;
}

.timeline-loc-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 100%;
}

.timeline-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.timeline-chart-head h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--accent);
}

.timeline-plot-wrap {
  position: relative;
  width: 100%;
  height: 190px;
}

.timeline-svg {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
}

.timeline-dot {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(44, 23, 33, 0.35);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.timeline-now-tag {
  position: absolute;
  top: 2px;
  transform: translateX(-50%);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg);
  padding: 0 4px;
  pointer-events: none;
}

.timeline-axis-x {
  position: relative;
  height: 20px;
  margin-top: 4px;
}

.timeline-tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
}

.timeline-tick.active {
  color: var(--accent);
  font-weight: 700;
}

.timeline-hit {
  fill: transparent;
  cursor: pointer;
}

.timeline-hit:hover {
  fill: rgba(140, 29, 74, 0.08);
}

.timeline-year-pills {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 5px;
  margin-top: 10px;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.year-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.year-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.year-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.timeline-selection-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.timeline-selection-head h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.02rem;
  color: var(--accent);
}

#favorites-filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Mobile Sticky Bottom Tab Bar (hidden on desktop) */
.mobile-tab-bar {
  display: none;
}

/* Manage Locations Modal */
.locations-manage-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.loc-manage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.checkbox-row input {
  width: auto;
}

/* Intermediate Tablet / Split-Window Breakpoints */
@media (max-width: 1080px) {
  .subtitle {
    display: none;
  }
}

@media (max-width: 880px) {
  .btn-label-desktop {
    display: none;
  }

  .nav-tab {
    padding: 5px 10px;
    font-size: 0.82rem;
  }
}

/* Responsive Mobile / Compact Window Space Optimization */
@media (max-width: 740px) {
  .container {
    padding: 0 8px;
  }

  .desktop-nav {
    display: none !important;
  }

  .btn-label-desktop {
    display: none;
  }

  .brand {
    gap: 6px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    font-size: 1.05rem;
  }

  .brand h1 {
    font-size: 1.08rem;
  }

  .subtitle {
    display: none;
  }

  .header-actions {
    gap: 5px;
  }

  .header-actions .btn-sm {
    padding: 5px 8px;
    font-size: 0.76rem;
  }

  .user-pill {
    display: none !important;
  }

  .main-layout {
    padding-top: 8px;
    padding-bottom: 78px;
    gap: 10px;
  }

  .panel {
    padding: 10px;
    box-shadow: var(--shadow-sm);
  }

  .panel-header {
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .tab-btn {
    padding: 5px 9px;
    font-size: 0.78rem;
  }

  .meal-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .filters-bar {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 10px;
  }

  .filters-bar input {
    grid-column: 1 / -1;
  }

  .log-filters-bar {
    grid-template-columns: 1fr;
  }

  .inventory-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .wine-map-canvas {
    height: 310px;
  }

  .mobile-tab-bar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    background: var(--header-bg);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 10px rgba(44, 23, 33, 0.08);
    padding: 4px 6px calc(5px + env(safe-area-inset-bottom));
    gap: 4px;
  }

  .mobile-tab {
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 5px 4px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
  }

  .mobile-tab-icon {
    font-size: 1.08rem;
    line-height: 1;
  }

  .mobile-tab-label {
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.1;
  }

  .mobile-tab.active {
    background: var(--accent-soft);
    color: var(--accent);
  }

  .mobile-tab.active .mobile-tab-label {
    font-weight: 700;
  }
}

/* Compact Quick-Add Modal */
#add-modal .modal-card {
  gap: 16px;
}

#add-modal .add-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#add-modal .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

#add-modal .field label {
  margin: 0;
  line-height: 1.2;
}

.scan-box-compact {
  padding: 12px 14px;
  gap: 8px;
}

.scan-box-compact .field-hint {
  margin: 0;
}

.batch-added-banner {
  background: #e7f4ec;
  border: 1px solid #a9d5ba;
  color: #1f5c37;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 0.84rem;
  font-weight: 600;
}

.label-ai-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.label-ai-row input {
  flex: 1;
  min-width: 0;
  height: 40px;
}

.label-ai-row button {
  flex-shrink: 0;
  white-space: nowrap;
  height: 40px;
  padding: 0 13px;
}

.quick-row-3 {
  display: grid;
  grid-template-columns: 96px 116px 1fr;
  gap: 12px;
  align-items: start;
}

.quick-row-3 input,
.quick-row-3 select,
.quick-row-3 .qty-stepper {
  height: 40px;
  box-sizing: border-box;
}

#f-vintage {
  -moz-appearance: textfield;
}

#f-vintage::-webkit-outer-spin-button,
#f-vintage::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.qty-stepper {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}

.qty-step-btn {
  border: none;
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
  width: 34px;
  flex-shrink: 0;
  cursor: pointer;
  padding: 0;
}

.qty-step-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.qty-stepper input {
  border: none;
  border-radius: 0;
  text-align: center;
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 4px;
  -moz-appearance: textfield;
}

.qty-stepper input::-webkit-outer-spin-button,
.qty-stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.storage-suggest-hint {
  margin: -6px 0 0;
  padding: 0 2px;
  color: var(--accent);
  font-weight: 600;
  line-height: 1.35;
}

.inferred-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.83rem;
  line-height: 1.35;
  cursor: pointer;
  font-family: inherit;
}

.inferred-summary:hover {
  border-color: var(--accent);
}

.inferred-edit-tag {
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.more-details-drawer {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  background: var(--surface);
}

.more-details-drawer summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
  line-height: 1.3;
}

.more-details-drawer[open] summary {
  color: var(--accent);
}

.add-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 2px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.add-footer-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 520px) {
  .quick-row-3 {
    grid-template-columns: 1fr 1fr;
  }
  .quick-row-3 .field:last-child {
    grid-column: 1 / -1;
  }
}
