/* ===== Global Reset & Base ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Verdana, sans-serif;
  font-size: 15px;
  color: #1E293B;
  background-color: #ffffff;
  line-height: 1.8;
  letter-spacing: 0.5px;
}

a { color: #3B82F6; text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4, h5, h6 {
  font-family: 'Segoe UI', sans-serif;
}

h1 { font-size: 30px; margin-bottom: 12px; }
h2 { font-size: 22px; margin: 20px 0 10px; }
h3 { font-size: 18px; margin: 16px 0 8px; }
p  { margin-bottom: 14px; }
.content-area ul, .content-area ol { padding-left: 30px; margin-bottom: 16px; }
.content-area li { margin-bottom: 8px; }
hr { border: 0; border-top: 1px solid #e2e8f0; margin: 20px 0; }

table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
th, td { border: 1px solid #e2e8f0; padding: 10px 14px; text-align: left; }

.content-area table th:first-child,
.content-area table td:first-child {
  white-space: nowrap;
}

th { background-color: #f8fafc; font-weight: 600; color: #1E3A5F; }

code {
  background: #f1f1f1;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: Consolas, monospace;
  font-size: 14px;
  word-wrap: break-word;
  word-break: break-word;
}

.content-area div[style*="background-color: #282A35"] code,
.content-area div[style*="background: #282A35"] code {
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
  display: block;
}

.content-area div[style*="background-color: #282A35"] code *,
.content-area div[style*="background: #282A35"] code * {
  color: inherit !important;
}

.page-layout { display: flex; min-height: 100vh; width: 100%; }
.content-area { flex: 1; padding: 30px 40px; max-width: 100%; background: #ffffff; overflow-x: hidden; }

/* ===== Example Box ===== */
.example-box:not(.floating-editor) {
  background: #e2e3e4;
  padding: clamp(12px, 3vw, 20px);
  margin: 24px 0;
  border-radius: 4px;
  max-width: 100%;
  width: 100%;
  overflow: hidden;
  border-left: none;
  box-sizing: border-box;
  display: block;
}

.example-box:not(.floating-editor) h3 {
  margin: 0 0 8px;
  font-size: clamp(1rem, 3vw, 1.5rem);
  line-height: 1.2;
  font-weight: 400;
  letter-spacing: 0;
  color: #000;
  font-family: 'Segoe UI', sans-serif;
  word-break: break-word;
}

.example-box:not(.floating-editor) pre {
  background: #fff;
  border: none;
  border-left: 4px solid #3B82F6;
  padding: clamp(10px, 2vw, 16px) clamp(10px, 2vw, 20px);
  margin: 0 0 14px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: clamp(12px, 1.8vw, 14px);
  line-height: 1.8;
  border-radius: 0;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  white-space: pre;
  word-break: normal;
  -webkit-overflow-scrolling: touch;
  display: block;
}

.example-box:not(.floating-editor) pre {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.example-box:not(.floating-editor) pre::-webkit-scrollbar { height: 4px; }
.example-box:not(.floating-editor) pre::-webkit-scrollbar-track { background: transparent; }
.example-box:not(.floating-editor) pre::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
.example-box:not(.floating-editor) pre::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.example-box:not(.floating-editor) pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  color: #000 !important;
  display: block;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: inherit;
  white-space: pre;
  word-break: normal;
}

.example-box:not(.floating-editor) pre code * {
  color: inherit;
  font-family: inherit;
  font-size: inherit;
}

.example-box:not(.floating-editor) pre .comment,
.example-box:not(.floating-editor) pre .token.comment,
.example-box:not(.floating-editor) pre .token.prolog,
.example-box:not(.floating-editor) pre .token.doctype,
.example-box:not(.floating-editor) pre .token.cdata {
  color: #aaa;
  font-size: 0.92em;
  opacity: 1;
}

.example-box:not(.floating-editor) pre .token.keyword {
  color: #ff0000;
}

.example-box:not(.floating-editor) button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #3B82F6;
  color: #fff;
  border: none;
  padding: clamp(8px, 2vw, 10px) clamp(14px, 3vw, 22px);
  border-radius: 4px;
  cursor: pointer;
  font-size: clamp(13px, 1.8vw, 16px);
  font-weight: 600;
  font-family: 'Segoe UI', sans-serif;
  line-height: 1;
  white-space: nowrap;
}

.example-box:not(.floating-editor) button:hover {
  background: #2563EB;
}

/* ===== Misc Utilities ===== */
.html-tag { color: darkred; }

