.polynomial-lesson {
  --poly-border: #d8e4f1;
  font-family: Inter, system-ui, sans-serif;
  --poly-soft: #f7faff;
  --poly-ink: #10203d;
  --poly-muted: #5d6d86;
  --poly-grid: #dbe6f2;
  --poly-axis: #425b7d;
}

.polynomial-lesson .studio-main {
  min-width: 0;
}

.poly-prerequisite,
.poly-callout {
  border-left: 3px solid #0877e8;
  padding: 14px 18px;
  background: #f3f8ff;
  border-radius: 0 10px 10px 0;
}

.poly-prerequisite a,
.polynomial-lesson .concept-link {
  color: #0069d9;
  font-weight: 750;
}

.poly-definition {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-start;
  gap: 8px 14px;
  padding: 16px 20px;
  border-left: 4px solid #0877e8;
  background: #edf5ff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.25rem, 2.4vw, 1.85rem);
  overflow-x: auto;
}

.poly-clean-list {
  display: grid;
  gap: 10px;
  padding: 0;
  list-style: none;
}

.poly-clean-list li {
  padding: 0 0 10px;
  border-bottom: 1px solid var(--poly-border);
}

.poly-clean-list li:last-child { border-bottom: 0; }

.poly-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  margin: 18px 0;
}

.poly-table {
  width: 100%;
  min-width: 660px;
  border-collapse: collapse;
  font-size: .93rem;
}

.poly-table th,
.poly-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--poly-border);
  text-align: left;
  vertical-align: top;
}

.poly-table th {
  color: #0b376d;
  background: #edf5ff;
}

.poly-plot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin: 20px 0;
}

.poly-plot-card,
.poly-plot-wide {
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--poly-border);
  border-radius: 12px;
  background: var(--poly-soft);
}

