:root {
  color-scheme: dark;
  --bg: #0a0b12;
  --panel: #121523;
  --panel-2: #191d2f;
  --text: #e8ecff;
  --muted: #a8b0d3;
  --accent: #a855f7;
  --accent-2: #22d3ee;
  --ok: #34d399;
  --border: rgba(167, 179, 255, 0.18);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, sans-serif; background: radial-gradient(circle at 20% -20%, rgba(168, 85, 247, 0.2), transparent 40%), var(--bg); color: var(--text); }
.bg-glow { position: fixed; inset: auto -10rem -15rem auto; width: 30rem; height: 30rem; background: radial-gradient(circle, rgba(34, 211, 238, 0.12), transparent 70%); pointer-events: none; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 2rem clamp(1rem, 2vw, 2.5rem) 1rem; }
.eyebrow { color: var(--muted); font-size: 0.85rem; margin: 0; }
h1 { margin: 0.2rem 0 0; font-size: clamp(1.6rem, 4vw, 2.5rem); }
.layout { padding: 1rem clamp(1rem, 2vw, 2.5rem) 2rem; display: grid; gap: 1rem; grid-template-columns: repeat(12, 1fr); }
.card { border: 1px solid var(--border); background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01)); border-radius: 1rem; padding: 1.2rem; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28); }
.hero p, p, li, .meta { color: var(--muted); }
.chart-card { grid-column: span 8; }
.list-card { grid-column: span 4; display: flex; flex-direction: column; }
.viz-header { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.header-controls { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--panel-2); color: var(--text); border-radius: 999px; padding: 0.4rem 0.8rem; cursor: pointer; }
.chip.accent { background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-color: transparent; }

.topbar-actions { display: flex; gap: 0.45rem; align-items: center; }
#addWineTopButton { position: relative; z-index: 41; }

