:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-strong: #eef3f5;
  --text: #172026;
  --muted: #62717b;
  --border: #d8e0e5;
  --accent: #0f6b7a;
  --accent-strong: #084c59;
  --danger: #b71d3f;
  --warning: #c47a24;
  --ok: #2f8f74;
  --shadow: 0 14px 40px rgba(28, 45, 58, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Hiragino Sans",
    "Yu Gothic",
    "Meiryo",
    system-ui,
    sans-serif;
  line-height: 1.55;
}

button,
input,
select {
  font: inherit;
}

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

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 3vw, 2.8rem);
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.data-badge {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

.notice,
.integration-panel,
.toolbar,
.commute-panel,
.map-panel,
.insight-panel,
.ranking-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  color: #37454d;
  font-size: 0.92rem;
  box-shadow: none;
}

.credit-note {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.84rem;
}

.integration-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
}

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

.integration-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.integration-metric {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px;
}

.integration-metric span,
.integration-metric small {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.integration-metric strong {
  display: block;
  margin-top: 2px;
  font-size: 1.2rem;
}

.integration-samples {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.integration-samples li {
  display: grid;
  gap: 2px;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #eef8f8;
  padding: 8px;
}

.integration-samples strong {
  font-size: 0.86rem;
}

.integration-samples span {
  color: var(--muted);
  font-size: 0.74rem;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr minmax(220px, 1.6fr) 1fr auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  padding: 14px;
}

.field,
.check-field {
  display: grid;
  gap: 6px;
}

.field span,
.check-field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.check-field {
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 42px;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

.field input:focus,
.field select:focus {
  outline: 3px solid rgba(15, 107, 122, 0.2);
  border-color: var(--accent);
}

.commute-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
}

.commute-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(220px, 1.1fr) minmax(150px, 0.6fr) auto;
  gap: 12px;
  align-items: end;
}

.commute-results {
  display: grid;
  gap: 10px;
}

.commute-source-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.commute-status,
.commute-empty {
  border-radius: 8px;
  background: #eef8f8;
  color: #31535a;
  padding: 8px 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.commute-empty {
  background: #fff5e8;
  color: #774b18;
}

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

.commute-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(82px, auto) minmax(104px, auto);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-left: 5px solid #b7c8d2;
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px;
}

.commute-row.is-current {
  border-left-color: var(--accent);
  background: #f0faf9;
}

.commute-row.is-selected {
  outline: 2px solid rgba(15, 107, 122, 0.22);
}

.commute-main {
  min-width: 0;
}

.commute-main strong,
.commute-main span {
  display: block;
}

.commute-main strong {
  font-size: 0.94rem;
}

.commute-main span,
.commute-main p,
.commute-time span {
  color: var(--muted);
  font-size: 0.76rem;
}

.commute-main p {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.commute-time {
  text-align: right;
}

.commute-time strong {
  display: block;
  font-size: 1.35rem;
  line-height: 1;
}

.commute-actions {
  display: grid;
  gap: 6px;
}

.commute-select,
.property-link,
.route-link {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 9px;
  background: #fff;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.commute-select:hover,
.property-link:hover,
.route-link:hover {
  border-color: var(--accent);
  background: #e8f3f4;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.map-panel,
.insight-panel,
.ranking-panel {
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.panel-heading.compact {
  margin-top: 18px;
}

.map-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.legend {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 4px;
  border-radius: 50%;
  vertical-align: -1px;
}

.legend-dot.low {
  background: var(--ok);
}

.legend-dot.mid {
  background: var(--warning);
}

.legend-dot.high {
  background: var(--danger);
}

.zoom-controls {
  display: inline-grid;
  grid-template-columns: 34px minmax(52px, auto) 34px 42px;
  gap: 6px;
  align-items: center;
}

.zoom-controls button {
  display: inline-grid;
  width: 34px;
  min-width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

#zoomReset {
  width: 42px;
  min-width: 42px;
  font-size: 0.76rem;
}

.zoom-controls button:hover {
  border-color: var(--accent);
  background: #e8f3f4;
}

#zoomLevel {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.map-root {
  position: relative;
  min-height: 540px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(rgba(116, 146, 164, 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(116, 146, 164, 0.22) 1px, transparent 1px),
    var(--surface-strong);
  background-size: 44px 44px;
  cursor: grab;
  touch-action: none;
}

.map-root.is-dragging {
  cursor: grabbing;
}

.map-svg {
  width: 100%;
  height: 540px;
  display: block;
}

.route-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 1px 1px rgba(23, 32, 38, 0.18));
}

.route-line-halo {
  fill: none;
  stroke: rgba(255, 255, 255, 0.74);
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.station-node {
  cursor: pointer;
  stroke: #ffffff;
  stroke-width: 2.5;
  transition: opacity 160ms ease, r 160ms ease;
}

.station-node:hover,
.station-node.is-selected {
  opacity: 1;
  stroke: #172026;
}

.station-node.is-major-terminal {
  stroke: #10242d;
  stroke-width: 3.1;
  filter: drop-shadow(0 2px 3px rgba(15, 31, 39, 0.28));
}

.station-node.is-price-missing {
  stroke: rgba(82, 101, 111, 0.72);
  stroke-width: 1.8;
}

.station-label {
  pointer-events: none;
  fill: #26343b;
  dominant-baseline: central;
  font-size: var(--station-label-font-size, 12px);
  font-weight: 700;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: var(--station-label-stroke-width, 4px);
}

.station-price-label {
  pointer-events: none;
  fill: #ffffff;
  dominant-baseline: central;
  font-size: var(--station-price-label-font-size, 9px);
  font-weight: 900;
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgba(20, 28, 34, 0.55);
  stroke-width: var(--station-price-label-stroke-width, 2px);
}

.map-render-summary {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.map-empty {
  display: grid;
  min-height: 540px;
  place-items: center;
  color: var(--muted);
}

.method-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  gap: 12px;
  margin-top: 12px;
}

.method-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.method-card h3 {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.92rem;
  letter-spacing: 0;
}

.method-card p,
.method-card li {
  color: #40505a;
  font-size: 0.84rem;
}

.method-card p {
  margin: 0 0 6px;
}

.method-card p:last-child {
  margin-bottom: 0;
}

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

.method-card li + li {
  margin-top: 5px;
}

.station-detail {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

.detail-kicker {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
}

.detail-title {
  margin-bottom: 4px;
  font-size: 1.5rem;
  line-height: 1.2;
}

.detail-note {
  color: var(--muted);
  font-size: 0.9rem;
}

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

.metric {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 3px;
  font-size: 1.08rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  border-radius: 8px;
  background: #e8f3f4;
  color: var(--accent-strong);
  padding: 4px 8px;
  font-size: 0.78rem;
  font-weight: 700;
}

.line-summary {
  display: grid;
  gap: 10px;
}

.line-row {
  display: grid;
  gap: 6px;
}

.line-row-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 800;
}

.line-price {
  display: grid;
  gap: 1px;
  justify-items: end;
  text-align: right;
}

.line-price small {
  color: var(--muted);
  font-size: 0.72rem;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 8px;
  background: #dfe7eb;
}

.bar-fill {
  height: 100%;
  border-radius: 8px;
}

.line-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.ranking-panel {
  margin-top: 16px;
}

.result-count {
  white-space: nowrap;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #eef3f5;
  color: #3d4c54;
  font-size: 0.78rem;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.is-selected {
  background: #eef8f8;
}

.station-name {
  font-weight: 800;
}

.price-cell {
  display: grid;
  gap: 2px;
}

.price-cell strong {
  font-size: 0.92rem;
}

.price-cell span {
  color: var(--muted);
  font-size: 0.78rem;
}

.subtext {
  color: var(--muted);
  font-size: 0.78rem;
}

.confidence {
  display: inline-block;
  border-radius: 8px;
  padding: 2px 8px;
  background: #edf1f3;
  color: #384a53;
  font-size: 0.78rem;
  font-weight: 800;
}

.confidence.high {
  background: #e3f4ec;
  color: #1d6c52;
}

.confidence.medium {
  background: #fff0da;
  color: #8a5419;
}

.confidence.low {
  background: #f1e9f6;
  color: #6a3d7d;
}

.estimate-badge {
  display: inline-block;
  margin-left: 4px;
  border-radius: 6px;
  padding: 2px 6px;
  background: #eef6f7;
  color: #0d5965;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.estimate-badge.expanded {
  background: #fff4df;
  color: #8b5215;
}

.estimate-badge.municipality {
  background: #edf1f3;
  color: #465861;
}

.estimate-badge.missing {
  background: #f0f2f3;
  color: #74838a;
}

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

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

  .commute-controls,
  .commute-list {
    grid-template-columns: 1fr;
  }

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

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

  .integration-grid,
  .integration-samples {
    grid-template-columns: 1fr;
  }

  .map-root,
  .map-svg,
  .map-empty {
    min-height: 460px;
    height: 460px;
  }
}

@media (max-width: 640px) {
  .app-header,
  .integration-heading,
  .panel-heading {
    display: grid;
  }

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

  .data-badge,
  .result-count,
  .legend {
    white-space: normal;
  }

  .map-actions {
    justify-items: start;
  }

  .commute-row {
    grid-template-columns: 1fr;
  }

  .commute-time {
    text-align: left;
  }

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

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

  .map-root,
  .map-svg,
  .map-empty {
    min-height: 390px;
    height: 390px;
  }
}