.poly-plot-card { margin: 0; }
.poly-plot-card h3,
.poly-plot-wide h3 { margin: 0 0 8px; font-size: 1rem; }
.poly-plot-card figcaption,
.poly-plot-wide figcaption { margin-top: 8px; color: var(--poly-muted); font-size: .9rem; }
.poly-svg { display: block; width: 100%; height: auto; min-width: 0; }
.poly-grid line { stroke: var(--poly-grid); stroke-width: 1; }
.poly-grid text,
.poly-axes text,
.poly-points text,
.poly-legend text { fill: var(--poly-muted); font: 12px Inter, sans-serif; }
.poly-axes line { stroke: var(--poly-axis); stroke-width: 1.8; }
.poly-curve { fill: none; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.poly-curve.is-dashed,
.poly-legend .is-dashed { stroke-dasharray: 8 6; }
.poly-points circle { fill: #0877e8; stroke: #fff; stroke-width: 2; }
.poly-points circle.is-extreme { fill: #d66a00; }
.poly-points circle.is-intersection { fill: #8255d9; }
.poly-legend line { stroke-width: 3; }

.poly-sign-line {
  display: grid;
  grid-template-columns: repeat(7, minmax(72px, 1fr));
  min-width: 620px;
  text-align: center;
  border-block: 1px solid var(--poly-border);
}
.poly-sign-line span { padding: 10px 8px; border-right: 1px solid var(--poly-border); }
.poly-sign-line span:last-child { border-right: 0; }
.poly-sign-line .positive { color: #007a5c; font-weight: 800; }
.poly-sign-line .negative { color: #b54708; font-weight: 800; }
.poly-sign-line .zero { color: #0877e8; font-weight: 800; }

.poly-solved-list {
  display: grid;
  gap: 14px;
}
.poly-solved-list details {
  border-bottom: 1px solid var(--poly-border);
  padding: 0 0 14px;
}
.poly-solved-list summary {
  cursor: pointer;
  color: var(--poly-ink);
  font-weight: 800;
}
.poly-solved-list details > div { padding: 10px 0 0 20px; }

.poly-exercise-group-title {
  margin: 28px 0 12px;
  color: #075fc7;
}

.poly-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 24px;
}

.polynomial-lesson .concept-strip {
  margin: 18px 0;
  padding: 13px 16px;
  border-left: 3px solid #0877e8;
  border-radius: 0 8px 8px 0;
  background: #f3f8ff;
  color: #29405f;
}

.polynomial-lesson .clean-table-wrap {
  max-width: 100%;
  margin: 18px 0;
  overflow-x: auto;
  border-block: 1px solid var(--poly-border);
}

.polynomial-lesson .clean-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: .94rem;
}

.polynomial-lesson .clean-table th,
.polynomial-lesson .clean-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--poly-border);
  text-align: left;
  vertical-align: top;
}

.polynomial-lesson .clean-table tr:last-child td { border-bottom: 0; }
.polynomial-lesson .clean-table th { color: #0b376d; background: #edf5ff; }

.polynomial-lesson .plot-grid {
  display: grid;
  gap: 14px;
  margin: 20px 0;
}
.polynomial-lesson .plot-grid-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.polynomial-lesson .plot-grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.polynomial-lesson .plot-grid-four { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.polynomial-lesson .plot-card {
  min-width: 0;
  margin: 18px 0;
  padding: 12px;
  border: 1px solid var(--poly-border);
  border-radius: 10px;
  background: var(--poly-soft);
}
.polynomial-lesson .plot-grid .plot-card { margin: 0; }
.polynomial-lesson .plot-card figcaption,
.polynomial-lesson .plot-caption { margin: 8px 0 0; color: var(--poly-muted); font-size: .9rem; text-align: center; }
.polynomial-lesson .polynomial-plot { min-width: 0; overflow: hidden; }
.polynomial-lesson .compact-plot { max-width: 700px; }

.polynomial-lesson .sign-chart,
.polynomial-lesson .variation-line {
  display: grid;
  grid-template-columns: repeat(7, minmax(72px, 1fr));
  min-width: 620px;
  margin: 18px 0;
  border-block: 1px solid var(--poly-border);
  text-align: center;
  overflow-x: auto;
}
.polynomial-lesson .sign-chart span,
.polynomial-lesson .sign-chart strong,
.polynomial-lesson .variation-line span,
.polynomial-lesson .variation-line strong { padding: 10px 8px; }
.polynomial-lesson .sign-chart strong,
.polynomial-lesson .variation-line strong { color: #0877e8; }
.polynomial-lesson .variation-line { grid-template-columns: 1fr auto 1fr auto 1fr; min-width: 500px; }

.polynomial-lesson .graph-method { display: grid; gap: 10px; padding-left: 1.4rem; }
.polynomial-lesson .solution-list { display: grid; gap: 0; margin-top: 16px; }
.polynomial-lesson .solution-details {
  border-bottom: 1px solid var(--poly-border);
  padding: 0;
}
.polynomial-lesson .solution-details summary,
.polynomial-lesson .answer-key-details summary {
  cursor: pointer;
  padding: 14px 4px;
  color: var(--poly-ink);
  font-weight: 800;
}
.polynomial-lesson .solution-details > div { padding: 0 4px 14px 24px; }
.polynomial-lesson .answer-key-details {
  margin-top: 24px;
  padding: 0 14px;
  border: 1px solid var(--poly-border);
  border-radius: 10px;
  background: var(--poly-soft);
}
.polynomial-lesson .answer-key-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 28px;
  padding: 0 20px 18px 38px;
}

[data-theme="dark"] .polynomial-lesson {
  --poly-border: #29425f;
  --poly-soft: #0f1f33;
  --poly-ink: #f4f8ff;
  --poly-muted: #b9c8dc;
  --poly-grid: #243b55;
  --poly-axis: #9fb3cc;
}
[data-theme="dark"] .poly-prerequisite,
[data-theme="dark"] .poly-callout,
[data-theme="dark"] .poly-definition,
[data-theme="dark"] .poly-table th { background: #10243c; color: #f5f8ff; }
[data-theme="dark"] .polynomial-lesson .concept-strip,
[data-theme="dark"] .polynomial-lesson .clean-table th,
[data-theme="dark"] .polynomial-lesson .answer-key-details { background: #10243c; color: #f5f8ff; }
[data-theme="dark"] .polynomial-lesson .plot-card { background: #0f1f33; }
[data-theme="dark"] .poly-prerequisite a,
[data-theme="dark"] .polynomial-lesson .concept-link { color: #77baff; }
[data-theme="dark"] .poly-table td,
[data-theme="dark"] .poly-sign-line span { color: #eef5ff; }

@media (max-width: 760px) {
  .poly-plot-grid,
  .poly-summary-grid,
  .polynomial-lesson .plot-grid-two,
  .polynomial-lesson .plot-grid-three,
  .polynomial-lesson .plot-grid-four,
  .polynomial-lesson .answer-key-list { grid-template-columns: 1fr; }
  .poly-plot-card,
  .poly-plot-wide { padding: 8px; }
  .poly-definition { font-size: 1.15rem; }
  .polynomial-lesson .plot-card { padding: 6px; }
  .polynomial-lesson .solution-details > div { padding-left: 4px; }
  .polynomial-lesson .clean-table { min-width: 560px; }
}

@media (prefers-reduced-motion: reduce) {
  .polynomial-lesson * { scroll-behavior: auto !important; }
}
