:root {
  --bg-dark: #1a1a1a;
  --bg-card: #252525;
  --bg-slot: #2d2d2d;
  --bg-slot-hover: #363636;
  --border: #3a3a3a;
  --text: #e8e8e8;
  --text-muted: #888;
  --red-wine: #722F37;
  --white-wine: #F5E6C8;
  --rose-wine: #E8A0A0;
  --sparkling: #D4AF37;
  --priority-1: #ff4444;
  --priority-2: #ff8844;
  --priority-3: #ffbb44;
  --accent: #8B7355;
  --fridge-bg: #1e2a35;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  padding: 1rem;
  font-size: 1rem;
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

header h1 {
  font-size: 2rem;
  letter-spacing: 0.05em;
}

header .search-trigger {
  margin-right: auto;
  margin-left: 1.5rem;
}

.stats {
  display: flex;
  gap: 2rem;
  font-size: 0.9rem;
}

.stat {
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Navigation tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.6rem 1.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.tab:hover { background: var(--bg-slot-hover); }
.tab.active { background: var(--accent); border-color: var(--accent); }

/* Views */
.view { display: none; }
.view.active { display: block; }

/* Zone sections */
.zone {
  margin-bottom: 2rem;
}

.zone-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.zone-title {
  font-size: 1.1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

/* Cellar grid */
.cellar-grid {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cellar-row {
  display: flex;
  gap: 3px;
  align-items: center;
}

.row-label {
  width: 80px;
  min-width: 80px;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
  padding-right: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
}

.row-label.zone-active {
  color: var(--text);
}

.row-label .zone-name {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 75px;
}

.row-label .row-id {
  font-size: 0.55rem;
  color: var(--text-muted);
  opacity: 0.7;
}

/* AI Drink Recommendations Panel */
.recommendation-panel {
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(139, 92, 246, 0.05) 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.recommendation-panel.collapsed .recommendation-subtitle,
.recommendation-panel.collapsed .recommendation-context,
.recommendation-panel.collapsed .recommendation-cards {
  display: none;
}

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

.recommendation-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.recommendation-header h2::before {
  content: '🍷';
}

.recommendation-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--bg-slot);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-dark);
  border-color: var(--accent);
}

.refresh-icon {
  font-size: 1.1rem;
  transition: transform 0.3s;
}

.btn-icon:hover .refresh-icon {
  transform: rotate(180deg);
}

.toggle-icon {
  font-size: 1.2rem;
  font-weight: bold;
}

.recommendation-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0.25rem 0 1rem 0;
}

.recommendation-context {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.context-label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.context-select {
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-slot);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

.context-select:focus {
  outline: none;
  border-color: var(--accent);
}

.context-input {
  flex: 1;
  min-width: 200px;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-slot);
  color: var(--text);
  font-size: 0.85rem;
}

.context-input:focus {
  outline: none;
  border-color: var(--accent);
}

.context-input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.recommendation-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.recommendation-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  position: relative;
  transition: all 0.2s;
  cursor: pointer;
}

.recommendation-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.recommendation-card .rank-badge {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.recommendation-card .wine-colour {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.5rem;
}

.recommendation-card .wine-colour.red { background: var(--wine-red); }
.recommendation-card .wine-colour.white { background: var(--wine-white); }
.recommendation-card .wine-colour.rose { background: var(--wine-rose); }
.recommendation-card .wine-colour.sparkling { background: var(--wine-sparkling); }

.recommendation-card .wine-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
}

.recommendation-card .wine-vintage {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.recommendation-card .rec-reason {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-style: italic;
}

.recommendation-card .urgency-tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 0.5rem;
}

