:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #059669;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --header-height: auto;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
  z-index: 600;
}

.app-brand {
  flex-shrink: 0;
}

.app-brand-link {
  color: inherit;
  text-decoration: none;
}

.app-brand-link:hover .app-brand-title {
  color: var(--primary);
}

.app-brand-eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.app-brand-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.app-header-controls {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}

.region-selectors {
  display: grid;
  grid-template-columns: 160px 180px;
  gap: 8px;
}

.region-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.region-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.region-field select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  background: #fff;
  outline: none;
}

.region-field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.search-box {
  flex: 1;
  max-width: 280px;
  min-width: 160px;
}

.search-box input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.app-body {
  display: grid;
  grid-template-columns: 380px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.app-body > .sidebar,
.app-body > .map-panel {
  min-height: 0;
  max-height: 100%;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 500;
}

.sidebar-context,
.toolbar,
.status,
.region-disclaimer {
  flex-shrink: 0;
}

.sidebar-context {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.region-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.region-seo-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
}

.region-seo-link:hover {
  text-decoration: underline;
}

.toolbar {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.btn {
  flex: 1;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: #eef2ff;
  color: #3730a3;
}

.region-disclaimer {
  padding: 12px 16px;
  margin: 12px 20px 0;
  border-radius: 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  font-size: 12px;
  line-height: 1.6;
}

.region-disclaimer.no-data {
  background: #f9fafb;
  border-color: var(--line);
  color: var(--muted);
}

.status {
  padding: 12px 20px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.status.error {
  color: #b91c1c;
}

.bin-list {
  list-style: none;
  margin: 0;
  padding: 8px 12px 16px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.bin-item {
  padding: 14px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.bin-item:hover,
.bin-item.active {
  border-color: var(--primary);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.12);
}

.bin-item h2 {
  margin: 0 0 6px;
  font-size: 15px;
}

.bin-item p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.bin-item .bin-subtitle {
  margin-top: 6px;
  font-size: 12px;
  color: #9ca3af;
}

.bin-item .distance {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-size: 12px;
  font-weight: 700;
}

.bin-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.bin-directions-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #eff6ff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  flex-shrink: 0;
}

.bin-directions-link:hover {
  background: #dbeafe;
}

.mobile-sheet-handle {
  display: none;
}

.mobile-view-bar {
  display: none;
}

.empty-state {
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.map-panel {
  position: relative;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
}

.map-info-window-link {
  display: block;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.map-info-window-link:hover .map-info-window {
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.22);
}

.map-info-window {
  min-width: 180px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
  line-height: 1.5;
  transition: box-shadow 0.15s ease;
}

.popup-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
}

.popup-address {
  margin: 0;
  font-size: 13px;
  color: #4b5563;
}

.popup-action {
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}

.cluster-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.cluster-marker-sm {
  width: 40px;
  height: 40px;
}

.cluster-marker-md {
  width: 48px;
  height: 48px;
}

.cluster-marker-lg {
  width: 56px;
  height: 56px;
}

.user-location-marker {
  width: 20px;
  height: 20px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.45);
}

.home-page {
  overflow: auto;
}

.home-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 40%);
}

