* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: #fafafa;
  color: #222;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  background: #ff8a65;
  color: #fff;
  padding: 12px 16px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  z-index: 1000;
}

header h1 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
}

header .region {
  font-size: 13px;
  background: rgba(255,255,255,0.25);
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 4px;
  font-weight: 400;
}

.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: 16px;
  font-size: 14px;
  cursor: pointer;
}

.tab.active {
  background: #fff;
  color: #ff8a65;
  font-weight: 600;
}

.tab-content {
  display: none;
  flex: 1;
  min-height: 0;
}

.tab-content.active {
  display: flex;
}

#tab-spots {
  flex: 1;
}

.sidebar {
  width: 240px;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  padding: 12px;
  overflow-y: auto;
  flex-shrink: 0;
}

.search-box {
  margin-bottom: 12px;
}

.search-box input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
}

.search-box input:focus {
  outline: none;
  border-color: #ff8a65;
}

.sidebar details {
  margin-bottom: 12px;
  border-bottom: 1px solid #f0f0f0;
  padding-bottom: 8px;
}

.sidebar summary {
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  font-size: 14px;
  color: #333;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 0 2px;
}

.filter-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  padding: 2px 0;
}

.filter-group input[type="checkbox"] {
  margin: 0;
}

.result-count {
  margin: 12px 0;
  font-size: 14px;
  color: #666;
  text-align: center;
}

.result-count #count {
  font-size: 22px;
  font-weight: 700;
  color: #ff8a65;
}

.view-toggle {
  display: flex;
  gap: 2px;
  margin-top: 8px;
}

.view-btn {
  flex: 1;
  background: #f5f5f5;
  border: 1px solid #ddd;
  padding: 6px 4px;
  font-size: 12px;
  cursor: pointer;
  color: #333;
}

.view-btn.active {
  background: #ff8a65;
  color: #fff;
  border-color: #ff8a65;
}

.view-btn:first-child { border-radius: 4px 0 0 4px; }
.view-btn:last-child { border-radius: 0 4px 4px 0; }

.content {
  flex: 1;
  display: flex;
  min-width: 0;
}

#map {
  flex: 1;
  min-width: 0;
  background: #e0e0e0;
}

#list {
  width: 360px;
  overflow-y: auto;
  background: #fff;
  border-left: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.content.view-map #list { display: none; }
.content.view-map #map { flex: 1; }
.content.view-list #map { display: none; }
.content.view-list #list { width: 100%; }

.spot-card {
  padding: 12px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.1s;
}

.spot-card:hover {
  background: #fff8f5;
}

.spot-card.highlighted {
  background: #ffe8de;
}

.spot-name {
  font-size: 15px;
  font-weight: 600;
  color: #333;
  margin: 0 0 4px;
}

.spot-meta {
  font-size: 12px;
  color: #666;
  margin: 0 0 4px;
}

.spot-cat {
  display: inline-block;
  background: #ff8a65;
  color: #fff;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 8px;
  margin-right: 4px;
}

.spot-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.spot-tag {
  font-size: 11px;
  background: #f0f0f0;
  color: #555;
  padding: 1px 6px;
  border-radius: 8px;
}

