/*
 * 地形図の紙とインクを下敷きにした配色。
 * - 軌跡（その山行そのもの）は地図でもグラフでも同じマゼンタ。標高による塗り分けも同じ色相の明暗
 * - 累積標高・登りは緑、年ごとの線は青・橙・緑
 * どれも明暗それぞれの背景で、彩度・明度帯・コントラストを検証済み。
 */
:root {
  color-scheme: light;
  --paper: #f1f3ee;
  --paper-raised: #e7ebe4;
  --card: #f8f9f6;
  --ink: #1d2521;
  --ink-2: #56615a;
  --rule: #d5dbd3;
  --track: #c2185b;
  --ascent: #128259;
  --descent: #7d8a82;
  --silhouette: #c3cbc2;
  --rest: rgb(86 97 90 / 0.13);
  --danger: #b3261e;
  --elev-1: #dc6fa3;
  --elev-2: #c24a86;
  --elev-3: #a02c6c;
  --elev-4: #781552;
  --elev-5: #4f0636;
  --year-1: #2a78d6;
  --year-2: #eb6834;
  --year-3: #1baf7a;
  --shadow: 0 1px 2px rgb(29 37 33 / 0.06), 0 4px 16px rgb(29 37 33 / 0.06);
  --radius: 12px;
  --font: "IBM Plex Sans JP", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #161b18;
    --paper-raised: #1f2622;
    --card: #1b211e;
    --ink: #e8ece8;
    --ink-2: #a9b3ac;
    --rule: #2c342f;
    --track: #e45a8c;
    --ascent: #22a672;
    --descent: #6f7b74;
    --silhouette: #3b4640;
    --rest: rgb(169 179 172 / 0.12);
    --danger: #f2877f;
    --elev-1: #9c2d6f;
    --elev-2: #bf4389;
    --elev-3: #db62a3;
    --elev-4: #ee8cc0;
    --elev-5: #f9c1dc;
    --year-1: #3987e5;
    --year-2: #d95926;
    --year-3: #199e70;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--ascent);
  outline-offset: 2px;
  border-radius: 4px;
}

h1,
h2,
h3 {
  line-height: 1.35;
  margin: 0;
}

.num {
  font-variant-numeric: tabular-nums;
}

[data-lucide],
.lucide {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
  vertical-align: -3px;
  flex: none;
}

.sub {
  font-size: 13px;
  color: var(--ink-2);
}

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

.site {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}

.site-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  text-decoration: none;
  flex: none;
}

.brand-mark {
  width: 32px;
  height: 20px;
  fill: var(--ink);
}

.site nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.site nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink-2);
  font-weight: 500;
  white-space: nowrap;
}

.site nav a:hover {
  background: var(--paper-raised);
  color: var(--ink);
}

.site nav a[aria-current="page"] {
  background: var(--ink);
  color: var(--paper);
}

.account-link {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  color: var(--ink-2);
  text-decoration: none;
  flex: none;
}

.account-link:hover {
  background: var(--paper-raised);
  color: var(--ink);
}

.account-link[aria-current="page"] {
  background: var(--ink);
  color: var(--paper);
}

.account-link .lucide {
  width: 22px;
  height: 22px;
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 24px 80px;
}

main:focus {
  outline: none;
}

.page-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.lede {
  color: var(--ink-2);
  max-width: 44em;
  margin: 4px 0 12px;
}

.notice {
  padding: 24px 0;
  color: var(--ink-2);
  max-width: 44em;
}

.notice.error {
  color: var(--danger);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 48px 0 14px;
}

.section-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 19px;
  font-weight: 600;
}

.section-title .lucide {
  color: var(--ink-2);
}

.section-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.sub-title {
  font-size: 15px;
  font-weight: 600;
  margin: 20px 0 4px;
  color: var(--ink-2);
}

.more {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.more:hover {
  color: var(--ink);
}

.chart-note {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--ink-2);
}

/* ---------- ボタン ---------- */

.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}

.button:hover {
  background: var(--paper-raised);
}

.button.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.button.primary:hover {
  opacity: 0.88;
}

.button.danger {
  color: var(--danger);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--paper-raised);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  background: var(--paper);
}

.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
  padding: 3px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.segmented button .lucide {
  width: 15px;
  height: 15px;
  vertical-align: -2px;
}

