/* ============================================================
   カップ数と身長の相互変換
   ============================================================ */

:root {
  --ink: #222;
  --ink-soft: #555;
  --muted: #767676;
  --line: #d5d5d5;
  --line-soft: #e8e8e8;
  --bg: #fff;
  --accent: #1f5fbf;
  --sans: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px 64px;
}

/* ---------- ヘッダー ---------- */

.page-head {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.page-head h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.4;
}

/* ---------- セクション ---------- */

.block {
  padding: 28px 0;
  border-bottom: 1px solid var(--line-soft);
}

.block h2 {
  margin: 0 0 18px;
  font-size: 1rem;
  font-weight: 600;
}

/* ---------- 入力（相互変換） ---------- */

.convert-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-bottom: 16px;
}

.field-label {
  flex: none;
  width: 66px;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.cup-picker {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
  min-width: 260px;
}

.cup-button {
  appearance: none;
  padding: 9px 0;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.9rem;
  cursor: pointer;
}

.cup-button:hover { border-color: var(--ink-soft); }

.cup-button.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.height-field {
  display: flex;
  align-items: baseline;
  gap: 6px;
  width: 190px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--line);
}

.height-field:focus-within { border-bottom-color: var(--accent); }

.height-field input {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
  outline: 0;
  appearance: textfield;
}

.height-field input::-webkit-outer-spin-button,
.height-field input::-webkit-inner-spin-button { appearance: none; margin: 0; }

.unit {
  color: var(--muted);
  font-size: 0.85rem;
}

.slider {
  display: block;
  width: 100%;
  max-width: 360px;
  margin: 0 0 0 82px;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.slider::-webkit-slider-runnable-track {
  height: 3px;
  background: var(--line);
}

.slider::-moz-range-track {
  height: 3px;
  background: var(--line);
}

.slider::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5.5px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
}

.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
}

/* ---------- 数値 ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.stats div { min-width: 0; }

.stats dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.stats dd {
  margin: 1px 0 0;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- グラフ ---------- */

.charts {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 32px;
}

.chart { margin: 0; }

.chart figcaption {
  margin-bottom: 12px;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.cup-bars {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
  align-items: end;
  height: 130px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.cup-bar {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.cup-bar-fill {
  width: 100%;
  height: var(--bar-height, 50%);
  background: #c4c4c4;
}

.cup-bar:hover .cup-bar-fill { background: #8a8a8a; }

.cup-bar.is-active .cup-bar-fill { background: var(--ink); }

.cup-bar-label {
  position: absolute;
  bottom: -21px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 0.72rem;
}

.cup-bar.is-active .cup-bar-label {
  color: var(--ink);
  font-weight: 600;
}

.cup-bar-share {
  position: absolute;
  bottom: calc(var(--bar-height, 50%) + 3px);
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 0.68rem;
  white-space: nowrap;
}

.cup-bar.is-active .cup-bar-share { color: var(--ink); }

.normal-chart {
  display: block;
  width: 100%;
  height: auto;
}

.normal-chart text {
  font-family: var(--sans);
  font-size: 9px;
  fill: var(--muted);
}

.normal-chart .chart-shade { fill: #d6d6d6; }
.normal-chart .chart-line { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.normal-chart .chart-axis { stroke: var(--line); stroke-width: 1; }
.normal-chart .marker-line { stroke: var(--accent); stroke-width: 1.2; stroke-dasharray: 3 3; }
.normal-chart .marker-dot { fill: var(--accent); }
.normal-chart .marker-label-text { fill: var(--ink); font-size: 10px; font-weight: 600; }

/* ---------- 対応表 ---------- */

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

.mapping-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

.mapping-table th,
.mapping-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.mapping-table th {
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 500;
  font-size: 0.75rem;
}

.mapping-table tbody tr { cursor: pointer; }

.mapping-table tbody tr:hover { background: #f6f6f6; }

.mapping-table tbody tr.is-selected { background: #efefef; }

.mapping-table .cup-cell { font-weight: 600; }

/* ---------- フォーカス ---------- */

.cup-button:focus-visible,
.height-field input:focus-visible,
.slider:focus-visible,
.mapping-table tbody tr:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- レスポンシブ ---------- */

@media (max-width: 600px) {
  .page { padding: 26px 16px 48px; }
  .convert-row { gap: 6px 12px; }
  .field-label { width: 100%; }
  .height-field { width: 160px; }
  .slider { margin-left: 0; max-width: none; }
  .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .cup-bars { height: 110px; gap: 4px; }
  .cup-bar-share { font-size: 0.6rem; }
  .mapping-table th,
  .mapping-table td { padding: 7px 6px; font-size: 0.78rem; }
}