.spot-tag.free { background: #c8e6c9; color: #1b5e20; }
.spot-tag.rain { background: #bbdefb; color: #0d47a1; }
.spot-tag.discovered { background: #ffe0b2; color: #e65100; }
.spot-tag.approx { background: #f5f5f5; color: #888; }
.spot-tag.tetsuban { background: #ffe082; color: #c43e00; font-weight: 600; }
.spot-tag.kids { background: #fff3e0; color: #e65100; }

.spot-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.fav-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.fav-btn:hover {
  transform: scale(1.2);
}

.fav-btn.active {
  filter: drop-shadow(0 0 2px #ff5252);
}

.spot-dist {
  font-size: 11px;
  color: #ff5722;
  margin-left: 6px;
  font-weight: 600;
}

.loc-btn {
  margin-top: 6px;
  padding: 6px 10px;
  background: #ff8a65;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  width: 100%;
}

.loc-btn:hover { background: #ff7043; }

.loc-status {
  font-size: 11px;
  color: #888;
  margin-top: 4px;
}

.card-discovered {
  border-left: 3px solid #ff9800;
}

.spot-reason {
  font-size: 12px;
  color: #555;
  margin: 4px 0;
  line-height: 1.4;
  font-style: italic;
}

.popup-reason {
  font-size: 12px;
  color: #555;
  margin: 4px 0;
  font-style: italic;
}

.popup-approximate {
  font-size: 11px;
  color: #888;
  margin-top: 4px;
}

.popup-source {
  font-size: 11px;
  color: #e65100;
  margin-top: 4px;
}

.spot-fee {
  font-size: 12px;
  color: #666;
  margin: 4px 0 0;
}

.spot-link {
  display: inline-block;
  font-size: 12px;
  color: #ff8a65;
  margin-top: 4px;
  text-decoration: none;
}

.spot-link:hover {
  text-decoration: underline;
}

.more-btn {
  display: block;
  width: calc(100% - 24px);
  margin: 12px;
  padding: 10px;
  background: #ff8a65;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.more-btn:hover {
  background: #ff7043;
}

.popup-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.popup-meta {
  font-size: 12px;
  color: #666;
}

.popup-link {
  display: inline-block;
  margin-top: 6px;
  color: #ff8a65;
  font-size: 12px;
}

/* Events tab */
.events-container {
  padding: 16px;
  width: 100%;
  overflow-y: auto;
}

.events-hint {
  background: #fff8f5;
  padding: 10px;
  border-radius: 6px;
  font-size: 13px;
  color: #555;
  margin: 0 0 16px;
}

.event-section {
  margin-bottom: 24px;
}

.event-section h2 {
  font-size: 16px;
  margin: 0 0 12px;
  color: #333;
}

.event-card {
  display: block;
  background: #fff;
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
  text-decoration: none;
  color: #333;
}

.event-card:hover {
  border-color: #ff8a65;
}

.event-source {
  font-size: 11px;
  color: #888;
}

.event-title {
  font-weight: 600;
  font-size: 14px;
  margin: 4px 0;
}

.event-snippet {
  font-size: 12px;
  color: #666;
}

.loading, .error {
  padding: 16px;
  text-align: center;
  color: #666;
}

.error {
  color: #d32f2f;
}

.hidden { display: none !important; }

/* Discover tab */
.discover-container {
  padding: 16px;
  width: 100%;
  overflow-y: auto;
}

.discover-header {
  margin-bottom: 16px;
}

.discover-hint {
  background: #fff8f5;
  padding: 10px;
  border-radius: 6px;
  font-size: 13px;
  color: #555;
  margin: 0 0 12px;
  line-height: 1.5;
}

.discover-tabs {
  display: flex;
  gap: 6px;
}

.d-tab {
  background: #f5f5f5;
  border: 1px solid #ddd;
  padding: 6px 14px;
  border-radius: 14px;
  font-size: 13px;
  cursor: pointer;
}

.d-tab.active {
  background: #ff8a65;
  color: #fff;
  border-color: #ff8a65;
}

.articles-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
}

.article-card {
  background: #fff;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
  text-decoration: none;
  color: #333;
  display: block;
  transition: border-color 0.1s, transform 0.1s;
}

.article-card:hover {
  border-color: #ff8a65;
  transform: translateY(-1px);
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.article-source {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 600;
}

.article-source.note { background: #41c9b4; color: #fff; }
.article-source.ameblo { background: #46c700; color: #fff; }

.article-likes {
  font-size: 12px;
  color: #e91e63;
  font-weight: 600;
}

.article-user {
  font-size: 11px;
  color: #888;
}

.article-title {
  font-weight: 600;
  font-size: 14px;
  margin: 4px 0;
  line-height: 1.4;
}

.article-snippet {
  font-size: 12px;
  color: #666;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Mobile */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
  }
  #tab-spots {
    flex-direction: column;
  }
  .content {
    flex-direction: column;
  }
  #list {
    width: 100%;
    max-height: 50vh;
    border-left: none;
    border-top: 1px solid #e0e0e0;
  }
  #map {
    min-height: 50vh;
  }
}