.nav-buttons { display: flex; justify-content: space-between; margin-top: 40px; }
.nav-buttons.top { margin-top: 10px; margin-bottom: 30px; }
.nav-buttons a {
  background: #3B82F6;
  color: #fff;
  border: 2px solid #3B82F6;
  padding: 4px 10px;
  font-size: 13px;
  border-radius: 4px;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}
.nav-buttons a:hover {
  background: #2563EB;
  border-color: #2563EB;
  text-decoration: none;
}
.nav-buttons a.disabled { pointer-events: none; background: #E2E8F0; color: #94A3B8; border-color: #E2E8F0; }

.note { background: #ffffcc; border-left: 6px solid #ffeb3b; padding: 12px 16px; margin: 16px 0; }

.note-section,
.warning-section,
.lesson-note {
  margin: 20px 0;
  padding: 28px 24px;
  color: #000000;
  border-radius: 0;
}

.note-section,
.lesson-note { background: #d9eee1; }

.warning-section { background: #ffb3b3; }

.note-section p,
.warning-section p,
.lesson-note p { margin: 0; }

.note-section p + p,
.warning-section p + p,
.lesson-note p + p { margin-top: 0; }

.note-section code,
.warning-section code,
.lesson-note code,
.lesson-note-success code {
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
}

/* ===== Subject Grid ===== */
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-top: 24px; }
.subject-card { background: #f1f1f1; border-radius: 8px; padding: 20px; border: 2px solid transparent; transition: border-color 0.2s; }
.subject-card:hover { border-color: #3B82F6; text-decoration: none; }
.subject-card h3 { margin-bottom: 6px; }

/* ===== Footer ===== */
.site-footer { background: #282A35; border-top: none; padding: 40px 20px; text-align: center; font-size: 14px; color: #f1f1f1; }
.site-footer-links { list-style: none; display: flex; justify-content: center; gap: 24px; margin-bottom: 24px; flex-wrap: wrap; }
.site-footer-links a { color: #ffffff; font-weight: 600; text-decoration: none; transition: color 0.2s; }
.site-footer-links a:hover { color: #3B82F6; }
.site-footer-disclaimer { max-width: 800px; margin: 0 auto 24px auto; line-height: 1.6; font-size: 13px; color: #cbd5e1; }
.site-footer-copyright { font-size: 14px; color: #ffffff; font-weight: 500; }

/* ===== Search ===== */
.search-result-item { padding: 14px 0; border-bottom: 1px solid #eee; }
.search-result-item a { font-size: 17px; font-weight: 600; }
.search-result-item p { font-size: 14px; color: #666; margin: 4px 0 0; }

/* ===== Certificate ===== */
.certificate { text-align: center; padding: 60px 40px; border: 4px double #3B82F6; border-radius: 16px; max-width: 600px; margin: 40px auto; }
.certificate h2 { color: #3B82F6; font-size: 28px; margin: 16px 0; }

/* ===== Quiz ===== */
.quiz-question { background: #f9f9f9; border-radius: 8px; padding: 16px 20px; margin-bottom: 20px; }
.quiz-question p { margin-bottom: 10px; }
#quizResult { background: #eff6ff; border-left: 6px solid #3B82F6; padding: 16px 20px; border-radius: 0 8px 8px 0; margin-top: 20px; }

.lesson-quiz {
  position: relative;
  width: 100%;
  max-width: none;
  margin: 28px 0 20px;
  padding: 12px !important;
  border: 1px solid #d6e4f5;
  border-radius: 18px;
  background: linear-gradient(180deg, #f8fbff 0%, #eef5ff 100%);
  color: #1E293B;
  box-shadow: 0 14px 30px rgba(30, 58, 95, 0.08);
  overflow: hidden;
  box-sizing: border-box;
}

.lesson-quiz::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, #1E3A5F, #3B82F6);
}

.lesson-quiz.is-correct { box-shadow: 0 18px 40px rgba(16, 185, 129, 0.14); }
.lesson-quiz.is-incorrect { box-shadow: 0 18px 40px rgba(239, 68, 68, 0.12); }

.lesson-quiz-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.lesson-quiz-header h2 {
  margin: 0;
  color: #1E3A5F;
  font-size: clamp(18px, 2.2vw, 24px);
  line-height: 1.1;
  letter-spacing: -0.4px;
}

.lesson-quiz-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #dbeafe;
  color: #1E3A5F;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.lesson-quiz-question {
  margin: 0 0 12px;
  color: #1E293B;
  text-align: left;
  font-size: clamp(14px, 1.8vw, 17px);
  font-weight: 700;
  line-height: 1.4;
}

.lesson-quiz-options { display: grid; gap: 8px; }

.lesson-quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #d6e4f5;
  border-radius: 12px;
  background: #ffffff;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.lesson-quiz-option:hover {
  transform: translateY(-1px);
  background: #f8fbff;
  border-color: #93c5fd;
  box-shadow: 0 10px 24px rgba(59, 130, 246, 0.08);
}

.lesson-quiz-option.is-selected {
  background: #eff6ff;
  border-color: #3B82F6;
  box-shadow: 0 10px 24px rgba(59, 130, 246, 0.14);
}

.lesson-quiz-option input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: #3B82F6;
}

.lesson-quiz-option span {
  color: #1E293B;
  font-size: clamp(13px, 1.6vw, 15px);
  font-weight: 600;
  line-height: 1.45;
  word-break: break-word;
}

.lesson-quiz-submit, .lesson-quiz-next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 14px 0 0;
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #1E3A5F, #3B82F6);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.lesson-quiz-submit:hover, .lesson-quiz-next:hover {
  background: linear-gradient(135deg, #16304e, #2563eb);
  transform: translateY(-1px);
}

.lesson-quiz-feedback {
  min-height: 22px;
  margin: 10px 0 0;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.lesson-quiz-feedback.is-correct { color: #047857; }
.lesson-quiz-feedback.is-incorrect { color: #b91c1c; }

/* ===== Navbar ===== */
.navbar { background-color: #FFFFFF !important; border-bottom: 1px solid #ddd; }
.navbar a, .navbar .logo { color: #1E3A5F !important; }

/* ===== Responsive: Tablet (max 1024px) ===== */
@media (max-width: 1024px) {
  .page-layout { flex-direction: column; }
  .content-area { padding: 20px 16px; width: 100%; max-width: none; overflow-x: hidden; }
  .nav-buttons { flex-direction: row; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
  .certificate { padding: 30px 20px; }

  img, pre, iframe, table {
    max-width: 100%;
    overflow-x: auto;
  }

  h1 { font-size: 24px; }
  h2 { font-size: 20px; }

  .example-box:not(.floating-editor) {
    padding: 16px;
    margin: 16px 0;
    width: 100%;
    max-width: none;
    overflow: hidden;
  }

  .example-box:not(.floating-editor) h3 {
    font-size: clamp(16px, 4vw, 22px);
    margin-bottom: 10px;
  }

  .example-box:not(.floating-editor) pre {
    padding: 12px 14px;
    font-size: 13px;
    border-left: 4px solid #3B82F6;
    margin-bottom: 14px;
    overflow-x: auto;
  }

  .example-box:not(.floating-editor) button {
    padding: 9px 18px;
    font-size: 14px;
    width: auto;
  }

  .lesson-quiz {
    max-width: none;
    margin: 22px 0 16px;
    padding: 12px !important;
    border-radius: 16px;
  }

  .lesson-quiz-question { margin-bottom: 12px; }
  .lesson-quiz-option { padding: 10px 12px; }
  .lesson-quiz-submit, .lesson-quiz-next { width: 100%; }
  .lesson-quiz-header h2 { font-size: 18px; }
}

/* ===== Responsive: Mobile (max 480px) ===== */
@media (max-width: 480px) {
  .content-area { padding: 14px 12px; }

  h1 { font-size: 20px; }
  h2 { font-size: 18px; }
  h3 { font-size: 16px; }

  .example-box:not(.floating-editor) {
    padding: 12px;
    margin: 12px 0;
    border-radius: 4px;
  }

  .example-box:not(.floating-editor) h3 {
    font-size: 16px;
    margin-bottom: 8px;
  }

  .example-box:not(.floating-editor) pre {
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.7;
    border-left: 4px solid #3B82F6;
    overflow-x: auto;
    white-space: pre;
  }

  .example-box:not(.floating-editor) button {
    width: 100%;
    justify-content: center;
    padding: 10px 16px;
    font-size: 14px;
  }

  .nav-buttons { flex-direction: column; gap: 8px; }
  .nav-buttons a { text-align: center; }

  .note-section,
  .warning-section,
  .lesson-note { padding: 16px 14px; }

  .lesson-quiz { margin: 16px 0 12px; }
  .lesson-quiz-submit, .lesson-quiz-next { width: 100%; font-size: 13px; }

  .subject-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .subject-card { padding: 14px; }

  .certificate { padding: 24px 16px; }
  .site-footer-links { gap: 14px; }
}