/* ============ DESIGN TOKENS ============ */
:root {
  --bg: #FAFAF8;
  --card: #FFF;
  --card-alt: #F5F4F0;
  --border: #E8E6E0;
  --border-hover: #D0CEC6;
  --text: #1A1A18;
  --text-secondary: #6B6960;
  --text-tertiary: #9E9B90;
  --accent: #8B6914;
  --accent-light: #F6EFD9;
  --danger: #C4402A;
  --danger-light: #FDF0ED;
  --success: #2A7D5F;
  --success-light: #E8F5EE;
  --info: #2E6BB0;
  --info-light: #EBF3FC;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Outfit', system-ui, sans-serif;
  --radius: 10px;
  --radius-lg: 14px;
}

/* ============ RESET & BASE ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ LAYOUT ============ */
.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* ============ USER SWITCHER ============ */
#user-bar {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 16px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.user-btn {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 24px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.user-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.user-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ============ HEADER ============ */
#app-header {
  text-align: center;
  padding: 40px 0 10px;
}
#app-header h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
#app-header p {
  color: var(--text-tertiary);
  font-size: 14px;
}

/* ============ METRICS ============ */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 20px 0 28px;
}
.metric-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.metric-value {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--accent);
}
.metric-label {
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ============ TABS ============ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  padding: 10px 16px;
  border: none;
  background: none;
  color: var(--text-tertiary);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 500;
}
.panel { display: none; }
.panel.active { display: block; }

/* ============ FRAGRANCE CARDS ============ */
.collection-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.collection-controls select,
.collection-controls input {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
}
.collection-controls input { flex: 1; min-width: 160px; }
.frag-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.frag-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
  position: relative;
}
.frag-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.frag-card .frag-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 2px;
}
.frag-card .frag-house {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}
.frag-card .frag-line {
  font-size: 12px;
  color: var(--text-tertiary);
  font-style: italic;
  margin-bottom: 6px;
}
.frag-card .frag-notes-text {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  line-height: 1.4;
}
.frag-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
  white-space: nowrap;
  background: #E8E4DC;
  color: #5A5648;
}
.season-strip {
  display: flex;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
.season-seg {
  padding: 2px 10px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.15);
}
.frag-card .frag-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 6px;
}
.frag-card .edit-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 14px;
  color: var(--text-tertiary);
  opacity: 0;
  transition: opacity 0.2s;
}
.frag-card:hover .edit-icon { opacity: 1; }
.sample-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-owned { background: var(--accent-light); color: var(--accent); }
.badge-sample { background: var(--info-light); color: var(--info); }

