:root {
  color-scheme: light;
  --bg: #f4f6f4;
  --panel: #ffffff;
  --panel-strong: #f9faf7;
  --ink: #1f2623;
  --muted: #67716d;
  --line: #d9dfda;
  --teal: #0f766e;
  --teal-dark: #0b5954;
  --blue: #2454a6;
  --amber: #b7791f;
  --red: #b42318;
  --green: #247a45;
  --shadow: 0 18px 48px rgba(31, 38, 35, 0.1);
  font-family:
    "Yu Gothic UI", "Meiryo", "Noto Sans JP", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(180deg, #eef4ef 0, rgba(244, 246, 244, 0) 260px),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1960px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 4px 2px 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 15px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  font-size: 13px;
  letter-spacing: 0;
}

.top-actions,
.panel-title-row,
.chart-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-chip,
.risk-badge,
.small-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.risk-badge.ok {
  color: var(--green);
  border-color: rgba(36, 122, 69, 0.35);
  background: rgba(36, 122, 69, 0.08);
}

.risk-badge.warn {
  color: var(--amber);
  border-color: rgba(183, 121, 31, 0.35);
  background: rgba(183, 121, 31, 0.09);
}

.risk-badge.danger {
  color: var(--red);
  border-color: rgba(180, 35, 24, 0.35);
  background: rgba(180, 35, 24, 0.08);
}

.primary-button,
.ghost-button,
.tab-button {
  border: 1px solid transparent;
  border-radius: 7px;
  min-height: 36px;
  padding: 8px 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.primary-button {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.22);
}

.primary-button:hover {
  background: var(--teal-dark);
}

.ghost-button,
.tab-button {
  background: var(--panel-strong);
  border-color: var(--line);
  color: var(--ink);
}

.field-checkbox {
  width: auto;
  min-height: 0;
  margin: 3px 0 0;
}

.tab-button {
  min-height: 30px;
  padding: 5px 9px;
  color: var(--muted);
  font-size: 12px;
}

.tab-button.active {
  background: #e8f2f1;
  border-color: rgba(15, 118, 110, 0.35);
  color: var(--teal-dark);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(660px, 1fr) minmax(280px, 350px);
  gap: 14px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.control-panel,
.compare-panel {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 14px;
}

.panel-title-row {
  justify-content: space-between;
  margin-bottom: 12px;
}

.control-section {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.control-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.control-section h3 {
  display: flex;
  justify-content: space-between;
  margin: 0 0 10px;
  color: #33413c;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  min-width: 0;
}

.field.wide {
  grid-column: 1 / -1;
}

.field label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.unit {
  color: #84908b;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 36px;
  border: 1px solid #cbd5cf;
  border-radius: 7px;
  padding: 7px 9px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--teal);
}

.sim-column {
  display: grid;
  gap: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric-card {
  min-height: 92px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 32px rgba(31, 38, 35, 0.07);
}

.metric-card .label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric-card .value {
  font-size: 24px;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 0;
}

.metric-card .sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.metric-card.warn {
  border-color: rgba(183, 121, 31, 0.35);
  background: #fffaf0;
}

.metric-card.danger {
  border-color: rgba(180, 35, 24, 0.35);
  background: #fff5f4;
}

.visual-row {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(260px, 1fr);
  gap: 14px;
}

.vector-panel,
.log-panel,
.chart-panel,
.curve-panel,
.table-panel {
  padding: 14px;
}

canvas {
  display: block;
  width: 100%;
  background: #fbfcfb;
  border: 1px solid #e2e7e3;
  border-radius: 7px;
}

#vectorCanvas {
  aspect-ratio: 19 / 15;
}

#chartCanvas {
  aspect-ratio: 92 / 38;
  min-height: 330px;
}

.warnings {
  display: grid;
  gap: 9px;
}

.warning-item {
  padding: 10px;
  border-left: 4px solid var(--line);
  border-radius: 7px;
  background: var(--panel-strong);
  color: #33413c;
  font-size: 13px;
  line-height: 1.45;
}

.warning-item.warn {
  border-left-color: var(--amber);
  background: #fffaf0;
}

.warning-item.danger {
  border-left-color: var(--red);
  background: #fff5f4;
}

.warning-item.ok {
  border-left-color: var(--green);
  background: #f1fbf4;
}

.table-scroll {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  padding: 8px 9px;
  border-bottom: 1px solid #e7ebe7;
  text-align: right;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8faf8;
  color: var(--muted);
  font-size: 11px;
}

th:first-child,
td:first-child {
  text-align: left;
}

th.text,
td.text {
  text-align: left;
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.reference-grid h3 {
  margin: 0 0 8px;
  color: #33413c;
}

.reference-scroll {
  max-height: 360px;
}

tr.selected-row td {
  background: #edf7f6;
  font-weight: 800;
}

.reference-note {
  margin: -4px 0 14px;
  max-width: 1100px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

td.estimated-cell {
  background: #fff8e8;
  border-left: 2px solid rgba(183, 121, 31, 0.35);
}

tr.selected-row td.estimated-cell {
  background: #f7efdc;
}

td.source-detail {
  min-width: 240px;
  max-width: 460px;
  white-space: normal;
  line-height: 1.45;
}

.driver-cards {
  display: grid;
  gap: 10px;
}

.driver-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #fff;
}

.driver-card.selected {
  border-color: rgba(15, 118, 110, 0.5);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.18);
}

.driver-card h3 {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.driver-card dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 10px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.driver-card dd {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
  text-align: right;
}

.score-bar {
  height: 7px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8ece8;
}

.score-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--amber), var(--green));
}