.home-header {
  padding: 20px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.home-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.home-hero {
  margin-bottom: 28px;
}

.home-hero-eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.home-hero-title {
  margin: 0 0 12px;
  font-size: clamp(28px, 5vw, 36px);
  line-height: 1.3;
}

.home-hero-desc {
  margin: 0;
  font-size: 15px;
  line-height: 1.7;
  color: var(--muted);
}

.home-panel {
  padding: 24px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.home-panel-title {
  margin: 0 0 16px;
  font-size: 18px;
}

.home-region-selectors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.home-region-summary {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.home-region-summary.error {
  color: #b91c1c;
}

.home-action-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

.home-map-link,
.home-region-link {
  display: block;
  text-align: center;
  text-decoration: none;
}

.home-seo-link {
  margin: 16px 0 0;
  font-size: 13px;
  text-align: center;
}

.home-seo-link a {
  color: var(--primary);
  text-decoration: none;
}

.home-seo-link a:hover {
  text-decoration: underline;
}

.seo-main {
  max-width: 800px;
}

.seo-breadcrumb {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--muted);
}

.seo-breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

.seo-title {
  margin: 0 0 12px;
  font-size: clamp(24px, 4vw, 32px);
  line-height: 1.35;
}

.seo-summary {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}

.seo-disclaimer {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  font-size: 13px;
  line-height: 1.6;
  color: #92400e;
}

.seo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 28px;
}

.seo-list-section {
  padding: 24px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.seo-list-title {
  margin: 0 0 16px;
  font-size: 18px;
}

.seo-bin-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.seo-bin-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.seo-bin-item:last-child {
  border-bottom: none;
}

.seo-bin-index {
  flex-shrink: 0;
  width: 28px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-align: right;
}

.seo-bin-body {
  min-width: 0;
}

.seo-bin-name {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
}

.seo-bin-address {
  margin: 0;
  font-style: normal;
  font-size: 14px;
  line-height: 1.5;
}

.seo-bin-coords {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.seo-note {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.seo-sido-section {
  margin-bottom: 24px;
  padding: 20px 24px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.seo-sido-title {
  margin: 0 0 12px;
  font-size: 17px;
}

.seo-region-links {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.seo-region-links a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}

.seo-region-links a:hover {
  background: #e8f0fe;
  color: var(--primary);
}

.seo-region-count {
  color: var(--muted);
  font-size: 12px;
}

.seo-intro {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
}

.ad-slot {
  margin: 20px 0;
  min-height: 90px;
  overflow: hidden;
}

.ad-slot-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #f9fafb;
}

.ad-slot-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.site-footer {
  margin-top: auto;
  padding: 10px 20px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
  flex-shrink: 0;
}

.site-footer--compact {
  padding: 6px 12px;
}

.site-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  flex-wrap: wrap;
  max-width: 1200px;
  margin: 0 auto;
}

.site-footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}

.site-footer-brand:hover .site-footer-brand-name {
  color: var(--primary);
}

.site-footer-logo {
  display: flex;
  line-height: 0;
}

.site-footer-brand-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.site-footer-copy {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.site-footer-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0;
  flex: 1 1 auto;
}

.site-footer-nav a {
  font-size: 12px;
  color: #4b5563;
  text-decoration: none;
  padding: 2px 5px;
  white-space: nowrap;
}

.site-footer-nav a:hover {
  color: var(--primary);
}

.site-footer-sep {
  color: #d1d5db;
  font-size: 11px;
  user-select: none;
}

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

.legal-main {
  max-width: 720px;
}

.legal-title {
  margin: 0 0 8px;
  font-size: 28px;
}

.legal-updated {
  margin: 0 0 24px;
  font-size: 13px;
  color: var(--muted);
}

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

.legal-section h2 {
  margin: 0 0 8px;
  font-size: 17px;
}

.legal-section p,
.legal-section ul {
  margin: 0;
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
}

.legal-section ul {
  padding-left: 20px;
}

.legal-section li + li {
  margin-top: 6px;
}

.legal-section a {
  color: var(--primary);
}

.home-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

.home-stat-card {
  padding: 18px 20px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.home-stat-label {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.home-stat-value {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

@media (max-width: 900px) {
  .app-header {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
  }

  .app-brand-eyebrow {
    display: none;
  }

  .app-brand-title {
    font-size: 16px;
    white-space: nowrap;
  }

  .app-header-controls {
    flex: 1;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    min-width: 0;
  }

  .region-selectors {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .region-field select {
    padding: 7px 8px;
    font-size: 12px;
  }

  .region-label {
    font-size: 10px;
  }

  .search-box {
    max-width: none;
    min-width: 0;
  }

  .search-box input {
    padding: 8px 10px;
    font-size: 13px;
  }

  .app-body {
    position: relative;
    display: block;
    grid-template-columns: unset;
    grid-template-rows: unset;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  .map-panel {
    position: absolute;
    inset: 0;
    z-index: 1;
  }

  .sidebar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 400;
    max-height: none;
    height: auto;
    border-right: none;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.12);
    transform: translateY(calc(100% - 52px));
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    pointer-events: auto;
  }

  .mobile-sheet-handle {
    display: block;
    flex-shrink: 0;
    width: 40px;
    height: 4px;
    margin: 8px auto 4px;
    border-radius: 999px;
    background: #d1d5db;
    cursor: grab;
    touch-action: none;
  }

  .sidebar-context {
    padding: 8px 16px 10px;
  }

  .region-title {
    font-size: 18px;
  }

  .toolbar {
    padding: 8px 16px;
  }

  .status {
    padding: 8px 16px;
    font-size: 12px;
  }

  .bin-list {
    max-height: min(52vh, 420px);
    padding-bottom: 8px;
  }

  .app-shell.mobile-view-list .sidebar {
    transform: translateY(0);
  }

  .app-shell.mobile-view-map .sidebar {
    transform: translateY(calc(100% - 52px));
    pointer-events: none;
  }

  .app-shell.mobile-view-map .mobile-sheet-handle,
  .app-shell.mobile-view-map .sidebar-context,
  .app-shell.mobile-view-map .region-disclaimer,
  .app-shell.mobile-view-map .toolbar,
  .app-shell.mobile-view-map .status,
  .app-shell.mobile-view-map .bin-list {
    pointer-events: auto;
  }

  .app-shell.mobile-view-list .map-panel {
    visibility: hidden;
  }

  .mobile-view-bar {
    display: flex;
    position: relative;
    z-index: 550;
    flex-shrink: 0;
    gap: 0;
    padding: 6px 12px calc(6px + env(safe-area-inset-bottom, 0px));
    background: var(--panel);
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.06);
  }

  .mobile-view-btn {
    flex: 1;
    padding: 10px 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
  }

  .mobile-view-btn.is-active {
    background: #eff6ff;
    color: var(--primary);
  }

  .app-shell .site-footer--compact {
    display: none;
  }

  .home-region-selectors,
  .home-stats,
  .home-action-links {
    grid-template-columns: 1fr;
  }

  .site-footer-inner {
    gap: 8px 12px;
  }

  .site-footer-copy {
    width: 100%;
    text-align: center;
    order: 3;
  }

  .site-footer-nav {
    justify-content: center;
    width: 100%;
    order: 2;
  }

  .site-footer-brand {
    order: 1;
    margin: 0 auto;
  }
}