.account-menu-wrap { position: relative; }
.account-menu-panel { position: absolute; right: 0; top: calc(100% + 0.35rem); min-width: 190px; background: var(--panel); border: 1px solid var(--border); border-radius: 0.6rem; padding: 0.3rem; display: grid; gap: 0.2rem; z-index: 20; }
.account-menu-item { border: 1px solid transparent; background: transparent; color: var(--text); text-align: left; border-radius: 0.45rem; padding: 0.45rem 0.55rem; cursor: pointer; }
.account-menu-item:hover { border-color: var(--border); background: var(--panel-2); }
.account-menu-item.danger { color: #fecaca; }
.auth-shell { max-width: 460px; margin: 2rem auto 0; padding: 0 1rem; }
.auth-card { display: grid; gap: 0.75rem; }
.auth-form { display: grid; gap: 0.65rem; }
.auth-error { color: #fecaca; border: 1px solid rgba(248, 113, 113, 0.45); background: rgba(127, 29, 29, 0.25); border-radius: 0.6rem; padding: 0.55rem 0.65rem; margin: 0; }

.auth-divider { border: 0; border-top: 1px solid var(--border); width: 100%; margin: 0.35rem 0; }
.auth-card h3 { margin: 0.1rem 0 0; font-size: 1rem; }

.auth-link { color: var(--accent-2); text-decoration: none; font-weight: 600; }
.auth-link:hover { text-decoration: underline; }
.password-strength-weak { color: #fca5a5; }
.password-strength-medium { color: #fde68a; }
.password-strength-strong { color: #86efac; }
.auth-dialog { border: 1px solid var(--border); border-radius: 1rem; background: var(--panel); color: var(--text); width: min(520px, 92vw); }
.auth-dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.78rem; color: #d8f2ff; }
label span { display: block; font-size: 0.75rem; color: var(--muted); margin-bottom: 0.2rem; }
select, input, textarea { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 0.5rem; padding: 0.45rem; font: inherit; }
textarea { resize: vertical; }
.loading-wrap { margin-top: 1.2rem; min-height: 520px; display: grid; place-content: center; justify-items: center; gap: 0.7rem; }
.spinner { width: 48px; height: 48px; border: 4px solid rgba(255, 255, 255, 0.15); border-top-color: var(--ok); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.viz-grid { margin-top: 1rem; display: grid; gap: 0.8rem; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.viz-card { grid-column: span 2; border: 1px solid var(--border); background: var(--panel); border-radius: 0.9rem; padding: 0.8rem; }
.viz-wide { grid-column: span 2; }

.trend-card { grid-column: span 3; }
.notes-overview-card { grid-column: span 1; }
.notes-overview-card .notes-list { max-height: 260px; }
.viz-card-header { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
canvas { width: 100%; max-height: 260px; }
.trend-and-notes { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 0.8rem; align-items: start; }
.notes-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.note-card { border: 1px solid var(--border); border-radius: 0.7rem; padding: 0.55rem; background: rgba(10, 11, 18, 0.45); }
.note-card h4 { margin: 0 0 0.45rem; font-size: 0.9rem; }
.notes-list { display: grid; gap: 0.45rem; max-height: 340px; overflow: auto; padding-right: 0.15rem; }
 .note-row { }
.note-line { display: flex; justify-content: space-between; gap: 0.6rem; align-items: center; font-size: 0.78rem; color: var(--muted); }
.note-count { background: rgba(34, 211, 238, 0.14); border: 1px solid rgba(34, 211, 238, 0.45); color: #bbf4ff; border-radius: 999px; padding: 0.1rem 0.45rem; min-width: 2rem; text-align: center; }
.list-header { display: flex; justify-content: space-between; gap: 0.6rem; align-items: end; }
.wine-list { margin-top: 0.8rem; overflow: auto; flex: 1; min-height: 0; display: grid; gap: 0.5rem; padding-right: 0.2rem; }
.wine-item { border: 1px solid var(--border); background: var(--panel); border-radius: 0.8rem; padding: 0.7rem; cursor: pointer; }
.wine-item:hover, .wine-item.active { border-color: var(--accent-2); }
.wine-item h4 { margin: 0 0 0.2rem; }
.wine-item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.6rem; }
.wine-item-rating { margin: 0; font-weight: 800; color: #ffffff; font-size: 1rem; line-height: 1; }
.wine-item-footer { display: flex; justify-content: space-between; align-items: flex-end; gap: 0.6rem; margin-top: 0.45rem; }
.wine-item-footer .badge-row { margin-top: 0; }
.maker-line { margin: 0 0 0.15rem; color: #ffffff; font-weight: 700; font-size: 0.84rem; }
.small { font-size: 0.8rem; color: var(--muted); }
.badge-row { margin-top: 0.45rem; display: flex; gap: 0.35rem; flex-wrap: wrap; }
.badge { background: rgba(168, 85, 247, 0.16); color: #e7d4ff; border: 1px solid rgba(168, 85, 247, 0.5); border-radius: 999px; font-size: 0.75rem; padding: 0.15rem 0.5rem; }
.detail-actions { display: flex; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.7rem; }
.wine-detail-head { display: grid; grid-template-columns: 160px 1fr; gap: 1rem; align-items: start; }
.wine-detail img { width: 160px; height: 210px; object-fit: cover; border-radius: 0.8rem; border: 1px solid var(--border); }
.back-btn { margin-bottom: 0.3rem; }
.wine-dialog { border: 1px solid var(--border); border-radius: 1rem; background: var(--panel); color: var(--text); width: min(700px, 90vw); }
.wine-dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.wine-form { display: grid; gap: 0.6rem; }
.form-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.form-head-inline { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.form-head-inline h3 { margin: 0; }
.entry-mode-inline { display: flex; align-items: center; gap: 0.45rem; font-size: 0.82rem; color: var(--muted); }
.entry-mode-inline select { min-width: 120px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.6rem; }
.form-actions { display: flex; justify-content: flex-end; }

.wine-form label { display: grid; gap: 0.3rem; }
.wide-field { grid-column: 1 / -1; }
#tasting_notes { width: 100%; min-height: 120px; text-align: left; }
.badge-picker { border: 1px solid var(--border); border-radius: 0.7rem; padding: 0.55rem; background: rgba(10, 11, 18, 0.45); }
.badge-picker > span { font-size: 0.82rem; color: var(--muted); }
.badge-picker-row { display: flex; gap: 0.45rem; margin-top: 0.45rem; }
.badge-picker-row input { flex: 1; }
.selected-badges, .badge-options { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.45rem; }
.badge-tag { display: inline-flex; align-items: center; gap: 0.3rem; border: 1px solid rgba(168, 85, 247, 0.5); background: rgba(168, 85, 247, 0.16); color: #e7d4ff; border-radius: 999px; padding: 0.16rem 0.5rem; font-size: 0.75rem; }
.badge-tag button { border: none; background: transparent; color: inherit; cursor: pointer; font-size: 0.8rem; }
.badge-option { border: 1px solid var(--border); background: var(--panel-2); color: var(--text); border-radius: 999px; padding: 0.18rem 0.52rem; cursor: pointer; font-size: 0.74rem; }
.note-pick { width: 100%; text-align: left; border: 1px solid var(--border); border-radius: 0.5rem; padding: 0.35rem 0.45rem; background: rgba(25, 29, 47, 0.55); color: inherit; cursor: pointer; }
.note-pick.active { border-color: var(--accent-2); background: rgba(34, 211, 238, 0.08); }
.note-filter-status { margin-top: 0.6rem; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 0.6rem; background: rgba(34, 211, 238, 0.08); display: flex; justify-content: space-between; align-items: center; gap: 0.4rem; }

.hidden { display: none; }
.first-run-overlay { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.62); display: grid; place-items: center; z-index: 40; padding: 1rem; }
.first-run-overlay.hidden { display: none; }
.first-run-card { width: min(560px, 92vw); border: 1px solid var(--border); border-radius: 1rem; padding: 1.1rem; background: var(--panel); box-shadow: 0 12px 30px rgba(0,0,0,0.35); display: grid; gap: 0.75rem; }
.first-run-card h2 { margin: 0; }
ul { padding-left: 1rem; }
@media (max-width: 1180px) { .trend-and-notes { grid-template-columns: 1fr; } }
@media (max-width: 960px) {
  .chart-card, .list-card { grid-column: span 12; }
  .viz-grid, .notes-columns, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .viz-card, .trend-card, .notes-overview-card, .viz-wide { grid-column: span 1; }
  .wine-detail-head { grid-template-columns: 1fr; }
  .wine-detail img { width: 100%; max-width: 260px; }
}

.somm-hidden { display: none !important; }
