:root {
  --ink: #10221d;
  --ink-2: #24423a;
  --paper: #f7f1e4;
  --paper-2: #efe1c6;
  --card: rgba(255, 250, 239, 0.92);
  --line: rgba(43, 64, 54, 0.18);
  --ring: #d9653b;
  --gold: #c89f57;
  --sage: #7f977f;
  --night: #13261f;
  --danger: #9e3e2e;
  --shadow: 0 24px 70px rgba(22, 37, 31, 0.18);
  --radius-lg: 32px;
  --radius-md: 22px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Zen Kaku Gothic New", "Yu Gothic", Meiryo, sans-serif;
  background:
    radial-gradient(circle at 16% 8%, rgba(217, 101, 59, 0.28), transparent 28rem),
    radial-gradient(circle at 86% 12%, rgba(127, 151, 127, 0.34), transparent 34rem),
    linear-gradient(135deg, #f7f1e4 0%, #ead8ba 48%, #d9c7a7 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    linear-gradient(30deg, rgba(16, 34, 29, 0.05) 12%, transparent 12.5%, transparent 87%, rgba(16, 34, 29, 0.05) 87.5%, rgba(16, 34, 29, 0.05)),
    linear-gradient(150deg, rgba(16, 34, 29, 0.05) 12%, transparent 12.5%, transparent 87%, rgba(16, 34, 29, 0.05) 87.5%, rgba(16, 34, 29, 0.05));
  background-size: 42px 72px;
}

a { color: inherit; }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  background: var(--night);
  color: #fff;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 1rem; }

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: clamp(18px, 5vw, 48px);
  align-items: end;
  padding: clamp(28px, 7vw, 72px) 0 20px;
}

.brand-mark {
  width: clamp(86px, 20vw, 164px);
  aspect-ratio: 1;
  border: 2px solid rgba(16, 34, 29, 0.22);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--paper);
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.22), transparent 30%),
    conic-gradient(from 210deg, var(--ring), #e8ad61, var(--sage), var(--night), var(--ring));
  box-shadow: var(--shadow);
  font-family: "Kaisei Tokumin", serif;
  font-size: clamp(42px, 9vw, 88px);
  font-weight: 700;
  transform: rotate(-7deg);
}

