.ss-math-tool {
  box-sizing: border-box;
  width: min(720px, 100%);
  margin: 12px auto 18px;
  border: 1px solid #b8d6e7;
  border-radius: 8px;
  background: #ffffff;
  color: #173b55;
  font-family: Arial, Helvetica, sans-serif;
  text-align: left;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}

.ss-math-tool * {
  box-sizing: border-box;
}

.ss-tool-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid #b8d6e7;
  background: linear-gradient(180deg, #f4fbff, #e7f5fc);
}

.ss-tool-title {
  color: #1d4f70;
  font-size: 20px;
  font-weight: bold;
  line-height: 24px;
}

.ss-tool-subtitle {
  margin-top: 3px;
  color: #4f6c7b;
  font-size: 13px;
  line-height: 18px;
}

.ss-tool-grid {
  display: grid;
  grid-template-columns: minmax(230px, 280px) 1fr;
  gap: 16px;
  padding: 16px;
}

.ss-tool-panel {
  border: 1px solid #d5e6ef;
  border-radius: 8px;
  background: #fbfdff;
  padding: 12px;
}

.ss-tool-field {
  display: block;
  margin-bottom: 12px;
}

.ss-tool-field span {
  display: block;
  margin-bottom: 5px;
  color: #31520c;
  font-size: 13px;
  font-weight: bold;
  line-height: 18px;
}

.ss-tool-field input,
.ss-tool-field select,
.ss-tool-field textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid #9fc0d2;
  border-radius: 6px;
  background: #ffffff;
  color: #173b55;
  font-size: 17px;
  line-height: 24px;
  padding: 6px 8px;
}

.ss-tool-field textarea {
  min-height: 128px;
  resize: vertical;
}

.ss-tool-field input:focus,
.ss-tool-field select:focus,
.ss-tool-field textarea:focus {
  border-color: #0b79bd;
  outline: 2px solid rgba(11,121,189,.18);
}

.ss-tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.ss-tool-subsection {
  margin: 14px 0 8px;
  border-top: 1px solid #d5e6ef;
  padding-top: 12px;
  color: #1d4f70;
  font-size: 15px;
  font-weight: bold;
}

.ss-tool-button {
  min-height: 38px;
  border: 1px solid #0a6ba3;
  border-radius: 6px;
  background: #0b79bd;
  color: #ffffff;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  line-height: 18px;
  padding: 8px 13px;
}

.ss-tool-button.secondary {
  border-color: #9fc0d2;
  background: #ffffff;
  color: #24546e;
}

.ss-tool-button:hover,
.ss-tool-button:focus {
  filter: brightness(.96);
  outline: none;
}

.ss-tool-result {
  min-height: 236px;
  border: 1px solid #d5e6ef;
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
}

.ss-tool-result h2 {
  margin: 0 0 10px;
  color: #1d4f70;
  font-size: 18px;
  line-height: 24px;
}

.ss-result-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #edf4f7;
  color: #173b55;
  font-size: 15px;
  line-height: 22px;
}

.ss-result-row:last-child {
  border-bottom: 0;
}

.ss-result-label {
  color: #31520c;
  font-weight: bold;
}

.ss-result-value {
  overflow-wrap: anywhere;
  font-weight: bold;
}

.ss-inline-note {
  color: #647d8b;
  font-size: 12px;
  font-weight: normal;
}

.ss-formula-box {
  margin-top: 12px;
  border: 1px solid #f0cf81;
  border-radius: 8px;
  background: #fff9e9;
  padding: 10px;
  color: #6b4100;
  font-size: 14px;
  line-height: 21px;
}

.ss-sequence-list {
  margin-top: 12px;
  color: #173b55;
  font-size: 14px;
  line-height: 22px;
  overflow-wrap: anywhere;
}

.ss-matrix-size {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.ss-matrix-size button {
  flex: 1;
}

.ss-matrix-input-grid {
  display: grid;
  gap: 7px;
  margin: 10px 0 12px;
}

.ss-matrix-input-grid.size-2 {
  grid-template-columns: repeat(2, minmax(54px, 1fr));
}

.ss-matrix-input-grid.size-3 {
  grid-template-columns: repeat(3, minmax(48px, 1fr));
}

.ss-matrix-input-grid input {
  min-height: 38px;
  border: 1px solid #9fc0d2;
  border-radius: 6px;
  color: #173b55;
  font-size: 16px;
  font-weight: bold;
  padding: 6px 8px;
  text-align: center;
}

.ss-matrix-table {
  border-collapse: separate;
  border-spacing: 6px;
  margin: 8px auto 12px;
}

.ss-matrix-table td {
  min-width: 62px;
  border: 1px solid #bfd6e3;
  border-radius: 6px;
  background: #f8fcff;
  color: #173b55;
  font-size: 16px;
  font-weight: bold;
  line-height: 24px;
  padding: 7px 9px;
  text-align: center;
}

.ss-matrix-note {
  color: #4f6c7b;
  font-size: 13px;
  line-height: 19px;
}

.ss-point-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(70px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.ss-point-grid label {
  display: block;
}

.ss-point-grid span {
  display: block;
  margin-bottom: 4px;
  color: #31520c;
  font-size: 13px;
  font-weight: bold;
}

.ss-point-grid input {
  width: 100%;
  min-height: 38px;
  border: 1px solid #9fc0d2;
  border-radius: 6px;
  color: #173b55;
  font-size: 16px;
  font-weight: bold;
  padding: 6px 8px;
  text-align: center;
}

.ss-graph-canvas {
  display: block;
  width: 100%;
  max-width: 420px;
  height: auto;
  margin: 12px auto 0;
  border: 1px solid #bfd6e3;
  border-radius: 8px;
  background: #ffffff;
}

.ss-tool-error {
  border-color: #e8b1b1;
  background: #fff0f0;
  color: #8a1616;
  font-weight: bold;
}

@media (max-width: 680px) {
  .ss-tool-header,
  .ss-tool-grid {
    display: block;
  }

  .ss-tool-panel {
    margin-bottom: 12px;
  }

  .ss-result-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}
