.ratio-tool {
  background: #ffffff;

  border: 1px solid var(--math-line);
  border-radius: 18px;

  box-shadow: var(--math-shadow);

  overflow: hidden;
}


.ratio-tool-head {
  display: flex;
  align-items: start;
  justify-content: space-between;

  gap: 20px;

  padding: 25px 28px 20px;

  border-bottom: 1px solid var(--math-line);
}


.ratio-tool-head h1 {
  margin: 0 0 7px;

  font-size: 30px;
}


.ratio-tool-head p {
  margin: 0;

  color: var(--math-text-soft);

  font-size: 13px;
  line-height: 1.7;
}


.ratio-grade {
  flex: 0 0 auto;

  padding: 6px 9px;

  background: var(--math-elementary-soft);

  border-radius: 8px;

  color: #287a51;

  font-size: 11px;
  font-weight: 800;
}


.ratio-tabs {
  display: grid;

  grid-template-columns:
    repeat(2, minmax(0, 1fr));

  background: #f6f8fb;

  border-bottom: 1px solid var(--math-line);
}


.ratio-tab {
  min-height: 50px;

  padding: 8px;

  background: transparent;

  border: 0;
  border-right: 1px solid var(--math-line);

  color: var(--math-text-soft);

  font-size: 12px;
  font-weight: 800;

  cursor: pointer;
}


.ratio-tab:last-child {
  border-right: 0;
}


.ratio-tab.is-active {
  background: #ffffff;

  color: var(--math-primary);

  box-shadow:
    inset 0 -3px 0
    var(--math-primary);
}


.ratio-workspace {
  display: grid;

  grid-template-columns:
    minmax(0, 1.3fr)
    minmax(300px, 0.8fr);
}


.ratio-input-panel {
  min-width: 0;

  padding: 25px 28px;

  border-right: 1px solid var(--math-line);
}


.ratio-mode-panel {
  display: none;
}


.ratio-mode-panel.is-active {
  display: block;
}


.ratio-mode-panel h2 {
  margin: 0 0 18px;

  font-size: 16px;
}


.ratio-pair {
  display: flex;
  align-items: center;
  justify-content: center;

  gap: 14px;
}


.ratio-pair input {
  width: 150px;
  height: 52px;

  padding: 0 12px;

  background: #ffffff;

  border: 1px solid var(--math-line);
  border-radius: 9px;

  color: var(--math-text);

  text-align: center;

  font-size: 20px;
  font-weight: 800;

  outline: none;
}


.ratio-colon {
  color: var(--math-text);

  font-size: 26px;
  font-weight: 900;
}


.ratio-equation {
  display: grid;

  grid-template-columns:
    minmax(70px, 1fr)
    20px
    minmax(70px, 1fr)
    24px
    minmax(70px, 1fr)
    20px
    minmax(70px, 1fr);

  align-items: center;

  gap: 6px;
}


.ratio-equation input {
  width: 100%;
  height: 50px;

  padding: 0 8px;

  background: #ffffff;

  border: 1px solid var(--math-line);
  border-radius: 9px;

  color: var(--math-text);

  text-align: center;

  font-size: 18px;
  font-weight: 800;

  outline: none;
}


.ratio-equation > span {
  text-align: center;

  color: var(--math-text);

  font-size: 18px;
  font-weight: 900;
}


.ratio-x {
  height: 50px;

  display: flex;
  align-items: center;
  justify-content: center;

  background: #f5f7fb;

  border: 1px solid var(--math-line);
  border-radius: 9px;

  color: var(--math-primary);

  font-size: 20px;
  font-weight: 900;
}


.ratio-pair input:focus,
.ratio-equation input:focus {
  border-color: var(--math-primary);

  box-shadow:
    0 0 0 3px
    rgba(47, 111, 237, 0.1);
}


.ratio-help {
  margin: 10px 0 0;

  color: var(--math-text-soft);

  text-align: center;

  font-size: 11px;
}