.segmented button:hover {
  color: var(--ink);
}

.segmented button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

/* ---------- 概要 ---------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.stat {
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.stat-label {
  font-size: 13px;
  color: var(--ink-2);
}

.stat-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
}

.stat-value .unit {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-2);
}

.stat-sub {
  display: flex;
  flex-direction: column;
  margin-top: 4px;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.delta .lucide {
  width: 15px;
  height: 15px;
}

.delta.up {
  color: var(--ascent);
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.trip-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.15s;
}

.trip-card:hover {
  box-shadow: var(--shadow);
}

.card-thumb {
  background:
    linear-gradient(var(--rule) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--rule) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--paper-raised);
  border-bottom: 1px solid var(--rule);
}

.thumb {
  display: block;
  width: 100%;
  height: 140px;
}

.thumb-line {
  fill: none;
  stroke: var(--track);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.thumb-start {
  fill: none;
  stroke: var(--ink);
  stroke-width: 9;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.card-body {
  padding: 14px 16px 16px;
}

.card-date {
  font-size: 13px;
  color: var(--ink-2);
}

.card-title {
  font-size: 17px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-peaks {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--ink-2);
  overflow: hidden;
  white-space: nowrap;
}

.card-peaks .lucide {
  width: 15px;
  height: 15px;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0 0;
}

.mini-stats dt {
  font-size: 12px;
  color: var(--ink-2);
}

.mini-stats dd {
  margin: 0;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

/* 山行カレンダー（山並み）と、右側の年の切り替え */
.ridge-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  gap: 16px;
  align-items: start;
}

.year-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 30px;
}

.year-list button {
  border: 0;
  border-radius: 8px;
  padding: 5px 14px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-align: left;
  cursor: pointer;
}

.year-list button:hover {
  background: var(--paper-raised);
  color: var(--ink);
}

.year-list button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
}

.year-select {
  margin-top: 30px;
  padding: 6px 8px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

.chart.ridge {
  cursor: default;
}

.chart.ridge .peak {
  cursor: pointer;
  outline: none;
}

.chart.ridge .peak path {
  fill: var(--ascent);
  fill-opacity: 0.14;
  stroke: var(--ascent);
  stroke-width: 2.25;
  stroke-linejoin: round;
}

.chart.ridge .peak:hover path,
.chart.ridge .peak:focus-visible path {
  fill-opacity: 0.3;
  stroke-width: 3.25;
}

.chart.ridge .ground {
  stroke: var(--ink-2);
  stroke-width: 1.5;
}

.chart.ridge .month-tick {
  stroke: var(--ink-2);
}

.chart.ridge .future {
  fill: var(--ink);
  opacity: 0.04;
}

.chart.ridge .today-line {
  stroke: var(--ink-2);
  stroke-dasharray: 3 3;
}

.chart.ridge .peak-name {
  fill: var(--ink);
  font-size: 13px;
  font-weight: 600;
  paint-order: stroke;
  stroke: var(--paper);
  stroke-width: 3px;
  pointer-events: none;
}

.chart.ridge .peak-alt {
  fill: var(--ink-2);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  paint-order: stroke;
  stroke: var(--paper);
  stroke-width: 3px;
  pointer-events: none;
}

.chart.ridge .empty {
  font-size: 14px;
}

.bests {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.best {
  display: block;
  padding: 16px 18px;
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  transition: box-shadow 0.15s;
}

.best:hover {
  box-shadow: var(--shadow);
}

.best-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-2);
}

.best-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.3;
  margin-top: 2px;
}

