:root {
  --wine-primary: #722F37;
  --wine-dark: #4A1C23;
  --wine-light: #8B4049;
  --wine-accent: #C9A227;
  --cream: #FAF8F5;
  --cream-dark: #F0EDE8;
  --text-dark: #2D2D2D;
  --text-muted: #6B6B6B;
  --border-subtle: rgba(0,0,0,0.08);
  --shadow-soft: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-medium: 0 4px 16px rgba(0,0,0,0.1);
  --header-height: 60px;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  width: 100%;
}

body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: linear-gradient(135deg, var(--wine-dark) 0%, var(--wine-primary) 100%);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: 0 1rem;
  gap: 1rem;
  z-index: 1000;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.top-header h1 {
  margin: 0;
  font-size: 1.4rem;
  color: white;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-align: center;
}

.top-header .menu-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  padding: 0.5rem 1rem;
  height: 40px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.top-header .add-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 1.8rem;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.top-header .menu-btn:hover,
.top-header .add-btn:hover {
  background: rgba(255,255,255,0.2);
}

.top-header #authSection a[role="button"] {
  background: var(--wine-accent);
  color: var(--wine-dark);
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
}

.top-header #authSection a[role="button"]:hover {
  background: #D4AD2F;
  transform: translateY(-1px);
}

.top-header #authSection span {
  color: rgba(255,255,255,0.9);
  margin-right: 0.75rem;
  font-size: 0.9rem;
}

.top-header #authSection a.secondary {
  background: rgba(255,255,255,0.15);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  text-decoration: none;
}

.app-layout {
  display: flex;
  position: relative;
  min-height: calc(100vh - var(--header-height));
  margin-top: var(--header-height);
}

.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--cream-dark);
  border-right: 1px solid var(--border-subtle);
  padding: 1.25rem;
  overflow-y: auto;
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, width 0.3s ease, min-width 0.3s ease, padding 0.3s ease;
}

.sidebar.hidden {
  width: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  opacity: 0;
}

.sidebar-actions {
  margin-bottom: 1.25rem;
}

.sidebar-actions button {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  border-radius: 8px;
  font-weight: 600;
  background: var(--wine-primary);
  color: white;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sidebar-actions button:hover {
  background: var(--wine-dark);
  transform: translateY(-1px);
}

.sidebar-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 1rem 0;
}

.sidebar h5 {
  margin: 0 0 1rem 0;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}

#sidebarLoginPrompt {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

#sidebarLoginPrompt a {
  color: var(--wine-primary);
  font-weight: 500;
}

.main-content {
  flex: 1;
  padding: 2rem 3rem;
  max-width: 760px;
  margin: 0 auto;
  background: var(--cream);
}

.main-content h2 {
  font-size: 1.1rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--wine-primary);
  color: var(--wine-primary);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.main-content h2:first-of-type {
  margin-top: 0;
}

.login-prompt {
  background: linear-gradient(135deg, rgba(114,47,55,0.08) 0%, rgba(201,162,39,0.08) 100%);
  padding: 1rem 1.25rem;
  border-radius: 10px;
  margin-bottom: 1.5rem;
  border-left: 3px solid var(--wine-accent);
}

.prediction-note {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
  margin: 0 0 1rem 0;
}

.login-prompt p {
  margin: 0;
  color: var(--text-dark);
  font-size: 0.95rem;
}

.login-prompt a {
  color: var(--wine-primary);
  font-weight: 500;
}

form label {
  display: block;
  margin-bottom: 1rem;
  color: var(--text-dark);
  font-size: 0.9rem;
  font-weight: 500;
}

form select,
form input[type="text"],
form input[type="number"],
form textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: white;
  font-size: 0.95rem;
  color: #000000;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-soft);
  margin-top: 0.35rem;
}

form select option {
  color: #000000;
  background: white;
}

form select:focus,
form input:focus,
form textarea:focus {
  outline: none;
  border-color: var(--wine-primary);
  box-shadow: 0 0 0 3px rgba(114,47,55,0.1);
}

form textarea {
  min-height: 80px;
  resize: vertical;
}

form button[type="submit"] {
  background: linear-gradient(135deg, var(--wine-primary) 0%, var(--wine-dark) 100%);
  color: white;
  border: none;
  padding: 1rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  width: 100%;
  margin-top: 1rem;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-medium);
}

