* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --primary:       #0f8472;
  --primary-mid:   #2aa693;
  --primary-light: #d0f0eb;
  --primary-bg:    #e8f7f4;
  --dark:          #1f2937;
  --text:          #0a0a0a;
  --text-mid:      #404040;
  --text-muted:    #aeaeb2;
  --surface:       #f7f4f0;
  --bg:            #eeeeee;
  --white:         #ffffff;
  --border:        rgba(0,0,0,0.08);
  --radius-xl:     16px;
  --radius-lg:     14px;
  --radius-md:     8px;
  --radius-pill:   9999px;
}

body {
  font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, 'Hiragino Sans', sans-serif;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

/* ── Header ── */
header {
  background: var(--primary);
  color: white;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(15,132,114,0.3);
  z-index: 1000;
  flex-shrink: 0;
  position: relative;
}
header h1 {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
}

#count-badge {
  font-size: 13px;
  opacity: 0.8;
}

#info-btn {
  display: none;
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

#info-dropdown {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 10000;
  overflow-y: auto;
  max-height: 70dvh;
}
#info-dropdown.open { display: block; }

/* ── Filter bar ── */
#filter-bar {
  background: var(--white);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

/* ── Filter trigger rows ── */
.filter-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  border-top: 1px solid rgba(0,0,0,0.05);
}
.filter-trigger:first-child { border-top: none; }

.filter-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

#coupon-trigger-label,
#cat-trigger-label {
  font-size: 12px;
  color: var(--text-mid);
  font-weight: 500;
}

.filter-chevron {
  margin-left: auto;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}
.filter-trigger.open .filter-chevron { transform: rotate(180deg); }

/* ── Filter expand panel (アコーディオン) ── */
.filter-expand {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
  background: var(--white);
}
.filter-expand.open { max-height: 1200px; }

.filter-expand-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px 12px;
}

/* ── Chips ── */
.chip {
  border: 1.5px solid var(--border);
  background: var(--white);
  border-radius: var(--radius-pill);
  padding: 5px 13px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  color: var(--text-mid);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}
.chip:active { opacity: 0.75; }
.chip.active { color: white; border-color: transparent; background: var(--primary); }

/* 券種 active colors */
#coupon-sheet-chips .chip[data-coupon="all"].active     { background: var(--dark); }
#coupon-sheet-chips .chip[data-coupon="both"].active    { background: #16a34a; }
#coupon-sheet-chips .chip[data-coupon="digital"].active { background: var(--primary); }
#coupon-sheet-chips .chip[data-coupon="paper"].active   { background: #b45309; }

/* ── Main area ── */
#main {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

/* ── Side panel (desktop: left; mobile: bottom) ── */
#side-panel {
  order: -1;
  width: 300px;
  min-height: 0;
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.3s ease;
}
#side-panel.closed { width: 0; }

#sidebar-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 140;
  pointer-events: none;
}

#sidebar-search {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  flex-shrink: 0;
}
#search-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  background: var(--white);
  font-family: inherit;
  color: var(--text);
}
#search-input:focus { border-color: var(--primary); background: var(--white); box-shadow: 0 0 0 3px var(--primary-bg); }

#sidebar-header {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mid);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
#sidebar-header .header-right { display: flex; align-items: center; gap: 8px; }
#sidebar-count { color: var(--text-muted); font-weight: 400; font-size: 12px; }
#sidebar-toggle-arrow {
  transition: transform 0.3s;
}

#store-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#store-list-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

#store-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#store-list-actions {
  padding: 10px 12px 12px;
  background: var(--white);
  flex-shrink: 0;
  overflow: hidden;
}

#load-more-button {
  width: 100%;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.15s;
}

#load-more-button:hover {
  background: var(--primary-bg);
}

.panel-section {
  background: var(--white);
  flex-shrink: 0;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mid);
}

.info-panel-body {
  display: grid;
  gap: 14px;
  padding: 14px 16px 18px;
}

.info-divider {
  border: none;
  border-top: 1px solid var(--border);
}

.contact-open-button {
  display: inline-flex;
  align-items: center;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
  justify-self: start;
  transition: background 0.15s;
}

.contact-open-button:hover {
  background: var(--primary-bg);
}