.source-box {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.source-box a {
  display: block;
  margin: 7px 0;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.source-box a:hover {
  text-decoration: underline;
}

@media (max-width: 1240px) {
  .workspace {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .compare-panel {
    position: static;
    grid-column: 1 / -1;
    max-height: none;
  }

  .driver-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .workspace,
  .visual-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-content: start;
  }

  .control-panel {
    position: static;
    max-height: none;
  }

  .metric-grid,
  .driver-cards,
  .reference-grid {
    grid-template-columns: 1fr;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 23px;
  }
}

.page-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.page-tab-button {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-weight: 900;
}

.page-tab-button.active {
  background: #e8f2f1;
  border-color: rgba(15, 118, 110, 0.35);
  color: var(--teal-dark);
}

.page-section {
  display: none;
}

.page-section.active {
  display: block;
}

.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 12px;
}

.chart-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.inline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.inline-toggle input {
  width: auto;
  min-height: 0;
  margin: 0;
}

.ghost-button.mini,
.tab-button.mini {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.chart-hint,
.field-help {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.textarea-label {
  display: block;
  margin: 8px 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

textarea {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  border: 1px solid #cbd5cf;
  border-radius: 7px;
  padding: 8px 9px;
  background: #fff;
  color: var(--ink);
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.manual-points-panel {
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.manual-points-panel textarea {
  min-height: 96px;
}

textarea:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--teal);
}

#torqueCurveFile {
  margin-top: 8px;
  min-height: 34px;
  padding: 5px 7px;
  font-size: 12px;
}

.curve-status {
  margin-top: 8px;
  padding: 9px;
  border-left: 4px solid var(--line);
  border-radius: 7px;
  background: var(--panel-strong);
  color: #33413c;
  font-size: 12px;
  line-height: 1.45;
}

.curve-status.active {
  border-left-color: var(--teal);
  background: #edf7f6;
}

.curve-status.warn {
  border-left-color: var(--amber);
  background: #fffaf0;
}


.torque-curve-canvas {
  display: block;
  width: 100%;
  height: clamp(300px, 31vw, 460px);
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.prose-panel {
  padding: 18px;
}

.prose-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.prose-grid article,
.formula-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel-strong);
}

.prose-grid p {
  margin: 0;
  color: #33413c;
  font-size: 13px;
  line-height: 1.7;
}

.prose-panel code {
  padding: 1px 4px;
  border-radius: 4px;
  background: #edf1ee;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95em;
}

.formula-box {
  margin-top: 14px;
}

.formula-box pre {
  margin: 0;
  overflow: auto;
  color: #33413c;
  font-size: 13px;
  line-height: 1.6;
}

.formula-box pre code {
  display: block;
  padding: 0;
  background: transparent;
}

.reference-panel {
  padding: 14px;
}

@media (max-width: 860px) {
  .chart-toolbar {
    justify-content: start;
  }

  .prose-grid {
    grid-template-columns: 1fr;
  }
}

.input-invalid {
  border-color: var(--red) !important;
  background: #fff5f4;
}

.chart-legend-box,
.curve-legend-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.chart-legend-box {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.legend-item-detail,
.curve-legend-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 7px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 7px 9px;
}

.legend-item-detail b,
.curve-legend-item b {
  display: block;
  font-size: 12px;
  color: var(--ink);
  line-height: 1.25;
}

.legend-item-detail span,
.curve-legend-item span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.legend-item-detail p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.legend-swatch {
  width: 18px;
  height: 10px;
  margin-top: 3px;
  border-top: 3px solid currentColor;
}

.legend-swatch.dashed {
  border-top-style: dashed;
}

.legend-swatch.dot {
  width: 10px;
  height: 10px;
  border: 0;
  border-radius: 999px;
  background: currentColor;
}

.legend-text {
  min-width: 0;
}

.method-grid article:nth-child(9),
.method-grid article:nth-child(10) {
  background: #fffaf0;
}

.curve-legend-item.selected {
  border-color: rgba(15, 118, 110, 0.38);
  background: #edf7f5;
}


.legend-line {
  width: 22px;
  height: 12px;
  margin-top: 3px;
  border-top: 3px solid currentColor;
  border-radius: 999px;
}

.legend-line.dashed {
  border-top-style: dashed;
}

.curve-status b {
  display: block;
  margin-bottom: 2px;
}

.curve-status span {
  display: block;
  margin-top: 2px;
}

.status-warning {
  color: var(--amber);
  font-weight: 800;
}

.method-notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.method-notes article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fffaf0;
}

.method-notes p,
.method-notes li {
  color: #33413c;
  font-size: 13px;
  line-height: 1.7;
}

.method-notes ol {
  margin: 0;
  padding-left: 1.2em;
}

@media (max-width: 860px) {
  .method-notes {
    grid-template-columns: 1fr;
  }
}


.primary-button.mini {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
}

.load-panel {
  max-width: 1500px;
  margin: 0 auto;
}

.load-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(480px, 1.1fr);
  gap: 14px;
  align-items: start;
}