.best-trip {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.best-trip span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.best-trip span:last-child {
  color: var(--ink-2);
  flex: none;
}

.best-note {
  font-size: 12px;
  color: var(--ink-2);
}

/* ---------- 山行の一覧 ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  margin: 20px 0 8px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 280px;
  max-width: 420px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-2);
}

.search:focus-within {
  border-color: var(--ink-2);
}

.search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 8px 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  outline: none;
}

.year {
  margin-top: 32px;
}

.year-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--ink);
}

.year-head h2 {
  font-size: 28px;
  font-weight: 700;
}

.year-sum {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  color: var(--ink-2);
}

.year-sum strong {
  color: var(--ink);
  font-weight: 600;
}

.trips {
  list-style: none;
  margin: 0;
  padding: 0;
}

.trip,
.col-labels {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 120px 360px;
  align-items: center;
  gap: 20px;
}

.trip {
  padding: 14px 8px;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
}

.trip:hover {
  background: var(--paper-raised);
}

.trip-date {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.trip-date .md {
  font-size: 21px;
  font-weight: 600;
}

.trip-date .dow {
  font-size: 13px;
  color: var(--ink-2);
}

.trip-title {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.trip-title .name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trip-title .route {
  font-size: 13px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.silhouette {
  width: 120px;
  height: 36px;
  display: block;
  overflow: visible;
}

.silhouette .land {
  fill: var(--silhouette);
}

.silhouette .ridge {
  fill: none;
  stroke: var(--ink-2);
  stroke-width: 1.25;
  stroke-linejoin: round;
}

.silhouette .peak {
  fill: var(--track);
  stroke: var(--paper);
  stroke-width: 1.5;
}

.trip-nums,
.col-labels .labels {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  text-align: right;
}

.trip-nums span {
  white-space: nowrap;
  color: var(--ink-2);
}

.trip-nums span.sorted {
  color: var(--ink);
  font-weight: 600;
}

.trip-nums small,
.col-labels small {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.3;
}

.col-labels small.sorted {
  color: var(--ink);
  font-weight: 600;
}

/* 数値の見出しは広い画面では列見出しにまとめ、狭い画面では各行に出す */
.trip-nums .m-only {
  display: none;
}

.col-labels {
  padding: 10px 8px 0;
}

/* ---------- 山行の詳細 ---------- */

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  text-decoration: none;
  margin-bottom: 12px;
}

.back:hover {
  color: var(--ink);
}

.trip-heading .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  color: var(--ink-2);
  margin: 6px 0 0;
}

.trip-heading .meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.peak-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.peak-chips li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px 3px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--card);
}

.peak-chips .name {
  font-weight: 600;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr);
  gap: 24px;
  margin-top: 24px;
}

.map-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.map-frame {
  position: relative;
}

.map {
  height: 480px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-raised);
}

.map.tall {
  height: min(72vh, 720px);
}

.map-panel {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  max-width: calc(100% - 64px);
  pointer-events: none;
}

.map-panel > * {
  pointer-events: auto;
}

.map-panel-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.map-panel .segmented {
  box-shadow: var(--shadow);
}

.map-panel .segmented button {
  font-size: 13px;
  padding: 2px 10px;
}

.exag,
.map-hint,
.elev-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--ink-2);
  margin: 0;
}

.exag[hidden],
.map-hint[hidden] {
  display: none;
}

.exag input {
  width: 110px;
  accent-color: var(--ink);
}

.exag output {
  color: var(--ink);
  min-width: 3.5em;
}

.elev-legend .num {
  color: var(--ink);
}

.elev-legend .ramp {
  width: 90px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--elev-1), var(--elev-2), var(--elev-3), var(--elev-4), var(--elev-5));
}

.end-marker {
  padding: 1px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.3);
}

/* 目印の要素には MapLibre が position: absolute を付けるので、ここでは position を指定しない */
.summit-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3px 10px 4px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: 0 1px 6px rgb(0 0 0 / 0.3);
}

.summit-marker .name {
  font-weight: 700;
  font-size: 13px;
}

.summit-marker .num {
  color: var(--ink-2);
}

.summit-marker::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  margin-left: -6px;
  border: 6px solid transparent;
  border-bottom: 0;
  border-top-color: var(--paper);
}

.replay {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.replay .play {
  min-width: 118px;
  justify-content: center;
}

.replay-hud {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 16px;
  margin-left: auto;
  font-size: 14px;
  font-weight: 600;
}

.replay-hud > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.replay-hud .lucide {
  width: 16px;
  height: 16px;
  color: var(--ink-2);
}

.replay-hud .sub {
  font-weight: 400;
}

.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 20px;
  margin: 0;
  align-content: start;
}

.facts div {
  border-top: 1px solid var(--rule);
  padding-top: 8px;
}

.facts dt {
  font-size: 13px;
  color: var(--ink-2);
}

.facts dd {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.3;
}

.facts dd small {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-2);
}

.rest-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 8px;
}

.rest-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.rest-item:hover {
  background: var(--paper-raised);
}

.rest-time {
  font-size: 14px;
  color: var(--ink-2);
}

