/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #1f2b47;
  --bg-input: #0f3460;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b0;
  --text-muted: #6c6c7c;
  --accent: #e94560;
  --accent-hover: #ff6b6b;
  --accent-dim: rgba(233, 69, 96, 0.15);
  --success: #4caf50;
  --warning: #ff9800;
  --border: #2a3a5e;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  --transition: 0.2s ease;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* === Header === */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon { font-size: 1.3rem; }

.nav {
  display: flex;
  gap: 0.5rem;
}

.nav button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all var(--transition);
}

.nav button:hover,
.nav button.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* === Views === */
.view {
  display: none;
  padding: 2rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.view.active { display: block; }

/* === Welcome === */
.welcome-hero {
  text-align: center;
  padding: 3rem 0;
}

.welcome-hero h2 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--accent), #ff9a9e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 2.5rem;
}

.welcome-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.feature {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
}

.feature-icon { font-size: 2rem; display: block; margin-bottom: 0.75rem; }
.feature h3 { margin-bottom: 0.5rem; font-size: 1rem; }
.feature p { font-size: 0.85rem; color: var(--text-secondary); }

.disclaimer {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

/* === Buttons === */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-large { padding: 1rem 3rem; font-size: 1.2rem; }

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 0.75rem 2rem;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover { border-color: var(--text-secondary); color: var(--text-primary); }
.btn-small { padding: 0.4rem 1rem; font-size: 0.85rem; }
.hidden { display: none !important; }

/* === Progress === */
.progress-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #ff9a9e);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  min-width: 3rem;
}

/* === Category Navigation === */
.category-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.category-nav button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.category-nav button:hover { color: var(--text-primary); border-color: var(--border); }
.category-nav button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.category-nav button.completed { color: var(--success); border-color: var(--success); }

/* === Test Content === */
.test-content {
  min-height: 400px;
}

.category-header {
  margin-bottom: 1.5rem;
}

.category-header h2 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.category-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* === Test Item === */
.test-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: border-color var(--transition);
}

.test-item:hover { border-color: var(--accent); }

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.item-name {
  font-weight: 600;
  font-size: 1rem;
}

.item-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

/* === Rating Controls === */
.rating-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rating-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.rating-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 70px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.rating-buttons {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.rating-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.rating-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.rating-btn.selected {
  color: #fff;
  border-color: transparent;
  font-weight: 600;
}

.rating-btn[data-value="5"].selected { background: #e91e63; }
.rating-btn[data-value="4"].selected { background: #ff5722; }
.rating-btn[data-value="3"].selected { background: #ff9800; }
.rating-btn[data-value="2"].selected { background: #ffc107; color: #000; }
.rating-btn[data-value="1"].selected { background: #8bc34a; color: #000; }
.rating-btn[data-value="0"].selected { background: #9e9e9e; }
.rating-btn[data-value="-1"].selected { background: #607d8b; }
.rating-btn[data-value="-2"].selected { background: #f44336; }

/* === Test Navigation === */
.test-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* === Results === */
.results-container {
  max-width: 900px;
  margin: 0 auto;
}

.results-header {
  text-align: center;
  margin-bottom: 2rem;
}

.results-header h2 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.results-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.result-category {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.result-category h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

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

.result-item-name {
  font-size: 0.9rem;
  flex: 1;
}

.result-item-ratings {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.result-badge {
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
}

.result-badge.giving { opacity: 0.9; }
.result-badge.receiving { opacity: 0.7; }

/* === Score Summary === */
.score-summary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 2rem;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.score-bar-container {
  margin-bottom: 0.75rem;
}

.score-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.score-bar {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* === Saved Results === */
.saved-container {
  max-width: 900px;
  margin: 0 auto;
}

.saved-container h2 {
  margin-bottom: 1.5rem;
}

.saved-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.saved-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.saved-item-info h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.saved-item-info p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.saved-item-actions {
  display: flex;
  gap: 0.5rem;
}

/* === Compare === */
.compare-container {
  max-width: 1100px;
  margin: 0 auto;
}

.compare-container h2 {
  margin-bottom: 1.5rem;
}

.compare-selector {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.compare-selector select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  min-width: 200px;
}

.compare-selector label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 0.3rem;
}

.compare-results {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.compare-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 1rem;
  align-items: center;
}

.compare-item.match { border-left: 3px solid var(--success); }
.compare-item.partial { border-left: 3px solid var(--warning); }
.compare-item.mismatch { border-left: 3px solid var(--accent); }

.compatibility-score {
  text-align: center;
  padding: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 2rem;
}

.compatibility-score .big-number {
  font-size: 4rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--success), #81c784);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.compatibility-score p {
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 500px;
  width: 100%;
}

.modal h3 { margin-bottom: 1rem; }

.modal input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 1rem;
  margin-bottom: 1rem;
}

.modal input:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

.empty-state p { font-size: 1.1rem; margin-bottom: 1rem; }

/* === Responsive === */
@media (max-width: 768px) {
  .header-inner { flex-direction: column; gap: 0.75rem; }
  .welcome-hero h2 { font-size: 1.8rem; }
  .category-nav { gap: 0.25rem; }
  .rating-buttons { gap: 0.2rem; }
  .rating-btn { padding: 0.3rem 0.45rem; font-size: 0.7rem; }
  .rating-label { min-width: 55px; font-size: 0.7rem; }
  .compare-item { grid-template-columns: 1fr; gap: 0.5rem; }
  .results-actions { flex-direction: column; align-items: center; }
}

@media (max-width: 480px) {
  .view { padding: 1rem; }
  .test-item { padding: 1rem; }
  .rating-row { flex-direction: column; align-items: flex-start; }
}

/* === Filter/Sort for results === */
.results-filter {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.results-filter select,
.results-filter input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
}

/* === Tooltip === */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.7rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.tooltip:hover::after { opacity: 1; }
