:root {
  --ink: #111111;
  --paper: #ffffff;
  --line: #e4e4e4;
  --mute: #6b6b6b;
  --soft: #f3f3f3;
  --taxi: #ffd400;
  --danger: #c62828;
  --ok: #1c8a4b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: #1b1b1b;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  position: relative;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
}

/* 上部バー */
.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: calc(12px + env(safe-area-inset-top)) 12px 0;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .04em;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--taxi);
  color: var(--ink);
  font-weight: 800;
}
.topbar-nav { display: flex; gap: 6px; }
.nav-btn {
  padding: 8px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
  font-size: 13px;
  font-weight: 600;
}

/* 地図 */
.map {
  position: sticky;
  top: 0;
  height: 42vh;
  min-height: 250px;
  max-height: 420px;
  overflow: hidden;
  background: #e6e9e1;
}
.map { z-index: 0; isolation: isolate; }
.leaflet-container { background: #e6e9e1; font: inherit; }
.map .leaflet-bottom { margin-bottom: 26px; }
.leaflet-control-attribution { font-size: 10px; }
.pin { position: relative; display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; }
.pin--pickup { background: var(--taxi); border: 3px solid var(--ink); }
.pin--pickup::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink); }
.pin--home { background: var(--ink); box-shadow: 0 0 0 2px #fff; }
.pin--car { border-radius: 0; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .4)); }
.pin-ripple {
  position: absolute;
  inset: -3px;
  display: none;
  border: 2px solid var(--ink);
  border-radius: 50%;
  animation: ripple 2s ease-out infinite;
}
.pin-ripple--late { animation-delay: 1s; }
.map[data-mode="search"] .pin-ripple { display: block; }
@keyframes ripple {
  from { transform: scale(1); opacity: .8; }
  to { transform: scale(5); opacity: 0; }
}
.leaflet-tooltip.pin-label {
  padding: 2px 9px;
  border: 0;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}
.leaflet-tooltip.pin-label::before { display: none; }
.home-map { height: 240px; margin-top: 8px; border: 1.5px solid var(--line); border-radius: 14px; overflow: hidden; z-index: 0; isolation: isolate; }

/* 下のシート */
.sheet {
  position: relative;
  z-index: 2;
  margin-top: -24px;
  min-height: calc(58vh + 24px);
  padding: 22px 16px calc(28px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--paper);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, .12);
}
.app.is-full .map { display: none; }
.app.is-full .sheet {
  margin-top: 0;
  min-height: 100vh;
  padding-top: calc(70px + env(safe-area-inset-top));
  border-radius: 0;
  box-shadow: none;
}

h1 { margin: 0 0 14px; font-size: 22px; line-height: 1.35; }
h2 { margin: 22px 0 8px; font-size: 13px; color: var(--mute); font-weight: 700; letter-spacing: .06em; }
p { margin: 0 0 12px; line-height: 1.7; }
.muted { color: var(--mute); font-size: 13px; }
.center { text-align: center; }

/* 乗車地・目的地 */
.route-box { border-radius: 14px; background: var(--soft); }
.route-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 0 14px;
}
.route-row + .route-row { border-top: 1px solid var(--line); }
.route-row input {
  flex: 1;
  min-width: 0;
  padding: 12px 0;
  border: 0;
  background: none;
  font-size: 16px;
  font-weight: 600;
  outline: none;
}
.route-row .grow { flex: 1; font-weight: 600; }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--taxi); border: 2px solid var(--ink); }
.dot--home { border-radius: 2px; background: var(--ink); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  padding: 9px 14px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-size: 14px;
  font-weight: 600;
}
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); }

/* 車種 */
.cars { display: grid; gap: 8px; }
.car {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  text-align: left;
}
.car[aria-pressed="true"] { border-color: var(--ink); background: var(--soft); }
.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--soft);
  font-size: 26px;
}
.car[aria-pressed="true"] .avatar { background: var(--taxi); }
.car-main { flex: 1; min-width: 0; }
.car-name { display: block; font-weight: 700; font-size: 16px; }
.car-sub { display: block; margin-top: 2px; color: var(--mute); font-size: 12px; }
.car-eta { flex: none; font-weight: 700; font-size: 14px; }

.field {
  width: 100%;
  margin-top: 10px;
  padding: 13px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  font-size: 16px;
}
.field:focus { border-color: var(--ink); outline: none; }
textarea.field { min-height: 110px; resize: vertical; line-height: 1.6; }
.label { display: block; margin-top: 14px; font-size: 13px; font-weight: 700; }

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--soft);
  font-size: 14px;
  font-weight: 600;
}
.toggle input { width: 20px; height: 20px; accent-color: var(--ink); }

/* ボタン */
.btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 16px;
  border: 0;
  border-radius: 14px;
  background: var(--soft);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}
.btn--primary { margin-top: 20px; background: var(--ink); color: var(--paper); }
.btn--line { background: #06c755; color: #fff; }
.btn--locate { padding: 12px; font-size: 14px; }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.estimate { margin: 10px 2px 0; color: var(--mute); font-size: 13px; font-weight: 600; line-height: 1.6; }
.btn--ghost { background: none; color: var(--mute); font-size: 14px; padding: 12px; }
.btn--danger { background: none; color: var(--danger); font-size: 14px; padding: 12px; }
.btn:disabled { opacity: .5; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* カード類 */
.card { padding: 14px; border: 1.5px solid var(--line); border-radius: 14px; }
.card + .card { margin-top: 10px; }
.driver { display: flex; align-items: center; gap: 12px; }
.driver .avatar { width: 54px; height: 54px; font-size: 30px; background: var(--taxi); }
.driver-name { font-weight: 700; font-size: 17px; }
.plate {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}
.quote { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--mute); font-size: 13px; }

.eta { display: flex; align-items: baseline; gap: 6px; margin-bottom: 4px; }
.eta-num { font-size: 56px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.eta-unit { font-size: 18px; font-weight: 700; }
.eta-clock { margin-left: auto; text-align: right; color: var(--mute); font-size: 13px; }
.eta-clock b { display: block; color: var(--ink); font-size: 20px; font-variant-numeric: tabular-nums; }
.status { margin-bottom: 14px; font-weight: 700; }

.rows { margin: 0; }
.rows div { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.rows div:last-child { border-bottom: 0; }
.rows dt { flex: none; width: 6.5em; color: var(--mute); font-size: 13px; }
.rows dd { margin: 0; flex: 1; font-weight: 600; overflow-wrap: anywhere; }

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--taxi);
  font-size: 12px;
  font-weight: 700;
}

.dots { display: flex; gap: 6px; margin: 4px 0 16px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

.stars { display: flex; justify-content: center; gap: 4px; margin: 10px 0 4px; }
.star { padding: 4px; border: 0; background: none; font-size: 40px; line-height: 1; color: #d5d5d5; }
.star[aria-pressed="true"] { color: var(--taxi); -webkit-text-stroke: 1px var(--ink); }

.receipt {
  padding: 18px 16px;
  border: 1.5px dashed var(--ink);
  border-radius: 4px;
  background: #fffdf2;
}
.receipt h1 { text-align: center; letter-spacing: .5em; margin-bottom: 4px; }
.receipt-total { margin: 12px 0 0; padding-top: 12px; border-top: 2px solid var(--ink); font-size: 20px; font-weight: 800; text-align: right; }

.driver-edit { position: relative; }
.driver-edit .field { margin-top: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 10;
  max-width: 90vw;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  font-weight: 600;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .pin-ripple, .dots i { animation: none; }
  .toast { transition: none; }
}
