:root {
  --header-h: 64px;
  --sidebar-w: 340px;
  --accent: #e8543f;
  --bg: #f6f5f3;
  --text: #2c2c2c;
  --muted: #888;
  --border: #e2e0dc;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* ===== Header ===== */
.app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 1000;
}
.app-title {
  font-size: 18px;
  margin: 0;
  white-space: nowrap;
}
.controls {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}
.search, .genre, .locate {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 14px;
  background: #fff;
}
.search { width: 220px; }
.locate {
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  white-space: nowrap;
}
.locate:hover { opacity: 0.9; }

/* ===== Main ===== */
.app-main {
  display: flex;
  height: calc(100% - var(--header-h));
}
.sidebar {
  width: var(--sidebar-w);
  border-right: 1px solid var(--border);
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.status-filter {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { background: #faf7f4; }
.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.sidebar-summary {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.me {
  margin-left: auto;
  cursor: pointer;
  text-decoration: underline dotted;
}
.restaurant-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}
.restaurant-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  gap: 10px;
}
.restaurant-item:hover { background: #faf7f4; }
.restaurant-item.active { background: #fdeeeb; }
.item-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: #eee;
  flex-shrink: 0;
}
.item-body { min-width: 0; }
.item-name {
  font-weight: 600;
  font-size: 14px;
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.genre-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.item-address {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== ステータスバッジ & 操作ボタン ===== */
.status-badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-want    { background: #eef0f2; color: #5a6470; }
.badge-visited { background: #e7f4ea; color: #2e7d46; }
.badge-good    { background: #fff4d6; color: #b8860b; }
.badge-bad     { background: #fdeceb; color: #c0392b; }

.status-btns {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.sbtn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  line-height: 1.2;
}
.sbtn:hover { background: #faf7f4; }
.sbtn.on { border-color: var(--accent); background: #fdeeeb; color: var(--accent); font-weight: 600; }

.map { flex: 1; height: 100%; }

/* ===== Popup ===== */
.popup-name { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.popup-thumb {
  width: 100%;
  max-height: 130px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 6px;
}
.popup-meta { font-size: 12px; color: #555; margin: 2px 0; }
.popup-link {
  display: inline-block;
  margin-top: 6px;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.popup-link:hover { text-decoration: underline; }

/* ===== Legend ===== */
.legend {
  background: rgba(255, 255, 255, 0.92);
  padding: 8px 10px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  font-size: 12px;
  line-height: 1.6;
  max-height: 220px;
  overflow-y: auto;
}
.legend-row { display: flex; align-items: center; gap: 6px; }

/* ===== Responsive ===== */
@media (max-width: 720px) {
  :root { --sidebar-w: 100%; }
  .app-header { height: auto; flex-direction: column; align-items: stretch; padding: 10px; }
  .controls { margin-left: 0; }
  .search { flex: 1; width: auto; }
  .app-main { flex-direction: column; height: calc(100% - 110px); }
  .sidebar { height: 40%; border-right: none; border-bottom: 1px solid var(--border); }
  .map { height: 60%; }
}
