:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --border: #d7dcea;
  --text: #1a2440;
  --muted: #5a647a;
  --primary: #295dff;
  --primary-soft: #e9efff;
  --correct: #1f9d55;
  --wrong: #d93025;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand-block {
  display: flex;
  align-items: center;
}

.site-logo {
  width: 320px;
  max-width: 46vw;
  height: auto;
}

h1 {
  margin: 0;
  font-size: 1.35rem;
}

#app-subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.language-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

select,
button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0.45rem 0.7rem;
  min-height: 40px;
}

button {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  cursor: pointer;
}

button.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
  padding: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.summary-panel {
  position: sticky;
  top: 1rem;
  height: fit-content;
}

.summary-panel h2,
.quiz-panel h2 {
  margin-top: 0;
}

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

.helper {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.quiz-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.question-list {
  display: grid;
  gap: 0.75rem;
}

.question-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  background: #fff;
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.question-number {
  margin: 0;
  font-size: 1rem;
}

.question-text {
  margin: 0.5rem 0;
  line-height: 1.45;
  white-space: pre-line;
}

.options {
  display: grid;
  gap: 0.4rem;
}

.option-label {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
}

.option-label:hover {
  background: var(--primary-soft);
}

.option-label.correct-highlight {
  border-color: var(--correct);
  background: #e8f7ef;
}

.option-label.wrong-highlight {
  border-color: var(--wrong);
  background: #ffefee;
}

.result-badge {
  font-size: 0.82rem;
  color: var(--muted);
}

.result-badge.correct {
  color: var(--correct);
}

.result-badge.wrong {
  color: var(--wrong);
}

.answer-line {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.hidden {
  display: none;
}

.chapter-tag {
  display: inline-block;
  margin: 0 0 0.45rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.8rem;
  background: #f7f9ff;
}

.mode-buttons {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}

#dataset-buttons button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .summary-panel {
    position: static;
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: 0.75rem;
    gap: 0.75rem;
    align-items: flex-start;
  }

  .site-logo {
    width: 250px;
    max-width: 100%;
  }

  h1 {
    font-size: 1.15rem;
  }

  #app-subtitle {
    font-size: 0.9rem;
  }

  .language-controls {
    width: 100%;
    gap: 0.45rem;
    font-size: 0.9rem;
  }

  .language-controls select {
    flex: 1 1 160px;
    min-width: 140px;
  }

  .layout {
    padding: 0.7rem;
    gap: 0.7rem;
  }

  .panel {
    padding: 0.75rem;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .mode-buttons {
    grid-template-columns: 1fr;
  }

  .question-card {
    padding: 0.65rem;
  }

  .question-header {
    align-items: flex-start;
    gap: 0.4rem;
    flex-direction: column;
  }

  .result-badge {
    font-size: 0.78rem;
  }

  .option-label {
    padding: 0.6rem;
  }

  .answer-line {
    font-size: 0.86rem;
    line-height: 1.35;
  }
}

@media (max-width: 480px) {
  .site-logo {
    width: 210px;
  }

  .language-controls select,
  .language-controls button {
    flex: 1 1 100%;
  }

  .actions {
    grid-template-columns: 1fr;
  }

  .summary-panel,
  .quiz-panel {
    border-radius: 10px;
  }
}