.load-input-card,
.load-output-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel-strong);
}

.load-field-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.load-result-card {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fff;
}

.load-result-card h3 {
  margin-bottom: 6px;
}

.load-result-card p {
  margin: 0;
  color: #33413c;
  font-size: 13px;
  line-height: 1.7;
}

.load-result-card p + p {
  margin-top: 6px;
}

.load-result-card.ok {
  border-left-color: var(--green);
  background: #f1fbf4;
}

.load-result-card.warn {
  border-left-color: var(--amber);
  background: #fffaf0;
}

.load-result-card.danger {
  border-left-color: var(--red);
  background: #fff5f4;
}

.muted-line {
  color: var(--muted) !important;
}

.load-table-scroll {
  max-height: 520px;
}

.load-table-scroll th:first-child {
  min-width: 150px;
}

@media (max-width: 980px) {
  .load-layout,
  .load-field-grid {
    grid-template-columns: 1fr;
  }
}


.load-visual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.diagram-card,
.formula-card,
.equation-card,
.example-card,
.var-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.diagram-card,
.formula-card {
  padding: 14px;
}

.diagram-card canvas {
  width: 100%;
  min-height: 240px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.equation-list,
.example-grid,
.variable-grid {
  display: grid;
  gap: 12px;
}

.equation-list,
.example-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.variable-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.equation-card,
.example-card,
.var-item {
  padding: 12px;
  background: #fff;
}

.equation-card h4,
.example-card h4,
.var-item b {
  margin: 0 0 8px;
  font-size: 13px;
}

.equation-display {
  padding: 10px 12px;
  border-radius: 8px;
  background: #f7f4ec;
  color: #3d3422;
  font-family: "Cambria Math", "STIX Two Math", "Times New Roman", "Yu Gothic UI", serif;
  font-size: 21px;
  line-height: 1.65;
  overflow-x: auto;
  white-space: nowrap;
}

.frac {
  display: inline-grid;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: center;
  vertical-align: middle;
  margin: 0 0.18em;
  line-height: 1.15;
}

.frac > span:first-child {
  display: block;
  padding: 0 0.24em 0.08em;
  border-bottom: 1.5px solid currentColor;
}

.frac > span:last-child {
  display: block;
  padding: 0.08em 0.24em 0;
  font-size: 0.86em;
}

.equation-display sub {
  font-size: 0.68em;
}

.equation-display sup {
  font-size: 0.68em;
}

.equation-card p,
.example-card p,
.var-item p,
.var-item span,
.method-rich-card p,
.method-rich-card li {
  margin: 8px 0 0;
  color: #33413c;
  font-size: 13px;
  line-height: 1.7;
}

.var-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.method-rich-card ol {
  margin: 0;
  padding-left: 1.2em;
}

@media (max-width: 980px) {
  .load-visual-grid,
  .equation-list,
  .example-grid,
  .variable-grid {
    grid-template-columns: 1fr;
  }
}


.equation-display {
  font-family: "Cambria Math", "Times New Roman", "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 20px;
  letter-spacing: 0.01em;
  white-space: normal;
}

.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin: 0 0.12em;
  line-height: 1.05;
}

