:root {
  color-scheme: light;
  --map-paper: #f7f7f4;
  --map-ink: #101010;
  --map-muted: #73736e;
  --map-soft: #ffffff;
  --map-line: #dfdfd8;
  --map-press: #eeeeea;
  --map-accent: #26806f;
  --map-blue: #496f8a;
  --map-shadow: 0 18px 44px rgba(20, 20, 20, 0.08);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body.map-standalone {
  margin: 0;
  overflow: hidden;
  background: var(--map-paper);
  color: var(--map-ink);
  font-family:
    Inter, "Pretendard", "Noto Sans KR", "Noto Sans SC", "Microsoft YaHei",
    sans-serif;
  letter-spacing: 0;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

:where(.map-root, body.map-standalone) button,
:where(.map-root, body.map-standalone) input {
  font: inherit;
}

:where(.map-root, body.map-standalone) button {
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
}

[hidden] {
  display: none !important;
}

.map-root {
  position: fixed;
  inset: 0;
  z-index: 4;
  background: var(--map-paper);
  color: var(--map-ink);
  font-family:
    Inter, "Pretendard", "Noto Sans KR", "Noto Sans SC", "Microsoft YaHei",
    sans-serif;
  letter-spacing: 0;
}

.map-root[hidden] {
  display: none !important;
}

.map-shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(100%, 520px);
  margin: 0 auto;
  padding:
    max(12px, env(safe-area-inset-top))
    calc(env(safe-area-inset-right) + 18px)
    calc(env(safe-area-inset-bottom) + 16px)
    calc(env(safe-area-inset-left) + 18px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(247, 247, 244, 0.98) 42%),
    var(--map-paper);
  opacity: 0;
  transform: translateY(18px) scale(0.985);
  transition:
    opacity 360ms ease,
    transform 440ms cubic-bezier(0.18, 0.88, 0.2, 1);
}

:where(.map-root.is-map-ready, body.map-standalone.is-map-ready) .map-shell {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.map-topbar,
.map-library,
.map-detail {
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 360ms ease,
    transform 440ms cubic-bezier(0.18, 0.88, 0.2, 1);
}

:where(.map-root.is-map-ready, body.map-standalone.is-map-ready) .map-topbar,
:where(.map-root.is-map-ready, body.map-standalone.is-map-ready) .map-library,
:where(.map-root.is-map-ready, body.map-standalone.is-map-ready) .map-detail {
  opacity: 1;
  transform: translateY(0);
}

:where(.map-root.is-map-ready, body.map-standalone.is-map-ready) .map-topbar {
  transition-delay: 40ms;
}

:where(.map-root.is-map-ready, body.map-standalone.is-map-ready) .map-library,
:where(.map-root.is-map-ready, body.map-standalone.is-map-ready) .map-detail {
  transition-delay: 90ms;
}

.map-topbar {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 12px;
  min-height: 56px;
}

.map-title {
  min-width: 0;
  text-align: center;
}

.map-title p {
  margin: 0 0 2px;
  color: var(--map-muted);
  font-size: 0.64rem;
  font-weight: 850;
  line-height: 1;
}

.map-title h1 {
  margin: 0;
  overflow: hidden;
  font-size: 1.02rem;
  font-weight: 850;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-icon-button,
.map-small-icon-button,
.map-nav-button {
  display: grid;
  place-items: center;
  border: 1px solid var(--map-line);
  background: rgba(255, 255, 255, 0.76);
  cursor: pointer;
  transition:
    background 150ms ease,
    color 150ms ease,
    opacity 150ms ease,
    transform 150ms ease;
}

.map-icon-button {
  width: 42px;
  aspect-ratio: 1;
  border-radius: 8px;
}

.map-small-icon-button {
  width: 32px;
  aspect-ratio: 1;
  border-radius: 8px;
}

.map-icon-button:active,
.map-small-icon-button:active,
.map-nav-button:active {
  background: var(--map-press);
  transform: scale(0.96);
}

.map-icon-button[aria-pressed="true"] {
  border-color: var(--map-ink);
  background: var(--map-ink);
  color: #fff;
}

.map-icon-button svg,
.map-small-icon-button svg,
.map-nav-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.55;
}

.map-library {
  min-height: 0;
  overflow: auto;
  padding: 18px 0 6px;
  scrollbar-width: none;
}

.map-library::-webkit-scrollbar {
  display: none;
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
}

.map-card {
  display: grid;
  min-width: 0;
  gap: 9px;
  padding: 8px;
  border: 1px solid var(--map-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: inherit;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 10px 26px rgba(18, 18, 18, 0.045);
  transition:
    background 150ms ease,
    transform 150ms ease,
    box-shadow 150ms ease;
}

.map-card:active {
  background: var(--map-press);
  box-shadow: 0 6px 16px rgba(18, 18, 18, 0.04);
  transform: scale(0.98);
}

.map-thumb {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 1 / 1.14;
  border: 1px solid rgba(16, 16, 16, 0.08);
  border-radius: 7px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(232, 234, 228, 0.72)),
    var(--map-soft);
}

.map-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.map-canvas {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  transition: transform 120ms ease;
  will-change: transform;
}

.map-canvas.is-dragging {
  transition: none;
}

.map-surface img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--map-soft);
}

