* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  height: 100%;
  margin: 0;
}

body {
  line-height: 1.6;
  background-color: #f0f0f0;
  color: #2c2c2c;
  margin: 0;
  padding-left: 0;
  padding-right: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-container {
  display: flex;
  justify-content: center;
  padding: 20px;
  gap: 20px;
}

.toc {
  flex: 0 0 250px;
  background: linear-gradient(145deg, #ffffff, #f2f2f2);
  padding: 20px;
  border-radius: 12px;
  height: fit-content;
  position: sticky;
  top: 20px;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid #ddd;
}

.toc-title {
  font-size: 1.2em;
  font-weight: bold;
  margin-top: 0;
  margin-bottom: 12px;
  color: #1a1f36;
  border-left: none;
  padding-left: 0;
  text-align: center;
}

.toc ul {
  list-style: none;
  padding-left: 0;
}

.toc ul li {
  margin-bottom: 8px;
}

.toc ul li a {
  text-decoration: none;
  color: #444;
  padding: 4px 8px;
  display: block;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.toc ul li a:hover {
  text-decoration: underline;
  color: #1a1f36;
  background-color: transparent;
}

main {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", sans-serif;
  flex: 1;
  max-width: 900px;
  background: #fff;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.card-link {
  display: block;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 15px 20px;
  margin-bottom: 15px;
  text-decoration: none;
  color: #333;
  background-color: #fdfdfd;
  transition: all 0.3s ease;
}

.card-link:hover {
  border-color: #1e90ff;
  background-color: #f0f8ff;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.card-link h2 {
  margin: 0 0 0.5em 0;
  font-size: 1.2rem;
}

.card-link p {
  margin: 0;
  font-size: 0.95rem;
  color: #555;
}

.card-link.disabled {
  pointer-events: none;
  color: #999;
  background-color: #f5f5f5;
  border-color: #ddd;
}

.card-link.disabled h2 {
  color: #aaa;
}

.card-link.disabled:hover {
  border-color: #ddd;
  background-color: #f5f5f5;
  box-shadow: none;
  cursor: default;
}

.page-title {
  font-size: 1.5em;
  font-weight: 600;
  color: #1a1f36;
  margin: 0 0 16px 8px;
  letter-spacing: 0.5px;
  font-family: "Yu Mincho", "游明朝", "Hiragino Mincho ProN", "ヒラギノ明朝 ProN W3", "ＭＳ Ｐ明朝", serif;
  padding-bottom: 6px;
}

h1,
h2,
h3 {
  color: #222;
}

h1 {
  font-size: 26px;
  margin-bottom: 0.5em;
}

h2 {
  font-size: 20px;
  margin-top: 1em;
  margin-bottom: 0.2em;
  border-bottom: solid 3px #cce4ff;
  position: relative;
}

h2:after {
  position: absolute;
  content: " ";
  display: block;
  border-bottom: solid 3px #5472cd;
  bottom: -3px;
  width: 20%;
}

h3 {
  font-size: 16px;
  margin-top: 1.5em;
  margin-bottom: 0.3em;
  border-left: 4px solid #5472cd;
  padding-left: 12px;
  border-radius: 4px;
}

p {
  font-size: clamp(15px, 1vw + 10px, 15px);
  margin: 0 0 8px;
  line-height: 1.7;
}

ul {
  margin: 0.5em 0 0.5em 1.5em;
}

li {
  margin-bottom: 0.3em;
}

ul li {
  font-size: 15px;
}

.return-link {
  display: inline-block;
  margin-bottom: 1rem;
  color: #0073aa;
  text-decoration: none;
  font-size: 0.95rem;
}

.return-link:hover {
  text-decoration: underline;
  color: #005f8c;
}

.proof-box {
  border: 2px solid #888;
  border-radius: 8px;
  padding: 1em;
  margin: 1.5em 0;
  background-color: #f9f9f9;
}

.proof-box p {
  margin: 0.5em 0;
}

.align-table {
  margin: 0 auto;
  border-collapse: collapse;
  text-align: left;
}

.align-table td {
  padding: 4px 8px;
  font-size: 16px;
}

figure {
  margin: 40px auto;
  width: 100%;
  max-width: 520px;
  text-align: center;
}

figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

figcaption {
  margin-top: 12px;
  padding: 0 8px;
  font-size: clamp(14px, 0.8vw + 10px, 15px);
  line-height: 1.7;
  color: #444;
}

figcaption strong {
  display: block;
  font-size: clamp(15px, 0.9vw + 10px, 16px);
  margin-bottom: 4px;
  color: #222;
  font-weight: 600;
}

.img-block {
  width: 70%;
  text-align: center;
}

.img-wrap img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.label {
  color: #333 !important;
  font-size: 12px;
  margin-top: 6px;
  text-align: center;
}

.condition-card {
  background: #fafafa;
  border: 1px solid #ddd;
  padding: 16px 20px;
  border-radius: 10px;
  margin-bottom: 24px;
}

.condition-title {
  font-weight: bold;
  margin-bottom: 6px;
  font-size: 15px;
}

.condition-text {
  margin-top: 10px;
  color: #444;
  line-height: 1.6;
  text-align: center;
}

.logic-summary {
  margin: 1.5em 0;
}

.logic-summary p {
  margin-bottom: 0.8em;
}

.logic-summary p:last-child {
  margin-bottom: 0;
}

.mod-table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-size: 11px;
  margin: 20px 0;
  background: #fff;
}

.mod-table th,
.mod-table td {
  border: 1px solid #ccc;
  padding: 4px 2px;
  vertical-align: middle;
}

.mod-table thead th {
  background: #f5f7fa;
  font-weight: 600;
}

.mod-table tbody th {
  background: #fafafa;
  font-weight: 600;
  white-space: nowrap;
}

.mod-table thead tr:nth-child(3) th:nth-child(5),
.mod-table tbody td:nth-child(6) {
  border-left: 2px solid #888;
}

.mod-table thead tr:nth-child(2) th:nth-child(3) {
  border-left: 2px solid #888;
}

.mod-table thead tr:nth-child(1) th:nth-child(3) {
  border-left: 2px solid #888;
}

.mod-table tbody tr:hover {
  background: #f9fcff;
}

.table-wrap {
  overflow-x: auto;
}

.formula {
  text-align: center;
  margin: 12px 0;
  font-size: 1.1rem;
  line-height: 2;
  overflow-x: auto;
}

.chart-wrap {
  position: relative;
  width: 100%;
  max-width: 680px;

  aspect-ratio: 1.6 / 1;

  margin: 28px auto;
  padding: 16px 18px;

  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 10px;

  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.formula {
  text-align: center;
  margin: 24px 0;
  overflow-x: auto;
  line-height: 1.9;
}

.formula mjx-container {
  font-size: 16px !important;
}

mjx-container mjx-mtext {
  font-size: 1.08em !important;
}

p mjx-container {
  font-size: 0.95em !important;
}

.formula mjx-container[jax="CHTML"][display="true"] {
  display: inline-block !important;
  text-align: left !important;
  margin: 0.4em 0 !important;
  max-width: 100%;
}

.formula mjx-math {
  padding: 2px 0;
}

@media (max-width: 600px) {
  .flex-images {
    flex-direction: column;
    align-items: center;
  }

  .img-block {
    margin: 0;
    width: 100%;
  }

  .flex-images img {
    width: 70%;
  }

  h1 {
    font-size: 22px;
    margin-bottom: 0.2em;
  }

  h2 {
    font-size: 18px;
    margin-top: 0.8em;
    margin-bottom: 0.15em;
  }

  p {
    font-size: clamp(12px, 1vw + 10px, 12px);
    margin: 0 0 8px;
    line-height: 1.7;
  }

  .align-table td {
    font-size: 12px;
  }

  ul li {
    font-size: 12px;
  }

  figcaption {
    font-size: 12px;
    line-height: 1.6;
    margin-top: 10px;
  }

  figcaption strong {
    font-size: 13px;
    margin-bottom: 3px;
  }

  figure {
    margin: 28px auto;
    max-width: 100%;
  }

  .formula {
    margin: 18px 0;
    padding: 0 4px;
    line-height: 1.7;
  }

  .formula mjx-container {
    font-size: 15px !important;
  }

  p mjx-container {
    font-size: 0.9em !important;
  }

  .chart-wrap {
    margin: 20px 0;
    padding: 12px 10px;
    border-radius: 8px;
  }
}

@media (max-width: 410px) {
  main {
    padding: 14px;
  }
}

@media (max-width: 768px) {
  .page-container {
    flex-direction: column;
    padding: 10px;
  }

  .toc {
    display: none;
  }
}