.urgency-tag.critical { background: rgba(244, 67, 54, 0.2); color: #f44336; }
.urgency-tag.high { background: rgba(255, 152, 0, 0.2); color: #ff9800; }
.urgency-tag.peak { background: rgba(76, 175, 80, 0.2); color: #4caf50; }
.urgency-tag.medium { background: rgba(33, 150, 243, 0.2); color: #2196f3; }

.recommendation-loading {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem;
  color: var(--text-muted);
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.recommendation-error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
}

.recommendation-error .error-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.no-api-key-notice {
  grid-column: 1 / -1;
  background: rgba(255, 152, 0, 0.1);
  border: 1px solid rgba(255, 152, 0, 0.3);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.no-api-key-notice p {
  margin: 0 0 0.5rem 0;
  color: var(--text);
}

.no-api-key-notice .hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.recommendation-placeholder {
  grid-column: 1 / -1;
  text-align: center;
  padding: 1.5rem;
}

.recommendation-placeholder p {
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.recommendation-placeholder .btn {
  padding: 0.75rem 1.5rem;
}

/* Cellar Analysis Panel */
.cellar-analysis-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1.5rem;
}

.analysis-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.analysis-header h3 {
  margin: 0;
  font-size: 1.2rem;
}

.analysis-header .btn {
  font-size: 1.2rem;
  padding: 0.2rem 0.5rem;
  line-height: 1;
}

.analysis-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.summary-stat {
  text-align: center;
  padding: 0.75rem;
  background: var(--bg-slot);
  border-radius: 6px;
}

.summary-stat .value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
}

.summary-stat .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.summary-stat.good .value { color: #4caf50; }
.summary-stat.warning .value { color: #ff9800; }
.summary-stat.bad .value { color: #f44336; }

.analysis-alerts {
  margin-bottom: 1rem;
}

.alert-item {
  padding: 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.alert-item.warning {
  background: rgba(255, 152, 0, 0.15);
  border-left: 3px solid #ff9800;
}

.alert-item.info {
  background: rgba(33, 150, 243, 0.15);
  border-left: 3px solid #2196f3;
}

.alert-item .alert-icon {
  font-size: 1.1rem;
}

.analysis-moves h4 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.moves-list {
  max-height: 300px;
  overflow-y: auto;
}

.move-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  background: var(--bg-slot);
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.move-item.priority-1 { border-left: 3px solid var(--priority-1); }
.move-item.priority-2 { border-left: 3px solid var(--priority-2); }
.move-item.priority-3 { border-left: 3px solid var(--priority-3); }

.move-details {
  flex: 1;
}

.move-wine-name {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.move-path {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.move-path .from { color: #f44336; }
.move-path .to { color: #4caf50; }
.move-path .arrow { margin: 0 0.5rem; color: var(--text-muted); }

.move-reason {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.25rem;
}

.move-confidence {
  font-size: 0.7rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  margin-left: 0.5rem;
}

.move-confidence.high { background: rgba(76, 175, 80, 0.2); color: #4caf50; }
.move-confidence.medium { background: rgba(255, 152, 0, 0.2); color: #ff9800; }
.move-confidence.low { background: rgba(158, 158, 158, 0.2); color: #9e9e9e; }

.move-actions {
  display: flex;
  gap: 0.5rem;
}

.move-actions .btn {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
}

.moves-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.analysis-ai-advice {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-slot);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}

.analysis-ai-advice h4 {
  margin-bottom: 0.75rem;
  color: var(--accent);
}

.analysis-ai-advice p {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.analysis-loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.no-moves {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Fridge grid */
.fridge-section {
  background: var(--fridge-bg);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.fridge-grid {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.fridge-row {
  display: flex;
  gap: 3px;
}

/* Slots */
.slot {
  width: 90px;
  height: 52px;
  background: var(--bg-slot);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 4px;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}

.slot:hover {
  background: var(--bg-slot-hover);
  transform: scale(1.02);
  z-index: 10;
}

.slot.empty {
  opacity: 0.4;
}

.slot.empty:hover {
  opacity: 0.7;
}

/* Wine colour indicators */
.slot.red { border-left: 3px solid var(--red-wine); }
.slot.white { border-left: 3px solid var(--white-wine); }
.slot.rose { border-left: 3px solid var(--rose-wine); }
.slot.sparkling { border-left: 3px solid var(--sparkling); }

/* Reduce-now priority badges */
.slot.priority-1::after,
.slot.priority-2::after,
.slot.priority-3::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 12px 12px 0;
}

.slot.priority-1::after { border-color: transparent var(--priority-1) transparent transparent; }
.slot.priority-2::after { border-color: transparent var(--priority-2) transparent transparent; }
.slot.priority-3::after { border-color: transparent var(--priority-3) transparent transparent; }

.slot-name {
  font-size: 0.65rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
  max-height: 2.4em;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
  hyphens: auto;
  max-width: 100%;
}

.slot-vintage {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.slot-loc {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: 0.5rem;
  color: var(--text-muted);
  opacity: 0.6;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.8);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 400px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 {
  margin-bottom: 0.5rem;
  font-size: 1.4rem;
}

.modal-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-field {
  margin-bottom: 1rem;
}

.modal-field label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
}

.modal-field span {
  font-size: 0.95rem;
}

.tasting-notes-text {
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text);
  line-height: 1.5;
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.btn {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
}

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

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-danger {
  background: var(--red-wine);
  color: white;
}

.btn-danger:hover {
  filter: brightness(1.2);
}

.btn-secondary {
  background: var(--bg-slot);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-slot-hover);
}

/* Reduce Now list view */
.reduce-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.reduce-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1rem;
  background: var(--bg-card);
  border-radius: 8px;
  border-left: 4px solid var(--priority-3);
}

.reduce-item.p1 { border-left-color: var(--priority-1); }
.reduce-item.p2 { border-left-color: var(--priority-2); }

.reduce-priority {
  font-size: 1.2rem;
  font-weight: 600;
  width: 30px;
  text-align: center;
}

.reduce-info {
  flex: 1;
}

.reduce-name {
  font-weight: 500;
  margin-bottom: 0.2rem;
}

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

.reduce-locations {
  font-size: 0.75rem;
  color: var(--accent);
}

/* Wine list view */
.wine-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.75rem;
}

/* Virtual list mode - single column with fixed height for windowing */
.wine-list.virtual-mode {
  display: block;
  height: calc(100vh - 280px);
  min-height: 400px;
  overflow-y: auto;
}

.wine-list.virtual-mode .virtual-list-wrapper {
  position: relative;
  width: 100%;
}

.wine-list.virtual-mode .virtual-list-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.wine-list.virtual-mode .virtual-list-item {
  box-sizing: border-box;
}

.wine-card {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: 8px;
  border-left: 4px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.wine-card:hover {
  background: var(--bg-slot-hover);
  transform: translateX(2px);
}

.wine-card.red { border-left-color: var(--red-wine); }
.wine-card.white { border-left-color: var(--white-wine); }
.wine-card.rose { border-left-color: var(--rose-wine); }
.wine-card.sparkling { border-left-color: var(--sparkling); }

.wine-count {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 30px;
}

.wine-details {
  flex: 1;
}

.wine-name {
  font-weight: 500;
  margin-bottom: 0.2rem;
}

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

/* Pairing view */
.pairing-form {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
}

.signal-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.signal-btn {
  padding: 0.5rem 1rem;
  background: var(--bg-slot);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  color: var(--text);
}

.signal-btn:hover {
  background: var(--bg-slot-hover);
}

.signal-btn.active {
  background: var(--accent);
  border-color: var(--accent);
}

.pairing-results {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.pairing-suggestion {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: 8px;
  border-left: 4px solid var(--accent);
}

.pairing-suggestion.clickable {
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.pairing-suggestion.clickable:hover {
  background: var(--bg-slot-hover);
  transform: translateX(2px);
}

.pairing-score {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 40px;
  text-align: center;
}

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  border: 1px solid var(--accent);
  padding: 1rem 1.5rem;
  border-radius: 8px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 200;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Sommelier / Natural pairing styles */
.natural-pairing {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
}

.natural-pairing input[type="text"] {
  width: 100%;
  padding: 0.8rem 1rem;
  background: var(--bg-slot);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 1rem;
}

.natural-pairing input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

.natural-pairing input[type="text"]::placeholder {
  color: var(--text-muted);
}

.pairing-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-group label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.filter-group input[type="radio"] {
  accent-color: var(--accent);
}

/* Sommelier response styles */
.sommelier-response {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.dish-analysis {
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.colour-suggestion {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 1rem;
}

.recommendation {
  background: var(--bg-slot);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  border-left: 3px solid var(--accent);
}

.recommendation.clickable {
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.recommendation.clickable:hover {
  background: var(--bg-slot-hover);
  transform: translateX(2px);
}

.recommendation.priority {
  border-left-color: var(--priority-2);
}

.recommendation-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.recommendation-header h4 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
  font-weight: 600;
}

.priority-badge {
  background: var(--priority-2);
  color: #000;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 600;
}

.recommendation .location {
  font-size: 0.85rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.recommendation .why {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.recommendation .food-tip {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

.no-match {
  color: var(--text-muted);
  font-style: italic;
}

/* Sommelier Chat */
.sommelier-chat {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1rem;
  margin-top: 1rem;
  border: 1px solid var(--border);
}

.chat-messages {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 1rem;
  padding: 0.5rem;
}

.chat-message {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  margin-bottom: 0.5rem;
  max-width: 85%;
  line-height: 1.5;
}

.chat-message.user {
  background: var(--accent);
  color: #000;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.chat-message.assistant {
  background: var(--bg-slot);
  color: var(--text);
  margin-right: auto;
  border-bottom-left-radius: 4px;
}

.chat-input-container {
  display: flex;
  gap: 0.5rem;
}

.chat-input-container input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-dark);
  color: var(--text);
  font-size: 0.95rem;
}

.chat-input-container input:focus {
  outline: none;
  border-color: var(--accent);
}

.chat-input-container button {
  padding: 0.75rem 1.5rem;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  align-items: center;
}

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

.chat-suggestion {
  background: var(--bg-slot);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.4rem 0.75rem;
  border-radius: 16px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.chat-suggestion:hover {
  background: var(--bg-slot-hover);
  color: var(--text);
  border-color: var(--accent);
}

.chat-recommendations {
  width: 100%;
}

.chat-recommendations .chat-intro {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.chat-recommendations .recommendation {
  margin-bottom: 0.5rem;
}

.loading-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--text-muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 0.5rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   DRAG AND DROP
   ============================================================ */

.slot.draggable {
  cursor: grab;
}

.slot.draggable:active {
  cursor: grabbing;
}

.slot.dragging {
  opacity: 0.5;
  transform: scale(1.05);
  z-index: 100;
}

.slot.drag-over {
  background: var(--accent) !important;
  opacity: 0.7;
  border: 2px dashed var(--text);
}

.slot.drag-over-invalid {
  background: var(--red-wine) !important;
  opacity: 0.5;
}

.slot.empty.drag-target {
  border: 2px dashed var(--accent);
  background: rgba(139, 115, 85, 0.2);
}

/* Swap mode - dropping on occupied slot */
.slot.drag-over-swap {
  background: var(--accent) !important;
  opacity: 0.8;
  border: 2px solid #ffd700;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* Swap mode active state */
body.swap-mode-active .slot:not(.swap-destination):not(.swap-target) {
  opacity: 0.4;
  pointer-events: none;
}

body.swap-mode-active .slot.swap-destination {
  border: 2px dashed #4CAF50;
  background: rgba(76, 175, 80, 0.2);
  cursor: pointer;
  animation: pulse-green 1.5s ease-in-out infinite;
}

body.swap-mode-active .slot.swap-target {
  border: 2px solid #ffd700;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
  animation: pulse-gold 1s ease-in-out infinite;
}

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 5px rgba(76, 175, 80, 0.3); }
  50% { box-shadow: 0 0 15px rgba(76, 175, 80, 0.6); }
}

@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 215, 0, 0.4); }
  50% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.8); }
}

/* ============================================================
   BOTTLE FORM
   ============================================================ */

.form-section {
  margin-bottom: 1.25rem;
}

.form-toggle {
  display: flex;
  gap: 0;
  background: var(--bg-slot);
  border-radius: 8px;
  padding: 4px;
}

.toggle-btn {
  flex: 1;
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.toggle-btn.active {
  background: var(--accent);
  color: white;
}

.toggle-btn:hover:not(.active) {
  background: var(--bg-slot-hover);
}

.form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-field {
  flex: 1;
}

.form-field label,
.form-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.form-field input,
.form-field select,
#wine-search {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--bg-slot);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.95rem;
}

.form-field input:focus,
.form-field select:focus,
#wine-search:focus {
  outline: none;
  border-color: var(--accent);
}

.form-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

/* Placement options for multi-bottle add */
.placement-options {
  margin-top: 1rem;
}

.placement-radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.placement-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
  transition: background 0.2s;
}

.placement-option:hover {
  background: var(--bg-slot-hover);
}

.placement-option input[type="radio"] {
  width: auto;
  margin: 0;
}

.placement-label {
  font-size: 0.9rem;
  color: var(--text);
}

/* Search Results */
.search-results {
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-slot);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 0.5rem;
  display: none;
}

.search-results.active {
  display: block;
}

.search-result-item {
  padding: 0.6rem 0.8rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--bg-slot-hover);
}

.search-result-item.selected {
  background: var(--accent);
}

.search-result-name {
  font-weight: 500;
}

.search-result-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Modal action buttons */
#bottle-modal .modal-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ============================================================
   PARSE TEXT SECTION
   ============================================================ */

#wine-text-input {
  width: 100%;
  padding: 0.8rem;
  background: var(--bg-slot);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  min-height: 100px;
}

#wine-text-input:focus {
  outline: none;
  border-color: var(--accent);
}

#wine-text-input::placeholder {
  color: var(--text-muted);
}

.parse-confidence {
  font-size: 0.85rem;
  padding: 0.5rem;
  background: var(--bg-slot);
  border-radius: 4px;
}

.parse-confidence small {
  opacity: 0.8;
}

.parsed-wine-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
  max-height: 150px;
  overflow-y: auto;
}

.parsed-wine-item {
  padding: 0.6rem 0.8rem;
  background: var(--bg-slot);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.parsed-wine-item:hover {
  background: var(--bg-slot-hover);
}

.parsed-wine-item.selected {
  border-color: var(--accent);
  background: rgba(139, 115, 85, 0.2);
}

.parsed-wine-item strong {
  color: var(--text);
}

.parsed-wine-item small {
  color: var(--text-muted);
}

.parsed-wine-preview {
  background: var(--bg-slot);
  border-radius: 8px;
  padding: 1rem;
}

.parsed-wine-preview h4 {
  margin: 0 0 0.75rem 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  font-size: 0.9rem;
}

.preview-grid label {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.preview-grid > div {
  display: flex;
  flex-direction: column;
}

.preview-notes {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.preview-notes label {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

/* Editable parsed wine form */
.parsed-wine-editable {
  margin-top: 1rem;
}

.parsed-edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.parsed-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.parsed-field label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.parsed-field input,
.parsed-field select {
  padding: 0.5rem;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.9rem;
}

.parsed-field input:focus,
.parsed-field select:focus {
  outline: none;
  border-color: var(--accent);
}

.parsed-field-row {
  display: flex;
  gap: 0.75rem;
}

.parsed-field-row .parsed-field {
  flex: 1;
}

/* Three-tab toggle adjustment */
.form-toggle .toggle-btn {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* ============================================================
   IMAGE UPLOAD
   ============================================================ */

.image-upload-area {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-slot);
  position: relative;
}

.image-upload-area:hover {
  border-color: var(--accent);
  background: rgba(139, 115, 85, 0.1);
}

.image-upload-area.drag-over {
  border-color: var(--accent);
  background: rgba(139, 115, 85, 0.2);
  transform: scale(1.01);
}

.image-upload-area.has-image {
  padding: 0.5rem;
}

.image-upload-area.has-image .upload-prompt {
  display: none;
}

.upload-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
}

.upload-icon {
  font-size: 2rem;
  opacity: 0.7;
}

.upload-prompt small {
  font-size: 0.75rem;
  opacity: 0.7;
}

#image-preview {
  display: none;
  position: relative;
}

#image-preview img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 6px;
  object-fit: contain;
}

#clear-image-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-small {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

/* Image upload buttons row */
.image-upload-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.image-upload-buttons .btn {
  flex: 1;
  padding: 0.5rem;
  font-size: 0.85rem;
}

/* Hide take photo button on non-mobile by default, show on mobile */
@media (min-width: 769px) {
  #take-photo-btn {
    display: none;
  }
  .image-upload-buttons {
    display: none;
  }
}

/* Parse divider */
.parse-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 1rem 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.parse-divider::before,
.parse-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.parse-divider span {
  padding: 0 0.75rem;
}

/* Adjust textarea height when image section is visible */
#parse-wine-section #wine-text-input {
  min-height: 60px;
}

/* ============================================================
   RATINGS
   ============================================================ */

/* Star display */
.stars-display {
  color: var(--accent);
  letter-spacing: 2px;
}

.stars-display.small {
  font-size: 0.9rem;
}

.stars-display.large {
  font-size: 1.4rem;
}

.stars-unrated {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
}

/* Confidence badge */
.confidence-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 0.5rem;
}

.confidence-high {
  background: rgba(76, 175, 80, 0.2);
  color: #4caf50;
}

.confidence-medium {
  background: rgba(255, 193, 7, 0.2);
  color: #ffc107;
}

.confidence-low {
  background: rgba(244, 67, 54, 0.2);
  color: #f44336;
}

.confidence-unrated {
  background: var(--bg-slot);
  color: var(--text-muted);
}

/* Compact rating on wine cards */
.wine-rating-compact {
  display: flex;
  align-items: center;
  margin-top: 0.25rem;
}

/* Ratings panel in modal */
.ratings-panel {
  background: var(--bg-slot);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
}

.ratings-panel.unrated {
  text-align: center;
  color: var(--text-muted);
}

.ratings-loading,
.ratings-error {
  text-align: center;
  color: var(--text-muted);
  padding: 1rem;
  font-size: 0.9rem;
}

.ratings-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.ratings-error p {
  margin: 0;
}

.ratings-summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
}

.purchase-score {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.score-value {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
}

.lens-indices {
  display: flex;
  gap: 1rem;
}

.lens-index {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.8rem;
}

.lens-icon {
  font-size: 1rem;
}

.lens-name {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.lens-value {
  font-weight: 600;
}

.ratings-detail-toggle {
  margin-top: 0.75rem;
  text-align: center;
}

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-text:hover {
  text-decoration: underline;
}

.ratings-detail {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.rating-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.rating-item:last-child {
  border-bottom: none;
}

.rating-delete-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.rating-item:hover .rating-delete-btn {
  opacity: 1;
}

.rating-delete-btn:hover {
  color: var(--priority-1);
}

.rating-source {
  font-size: 0.9rem;
}

.rating-score {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.award-badge {
  font-size: 0.7rem;
  background: var(--accent);
  color: white;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

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

.vintage-warning {
  color: var(--priority-2);
}

.ratings-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}

/* Progress bar for async operations */
.progress-container {
  margin: 1rem 0;
}

.progress-bar-wrapper {
  height: 8px;
  background: var(--bg-slot);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #4CAF50, #8BC34A);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* Manual rating form */
.manual-rating-form {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-slot);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.manual-rating-form h4 {
  margin: 0 0 1rem 0;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.manual-rating-form .form-row {
  margin-bottom: 0.75rem;
}

.manual-rating-form .form-field {
  flex: 1;
}

.manual-rating-form label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.manual-rating-form select,
.manual-rating-form input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.manual-rating-form select:focus,
.manual-rating-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.manual-rating-form .form-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.manual-rating-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* Settings slider */
.preference-slider {
  margin: 1rem 0;
}

.preference-slider input[type="range"] {
  width: 100%;
}

.preference-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ============================================================
   SLOT PICKER MODE
   ============================================================ */

.slot-picker-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 1rem;
  background: var(--bg-dark);
  border-bottom: 2px solid var(--accent);
  z-index: 100;
  text-align: center;
}

.slot-picker-overlay.active {
  display: block;
}

.slot-picker-header h3 {
  margin: 0 0 0.25rem 0;
  color: var(--accent);
}

.slot-picker-header p {
  margin: 0 0 0.5rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

body.slot-picker-mode .slot.empty.picker-target {
  border: 2px dashed var(--accent);
  background: rgba(139, 115, 85, 0.2);
  cursor: pointer;
  opacity: 1;
}

body.slot-picker-mode .slot.empty.picker-target:hover {
  background: rgba(139, 115, 85, 0.4);
  transform: scale(1.05);
}

body.slot-picker-mode .slot.suggested-slot {
  border: 2px solid #4caf50 !important;
  background: rgba(76, 175, 80, 0.3) !important;
  box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
  animation: pulse-suggested 1.5s ease-in-out infinite;
}

@keyframes pulse-suggested {
  0%, 100% { box-shadow: 0 0 5px rgba(76, 175, 80, 0.5); }
  50% { box-shadow: 0 0 15px rgba(76, 175, 80, 0.8); }
}

body.slot-picker-mode .slot:not(.empty) {
  opacity: 0.4;
  pointer-events: none;
}

/* Slot picker progress indicator */
.slot-picker-progress {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0.5rem 0;
}

/* Slot that was just placed during multi-bottle add */
body.slot-picker-mode .slot.picker-placed {
  border: 2px solid #4caf50 !important;
  background: rgba(76, 175, 80, 0.4) !important;
  opacity: 0.6;
  pointer-events: none;
}

body.slot-picker-mode .slot.picker-placed::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  color: #4caf50;
}

/* ============================================================
   PERSONAL RATING
   ============================================================ */

.personal-rating-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.personal-rating-input {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.personal-rating-input select {
  flex: 1;
  padding: 0.5rem;
  background: var(--bg-slot);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

#modal-personal-notes {
  width: 100%;
  padding: 0.5rem;
  background: var(--bg-slot);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

/* ============================================================
   HISTORY VIEW
   ============================================================ */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-item {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-slot);
  border-radius: 8px;
  border-left: 4px solid var(--text-muted);
}

.history-item.red {
  border-left-color: var(--red-wine);
}

.history-item.white {
  border-left-color: var(--white-wine);
}

.history-item.rose {
  border-left-color: var(--rose-wine);
}

.history-item.sparkling {
  border-left-color: var(--sparkling);
}

.history-date {
  min-width: 80px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.history-details {
  flex: 1;
}

.history-wine {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

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

.history-occasion,
.history-pairing {
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.history-notes {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.history-rating {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.history-stars {
  color: var(--accent);
}

.history-external {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ============================================================
   DRINK WINDOW INDICATORS
   ============================================================ */

.slot.at-peak::before {
  content: '\2605';
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 0.6rem;
  color: var(--sparkling);
}

.slot.past-peak::before {
  content: '!';
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 0.6rem;
  font-weight: bold;
  color: var(--priority-1);
}

.slot.too-young {
  opacity: 0.7;
}

.slot.too-young::before {
  content: 'z';
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 0.5rem;
  color: var(--text-muted);
}

/* Drink window form row */
.drink-window-row {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 0.5rem;
}

.drink-window-row .form-field {
  flex: 1;
}

.drink-window-row label {
  font-size: 0.7rem;
}

/* Responsive */
@media (max-width: 768px) {
  .slot {
    width: 70px;
    height: 44px;
  }

  .slot-name {
    font-size: 0.55rem;
  }

  .stats {
    gap: 1rem;
  }

  header {
    flex-direction: column;
    gap: 1rem;
  }

  .pairing-filters {
    flex-direction: column;
    gap: 1rem;
  }

  .image-upload-area {
    padding: 1rem;
  }

  .upload-prompt span {
    font-size: 0.9rem;
  }

  #image-preview img {
    max-height: 150px;
  }
}

@media (max-width: 500px) {
  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .form-field {
    margin-bottom: 1rem;
  }
}

/* ============================================
   Settings Page Styles
   ============================================ */

.settings-section {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}

.settings-section-title {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.settings-section-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

/* Rating Preference Slider - Settings Page */
.preference-slider-container {
  max-width: 400px;
}

.preference-slider-container .preference-labels {
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
}

#view-settings .preference-slider {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(to right, var(--rose-wine), var(--bg-slot), var(--sparkling));
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  margin: 0;
}

#view-settings .preference-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--text);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

#view-settings .preference-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--text);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.preference-value {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 1rem;
  gap: 0.25rem;
}

.preference-value span:first-child {
  font-size: 1.5rem;
  font-weight: 600;
  font-family: 'Cormorant Garamond', serif;
}

.preference-value span:last-child {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Toggle Switch */
.settings-toggle-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-slot);
  border-radius: 26px;
  transition: 0.3s;
  border: 1px solid var(--border);
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
  background: var(--text);
}

.toggle-label {
  font-size: 0.95rem;
}

/* Settings Rules */
.settings-rules {
  padding: 1rem;
  background: var(--bg-slot);
  border-radius: 6px;
  transition: opacity 0.2s;
}

.settings-rule {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.settings-rule:last-of-type {
  border-bottom: none;
}

.settings-rule label {
  font-size: 0.9rem;
}

.rule-input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rule-input-group input {
  width: 70px;
  padding: 0.4rem 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  text-align: center;
  font-size: 0.9rem;
}

.rule-input-group input:focus {
  border-color: var(--accent);
  outline: none;
}

.rule-input-group span {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.settings-rules button {
  margin-top: 1rem;
  width: 100%;
}

/* Reduce Candidates */
.reduce-candidates-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.reduce-candidate {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-slot);
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.reduce-candidate .candidate-checkbox {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.candidate-info {
  flex: 1;
}

.candidate-name {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.candidate-reason {
  font-size: 0.85rem;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

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

/* Credential Forms */
.credential-form {
  background: var(--bg-slot);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.credential-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.credential-source {
  font-weight: 500;
  font-size: 1rem;
}

.credential-status {
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text-muted);
}

.credential-status.status-valid {
  background: rgba(76, 175, 80, 0.2);
  color: #81c784;
}

.credential-status.status-failed {
  background: rgba(244, 67, 54, 0.2);
  color: #e57373;
}

.credential-status.status-pending {
  background: rgba(255, 193, 7, 0.2);
  color: #ffd54f;
}

.credential-inputs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.credential-inputs input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.9rem;
}

.credential-inputs input:focus {
  border-color: var(--accent);
  outline: none;
}

.credential-inputs input::placeholder {
  color: var(--text-muted);
}

.credential-actions {
  display: flex;
  gap: 0.5rem;
}

/* Credential Notes */
.credential-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 0.75rem;
  padding-left: 0.25rem;
}

/* Source Info Box */
.source-info {
  background: var(--bg-slot);
  border-radius: 6px;
  padding: 1rem;
  margin-top: 1.5rem;
}

.source-info h4 {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.source-info p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.source-info ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.source-info li {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.25rem 0;
  padding-left: 1rem;
  position: relative;
}

.source-info li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--accent);
}

.source-info li strong {
  color: var(--text);
  font-weight: 500;
}

/* Settings Warning */
.settings-warning {
  background: rgba(255, 193, 7, 0.15);
  border: 1px solid rgba(255, 193, 7, 0.3);
  color: #ffd54f;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* Settings About */
.settings-about {
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Settings Subsection Titles */
.settings-subsection-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 1rem 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.settings-subsection-title:first-child {
  margin-top: 0;
}

/* ==========================================
   DRINKING WINDOW STYLES
   ========================================== */

.drinking-window-section {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--bg-slot);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.drinking-window-section .section-header h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}

#drinking-window-display {
  margin-bottom: 0.75rem;
}

#drinking-window-display .no-data {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

/* Individual window entry */
.window-entry {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin: 0.25rem 0;
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--bg-card);
}

.window-range {
  font-weight: 600;
  min-width: 120px;
}

.window-source {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.window-status {
  margin-left: auto;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.window-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 0.25rem;
  opacity: 0.6;
}

.window-delete-btn:hover {
  opacity: 1;
  color: var(--priority-1);
}

/* Window status colors */
.status-critical {
  background: rgba(255, 68, 68, 0.15);
}
.status-critical .window-status {
  background: var(--priority-1);
  color: white;
}

.status-urgent,
.status-high {
  background: rgba(255, 136, 68, 0.15);
}
.status-urgent .window-status,
.status-high .window-status {
  background: var(--priority-2);
  color: white;
}

.status-soon,
.status-medium {
  background: rgba(255, 187, 68, 0.15);
}
.status-soon .window-status,
.status-medium .window-status {
  background: var(--priority-3);
  color: #333;
}

.status-peak {
  background: rgba(212, 175, 55, 0.15);
}
.status-peak .window-status {
  background: var(--sparkling);
  color: #333;
}

.status-hold {
  background: rgba(100, 149, 237, 0.15);
}
.status-hold .window-status {
  background: #4169E1;
  color: #fff;
}

.status-ok {
  background: rgba(76, 175, 80, 0.15);
}
.status-ok .window-status {
  background: #2E7D32;
  color: #fff;
}

.status-unknown {
  background: rgba(136, 136, 136, 0.15);
}
.status-unknown .window-status {
  background: var(--text-muted);
  color: white;
}

/* Manual window entry form */
.manual-window-entry {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
  flex-wrap: wrap;
}

.manual-window-entry .entry-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.manual-window-entry .window-inputs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.manual-window-entry input[type="number"] {
  width: 80px;
  padding: 0.35rem 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.9rem;
}

.manual-window-entry input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
}

.manual-window-entry .window-separator {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Reduce candidate urgency badges in settings */
.reduce-candidate .urgency-badge {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-left: 0.5rem;
}

.urgency-badge.critical {
  background: var(--priority-1);
  color: white;
}

.urgency-badge.high {
  background: var(--priority-2);
  color: white;
}

.urgency-badge.medium {
  background: var(--priority-3);
  color: #333;
}

.urgency-badge.peak {
  background: var(--sparkling);
  color: #333;
}

.urgency-badge.unknown,
.urgency-badge.low {
  background: var(--text-muted);
  color: white;
}

/* ============================================================
   WINE LIST FILTERS & STYLES
   ============================================================ */

.wine-list-header {
  margin-bottom: 1rem;
}

.wine-list-header h2 {
  margin-bottom: 1rem;
}

.wine-list-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: 8px;
}

.wine-list-filters .filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.wine-list-filters select {
  padding: 0.5rem 0.75rem;
  background: var(--bg-slot);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

.wine-list-filters select:focus {
  outline: none;
  border-color: var(--accent);
}

.wine-list-filters .search-group {
  flex: 1;
  min-width: 150px;
}

.wine-list-filters .search-group input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg-slot);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
}

.wine-list-filters .search-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.wine-list-filters .search-group input::placeholder {
  color: var(--text-muted);
}

.filter-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  background: var(--bg-slot);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.filter-chip:has(input:checked) {
  background: var(--priority-2);
  border-color: var(--priority-2);
  color: #000;
}

.filter-chip input {
  display: none;
}

.wine-list-stats {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.wine-list-stats .reduce-badge {
  background: var(--priority-2);
  color: #000;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
}

.wine-card.priority-1 { border-left-color: var(--priority-1); }
.wine-card.priority-2 { border-left-color: var(--priority-2); }
.wine-card.priority-3 { border-left-color: var(--priority-3); }

.wine-card {
  position: relative;
}

.wine-rating {
  color: var(--accent);
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

.wine-reduce-reason {
  font-size: 0.75rem;
  color: var(--priority-2);
  margin-top: 0.2rem;
}

.wine-locations {
  font-size: 0.75rem;
  color: var(--accent);
  margin-top: 0.3rem;
}

.wine-priority-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #000;
}

.wine-priority-badge.p1 { background: var(--priority-1); }
.wine-priority-badge.p2 { background: var(--priority-2); }
.wine-priority-badge.p3 { background: var(--priority-3); }

.empty-message {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}

/* ============================================================
   MOBILE MENU
   ============================================================ */

.mobile-menu-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  padding: 8px;
}

.mobile-menu-btn span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  transition: all 0.2s;
}

.tabs-container {
  display: flex;
  gap: 0.5rem;
}

/* ============================================================
   RESPONSIVE DESIGN
   ============================================================ */

/* Tablet (768px and below) */
@media (max-width: 768px) {
  body {
    padding: 0.5rem;
    font-size: 1rem;
  }

  header {
    flex-direction: column;
    gap: 1rem;
    padding: 0.75rem 0;
  }

  header h1 {
    font-size: 1.5rem;
  }

  .stats {
    width: 100%;
    justify-content: space-around;
    gap: 1rem;
  }

  .stat-value {
    font-size: 1.3rem;
  }

  .stat-label {
    font-size: 0.85rem;
  }

  /* Tabs - larger touch targets */
  .tab {
    font-size: 1rem;
    padding: 0.75rem 1rem;
  }

  /* Grid wrapper for horizontal scroll */
  .cellar-grid,
  .fridge-grid {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
  }

  /* Grid adjustments - keep readable size, allow scroll */
  .slot {
    width: 80px;
    height: 50px;
    padding: 4px;
    flex-shrink: 0;
  }

  .slot-name {
    font-size: 0.75rem;
  }

  .slot-vintage {
    font-size: 0.65rem;
  }

  .row-label {
    width: 60px;
    min-width: 60px;
    font-size: 0.65rem;
    padding-right: 4px;
    flex-shrink: 0;
  }

  .row-label .zone-name {
    font-size: 0.55rem;
    max-width: 55px;
  }

  .row-label .row-id {
    font-size: 0.5rem;
  }

  .cellar-row,
  .fridge-row {
    flex-wrap: nowrap;
  }

  /* Wine list filters */
  .wine-list-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .wine-list-filters .filter-group {
    width: 100%;
  }

  .wine-list-filters select {
    flex: 1;
  }

  .wine-list-filters .search-group {
    width: 100%;
  }

  /* Wine list */
  .wine-list {
    grid-template-columns: 1fr;
  }

  .wine-list.virtual-mode {
    height: calc(100vh - 320px);
    min-height: 300px;
  }

  /* Modals */
  .modal {
    width: 95%;
    max-height: 85vh;
    padding: 1rem;
  }

  .modal-actions {
    flex-wrap: wrap;
  }

  .modal-actions .btn {
    flex: 1 1 auto;
    min-width: 80px;
  }
}

/* Mobile (480px and below) */
@media (max-width: 480px) {
  body {
    font-size: 1rem;
  }

  /* Show hamburger menu */
  .mobile-menu-btn {
    display: flex;
  }

  .tabs {
    position: relative;
  }

  .tabs-container {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
    margin-top: 0.5rem;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  }

  .tabs-container.open {
    display: flex;
  }

  .tab {
    width: 100%;
    text-align: center;
    padding: 0.9rem;
    font-size: 1rem;
  }

  /* Grid - keep readable size, horizontal scroll */
  .cellar-grid,
  .fridge-grid {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 3px;
  }

  .cellar-row,
  .fridge-row {
    gap: 3px;
    flex-wrap: nowrap;
  }

  .slot {
    width: 75px;
    height: 48px;
    padding: 3px;
    flex-shrink: 0;
  }

  .slot-name {
    font-size: 0.7rem;
    -webkit-line-clamp: 2;
  }

  .slot-vintage {
    font-size: 0.6rem;
  }

  .slot-loc {
    font-size: 0.55rem;
  }

  .row-label {
    width: 50px;
    min-width: 50px;
    font-size: 0.6rem;
    flex-shrink: 0;
  }

  .row-label .zone-name {
    font-size: 0.5rem;
    max-width: 45px;
  }

  .row-label .row-id {
    font-size: 0.45rem;
  }

  /* Zone headers */
  .zone-title {
    font-size: 1rem;
  }

  .fridge-section {
    padding: 0.75rem;
  }

  /* Stats */
  .stat-value {
    font-size: 1.2rem;
  }

  .stat-label {
    font-size: 0.8rem;
  }

  /* Wine list stats */
  .wine-list-stats {
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.9rem;
  }

  /* Wine cards */
  .wine-card {
    padding: 0.75rem;
  }

  .wine-count {
    font-size: 1.3rem;
    min-width: 30px;
  }

  .wine-name {
    font-size: 1rem;
  }

  .wine-meta {
    font-size: 0.9rem;
  }

  /* Pairing view */
  .natural-pairing {
    padding: 1rem;
  }

  .natural-pairing input[type="text"] {
    font-size: 1rem;
    padding: 0.9rem 1rem;
  }

  .signal-grid {
    gap: 0.5rem;
  }

  .signal-btn {
    padding: 0.5rem 0.9rem;
    font-size: 0.9rem;
  }

  /* History */
  .history-item {
    flex-direction: column;
    gap: 0.5rem;
  }

  .history-date {
    align-self: flex-start;
    font-size: 0.9rem;
  }

  .history-wine {
    font-size: 1rem;
  }

  .history-meta,
  .history-occasion,
  .history-pairing,
  .history-notes {
    font-size: 0.9rem;
  }

  .history-rating {
    align-self: flex-start;
  }

  /* Buttons */
  .btn {
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
  }

  /* Reduce list */
  .reduce-name {
    font-size: 1rem;
  }

  .reduce-meta {
    font-size: 0.9rem;
  }

  .reduce-locations {
    font-size: 0.85rem;
  }

  /* Modal fields */
  .modal-field label {
    font-size: 0.85rem;
  }

  .modal-field span {
    font-size: 1rem;
  }

  /* Form fields */
  .form-field label,
  .form-label {
    font-size: 0.85rem;
  }

  .form-field input,
  .form-field select {
    font-size: 1rem;
    padding: 0.7rem 0.9rem;
  }

  /* Toast */
  .toast {
    left: 1rem;
    right: 1rem;
    transform: translateY(100px);
    width: auto;
    font-size: 1rem;
  }

  .toast.show {
    transform: translateY(0);
  }
}

/* Very small screens (360px and below) */
@media (max-width: 360px) {
  /* Keep slots readable - scroll instead of shrinking */
  .slot {
    width: 70px;
    height: 45px;
  }

  .slot-name {
    font-size: 0.65rem;
  }

  .row-label {
    width: 40px;
    min-width: 40px;
    font-size: 0.55rem;
  }

  .row-label .zone-name {
    display: none;
  }

  .row-label .row-id {
    font-size: 0.55rem;
  }

  header h1 {
    font-size: 1.25rem;
  }

  .stats {
    gap: 0.5rem;
  }

  .stat-value {
    font-size: 1.1rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  .tab {
    font-size: 0.95rem;
    padding: 0.8rem;
  }

  .btn {
    font-size: 0.85rem;
  }
}

/* Responsive Settings */
@media (max-width: 600px) {
  .settings-rule {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .credential-inputs {
    flex-direction: column;
  }

  .preference-labels span:nth-child(2) {
    display: none;
  }

  .manual-window-entry {
    flex-direction: column;
    align-items: flex-start;
  }

  .window-entry {
    flex-wrap: wrap;
  }

  .window-status {
    margin-left: 0;
    margin-top: 0.25rem;
  }
}

/* ============================================
   Awards Database Styles
   ============================================ */

.awards-import-section {
  margin-bottom: 2rem;
}

.awards-import-form {
  background: var(--bg-slot);
  border-radius: 6px;
  padding: 1rem;
}

.import-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.import-row .form-field {
  flex: 1;
}

.import-row .form-field:last-child {
  flex: 0 0 100px;
}

.import-row label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
}

.import-row select,
.import-row input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.9rem;
}

.import-row select:focus,
.import-row input:focus {
  border-color: var(--accent);
  outline: none;
}

.import-type-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.import-tab {
  flex: 1;
  padding: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.import-tab:hover {
  background: var(--bg-slot-hover);
  color: var(--text);
}

.import-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text);
}

.import-input-area {
  margin-bottom: 1rem;
}

.import-input-area label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
}

.import-input-area input[type="url"],
.import-input-area input[type="file"],
.import-input-area textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.9rem;
}

.import-input-area input:focus,
.import-input-area textarea:focus {
  border-color: var(--accent);
  outline: none;
}

.import-input-area textarea {
  resize: vertical;
  min-height: 100px;
}

.import-input-area input[type="file"] {
  padding: 0.35rem 0.5rem;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.import-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-card);
  border-radius: 4px;
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.progress-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* PDF Files List (multi-select) */
.pdf-files-list {
  margin-top: 0.75rem;
}

.pdf-files-header {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.pdf-file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--bg-slot);
  border-radius: 4px;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}

.pdf-file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 0.5rem;
}

.pdf-file-year {
  font-size: 0.8rem;
  white-space: nowrap;
}

.pdf-file-year.detected {
  color: #81c784;
}

.pdf-file-year.missing {
  color: #ffb74d;
}

/* Award Sources List */
.awards-sources-list {
  margin-top: 0.5rem;
}

.awards-source-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg-slot);
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.source-info-main {
  flex: 1;
}

.source-name {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

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

.source-stats {
  display: flex;
  gap: 1rem;
  align-items: center;
  font-size: 0.85rem;
}

.source-stats .stat-matched {
  color: #81c784;
}

.source-stats .stat-unmatched {
  color: var(--text-muted);
}

.source-actions {
  display: flex;
  gap: 0.5rem;
}

/* Unmatched Awards */
.awards-unmatched-list {
  margin-top: 0.5rem;
}

.award-unmatched-item {
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  background: var(--bg-slot);
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.award-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.award-wine-name {
  font-weight: 500;
}

.award-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.award-badge.gold {
  background: rgba(212, 175, 55, 0.2);
  color: var(--sparkling);
}

.award-badge.silver {
  background: rgba(192, 192, 192, 0.2);
  color: #c0c0c0;
}

.award-badge.bronze {
  background: rgba(205, 127, 50, 0.2);
  color: #cd7f32;
}

.award-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.award-matches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.match-suggestion {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  background: var(--bg-card);
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.match-suggestion:hover {
  border-color: var(--accent);
  background: var(--bg-slot-hover);
}

.match-score {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.no-data {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
  padding: 0.5rem;
}

/* Local Awards Display in Wine Modal */
.local-awards-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.local-awards-title {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.local-awards-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.local-award-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem;
  background: var(--bg-slot);
  border-radius: 4px;
  font-size: 0.85rem;
}

.local-award-badge {
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
}

.local-award-badge.award-trophy {
  background: rgba(156, 39, 176, 0.2);
  color: #ce93d8;
}

.local-award-badge.award-double-gold {
  background: rgba(255, 215, 0, 0.25);
  color: #ffd700;
}

.local-award-badge.award-gold {
  background: rgba(212, 175, 55, 0.2);
  color: var(--sparkling);
}

.local-award-badge.award-silver {
  background: rgba(192, 192, 192, 0.2);
  color: #d0d0d0;
}

.local-award-badge.award-bronze {
  background: rgba(205, 127, 50, 0.2);
  color: #cd7f32;
}

.local-award-comp {
  color: var(--text);
}

.local-award-category {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Mobile adjustments for awards */
@media (max-width: 600px) {
  .import-row {
    flex-direction: column;
  }

  .import-row .form-field:last-child {
    flex: 1;
  }

  .import-type-tabs {
    flex-wrap: wrap;
  }

  .import-tab {
    flex: 1 1 calc(33% - 0.5rem);
    text-align: center;
  }

  .source-stats {
    flex-direction: column;
    gap: 0.25rem;
    align-items: flex-end;
  }

  .awards-source-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .source-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .local-awards-list {
    flex-direction: column;
  }
}

/* ============================================
   BACKUP & EXPORT
   ============================================ */

.backup-stats {
  display: flex;
  gap: 1.5rem;
  margin: 1rem 0;
  padding: 1rem;
  background: var(--bg-slot);
  border-radius: 8px;
}

.backup-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.backup-stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
}

.backup-stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.backup-export-section,
.backup-import-section {
  margin-top: 1.5rem;
}

.backup-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.backup-buttons .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.import-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* Mobile adjustments for backup */
@media (max-width: 600px) {
  .backup-stats {
    gap: 1rem;
  }

  .backup-stat-value {
    font-size: 1.25rem;
  }

  .backup-buttons {
    flex-direction: column;
  }

  .backup-buttons .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Screen reader only - visually hidden but accessible */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link for keyboard navigation */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent);
  color: var(--text);
  padding: 0.5rem 1rem;
  z-index: 10000;
  text-decoration: none;
  font-weight: 500;
  border-radius: 0 0 4px 0;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* Focus visible styles for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Remove default focus for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: #666;
    --text-muted: #aaa;
  }

  .btn {
    border: 2px solid currentColor;
  }

  .slot {
    border: 1px solid var(--text-muted);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================
   GLOBAL SEARCH
   ============================================ */

.global-search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 15vh;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
}

.global-search-overlay.active {
  opacity: 1;
  visibility: visible;
}

.global-search-modal {
  width: 100%;
  max-width: 600px;
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  transform: translateY(-20px);
  transition: transform 0.15s;
}

.global-search-overlay.active .global-search-modal {
  transform: translateY(0);
}

.global-search-input-wrapper {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: 0.75rem;
}

.global-search-input-wrapper .search-icon {
  font-size: 1.25rem;
  opacity: 0.6;
}

.global-search-input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 1.1rem;
  color: var(--text);
  outline: none;
}

.global-search-input::placeholder {
  color: var(--text-muted);
}

.search-shortcut {
  background: var(--bg-slot);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: inherit;
}

.global-search-results {
  max-height: 400px;
  overflow-y: auto;
}

.search-section {
  padding: 0.5rem 0;
}

.search-section-title {
  padding: 0.5rem 1.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  transition: background 0.1s;
}

.search-result-item:hover,
.search-result-item.selected {
  background: var(--bg-slot-hover);
}

.search-result-item .result-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.search-result-item .result-colour {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.search-result-item .result-colour.red { background: var(--red-wine); }
.search-result-item .result-colour.white { background: var(--white-wine); }
.search-result-item .result-colour.rose { background: var(--rose-wine); }
.search-result-item .result-colour.sparkling { background: var(--sparkling); }

.search-result-item .result-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.search-result-item .result-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-item .result-name mark {
  background: var(--accent);
  color: var(--bg-dark);
  padding: 0 2px;
  border-radius: 2px;
}

.search-result-item .result-vintage {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.search-result-item .result-label {
  flex: 1;
}

.search-result-item .result-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.search-result-item .result-stars {
  color: var(--accent);
}

.search-result-item .result-count {
  opacity: 0.7;
}

.search-empty {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--text-muted);
}

.search-empty .search-hint {
  font-size: 0.85rem;
  margin-top: 0.5rem;
  opacity: 0.7;
}

.search-error {
  padding: 1rem 1.25rem;
  color: var(--priority-1);
  text-align: center;
}

/* Wine card highlight animation */
.wine-card.highlight-pulse {
  animation: highlight-pulse 0.5s ease-out 3;
}

@keyframes highlight-pulse {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 3px var(--accent); }
}

/* Search trigger button in header */
.search-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-slot);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s, border-color 0.15s;
}

.search-trigger:hover {
  background: var(--bg-slot-hover);
  border-color: var(--text-muted);
}

.search-trigger kbd {
  background: var(--bg-dark);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.75rem;
}

/* Mobile adjustments */
@media (max-width: 600px) {
  .global-search-overlay {
    padding-top: 5vh;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .global-search-modal {
    max-width: none;
  }

  .search-shortcut {
    display: none;
  }

  .search-trigger kbd {
    display: none;
  }
}

/* ============================================
   PWA Update Notification & Install Button
   ============================================ */

.update-notification {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 10000;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.update-notification span {
  color: var(--text);
  font-size: 0.95rem;
}

/* Install app button (shown in settings or header) */
#install-app-btn {
  display: none; /* Hidden by default, shown via JS when installable */
}

/* PWA standalone mode adjustments */
@media (display-mode: standalone) {
  /* Add padding for notch/safe areas on mobile */
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  /* Hide install button when already installed */
  #install-app-btn {
    display: none !important;
  }
}

/* Offline indicator */
.offline-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--priority-2);
  color: white;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.85rem;
  z-index: 9999;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.offline-indicator.visible {
  transform: translateY(0);
}

/* Mobile-first PWA improvements */
@media (max-width: 600px) {
  .update-notification {
    left: 1rem;
    right: 1rem;
    transform: none;
    flex-direction: column;
    text-align: center;
  }

  @keyframes slideUp {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}
