:root {
  color-scheme: light;
  --background: #f7f8fb;
  --surface: #ffffff;
  --surface-soft: #eef4fb;
  --text: #172033;
  --muted: #697386;
  --border: #d9e0ea;
  --primary: #1d6fd6;
  --primary-strong: #1557ad;
  --primary-soft: #e8f1fd;
  --danger: #c53445;
  --shadow: 0 18px 40px rgba(27, 44, 74, 0.16);
  --panel-width: 420px;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    "Yu Gothic", "Noto Sans JP", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  color: var(--text);
  background: var(--background);
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-width);
  width: 100%;
  height: 100vh;
  min-height: 620px;
  overflow: hidden;
}

.map {
  position: relative;
  width: 100%;
  height: 100%;
  background: #dce5ee;
}

.map-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  padding: 20px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.96);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 500;
}

.panel-header {
  display: grid;
  gap: 8px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary);
  font-weight: 700;
}

.brand-mark {
  width: 28px;
  height: 28px;
  display: block;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(27, 44, 74, 0.18);
}

.brand-name {
  font-size: 0.9rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.55rem;
  line-height: 1.25;
  letter-spacing: 0;
}

h2 {
  font-size: 0.9rem;
  letter-spacing: 0;
}

#mapSubtitle {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  min-width: 0;
  padding: 10px 8px;
  text-align: center;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.metric-value {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
}

.metric-label {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 8px;
}

.action-button,
.icon-button,
.text-button,
.store-link {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

.action-button,
.icon-button,
.text-button {
  color: var(--text);
  background: var(--surface);
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  font-weight: 700;
}

.action-button.primary {
  color: white;
  background: var(--primary);
  border-color: var(--primary);
}

.action-button.is-liked {
  color: var(--danger);
  background: #fff0f2;
  border-color: #f2bbc3;
}

.icon-button,
.text-button {
  padding: 0 12px;
  font-weight: 700;
}

.text-button {
  width: 100%;
}

.action-button:active,
.icon-button:active,
.text-button:active,
.store-link:active {
  transform: translateY(1px);
}

.action-button:disabled,
.icon-button:disabled {
  cursor: default;
  opacity: 0.6;
}

.download-block {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: var(--primary-soft);
  border: 1px solid #c8dbf3;
  border-radius: 8px;
}

.download-block p {
  color: #24415f;
  font-size: 0.88rem;
  line-height: 1.5;
}

.store-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.store-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  color: var(--primary);
  text-decoration: none;
  background: var(--surface);
  font-weight: 800;
}

.store-link.primary {
  color: white;
  background: var(--primary);
  border-color: var(--primary);
}

.categories-section,
.marker-list-section,
.marker-detail {
  display: grid;
  gap: 10px;
}

.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}

.category-chip.is-active {
  border-color: var(--chip-color);
  background: color-mix(in srgb, var(--chip-color) 12%, white);
}

.category-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--chip-color);
}

.marker-list {
  display: grid;
  gap: 8px;
}

.marker-item {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  padding: 11px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.marker-item.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.marker-item-dot {
  width: 12px;
  height: 12px;
  margin-top: 4px;
  border-radius: 999px;
  background: var(--marker-color);
}

.marker-item-title {
  overflow: hidden;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.marker-item-meta {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.marker-detail {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.marker-detail h2 {
  font-size: 1.05rem;
}

.marker-detail-meta,
.marker-detail-memo {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.marker-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.marker-detail-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  color: var(--primary);
  text-decoration: none;
  background: var(--primary-soft);
  border-radius: 8px;
  font-weight: 700;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.photo-grid img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.empty-detail,
.empty-list {
  color: var(--muted);
  line-height: 1.6;
}

.loading-screen,
.error-screen {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 100vh;
  padding: 24px;
  background: linear-gradient(135deg, #eef6ff, #f7f8fb);
}

.loading-card,
.error-card {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 24px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.error-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin: 0 auto;
  color: white;
  background: var(--danger);
  border-radius: 50%;
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  color: white;
  background: rgba(23, 32, 51, 0.94);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.marker-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 24px 12px;
  background: rgba(15, 23, 42, 0.42);
}

.marker-dialog {
  display: flex;
  flex-direction: column;
  width: min(560px, calc(100vw - 24px));
  max-height: min(780px, calc(100vh - 48px));
  overflow: hidden;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.28);
}

.marker-dialog-header {
  position: relative;
  padding: 18px 44px 14px 18px;
  border-bottom: 1px solid var(--border);
}

.marker-dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.marker-dialog-address {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  color: #4b5563;
  font-size: 0.9rem;
  line-height: 1.45;
}

.marker-dialog-icon {
  color: var(--primary);
  font-size: 0.72rem;
  line-height: 1.8;
}

.marker-dialog h2 {
  margin: 0 0 10px;
  font-size: 1.35rem;
  line-height: 1.3;
}

.marker-dialog-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.marker-dialog-links a,
.marker-dialog-actions a,
.marker-dialog-close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  text-decoration: none;
  border-radius: 16px;
  font-weight: 700;
}

.marker-dialog-links a {
  color: var(--primary);
  background: var(--surface-soft);
}

.marker-dialog-body {
  overflow-y: auto;
  padding: 12px;
}

.marker-dialog-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.marker-dialog-category,
.marker-dialog-date {
  min-width: 0;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.marker-dialog-category {
  max-width: 70%;
  overflow: hidden;
  color: white;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--category-color);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--category-color) 34%, transparent);
}

.marker-dialog-date {
  color: #4b5563;
  background: var(--surface-soft);
}

.marker-dialog-photos {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 8px -12px 14px;
  padding: 4px 12px 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}

.marker-dialog-photos a {
  flex: 0 0 min(72%, 320px);
  display: flex;
  justify-content: center;
  scroll-snap-align: center;
}

.marker-dialog-photos img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: contain;
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
}

.marker-dialog-memo {
  padding: 12px;
  color: #273244;
  background: #fbfcfe;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.marker-dialog-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.marker-dialog-actions a {
  min-width: 0;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-size: 0.86rem;
}

.marker-dialog-footer {
  padding: 0 12px 12px;
}

.marker-dialog-close-button {
  width: 100%;
  color: white;
  background: var(--primary);
  border: 1px solid var(--primary);
  cursor: pointer;
}

.material-like-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
    min-height: 100vh;
    overflow: auto;
  }

  .map {
    height: 58vh;
    min-height: 360px;
  }

  .map-panel {
    height: auto;
    min-height: 42vh;
    border-top: 1px solid var(--border);
    border-left: 0;
    border-radius: 18px 18px 0 0;
    transform: translateY(-18px);
  }
}

@media (max-width: 520px) {
  .map {
    height: 55vh;
    min-height: 320px;
  }

  .map-panel {
    padding: 16px;
  }

  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .actions {
    grid-template-columns: 1fr 1fr;
  }

  .icon-button {
    grid-column: 1 / -1;
  }

  .store-links {
    grid-template-columns: 1fr;
  }

  .marker-dialog {
    max-height: calc(100vh - 28px);
  }

  .marker-dialog-actions {
    grid-template-columns: 1fr;
  }

  .marker-dialog-photos img {
    height: 150px;
  }
}