/* ============ TAG COLORS ============ */
.tag-woody { background: #E8DCC8; color: #5A4A30; }
.tag-citrus { background: #FFF3C0; color: #7A6A10; }
.tag-amber, .tag-resinous { background: #F0D8A0; color: #6B4E1A; }
.tag-tobacco { background: #D8C8A0; color: #5A4820; }
.tag-floral { background: #F0D0E0; color: #7A3060; }
.tag-fresh { background: #D0F0E0; color: #206040; }
.tag-gourmand, .tag-vanilla, .tag-sweet { background: #F8E0D0; color: #7A4020; }
.tag-leather { background: #D0C0B0; color: #4A3828; }
.tag-spicy { background: #F0D0C0; color: #7A3020; }
.tag-marine, .tag-aquatic { background: #C8E0F0; color: #204060; }
.tag-musky, .tag-musk, .tag-clean { background: #E8E0F0; color: #504068; }
.tag-animalic { background: #D8C0A0; color: #5A3820; }
.tag-rose { background: #F0C0D0; color: #8A2050; }
.tag-earthy { background: #D0C8B0; color: #4A4030; }
.tag-powdery { background: #E8D8E8; color: #604060; }
.tag-oriental { background: #E0C0A0; color: #6A4020; }
.tag-smoky { background: #C8C0B8; color: #3A3830; }
.tag-boozy { background: #E0C8B0; color: #6A4828; }
.tag-iris { background: #D0C8E0; color: #404060; }
.tag-saffron { background: #F0D0A0; color: #7A5020; }
.tag-dark { background: #B8B0A8; color: #2A2820; }
.tag-green { background: #C8E0B0; color: #305020; }
.tag-fig { background: #D0E0C0; color: #405030; }
.tag-herbal { background: #C0D8B8; color: #304828; }
.tag-vetiver { background: #B8C8A8; color: #384828; }
.tag-sandalwood { background: #E0D0B8; color: #5A4830; }
.tag-mineral { background: #C8D0D8; color: #384050; }
.tag-patchouli { background: #C8B8A0; color: #4A3828; }
.tag-incense { background: #D0C0B0; color: #504030; }
.tag-paper { background: #E0D8D0; color: #504840; }
.tag-neroli { background: #F0E8D0; color: #606020; }
.tag-oud { background: #C8B8A8; color: #4A3828; }
.tag-nostalgic { background: #D8D0C8; color: #484038; }
.tag-fruity { background: #F0D8E0; color: #7A3050; }
.tag-aromatic { background: #C0D8C0; color: #305030; }
.tag-default { background: #E8E4DC; color: #5A5648; }
.tag-extreme { background: #C0A8A0; color: #4A2820; }
.tag-salty { background: #D0E0E8; color: #304858; }
.tag-intimate { background: #E0D0E8; color: #504060; }
.tag-tangy { background: #F0E0C0; color: #6A5020; }

/* ============ OVERVIEW TAB ============ */
.overview-section {
  margin-bottom: 28px;
}
.overview-section h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: var(--text);
}
.season-chart {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  height: 120px;
  padding: 0 20px;
}
.season-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.season-bar-fill {
  width: 100%;
  max-width: 60px;
  border-radius: 4px 4px 0 0;
  transition: height 0.3s;
}
.season-bar-label {
  font-size: 12px;
  color: var(--text-secondary);
}
.season-bar-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}
.note-freq-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.note-freq-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
}
.note-freq-item .count {
  font-weight: 600;
  color: var(--accent);
  margin-left: 4px;
}

/* ============ EDWARDS WHEEL ============ */
.wheel-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.wheel-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
}
.wheel-controls label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.wheel-svg-wrap {
  width: 100%;
  max-width: 800px;
}
.wheel-svg-wrap svg { width: 100%; height: auto; }
.wheel-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  font-size: 12px;
}
.wheel-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.wheel-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ============ TOOLTIP ============ */
.tooltip {
  position: fixed;
  padding: 8px 12px;
  background: var(--text);
  color: #fff;
  font-size: 12px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
  max-width: 240px;
  line-height: 1.4;
}
.tooltip.visible { opacity: 1; }

/* ============ FAMILIES & GAPS ============ */
.family-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}
.family-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.family-card h4 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  margin-bottom: 4px;
}
.family-card .family-count {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}
.family-card .family-names {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.gap-list { display: flex; flex-direction: column; gap: 10px; }
.gap-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius);
  padding: 14px;
}
.gap-card.severity-high { border-left-color: #D08030; }
.gap-card.severity-medium, .gap-card.severity-moderate { border-left-color: var(--info); }
.gap-card.severity-low { border-left-color: var(--text-tertiary); }
.gap-card h4 { font-size: 0.95rem; margin-bottom: 4px; }
.gap-card .gap-severity {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.gap-card .gap-severity.critical { color: var(--danger); }
.gap-card .gap-severity.high { color: #D08030; }
.gap-card .gap-severity.medium, .gap-card .gap-severity.moderate { color: var(--info); }
.gap-card .gap-severity.low { color: var(--text-tertiary); }
.gap-card .gap-detail {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ============ SAMPLE VERDICTS ============ */
.verdict-list { display: flex; flex-direction: column; gap: 10px; }
.verdict-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.verdict-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.verdict-header:hover { background: var(--card-alt); }
.verdict-header .verdict-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.verdict-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.verdict-buy { background: var(--success-light); color: var(--success); }
.verdict-consider { background: #FFF8E0; color: #8A6E10; }
.verdict-skip { background: var(--danger-light); color: var(--danger); }
.verdict-header .verdict-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
}
.verdict-header .verdict-house {
  font-size: 13px;
  color: var(--text-secondary);
  margin-left: 6px;
}
.verdict-arrow {
  font-size: 14px;
  color: var(--text-tertiary);
  transition: transform 0.2s;
}
.verdict-card.open .verdict-arrow { transform: rotate(180deg); }
.verdict-body {
  display: none;
  padding: 0 16px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.verdict-card.open .verdict-body { display: block; }
.verdict-reason {
  background: var(--card-alt);
  border-radius: 6px;
  padding: 10px 12px;
  margin-top: 8px;
  font-style: italic;
}

/* ============ EDIT TAB ============ */
.edit-tab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.edit-tab-header .edit-status {
  font-size: 13px;
  color: var(--text-tertiary);
}
.btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #7A5B10; }
.btn-secondary { background: var(--card-alt); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #A83520; }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.edit-actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.edit-frag-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 16px;
}
.edit-frag-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.edit-frag-item .ef-name { font-weight: 500; }
.edit-frag-item .ef-house { color: var(--text-secondary); margin-left: 6px; }
.edit-frag-item .ef-modified {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-light);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 8px;
}

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--bg);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}
.modal-header h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
}
.modal-close {
  font-size: 24px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 4px;
  line-height: 1;
}
.edit-form {
  padding: 0 24px 24px;
}
.edit-form fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.edit-form legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  padding: 0 6px;
}
.edit-form label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.edit-form input,
.edit-form select,
.edit-form textarea {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  width: 100%;
}
.edit-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.edit-form .seasons-row {
  display: flex;
  gap: 16px;
}
.edit-form .seasons-row label {
  flex-direction: row;
  align-items: center;
  gap: 4px;
  font-size: 13px;
}
.edit-form .seasons-row input { width: auto; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 640px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .frag-grid { grid-template-columns: 1fr; }
  .family-grid { grid-template-columns: 1fr; }
  .edit-form .form-row { grid-template-columns: 1fr; }
  #app-header h1 { font-size: 1.5rem; }
  .metric-value { font-size: 1.4rem; }
}
