:root {
  /* Dark Theme Colors */
  --bg-main: #0F1219;
  --bg-panel: rgba(25, 30, 40, 0.6);
  --bg-panel-hover: rgba(35, 42, 54, 0.8);
  --border-color: rgba(255, 255, 255, 0.1);
  
  --text-main: #E2E8F0;
  --text-muted: #94A3B8;
  
  --primary: #EC4899;
  --primary-hover: #DB2777;
  --primary-glow: rgba(236, 72, 153, 0.5);
  
  --secondary: #F472B6;
  --accent: #06B6D4;
  --accent-glow: rgba(6, 182, 212, 0.5);
  
  --success: #10B981;
  --error: #EF4444;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light theme overrides (can be expanded) */
.light-theme {
  --bg-main: #F8FAFC;
  --bg-panel: rgba(255, 255, 255, 0.8);
  --bg-panel-hover: rgba(255, 255, 255, 1);
  --border-color: rgba(0, 0, 0, 0.1);
  --text-main: #0F172A;
  --text-muted: #64748B;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  transition: background-color var(--transition);
}

.font-mono {
  font-family: 'Fira Code', ui-monospace, SFMono-Regular, monospace;
}

/* Utility Classes */
.hidden { display: none !important; }
.text-primary { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.bg-primary { background-color: var(--primary); }
.bg-secondary { background-color: var(--secondary); }
.bg-accent { background-color: var(--accent); }
.bg-white { background-color: #F8FAFC; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.pt-1 { padding-top: 0.25rem; }
.text-sm { font-size: 0.875rem; }
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
.text-2xl { font-size: 1.5rem; }
.text-xl { font-size: 1.25rem; }
.text-lg { font-size: 1.125rem; }
.inline { display: inline; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.w-4 { width: 1rem; }
.h-4 { height: 1rem; }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in {
  animation: fadeIn var(--transition) forwards;
}

/* Glassmorphism */
.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Layout */
.app-container {
  display: flex;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  height: calc(100vh - 2rem);
  margin: 1rem;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 2.5rem;
  letter-spacing: -0.025em;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-grow: 1;
}

.nav-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: all var(--transition);
}

.nav-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-btn.active {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 0 15px var(--primary-glow);
}

.nav-btn i {
  width: 1.25rem;
  height: 1.25rem;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.theme-toggle {
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  display: inline-flex;
  transition: background var(--transition);
}
.theme-toggle:hover {
  background: rgba(255,255,255,0.1);
}

/* Main Content */
.main-content {
  flex-grow: 1;
  padding: 2.5rem;
  max-width: 900px;
  margin: 0 auto;
}

.view-section {
  display: none;
}
.view-section.active {
  display: block;
}

.view-header {
  margin-bottom: 2.5rem;
}

.view-header h1 {
  font-size: 2.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.025em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* Calculator Card */
.calculator-card {
  padding: 2rem;
}

.input-group {
  margin-bottom: 2rem;
}

.input-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

input[type="text"] {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 1rem;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.input-large {
  font-size: 1.25rem !important;
  padding: 1.25rem !important;
}

.icon-btn {
  position: absolute;
  right: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.5rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.icon-btn:hover {
  color: var(--text-main);
  background: rgba(255,255,255,0.1);
}

.input-options {
  display: flex;
  gap: 1.5rem;
  margin-top: 1rem;
}

.custom-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
  user-select: none;
}
.custom-checkbox input {
  display: none;
}
.checkmark {
  width: 18px;
  height: 18px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.custom-checkbox input:checked ~ .checkmark {
  background: var(--primary);
  border-color: var(--primary);
}
.custom-checkbox input:checked ~ .checkmark::after {
  content: '';
  width: 4px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

.specificity-display {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.score-overall {
  background: rgba(0,0,0,0.3);
  padding: 1.5rem;
  border-radius: var(--radius-sm);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid var(--border-color);
  position: relative;
}

.score-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.score-tuple {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #fff;
  text-shadow: 0 0 20px rgba(255,255,255,0.2);
}

.important-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  background: var(--error);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  border-radius: 100px;
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.4);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

.score-breakdown {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.score-item {
  background: rgba(0,0,0,0.2);
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.score-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.score-item-title {
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.score-item-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

.score-bar-container {
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.score-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.score-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* History */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.875rem;
  transition: color 0.2s;
}
.btn-text:hover { color: var(--text-main); }

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}
.history-item:hover {
  background: var(--bg-panel-hover);
  border-color: var(--primary);
}
.history-code {
  font-size: 0.9rem;
}
.history-tuple {
  font-size: 0.85rem;
  color: var(--primary);
}

/* Compare View */
.compare-container {
  display: flex;
  gap: 2rem;
  align-items: stretch;
  position: relative;
}

.compare-card {
  flex: 1;
  padding: 2rem;
  display: flex;
  flex-direction: column;
}

.comp-tuple {
  font-size: 2.25rem;
  font-weight: 700;
  text-align: center;
  color: #fff;
  margin-top: auto;
  padding: 1.5rem 0;
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius-sm);
}

.compare-vs {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
}

.vs-circle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.25rem;
  background: var(--bg-main);
  border: 2px solid var(--border-color);
  color: var(--text-muted);
}

/* Quiz View */
.quiz-header {
  display: flex;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 1.1rem;
}

.quiz-battlefield {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 2rem;
}

.quiz-option {
  padding: 2rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-panel);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  position: relative;
}

.quiz-option:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.quiz-option.correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.1);
}

.quiz-option.incorrect {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

.quiz-vs {
  text-align: center;
  padding: 0.5rem 0;
}

.quiz-reveal {
  margin-top: 1rem;
  color: var(--primary);
  animation: fadeIn 0.3s forwards;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 0 15px var(--primary-glow);
}

/* Reference View */
.reference-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.ref-card {
  padding: 1.5rem;
}

.ref-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.ref-list li {
  padding-left: 1.5rem;
  position: relative;
}
.ref-list li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--text-muted);
}
.ref-list code {
  background: rgba(0,0,0,0.3);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--success);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  z-index: 1000;
  opacity: 1;
  transform: translateY(0);
  transition: all 0.3s;
}
.toast.hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

/* Responsive */
@media (max-width: 768px) {
  .app-container { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; margin-bottom: 0; }
  .nav-links { flex-direction: row; flex-wrap: wrap; }
  .nav-btn { width: auto; }
  .score-breakdown { grid-template-columns: repeat(2, 1fr); }
  .compare-container { flex-direction: column; }
  .reference-grid { grid-template-columns: 1fr; }
}
