*, *::before, *::after { box-sizing: border-box; }

body { overflow-x: hidden; }
header .main-title { margin-bottom: 0; }
.main-content { min-width: 0; }

.fraction-compare-page {
  gap: 1.5rem;
  overflow: hidden;
  min-width: 0;
}

.fraction-hero {
  max-width: 900px;
  margin: 0 auto .4rem;
  text-align: center;
}

.hero-kicker {
  display: inline-block;
  margin-bottom: .55rem;
  color: #5e78ad;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .12em;
}

.fraction-hero h1 {
  margin: 0 0 .7rem;
  color: var(--primary-color, #2f66d8);
  font: 700 clamp(2rem, 4vw, 3.15rem)/1.15 'Raleway', sans-serif;
  overflow-wrap: anywhere;
}

.fraction-hero p {
  max-width: 760px;
  margin: 0 auto;
  color: #4a5568;
  font-size: 1.06rem;
  line-height: 1.65;
  text-align: center;
}

.fraction-tool {
  --blue: #3f73c9;
  --blue-dark: #2d5fae;
  --blue-soft: #edf5ff;
  --rose: #e69aa4;
  --rose-soft: #fff1f3;
  --gold: #bd8734;
  --gold-soft: #fff7e9;
  --mint: #559b78;
  --mint-soft: #eef9f3;
  --ink: #172033;
  --muted: #64748b;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto 1.8rem;
  padding: 26px 22px 32px;
  background: #f5f8fc;
  border: 1px solid #e7edf5;
  border-radius: 20px;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

.problem-setup {
  max-width: 820px;
  margin: 0 auto;
}

.setup-card {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 58px minmax(120px, 1fr) minmax(170px, auto);
  gap: 18px;
  align-items: center;
  padding: 20px 22px;
  background: #fff;
  border: 1px solid #e2e9f2;
  border-radius: 16px;
  box-shadow: 0 10px 28px rgba(42,61,92,.08);
}

.fraction-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.entry-label {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 750;
}

.fraction-input {
  display: grid;
  grid-template-rows: 44px 3px 44px;
  width: 82px;
  align-items: center;
}

.fraction-input input {
  width: 100%;
  height: 40px;
  padding: 4px 7px;
  border: 2px solid #d5deea;
  border-radius: 10px;
  background: #fbfdff;
  color: var(--ink);
  font: 750 1.2rem/1 system-ui, sans-serif;
  text-align: center;
  outline: none;
  transition: border-color .16s, box-shadow .16s, background .16s;
}

.fraction-input input:focus {
  border-color: #8fb0e6;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(63,115,201,.10);
}

.fraction-line {
  height: 2px;
  margin: 0 4px;
  background: #29364a;
  border-radius: 999px;
}

.setup-compare {
  color: #5e6f86;
  font: 800 2rem/1 system-ui, sans-serif;
  text-align: center;
}

.setup-actions {
  display: grid;
  gap: 8px;
  min-width: 170px;
}

.btn-start,
.btn-random,
.btn-help,
.step-choice,
.check-step,
.summary-button,
.hint-help {
  font-family: inherit;
  cursor: pointer;
  transition: transform .16s, box-shadow .16s, background .16s, border-color .16s;
}

.btn-start,
.btn-random {
  min-height: 46px;
  padding: 0 17px;
  border-radius: 11px;
  font-size: .9rem;
  font-weight: 800;
}

.btn-start {
  border: 0;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 6px 14px rgba(63,115,201,.18);
}

.btn-start:hover {
  background: var(--blue-dark);
  transform: translateY(-1px);
}

.btn-random {
  border: 1px solid #b7c9e2;
  background: #f8fbff;
  color: #3d638f;
}

.btn-random:hover {
  background: #edf5ff;
  border-color: #92afd4;
  transform: translateY(-1px);
}

.btn-random i { margin-right: 6px; }

.setup-message {
  min-height: 1.35em;
  margin: 10px auto 4px;
  color: #c84d59;
  font-size: .88rem;
  font-weight: 700;
  text-align: center;
}

.setup-message.ready { color: #3d7b5d; }

.setup-note {
  max-width: 680px;
  margin: 0 auto;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.5;
  text-align: center;
}

.tutor-workspace {
  max-width: 920px;
  margin: 26px auto 0;
}

.equation-stage {
  position: relative;
  min-height: 390px;
  padding: 26px 24px 24px;
  background: #fff;
  border: 1px solid #e1e8f1;
  border-radius: 18px;
  box-shadow: 0 16px 38px rgba(34,50,78,.09);
}

.stage-kicker {
  margin-bottom: 12px;
  color: #6d86ad;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .11em;
  text-align: center;
}

.equation-work {
  display: grid;
  gap: 18px;
  justify-content: center;
  min-height: 205px;
  padding: 12px 0 14px;
  color: #15243a;
}

.work-row {
  display: grid;
  grid-template-columns: 112px 64px 112px;
  align-items: center;
  justify-content: center;
  min-height: 104px;
  font-family: Georgia, 'Times New Roman', serif;
}

.row-connector {
  color: #8190a2;
  font-family: system-ui, sans-serif;
  font-size: .94rem;
  font-weight: 800;
  text-align: center;
}

.work-operator {
  color: #263b56;
  font-family: system-ui, sans-serif;
  font-size: 2.4rem;
  font-weight: 750;
  text-align: center;
}

.work-operator.is-question {
  color: #72849c;
}

.work-operator.is-proof {
  color: #2d5fae;
}

.work-fraction {
  display: grid;
  grid-template-rows: 43px 6px 43px;
  width: 98px;
  min-width: 98px;
  justify-self: center;
  align-items: center;
  font-size: 1.95rem;
  font-weight: 500;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.work-fraction .bar {
  height: 3px;
  margin: 0 2px;
  background: #172033;
  border-radius: 999px;
  box-shadow: 0 1px 0 rgba(23,32,51,.08);
}

.work-value {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 39px;
  border-radius: 9px;
}

.work-value.is-focus {
  color: #1f568e;
  background: #e8f2ff;
  outline: 3px solid #77a1db;
  outline-offset: -3px;
  box-shadow: 0 0 0 3px #fff;
}

.work-value.is-done {
  color: #254b77;
  background: #f1f6fc;
}

.work-value.is-placeholder {
  color: #9aa8ba;
  background: #f7f9fc;
  border: 1px dashed #cbd6e3;
  font-family: system-ui, sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
}

.work-input,
.action-input {
  width: 68px;
  height: 39px;
  padding: 3px 5px;
  border: 2px solid #7da4db;
  border-radius: 9px;
  background: #fff;
  color: #173b68;
  font: 800 1.2rem/1 system-ui, sans-serif;
  text-align: center;
  outline: none;
  box-shadow: 0 0 0 4px rgba(63,115,201,.08);
}

.action-input {
  width: 84px;
  height: 44px;
}

.equation-hint {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  max-width: 650px;
  margin: 8px auto 0;
  padding: 14px 14px 14px 18px;
  background: var(--gold-soft);
  border: 1px solid #efd8ad;
  border-radius: 13px;
}

.hint-arrow {
  position: absolute;
  top: -23px;
  left: 50%;
  transform: translateX(-50%);
  color: #c29347;
  font-size: 1.45rem;
  font-weight: 900;
}

.hint-copy {
  color: #654b24;
  font-size: .94rem;
  font-weight: 700;
  line-height: 1.5;
}

.hint-copy strong { color: #4c381c; }

.hint-help {
  width: 36px;
  height: 36px;
  border: 1px solid #d7b97f;
  border-radius: 50%;
  background: #fff;
  color: #8d6529;
  font-size: 1.05rem;
  font-weight: 900;
}

.hint-help:hover {
  background: #fffaf0;
  transform: translateY(-1px);
}

.equation-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  margin-top: 14px;
}

.symbol-actions {
  display: flex;
  gap: 10px;
}

.step-choice {
  min-width: 72px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid #b7c9e2;
  border-radius: 12px;
  background: #f8fbff;
  color: #294f7d;
  font-size: 1.6rem;
  font-weight: 850;
}

.step-choice:hover {
  background: #edf5ff;
  border-color: #8eadd5;
  transform: translateY(-1px);
}

.input-action {
  display: flex;
  align-items: center;
  gap: 9px;
}

.check-step {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  font-size: .9rem;
  font-weight: 800;
}

.check-step:hover {
  background: var(--blue-dark);
  transform: translateY(-1px);
}

.step-feedback {
  min-height: 1.35em;
  margin: 10px auto 0;
  color: #a35661;
  font-size: .88rem;
  font-weight: 750;
  text-align: center;
}

.step-feedback.good { color: #3d7b5d; }
.step-feedback.bad { color: #b74f5c; }

.visual-explanation {
  margin-top: 18px;
  padding: 20px;
  background: #fff;
  border: 1px solid #e1e8f1;
  border-radius: 16px;
}

.visual-heading {
  display: grid;
  gap: 3px;
  margin-bottom: 18px;
  text-align: center;
}

.visual-heading strong {
  color: #31455f;
  font-size: 1rem;
}

.visual-heading span {
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.45;
}

.models-area {
  display: grid;
  grid-template-columns: minmax(0,1fr) 48px minmax(0,1fr);
  gap: 14px;
  align-items: center;
}

.fraction-model {
  min-width: 0;
}

.model-heading {
  min-height: 24px;
  margin-bottom: 8px;
  color: #42546c;
  font-size: .9rem;
  text-align: center;
}

.model-compare {
  color: #5b6d84;
  font-size: 1.7rem;
  font-weight: 850;
  text-align: center;
}

.fraction-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  width: 100%;
  min-height: 58px;
  overflow: hidden;
  background: #f7f9fc;
  border: 2px solid #cad5e3;
  border-radius: 10px;
}

.fraction-strip span {
  min-width: 1px;
  border-right: 1px solid rgba(91,108,132,.30);
  background: #fff;
}

.fraction-strip span:last-child { border-right: 0; }

.fraction-strip.strip-a span.filled {
  background: #88addf;
}

.fraction-strip.strip-b span.filled {
  background: #efb0b8;
}

.same-size-status {
  max-width: 700px;
  min-height: 1.35em;
  margin: 14px auto 0;
  color: #53657b;
  font-size: .88rem;
  font-weight: 650;
  line-height: 1.55;
  text-align: center;
}

.controls {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.btn-help {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid #b8c8dc;
  border-radius: 11px;
  background: #fff;
  color: #46617f;
  font-size: .9rem;
  font-weight: 800;
}

.btn-help:hover {
  background: #f7faff;
  border-color: #96aec9;
  transform: translateY(-1px);
}

.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-right: 7px;
  border: 1px solid #98abc1;
  border-radius: 50%;
  font-size: .76rem;
}

.result-summary {
  display: none;
  max-width: 760px;
  margin: 22px auto 0;
  padding: 22px 0 4px;
  border-top: 1px solid #dfe6ef;
  text-align: center;
}

.result-summary.show { display: block; }

.result-summary h2 {
  margin: 0 0 12px;
  color: #28405f;
  font-size: 1.26rem;
}

.complete-equation {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 8px auto 10px;
  color: #19283e;
  font: 500 1.45rem/1.25 Georgia, 'Times New Roman', serif;
}

.complete-fraction {
  display: grid;
  grid-template-rows: 30px 4px 30px;
  width: 58px;
  align-items: center;
  text-align: center;
}

.complete-fraction .complete-bar {
  height: 2px;
  background: #172033;
  border-radius: 999px;
}

.complete-symbol {
  color: #2d5fae;
  font: 800 1.5rem/1 system-ui, sans-serif;
}

.complete-proof {
  margin: 8px auto 12px;
  color: #53657b;
  font-size: .92rem;
  line-height: 1.55;
}

.summary-button {
  min-height: 44px;
  margin-top: 8px;
  padding: 0 20px;
  border: 0;
  border-radius: 11px;
  background: #436fb9;
  color: #fff;
  font-size: .9rem;
  font-weight: 800;
}

.summary-button:hover {
  background: #315da9;
  transform: translateY(-1px);
}

.fraction-content {
  display: grid;
  gap: 18px;
  max-width: 940px;
  margin: 0 auto 30px;
}

.content-card {
  padding: 24px 26px;
  background: #fff;
  border: 1px solid #e4eaf2;
  border-radius: 16px;
  box-shadow: 0 8px 22px rgba(38,57,86,.06);
}

.content-card h2 {
  margin: 0 0 12px;
  color: #2d4d79;
  font-size: 1.34rem;
}

.content-card h3 {
  margin: 14px 0 4px;
  color: #3b4f69;
  font-size: 1rem;
}

.content-card p,
.content-card li {
  color: #4e5d70;
  font-size: .96rem;
  line-height: 1.7;
}

.content-card p:last-child { margin-bottom: 0; }

.content-card ol {
  margin: 0;
  padding-left: 22px;
}

.content-card li { padding-left: 4px; }

.content-card li p {
  margin: 2px 0 10px;
}

.worked-example {
  max-width: 470px;
  margin: 16px auto;
  padding: 16px 18px;
  background: #f7faff;
  border: 1px solid #dbe6f4;
  border-radius: 13px;
}

.worked-row {
  display: grid;
  grid-template-columns: 1fr 40px 1fr;
  align-items: center;
  padding: 5px 0;
  color: #314b6d;
  font-size: 1.05rem;
  font-weight: 750;
  text-align: center;
}

.worked-arrow { color: #8497ae; }

.worked-result {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #d9e4f1;
  color: #235a9d;
  font-weight: 850;
  text-align: center;
}

.related-card {
  background: #f8fbff;
}

.related-link {
  display: inline-block;
  margin-top: 4px;
  color: #2f66b4;
  font-weight: 800;
  text-decoration: none;
}

.related-link:hover { text-decoration: underline; }

@media (max-width: 880px) {
  .setup-card {
    grid-template-columns: 1fr 48px 1fr;
  }

  .setup-actions {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
    width: min(430px, 100%);
    margin: 0 auto;
  }
}

@media (max-width: 640px) {
  .fraction-tool {
    padding: 18px 12px 24px;
    border-radius: 15px;
  }

  .setup-card {
    grid-template-columns: 1fr 34px 1fr;
    gap: 10px;
    padding: 16px 10px;
  }

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

  .fraction-input {
    width: 72px;
    grid-template-rows: 40px 3px 40px;
  }

  .fraction-input input {
    height: 37px;
    font-size: 1.05rem;
  }

  .setup-compare { font-size: 1.55rem; }

  .equation-stage {
    min-height: 350px;
    padding: 21px 10px 18px;
  }

  .work-row {
    grid-template-columns: 90px 42px 90px;
    min-height: 92px;
  }

  .work-fraction {
    width: 82px;
    min-width: 82px;
    grid-template-rows: 38px 5px 38px;
    font-size: 1.62rem;
  }

  .work-operator { font-size: 2rem; }

  .work-input {
    width: 58px;
    height: 35px;
    font-size: 1.05rem;
  }

  .equation-hint {
    margin-left: 2px;
    margin-right: 2px;
  }

  .models-area {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .model-compare {
    min-height: 26px;
    transform: rotate(90deg);
  }

  .fraction-strip { min-height: 48px; }

  .content-card { padding: 20px 18px; }

  .complete-equation {
    gap: 7px;
    font-size: 1.22rem;
  }

  .complete-fraction {
    width: 50px;
    grid-template-rows: 26px 4px 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