.frac .num {
  display: block;
  padding: 0 0.25em 0.12em;
  border-bottom: 1px solid currentColor;
}

.frac .den {
  display: block;
  padding: 0.12em 0.25em 0;
}

.equation-card p,
.example-card p,
.var-item p,
.var-item span {
  font-size: 12.5px;
}


.equation-display {
  font-family: "Cambria Math", "STIX Two Math", "Times New Roman", "Yu Mincho", serif;
  font-size: 22px;
  letter-spacing: 0.01em;
  white-space: normal;
}

.equation-display sub,
.equation-display sup {
  font-size: 0.65em;
  line-height: 0;
}

.frac {
  display: inline-grid;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: center;
  vertical-align: middle;
  margin: 0 0.18em;
  line-height: 1.15;
}

.frac > span:first-child {
  display: block;
  padding: 0 0.25em 0.08em;
  border-bottom: 1.4px solid currentColor;
}

.frac > span:last-child {
  display: block;
  padding: 0.08em 0.25em 0;
  font-size: 0.92em;
}

.equation-card p,
.example-card p,
.var-item p {
  color: #42504a;
}


.equation-display {
  font-family: "Cambria Math", "STIX Two Math", "Times New Roman", "Yu Mincho", serif;
  white-space: nowrap;
  font-size: 20px;
  line-height: 1.55;
  letter-spacing: 0;
}

.equation-display i {
  font-style: italic;
}

.equation-display sub,
.equation-display sup {
  font-size: 0.68em;
  line-height: 0;
}

.frac {
  display: inline-grid;
  grid-template-rows: auto auto;
  align-items: center;
  vertical-align: middle;
  text-align: center;
  line-height: 1.15;
  margin: 0 0.12em;
}

.frac .num {
  display: block;
  padding: 0 0.28em 0.06em;
  border-bottom: 1.4px solid currentColor;
}

.frac .den {
  display: block;
  padding: 0.08em 0.28em 0;
}

.paren {
  display: inline-block;
  padding: 0 0.06em;
  font-size: 1.15em;
}

.equation-card p,
.example-card p,
.var-item p {
  color: #3d4742;
}


.equation-display {
  display: flex;
  align-items: center;
  min-height: 58px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #f6f1e8;
  color: #2d261c;
  font-family: "Cambria Math", "STIX Two Math", "Times New Roman", "Yu Mincho", serif;
  font-size: clamp(20px, 1.8vw, 28px);
  line-height: 1.25;
  letter-spacing: 0.01em;
  overflow-x: auto;
  white-space: nowrap;
}

