:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #111111;
  --muted: #626873;
  --line: #d8dce2;
  --line-strong: #111111;
  --accent: #00d46a;
  --accent-dark: #007a3d;
  --warn: #f7c948;
  --danger: #d92d20;
  --shadow: 0 12px 32px rgba(17, 17, 17, 0.12);
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
  min-height: 100vh;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--panel);
  border-right: 1px solid var(--line-strong);
}

.panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--line-strong);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 23px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
  line-height: 1.35;
}

.source-link,
.text-button {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 6px;
}

.source-link {
  flex: 0 0 auto;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 700;
}

.source-link:hover,
.text-button:hover {
  background: #111;
  color: #fff;
}

.search-panel {
  flex: 1 1 48%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-bottom: 1px solid var(--line-strong);
  background: var(--panel);
}

.search-tab,
.selected-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 0 22px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
  text-align: left;
}

.search-tab::after,
.selected-tab::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.search-tab__meta,
.selected-tab__meta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  margin-left: auto;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.search-panel.is-collapsed {
  flex: 0 0 auto;
}

.search-panel.is-collapsed .search-panel__content {
  display: none;
}

.search-panel.is-collapsed .search-tab::after,
.selected.is-collapsed .selected-tab::after {
  transform: rotate(-45deg);
}

