:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #667085;
  --line: #d7dde5;
  --panel: #ffffff;
  --paper: #eef2f6;
  --accent: #176b87;
  --accent-dark: #0f5066;
  --field: #f8fafc;
  --danger: #a13d35;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Arial, "Noto Sans KR", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

body {
  display: flex;
  align-items: stretch;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

button:hover {
  border-color: #9fb1c4;
}

button.is-active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--field);
  color: var(--ink);
}

select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--field);
  color: var(--ink);
}

label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  color: #344054;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: var(--field);
}

.toggle-row span {
  display: grid;
  gap: 3px;
}

.toggle-row small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.control-panel {
  position: sticky;
  top: 0;
  z-index: 5;
  width: 340px;
  min-width: 340px;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--line);
  padding: 18px;
  background: var(--panel);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.brand p,
.hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.field-label {
  margin: 0;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title-row strong {
  min-width: 42px;
  border-radius: 6px;
  padding: 5px 8px;
  background: #e8f1f4;
  color: var(--accent-dark);
  text-align: center;
}

.panel-section {
  display: grid;
  gap: 12px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.panel-section h2 {
  margin: 0;
  font-size: 15px;
}

.inline-control {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 8px;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.preset-grid.compact button {
  min-height: 32px;
  font-size: 12px;
}

.zoom-preset-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.zoom-preset-grid button {
  min-height: 32px;
  font-size: 12px;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.slot-grid button {
  min-height: 34px;
  font-size: 12px;
}

.guide-list {
  display: grid;
  gap: 10px;
}

.guide-list article {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--field);
}

.guide-list strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.guide-list p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.is-hidden {
  display: none;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.segmented.two {
  grid-template-columns: repeat(2, 1fr);
}

.segmented.three {
  grid-template-columns: repeat(3, 1fr);
}

.segmented button.is-active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.primary-button {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.primary-button:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.workspace {
  flex: 1;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
}

.topbar div {
  display: flex;
  gap: 10px;
  align-items: baseline;
}

#sizeText {
  color: var(--muted);
  font-size: 13px;
}

.map-canvas {
  position: relative;
  width: 100%;
  height: calc(100vh - 58px);
  overflow: hidden;
  background: #dce7df;
}

.map,
.web-map-frame,
.fallback-map {
  position: absolute;
  inset: 0;
}

.web-map-frame {
  z-index: 2;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.map-pan-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.map-pan-overlay.is-dragging {
  cursor: grabbing;
}

.drag-hint {
  position: fixed;
  right: 16px;
  bottom: 16px;
  border-radius: 6px;
  padding: 8px 10px;
  color: #fff;
  background: rgba(23, 32, 42, 0.78);
  font-size: 12px;
  pointer-events: none;
}

.map-canvas.provider-kakao .web-map-frame {
  left: -380px;
  top: -92px;
  width: calc(100% + 780px);
  height: calc(100% + 92px);
}

.map-canvas.provider-naver .web-map-frame {
  left: -620px;
  top: -86px;
  width: calc(100% + 1120px);
  height: calc(100% + 150px);
}

.map {
  z-index: 1;
}

.fallback-map {
  z-index: 0;
  background:
    linear-gradient(115deg, rgba(23, 107, 135, 0.18), transparent 35%),
    linear-gradient(35deg, rgba(231, 196, 83, 0.2), transparent 40%),
    #dfe9e3;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(23, 32, 42, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 32, 42, 0.08) 1px, transparent 1px);
  background-size: 80px 80px;
}

.preview-pin {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50% 50% 50% 0;
  transform: translate(-50%, -80%) rotate(-45deg);
  background: var(--danger);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.preview-pin span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
}

.preview-label {
  position: absolute;
  left: 50%;
  top: calc(50% + 44px);
  width: min(360px, 80vw);
  padding: 14px 16px;
  border: 1px solid rgba(23, 32, 42, 0.14);
  border-radius: 8px;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.88);
  text-align: center;
}

.preview-label p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 820px) {
  body {
    display: block;
  }

  .control-panel {
    position: relative;
    width: 100%;
    min-width: 0;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .topbar {
    position: relative;
  }

  .workspace {
    height: auto;
    overflow: visible;
  }

  .map-canvas {
    height: 70vh;
  }
}
