:root {
  --primary: #1a73e8;
  --primary-hover: #1557b0;
  --bg: #f8f9fa;
  --card-bg: #ffffff;
  --text: #202124;
  --text-muted: #5f6368;
  --border: #dadce0;
  --success: #1e8e3e;
  --danger: #d93025;
  --warning: #f9ab00;
  --flagged: #e37400;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #121212;
  --card-bg: #1e1e1e;
  --text: #e8eaed;
  --text-muted: #9aa0a6;
  --border: #3c4043;
  --primary: #8ab4f8;
  --primary-hover: #aecbfa;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header.app-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.brand span.badge-beta {
  font-size: 0.7rem;
  background: #e8f0fe;
  color: #1a73e8;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.header-links {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.btn-k8s {
  background: #326ce5;
  color: #fff;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: opacity 0.2s;
}

.btn-k8s:hover {
  opacity: 0.9;
}

/* Main Container */
main.container {
  max-width: 1250px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
}

/* Dashboard */
.hero-section {
  text-align: center;
  margin-bottom: 2rem;
}

.hero-section h1 {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

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

/* Category Filters */
.category-filters {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.cat-pill {
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
}

.cat-pill:hover, .cat-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.5rem;
}

.exam-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.exam-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.exam-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--card-accent, #1a73e8);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.badge-code {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: #f1f3f4;
  color: var(--text);
}

.exam-card h2 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.card-meta {
  display: flex;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.card-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.target-badge {
  background: #e6f4ea;
  color: #137333;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* Practice Exam Set Buttons */
.btn-set {
  background: #f1f3f4;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
  text-align: center;
}

.btn-set:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.card-actions {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

button.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.2s;
}

button.btn-primary:hover {
  background: var(--primary-hover);
}

button.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.6rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.2s;
}

button.btn-secondary:hover {
  background: #f1f3f4;
}

/* Exam Active Screen */
.exam-view {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.exam-topbar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 70px;
  z-index: 90;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.exam-info h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.exam-progress-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.timer-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.3rem;
  font-weight: 700;
  font-family: monospace;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  background: #f1f3f4;
}

.timer-box.warning {
  background: #fce8e6;
  color: var(--danger);
}

.exam-actions-top {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.flag-checkbox {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  user-select: none;
}

.flag-checkbox.flagged {
  background: #fef7e0;
  border-color: var(--flagged);
  color: var(--flagged);
  font-weight: 600;
}

/* Question Box */
.question-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.question-domain {
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.question-text {
  font-size: 1.15rem;
  font-weight: 500;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.question-text pre {
  background: #282c34;
  color: #abb2bf;
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1rem 0;
  font-size: 0.95rem;
}

.select-hint {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.option-item:hover {
  background: #f8f9fa;
  border-color: #b0b4b8;
}

.option-item.selected {
  border-color: var(--primary);
  background: #e8f0fe;
}

.option-item.correct {
  border-color: var(--success);
  background: #e6f4ea;
}

.option-item.incorrect {
  border-color: var(--danger);
  background: #fce8e6;
}

.option-key {
  font-weight: 700;
  font-size: 0.95rem;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--border);
  color: var(--text);
  flex-shrink: 0;
}

.option-item.selected .option-key {
  background: var(--primary);
  color: #fff;
}

.option-text {
  font-size: 1rem;
  line-height: 1.4;
  flex: 1;
}

/* Explanation Box (Study Mode) */
.explanation-box {
  margin-top: 1.5rem;
  padding: 1.25rem;
  border-radius: 8px;
  background: #f8f9fa;
  border-left: 4px solid var(--primary);
}

.explanation-box h4 {
  margin-bottom: 0.5rem;
  color: var(--primary);
  font-size: 1rem;
}

.explanation-box p {
  white-space: pre-line;
  font-size: 0.95rem;
  color: var(--text);
}

/* Exam Navigation */
.exam-navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
}

/* Review Screen Modal / View */
.review-palette {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
}

.palette-legend {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-dot {
  width: 16px;
  height: 16px;
  border-radius: 4px;
}

.legend-dot.answered { background: var(--primary); }
.legend-dot.unanswered { background: var(--border); }
.legend-dot.flagged { background: var(--flagged); }

.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
  gap: 0.75rem;
}

.palette-btn {
  height: 45px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.2s;
}

.palette-btn.answered {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.palette-btn.flagged::after {
  content: "★";
  color: var(--flagged);
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.75rem;
}

/* Score Screen */
.score-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.score-badge {
  display: inline-block;
  font-size: 1.4rem;
  font-weight: 800;
  padding: 0.5rem 2rem;
  border-radius: 30px;
  margin-bottom: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.score-badge.pass {
  background: #e6f4ea;
  color: #137333;
  border: 2px solid #34a853;
}

.score-badge.fail {
  background: #fce8e6;
  color: #c5221f;
  border: 2px solid #ea4335;
}

.score-number {
  font-size: 3.5rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.domain-stats-box {
  margin: 2rem 0;
  text-align: left;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.domain-row {
  margin-bottom: 1rem;
}

.domain-title {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.progress-bar-bg {
  width: 100%;
  height: 10px;
  background: #e8eaed;
  border-radius: 5px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 5px;
}
