/* ---------- design tokens ---------- */
:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-alt: #f3efe9;
  --ink: #1c1b18;
  --ink-soft: #5e5b54;
  --ink-mute: #8a857c;
  --line: #e7e1d6;
  --line-strong: #d3cbbb;
  --accent: #b8533a;        /* sealing wax red — torii vermillion */
  --accent-soft: #f5e5e0;
  --accent-ink: #842f1e;
  --shadow-sm: 0 1px 2px rgba(28, 27, 24, .06);
  --shadow-md: 0 8px 24px rgba(28, 27, 24, .08);
  --radius: 8px;
  --radius-lg: 14px;
  --header-h: 64px;
  --tabbar-h: 62px;

  --font-jp: 'Hiragino Kaku Gothic ProN', 'Yu Gothic UI', 'Noto Sans JP',
             'Helvetica Neue', Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-jp);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  color: var(--accent-ink);
  text-decoration: underline;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

/* ---------- layout shell ---------- */
.app {
  display: grid;
  grid-template-rows: var(--header-h) auto 1fr;
  min-height: 100dvh;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: var(--header-h);
}

.site-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.brand-text {
  display: inline-flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.site-title,
.brand-short {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-short { display: none; } /* hidden on desktop, shown on mobile */

.site-sub {
  font-size: 12px;
  color: var(--ink-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.back-link {
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
}

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

.lang-switch {
  display: inline-flex;
  background: var(--surface-alt);
  border-radius: 999px;
  padding: 3px;
}

.lang-btn {
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
  transition: all .15s;
}

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

.lang-btn.is-active {
  background: var(--surface);
  color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
}

/* ---- compact language menu (mobile) ---- */
.lang-menu {
  position: relative;
  display: none;
}

.lang-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px 7px 11px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1;
  border: 0;
  box-shadow: 0 2px 8px rgba(184, 83, 58, .35);
  -webkit-tap-highlight-color: transparent;
  transition: background .15s, box-shadow .15s;
}
.lang-trigger:active { background: var(--accent-ink); box-shadow: 0 1px 3px rgba(184, 83, 58, .4); }
.lang-trigger .lang-globe { width: 14px; height: 14px; fill: currentColor; }
.lang-trigger .lang-caret { width: 12px; height: 12px; fill: currentColor; transition: transform .15s; }
.lang-trigger[aria-expanded="true"] .lang-caret { transform: rotate(180deg); }

.lang-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 150px;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 12px 28px rgba(28, 27, 24, .14);
  padding: 6px;
  z-index: 70;
}
.lang-popover[hidden] { display: none; }

.lang-option {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
}
.lang-option:active { background: var(--surface-alt); }
.lang-option.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
}
.lang-option .check {
  color: var(--accent);
  font-weight: 900;
  font-size: 14px;
}

.mobile-menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  align-items: center;
  justify-content: center;
}

.mobile-menu-toggle::before {
  content: '';
  width: 16px;
  height: 2px;
  background: var(--ink);
  box-shadow: 0 -5px 0 var(--ink), 0 5px 0 var(--ink);
}

/* ---------- source notice banner ---------- */
.source-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  background: #fff8d6;
  border-bottom: 1px solid #ecdf95;
  color: #6b5300;
  font-size: 12.5px;
  line-height: 1.5;
  font-weight: 500;
}

.source-icon {
  width: 16px;
  height: 16px;
  fill: #b88a00;
  flex: none;
}

@media (max-width: 480px) {
  .source-notice {
    padding: 8px 14px;
    font-size: 11.5px;
  }
}

/* ---------- main split ---------- */
.main {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 0;
}

