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

:root {
  --wine-red: #722F37;
  --wine-dark: #4A1C24;
  --wine-light: #A45A64;
  --gold: #C9A84C;
  --gold-light: #E8D5A3;
  --bg: #1A1A2E;
  --bg-card: #16213E;
  --bg-card-hover: #1A2744;
  --text: #E8E8E8;
  --text-muted: #9A9AB0;
  --border: #2A2A4A;
  --white: #FFFFFF;
  --green: #4CAF50;
  --orange: #FF9800;
  --red-badge: #E53935;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  background: linear-gradient(135deg, var(--wine-dark), var(--wine-red));
  padding: 1.5rem 2rem;
  border-bottom: 2px solid var(--gold);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
}

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

h1 {
  font-size: 1.8rem;
  color: var(--gold-light);
  letter-spacing: 0.5px;
}

.sync-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sync-indicator {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
}

.sync-live {
  background: rgba(76, 175, 80, 0.2);
  color: #81C784;
}

.sync-offline {
  background: rgba(255, 152, 0, 0.2);
  color: #FFB74D;
}

.sync-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--gold-light);
  font-size: 1.2rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.sync-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sync-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.download-wrapper {
  position: relative;
}

.download-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  z-index: 100;
  min-width: 100px;
}

.download-menu.open {
  display: block;
}

.download-menu button {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
}

.download-menu button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.stats {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.stat {
  text-align: center;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--gold-light);
  text-transform: uppercase;
  letter-spacing: 1px;
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

.controls {
  margin-bottom: 1.5rem;
}

.search-bar {
  margin-bottom: 1rem;
}

.search-bar input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input:focus {
  border-color: var(--gold);
}

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

.filters select {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
  min-width: 160px;
}

.filters select:focus {
  border-color: var(--gold);
}

.results-info {
  padding: 0.5rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.wine-grid {
  /* container for table or card grid */
}

.wine-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  transition: transform 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.wine-card:hover {
  transform: translateY(-2px);
  border-color: var(--wine-light);
}

.wine-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.wine-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--white);
  line-height: 1.3;
  flex: 1;
}

.wine-vintage {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
}

