:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dfe3e8;
  --text: #17202b;
  --muted: #5d6b7a;
  --accent: #1d6fd8;
  --accent-contrast: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #dc2626;
  --danger-halo: rgba(220, 38, 38, 0.28);
  --mode-star: #1d6fd8;
  --mode-other: #8b5cf6;
  --mode-surface: #6b7280;
  --map-bg-inner: #e6f0fa;
  --map-bg-outer: #cfe2f4;
  --map-atmosphere: rgba(147, 197, 253, 0.45);
  --map-ocean-light: #f2f8ff;
  --map-ocean: #cde4f7;
  --map-land: #faf8f2;
  --map-coast: #9bbcd9;
  --map-border: #dce3ea;
  --map-graticule: rgba(59, 110, 165, 0.09);
  --map-outline: #93bce0;
  --map-dot: rgba(40, 80, 120, 0.2);
  --map-stop-fill: #ffffff;
  --map-stop-stroke: #1d6fd8;
  --map-label: rgba(28, 48, 72, 0.76);
  --map-label-halo: rgba(255, 255, 255, 0.82);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 14px rgba(15, 23, 42, 0.06);
  --radius: 10px;
  color-scheme: light dark;
}

:root[data-theme='light'] {
  color-scheme: light;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0e141b;
  --surface: #17202b;
  --surface-2: #1f2a37;
  --border: #2c3a4a;
  --text: #e8edf2;
  --muted: #9aa8b7;
  --accent: #5aa2f5;
  --accent-contrast: #0b1520;
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --danger-halo: rgba(248, 113, 113, 0.3);
  --mode-star: #5aa2f5;
  --mode-other: #b79cff;
  --mode-surface: #a3adb8;
  --map-bg-inner: #2c4766;
  --map-bg-outer: #1e334d;
  --map-atmosphere: rgba(110, 185, 250, 0.38);
  --map-ocean-light: #2b4a6e;
  --map-ocean: #1e3958;
  --map-land: #384e68;
  --map-coast: #6082a8;
  --map-border: #48617e;
  --map-graticule: rgba(140, 185, 230, 0.1);
  --map-outline: #5a8ec2;
  --map-dot: rgba(190, 215, 240, 0.24);
  --map-stop-fill: #132030;
  --map-stop-stroke: #5aa2f5;
  --map-label: rgba(226, 236, 248, 0.8);
  --map-label-halo: rgba(15, 25, 38, 0.82);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, 'Hiragino Sans', 'Noto Sans JP', 'Segoe UI', sans-serif;
  display: flex;
  flex-direction: column;
}

[hidden] {
  display: none !important;
}

h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 7px;
  padding: 5px 10px;
  line-height: 1.3;
  white-space: nowrap;
}

button:hover {
  background: var(--surface-2);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

button.primary:hover {
  filter: brightness(1.08);
  background: var(--accent);
}

button.link {
  border: 0;
  background: none;
  padding: 2px 4px;
  color: var(--muted);
  font-size: 12px;
}

button.link:hover {
  color: var(--text);
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input[type='text'],
input[type='search'],
input[type='number'],
input[type='date'],
select {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 7px;
  padding: 6px 9px;
  min-width: 0;
}

/* ---- ヘッダー ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

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

.brand-name {
  margin: 0;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.badge {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.plan-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  flex-wrap: wrap;
}

.plan-tools select {
  max-width: 240px;
  flex: 0 1 240px;
}

.divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lang {
  font-weight: 600;
}

/* ---- レイアウト ---- */
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 8px minmax(340px, var(--side-width, 480px));
}

.map-pane {
  position: relative;
  min-height: 0;
  background: var(--map-bg-outer);
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  display: block;
}

.pane-resizer {
  position: relative;
  cursor: col-resize;
  background: var(--border);
  transition: background 0.15s ease;
  touch-action: none;
  user-select: none;
  z-index: 5;
}

.pane-resizer::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 36px;
  border-radius: 2px;
  background: var(--muted);
  opacity: 0.6;
}