.search-panel__content {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.search {
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.search__label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search input {
  width: 100%;
  height: 42px;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: none;
}

.search input:focus {
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.28);
}

.status {
  min-height: 19px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status.is-error {
  color: var(--danger);
  font-weight: 700;
}

.search-panel,
.selected {
  min-height: 0;
}

.results {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.selected {
  flex: 1 1 45%;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--line-strong);
  background: var(--panel);
}

.selected.is-collapsed {
  flex: 0 0 auto;
}

.selected.is-collapsed .selected__content {
  display: none;
}

.selected__content {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
}

.section-head span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.selected-actions {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 38px;
  padding: 5px 22px;
  border-bottom: 1px solid var(--line);
}

.selected.has-selection .selected-actions {
  display: flex;
}

.text-button {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.result-list,
.selected-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}

.result-list {
  flex: 0 0 auto;
  max-height: 174px;
  overflow-y: auto;
}

.selected-list {
  flex: 1 1 auto;
}

.result-item,
.selected-item {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 13px 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.result-item {
  display: block;
  padding: 0;
}

.selected-item {
  grid-template-columns: 34px minmax(0, 1fr) 76px;
  align-items: center;
}

.result-item:hover,
.selected-item:hover {
  background: #f8fafc;
}

.item-main {
  min-width: 0;
}

.item-title {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-subtitle {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.booth-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  height: 24px;
  margin-right: 7px;
  padding: 0 8px;
  border-radius: 4px;
  background: #111;
  color: #fff;
  font-size: 12px;
  font-weight: 850;
}

.result-select,
.item-command,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: #111;
  font-weight: 900;
}

.result-select {
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 58px;
  padding: 13px 22px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.result-select.is-added {
  background: rgba(0, 212, 106, 0.12);
}

.result-select:hover,
.item-command:hover,
.icon-button:hover {
  background: #f8fafc;
  color: #111;
}

.result-select:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

.item-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(17, 17, 17, 0.18);
  color: #111;
  font-size: 13px;
  font-weight: 900;
}

.item-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  align-items: center;
}

.item-command {
  height: 34px;
  font-size: 14px;
}

.item-command--remove:hover {
  border-color: var(--danger);
  background: var(--danger);
}

.empty-note {
  margin: 0;
  padding: 18px 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.empty-note.is-hidden {
  display: none;
}

.map-area {
  position: relative;
  min-width: 0;
  min-height: 100vh;
  background: #e8eaee;
}

.map-toolbar {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 25;
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  box-shadow: var(--shadow);
  font-size: 21px;
}

.map-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #eceff3;
}

.map-stage {
  position: relative;
  width: 100%;
  height: 100%;
}

.map-stage svg {
  display: block;
  width: 100%;
  height: 100%;
  background: #fff;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.map-stage svg.is-panning {
  cursor: grabbing;
}

.map-loading,
.map-error {
  display: grid;
  place-items: center;
  height: 100%;
  margin: 0;
  padding: 24px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}

.map-error {
  color: var(--danger);
}

.booth-hotspot {
  cursor: pointer;
}

.booth-hotspot:hover {
  filter: drop-shadow(0 0 5px rgba(17, 17, 17, 0.45));
}

.booth-hotspot:hover rect {
  fill: #111111 !important;
}

.booth-hotspot:hover path,
.booth-hotspot:hover text {
  fill: #ffffff !important;
}

.booth-hotspot.is-selected path,
.booth-hotspot.is-selected text {
  opacity: 0;
}

.booth-popup[hidden] {
  display: none;
}

.booth-popup {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 7;
  display: flex;
  flex-direction: column;
  width: min(420px, calc(100% - 36px));
  max-height: min(420px, calc(100% - 36px));
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.booth-popup__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 9px 12px 9px 14px;
  border-bottom: 1px solid var(--line);
}

.booth-popup__title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.booth-popup__booth {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  height: 25px;
  padding: 0 8px;
  border-radius: 4px;
  background: #111;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.booth-popup__title {
  overflow: hidden;
  font-size: 14px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.booth-popup__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: #111;
  font-size: 20px;
  font-weight: 900;
}

.booth-popup__list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}

.booth-popup__item {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.booth-popup__item.is-added {
  background: rgba(0, 212, 106, 0.12);
}

.booth-popup__item:hover,
.booth-popup__close:hover {
  background: #f8fafc;
}

.booth-popup__name,
.booth-popup__subtitle {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.booth-popup__name {
  font-size: 14px;
  font-weight: 850;
  line-height: 1.3;
}

.booth-popup__subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
}

.selection-fill {
  fill-opacity: 0.5;
  pointer-events: none;
}

.selection-number {
  fill: #111;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.selection-marker.is-hovered .selection-number {
  fill: #ffffff !important;
}

@media (max-width: 980px) {
  .app {
    --search-float-height: 280px;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
  }

  .panel {
    display: contents;
    min-height: auto;
    border-right: 0;
    border-bottom: 0;
  }

  .search-panel,
  .search,
  .selected,
  .map-area {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .search-panel {
    order: 1;
    position: sticky;
    top: 0;
    z-index: 31;
    flex: 0 0 44px;
    max-height: none;
    overflow: visible;
    border-bottom: 1px solid var(--line-strong);
    box-shadow: none;
  }

  .search-tab,
  .selected-tab {
    min-height: 44px;
    padding: 0 18px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .search-panel__content {
    position: fixed;
    top: 44px;
    right: 0;
    left: 0;
    z-index: 35;
    height: var(--search-float-height);
    max-height: var(--search-float-height);
    overflow: hidden;
    border-bottom: 1px solid var(--line-strong);
    background: var(--panel);
  }

  .search-panel:not(.is-collapsed) + .selected {
    transform: translateY(var(--search-float-height, 0px));
  }

  .search {
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .search__label {
    margin-bottom: 6px;
    font-size: 12px;
  }

  .search input {
    display: block;
    width: 100%;
  }

  .search input {
    height: 40px;
    border-radius: 6px;
  }

  .status {
    min-height: 17px;
    margin-top: 7px;
    font-size: 12px;
  }

  .map-area {
    order: 3;
    min-height: 0;
    height: calc(100vh - 88px);
    height: calc(100dvh - 88px);
    border-bottom: 1px solid var(--line-strong);
  }

  .map-toolbar {
    position: absolute;
    top: auto;
    right: 8px;
    bottom: 8px;
    left: auto;
    flex-direction: column;
    width: auto;
    max-width: none;
    transform: none;
    gap: 6px;
    padding: 6px;
    border: 1px solid rgba(17, 17, 17, 0.18);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  .icon-button {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    box-shadow: none;
    font-size: 18px;
  }

  .selected {
    order: 2;
    position: sticky;
    top: 44px;
    z-index: 30;
    flex: 0 0 44px;
    display: flex;
    flex-direction: column;
    max-height: none;
    overflow: visible;
    background: var(--panel);
    border-bottom: 1px solid var(--line-strong);
  }

  .selected__content {
    position: fixed;
    top: 88px;
    right: 0;
    left: 0;
    z-index: 35;
    max-height: min(46dvh, 330px);
    overflow: hidden;
    border-bottom: 1px solid var(--line-strong);
    background: var(--panel);
  }

  .results {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    max-height: none;
    background: var(--panel);
    border-bottom: 0;
  }

  .section-head {
    min-height: 42px;
    padding: 0 18px;
    background: var(--panel);
  }

  h2 {
    font-size: 14px;
  }

  .selected-list {
    display: block;
    max-height: min(38dvh, 292px);
    overflow-x: hidden;
    overflow-y: auto;
  }

  .selected-list:empty {
    display: none;
  }

  .selected-item {
    grid-template-columns: 32px minmax(0, 1fr) 82px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
  }

  .item-index {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .selected-actions {
    justify-content: flex-start;
    padding: 6px 16px;
  }

  .selected-actions .text-button {
    width: auto;
    min-width: 0;
    padding: 0 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  .selected-item:last-child {
    border-bottom: 0;
  }

  .empty-note {
    padding: 12px 18px;
    font-size: 12px;
  }

  .result-list {
    max-height: 168px;
    overflow-y: auto;
  }

  .result-item {
    padding: 0;
  }

  .result-select {
    min-height: 56px;
    padding: 12px 18px;
  }

  .item-title {
    font-size: 14px;
  }

  .item-subtitle {
    font-size: 12px;
  }

  .booth-pill {
    min-width: 56px;
    height: 23px;
    margin-right: 6px;
    font-size: 11px;
  }

  .booth-popup {
    position: fixed;
    right: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 40;
    width: auto;
    max-height: min(42dvh, 320px);
  }
}

@media (max-width: 560px) {
  .search,
  .result-item,
  .selected-item,
  .empty-note {
    padding-left: 16px;
    padding-right: 16px;
  }

  h1 {
    font-size: 18px;
  }

  .selected-item {
    grid-template-columns: 32px minmax(0, 1fr) 82px;
  }

  .map-toolbar {
    right: 8px;
    bottom: 8px;
    left: auto;
    transform: none;
  }

  .icon-button {
    width: 34px;
    height: 34px;
    font-size: 18px;
  }
}