.eyebrow, .mini-label {
  margin: 0 0 0.5rem;
  color: var(--ring);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

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

h1 {
  margin-bottom: 0.8rem;
  font-family: "Kaisei Tokumin", serif;
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.05em;
  font-size: clamp(2.45rem, 9vw, 6.4rem);
}

h1 span {
  text-decoration: underline;
  text-decoration-thickness: 0.12em;
  text-decoration-color: rgba(217, 101, 59, 0.58);
  text-underline-offset: 0.1em;
}

.lead {
  max-width: 690px;
  font-size: clamp(1rem, 2.4vw, 1.18rem);
  line-height: 1.75;
  color: var(--ink-2);
}

.search-panel,
.map-card,
.results-card {
  border: 1px solid rgba(16, 34, 29, 0.14);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.search-panel {
  border-radius: var(--radius-lg);
  padding: clamp(16px, 3vw, 26px);
  margin-bottom: 18px;
}

#searchForm {
  display: grid;
  grid-template-columns: minmax(260px, 1.35fr) minmax(320px, 1fr) minmax(130px, 0.28fr) minmax(150px, 0.35fr);
  gap: 14px;
  align-items: end;
}

.field > span,
.duration-box legend,
.custom-duration span,
.sorter span {
  display: block;
  margin-bottom: 0.5rem;
  color: rgba(16, 34, 29, 0.72);
  font-size: 0.84rem;
  font-weight: 900;
}

.input-with-action,
.unit-input,
.custom-duration,
.sorter {
  display: flex;
  align-items: center;
  gap: 8px;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(16, 34, 29, 0.16);
  border-radius: 18px;
  padding: 0.92rem 1rem;
  color: var(--ink);
  background: rgba(255, 252, 245, 0.92);
  outline: none;
  transition: border 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

input:focus,
select:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 4px rgba(217, 101, 59, 0.12);
}

.search-button,
.nav-button {
  border: 0;
  border-radius: 18px;
  padding: 0.96rem 1.25rem;
  color: #fff7ea;
  background: var(--night);
  box-shadow: 0 12px 26px rgba(16, 34, 29, 0.24);
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.search-button:hover,
.nav-button:hover { transform: translateY(-1px); box-shadow: 0 16px 32px rgba(16, 34, 29, 0.28); }
.search-button:active,
.nav-button:active { transform: translateY(1px); }

.duration-box {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.duration-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 8px;
}

.duration-chips input { position: absolute; opacity: 0; pointer-events: none; }
.duration-chips span {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0.46rem 0.78rem;
  border-radius: 999px;
  border: 1px solid rgba(16, 34, 29, 0.16);
  background: rgba(255,255,255,0.44);
  font-weight: 800;
  cursor: pointer;
}
.duration-chips input:checked + span {
  color: #fff7ea;
  border-color: var(--night);
  background: var(--night);
}

.custom-duration input { max-width: 110px; padding: 0.7rem 0.8rem; border-radius: 14px; }
.custom-duration b,
.unit-input b { color: rgba(16, 34, 29, 0.62); }
.unit-input input { padding-right: 0.65rem; }

.status {
  min-height: 1.5rem;
  margin-top: 14px;
  color: var(--ink-2);
  font-weight: 700;
}
.status.error { color: var(--danger); }

.candidate-panel {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.candidate-panel button {
  border: 1px solid rgba(16, 34, 29, 0.16);
  border-radius: 999px;
  background: rgba(255, 252, 245, 0.9);
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  font-weight: 800;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  gap: 18px;
  align-items: start;
}

.map-card {
  position: sticky;
  top: 14px;
  overflow: hidden;
  border-radius: var(--radius-lg);
}

#map {
  width: 100%;
  height: min(72vh, 660px);
  min-height: 420px;
  background: #d8dfd5;
}

.map-credit {
  position: absolute;
  left: 14px;
  bottom: 12px;
  z-index: 2;
  border-radius: 999px;
  padding: 0.34rem 0.68rem;
  background: rgba(255, 250, 239, 0.88);
  color: rgba(16, 34, 29, 0.72);
  font-size: 0.76rem;
  font-weight: 800;
}

.map-actions {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 4;
  display: grid;
  gap: 8px;
  justify-items: end;
}

.locate-button,
.search-here-button {
  border: 1px solid rgba(16, 34, 29, 0.13);
  border-radius: 999px;
  background: rgba(255, 252, 245, 0.96);
  color: var(--ink);
  box-shadow: 0 12px 28px rgba(16, 34, 29, 0.22);
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.locate-button:hover,
.search-here-button:hover { transform: translateY(-1px); box-shadow: 0 16px 34px rgba(16, 34, 29, 0.26); }
.locate-button:active,
.search-here-button:active { transform: translateY(1px); }

.locate-button {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  padding: 0;
}

.locate-button .locate-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.locate-icon {
  position: relative;
  width: 24px;
  height: 24px;
  border: 2px solid currentColor;
  border-radius: 50%;
}
.locate-icon::before,
.locate-icon::after {
  content: "";
  position: absolute;
  background: currentColor;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.locate-icon::before { width: 2px; height: 34px; }
.locate-icon::after { width: 34px; height: 2px; }

.locate-button.is-locating { color: #2166d9; border-color: rgba(33, 102, 217, 0.28); }
.locate-button.is-following { color: #fff; background: #1a73e8; border-color: #1a73e8; }
.locate-button.is-following .locate-icon::before,
.locate-button.is-following .locate-icon::after { background: #fff; }

.search-here-button {
  min-height: 42px;
  padding: 0.68rem 0.9rem;
  background: rgba(16, 34, 29, 0.94);
  color: #fff7ea;
}
.search-here-button:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  transform: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 1000;
  width: min(92vw, 430px);
  transform: translateX(-50%);
  border-radius: 999px;
  padding: 0.82rem 1rem;
  color: #fff7ea;
  background: rgba(16, 34, 29, 0.95);
  box-shadow: 0 18px 46px rgba(16, 34, 29, 0.28);
  font-weight: 900;
  text-align: center;
}

.maplibregl-marker.rin-location-marker { z-index: 3; }
.rin-location-dot {
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #1a73e8;
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.35), 0 8px 18px rgba(0, 0, 0, 0.25);
}

.results-card {
  border-radius: var(--radius-lg);
  padding: clamp(14px, 2.4vw, 22px);
  min-height: 420px;
}

.results-head {
  display: flex;
  gap: 12px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 12px;
}

.result-controls {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.results-head h2 {
  margin-bottom: 0;
  font-family: "Kaisei Tokumin", serif;
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  letter-spacing: -0.04em;
}

.sorter { gap: 6px; align-items: flex-start; flex-direction: column; min-width: 122px; }
.sorter select { padding: 0.64rem 0.8rem; border-radius: 14px; }

.summary-strip {
  margin-bottom: 12px;
  border-radius: 18px;
  padding: 0.8rem 1rem;
  background: linear-gradient(135deg, rgba(217,101,59,0.14), rgba(127,151,127,0.14));
  color: var(--ink-2);
  font-weight: 800;
  line-height: 1.55;
}

.plan-b-panel {
  margin-bottom: 12px;
  border: 1px solid rgba(16, 34, 29, 0.13);
  border-radius: 20px;
  padding: 12px;
  background: rgba(16, 34, 29, 0.055);
}
.plan-b-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}
.plan-b-head strong { display: block; color: var(--ink); line-height: 1.45; }
.plan-b-source {
  max-width: 220px;
  color: rgba(16, 34, 29, 0.58);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.35;
  text-align: right;
}
.plan-b-list {
  display: grid;
  gap: 7px;
  padding: 0;
  margin: 0;
  list-style: none;
}
.plan-b-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 6px 8px;
  align-items: center;
  border-radius: 15px;
  padding: 0.56rem 0.64rem;
  background: rgba(255, 252, 245, 0.78);
}
.plan-b-item.primary { outline: 2px solid rgba(217, 101, 59, 0.2); }
.plan-b-rank {
  border-radius: 999px;
  padding: 0.18rem 0.45rem;
  background: var(--night);
  color: #fff7ea;
  font-size: 0.72rem;
  font-weight: 900;
}
.plan-b-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 900; }
.plan-b-metrics { grid-column: 2; color: rgba(16, 34, 29, 0.66); font-size: 0.8rem; font-weight: 800; }
.plan-b-signal {
  grid-column: 3;
  grid-row: 1 / span 2;
  justify-self: end;
  border-radius: 999px;
  padding: 0.24rem 0.52rem;
  background: rgba(16, 34, 29, 0.07);
  color: rgba(16, 34, 29, 0.68);
  font-size: 0.76rem;
  font-weight: 900;
}
.plan-b-signal.available, .badge.vacancy.available { background: rgba(46, 125, 50, 0.16); color: #246b31; }
.plan-b-signal.crowded, .badge.vacancy.crowded { background: rgba(200, 159, 87, 0.26); color: #7b5921; }
.plan-b-signal.full, .badge.vacancy.full { background: rgba(158, 62, 46, 0.16); color: var(--danger); }
.plan-b-signal.parked, .badge.vacancy.parked { background: rgba(26, 115, 232, 0.14); color: #1b5fb8; }
.plan-b-signal.left, .badge.vacancy.left { background: rgba(16, 34, 29, 0.08); color: rgba(16, 34, 29, 0.68); }
.plan-b-next {
  width: 100%;
  margin-top: 9px;
  border: 0;
  border-radius: 999px;
  padding: 0.68rem 0.8rem;
  color: #fff7ea;
  background: var(--ring);
  font-weight: 900;
  cursor: pointer;
}

.parking-list {
  display: grid;
  gap: 10px;
}

.parking-card {
  position: relative;
  border: 1px solid rgba(16, 34, 29, 0.12);
  border-radius: var(--radius-md);
  padding: 14px;
  background: rgba(255, 252, 245, 0.82);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.parking-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--sage);
  opacity: 0.55;
}
.parking-card:hover,
.parking-card.selected {
  transform: translateY(-1px);
  border-color: rgba(217, 101, 59, 0.54);
  box-shadow: 0 14px 32px rgba(16,34,29,0.14);
}
.parking-card.selected::before { background: var(--ring); opacity: 1; }

.card-top {
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: space-between;
}
.metric {
  font-size: clamp(1.12rem, 3vw, 1.42rem);
  font-weight: 900;
  letter-spacing: -0.03em;
}
.metric strong { color: var(--ring); }
.duration-note { color: rgba(16,34,29,0.62); font-size: 0.84rem; font-weight: 800; }
.rank {
  min-width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--night);
  color: #fff7ea;
  font-weight: 900;
}
.card-name {
  margin: 0.35rem 0 0.6rem;
  font-size: 1.02rem;
  font-weight: 900;
}
.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 0.62rem;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  background: rgba(16, 34, 29, 0.07);
  color: rgba(16, 34, 29, 0.76);
  font-size: 0.78rem;
  font-weight: 800;
}
.badge.sample { background: rgba(217, 101, 59, 0.13); color: #833d29; }
.badge.unverified { background: rgba(158, 62, 46, 0.12); color: #8a3a2c; }
.badge.confirmed { background: rgba(46, 125, 50, 0.12); color: #246b31; }
.badge.cap { background: rgba(127, 151, 127, 0.22); color: #2d5748; }
.badge.height-unknown { background: rgba(200, 159, 87, 0.22); }
.badge.source { background: rgba(16, 34, 29, 0.06); color: rgba(16, 34, 29, 0.62); }
.parking-card.fee-unknown .metric strong { color: #8a3a2c; font-weight: 700; }
.badge.vacancy.unknown { background: rgba(16, 34, 29, 0.07); color: rgba(16, 34, 29, 0.62); }
.reason {
  margin: 0 0 0.8rem;
  color: var(--ink-2);
  font-weight: 800;
  line-height: 1.45;
}
.nav-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}
.address {
  color: rgba(16, 34, 29, 0.55);
  font-size: 0.78rem;
  line-height: 1.4;
}
.nav-button {
  display: inline-flex;
  text-decoration: none;
  padding: 0.7rem 0.9rem;
  border-radius: 999px;
  font-size: 0.86rem;
}

.observation-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(16, 34, 29, 0.14);
}
.observation-row span {
  color: rgba(16, 34, 29, 0.58);
  font-size: 0.78rem;
  font-weight: 900;
}
.observe-button {
  border: 1px solid rgba(16, 34, 29, 0.13);
  border-radius: 999px;
  padding: 0.36rem 0.58rem;
  background: rgba(255, 252, 245, 0.92);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
}
.observe-button:hover { border-color: rgba(217, 101, 59, 0.5); color: var(--ring); }

.empty-state {
  border: 1px dashed rgba(16, 34, 29, 0.24);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  color: var(--ink-2);
  line-height: 1.7;
}

.footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  justify-content: center;
  padding: 28px 0 40px;
  color: rgba(16, 34, 29, 0.66);
  font-size: 0.86rem;
  font-weight: 700;
}

.maplibregl-popup-content {
  border-radius: 14px;
  padding: 10px 12px;
  font-family: "Zen Kaku Gothic New", "Yu Gothic", Meiryo, sans-serif;
  color: var(--ink);
}

@media (max-width: 920px) {
  .hero { grid-template-columns: 1fr; align-items: start; }
  .brand-mark { width: 94px; }
  #searchForm { grid-template-columns: 1fr; }
  .workspace { grid-template-columns: 1fr; }
  .map-card { position: relative; top: 0; }
  #map { height: 46vh; min-height: 330px; }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 18px, 1180px); }
  .hero { padding-top: 24px; }
  .lead { font-size: 0.98rem; }
  .input-with-action { align-items: stretch; flex-direction: column; }
  .search-button { width: 100%; }
  .duration-chips { display: grid; grid-template-columns: repeat(3, 1fr); }
  .duration-chips span { justify-content: center; padding-inline: 0.5rem; }
  .results-head { align-items: stretch; flex-direction: column; }
  .result-controls { justify-content: stretch; }
  .sorter { width: 100%; }
  .card-top { align-items: flex-start; }
  .nav-row { align-items: stretch; flex-direction: column; }
  .nav-button { justify-content: center; }
  .plan-b-head { flex-direction: column; }
  .plan-b-source { max-width: none; text-align: left; }
  .plan-b-item { grid-template-columns: auto minmax(0, 1fr); }
  .plan-b-signal { grid-column: 1 / -1; grid-row: auto; justify-self: start; }
  .map-actions { right: 10px; bottom: 56px; }
  .map-credit { max-width: calc(100% - 20px); font-size: 0.68rem; }
}
