:root {
  --ink: #17212b;
  --paper: #f7f7f2;
  --accent: #13795b;
  --line: #d4d8d0;
  --muted: #5b6660;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Georgia, serif;
  font-size: 18px;
  line-height: 1.6;
}

a { color: var(--accent); }

.container { width: min(100% - 32px, 960px); margin: 0 auto; }

.site-header { border-bottom: 1px solid var(--line); background: #ffffff; }
.navigation { display: flex; align-items: center; justify-content: space-between; min-height: 68px; gap: 24px; }
.navigation nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px 20px; }
.navigation a { text-decoration: none; }
.brand { color: var(--ink); font-weight: 700; }

main.container { padding-block: 64px; min-height: calc(100vh - 140px); }
h1 { margin: 0 0 16px; font-size: 42px; line-height: 1.15; }
h2 { margin: 0 0 8px; font-size: 24px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-family: Arial, sans-serif; font-size: 14px; font-weight: 700; text-transform: uppercase; }
.intro { max-width: 700px; }
.button { display: inline-block; margin-top: 12px; padding: 10px 16px; color: #ffffff; background: var(--accent); border-radius: 4px; text-decoration: none; }
.page-heading { margin-bottom: 32px; }
.classes-overview { margin-top: -32px; }
.class-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; }
.class-card { padding: 22px; border: 1px solid rgba(23, 33, 43, 0.14); border-radius: 8px; box-shadow: 0 5px 16px rgba(23, 33, 43, 0.05); }
.class-card:nth-child(6n + 1) { background: linear-gradient(135deg, rgba(255, 107, 107, 0.5), rgba(255, 226, 226, 0.5)); }
.class-card:nth-child(6n + 2) { background: linear-gradient(135deg, rgba(255, 193, 7, 0.5), rgba(255, 244, 194, 0.5)); }
.class-card:nth-child(6n + 3) { background: linear-gradient(135deg, rgba(76, 175, 80, 0.5), rgba(218, 244, 219, 0.5)); }
.class-card:nth-child(6n + 4) { background: linear-gradient(135deg, rgba(33, 150, 243, 0.5), rgba(213, 236, 255, 0.5)); }
.class-card:nth-child(6n + 5) { background: linear-gradient(135deg, rgba(156, 39, 176, 0.5), rgba(238, 215, 243, 0.5)); }
.class-card:nth-child(6n) { background: linear-gradient(135deg, rgba(255, 112, 67, 0.5), rgba(255, 226, 216, 0.5)); }
.class-card-heading { display: flex; align-items: center; gap: 14px; }
.class-mark { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; color: #ffffff; background: var(--accent); border-radius: 50%; font-family: Arial, sans-serif; font-size: 20px; font-weight: bold; }
.class-kicker { margin: 0; color: var(--muted); font-family: Arial, sans-serif; font-size: 12px; font-weight: bold; letter-spacing: 0.08em; text-transform: uppercase; }
.class-card h3 { margin: 2px 0 0; font-size: 22px; }
.class-total { margin: 22px 0 18px; color: var(--muted); font-family: Arial, sans-serif; font-size: 14px; }
.class-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.class-actions .button { margin: 0; padding: 8px 12px; font-family: Arial, sans-serif; font-size: 14px; }
.class-actions .button span { margin-left: 4px; }
.text-link { font-family: Arial, sans-serif; font-size: 13px; font-weight: bold; text-decoration: none; }
.question-proposal {
  margin: 0 0 16px;
  padding: 14px 16px;
  background: #f0f6f2;
  border-left: 4px solid var(--accent);
}
.question-proposal-content { margin-top: 8px; line-height: 1.5; }
.question-proposal-text { vertical-align: middle; }
.automatisme-code {
  margin: 10px 0;
  padding: 12px 14px;
  overflow-x: auto;
  color: #e8edf2;
  background: #17212b;
  border: 0;
  border-radius: 4px;
  font-family: 'Fira Code', 'Cascadia Code', Consolas, monospace;
  font-size: 0.92em;
  line-height: 1.5;
  white-space: pre-wrap;
}
.automatisme-code code { color: inherit; background: transparent; border: 0; }
.course-list { border-top: 1px solid var(--line); }
.course-item { padding: 24px 0; border-bottom: 1px solid var(--line); }
.course-item p { margin: 0; color: var(--muted); }
.lesson { max-width: 760px; }
.lesson-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.lesson-heading h1 { flex: 1; }
.print-button {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.print-button:hover { background: #f0f4f2; }
.lesson-content { margin-top: 28px; }
.activity-question {
  margin: 20px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: #ffffff;
}
.activity-question-text { margin-bottom: 12px; }
.activity-question-text > :first-child { margin-top: 0; }
.activity-question-text > :last-child { margin-bottom: 0; }
.activity-answer summary {
  display: inline-block;
  padding: 8px 12px;
  color: #ffffff;
  background: var(--accent);
  border-radius: 4px;
  cursor: pointer;
  font-family: Arial, sans-serif;
  font-size: 15px;
  font-weight: 700;
}
.activity-answer summary:hover { background: #0f624a; }
.activity-answer-content { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

.assignment-sheet {
  max-width: none;
  margin: 0;
}
.assignment-sheet-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.assignment-sheet-heading h2 { margin-bottom: 0; }
.assignment-header {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 16px 28px;
  margin: 24px 0 36px;
  padding: 16px;
  border: 1px solid var(--line);
  font-family: Arial, sans-serif;
  font-size: 16px;
}
.assignment-header label { display: flex; gap: 8px; align-items: baseline; }
.assignment-header input {
  min-width: 0;
  flex: 1;
  padding: 4px;
  border: 0;
  border-bottom: 1px solid var(--ink);
  font: inherit;
  background: transparent;
}
.assignment-exercise { margin-top: 32px; }
.assignment-exercise h2 { margin-bottom: 8px; }
.assignment-exercise-edit { color: inherit; }
.assignment-exercise-edit:hover { color: var(--accent); }
.exercise-correction {
  margin-top: 20px;
  padding: 12px;
  border: 2px solid #c62828;
  border-radius: 4px;
  background: #fff8f8;
}
.exercise-correction summary {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid #c62828;
  border-radius: 4px;
  color: #b71c1c;
  cursor: pointer;
  font-weight: bold;
}
.exercise-correction summary:hover { background: #ffebee; }
.exercise-correction[open] summary { margin-bottom: 12px; }
.assignment-exercise-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.assignment-exercise-option span { display: flex; flex-direction: column; }
.assignment-exercise-option small { color: var(--muted); font-size: 13px; }

code {
  font-family: 'Fira Code', 'Cascadia Code', Consolas, Monaco, 'Andale Mono', monospace;
  font-size: 0.9em;
}

:not(pre) > code {
  padding: 0.2em 0.45em;
  color: #0f5132;
  background-color: #e8f5e9;
  border: 1px solid #c8e6c9;
  border-radius: 4px;
}

.code-block-container {
  margin: 1.5rem 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  background: #1e1e2e;
  border: 1px solid #313244;
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: #181825;
  color: #a6adc8;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid #313244;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.code-block-header .copy-btn {
  background: #313244;
  color: #cdd6f4;
  border: none;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.code-block-header .copy-btn:hover {
  background: #45475a;
  color: #ffffff;
}

pre {
  margin: 0;
  padding: 18px 20px;
  overflow-x: auto;
  background: #1e1e2e;
  color: #cdd6f4;
  line-height: 1.55;
  font-size: 15px;
}

pre code {
  background: transparent !important;
  padding: 0 !important;
  border: none !important;
  color: inherit;
}

/* Style des tableaux de contenu Markdown et tables de vérité */
.lesson-content table,
.content-table {
  border-collapse: collapse !important;
  margin: 1.5rem 0;
  background: #ffffff;
  border: 2px solid #17212b !important;
}

.lesson-content table th,
.lesson-content table td,
.content-table th,
.content-table td {
  padding: 10px 18px !important;
  border: 1px solid #17212b !important;
  text-align: center !important;
  vertical-align: middle;
}

.lesson-content table th,
.content-table th {
  background: #e8f5e9 !important;
  font-family: Arial, sans-serif;
  font-size: 15px;
  font-weight: bold;
  color: #13795b !important;
  border-bottom: 2px solid #17212b !important;
}

.lesson-content table tr:nth-child(even),
.content-table tr:nth-child(even) {
  background-color: #f7f9f8;
}
.content-image {
  display: block;
  width: 100%;
  max-width: 760px;
  height: min(420px, 60vw);
  min-height: 180px;
  margin: 20px auto;
  padding: 10px;
  box-sizing: border-box;
  object-fit: contain;
  border: 1px solid #b9aa8d;
  border-radius: 6px;
  background: #fbf7ee;
  box-shadow: 0 4px 12px rgba(40, 56, 69, 0.12);
}

.notice { padding: 16px; border-left: 4px solid #c58a18; background: #fff8de; margin-bottom: 24px; }
.notice-success { border-left-color: #13795b; background: #e8f5e9; }
.notice-error { border-left-color: #d32f2f; background: #ffebee; }

/* Widget interactif de visualisation de la parabole (second degré) */
.parabole-widget {
  margin: 1.5rem 0;
  padding: 16px;
  border: 1px solid var(--line, #ddd);
  border-radius: 6px;
  background: #fbfbfb;
}
.parabole-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 12px;
  font-family: Arial, sans-serif;
  font-size: 14px;
}
.parabole-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.parabole-canvas {
  display: block;
  max-width: 100%;
  background: #ffffff;
  border: 1px solid var(--line, #ddd);
  border-radius: 4px;
}
.parabole-info {
  margin-top: 10px;
  font-family: Arial, sans-serif;
  font-size: 14px;
  color: #333;
}
.nuage-points-widget {
  margin: 24px 0;
  padding: 18px;
  border: 1px solid var(--line);
  background: #f8fafc;
}
.nuage-points-caption {
  margin-top: 0;
}
.nuage-points-canvas {
  display: block;
  width: 100%;
  max-width: 620px;
  height: auto;
  border: 1px solid var(--line, #ddd);
  background: #fff;
}
.nuage-points-info {
  min-height: 1.5em;
  margin-bottom: 0;
}

/* Widget interactif du nombre d'or et de l'architecture grecque */
.golden-greece-widget {
  margin: 24px 0;
  padding: 18px;
  border: 1px solid var(--line, #ddd);
  background: #fbf7ee;
}
.golden-greece-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.golden-greece-gallery figure {
  margin: 0;
  padding: 10px;
  border: 1px solid #b9aa8d;
  border-radius: 6px;
  background: #fffdf7;
  box-shadow: 0 4px 12px rgba(40, 56, 69, 0.1);
}
.golden-greece-gallery img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border: 1px solid #d8cdb8;
  background: #fff;
}
.golden-greece-gallery figcaption {
  margin-top: 6px;
  font-size: 0.9rem;
  color: #48545b;
}
.golden-greece-control {
  display: block;
  margin-bottom: 12px;
  font-size: 0.95rem;
}
.golden-greece-control input {
  display: block;
  width: min(100%, 420px);
  margin-top: 8px;
}
.golden-greece-canvas {
  display: block;
  width: 100%;
  max-width: 760px;
  height: auto;
  border: 1px solid var(--line, #ddd);
  background: #f5efe1;
}
.golden-greece-info {
  min-height: 1.5em;
  margin-bottom: 0;
  color: #283845;
}

@media (max-width: 620px) {
  .golden-greece-gallery {
    grid-template-columns: 1fr;
  }
}

/* Styles pour la page redige.php */
.redige-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-top: 24px;
}

@media (max-width: 900px) {
  .redige-grid {
    grid-template-columns: 1fr;
  }
}

.editor-column, .preview-column {
  background: #ffffff;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.redige-form .form-group {
  margin-bottom: 20px;
}

.redige-form label {
  display: block;
  font-family: Arial, sans-serif;
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 6px;
  color: var(--ink);
}

.redige-form input[type="text"],
.redige-form input[type="number"],
.redige-form input[type="date"],
.redige-form textarea,
.redige-form select,
.editor-column select {
  width: 100%;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fafafa;
}

.redige-form input:focus,
.redige-form textarea:focus,
.redige-form select:focus,
.editor-column select:focus {
  outline: none;
  border-color: var(--accent);
  background: #ffffff;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 24px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.button-success {
  background-color: #13795b;
  border: none;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  padding: 12px 24px;
  border-radius: 6px;
}

.button-success:hover {
  background-color: #0f5132;
}

.preview-box {
  border: 1px dashed var(--line);
  padding: 16px;
  border-radius: 6px;
  background: #fafafa;
  min-height: 300px;
}

/* Styles pour admin.php */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  margin-top: 16px;
}

.admin-table th, .admin-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.admin-table th {
  background: #f0f4f2;
  font-family: Arial, sans-serif;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.position-input {
  width: 60px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  text-align: center;
  font-size: 15px;
  font-weight: bold;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: bold;
  border-radius: 12px;
  font-family: Arial, sans-serif;
}

.badge-published { background: #e8f5e9; color: #1b5e20; }
.badge-draft { background: #fff3e0; color: #e65100; }

.muted-text { color: var(--muted); font-size: 14px; }

.admin-collapsible > summary { cursor: pointer; }
.exercise-picker { border-top: 1px solid var(--line); }
.exercise-picker-row,
.selected-exercise {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.exercise-picker-row a { flex: 1; font-weight: bold; }
.exercise-picker-row span { display: flex; flex: 1; flex-direction: column; }
.exercise-picker-row .button { margin-top: 0; padding: 6px 12px; font-size: 14px; }
.selected-exercise span { flex: 1; }

@media (max-width: 560px) {
  .exercise-picker-row,
  .selected-exercise { align-items: flex-start; flex-direction: column; gap: 8px; }
}

.action-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.btn-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: bold;
}

.btn-edit {
  background: #e3f2fd;
  color: #1565c0;
  border: 1px solid #bbdefb;
  padding: 4px 10px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 13px;
  font-weight: bold;
  transition: background 0.2s;
}

.btn-edit:hover {
  background: #bbdefb;
}

.btn-delete {
  background: #ffebee;
  color: #c62828;
  border: 1px solid #ffcdd2;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
  transition: background 0.2s;
}

.btn-delete:hover {
  background: #ffcdd2;
}

.site-footer { padding: 24px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 15px; }

@media print {
  @page { margin: 15mm; }

  * {
    color: #000000 !important;
    background: #ffffff !important;
    box-shadow: none !important;
  }

  .site-header,
  .site-footer,
  .lesson .eyebrow,
  .print-button,
  .assignment-controls,
  .activity-answer summary,
  .course-view .activity-answer > summary { display: none !important; }

  body { font-size: 12pt; }
  main.container { width: 100%; min-height: 0; padding: 0; }
  .lesson { max-width: none; }
  .lesson-heading h1 { margin-bottom: 0; }
  .lesson-content { margin-top: 0; }
  .course-view .activity-question {
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
  }
  .course-view .activity-question + br { display: none !important; }
  .course-view .activity-question-text { margin-bottom: 0; }
  .course-view .activity-answer-content { margin-top: 0; padding-top: 0; }
  .assignment-sheet { max-width: none; margin: 0; padding: 0; border: 0; }
  .assignment-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 32px;
    margin: 26px 0 38px;
    padding: 18px 20px;
    border: 2px solid #000000;
    border-radius: 4px;
    font-size: 12pt;
  }
  .assignment-header input { border-bottom-color: #000000; }
  pre { white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid #000000; }
  .code-block-container { border: 1px solid #000000; }
  .assignment-sheet .code-block-header { display: none; }
  .assignment-exercise-id { display: inline !important; color: #000000 !important; }
  .exercise-correction { display: block !important; }
  .exercise-correction > summary { display: block !important; font-weight: bold; }
  .exercise-correction > :not(summary) { display: block !important; }
  .assignment-sheet .katex-display {
    margin: 0.8em 0;
    overflow: visible;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .assignment-sheet .katex,
  .assignment-sheet .katex * {
    color: #000000 !important;
    background: transparent !important;
  }
  .assignment-sheet .katex .frac-line { border-bottom-color: #000000 !important; }
  a { text-decoration: none; }
}

@media (max-width: 560px) {
  .navigation { min-height: 58px; }
  .navigation nav { gap: 12px; }
  main.container { padding-block: 40px; }
  h1 { font-size: 34px; }
  .assignment-sheet { padding: 20px; }
  .assignment-header { grid-template-columns: 1fr; }
}