.pane-resizer:hover,
.pane-resizer.dragging,
.pane-resizer:focus-visible {
  background: var(--accent);
}

.pane-resizer:hover::after,
.pane-resizer.dragging::after,
.pane-resizer:focus-visible::after {
  background: var(--accent-contrast);
  opacity: 1;
}

.side {
  overflow: hidden;
  padding: 10px 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.side-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  flex-shrink: 0;
}

.side-tabs button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 6px 4px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.side-tabs button:hover {
  color: var(--text);
}

.side-tabs button[aria-selected='true'] {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
}

.tab-badge {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  display: inline-block;
  flex-shrink: 0;
}

.tab-badge.ok {
  background: var(--ok);
}

.tab-badge.warn {
  background: var(--warn);
}

.tab-badge.fail {
  background: var(--danger);
}

.side-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 12px;
}

.tab-panel[hidden] {
  display: none !important;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.settings {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.settings .field.full {
  flex: 1 1 100%;
}

.settings .field.grow {
  flex: 1 1 140px;
  min-width: 130px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.field.grow {
  flex: 1;
}

.field > span {
  font-size: 11px;
  color: var(--muted);
}

.name-field {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 31px;
  padding: 2px 4px 2px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-alt);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.name-field.editing {
  background: var(--surface);
  border-color: var(--accent);
  outline: 1px solid var(--accent);
}

.name-display {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 0;
}

.name-display.untitled {
  color: var(--muted);
  font-weight: 500;
}

.name-field .name-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 2px 0;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
}

.name-edit-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.name-edit-btn:hover {
  background: var(--surface);
  color: var(--accent);
}

.name-field.editing .name-edit-btn {
  color: var(--accent);
}

/* ---- 地図の上の部品 ---- */
.map-controls {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.seg button {
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--border);
  padding: 5px 10px;
}

.seg button:last-child {
  border-right: 0;
}

.seg button[aria-pressed='true'] {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.btn-explore {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-explore .airline-logo-sm {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: #fff;
  object-fit: contain;
  flex-shrink: 0;
}

.btn-explore-clear {
  padding: 5px 8px !important;
  font-size: 11px;
  color: var(--muted);
}

.btn-explore-clear:hover {
  color: var(--danger);
}

/* ---- 航空会社別の就航都市パネル ---- */
.airline-panel {
  position: absolute;
  top: 48px;
  left: 10px;
  width: min(560px, calc(100% - 20px));
  height: min(460px, calc(100% - 96px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 4;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.airline-panel[hidden] {
  display: none !important;
}

.airline-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.airline-panel-head strong {
  font-size: 13px;
}

.airline-panel-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 2px 6px;
  font-size: 13px;
  cursor: pointer;
}

.airline-panel-close:hover {
  color: var(--text);
}

.airline-panel-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 225px minmax(0, 1fr);
}

.airline-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.airline-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.airline-item:hover {
  background: var(--surface-2);
}

.airline-item.active {
  background: var(--surface-2);
  border-color: var(--accent);
}

.airline-logo {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  object-fit: contain;
  padding: 2px;
  flex-shrink: 0;
}

.airline-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.airline-meta b {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.airline-meta small {
  font-size: 10.5px;
  color: var(--muted);
}

.airline-cities-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.airline-cities-head {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.airline-selected-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.airline-selected-banner .airline-logo {
  width: 30px;
  height: 30px;
}

.airline-selected-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.airline-selected-title b {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.airline-selected-title small {
  font-size: 11px;
  color: var(--muted);
}

.airline-cities-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.airline-cities-controls input {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  font-size: 12px;
}

.airline-scope-seg button {
  padding: 3px 7px;
  font-size: 11px;
}

.airline-city-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.airline-city-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.airline-city-row:hover {
  background: var(--surface-2);
}

.airline-city-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.airline-city-main b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.airline-city-main small {
  font-size: 10.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.airline-hub-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.16);
  color: #d97706;
  font-weight: 600;
}

.airline-city-add {
  padding: 2px 7px;
  font-size: 11px;
  border-radius: 5px;
}

.map-legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  gap: 12px;
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  box-shadow: var(--shadow);
}

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

.swatch {
  width: 18px;
  height: 0;
  border-top: 3px solid;
  display: inline-block;
}

.swatch.mode-star {
  border-color: var(--mode-star);
}

.swatch.mode-other {
  border-color: var(--mode-other);
}

.swatch.mode-surface {
  border-color: var(--mode-surface);
  border-top-style: dotted;
}

.swatch.unverified {
  border-color: var(--warn);
  border-top-style: dashed;
}

.map-tip,
.map-popup {
  position: absolute;
  transform: translate(-50%, calc(-100% - 12px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 5px 9px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 3;
}

.map-tip {
  pointer-events: none;
}

.map-popup {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px 7px 10px;
  z-index: 4;
}

.map-popup b {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}

/* ---- サマリー ---- */
.summary-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.summary-route {
  font-size: 12px;
  color: var(--muted);
}

.miles {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.miles small {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 4px;
}

.tier-pill {
  text-align: right;
  font-size: 11px;
  color: var(--muted);
}

.tier-pill b {
  display: block;
  font-size: 16px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.tier-pill.over b {
  color: var(--danger);
}

.gauge {
  position: relative;
  height: 10px;
  margin: 12px 0 20px;
  border-radius: 999px;
  background: var(--surface-2);
}

.gauge-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  background: var(--accent);
  max-width: 100%;
}

.gauge.over .gauge-fill {
  background: var(--danger);
}

.gauge-tick {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  margin-left: -1px;
  background: var(--muted);
  opacity: 0.55;
}

.gauge-tick span {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.gauge-tick.active {
  opacity: 1;
  background: var(--text);
}

.gauge-tick.active span {
  color: var(--text);
  font-weight: 700;
}

.gauge-tick:last-child span {
  transform: translateX(-100%);
}

.gauge-note {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

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

.stat {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 6px 9px;
}

.stat span {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.stat b {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.stat.bad b {
  color: var(--danger);
}

.verdict {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  margin: 2px 0 6px;
}

.verdict.ok {
  color: var(--ok);
}

.verdict.fail {
  color: var(--danger);
}

.checks,
.hints {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13px;
}

.checks li,
.hints li {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 4px;
  align-items: start;
}

.checks li.ok {
  color: var(--muted);
}

.checks li.ok .mark {
  color: var(--ok);
}

.checks li.fail {
  font-weight: 600;
}

.checks li.fail .mark {
  color: var(--danger);
}

.hints {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.hints li .mark {
  color: var(--accent);
}

.hints li.warn .mark {
  color: var(--warn);
}

.sub-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 5px;
}

.extra {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--muted);
}

.extra div {
  display: flex;
  align-items: center;
  gap: 6px;
}

.note {
  font-size: 11px;
  color: var(--muted);
  margin: 10px 0 0;
}

.empty {
  color: var(--muted);
  margin: 4px 0 10px;
}

/* ---- 検索 ---- */
.search {
  position: relative;
  margin-bottom: 10px;
}

.search input {
  width: 100%;
  padding: 8px 10px;
}

.search-results {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 320px;
  overflow-y: auto;
}

.search-results li {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.search-results li.active,
.search-results li:hover {
  background: var(--surface-2);
}

.search-results li.none {
  display: block;
  color: var(--muted);
  cursor: default;
  background: none;
}

.search-results small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ---- 旅程リスト ---- */
.stops {
  list-style: none;
  margin: 0;
  padding: 0;
}

.stop {
  display: grid;
  grid-template-columns: 14px 40px minmax(0, 1fr) auto;
  grid-template-areas:
    'grip code title tools'
    'grip code sub meta';
  align-items: center;
  column-gap: 6px;
  padding: 5px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.stop .grip {
  grid-area: grip;
}

.stop .code {
  grid-area: code;
}

.stop .title {
  grid-area: title;
  font-weight: 600;
}

.stop .sub {
  grid-area: sub;
  color: var(--muted);
  font-size: 11px;
}

.stop .title,
.stop .sub {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stop .meta {
  grid-area: meta;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
}

.stop .row-tools {
  grid-area: tools;
  justify-self: end;
}

.stop.origin {
  border-color: var(--mode-star);
}

.stop.drop-target {
  box-shadow: 0 -3px 0 var(--accent);
}

.stop.dragging {
  opacity: 0.45;
}

.grip {
  cursor: grab;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  user-select: none;
}

.kind {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
}

.kind.transfer {
  color: var(--muted);
  border-style: dashed;
}

.nights {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
}

.nights input {
  width: 44px;
  padding: 1px 4px;
  text-align: right;
  color: var(--text);
}

.row-tools {
  display: inline-flex;
  gap: 2px;
}

.row-tools button {
  border: 0;
  background: none;
  padding: 3px 5px;
  color: var(--muted);
  border-radius: 5px;
}

.row-tools button:hover {
  background: var(--surface-2);
  color: var(--text);
}

.row-tools button:disabled {
  opacity: 0.3;
  cursor: default;
}

.leg {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 4px 24px;
  position: relative;
  font-size: 12px;
  min-height: 34px;
}

.leg::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 0;
  bottom: 0;
  border-left: 3px solid var(--mode-star);
}

.leg.mode-other::before {
  border-color: var(--mode-other);
}

.leg.mode-surface::before {
  border-color: var(--mode-surface);
  border-left-style: dotted;
}

.leg.flagged::before {
  border-color: var(--danger);
}

.leg .seg {
  box-shadow: none;
}

.leg .seg button {
  padding: 2px 8px;
  font-size: 11px;
}

.leg .seg button[aria-pressed='true'][data-mode='other'] {
  background: var(--mode-other);
}

.leg .seg button[aria-pressed='true'][data-mode='surface'] {
  background: var(--mode-surface);
}

.leg-miles {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}

.tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.tag.flagged {
  background: var(--danger);
  color: #fff;
}

.tag.warn {
  background: none;
  border: 1px solid var(--warn);
  color: var(--warn);
  font-weight: 600;
}

.carrier {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px 1px 3px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.carrier:hover {
  border-color: var(--accent);
  background: var(--surface-alt);
}

.carrier-logo {
  width: 13px;
  height: 13px;
  border-radius: 2px;
  background: #ffffff;
  object-fit: contain;
  flex-shrink: 0;
}

.carrier-name {
  font-family: var(--font, -apple-system, BlinkMacSystemFont, 'Hiragino Sans', sans-serif);
  font-weight: 500;
  font-size: 10.5px;
  color: var(--muted);
}

.carrier.seasonal {
  border: 1px dashed var(--muted);
  background: none;
}

.leg {
  flex-wrap: wrap;
}

.leg.unverified::before {
  border-color: var(--warn);
  border-left-style: dashed;
}

.advice {
  flex-basis: 100%;
  font-size: 12px;
  color: var(--muted);
  padding-bottom: 4px;
}

.advice p {
  margin: 2px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.advice p span {
  flex: 1;
  min-width: 0;
}

.advice button {
  font-size: 11px;
  padding: 2px 8px;
}

.checks li.warn .mark,
.verdict.warn {
  color: var(--warn);
}

.checks li.warn {
  font-weight: 600;
}

.map-tip small,
.map-popup small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.map-tip small.has-direct,
.map-popup small.has-direct {
  color: var(--accent);
  font-weight: 600;
}

.map-controls .seg[hidden] {
  display: none;
}

/* ---- 価格 ---- */
.price-controls {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
}

.price-controls label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.price-controls input {
  width: 46px;
  padding: 2px 4px;
  color: var(--text);
}

.price-controls select {
  padding: 2px 4px;
  color: var(--text);
}

.price-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 7px 0;
  border-top: 1px solid var(--border);
}

.price-row b {
  font-weight: 600;
  margin-right: 6px;
}

.price-row small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.price-value {
  text-align: right;
}

.price-value .amount {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.money {
  display: inline-flex;
  gap: 4px;
}

.money input {
  width: 112px;
  padding: 4px 6px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.money select {
  padding: 4px 2px;
  font-size: 12px;
}

.price-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding-top: 9px;
  border-top: 2px solid var(--text);
}

.price-total b {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.price-total.sub {
  border-top: 0;
  padding-top: 2px;
  color: var(--muted);
}

.price-total.sub b {
  font-size: 14px;
  color: var(--text);
}

.price-notes {
  border-top: 0;
  padding-top: 0;
  font-size: 12px;
}

.leg-price {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: var(--muted);
}

.leg-price input {
  width: 78px;
  padding: 2px 5px;
  text-align: right;
  font-size: 12px;
  color: var(--text);
}

.fare-table {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
}

.fare-table summary {
  cursor: pointer;
  font-weight: 600;
}

.table-scroll {
  overflow-x: auto;
  margin: 6px 0;
}

.fare-table table {
  border-collapse: collapse;
  width: 100%;
}

.fare-table th,
.fare-table td {
  padding: 3px 3px;
  text-align: right;
  white-space: nowrap;
  font-weight: 500;
}

.fare-table thead th {
  color: var(--muted);
  font-size: 11px;
}

.fare-table tbody th {
  text-align: left;
  font-weight: 600;
}

.fare-table tr.origin th {
  color: var(--accent);
}

.fare-table td input {
  width: 66px;
  padding: 2px 4px;
  text-align: right;
  font-size: 12px;
}

.fare-table td input.current {
  border-color: var(--accent);
}

.fare-table td select {
  padding: 2px;
  font-size: 11px;
}

.fare-table .compare-row td {
  text-align: left;
  color: var(--muted);
  font-size: 11px;
  padding: 0 3px 6px;
  font-variant-numeric: tabular-nums;
}

.fare-table .compare-row b {
  color: var(--text);
}

.fare-table .cheaper {
  color: var(--ok);
}

.fare-table .dearer {
  color: var(--muted);
}

.add-country {
  display: flex;
  gap: 6px;
}

.add-country select {
  flex: 1;
  padding: 3px 6px;
}

/* ---- 日程タイムライン ---- */
.tl-summary {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tl-bar {
  display: flex;
  gap: 2px;
  height: 28px;
  border-radius: 7px;
  overflow: hidden;
  background: var(--surface-2);
  margin-bottom: 6px;
}

.tl-seg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  padding: 0 2px;
  color: #fff;
  font-size: 10px;
  line-height: 1.05;
  overflow: hidden;
  cursor: default;
  background: var(--muted);
}

.tl-seg span {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-weight: 700;
}

.tl-seg small {
  font-size: 9px;
  opacity: 0.9;
}

.tl-seg.zone-1,
.tl-dot.zone-1,
.tl-nights.zone-1 {
  background: #2563eb;
  color: #fff;
}

.tl-seg.zone-2,
.tl-dot.zone-2,
.tl-nights.zone-2 {
  background: #0d9488;
  color: #fff;
}

.tl-seg.zone-3,
.tl-dot.zone-3,
.tl-nights.zone-3 {
  background: #d97706;
  color: #fff;
}

.tl-seg.role-side,
.tl-seg.role-outside {
  opacity: 0.72;
}

.tl-legend {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
  flex-wrap: wrap;
}

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

.tl-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.tl-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 280px;
  overflow-y: auto;
  font-size: 12px;
}

.tl-row {
  display: grid;
  grid-template-columns: 112px 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 6px;
  background: var(--surface-2);
}

.tl-row.role-side,
.tl-row.role-outside {
  opacity: 0.8;
}

.tl-date {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tl-city {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.tl-nights {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

/* ---- プラン比較 ---- */
.compare-hint {
  margin: 0 0 8px;
}

.compare-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}

.compare-table th,
.compare-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}

.compare-table tbody th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  width: 96px;
}

.compare-table thead th {
  border-bottom: 2px solid var(--border);
  min-width: 132px;
}

.compare-table .active-col {
  background: var(--surface-2);
}

.cmp-col-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cmp-col-head b {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cmp-name-input {
  width: 100%;
  font-weight: 700;
  font-size: 12px;
  padding: 3px 6px;
}

.cmp-col-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.cmp-active-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
}

.cmp-switch {
  font-size: 11px;
  padding: 1px 7px;
}

.cmp-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
}

.cmp-pill.ok {
  background: rgba(21, 128, 61, 0.14);
  color: var(--ok);
}

.cmp-status.ok {
  color: var(--ok);
  font-weight: 600;
}

.cmp-status.warn {
  color: var(--warn);
  font-weight: 600;
}

.cmp-status.fail {
  color: var(--danger);
  font-weight: 600;
}

.compare-table td small {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.compare-table td small.cheaper {
  color: var(--ok);
  font-weight: 600;
}

.compare-table td small.dearer {
  color: var(--muted);
}

.cmp-stops {
  line-height: 1.35;
  word-break: break-word;
}

/* ---- SEO / AIO ガイドカード ---- */
.guide-card {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
}

.guide-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
}

.guide-head h2 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
}

.guide-updated {
  font-size: 10.5px;
  color: var(--muted);
}

.guide-bluf {
  margin: 0 0 8px;
  padding: 7px 9px;
  border-radius: 7px;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
}

.guide-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-bottom: 10px;
  font-size: 11px;
}

.guide-toc a {
  color: var(--accent);
  text-decoration: none;
}

.guide-toc a:hover {
  text-decoration: underline;
}

.guide-card h3 {
  margin: 12px 0 5px;
  font-size: 12.5px;
  font-weight: 700;
}

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

.guide-card ul,
.guide-card ol {
  margin: 0 0 8px;
  padding-left: 18px;
}

.guide-card li {
  margin-bottom: 3px;
}

.guide-table-wrap {
  overflow-x: auto;
  margin: 6px 0 8px;
}

.guide-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.guide-table th,
.guide-table td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.guide-table th {
  color: var(--muted);
  font-weight: 600;
  background: var(--surface-2);
}

.guide-faq {
  margin: 0 0 8px;
}

.guide-faq dt {
  font-weight: 700;
  margin-top: 6px;
}

.guide-faq dd {
  margin: 2px 0 0 10px;
  color: var(--muted);
}

.guide-sources a {
  color: var(--accent);
}

/* ---- フッター・トースト ---- */
.footer {
  font-size: 11px;
  color: var(--muted);
  padding: 0 4px 8px;
}

.footer p {
  margin: 0 0 4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 20;
  max-width: calc(100vw - 32px);
}

/* ---- スマホ ---- */
@media (max-width: 860px) {
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
  }

  .layout {
    display: flex;
    flex-direction: column;
  }

  .topbar {
    padding: max(6px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
    gap: 6px 8px;
  }

  .brand {
    flex: 1 1 auto;
    min-width: 0;
    gap: 6px;
  }

  .brand-name {
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .badge {
    font-size: 10px;
    padding: 1px 5px;
    flex-shrink: 0;
  }

  .topbar-actions {
    margin-left: auto;
    flex-shrink: 0;
  }

  .theme-toggle,
  .lang {
    font-size: 11.5px;
    padding: 4px 7px;
  }

  .plan-tools {
    order: 3;
    flex-basis: 100%;
    gap: 4px;
  }

  .plan-tools button {
    font-size: 11.5px;
    padding: 4px 8px;
  }

  .map-pane {
    position: relative;
    height: 44vh;
    min-height: 260px;
    max-height: 360px;
    border-bottom: 1px solid var(--border);
  }

  .map-controls {
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 5px;
  }

  .map-controls button {
    font-size: 11px;
    padding: 4px 7px;
  }

  .map-legend {
    left: 8px;
    bottom: 8px;
    font-size: 10px;
    padding: 3px 7px;
    gap: 7px;
  }

  .airline-panel {
    left: 8px;
    right: 8px;
    top: 44px;
    width: auto;
    max-height: calc(100% - 54px);
  }

  .side {
    border-left: 0;
    overflow: visible;
    padding: 10px max(10px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .side-tabs {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .side-tabs::-webkit-scrollbar {
    display: none;
  }

  .side-tabs button {
    flex: 1 0 auto;
    padding: 6px 8px;
    font-size: 11.5px;
  }

  .side-body {
    overflow: visible;
  }

  .pane-resizer {
    display: none;
  }

  .divider {
    display: none;
  }

  .plan-tools select {
    flex: 1 1 100%;
    max-width: none;
    font-size: 12px;
    padding: 4px 8px;
  }
}

/* ---- 印刷・PDF保存（A4縦1枚レイアウト） ---- */
.print-sheet {
  display: none;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 8mm 10mm;
  }

  html,
  body {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    background: #ffffff !important;
    color: #0f172a !important;
    font-size: 8.5pt;
    line-height: 1.3;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .topbar,
  .layout,
  .toast {
    display: none !important;
  }

  .print-sheet {
    display: flex !important;
    flex-direction: column;
    gap: 6px;
    width: 100%;
  }

  .print-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1.5px solid #1e3a8a;
    padding-bottom: 4px;
  }

  .print-head h1 {
    margin: 0;
    font-size: 13pt;
    font-weight: 700;
    color: #0f172a;
  }

  .print-head-meta {
    font-size: 8.5pt;
    color: #475569;
  }

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

  .print-kpi {
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    padding: 3px 6px;
    background: #f8fafc;
  }

  .print-kpi span {
    display: block;
    font-size: 7pt;
    color: #64748b;
  }

  .print-kpi strong {
    font-size: 9.5pt;
    color: #0f172a;
  }

  .print-map-box {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    overflow: hidden;
    background: #d9e8f6;
  }

  .print-map-box canvas,
  .print-map-box img {
    display: block;
    width: 100%;
    height: 54mm;
    object-fit: contain;
  }

  .print-summary-grid {
    display: grid;
    grid-template-columns: 1fr 1.25fr;
    gap: 7px;
    align-items: stretch;
  }

  .print-card {
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    padding: 5px 7px;
    background: #ffffff;
    break-inside: avoid;
  }

  .print-itinerary-card {
    break-inside: auto;
  }

  .print-itinerary-card thead {
    display: table-header-group;
  }

  .print-itinerary-card tr {
    break-inside: avoid;
  }

  .print-card h2 {
    margin: 0 0 4px;
    font-size: 9pt;
    font-weight: 700;
    color: #1e3a8a;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 2px;
  }

  .print-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 7.8pt;
  }

  .print-table th,
  .print-table td {
    padding: 2px 4px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    vertical-align: middle;
  }

  .print-table th {
    font-weight: 600;
    color: #475569;
    background: #f8fafc;
  }

  .print-table td.num,
  .print-table th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
  }

  .print-table td.nowrap,
  .print-table th.nowrap {
    white-space: nowrap;
  }

  .print-compare-table tr.is-printing td {
    background: #eff6ff !important;
    border-top: 1.5px solid #2563eb;
    border-bottom: 1.5px solid #2563eb;
    color: #0f172a;
  }

  .print-compare-table tr.is-printing td:first-child {
    box-shadow: inset 3px 0 0 #2563eb;
    padding-left: 7px;
  }

  .print-active-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 0 5px;
    border-radius: 999px;
    background: #1d4ed8;
    color: #ffffff;
    font-size: 6.8pt;
    font-weight: 700;
    line-height: 1.45;
    vertical-align: middle;
  }

  .print-checks {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 7.8pt;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .print-right-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .print-foot {
    font-size: 7pt;
    color: #64748b;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-top: 1px solid #e2e8f0;
    padding-top: 4px;
  }
}