.wine-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge {
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-rouge { background: rgba(114, 47, 55, 0.6); color: #F4A0A8; }
.badge-blanc { background: rgba(201, 168, 76, 0.3); color: var(--gold-light); }
.badge-rose { background: rgba(255, 152, 0, 0.3); color: #FFB74D; }
.badge-orange { background: rgba(255, 120, 0, 0.3); color: #FFAB76; }
.badge-bottles {
  background: rgba(76, 175, 80, 0.2);
  color: var(--green);
}

.wine-origin {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.wine-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.wine-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
}

.wine-maturity {
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
}

.maturity-not-ready {
  background: rgba(33, 150, 243, 0.2);
  color: #64B5F6;
}

.maturity-ready {
  background: rgba(76, 175, 80, 0.2);
  color: #81C784;
}

.maturity-peak {
  background: rgba(76, 175, 80, 0.4);
  color: #A5D6A7;
  font-weight: 700;
}

.maturity-past {
  background: rgba(229, 57, 53, 0.2);
  color: #EF9A9A;
}

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

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

/* View toggle */
.view-toggle {
  display: flex;
  gap: 2px;
  margin-left: auto;
}

.view-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}

.view-btn:first-child { border-radius: 8px 0 0 8px; }
.view-btn:last-child { border-radius: 0 8px 8px 0; }

.view-btn.active {
  background: var(--wine-red);
  color: var(--white);
  border-color: var(--wine-red);
}

/* Card grid wrapper */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

/* Table styles */
.table-wrapper {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.wine-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.wine-table thead {
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 10;
}

.wine-table th {
  padding: 0.75rem 0.75rem;
  text-align: left;
  font-weight: 600;
  color: var(--gold-light);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.th-sortable {
  cursor: pointer;
  user-select: none;
}

.th-sortable:hover {
  color: var(--gold);
}

.th-center { text-align: center; }
.th-right { text-align: right; }

.sort-arrows {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  margin-right: 0.3rem;
  line-height: 0;
  gap: 1px;
}

.arrow-up, .arrow-down {
  font-size: 0.5rem;
  color: var(--text-muted);
  opacity: 0.3;
  line-height: 1;
}

.arrow-up.active, .arrow-down.active {
  color: var(--gold);
  opacity: 1;
}

.wine-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.wine-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.wine-table td {
  padding: 0.6rem 0.75rem;
  vertical-align: middle;
}

.td-name {
  font-weight: 500;
  color: var(--white);
  max-width: 300px;
}

.td-center { text-align: center; }
.td-right { text-align: right; }
.td-price { color: var(--gold); font-weight: 600; }

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

.format-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(255,255,255,0.05);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

.badge-sm {
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.maturity-pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  white-space: nowrap;
}

.maturity-years {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Login screen */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-box h2 {
  color: var(--gold-light);
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}

.login-box input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  margin-bottom: 1rem;
}

.login-box input:focus {
  border-color: var(--gold);
}

.login-box button {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--wine-dark), var(--wine-red));
  color: var(--gold-light);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.login-box button:hover {
  opacity: 0.9;
}

.login-error {
  color: var(--red-badge);
  font-size: 0.85rem;
  margin-top: 0.75rem;
  min-height: 1.2em;
}

/* API section */
.api-section {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.api-section h3 {
  color: var(--gold-light);
  font-size: 1rem;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.api-url-box {
  margin-bottom: 0.75rem;
}

.api-url-box label {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.3rem;
}

.api-url-row {
  display: flex;
  gap: 0.5rem;
}

.api-url-row input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  font-family: monospace;
  outline: none;
}

.api-url-row button, .rotate-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.api-url-row button:hover, .rotate-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.rotate-btn {
  margin-top: 0.5rem;
  border-color: var(--wine-light);
  color: var(--wine-light);
}

/* Header title group */
.header-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  white-space: nowrap;
}

.user-badge-cellar {
  background: rgba(139, 69, 69, 0.3);
  color: var(--wine-light);
  border: 1px solid var(--wine-red);
}

.user-badge-saq {
  background: rgba(42, 31, 94, 0.3);
  color: #B39DDB;
  border: 1px solid #4a3080;
}

/* SAQ search section */
.saq-section {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 2rem;
}

.saq-search-controls {
  margin-bottom: 1rem;
}

.saq-search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.saq-search-bar input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 1rem;
}

.saq-search-bar input:focus {
  outline: none;
  border-color: var(--gold);
}

.saq-search-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #2a1f5e, #4a3080);
  color: var(--gold-light);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.saq-search-btn:hover {
  opacity: 0.9;
}

.saq-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.saq-filters select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.9rem;
}

.saq-results-info {
  padding: 0.25rem 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  min-height: 1.5rem;
}

.saq-store-warning {
  color: var(--orange);
}

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

.saq-empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.saq-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.saq-card {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  transition: border-color 0.2s;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.saq-card:hover {
  border-color: var(--gold);
}

.saq-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.saq-card-name {
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.3;
  flex: 1;
}

.saq-card-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
}

.saq-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.saq-card-vintage {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.saq-pastille {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  background: rgba(76, 175, 80, 0.15);
  color: #81C784;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.saq-card-grape {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

.saq-card-origin {
  font-size: 0.85rem;
  color: var(--text-muted);
}

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

.saq-card-avail {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.saq-avail-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 500;
}

.saq-avail-online {
  background: rgba(76, 175, 80, 0.2);
  color: #81C784;
}

.saq-avail-store {
  background: rgba(66, 165, 245, 0.2);
  color: #64B5F6;
}

.saq-avail-mystore {
  background: rgba(186, 104, 200, 0.2);
  color: #CE93D8;
}

.saq-avail-other {
  background: rgba(158, 158, 158, 0.2);
  color: #BDBDBD;
}

.saq-card-link {
  font-size: 0.8rem;
  color: var(--gold);
  text-decoration: none;
  white-space: nowrap;
}

.saq-card-link:hover {
  text-decoration: underline;
}

/* SAQ store selector in profile */
.saq-store-autocomplete {
  position: relative;
  margin-top: 0.5rem;
}
.saq-store-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.9rem;
  box-sizing: border-box;
}
.saq-store-input:focus { border-color: var(--accent); outline: none; }
.saq-store-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  z-index: 50;
}
.saq-store-dropdown.open { display: block; }
.saq-store-option {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.saq-store-option:hover, .saq-store-option.active {
  background: var(--accent);
  color: #fff;
}
.saq-store-option .store-banner {
  font-size: 0.75rem;
  opacity: 0.6;
  margin-left: 0.3rem;
}
.saq-store-group-label {
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent);
  letter-spacing: 0.04em;
  pointer-events: none;
}

.saq-store-saved {
  font-size: 0.85rem;
  color: var(--green);
  margin-top: 0.25rem;
}

.profile-store-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

@media (max-width: 600px) {
  .saq-card-grid {
    grid-template-columns: 1fr;
  }
  .saq-search-bar {
    flex-direction: column;
  }
}

/* Floating action buttons */
.fab-group {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 900;
  align-items: center;
}

.fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  color: var(--gold-light);
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.fab-chat {
  background: linear-gradient(135deg, var(--wine-dark), var(--wine-red));
}

.fab-profile {
  background: linear-gradient(135deg, #2a1f5e, #4a3080);
  width: 48px;
  height: 48px;
  font-size: 1.3rem;
}

.fab-icon {
  line-height: 1;
}

/* Profile panel */
.profile-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 950;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.profile-panel.open {
  transform: translateX(0);
}

.profile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #2a1f5e, #4a3080);
  border-bottom: 2px solid var(--gold);
  flex-shrink: 0;
}

.profile-header h3 {
  color: var(--gold-light);
  font-size: 1.1rem;
  margin: 0;
}

.panel-close {
  background: none;
  border: none;
  color: var(--gold-light);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.panel-close:hover {
  opacity: 1;
}

.profile-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.profile-intro {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.profile-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

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

.profile-section h4 {
  color: var(--gold-light);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
}

.profile-section-header h4 {
  margin-bottom: 0;
}

.pref-count {
  background: var(--wine-red);
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.4rem;
}

.pref-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pref-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 0.5rem;
}

.pref-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.4;
  transition: border-color 0.15s;
}

.pref-chip:hover {
  border-color: var(--wine-light);
}

.pref-chip-text {
  flex: 1;
}

.pref-chip-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s;
}

.pref-chip-delete:hover {
  color: var(--red-badge);
}

.cepage-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.cepage-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(76, 175, 80, 0.12);
  border: 1px solid rgba(76, 175, 80, 0.3);
  border-radius: 20px;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  color: #81C784;
  transition: border-color 0.15s;
}