.map-card-meta {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.map-card-name {
  overflow: hidden;
  font-size: 0.91rem;
  font-weight: 850;
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-card-date {
  color: var(--map-muted);
  font-size: 0.72rem;
  font-weight: 760;
  line-height: 1.2;
}

.map-empty {
  display: grid;
  grid-column: 1 / -1;
  min-height: 56vh;
  place-items: center;
  color: var(--map-muted);
  font-size: 0.92rem;
  font-weight: 800;
  text-align: center;
}

.map-detail {
  position: relative;
  min-height: 0;
  overflow: hidden;
  padding-top: 14px;
}

.map-carousel {
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  touch-action: pan-y;
}

.map-track {
  display: flex;
  height: 100%;
  min-height: 0;
  transition: transform 340ms cubic-bezier(0.18, 0.88, 0.2, 1);
  will-change: transform;
}

.map-slide {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  flex: 0 0 100%;
  min-width: 0;
  min-height: 0;
  padding: 0 2px 4px;
}

.map-surface {
  position: relative;
  overflow: hidden;
  min-height: 0;
  border: 1px solid var(--map-line);
  border-radius: 8px;
  background: var(--map-soft);
  box-shadow: var(--map-shadow);
}

.map-place-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.map-zoom-controls {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 4;
  display: grid;
  gap: 6px;
}

.map-zoom-button {
  display: grid;
  width: 34px;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid var(--map-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--map-ink);
  box-shadow: 0 8px 20px rgba(20, 20, 20, 0.09);
  cursor: pointer;
  transition:
    background 150ms ease,
    opacity 150ms ease,
    transform 150ms ease;
}

.map-zoom-button:active {
  background: var(--map-press);
  transform: scale(0.95);
}

.map-zoom-button:disabled {
  cursor: default;
  opacity: 0.38;
}

.map-zoom-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.map-place {
  position: absolute;
  z-index: 2;
  display: grid;
  min-width: 28px;
  min-height: 28px;
  place-items: center;
  transform: translate(-50%, -100%);
  pointer-events: auto;
}

.map-place::before {
  position: absolute;
  inset: auto auto -8px 50%;
  width: 10px;
  height: 10px;
  border-right: 1px solid rgba(255, 255, 255, 0.74);
  border-bottom: 1px solid rgba(255, 255, 255, 0.74);
  background: var(--place-color, var(--map-accent));
  transform: translateX(-50%) rotate(45deg);
  content: "";
}

.map-place span {
  position: relative;
  display: block;
  max-width: 112px;
  overflow: hidden;
  padding: 6px 9px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 999px;
  background: var(--place-color, var(--map-accent));
  color: #fff;
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1.12;
  text-overflow: ellipsis;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.18);
  white-space: nowrap;
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.16);
}