.equation-display sub,
.equation-display sup {
  font-size: 0.62em;
  line-height: 0;
}

.frac {
  display: inline-grid;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: center;
  vertical-align: middle;
  margin: 0 0.12em;
  line-height: 1.05;
}

.frac > span:first-child {
  display: block;
  min-width: 100%;
  padding: 0 0.22em 0.12em;
  border-bottom: 1.6px solid currentColor;
  text-align: center;
}

.frac > span:last-child {
  display: block;
  padding: 0.1em 0.22em 0;
  text-align: center;
}

.frac.inline {
  font-size: 0.88em;
  transform: translateY(0.05em);
}

.equation-card p,
.example-card p,
.var-item p,
.var-item span {
  color: #33413c;
  font-size: 12.5px;
  line-height: 1.65;
}


.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin: 0 0.12em;
  line-height: 1.1;
}

.frac > span:first-child {
  display: block;
  padding: 0 0.25em 0.08em;
  border-bottom: 1.5px solid currentColor;
}

.frac > span:last-child {
  display: block;
  padding: 0.08em 0.25em 0;
  font-size: 0.9em;
}

.equation-display sub,
.equation-display sup {
  font-size: 0.68em;
}


.frac {
  display: inline-grid;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: center;
  vertical-align: middle;
  margin: 0 0.16em;
  line-height: 1.05;
}

.frac-num {
  display: block;
  padding: 0 0.28em 0.08em;
  border-bottom: 1.6px solid currentColor;
}

.frac-den {
  display: block;
  padding: 0.08em 0.28em 0;
  font-size: 0.9em;
}

.equation-display sub,
.variable-grid sub,
.reference-note sub,
.field label sub {
  font-size: 0.72em;
  line-height: 0;
}

.equation-display sup {
  font-size: 0.72em;
}


.equation-display {
  display: flex;
  align-items: center;
  min-height: 58px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #f7f4ec;
  color: #2f281d;
  overflow-x: auto;
}

.math-line {
  display: inline-flex;
  align-items: center;
  gap: 0.28em;
  white-space: nowrap;
  font-family: "Cambria Math", "Latin Modern Math", "STIX Two Math", "Times New Roman", "Noto Serif", serif;
  font-size: 21px;
  line-height: 1.45;
  letter-spacing: 0.01em;
}

.frac {
  display: inline-grid;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: center;
  vertical-align: middle;
  margin: 0 0.15em;
  line-height: 1.12;
}

.frac > span:first-child {
  display: block;
  padding: 0 0.35em 0.13em;
  border-bottom: 1.5px solid currentColor;
}

.frac > span:last-child {
  display: block;
  padding: 0.13em 0.35em 0;
  font-size: 0.9em;
}

.frac.inline {
  font-size: 0.9em;
}

.equation-card p,
.example-card p,
.var-item p,
.var-item span,
.method-rich-card p,
.method-rich-card li {
  margin: 8px 0 0;
  color: #33413c;
  font-size: 13px;
  line-height: 1.6;
}