.cepage-chip:hover {
  border-color: var(--green);
}

.cepage-chip-delete {
  background: none;
  border: none;
  color: rgba(129, 199, 132, 0.5);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}

.cepage-chip-delete:hover {
  color: var(--red-badge);
}

.cepage-count {
  background: var(--green);
}

.cepage-add-btn {
  background: linear-gradient(135deg, #2d5a2e, #4CAF50);
}

.pref-add-form {
  display: flex;
  gap: 0.5rem;
}

.pref-add-form input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
}

.pref-add-form input:focus {
  border-color: var(--gold);
}

.pref-add-btn {
  background: linear-gradient(135deg, #2a1f5e, #4a3080);
  border: none;
  color: var(--gold-light);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.pref-add-btn:hover {
  opacity: 0.85;
}

.profile-guide-section {
  border-color: rgba(74, 48, 128, 0.4);
  background: rgba(42, 31, 94, 0.15);
}

.profile-guide-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.profile-guide-btn {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #2a1f5e, #4a3080);
  color: var(--gold-light);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.profile-guide-btn:hover {
  opacity: 0.9;
}

/* Guide chat inside profile panel */
.profile-header-guide {
  background: linear-gradient(135deg, #2a1f5e, #4a3080);
}

.guide-back-btn {
  background: none;
  border: none;
  color: var(--gold-light);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  opacity: 0.8;
  transition: opacity 0.15s;
  line-height: 1;
}

.guide-back-btn:hover {
  opacity: 1;
}

.guide-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.guide-chat-form {
  border-top: 1px solid rgba(74, 48, 128, 0.4);
}

.guide-chat-send {
  background: linear-gradient(135deg, #2a1f5e, #4a3080);
}

.chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 950;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.chat-panel.open {
  transform: translateX(0);
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, var(--wine-dark), var(--wine-red));
  border-bottom: 2px solid var(--gold);
  flex-shrink: 0;
}

.chat-header h3 {
  color: var(--gold-light);
  font-size: 1.1rem;
  margin: 0;
}

/* .panel-close is used for both panels (defined above) */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-bubble {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  max-width: 90%;
  word-wrap: break-word;
}

.chat-bubble-user {
  background: var(--wine-red);
  color: var(--white);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-bubble-ai {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-bubble-ai strong {
  color: var(--gold);
}

.chat-typing {
  color: var(--text-muted);
  font-style: italic;
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
}

.chat-form input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

.chat-form input:focus {
  border-color: var(--gold);
}

.chat-send {
  background: linear-gradient(135deg, var(--wine-dark), var(--wine-red));
  border: none;
  color: var(--gold-light);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.chat-send:hover {
  opacity: 0.85;
}

.chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  header {
    padding: 1rem;
  }

  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  h1 {
    font-size: 1.4rem;
  }

  main {
    padding: 1rem;
  }

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

  .wine-table { font-size: 0.8rem; }
  .wine-table th, .wine-table td { padding: 0.5rem; }

  .filters select {
    min-width: 0;
    flex: 1;
  }

  .chat-panel,
  .profile-panel {
    width: 100%;
  }

  .fab-group {
    bottom: 1rem;
    right: 1rem;
  }

  .fab-chat {
    width: 48px;
    height: 48px;
    font-size: 1.3rem;
  }

  .fab-profile {
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
  }
}
