:root {
  --nom: #4a90e2;
  --acc: #e2a04a;
  --dat: #50c878;
  --gen: #9b59b6;
  --bg: #f8f9fa;
  --card: #ffffff;
  --text: #2d3748;
  --text-secondary: #4a5568;
  --border: #e2e8f0;
  --highlight: #fef3c7;
  --shadow: rgba(0,0,0,0.1);
  --table-header: #f8fafc;
  --note-bg: #f1f5f9;
  --usage-bg: #edf2f7;
  --correct: #48bb78;
  --wrong: #f56565;
  --transition: 0.3s ease;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --border: #334155;
  --highlight: #422006;
  --shadow: rgba(0,0,0,0.4);
  --table-header: #1e293b;
  --note-bg: #0f172a;
  --usage-bg: #1e293b;
}

* { box-sizing: border-box; margin: 0; padding: 0; transition: background-color var(--transition), color var(--transition), border-color var(--transition); }
body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding: 20px;
  min-height: 100vh;
}
.container { max-width: 1200px; margin: 0 auto; }

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  position: relative;
}
h1 { font-size: 2rem; line-height: 1.2; }
.subtitle { text-align: center; color: var(--text-secondary); margin-bottom: 20px; }

/* Navigation Container */
.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 20px;
  flex-wrap: wrap;
}

.theme-toggle-wrapper {
  display: flex;
  align-items: center;
}

.theme-toggle {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 50px;
  padding: 6px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--text);
}
.theme-toggle:hover { transform: translateY(-1px); }
.icon { font-size: 1.2rem; }

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
button {
  padding: 8px 16px;
  border: 2px solid var(--border);
  background: var(--card);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
  color: var(--text);
}
button:hover { transform: translateY(-1px); }
button.active { border-color: currentColor; background: var(--note-bg); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Hamburger Menu Button */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 30px;
  height: 24px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 101;
}
.hamburger span {
  display: block;
  height: 3px;
  width: 100%;
  background: var(--text);
  border-radius: 3px;
  transition: all 0.3s ease;
}

.tabs { display: none; }
.tabs.active { display: block; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}
.card {
  background: var(--card);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 8px var(--shadow);
  border-top: 4px solid;
  max-width: 100%; 
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.nom { border-color: var(--nom); }
.acc { border-color: var(--acc); }
.dat { border-color: var(--dat); }
.gen { border-color: var(--gen); }

.card h2 { margin-bottom: 10px; font-size: 1.3rem; }
.card .usage { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 15px; font-style: italic; }

/* Standard Table Styles */
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); word-wrap: break-word; }
th { background: var(--table-header); font-weight: 600; }
tr:last-child td { border-bottom: none; }

.changed { background: var(--highlight); font-weight: 500; }

.note { 
  margin-top: auto; 
  font-size: 0.85rem; 
  color: var(--text-secondary); 
  background: var(--note-bg); 
  padding: 8px; 
  border-radius: 6px; 
}

/* Compare Mode Layout */
.compare-all .grid {
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 2000px) {
  .compare-all .grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.usage-guide {
  background: var(--card);
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 8px var(--shadow);
  margin-top: 20px;
}
.usage-guide h3 { margin-bottom: 10px; }
.usage-guide table th { background: var(--usage-bg); }

.quiz-link {
  display: inline-block;
  padding: 8px 16px;
  background: var(--nom);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  transition: transform 0.2s, background-color 0.2s;
  border: 2px solid var(--nom);
}
.quiz-link:hover { transform: translateY(-1px); background-color: #357abd; border-color: #357abd; }

/* Quiz Styles */
.quiz-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}
select {
  padding: 8px 12px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 6px;
  font-size: 1rem;
  max-width: 100%;
}
.back-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
}
.back-link:hover { text-decoration: underline; }

#quiz-container {
  background: var(--card);
  padding: 24px;
  border-radius: 10px;
  box-shadow: 0 2px 8px var(--shadow);
  margin-bottom: 20px;
  min-height: 150px;
}
.question-text { font-size: 1.2rem; margin-bottom: 16px; font-weight: 500; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option-btn {
  padding: 12px;
  text-align: left;
  border: 2px solid var(--border);
  background: var(--card);
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
}
.option-btn:hover { border-color: var(--nom); }
.option-btn.selected { border-color: var(--nom); background: var(--note-bg); }
.option-btn.correct { border-color: var(--correct); background: #f0fff4; }
.option-btn.wrong { border-color: var(--wrong); background: #fff5f5; }

.feedback {
  padding: 16px;
  border-radius: 8px;
  margin-top: 16px;
  font-weight: 500;
}
.feedback.correct { background: #f0fff4; color: #22543d; border: 2px solid var(--correct); }
.feedback.wrong { background: #fff5f5; color: #742a2a; border: 2px solid var(--wrong); }
.feedback.hidden { display: none; }

.quiz-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  gap: 10px;
}
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin-top: 20px;
  overflow: hidden;
}
#progress-fill {
  height: 100%;
  background: var(--dat);
  transition: width 0.3s ease;
}

/* =========================================
   MOBILE RESPONSIVE LAYOUT
   ========================================= */
@media (max-width: 768px) {
  body { padding: 10px; }
  
  /* Header: Hamburger on Left, Title Next to it */
  .header {
    justify-content: flex-start;
    gap: 15px;
    margin-bottom: 0;
  }
  
  /* Smaller title to fit with hamburger */
  h1 { font-size: 1.2rem; }
  
  .hamburger { display: flex; }
  
  .nav-container {
    display: none;
    flex-direction: column;
    align-items: stretch;
    position: absolute;
    top: 50px;
    left: 0;
    right: 0;
    background: var(--card);
    padding: 20px;
    box-shadow: 0 4px 6px var(--shadow);
    z-index: 100;
    border-radius: 0 0 10px 10px;
    border: 1px solid var(--border);
    border-top: none;
    margin-bottom: 0;
  }
  
  .nav-container.open { display: flex; }
  
  .theme-toggle-wrapper { justify-content: center; margin-bottom: 15px; }
  .controls { justify-content: center; margin-bottom: 15px; }
  
  .quiz-link {
    display: block;
    text-align: center;
    margin: 0 auto;
    width: fit-content;
  }
  
  #btn-compare { display: none; }
  
  .compare-all .grid {
    grid-template-columns: 1fr;
  }

  /* 
     FIX: Hide the first row (header) on mobile.
     The HTML uses <tr> for headers, not <thead>, so we target the first row.
  */
  tr:first-child { display: none; }

  .quiz-controls { flex-direction: column; align-items: stretch; }
  .back-link { text-align: center; margin-top: 10px; }

  table, tbody, th, td, tr { display: block; }
  tr { 
    margin-bottom: 15px; 
    border: 1px solid var(--border); 
    border-radius: 8px; 
    padding: 10px; 
    background: var(--bg); 
  }
  td {
    border: none;
    position: relative;
    padding-left: 50%;
    text-align: right;
    font-size: 0.9rem;
  }
  td:before {
    position: absolute;
    left: 6px;
    top: 0;
    width: 45%;
    padding-right: 10px;
    white-space: nowrap;
    text-align: left;
    font-weight: bold;
    content: attr(data-label);
  }
  td:first-child {
    text-align: left;
    padding-left: 0;
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 5px;
    background: transparent !important;
  }
  td:first-child:before { content: none; }
}