.ratio-actions {
  display: flex;
  justify-content: center;

  gap: 8px;

  margin-top: 22px;
}


.ratio-actions button {
  min-height: 44px;

  border: 0;
  border-radius: 9px;

  font-weight: 800;

  cursor: pointer;
}


.ratio-calculate {
  min-width: 155px;

  background: var(--math-primary);

  color: #ffffff;
}


.ratio-clear {
  min-width: 76px;

  background: #eef1f6;

  color: #566176;
}


.ratio-error {
  margin: 14px 0 0;

  color: #c0392b;

  text-align: center;

  font-size: 12px;
  font-weight: 700;
}


.ratio-result-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  min-height: 245px;

  padding: 24px;

  background: #f8faff;

  text-align: center;
}


.ratio-result-label {
  margin-bottom: 8px;

  color: var(--math-text-soft);

  font-size: 12px;
  font-weight: 800;
}


.ratio-result {
  color: var(--math-primary);

  font-size: 38px;
  font-weight: 900;
}


.ratio-sub-result,
.ratio-percent-result {
  margin-top: 8px;

  color: var(--math-text-soft);

  font-size: 13px;
  line-height: 1.6;
}


.ratio-steps {
  padding: 22px 28px 27px;

  border-top: 1px solid var(--math-line);
}


.ratio-steps-head h2 {
  margin: 0 0 12px;

  font-size: 16px;
}


.ratio-steps-list {
  display: grid;

  gap: 7px;
}


.ratio-step {
  display: flex;

  gap: 12px;

  padding: 10px 12px;

  background: #f7f9fc;

  border-radius: 9px;
}


.ratio-step-number {
  flex: 0 0 auto;

  width: 24px;
  height: 24px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  background: var(--math-primary-soft);

  border-radius: 50%;

  color: var(--math-primary);

  font-size: 11px;
  font-weight: 900;
}


.ratio-step-text {
  color: #43506a;

  font-size: 13px;
  line-height: 1.7;
}


.ratio-info-grid {
  display: grid;

  grid-template-columns:
    repeat(2, minmax(0, 1fr));

  gap: 10px;

  margin-top: 20px;
}


.ratio-info-card {
  padding: 18px;

  background: #ffffff;

  border: 1px solid var(--math-line);
  border-radius: 13px;
}


.ratio-info-card h2 {
  margin: 0 0 8px;

  font-size: 15px;
}


.ratio-info-card p {
  margin: 0;

  color: var(--math-text-soft);

  font-size: 12px;
  line-height: 1.7;
}


@media (max-width: 760px) {

  .ratio-workspace {
    grid-template-columns: 1fr;
  }


  .ratio-input-panel {
    border-right: 0;
    border-bottom: 1px solid var(--math-line);
  }


  .ratio-result-panel {
    min-height: 170px;
  }

}


@media (max-width: 520px) {

  .ratio-tool-head {
    padding: 20px 18px;
  }


  .ratio-tool-head h1 {
    font-size: 26px;
  }


  .ratio-grade {
    display: none;
  }


  .ratio-input-panel {
    padding: 20px 14px;
  }


  .ratio-pair {
    gap: 10px;
  }


  .ratio-pair input {
    min-width: 0;

    width: 100%;

    max-width: 120px;

    height: 48px;

    font-size: 18px;
  }


  .ratio-equation {
    grid-template-columns:
      minmax(50px, 1fr)
      14px
      minmax(50px, 1fr)
      18px
      minmax(50px, 1fr)
      14px
      minmax(50px, 1fr);

    gap: 3px;
  }


  .ratio-equation input,
  .ratio-x {
    height: 46px;

    font-size: 16px;
  }


  .ratio-equation > span {
    font-size: 15px;
  }


  .ratio-result {
    font-size: 32px;
  }


  .ratio-info-grid {
    grid-template-columns: 1fr;
  }

}