/* ---------- sidebar / menu ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 18px 4px 32px;
  position: sticky;
  top: var(--header-h);
  height: calc(100dvh - var(--header-h));
}

.menu-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--ink-mute);
  font-weight: 700;
  padding: 0 20px 10px;
  margin: 0;
}

.cat {
  margin: 8px 12px 4px;
}

.cat-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  transition: background .15s;
}

.cat-head:hover {
  background: var(--surface-alt);
}

.cat-icon {
  width: 18px;
  height: 18px;
  fill: var(--accent);
  flex: none;
}

.cat-name {
  flex: 1;
  text-align: left;
}

.cat-toggle {
  color: var(--ink-mute);
  font-size: 12px;
  transition: transform .2s;
}

.cat.is-collapsed .cat-toggle {
  transform: rotate(-90deg);
}

.cat-list {
  list-style: none;
  margin: 4px 0 4px;
  padding: 0;
  max-height: 1000px;
  overflow: hidden;
  transition: max-height .25s ease;
}

.cat.is-collapsed .cat-list {
  max-height: 0;
}

.item {
  width: 100%;
  text-align: left;
  padding: 9px 14px 9px 40px;
  border-radius: var(--radius);
  display: block;
  position: relative;
  transition: background .12s;
}

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

.item.is-active {
  background: var(--accent-soft);
}

.item.is-active::before {
  content: '';
  position: absolute;
  left: 22px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateY(-50%);
}

.item-name {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
}

.item-desc {
  display: block;
  font-size: 11.5px;
  color: var(--ink-mute);
  margin-top: 2px;
  line-height: 1.4;
}

/* ---------- map panel ---------- */
.map-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

.map-head {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.route-row {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.origin-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid rgba(184, 83, 58, .22);
}

.origin-pin {
  width: 16px;
  height: 16px;
  fill: var(--accent);
  flex: none;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .08));
}

.origin-text {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1.2;
}

.origin-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .75;
}

.origin-brand {
  font-size: 13px;
  font-weight: 700;
}

.mode-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.mode-chip::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .6;
}

