:root {
  --bg: #f5f3ef;
  --panel: #fffdf9;
  --panel-strong: #ffffff;
  --ink: #1c2430;
  --muted: #6a7280;
  --line: #d8d2c7;
  --confirmed: #2563eb;
  --unconfirmed: #be6a15;
  --planned: #168767;
  --stalled: #a43f54;
  --shadow: 0 18px 48px rgba(24, 35, 48, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  height: 100vh;
  min-height: 680px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 249, 0.96);
  backdrop-filter: blur(10px);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #1e293b;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.topbar-metrics {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.topbar-metrics span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 12px;
}

.topbar-metrics strong {
  color: var(--ink);
  font-size: 14px;
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr) 340px;
  min-height: 0;
}

.left-panel,
.detail-panel {
  min-height: 0;
  overflow: auto;
  border-color: var(--line);
  background: var(--panel);
}

.left-panel {
  border-right: 1px solid var(--line);
}

.detail-panel {
  border-left: 1px solid var(--line);
}

.search-section,
.filter-section,
.focus-section,
.list-section {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.search-section label,
.section-title h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 8px;
  margin-top: 10px;
}

.search-row input {
  width: 100%;
  height: 38px;
  border: 1px solid #c8c2b8;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

.search-row button,
.quick-grid button,
.text-button,
.layer-switch button {
  border: 1px solid #c8c2b8;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.search-row button {
  height: 38px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.text-button {
  padding: 5px 8px;
  color: var(--muted);
  font-size: 12px;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  border: 1px solid #c8c2b8;
  border-radius: 8px;
  background: #fff;
  padding: 6px 10px;
  color: var(--ink);
  font-size: 12px;
}

.filter-chip.is-active {
  border-color: #1e293b;
  background: #1e293b;
  color: #fff;
}

.filter-chip small {
  color: inherit;
  opacity: 0.76;
}

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

.quick-grid button {
  height: 36px;
  background: #fbfaf7;
}

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

.project-item {
  width: 100%;
  border: 1px solid #d9d2c8;
  border-radius: 8px;
  background: #fff;
  padding: 11px;
  text-align: left;
}

.project-item.is-active {
  border-color: #1e293b;
  box-shadow: inset 3px 0 0 #1e293b;
}

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

.project-title strong {
  line-height: 1.3;
  font-size: 14px;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 6px;
  padding: 3px 7px;
  background: #eef2f7;
  color: #263244;
  font-size: 11px;
  font-weight: 800;
}

.badge.status-confirmed {
  background: rgba(37, 99, 235, 0.12);
  color: var(--confirmed);
}

.badge.status-unconfirmed {
  background: rgba(190, 106, 21, 0.13);
  color: var(--unconfirmed);
}

.badge.status-progressing {
  background: rgba(124, 58, 237, 0.13);
  color: #6d28d9;
}

.badge.status-discussing {
  background: rgba(15, 118, 110, 0.13);
  color: #0f766e;
}

.badge.status-planned {
  background: rgba(22, 135, 103, 0.13);
  color: var(--planned);
}

.badge.status-stalled {
  background: rgba(164, 63, 84, 0.14);
  color: var(--stalled);
}

.map-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
}

.map {
  width: 100%;
  height: 100%;
  background: #ddd7cd;
}

.map-overlay {
  position: absolute;
  z-index: 600;
  border: 1px solid rgba(34, 43, 54, 0.14);
  border-radius: 8px;
  background: rgba(255, 253, 249, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.map-legend {
  left: 14px;
  bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  font-size: 12px;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.legend-dot.confirmed {
  background: var(--confirmed);
}

.legend-dot.progressing {
  background: #7c3aed;
}

.legend-dot.discussing {
  background: #0f766e;
}

.legend-dot.unconfirmed {
  background: var(--unconfirmed);
}

.legend-dot.planned {
  background: var(--planned);
}

.legend-dot.stalled {
  background: var(--stalled);
}

.layer-switch {
  top: 14px;
  right: 14px;
  display: flex;
  gap: 6px;
  padding: 6px;
}

.layer-switch button {
  min-height: 32px;
  padding: 5px 10px;
  color: var(--muted);
}

.layer-switch button.is-active {
  border-color: #1e293b;
  background: #1e293b;
  color: #fff;
}

.detail-panel {
  padding: 18px;
}

.detail-empty {
  min-height: 220px;
  display: grid;
  align-content: center;
  gap: 8px;
  color: var(--muted);
}

.detail-empty h2,
.detail-card h2 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.25;
}

.detail-empty p {
  margin: 0;
  line-height: 1.55;
}

.detail-kicker {
  color: #8b6f47;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.detail-card {
  display: grid;
  gap: 14px;
}

.detail-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

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

.detail-stat {
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  padding: 10px;
}

.detail-stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.detail-stat strong {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.25;
}

.source-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 7px 10px;
  color: #1e293b;
  text-decoration: none;
  font-weight: 800;
}

.leaflet-popup-content {
  min-width: 220px;
  margin: 12px;
}

.popup-title {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.35;
}

.popup-body {
  display: grid;
  gap: 5px;
  color: #4b5563;
  font-size: 12px;
}

.popup-action {
  width: 100%;
  margin-top: 10px;
  border: 1px solid #1e293b;
  border-radius: 8px;
  background: #1e293b;
  color: #fff;
  min-height: 32px;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .detail-panel {
    position: fixed;
    right: 12px;
    bottom: 12px;
    z-index: 650;
    width: min(380px, calc(100vw - 24px));
    max-height: min(52vh, 460px);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 100vh;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .topbar-metrics {
    width: 100%;
    overflow-x: auto;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 43vh auto;
  }

  .map-panel {
    grid-row: 1;
  }

  .left-panel {
    grid-row: 2;
    border-right: 0;
    border-top: 1px solid var(--line);
    max-height: none;
  }

  .detail-panel {
    right: 8px;
    bottom: 8px;
    width: calc(100vw - 16px);
    max-height: 46vh;
    padding: 14px;
  }

  .brand h1 {
    font-size: 16px;
  }

  .map-legend {
    left: 8px;
    right: 8px;
    bottom: 8px;
  }

  .layer-switch {
    top: 8px;
    right: 8px;
  }
}