.example-card p {
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

.math {
  display: inline-flex;
  align-items: center;
  gap: 0.22em;
  white-space: nowrap;
  font-family: "Cambria Math", "Latin Modern Math", "STIX Two Math", "Times New Roman", "Noto Serif", serif;
  font-size: 21px;
  line-height: 1.45;
  letter-spacing: 0.01em;
}

/* Final equation rendering overrides */
.equation-display {
  display: flex;
  align-items: center;
  min-height: 62px;
  padding: 12px 14px;
  overflow-x: auto;
}

.equation-display .math,
.equation-display > i,
.equation-display > .frac {
  font-family: "Cambria Math", "Latin Modern Math", "STIX Two Math", "Times New Roman", "Noto Serif", serif;
  font-size: 21px;
  line-height: 1.45;
  white-space: nowrap;
}

.equation-display .math {
  display: inline-flex;
  align-items: center;
  gap: 0.18em;
}

.equation-display .frac {
  display: inline-grid;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: center;
  vertical-align: middle;
  margin: 0 0.16em;
  line-height: 1.08;
}

.equation-display .frac-num,
.equation-display .frac > span:first-child {
  display: block;
  padding: 0 0.34em 0.12em;
  border-bottom: 1.6px solid currentColor;
}

.equation-display .frac-den,
.equation-display .frac > span:last-child {
  display: block;
  padding: 0.12em 0.34em 0;
  font-size: 0.9em;
}


/* Final equation typography override */
.equation-display {
  display: block;
  min-height: 64px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #f7f4ec;
  color: #2f281d;
  font-family: "Cambria Math", "STIX Two Math", "Times New Roman", "Yu Mincho", serif;
  font-size: clamp(20px, 1.7vw, 27px);
  line-height: 1.55;
  white-space: nowrap;
  overflow-x: auto;
}
.equation-display sub,
.equation-display sup {
  font-size: 0.65em;
  line-height: 0;
}
.equation-display .paren {
  display: inline-block;
  padding: 0 0.04em;
  font-size: 1.12em;
}
.equation-display .frac {
  display: inline-grid;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: center;
  vertical-align: middle;
  margin: 0 0.16em;
  line-height: 1.08;
}
.equation-display .frac > span:first-child,
.equation-display .frac-num {
  display: block;
  min-width: 100%;
  padding: 0 0.34em 0.12em;
  border-bottom: 1.6px solid currentColor;
  text-align: center;
}
.equation-display .frac > span:last-child,
.equation-display .frac-den {
  display: block;
  padding: 0.12em 0.34em 0;
  text-align: center;
  font-size: 0.92em;
}

.legend-toggle {
  cursor: pointer;
  grid-template-columns: auto auto minmax(0, 1fr);
}

.legend-toggle > input {
  width: 16px;
  min-height: 16px;
  margin: 1px 2px 0 0;
  accent-color: var(--teal);
}

.legend-toggle.muted {
  opacity: 0.58;
  background: #f3f5f3;
}

.torque-average-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.torque-average-panel:empty {
  display: none;
}

.torque-average-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fbfcfb;
}

.torque-average-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.torque-average-card b {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.25;
}

.torque-average-card p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}


.series-toggle-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.series-toggle-panel .toggle-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-right: 4px;
}

.metric-label-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.metric-label-row .label {
  margin-bottom: 0;
}

.help-dot {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  border: 1px solid #cbd5cf;
  border-radius: 999px;
  background: #f8faf8;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.help-dot:hover,
.help-dot:focus-visible {
  background: #e8f2f1;
  border-color: rgba(15, 118, 110, 0.45);
}

.metric-popover {
  position: absolute;
  z-index: 1000;
  padding: 14px 15px;
  border: 1px solid rgba(15, 118, 110, 0.35);
  border-radius: 10px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 22px 62px rgba(31, 38, 35, 0.24);
  font-size: 13px;
  line-height: 1.7;
}

.metric-popover[hidden] {
  display: none;
}

.metric-popover h3 {
  margin: 0 28px 8px 0;
  font-size: 15px;
}

.metric-popover p {
  margin: 8px 0 0;
}

.metric-popover code {
  display: inline-block;
  max-width: 100%;
  padding: 4px 6px;
  overflow-x: auto;
  border-radius: 6px;
  background: #edf1ee;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  white-space: normal;
}

.metric-popover-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 15px;
  font-weight: 900;
}

.reference-grid {
  grid-template-columns: 1fr;
}

