@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #FAF8F4;
  --surface: #FFFFFF;
  --surface-dim: #F1ECE2;
  --border: rgba(43,38,32,0.10);
  --ink: #2B2620;
  --ink-soft: rgba(43,38,32,0.6);
  --ink-faint: rgba(43,38,32,0.4);
  --primary: #7A2E3D;
  --primary-soft: rgba(122,46,61,0.08);
  --grape: #7C6A9C;
  --gold: #C79C5E;
  --sage: #5C7A52;
  --rust: #C1653A;
  --garnet: #9C3347;
  --shadow-sm: 0 1px 2px rgba(43,38,32,0.06);
  --shadow-md: 0 4px 16px rgba(43,38,32,0.08);
  --shadow-lg: 0 12px 32px rgba(43,38,32,0.14);
}

* { box-sizing: border-box; }

html, body { overflow-x: hidden; width: 100%; }

body {
  margin: 0;
  background: var(--bg);
  font-family: 'Inter', sans-serif;
  color: var(--ink);
  overflow-x: hidden;
}

.page { max-width: 760px; margin: 0 auto; padding: 28px 20px 60px; }

.header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 4px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.brand-logo { width: 40px; height: 40px; flex-shrink: 0; }

.header h1 {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}
.brand-domain {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--ink-faint);
  letter-spacing: 0.3px; margin-top: 1px;
}
.tagline { color: var(--ink-soft); font-size: 13.5px; margin: 0 0 22px; }

.user-block { position: relative; text-align: right; flex-shrink: 0; }
.user-block-trigger {
  display: flex; align-items: center; gap: 8px; background: none; border: none;
  cursor: pointer; padding: 0; font-family: 'Fraunces', serif; font-size: 26px;
  font-weight: 600; color: var(--ink); max-width: 100%;
}
.user-block-trigger span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottle-count-label {
  font-family: 'Fraunces', serif; font-size: 26px; font-weight: 600;
  color: var(--ink); opacity: 0.4; margin-top: 2px;
}
.avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--primary-soft);
  color: var(--primary); font-size: 11px; font-weight: 700; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.account-dropdown {
  display: none; position: absolute; top: calc(100% + 8px); right: 0; width: 240px;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
  border: 1px solid var(--border); overflow: hidden; z-index: 50;
}
.account-dropdown.open { display: block; }
.dropdown-head { padding: 14px; border-bottom: 1px solid var(--border); }
.dd-name { font-weight: 600; font-size: 13.5px; }
.dd-email { font-size: 11.5px; color: var(--ink-faint); }
.dropdown-section { padding: 8px; display: flex; flex-direction: column; }
.dropdown-section a {
  padding: 8px; border-radius: 8px; font-size: 13px; color: var(--ink);
  text-decoration: none;
}
.dropdown-section a:hover { background: var(--surface-dim); }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.tab {
  padding: 8px 16px; border-radius: 999px; font-family: 'Inter', sans-serif;
  font-weight: 600; font-size: 13px; text-decoration: none; color: var(--ink-soft);
}
.tab.active { background: var(--primary); color: #fff; }

.card { background: var(--surface); border-radius: 16px; padding: 20px; min-height: 300px; box-shadow: var(--shadow-md); border: 1px solid var(--border); }
.card-search { min-height: 150px; }
.load-sentinel { text-align: center; padding: 16px 0; font-size: 12px; color: var(--ink-faint); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(43,38,32,0.5);
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-box { background: var(--surface); border-radius: 14px; padding: 22px; max-width: 400px; width: 100%; box-shadow: var(--shadow-lg); }

.wine-card, .entry-card {
  background: var(--surface); border-radius: 12px; padding: 16px;
  border: 1px solid var(--border); margin-bottom: 10px; position: relative; box-shadow: var(--shadow-sm);
}
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }
.wine-title { font-family: 'Fraunces', serif; font-size: 15.5px; font-weight: 600; overflow-wrap: break-word; }
.wine-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-top > div:first-child { min-width: 0; }

.pill {
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  display: inline-block;
}
.badge-gold { background: rgba(199,156,94,0.16); color: var(--gold); }
.badge-sage { background: rgba(92,122,82,0.14); color: var(--sage); }
.badge-rust { background: rgba(193,101,58,0.14); color: var(--rust); }
.badge-garnet { background: rgba(156,51,71,0.12); color: var(--garnet); }
.pill-neutral { background: var(--surface-dim); color: var(--ink-soft); }

.btn {
  font-family: 'Inter', sans-serif; font-weight: 600; font-size: 13px;
  border-radius: 7px; padding: 9px 18px; cursor: pointer; border: none;
  text-decoration: none; display: inline-block;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--border); }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-soft); font-weight: 500; margin-bottom: 12px; min-width: 0; }
.field input, .field select {
  padding: 8px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--ink);
  width: 100%; max-width: 100%; box-sizing: border-box;
}
.field input[type="date"] {
  font-family: 'Inter', sans-serif;
  -webkit-appearance: none;
  appearance: none;
  min-height: 36px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; min-width: 0; }
@media (max-width: 520px) {
  .form-grid { grid-template-columns: 1fr; }
}
.search-box-wrap { position: relative; margin-bottom: 12px; }
.search-box {
  display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: 10px;
  padding: 10px 14px; border: 1px solid var(--border); margin-bottom: 0;
}
.search-box input { border: none; outline: none; flex: 1; min-width: 0; font-size: 14px; background: transparent; font-family: 'Inter', sans-serif; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
  text-decoration: none; border: 1px solid var(--border); color: var(--ink-soft);
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.timeline-track {
  position: relative; height: 8px; border-radius: 4px; background: var(--surface-dim);
  margin-top: 10px;
}
.timeline-fill { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: var(--sage); opacity: 0.5; }
.timeline-now { position: absolute; top: -4px; width: 3px; height: 16px; background: var(--ink); border-radius: 2px; }
.timeline-labels { display: flex; justify-content: space-between; font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--ink-soft); margin-top: 5px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-faint); font-size: 13px; }
.error-msg { background: rgba(156,51,71,0.08); color: var(--garnet); padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.auth-card { max-width: 380px; margin: 60px auto; background: var(--surface); border-radius: 16px; padding: 28px; box-shadow: var(--shadow-md); border: 1px solid var(--border); }
.auth-card h1 { font-family: 'Fraunces', serif; font-size: 24px; margin: 0 0 4px; color: var(--ink); }
.auth-card p.sub { font-size: 13px; color: var(--ink-soft); margin: 0 0 20px; }
.auth-card a { color: var(--primary); font-size: 13px; }
.helper-text { font-size: 11.5px; color: var(--ink-faint); margin: 10px 0 0; }