.mode-chip[data-mode="walk"]    { color: #2d7a4e; background: #e6f3ec; border-color: #c1e1ce; }
.mode-chip[data-mode="transit"] { color: #1f5d9e; background: #e6eff8; border-color: #c2d6ec; }
.mode-chip[data-mode="drive"]   { color: #8a5a14; background: #f7eed8; border-color: #e3d3a3; }
.mode-chip[data-mode="service"] { color: #6b3aa3; background: #efe7f7; border-color: #d6c8ea; }
.mode-chip[data-mode="origin"]  { color: #842f1e; background: #f5e5e0; border-color: #c2d6ec; }

.tel-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px 5px 9px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .01em;
  background: #1f2933;
  color: #fff;
  text-decoration: none;
  transition: background .15s;
}

.tel-chip:hover {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.tel-icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
  flex: none;
}

/* small phone badge inside the menu items */
.item-tel {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.item-tel::before {
  content: '☎';
  font-size: 11px;
  color: var(--accent);
}

.map-head-text {
  flex: 1;
  min-width: 0;
}

.map-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.map-desc {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.map-open {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s;
}

.map-open:hover {
  background: var(--accent);
}

.map-frame-wrap {
  flex: 1;
  position: relative;
  min-height: 360px;
  background: var(--surface-alt);
}

#map-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---------- mobile-only UI: hidden on desktop ---------- */
.category-chips,
.mobile-sheet {
  display: none;
}

/* ---------- mobile (Google-Maps-style chips + persistent bottom sheet) ---------- */
@media (max-width: 860px) {
  /* page becomes a fixed shell so the map can fill viewport */
  html, body { overflow: hidden; height: 100%; }
  .app {
    height: 100dvh;
    min-height: 0;
    grid-template-rows: var(--header-h) auto 1fr;
  }

  /* hide desktop sidebar + ☰ toggle */
  .sidebar { display: none; }
  .mobile-menu-toggle { display: none; }

  /* hide the desktop map-head — current item info lives in the peek sheet now */
  .map-head { display: none; }

  /* mobile header: 2 explicit grid rows — chips on row 1, lang on row 2 */
  .app { grid-template-rows: auto auto 1fr; }
  .site-header {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    align-items: center;
    height: auto;
    min-height: 0;
    padding: calc(6px + env(safe-area-inset-top)) 14px 8px;
    row-gap: 8px;
    position: relative;
  }
  .site-brand        { display: none; }
  .mobile-menu-toggle { display: none; }

  /* row 1: chips */
  .category-chips {
    grid-row: 1;
    grid-column: 1;
    width: 100%;
    min-width: 0;
  }

  /* row 2: lang menu (right-aligned in its full-width row) */
  .header-actions {
    grid-row: 2;
    grid-column: 1;
    width: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
  }

  .brand-long  { display: none; }
  .brand-short { display: none; }
  .brand-sub   { display: none; }
  .back-link   { display: none; }

  /* swap to compact language menu */
  .lang-switch { display: none; }
  .lang-menu   { display: block; }

  .source-notice {
    padding: 6px 14px;
    font-size: 11px;
    line-height: 1.35;
  }
  .source-icon { width: 14px; height: 14px; }

  .main {
    display: block;
    position: relative;
    overflow: hidden;
  }
  .map-panel { position: absolute; inset: 0; display: block; }
  .map-frame-wrap {
    position: absolute;
    inset: 0;
    min-height: 0;
  }

  /* ---- top horizontal category chips ---- */
  .category-chips {
    display: flex;
    gap: 8px;
    padding: 4px 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    margin: 0;
  }
  .category-chips::-webkit-scrollbar { display: none; }

  .chip-btn {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px 8px 11px;
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    border: 1px solid var(--line);
    box-shadow: 0 2px 8px rgba(28, 27, 24, .12);
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s, color .15s, border-color .15s;
  }
  .chip-btn .cat-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
  }
  .chip-btn:active { background: var(--surface-alt); }
  .chip-btn.is-active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 3px 10px rgba(184, 83, 58, .35);
  }

  /* ---- persistent bottom sheet (peek + expanded) ---- */
  .mobile-sheet {
    display: flex;
    flex-direction: column;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: var(--surface);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 28px rgba(28, 27, 24, .18);
    padding-bottom: env(safe-area-inset-bottom);
    transition: max-height .28s cubic-bezier(.32, .72, .26, 1);
    max-height: 180px;
    will-change: max-height;
  }
  .mobile-sheet[data-state="expanded"] {
    max-height: 70vh;
  }

  .sheet-grip-btn {
    width: 100%;
    padding: 10px 0 4px;
    display: flex;
    justify-content: center;
    background: transparent;
    flex: none;
  }
  .sheet-grip {
    display: block;
    width: 42px;
    height: 4px;
    background: var(--line-strong);
    border-radius: 999px;
  }
  .sheet-grip-btn:active .sheet-grip { background: var(--accent); }

  .sheet-peek {
    padding: 4px 18px 14px;
    flex: none;
  }
  .peek-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
    min-height: 1px;
  }
  .peek-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.3;
  }
  .peek-desc {
    margin: 4px 0 0;
    font-size: 12.5px;
    color: var(--ink-soft);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .mobile-sheet[data-state="expanded"] .peek-desc {
    -webkit-line-clamp: unset;
  }

  .peek-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
  .peek-tel,
  .peek-open {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
  }
  .peek-tel {
    background: var(--accent);
    color: #fff;
  }
  .peek-tel svg {
    width: 13px;
    height: 13px;
    fill: currentColor;
  }
  .peek-tel:active { background: var(--accent-ink); }
  .peek-open {
    background: var(--surface-alt);
    color: var(--ink);
    border: 1px solid var(--line);
  }
  .peek-open::after { content: ' ↗'; }
  .peek-open:active { background: var(--line); }

  .sheet-expanded {
    flex: 1;
    overflow: hidden;
    display: none;
    flex-direction: column;
    padding: 0 12px 14px;
  }
  .mobile-sheet[data-state="expanded"] .sheet-expanded {
    display: flex;
  }
  .mobile-sheet[data-state="expanded"] .sheet-peek {
    display: none;
  }

  .sheet-cat-title {
    margin: 0 6px 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink-mute);
    text-transform: uppercase;
    letter-spacing: .08em;
    flex: none;
  }

  .sheet-list {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 2px 8px;
  }

  .sheet-item {
    width: 100%;
    text-align: left;
    display: block;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: var(--surface);
    transition: background .12s;
  }
  .sheet-item + .sheet-item { margin-top: 4px; }
  .sheet-item:active { background: var(--surface-alt); }
  .sheet-item.is-active {
    background: var(--accent-soft);
    border-color: rgba(184, 83, 58, .25);
  }
  .sheet-item-name {
    display: block;
    font-size: 14.5px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.35;
  }
  .sheet-item-desc {
    display: block;
    font-size: 12px;
    color: var(--ink-soft);
    margin-top: 3px;
    line-height: 1.45;
  }
  .sheet-item-tel {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
  }
  .sheet-item-tel::before { content: '☎'; }
}

@media (max-width: 380px) {
  .chip-btn { padding: 7px 11px 7px 9px; font-size: 12px; }
  .chip-btn .cat-icon { width: 14px; height: 14px; }
  .peek-title { font-size: 16px; }
}

/* ---------- prefers-reduced-motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: .01ms !important;
  }
}