form button[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(114,47,55,0.3);
}

form button[type="submit"]:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

hr {
  border: none;
  height: 1px;
  background: var(--border-subtle);
  margin: 2rem 0;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

article {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-subtle);
  margin-bottom: 1rem;
}

article h4 {
  margin: 0 0 1rem 0;
  color: var(--wine-primary);
  font-size: 1.1rem;
}

article h5 {
  margin: 1rem 0 0.5rem 0;
  color: #000000;
  font-size: 0.95rem;
}

article ul {
  margin: 0;
  padding-left: 1.25rem;
}

article li {
  margin-bottom: 0.35rem;
  color: #000000;
}

article p {
  color: #000000;
}

button.secondary {
  background: white;
  color: var(--wine-primary);
  border: 2px solid var(--wine-primary);
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

button.secondary:hover {
  background: var(--wine-primary);
  color: white;
}

details {
  background: var(--cream-dark);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}

details summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--text-dark);
}

details[open] summary {
  margin-bottom: 0.75rem;
}

.sidebar-history-card {
  padding: 0.875rem;
  margin-bottom: 0.5rem;
  background: white;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-soft);
}

.sidebar-history-card:hover {
  border-color: var(--wine-primary);
  transform: translateX(4px);
  box-shadow: var(--shadow-medium);
}

.sidebar-history-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.375rem;
}

.sidebar-history-card .wine-type {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-dark);
}

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

.sidebar-history-card .prediction {
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  color: var(--text-muted);
}

.sidebar-history-card .match-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.match-badge.exact {
  background: #27AE60;
  color: white;
}

.match-badge.close {
  background: var(--wine-accent);
  color: var(--wine-dark);
}

.match-badge.wrong {
  background: #E8E8E8;
  color: #666;
}

.history-card {
  margin-bottom: 1rem;
}

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

.match-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.match-exact {
  color: #27AE60;
}

.match-close {
  color: var(--wine-accent);
}

.match-wrong {
  color: #E74C3C;
}

.tasting-details {
  padding: 1rem;
  background: var(--cream-dark);
  border-radius: 8px;
}

.tasting-details h6 {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  color: var(--wine-primary);
}

.autocomplete-container {
  position: relative;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border-subtle);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  display: none;
  box-shadow: var(--shadow-medium);
}

.autocomplete-dropdown.visible {
  display: block;
}

.autocomplete-item {
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-dark);
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.15s ease;
}

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

.autocomplete-item:hover,
.autocomplete-item.highlighted {
  background: var(--cream-dark);
}

.autocomplete-item .match {
  color: var(--wine-primary);
  font-weight: 600;
}

.section-note {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
  margin: 0 0 1.5rem 0;
}

#actualBottleSection {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 2px solid var(--wine-primary);
}

.actual-bottle-form {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-subtle);
}

.actual-bottle-form label {
  display: block;
  margin-bottom: 1rem;
  color: var(--text-dark);
  font-size: 0.9rem;
  font-weight: 500;
}

.actual-bottle-form input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--cream);
  font-size: 0.95rem;
  color: var(--text-dark);
  transition: all 0.2s ease;
  margin-top: 0.35rem;
}

.actual-bottle-form input:focus {
  outline: none;
  border-color: var(--wine-primary);
  box-shadow: 0 0 0 3px rgba(114,47,55,0.1);
  background: white;
}

.actual-bottle-form button {
  margin-top: 1rem;
  width: 100%;
}

.recap-article {
  margin-top: 1.5rem;
  background: linear-gradient(135deg, rgba(114,47,55,0.05) 0%, rgba(201,162,39,0.05) 100%);
  border-left: 4px solid var(--wine-accent);
}

.recap-article h4 {
  color: var(--wine-dark);
}

.recap-article p {
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

.recap-article ul {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}

.recap-article li {
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    z-index: 999;
    background: var(--cream-dark);
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
  }
  
  .sidebar.hidden {
    transform: translateX(-100%);
    width: 280px;
    min-width: 280px;
    padding: 1.25rem;
  }
  
  .main-content {
    padding: 1.5rem;
  }
  
  .grid {
    grid-template-columns: 1fr;
  }
  
  .top-header h1 {
    font-size: 1.2rem;
  }
}
