:root {
  --color-bg: #f4f5f7;
  --color-header: #1b1f3b;
  --color-accent: #ff6b35;
  --color-accent-dark: #e0551f;
  --color-text: #23262f;
  --color-text-muted: #6b7078;
  --color-border: #e2e4e9;
  --color-card: #ffffff;
  --header-h: 60px;
  --region-h: 44px;
  --ad-h: 50px;
  --footer-h: 34px;
  --sidebar-w: 320px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", "Helvetica Neue", Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

/* ---------- Header ---------- */
.app-header {
  height: var(--header-h);
  background: var(--color-header);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.header-inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
}

.logo {
  font-size: 18px;
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex-shrink: 1;
}

.logo-sub {
  font-size: 11px;
  font-weight: 400;
  color: #b8bcd4;
  display: none;
}

@media (min-width: 640px) {
  .logo-sub { display: inline; }
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.date-btn {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
.date-btn:hover { background: rgba(255,255,255,0.25); }

#dateInput {
  background: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 14px;
  height: 30px;
}

.today-btn {
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0 12px;
  height: 30px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.today-btn:hover { background: var(--color-accent-dark); }

/* ---------- Region bar ---------- */
.region-bar {
  height: var(--region-h);
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  flex-shrink: 0;
}

.region-label {
  font-size: 12.5px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

#prefSelect {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 5px 6px;
  font-size: 13px;
  background: #fff;
  color: var(--color-text);
  max-width: 40vw;
}

.locate-btn {
  background: #eef0fb;
  color: var(--color-header);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.locate-btn:hover { background: #e2e5f7; }
.locate-btn:disabled { opacity: 0.6; cursor: default; }

.search-btn {
  background: #eef0fb;
  color: var(--color-header);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.search-btn:hover { background: #e2e5f7; }

.region-note {
  font-size: 11.5px;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Ad slots ---------- */
.ad-slot {
  height: var(--ad-h);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.ad-bottom { border-bottom: none; border-top: 1px solid var(--color-border); }
.ad-label {
  font-size: 11px;
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
}

/* ---------- Main layout ---------- */
.app-main {
  display: flex;
  height: calc(100vh - var(--header-h) - var(--region-h) - var(--ad-h) * 2 - var(--footer-h));
  position: relative;
  overflow: hidden;
}

#map {
  flex: 1;
  height: 100%;
  z-index: 1;
}

/* ---------- Sidebar (desktop) ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--color-card);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 500;
}

.sidebar-section {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--color-border);
}
.sidebar-section:last-child { border-bottom: none; }

.sidebar-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.sidebar-header h2 {
  font-size: 15px;
  margin: 0;
}

.visit-count {
  font-size: 12px;
  color: #fff;
  background: var(--color-accent);
  padding: 2px 8px;
  border-radius: 999px;
}

.event-count {
  background: #5c6bc0;
}

.fav-count {
  background: #ffb300;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.share-day-btn,
.share-x-btn {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.share-x-btn { padding: 5px 14px; font-size: 12.5px; }
.detail-share {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 8px 0 4px;
}
.detail-page-link { font-size: 12.5px; }
.about-links { font-size: 13px; }

.fav-section {
  flex: 0 0 auto;
}
.fav-section .visit-list {
  max-height: 180px;
}

.fav-star {
  border: none;
  background: transparent;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  color: #d0d3da;
  padding: 4px;
  flex-shrink: 0;
}
.fav-star:hover { color: #ffb300; }
.fav-star.active { color: #ffb300; }

.detail-fav-star {
  position: absolute;
  top: 8px;
  right: 48px;
  font-size: 22px;
}

.visit-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  min-height: 0;
}

.visit-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.visit-card:hover { background: #f6f7fb; border-color: var(--color-border); }

.visit-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--color-border);
}

.visit-info { min-width: 0; }
.visit-performer { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.visit-store { font-size: 12px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.event-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eef0fb;
  font-size: 18px;
}

.visit-title { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty-state {
  padding: 32px 16px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 13px;
  line-height: 1.7;
}

.sidebar-toggle { display: none; }
.sidebar-toggle-fab { display: none; }

/* ---------- Leaflet marker ---------- */
.performer-marker {
  width: 38px;
  height: 38px;
  background: var(--color-accent);
  font-size: 17px;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  position: relative;
}
.performer-marker.multi::after {
  content: attr(data-count);
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: var(--color-accent);
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid #fff;
}

.marker-event-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #5c6bc0;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  line-height: 1;
}

.event-marker {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #5c6bc0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  position: relative;
}
.event-marker.multi::after {
  content: attr(data-count);
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: var(--color-header);
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid #fff;
}

.leaflet-popup-content-wrapper { border-radius: 10px; }

.me-marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #4285f4;
  border: 3px solid #fff;
  box-shadow: 0 0 0 4px rgba(66,133,244,0.35), 0 2px 6px rgba(0,0,0,0.35);
}

/* ---------- Detail panel ---------- */
.detail-panel {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 2000;
}
.detail-panel.open { display: flex; }

.detail-panel-inner {
  background: #fff;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 20px;
  position: relative;
  animation: slideUp 0.2s ease-out;
}

@media (min-width: 900px) {
  .detail-panel { align-items: center; }
  .detail-panel-inner { border-radius: 16px; max-height: 70vh; }
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.detail-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #f0f1f4;
  font-size: 18px;
  cursor: pointer;
  color: var(--color-text-muted);
}

/* ---------- Search panel ---------- */
.search-panel {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 2100;
}
.search-panel.open { display: flex; }

.search-panel-inner {
  background: #fff;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  margin-top: 12vh;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  animation: slideUp 0.2s ease-out;
}

.search-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 10px;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  min-width: 0;
}
.search-input:focus { outline: 2px solid var(--color-accent); outline-offset: -1px; }

.search-panel .detail-close {
  position: static;
  flex-shrink: 0;
}

.search-results {
  overflow-y: auto;
  padding: 4px 8px 12px;
  min-height: 0;
}

.search-group-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
  padding: 10px 8px 4px;
}

.search-btn { display: none; }
@media (min-width: 900px) {
  .search-btn { display: inline-block; }
}

.search-fab { display: none; }

.detail-store-name { font-size: 18px; font-weight: 700; margin: 4px 0 2px; padding-right: 30px; }
.detail-store-address { font-size: 13px; color: var(--color-text-muted); margin-bottom: 4px; }
.detail-store-link { font-size: 12.5px; }
.detail-section-title { font-size: 13px; font-weight: 700; margin: 18px 0 8px; color: var(--color-text-muted); }

.detail-visit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
}
.detail-visit-row:last-child { border-bottom: none; }
.detail-visit-date { font-size: 12px; color: #fff; background: var(--color-header); padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.detail-visit-performer { font-size: 14px; font-weight: 600; }
.detail-visit-genre { font-size: 11.5px; color: var(--color-text-muted); }
.detail-visit-source { font-size: 11px; margin-left: auto; white-space: nowrap; }

.disclaimer-note {
  margin-top: 16px;
  font-size: 11px;
  color: var(--color-text-muted);
  line-height: 1.6;
  border-top: 1px solid var(--color-border);
  padding-top: 10px;
}

a { color: var(--color-accent-dark); }

/* ---------- Disclaimer ---------- */
.disclaimer-btn {
  position: fixed;
  right: 14px;
  bottom: calc(var(--ad-h) + var(--footer-h) + 14px);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--color-header);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  z-index: 1500;
}
.disclaimer-btn:hover { background: #2a2f52; }

.disclaimer-popover {
  position: fixed;
  right: 14px;
  bottom: calc(var(--ad-h) + var(--footer-h) + 54px);
  width: min(320px, calc(100vw - 28px));
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
  padding: 16px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--color-text);
  display: none;
  z-index: 1500;
}
.disclaimer-popover.open { display: block; }
.disclaimer-popover strong { display: block; margin-bottom: 6px; font-size: 13.5px; }
.disclaimer-popover p { margin: 0; }
.disclaimer-popover-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: #f0f1f4;
  font-size: 15px;
  cursor: pointer;
  color: var(--color-text-muted);
}

/* ---------- About section ---------- */
.about-section {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px;
  background: #fff;
}
.about-section h2 {
  font-size: 18px;
  border-left: 4px solid var(--color-accent);
  padding-left: 10px;
  margin: 0 0 14px;
}
.about-section h3 {
  font-size: 15px;
  margin: 28px 0 10px;
}
.about-section p {
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--color-text);
  margin: 0 0 12px;
}
.about-section dl { margin: 0; }
.about-section dt {
  font-size: 13.5px;
  font-weight: 700;
  margin-top: 14px;
}
.about-section dd {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.7;
  margin: 4px 0 0;
}

/* ---------- Footer ---------- */
.app-footer {
  height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 10.5px;
  color: var(--color-text-muted);
  background: #fff;
  border-top: 1px solid var(--color-border);
  padding: 0 10px;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.app-footer p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.app-footer .footer-map-credit { display: none; }
.app-footer .footer-privacy-link { flex-shrink: 0; white-space: nowrap; color: var(--color-text-muted); text-decoration: underline; }
@media (min-width: 700px) {
  .app-footer .footer-map-credit { display: block; }
}

/* ---------- Mobile layout ---------- */
@media (max-width: 899px) {
  :root { --sidebar-w: 100%; }

  .logo { font-size: 12.5px; }

  .header-inner { gap: 6px; }
  .date-nav { gap: 3px; }
  .date-btn { width: 26px; height: 26px; font-size: 16px; }
  #dateInput { font-size: 12px; padding: 5px 2px; }
  .today-btn { padding: 0 6px; font-size: 11.5px; }

  .region-bar { gap: 6px; padding: 0 10px; }
  .region-label { display: none; }
  #prefSelect { max-width: 32vw; font-size: 12.5px; }
  .locate-btn { padding: 5px 8px; font-size: 12px; }
  .region-note { display: none; }

  .app-main { flex-direction: column; }

  #map { order: 1; height: 100%; }

  .sidebar {
    order: 2;
    position: absolute;
    left: 0; right: 0; bottom: 0;
    width: 100%;
    border-right: none;
    border-top: 1px solid var(--color-border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -6px 20px rgba(0,0,0,0.25);
    height: 100%;
    transform: translateY(calc(100% - 56px));
    transition: transform 0.25s ease;
    z-index: 600;
    animation: sidebarHint 1.8s ease-in-out 1s 2;
  }

  @keyframes sidebarHint {
    0%, 100% { transform: translateY(calc(100% - 56px)); }
    50% { transform: translateY(calc(100% - 72px)); }
  }
  .sidebar.expanded { transform: translateY(0); animation: none; }

  .sidebar-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 56px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--color-accent), var(--color-accent-dark));
    border: none;
    border-radius: 16px 16px 0 0;
    font-size: 13.5px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    position: relative;
  }
  .sidebar-toggle::before {
    content: "";
    position: absolute;
    top: 7px;
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255,255,255,0.6);
  }
  .sidebar-toggle .toggle-summary {
    display: block;
    font-size: 11.5px;
    font-weight: 500;
    opacity: 0.95;
  }
  .chevron { transition: transform 0.2s; }
  .sidebar.expanded .chevron { transform: rotate(180deg); }

  .sidebar-toggle-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 12px;
    right: 12px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid #ffb300;
    background: var(--color-accent);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    z-index: 700;
    transition: background 0.15s;
  }
  .sidebar-toggle-fab:active { background: var(--color-accent-dark); }
  .sidebar.expanded ~ .sidebar-toggle-fab,
  .sidebar-toggle-fab.is-open {
    background: var(--color-header);
  }

  .search-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 12px;
    right: 68px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid #ffb300;
    background: var(--color-header);
    color: #fff;
    font-size: 19px;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    z-index: 700;
  }

  .search-panel-inner { margin-top: 0; max-height: 100%; border-radius: 0; height: 100%; }
  .search-panel { align-items: stretch; }
}
