@font-face {
  font-family: 'Space Grotesk';
  src: url('../fonts/SpaceGrotesk.ttf') format('truetype');
  font-weight: 400 700;
  font-display: swap;
}

:root {
  /* Design tokens — Spotify-inspired immersive dark theme */
  --bg: #121212;
  --surface: #181818;
  --surface-2: #1f1f1f;
  --surface-3: #282828;
  --surface-hover: #2a2a2a;
  --accent: #1ed760;
  --accent-2: #1db954;
  --accent-glow: rgba(30, 215, 96, 0.15);
  --accent-subtle: rgba(30, 215, 96, 0.08);
  --text: #ffffff;
  --text-muted: #b3b3b3;
  --text-dim: #a7a7a7;
  --text-faint: #727272;
  --border: #282828;
  --border-light: #3e3e3e;
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-standard: rgba(255, 255, 255, 0.1);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --radius-pill: 500px;
  --font-sans: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --shadow: 0px 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-md: 0px 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0px 8px 24px rgba(0, 0, 0, 0.5);
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 120ms ease;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Subtle background gradient ── */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(ellipse 100% 60% at 50% 0%, rgba(30, 215, 96, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(30, 215, 96, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ── Subtle grid pattern ── */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.01) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.01) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* ── Header ── */
.app-header {
  padding: 32px 20px 20px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border-subtle);
  text-align: center;
  position: relative;
  z-index: 1;
  overflow: hidden;
}

.app-header::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  right: -50%;
  bottom: -50%;
  background: radial-gradient(circle at 50% 50%, rgba(30, 215, 96, 0.05) 0%, transparent 50%);
  animation: pulse 4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

.app-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 2px;
  opacity: 0.8;
}

.app-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, #ffffff 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
  animation: slideDown 0.5s ease-out;
  position: relative;
  z-index: 1;
}

.tagline {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 4px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
  animation: slideDown 0.5s ease-out 0.1s backwards;
  position: relative;
  z-index: 1;
}

/* ── Main ── */
main#app {
  flex: 1;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.tab {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding: 16px 16px 24px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.tab.active { display: block; }

/* ── Search ── */
.search-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding-bottom: 14px;
  margin-bottom: 2px;
}

.search-bar input {
  width: 100%;
  padding: 13px 16px 13px 42px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 400;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 14px center;
}

.search-bar input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background-color: var(--surface-3);
}

.search-bar input::placeholder {
  color: var(--text-faint);
  font-weight: 400;
}

/* ── Note chips ── */
.note-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 16px;
}

.chip {
  padding: 6px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  letter-spacing: 0.01em;
}

.chip:hover {
  border-color: var(--border-light);
  color: var(--text);
  background: var(--surface-3);
}

.chip.active {
  background: var(--accent);
  color: #0a0a0a;
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* ── Results ── */
.results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.perfume-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color var(--transition), transform var(--transition-fast), box-shadow var(--transition);
  cursor: default;
  animation: fadeIn 300ms ease-out backwards;
  position: relative;
  overflow: hidden;
}

.perfume-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.perfume-card:hover {
  background: var(--surface-2);
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.perfume-card:hover::before {
  opacity: 0.6;
}

.perfume-card .name {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--text);
  letter-spacing: -0.01em;
}

.perfume-card .brand {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 3px;
  font-weight: 400;
}

.perfume-card .no-rating {
  color: var(--text-faint);
  font-weight: 400;
  font-size: 0.74rem;
  font-style: italic;
}

.perfume-card .meta {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  font-size: 0.74rem;
  color: var(--text-dim);
  flex-wrap: wrap;
  align-items: center;
}

.perfume-card .rating {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.78rem;
}

.perfume-card .rating::before {
  content: '★ ';
  font-size: 0.7rem;
}

.perfume-card .accords {
  color: var(--text-muted);
  font-size: 0.76rem;
  margin-top: 8px;
  line-height: 1.5;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Tab bar ── */
.tab-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 0;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.66rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  transition: color var(--transition-fast), transform var(--transition-fast);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.tab-btn:active {
  transform: scale(0.95);
}

.tab-btn.active {
  color: var(--accent);
}

.tab-btn .icon {
  font-size: 1.15rem;
  line-height: 1;
  transition: transform var(--transition-fast);
}

.tab-btn.active .icon {
  transform: scale(1.05);
}

/* ── Advisor ── */
#advisor-content {
  margin-top: 4px;
}

.advisor-modes {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.mode-btn {
  padding: 8px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  letter-spacing: 0.01em;
}

.mode-btn:hover {
  border-color: var(--border-light);
  color: var(--text);
}

.mode-btn.active {
  background: var(--accent);
  color: #0a0a0a;
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.advisor-intro {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 14px;
  line-height: 1.5;
}

#advisor-content input[type="text"] {
  width: 100%;
  padding: 13px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.92rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#advisor-content input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#advisor-content .result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 10px;
  transition: border-color var(--transition);
}

#advisor-content .result-card .name {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

#advisor-content .result-card .brand {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 2px;
}

#advisor-content .result-card .reason {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 8px;
  line-height: 1.45;
}

/* ── Graph ── */
#graph-container {
  width: 100%;
  height: calc(100vh - 220px);
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-top: 4px;
}

.graph-legend {
  padding: 10px 14px;
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.graph-legend strong {
  color: var(--text-muted);
  font-weight: 600;
}

/* ── Loading ── */
.loading {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.loading::after {
  content: '';
  display: block;
  width: 40px;
  height: 3px;
  background: var(--surface-3);
  border-radius: 2px;
  margin: 16px auto 0;
  overflow: hidden;
  position: relative;
}

.loading::before {
  content: '';
  display: block;
  width: 40px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  margin: 0 auto;
  animation: shimmer 1.5s ease-in-out infinite;
  position: absolute;
  left: 0;
  top: 0;
}

/* ── Responsive ── */
@media (min-width: 768px) {
  main#app {
    max-width: 640px;
    margin: 0 auto;
  }
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ── Selection ── */
::selection {
  background: var(--accent-glow);
  color: var(--text);
}

/* ── Focus ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
PY