.store-item {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.store-item:active,
.store-item:hover { background: var(--primary-bg); border-color: var(--primary-light); }

.store-item.active {
  background: var(--primary-bg);
  border-color: var(--primary);
  box-shadow: inset 3px 0 0 var(--primary);
}

.store-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 3px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.store-item-sub {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.store-item-desc {
  font-size: 11px;
  color: var(--text-mid);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}
.store-item-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.store-tag {
  border-radius: var(--radius-pill);
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 600;
  color: white;
}
.store-tag.digital { background: var(--primary); }
.store-tag.paper   { background: #b45309; }
.store-tag.both    { background: #16a34a; }
.store-tag.cat     { background: var(--dark); }

/* ── Map ── */
#map { flex: 1; min-height: 0; }

/* ── Popup ── */
.popup-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.popup-address { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.popup-desc { font-size: 12px; color: var(--text-mid); line-height: 1.5; margin-bottom: 6px; }
.popup-phone { font-size: 12px; margin-bottom: 6px; }
.popup-phone a { color: var(--primary); text-decoration: none; }
.popup-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.popup-tag { border-radius: var(--radius-pill); padding: 2px 8px; font-size: 11px; font-weight: 600; color: white; }
.popup-tag.digital { background: var(--primary); }
.popup-tag.paper   { background: #b45309; }
.popup-tag.both    { background: #16a34a; }
.popup-tag.cat     { background: var(--dark); }
.popup-tag.area    { background: var(--text-muted); }
.popup-links { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.popup-links a {
  font-size: 11px; color: var(--primary); text-decoration: none;
  border: 1px solid var(--primary-light); border-radius: var(--radius-md);
  padding: 2px 7px; background: var(--primary-bg);
}
.popup-links a:hover { background: var(--primary-light); }

/* ── Loading ── */
#loading {
  position: fixed; inset: 0;
  background: rgba(255,255,255,0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; font-size: 15px; color: var(--text-muted);
}
#loading.hidden { display: none; }

.footer-copy {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-mid);
}
.footer-copy a {
  color: var(--primary);
  text-decoration: underline;
}

.footer-disclaimer {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 16px;
}

.footer-links a {
  text-decoration: none;
  color: var(--primary);
  background: transparent;
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
}

.footer-links a:hover {
  background: var(--primary-bg);
}

.contact-form-body {
  display: grid;
  gap: 12px;
}

.contact-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mid);
}

.contact-form input,
.contact-form select,
.contact-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  font: inherit;
  background: var(--white);
  color: var(--text);
}

.contact-form input:focus,
.contact-form select:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-bg);
}

.contact-form textarea {
  resize: vertical;
  min-height: 132px;
}

.contact-form button {
  border: none;
  border-radius: var(--radius-lg);
  background: var(--primary);
  color: white;
  font: inherit;
  font-weight: 700;
  padding: 12px 16px;
  cursor: pointer;
}

.contact-form button:hover { opacity: 0.88; }

.contact-form button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.contact-note {
  font-size: 12px;
  color: var(--text-muted);
}

.contact-error {
  color: #d32f2f;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.contact-form .input-error {
  border-color: #d32f2f !important;
  outline: none;
  box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.2);
}

.modal-company-name {
  margin-top: 18px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.modal-company-name a {
  color: inherit;
  text-decoration: none;
}
.modal-company-name a:hover {
  text-decoration: underline;
}

.contact-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 900;
}

.contact-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 901;
}

.contact-modal-card {
  width: min(560px, 100%);
  max-height: min(88dvh, 860px);
  display: flex;
  flex-direction: column;
  background: rgba(255,255,255,0.98);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}


.contact-form {
  display: contents;
}

.contact-form-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 22px;
}

.contact-form-footer {
  flex-shrink: 0;
  padding: 12px 22px 18px;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,0.98);
}

.contact-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 22px 14px;
  flex-shrink: 0;
}

.contact-modal-header h2 {
  font-size: 22px;
}

.contact-modal-close {
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: var(--radius-pill);
  padding: 8px 12px;
  font: inherit;
  color: var(--text-mid);
  cursor: pointer;
}

/* ── Desktop store-panel collapse ── */
@media (min-width: 769px) {
  #store-panel {
    transition: max-height 0.3s ease, overflow 0.3s;
    max-height: 10000px;
  }
  #store-panel.collapsed {
    max-height: 0 !important;
    flex: none !important;
    overflow: hidden !important;
  }
  #sidebar-header.panel-collapsed #sidebar-toggle-arrow { transform: rotate(180deg); }
}

/* ── Mobile (末尾に置くことでデスクトップルールより優先される) ── */
@media (max-width: 768px) {
  #main { flex-direction: column; }

  #filter-triggers {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .filter-group:first-child {
    border-right: 1px solid var(--border);
  }

  #map {
    flex: 1 1 0;
    min-height: 35dvh;
  }

  #side-panel {
    order: 1;
    flex: 0 0 auto;
    width: 100%;
    max-height: 65dvh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.12);
    transition: none;
    overflow: hidden;
  }
  #side-panel.closed { width: 100%; }

  #sidebar-header.expanded-arrow #sidebar-toggle-arrow { transform: rotate(180deg); }

  #info-btn { display: flex; }
  .panel-section { display: none; }

  #store-panel {
    flex: none;
    overflow: hidden;
    height: 8.5rem;
    transition: height 0.3s cubic-bezier(0.25,0.46,0.45,0.94);
  }
  #store-panel.expanded { height: 42dvh; }

  #sidebar-search {
    max-height: 0;
    overflow: hidden;
    padding: 0;
    transition: max-height 0.3s ease, padding 0.3s ease;
  }
  #store-panel.expanded #sidebar-search {
    max-height: 60px;
    padding: 8px 12px;
  }

  #store-list-actions {
    max-height: 0;
    padding: 0 12px;
    transition: max-height 0.3s ease, padding 0.3s ease;
  }
  #store-list-actions.reveal {
    max-height: 80px;
    padding: 10px 12px 12px;
  }

  #store-list {
    padding: 4px 8px;
  }

  header {
    gap: 8px;
  }

  header h1 {
    font-size: 14px;
    line-height: 1.35;
  }

  #count-badge {
    display: none;
  }

  .contact-modal {
    align-items: flex-end;
    padding: 10px;
  }

  .contact-modal-card {
    width: 100%;
    max-height: 82dvh;
    border-radius: var(--radius-xl) var(--radius-xl) var(--radius-md) var(--radius-md);
    padding: 18px;
  }

  .contact-modal-header h2 {
    font-size: 18px;
  }
}
