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

html, body {
  background: #f5f5f5;
  font-family: 'Patrick Hand', cursive;
  color: #333;
  line-height: 1.6;
  min-height: 100vh;
  padding: 16px 0;
  /* Set base font size for rem units with responsiveness */
  font-size: 16px;
}

/* Responsive base font size */
@media (max-width: 900px) {
  html, body {
    font-size: 15px;
  }
}

@media (max-width: 700px) {
  html, body {
    font-size: 14px;
  }
}

@media (max-width: 500px) {
  html, body {
    font-size: 13px;
  }
}

/* === Notebook Page === */
.notebook-page {
  max-width: 900px;
  margin: 0 auto;
  background: #fff;
  position: relative;
  padding: 40px 30px 60px 50px;
  border-radius: 6px;
  box-shadow: 0 0 16px rgba(0,0,0,0.15);
  background-image: linear-gradient(to bottom, #e3eafe 1px, transparent 1px);
  background-size: 100% 32px;
}

/* === Margin Line === */
.margin-line {
  position: absolute;
  left: 20px;
  top: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(to right, #ff6666 0% 35%, #ff9999 35% 80%, #ff6666 80% 100%);
  border-radius: 2px;
}

/* === Headings === */
h1 {
  font-family: 'Caveat', cursive;
  text-align: center;
  margin: 0 0 30px 0;
  font-size: 2.2rem;
  text-decoration: underline;
  font-weight: 700;
  color: #3e7708; /* default green */
}

h1.blue {
  color: #0609c4;
}

/* === Question & Solution Blocks === */
.exercise {
  margin-bottom: 30px;
  padding-left: 10px;
}

.question {
  color: #850324;
  font-weight: bold;
  font-size: 1.5rem;
  margin-bottom: 12px;
}

/* .solution defines overall visual for solution area */
.solution {
  color: #000080;
  font-size: 1.5rem;
  margin-left: 1px;
  margin-bottom: 20px;
  line-height: 1.6;
  background: linear-gradient(180deg, rgba(0,0,0,0.01), transparent);
  padding: 10px 12px;
  border-radius: 6px;
}

/* Ensure nested tags inherit solution style */
.solution p,
.solution .step,
.solution li,
.solution div,
.solution table,
.solution td,
.solution th,
.solution pre {
  color: inherit;
  font-size: inherit;
}

.part {
  display: inline-block;
  color: #b80c0c;
  font-size: 1.5rem;
}

/* Step block for sequential working */
.step {
  margin: 10px 0;
  padding-left: 12px;
}

/* Important visual elements */
.important-term {
  display: inline-block;
  background: #92e6263d;
  padding: 4px 8px;
  margin: 2px 0;
  border-radius: 3px;
  font-weight: 700;
}

.formula {
  display: block;
  font-family: 'Courier New', monospace;
  background: #f4f7fb;
  padding: 8px 10px;
  margin: 10px 0;
  border-radius: 6px;
  border: 1px dashed #cfd8e3;
  overflow-x: auto;
}

/* Final answer box */
.final-answer {
  background-color: #e6f7ff;
  padding: 12px 14px;
  border-radius: 6px;
  border: 2px solid #000080;
  margin: 12px 0;
  font-weight: 700;
}

/* Short note / hint box */
.note {
  background: #fff8e1;
  border-left: 4px solid #ffb300;
  padding: 8px 12px;
  border-radius: 4px;
  margin: 8px 0;
}

/* Multiple solutions container (tab-like or toggled list) */
.mult-solutions {
  margin-top: 8px;
}

.mult-solutions .option {
  margin: 8px 0;
  padding: 50px;
  border-radius: 6px;
  border: 1px solid #e0e7ff;
  background: #fafcffde;
}

.mult-solutions .option .label {
  font-weight: 700;
  margin-bottom: 6px;
  color: #0b333d;
}
.image-placeholder {
      width: 100%;
      height: 200px;
      /* background: #e0e0e0; */
      border: 1px dashed #f8f8f805;
      display: flex;
      align-items: right;
      justify-content: center;
      margin-top: 15px;
      color: #eee9e97a;
      font-family: sans-serif;
      font-size: 14px;
      text-align: center;
    }
/* Figure and diagram wrapper */
.figure {
  display: block;
  margin: 12px auto;
  text-align: center;
}

.figure caption {
  font-style: italic;
  margin-top: 6px;
  color: #666;
}

/* Table styling for factor tables and steps */
table.factor, table.step-table {
  border-collapse: collapse;
  margin: 8px 0;
}

table.factor td, table.factor th, table.step-table td {
  border: 1px solid #d6d6d6;
  padding: 6px 8px;
  text-align: center;
  vertical-align: middle;
}

/* Small helpers */
.small-muted {
  color: #666;
  font-size: 0.95rem;
}

/* Page-specific styles */
.part {
  display: block;
  margin-top: 16px;
}

.small-step {
  margin: 6px 0;
}

/* Print friendliness */
@media print {
  body { background: #fff; color: #000; }
  .notebook-page { box-shadow: none; background: transparent; }
  .margin-line { display: none; }
  .final-answer { page-break-inside: avoid; }
}

/* Responsive tweaks */
@media (max-width: 700px) {
  .notebook-page {
    padding: 22px 16px 36px 36px;
  }
  
  .question, .solution, .part {
    font-size: 1.3rem;
  }
  
  .formula { 
    font-size: 0.95rem; 
    padding: 6px 8px;
  }
}

@media (max-width: 500px) {
  .notebook-page {
    padding: 18px 12px 28px 28px;
  }
  
  .question, .solution, .part {
    font-size: 1.2rem;
  }
  
  h1 {
    font-size: 1.8rem;
  }
}