:root {
  color-scheme: light;
  --hist-paper: #f5f4ef;
  --hist-surface: #fbfaf6;
  --hist-ink: #222824;
  --hist-muted: #687069;
  --hist-line: #cfd3cc;
  --hist-line-strong: #9fa79f;
  --hist-accent: #245b49;
  --hist-accent-soft: #e2ebe5;
  --hist-curve: #a35f2d;
  --hist-danger: #9b2f2f;
  --hist-danger-soft: #f8e9e7;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

* {
  box-sizing: border-box;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--hist-accent);
  outline-offset: 3px;
}

.section-kicker {
  margin: 0 0 5px;
  color: var(--hist-accent);
  font-size: .78rem;
  font-weight: 780;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.tool-shell h2,
.table-section h2,
.chart-section h2,
.content-section h2 {
  margin: 0;
  font-size: clamp(1.2rem, 2vw, 1.48rem);
  line-height: 1.4;
}

.tool-shell h3,
.content-section h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.4;
}

.tool-shell {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  border: 1px solid var(--hist-line-strong);
  background: var(--hist-surface);
}

.calculator-panel,
.result-panel {
  min-width: 0;
  padding: 24px;
}

.calculator-panel {
  border-right: 1px solid var(--hist-line);
}

.data-label,
.input-field label {
  display: block;
  font-weight: 760;
}

.data-label {
  margin-top: 18px;
}

.data-input,
.input-field input {
  display: block;
  width: 100%;
  border: 1px solid var(--hist-line-strong);
  border-radius: 2px;
  color: var(--hist-ink);
  background: #fff;
}

.data-input {
  min-height: 156px;
  margin-top: 7px;
  padding: 11px 12px;
  resize: vertical;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  line-height: 1.55;
}

.input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.input-field {
  min-width: 0;
}

.input-field input {
  min-height: 44px;
  margin-top: 7px;
  padding: 9px 10px;
  font-variant-numeric: tabular-nums;
}

.data-input[aria-invalid="true"],
.input-field input[aria-invalid="true"] {
  border-color: var(--hist-danger);
  background: #fff8f8;
}

.optional-label {
  color: var(--hist-muted);
  font-size: .75rem;
  font-weight: 500;
}

.field-help,
.keyboard-help,
.section-state {
  margin: 6px 0 0;
  color: var(--hist-muted);
  font-size: .78rem;
  line-height: 1.55;
}

.keyboard-help {
  margin-top: 12px;
}

.form-error {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-left: 4px solid var(--hist-danger);
  background: var(--hist-danger-soft);
  color: #762525;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.form-error[hidden] {
  display: none;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.button {
  min-height: 46px;
  padding: 9px 16px;
  border: 1px solid var(--hist-accent);
  border-radius: 2px;
  cursor: pointer;
  font-weight: 760;
}

.button-primary {
  color: #fff;
  background: var(--hist-accent);
}

.button-primary:hover {
  background: #1b4738;
}

.button-secondary {
  color: var(--hist-accent);
  background: transparent;
}

.result-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.status-badge {
  flex: 0 0 auto;
  max-width: 44%;
  padding: 4px 8px;
  border: 1px solid var(--hist-line-strong);
  color: var(--hist-muted);
  background: var(--hist-paper);
  font-size: .72rem;
  font-weight: 760;
  text-align: center;
  overflow-wrap: anywhere;
}

.status-badge[data-state="ready"] {
  border-color: var(--hist-accent);
  color: var(--hist-accent);
  background: var(--hist-accent-soft);
}

.status-badge[data-state="error"] {
  border-color: var(--hist-danger);
  color: var(--hist-danger);
  background: var(--hist-danger-soft);
}
.result-summary {
  min-height: 3.4em;
  margin: 13px 0 0;
  color: #38413b;
  font-size: .9rem;
  overflow-wrap: anywhere;
}

.result-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 14px 0 0;
  border-top: 1px solid var(--hist-line);
  border-left: 1px solid var(--hist-line);
}

.result-details[hidden],
.distribution-note[hidden],
.table-wrap[hidden] {
  display: none;
}

.result-details > div {
  min-width: 0;
  padding: 9px 10px;
  border-right: 1px solid var(--hist-line);
  border-bottom: 1px solid var(--hist-line);
  background: #fff;
}

.result-details > .detail-wide {
  grid-column: 1 / -1;
}

.result-details dt {
  color: var(--hist-muted);
  font-size: .72rem;
}

.result-details dd {
  margin: 2px 0 0;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.distribution-note {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--hist-line);
  background: var(--hist-paper);
}

.distribution-note strong {
  color: var(--hist-accent);
  font-size: .86rem;
}

.distribution-note p {
  margin: 5px 0 0;
  color: var(--hist-muted);
  font-size: .82rem;
  overflow-wrap: anywhere;
}