.reference-scroll {
  max-height: min(72vh, 760px);
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable::after {
  content: " ↕";
  color: #9aa7a1;
  font-size: 10px;
}

th.sortable.sorted::after {
  content: " ↑";
  color: var(--teal-dark);
}

th.sortable.sorted.desc::after {
  content: " ↓";
}

.usage-panel,
.method-panel {
  max-width: 1500px;
  margin: 0 auto;
}

.usage-lead,
.method-intro-card {
  margin-bottom: 16px;
  padding: 16px 18px;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-left: 5px solid var(--teal);
  border-radius: 10px;
  background: #edf7f5;
}

.usage-lead p,
.method-intro-card p {
  margin: 0;
  color: #33413c;
  font-size: 14px;
  line-height: 1.95;
}

.usage-lead p + p,
.method-intro-card p + p {
  margin-top: 10px;
}

.usage-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.usage-step-card {
  position: relative;
  min-height: 190px;
  padding: 18px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.usage-step-card > b {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-bottom: 10px;
  border-radius: 999px;
  background: #e8f2f1;
  color: var(--teal-dark);
}

.usage-step-card h3 {
  margin-bottom: 8px;
  font-size: 14px;
}

.usage-step-card p,
.usage-grid p,
.method-grid p,
.method-notes p,
.method-notes li {
  color: #33413c;
  font-size: 13px;
  line-height: 1.95;
}

.usage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.usage-grid pre {
  margin: 0 0 10px;
  overflow: auto;
  padding: 10px;
  border-radius: 8px;
  background: #f7f8f7;
  font-size: 12px;
  line-height: 1.55;
}

.expanded-method-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.expanded-method-grid article {
  padding: 16px;
}

.expanded-method-grid article h3 {
  margin-bottom: 10px;
  font-size: 14px;
}

.expanded-method-grid article p + p {
  margin-top: 8px;
}

.method-formula-box pre {
  line-height: 1.75;
}

@media (max-width: 1100px) {
  .usage-steps,
  .usage-grid,
  .expanded-method-grid {
    grid-template-columns: 1fr;
  }
}

.curve-point-toolbar {
  display: grid;
  grid-template-columns: auto minmax(260px, 460px) 1fr;
  align-items: center;
  gap: 8px;
  margin: 8px 0 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcfb;
}

.curve-point-toolbar label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.curve-point-toolbar select {
  width: 100%;
  min-height: 34px;
}

.curve-point-status {
  justify-self: start;
  white-space: normal;
  line-height: 1.35;
}

.math-note-card {
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.math-note-card h3,
.formula-group h4 {
  margin: 0 0 8px;
}

.math-note-card p {
  margin: 0 0 10px;
  color: #33413c;
  font-size: 13px;
  line-height: 1.85;
}

.math-block,
.metric-formula-math {
  overflow-x: auto;
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 8px;
  background: #f7fbfa;
  color: #20332e;
  font-size: 14px;
  line-height: 1.65;
}

.formula-group {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #dfe5e1;
  border-radius: 10px;
  background: #fff;
}

.formula-group:first-of-type {
  margin-top: 0;
}

.formula-group h4 {
  color: var(--teal-dark);
  font-size: 13px;
}

.metric-popover .metric-formula-math {
  font-size: 13px;
}

@media (max-width: 900px) {
  .curve-point-toolbar {
    grid-template-columns: 1fr;
  }
}

/* 詳細パラメータの折りたたみ */
.advanced-fields {
  margin-top: 8px;
  border-top: 1px dashed var(--line, #d8d2c6);
  padding-top: 6px;
}
.advanced-fields summary {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--muted-ink, #6b6356);
  user-select: none;
  padding: 2px 0;
}
.advanced-fields summary:hover { color: var(--ink, #2c2a26); }
.advanced-fields[open] summary { margin-bottom: 6px; }

/* 計算モデルのサマリーチップ */
.model-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.model-chip {
  font-size: 0.74rem;
  line-height: 1.35;
  color: #4a554f;
  background: #f4f6f3;
  border: 1px solid #dde4de;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.model-chip b {
  color: #0f766e;
  margin-right: 5px;
  font-weight: 600;
}
@media (max-width: 720px) {
  .model-chip { white-space: normal; }
}

/* 機構図解の表示倍率 */
.zoom-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  font-size: 0.8rem;
  color: #5d685f;
}
.zoom-row input[type="range"] { flex: 1; max-width: 220px; accent-color: #0f766e; }

/* 数式: 組版結果のはみ出し防止とプレーン表示 */
.math-block mjx-container,
.metric-formula-math mjx-container,
.equation-display mjx-container {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}
.math-block.math-plain,
.metric-formula-math.math-plain {
  font-family: "Consolas", "Menlo", monospace;
  font-size: 13.5px;
  letter-spacing: 0.01em;
}
.equation-display.math-upgrade { overflow-x: auto; }
