:root {
  --ink: #333;
  --muted: #596477;
  --paper: #fff;
  --surface: #fff;
  --line: #b9c3da;
  --blue: #4169e1;
  --blue-dark: #2449b8;
  --green: #168f48;
  --green-soft: #e8f6ec;
  --red: #e60012;
  --red-soft: #fff0f1;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font-family: Arial, Helvetica, "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  font-size: 0.875rem;
  line-height: 1.35;
}

button, input { font: inherit; }

.page-shell {
  width: min(1560px, calc(100% - 24px));
  margin: 0 auto;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 2px 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #e60012;
  font-size: 0.9rem;
  font-weight: 780;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  color: #fff;
  background: #e60012;
  border-radius: 2px;
}

.brand-mark svg { width: 19px; height: 19px; fill: currentColor; }

.header-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 7px;
  color: #8a93a4;
  font-size: 0.7rem;
  line-height: 1.2;
}

.header-links a {
  color: #6f7889;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.header-links a:hover { color: #e60012; text-decoration: underline; }
.header-links a:focus-visible { outline: 2px solid #4169e1; outline-offset: 2px; }

.simulator-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(420px, 1fr);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid #aeb9d2;
  border-radius: 2px;
}

.setup-block,
.result-block { padding: 17px 19px; }

.setup-block form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: end;
  gap: 9px;
  margin-top: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr 0.8fr;
  gap: 8px;
}

.field {
  display: grid;
  min-width: 0;
  gap: 4px;
  color: #404a5d;
  font-size: 0.74rem;
  font-weight: 700;
}

.field-help {
  color: #7a8497;
  cursor: help;
  font-weight: 400;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}

.input-shell {
  display: flex;
  min-height: 41px;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  background: #f9fbfd;
  border: 1px solid var(--line);
  border-radius: 2px;
  transition: border-color 140ms ease, background 140ms ease;
}

.input-shell:focus-within {
  background: #fff;
  border-color: var(--blue);
  outline: 2px solid rgba(65, 105, 225, 0.18);
  outline-offset: -2px;
}

.input-shell input {
  width: 100%;
  min-width: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 0.9rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.prefix,
.suffix { color: #7a8497; font-size: 0.72rem; font-weight: 680; }

.simulate-button {
  display: flex;
  width: 130px;
  justify-self: start;
  min-height: 41px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 0;
  padding: 0 12px;
  color: #fff;
  background: var(--blue);
  border: 0;
  border-radius: 2px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 790;
  transition: transform 140ms ease, background 140ms ease;
}

.simulate-button:hover { background: var(--blue-dark); transform: translateY(-1px); }
.simulate-button:active { transform: translateY(1px); }
.simulate-button:focus-visible { outline: 3px solid rgba(23, 135, 232, 0.38); outline-offset: 2px; }
.simulate-button svg { width: 15px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

.form-error {
  grid-column: 1 / -1;
  margin: 1px 0 0;
  color: var(--red);
  font-size: 0.72rem;
  font-weight: 680;
}

.result-block {
  position: relative;
  display: grid;
  grid-template-columns: minmax(140px, 0.72fr) minmax(220px, 1fr);
  grid-template-rows: auto auto 5px;
  column-gap: 19px;
  align-content: center;
  overflow: hidden;
  color: var(--ink);
  background: #eef2ff;
  border-left: 1px solid #aeb9d2;
}

.result-block::after { content: none; }

.result-block h2 {
  grid-column: 1;
  grid-row: 1;
  max-width: 220px;
  margin: 0;
  color: #26375e;
  font-size: 0.77rem;
  font-weight: 680;
  letter-spacing: -0.01em;
}

.failure-row {
  display: flex;
  grid-column: 1;
  grid-row: 2;
  align-items: baseline;
  gap: 7px;
  margin-top: 1px;
}

.failure-row strong {
  color: #e60012;
  font-size: clamp(2.8rem, 4.5vw, 4rem);
  line-height: 0.98;
  letter-spacing: -0.08em;
  font-variant-numeric: tabular-nums;
}

.risk-track {
  grid-column: 1;
  grid-row: 3;
  overflow: hidden;
  height: 4px;
  margin: 4px 0 0;
  background: #ccd4e7;
  border-radius: 99px;
}

.risk-track span {
  display: block;
  width: 0;
  height: 100%;
  background: #4169e1;
  border-radius: inherit;
  transition: width 400ms ease, background 200ms ease;
}

.result-details {
  display: grid;
  grid-column: 2;
  grid-row: 1 / 4;
  align-content: center;
}

.result-stats {
  display: grid;
  margin: 0;
}

.result-stats div {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid #cbd3e5;
}

.result-stats dt { color: #596477; font-size: 0.64rem; }
.result-stats dd { margin: 0; color: #16244a; font-size: 0.76rem; font-weight: 780; font-variant-numeric: tabular-nums; text-align: right; }

.share-button {
  justify-self: end;
  min-width: 68px;
  margin-top: 5px;
  padding: 4px 10px;
  color: #2449b8;
  background: #fff;
  border: 1px solid #8da0d0;
  border-radius: 2px;
  cursor: pointer;
  font-size: 0.66rem;
  font-weight: 700;
}

.share-button:hover { color: #fff; background: #4169e1; border-color: #4169e1; }
.share-button:focus-visible { outline: 2px solid #4169e1; outline-offset: 2px; }

.paths-section { padding: 11px 0 24px; }

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 0 18px;
  color: #7a8497;
  font-size: 0.62rem;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 18px;
  margin-bottom: 6px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 11px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 680;
}

.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-line { width: 15px; height: 2px; border-radius: 99px; }
.legend-line.success { background: var(--green); }
.legend-line.failure { background: var(--red); }

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

.chart-card {
  padding: 8px 8px 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 2px;
  animation: chart-in 360ms ease both;
}

.chart-card header,
.chart-axis { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.path-label { color: #4a5568; font-size: 0.65rem; font-weight: 760; }

.path-status {
  padding: 3px 5px;
  border-radius: 999px;
  font-size: 0.55rem;
  font-weight: 810;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.chart-card.is-success .path-status { color: #057155; background: var(--green-soft); }
.chart-card.is-failure .path-status { color: #b92d2d; background: var(--red-soft); }

.chart-card canvas {
  display: block;
  width: 100%;
  height: 110px;
  margin-top: 5px;
}

.chart-axis { color: #8a93a4; font-size: 0.55rem; font-weight: 650; }

@keyframes chart-in {
  from { opacity: 0; transform: translateY(5px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 1120px) {
  .simulator-panel { grid-template-columns: 1fr; }
  .result-block { min-height: 145px; }
  .chart-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .setup-block form { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .page-shell { width: min(100% - 14px, 1560px); }
  .masthead { padding-top: 7px; }
  .header-links { width: 100%; justify-content: flex-start; font-size: 0.66rem; }
  .setup-block, .result-block { padding: 13px; }
  .field-grid { grid-template-columns: 1fr; }
  .chart-card canvas { height: 88px; }
  .site-footer { flex-wrap: wrap; }
}

@media (max-width: 420px) {
  .result-block {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
  }
  .result-block h2, .failure-row, .risk-track, .result-details { grid-column: 1; }
  .result-block h2 { grid-row: 1; }
  .failure-row { grid-row: 2; }
  .risk-track { grid-row: 3; }
  .result-details { grid-row: 4; margin-top: 8px; }
}