.table-section,
.chart-section {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--hist-line);
}

.table-wrap {
  max-width: 100%;
  margin-top: 12px;
  overflow-x: auto;
  border: 1px solid var(--hist-line);
  background: #fff;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.frequency-table {
  width: 100%;
  min-width: 710px;
  border-collapse: collapse;
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
}

.frequency-table caption {
  padding: 10px 12px;
  color: var(--hist-muted);
  background: var(--hist-paper);
  text-align: left;
}

.frequency-table th,
.frequency-table td {
  padding: 9px 10px;
  border-top: 1px solid var(--hist-line);
  border-right: 1px solid var(--hist-line);
  text-align: right;
  white-space: nowrap;
}

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

.frequency-table th:last-child,
.frequency-table td:last-child {
  border-right: 0;
}

.frequency-table thead th {
  color: var(--hist-accent);
  background: var(--hist-accent-soft);
  font-size: .76rem;
}

.frequency-table tbody tr[data-modal="true"] {
  background: #f5f9f6;
}

.frequency-table tbody tr[data-modal="true"] td:first-child {
  box-shadow: inset 4px 0 0 var(--hist-accent);
  font-weight: 750;
}

.chart-shell {
  margin: 12px 0 0;
  border: 1px solid var(--hist-line);
  background: #f0f2ed;
  overflow: hidden;
}

.distribution-svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 260px;
}

.distribution-svg .chart-grid,
.distribution-svg .chart-axis,
.distribution-svg .chart-tick {
  vector-effect: non-scaling-stroke;
}

.distribution-svg .chart-grid {
  stroke: var(--hist-line);
  stroke-width: 1;
}

.distribution-svg .chart-axis {
  stroke: var(--hist-ink);
  stroke-width: 2;
}

.distribution-svg .chart-tick {
  stroke: var(--hist-line-strong);
  stroke-width: 1;
}

.distribution-svg .chart-bar {
  fill: var(--hist-accent-soft);
  stroke: var(--hist-accent);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.distribution-svg .chart-curve {
  fill: none;
  stroke: var(--hist-curve);
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.distribution-svg .chart-point {
  fill: #fff;
  stroke: var(--hist-curve);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.distribution-svg .chart-label,
.distribution-svg .chart-axis-label {
  fill: var(--hist-muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 15px;
}

.distribution-svg .chart-axis-label {
  fill: var(--hist-ink);
  font-size: 16px;
  font-weight: 700;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 10px 0 0;
  padding: 0;
  color: var(--hist-muted);
  font-size: .76rem;
  list-style: none;
}

.chart-legend li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-bar {
  display: inline-block;
  width: 20px;
  height: 12px;
  border: 2px solid var(--hist-accent);
  background: var(--hist-accent-soft);
}

.legend-line {
  display: inline-block;
  width: 24px;
  border-top: 3px solid var(--hist-curve);
}
.content-section {
  margin-top: 34px;
  padding-top: 28px;
  border-top: 1px solid var(--hist-line-strong);
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
  border-top: 1px solid var(--hist-line);
  border-left: 1px solid var(--hist-line);
}

.method-grid article {
  min-width: 0;
  padding: 14px 15px;
  border-right: 1px solid var(--hist-line);
  border-bottom: 1px solid var(--hist-line);
}

.method-grid strong {
  display: block;
  color: var(--hist-accent);
  overflow-wrap: anywhere;
}

.method-grid p {
  margin: 5px 0 0;
  color: var(--hist-muted);
  font-size: .84rem;
  overflow-wrap: anywhere;
}

.scope-box {
  margin-top: 18px;
  padding: 16px 17px;
  border: 1px solid var(--hist-line);
  background: var(--hist-surface);
}

.scope-box ul {
  margin: 10px 0 0;
  padding-left: 1.25em;
}

.scope-box li + li {
  margin-top: 5px;
}

@media (max-width: 900px) {
  .tool-shell {
    grid-template-columns: 1fr;
  }

  .calculator-panel {
    border-right: 0;
    border-bottom: 1px solid var(--hist-line);
  }
}

@media (max-width: 560px) {
  .calculator-panel,
  .result-panel {
    padding: 18px 14px;
  }

  .input-grid,
  .result-details,
  .method-grid {
    grid-template-columns: 1fr;
  }

  .result-details > .detail-wide {
    grid-column: auto;
  }

  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }

  .distribution-svg {
    min-height: 210px;
  }

  .distribution-svg .chart-label {
    font-size: 20px;
  }

  .distribution-svg .chart-axis-label {
    font-size: 21px;
  }
}

@media (max-width: 390px) {
  .result-heading-row {
    gap: 8px;
  }

  .status-badge {
    max-width: 42%;
  }

  .chart-legend {
    display: grid;
    grid-template-columns: 1fr;
  }
}

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