.map-slide-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 10px 2px 0;
  color: var(--map-muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.map-slide-footer strong {
  overflow: hidden;
  color: var(--map-ink);
  font-size: 0.88rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-slide-footer time {
  flex: 0 0 auto;
  color: var(--map-blue);
  font-variant-numeric: tabular-nums;
}

.map-nav-button {
  position: absolute;
  top: 50%;
  z-index: 3;
  width: 34px;
  aspect-ratio: 1;
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(20, 20, 20, 0.08);
  transform: translateY(-50%);
}

.map-nav-button:active {
  transform: translateY(-50%) scale(0.96);
}

.map-nav-button:disabled {
  cursor: default;
  opacity: 0;
  pointer-events: none;
}

.map-nav-prev {
  left: 10px;
}

.map-nav-next {
  right: 10px;
}

.map-editor {
  position: absolute;
  top: 14px;
  right: 0;
  bottom: 4px;
  z-index: 5;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(58%, 236px);
  padding: 12px;
  border: 1px solid var(--map-line);
  border-radius: 8px 0 0 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: -18px 0 44px rgba(20, 20, 20, 0.12);
  transform: translateX(108%);
  transition: transform 260ms cubic-bezier(0.18, 0.88, 0.2, 1);
}

.map-detail.is-editing .map-editor {
  transform: translateX(0);
}

.map-place-form {
  display: grid;
  gap: 12px;
  align-content: start;
}

.map-editor-head,
.map-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.map-editor-head span,
.map-modal-head h2 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 880;
  line-height: 1.2;
}

.map-field {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.map-field span,
.map-switch-row > span {
  color: var(--map-muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.2;
}

.map-field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--map-line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--map-ink);
  outline: none;
}

.map-field input:focus {
  border-color: var(--map-ink);
  box-shadow: 0 0 0 3px rgba(16, 16, 16, 0.08);
}

.map-color-field input[type="color"] {
  height: 46px;
  padding: 3px;
  cursor: pointer;
}

.map-status {
  min-height: 18px;
  margin: 0;
  color: #b3261e;
  font-size: 0.76rem;
  font-weight: 740;
  line-height: 1.35;
}

.map-status.is-success {
  color: #176b3a;
}

.map-place-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-top: 12px;
  scrollbar-width: none;
}

.map-place-list::-webkit-scrollbar {
  display: none;
}

.map-place-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 6px 7px;
  border: 1px solid var(--map-line);
  border-radius: 8px;
  background: rgba(247, 247, 244, 0.72);
}

.map-place-swatch {
  width: 14px;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  background: var(--place-color);
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.12);
}

.map-place-row-name {
  overflow: hidden;
  font-size: 0.79rem;
  font-weight: 820;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-place-row button {
  display: grid;
  width: 30px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 7px;
  color: var(--map-muted);
  cursor: pointer;
}

.map-place-row button:active {
  background: var(--map-press);
}

.map-place-row svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.map-place-empty {
  margin: 0;
  color: var(--map-muted);
  font-size: 0.78rem;
  font-weight: 780;
}

.map-modal {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(247, 247, 244, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.map-create-form {
  display: grid;
  width: min(100%, 360px);
  max-height: min(720px, 90dvh);
  gap: 13px;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--map-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--map-shadow);
}

.map-source-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--map-line);
  border-radius: 8px;
  background: rgba(247, 247, 244, 0.82);
}

.map-source-tabs label {
  min-width: 0;
}

.map-source-tabs input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.map-source-tabs span {
  display: grid;
  min-height: 36px;
  place-items: center;
  border-radius: 7px;
  color: var(--map-muted);
  font-size: 0.8rem;
  font-weight: 850;
  cursor: pointer;
}

.map-source-tabs input:checked + span {
  background: var(--map-ink);
  color: #fff;
}

.map-switch-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 46px;
  gap: 12px;
}

.map-switch-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.map-switch {
  position: relative;
  display: inline-flex;
  width: 48px;
  height: 28px;
  border: 1px solid var(--map-line);
  border-radius: 999px;
  background: #e7e7e2;
  transition:
    background 160ms ease,
    border-color 160ms ease;
}

.map-switch::before {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
  transition: transform 160ms ease;
  content: "";
}

.map-switch-input:checked + .map-switch {
  border-color: var(--map-accent);
  background: var(--map-accent);
}

.map-switch-input:checked + .map-switch::before {
  transform: translateX(20px);
}

.map-file-field input {
  min-height: auto;
  padding: 10px;
}

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

.map-secondary-button,
.map-primary-button {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 850;
  cursor: pointer;
  transition:
    background 150ms ease,
    opacity 150ms ease,
    transform 150ms ease;
}

.map-secondary-button {
  border: 1px solid var(--map-line);
  background: rgba(247, 247, 244, 0.82);
  color: var(--map-ink);
}

.map-primary-button {
  background: var(--map-ink);
  color: #fff;
}

.map-secondary-button:active,
.map-primary-button:active {
  transform: scale(0.98);
}

.map-primary-button:disabled,
.map-secondary-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

@media (max-width: 380px) {
  .map-grid {
    gap: 10px;
  }

  .map-card {
    padding: 7px;
  }

  .map-place span {
    max-width: 92px;
  }
}

@media (max-height: 620px) {
  .map-shell {
    padding-bottom: calc(env(safe-area-inset-bottom) + 12px);
  }

  .map-library {
    padding-top: 12px;
  }

  .map-editor {
    top: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .map-shell,
  .map-topbar,
  .map-library,
  .map-detail,
  .map-track,
  .map-editor {
    transition-duration: 1ms;
  }
}