.rest-place {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rest-dur {
  font-weight: 600;
}

.split-name {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.split-name .lucide {
  width: 15px;
  height: 15px;
  color: var(--ink-2);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 48px;
}

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

.chart-wrap {
  position: relative;
}

.chart {
  width: 100%;
  display: block;
  touch-action: pan-y;
  cursor: crosshair;
}

.chart .grid-line {
  stroke: var(--rule);
  stroke-width: 1;
}

.chart .zero-line {
  stroke: var(--ink-2);
  stroke-width: 1;
}

.chart .tick {
  fill: var(--ink-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.chart .tick.value {
  fill: var(--ink);
  font-weight: 600;
}

.chart .area {
  fill: var(--track);
  opacity: 0.1;
}

.chart .line {
  fill: none;
  stroke: var(--track);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart .rest-band {
  fill: var(--rest);
}

.chart .rest-dot {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 1.5;
}

.chart .cursor-line {
  stroke: var(--ink-2);
  stroke-width: 1;
}

.chart .cursor-dot {
  fill: var(--track);
  stroke: var(--paper);
  stroke-width: 2;
}

.chart .cursor-dot.other {
  fill: var(--descent);
}

.chart .bar {
  fill: var(--ascent);
}

.chart .bar.down {
  fill: var(--descent);
}

.chart:not(.pace) .bar:hover,
.chart .bar:focus-visible {
  opacity: 0.75;
  outline: none;
}

.chart .summit-mark {
  fill: var(--ink);
}

.chart .summit-label {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 600;
  paint-order: stroke;
  stroke: var(--paper);
  stroke-width: 3px;
}

.chart .series {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart .series.current {
  stroke: var(--track);
  stroke-width: 2.75;
}

.chart .series.other {
  stroke: var(--descent);
  opacity: 0.8;
}

.chart .series.year-1,
.chart .key.year-1 {
  stroke: var(--year-1);
}

.chart .series.year-2,
.chart .key.year-2 {
  stroke: var(--year-2);
}

.chart .series.year-3,
.chart .key.year-3 {
  stroke: var(--year-3);
}

.chart .series.latest {
  stroke-width: 3;
}

.chart .key {
  stroke-width: 3;
  stroke-linecap: round;
}

.chart .end-label {
  fill: var(--ink-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.chart .end-label.current {
  fill: var(--ink);
  font-weight: 600;
}

.chart:focus-visible {
  outline: 2px solid var(--ascent);
  outline-offset: 4px;
}

.tooltip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.18);
  max-width: 260px;
  font-variant-numeric: tabular-nums;
}

.tooltip strong {
  display: block;
  font-size: 16px;
  font-weight: 600;
}

/* ---------- 表 ---------- */

details {
  margin-top: 12px;
}

details summary {
  cursor: pointer;
  color: var(--ink-2);
  padding: 8px 0;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

table.data th,
table.data td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}

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

table.data thead th {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  border-bottom: 2px solid var(--ink);
}

table.data tfoot th,
table.data tfoot td {
  font-weight: 600;
  border-bottom: 0;
  border-top: 2px solid var(--ink);
}

table.data tr.current td {
  background: var(--paper-raised);
}

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

.summit-table .summit-name a {
  font-weight: 600;
  text-decoration: none;
}

.summit-table .summit-name a:hover {
  text-decoration: underline;
}

.summit-table .ele-cell {
  width: 40%;
  min-width: 200px;
}

/* 標高の棒（0 m から、いちばん高い山を枠いっぱいとして比べる）と数値を横に並べる */
.ele-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ele-track {
  flex: 1;
  height: 8px;
}

.ele-bar {
  display: block;
  height: 100%;
  border-radius: 0 4px 4px 0;
  background: var(--silhouette);
}

.ele-row .num {
  flex: none;
  min-width: 4.5em;
  text-align: right;
}

/* ---------- 地図（すべての山行） ---------- */

.atlas {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
}

.atlas-side {
  max-height: min(72vh, 720px);
  overflow-y: auto;
  border-top: 1px solid var(--rule);
}

.atlas-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.atlas-item {
  display: grid;
  grid-template-columns: 6.2em minmax(0, 1fr);
  gap: 0 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
}

.atlas-item .date {
  grid-row: span 2;
  font-size: 13px;
  color: var(--ink-2);
  padding-top: 2px;
}

.atlas-item .name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.atlas-list li.active .atlas-item,
.atlas-item:hover {
  background: var(--paper-raised);
  box-shadow: inset 3px 0 0 var(--track);
}

.popup {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font);
}

.popup-title {
  font-size: 15px;
}

.popup .sub {
  color: #56615a;
}

.popup-trip {
  display: flex;
  flex-direction: column;
  padding: 6px 8px;
  border-radius: 6px;
  background: #eef1ec;
  text-decoration: none;
  line-height: 1.45;
}

.popup-trip:hover {
  background: #e2e7df;
}

.popup-trip .num {
  font-size: 12px;
  color: #56615a;
}

.maplibregl-popup-content {
  font-family: var(--font);
  color: #1d2521;
  padding: 12px 14px;
  border-radius: 10px;
}

/* ---------- 狭い画面 ---------- */

@media (max-width: 1000px) {
  .kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .trip,
  .col-labels {
    grid-template-columns: 64px minmax(0, 1fr) 120px 300px;
  }
}

@media (max-width: 820px) {
  .site-inner,
  main {
    padding-left: 16px;
    padding-right: 16px;
  }

  .site-inner {
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .brand {
    order: 1;
  }

  .account-link {
    order: 2;
  }

  .site nav {
    order: 3;
    width: 100%;
  }

  .site nav a {
    padding: 4px 12px;
  }

  .page-title {
    font-size: 26px;
  }

  /* 5 枚を 2 列に並べると 1 枚余るので、累積標高だけ 2 列分の幅にする */
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-flow: dense;
  }

  .kpis .stat:nth-child(2) {
    grid-column: span 2;
  }

  .stat-value {
    font-size: 26px;
  }

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

  .trip-card {
    flex-direction: row;
  }

  .card-thumb {
    flex: 0 0 104px;
    border-bottom: 0;
    border-right: 1px solid var(--rule);
  }

  .thumb {
    height: 100%;
    min-height: 120px;
  }

  .card-body {
    min-width: 0;
  }

  .trip {
    grid-template-columns: 52px minmax(0, 1fr) 96px;
    gap: 12px;
  }

  .trip-nums {
    grid-column: 2 / -1;
    text-align: left;
    grid-template-columns: repeat(4, auto);
    justify-content: start;
    gap: 16px;
  }

  .silhouette {
    width: 96px;
  }

  .col-labels {
    display: none;
  }

  .trip-nums .m-only {
    display: block;
  }

  .detail-grid,
  .atlas,
  .ridge-layout {
    grid-template-columns: 1fr;
  }

  .year-list {
    flex-direction: row;
    order: -1;
    padding-top: 0;
    overflow-x: auto;
  }

  .year-select {
    order: -1;
    margin-top: 0;
    justify-self: start;
  }

  .map {
    height: 380px;
  }

  .map.tall {
    height: 460px;
  }

  .atlas-side {
    max-height: none;
  }

  .replay-hud {
    margin-left: 0;
    width: 100%;
  }
}

@media (max-width: 520px) {
  /* 4 つの項目を等分し、アイコンの下にラベルを置いて全部を見せる */
  .site nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    overflow: visible;
  }

  .site nav a {
    flex-direction: column;
    gap: 0;
    padding: 4px 0;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.4;
  }

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

  .facts dd {
    font-size: 20px;
  }

  .map-panel .segmented button {
    padding: 2px 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

/* ---------- アカウント ---------- */

.account-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  padding: 20px;
  margin-top: 20px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.account-head {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 17px;
}

.account-head .lucide {
  width: 32px;
  height: 32px;
  color: var(--ink-2);
}

.account-meta {
  margin: 0;
  display: grid;
  gap: 4px;
}

.account-meta dt {
  font-size: 13px;
  color: var(--ink-2);
}

.account-meta dd {
  margin: 0;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  word-break: break-all;
}

.token-issued {
  margin: 16px 0;
  padding: 16px 18px;
  border: 1px solid var(--ascent);
  border-radius: var(--radius);
  background: var(--card);
}

.token-issued-head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ascent);
  margin-bottom: 10px;
}

.token-value {
  display: block;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--paper-raised);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  word-break: break-all;
  user-select: all;
}

.token-issued .actions {
  margin-top: 12px;
}

.token-name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.token-name .lucide {
  color: var(--ink-2);
}

.notice.signin {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}
