.mode-tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 58px;
  padding: 0 26px;
  border-bottom: 1px solid #e5ebf4;
  background: #fff;
}

.mode-tabs button {
  min-height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #66738b;
  font-weight: 900;
}

.mode-tabs button.active {
  background: #eef4ff;
  color: var(--blue);
}

.mode-tabs span {
  margin-left: auto;
  color: #97a4ba;
  font-weight: 800;
}

.label-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: calc(100vh - 112px);
}

.label-panel {
  padding: 20px;
  border-right: 1px solid #e1e7f0;
  background: #fff;
}

.road-preview {
  position: relative;
  height: 172px;
  overflow: hidden;
  border-radius: 9px;
  background: linear-gradient(#1f2b42, #0c111c);
}

.preview-img {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 저장된 박스를 미리보기 위에 표시(닫아도 유지) */
.preview-boxes {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.preview-boxes .pbox {
  position: absolute;
  border: 2px solid var(--cyan);
  background: rgba(16, 212, 210, 0.14);
}

.preview-boxes .pbox.red {
  border-color: var(--red);
  background: rgba(239, 68, 68, 0.16);
}

.preview-boxes .pbox.orange {
  border-color: var(--orange);
  background: rgba(245, 158, 11, 0.16);
}

.preview-boxes .pbox span {
  position: absolute;
  top: -15px;
  left: -2px;
  padding: 0 4px;
  border-radius: 3px;
  background: rgba(7, 11, 20, 0.8);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  white-space: nowrap;
}

/* 실제 이미지가 올라오면 CSS 가짜 도로 placeholder는 숨긴다. */
.road-preview.has-image .road,
.road-preview.has-image .lane {
  display: none;
}

.btn.wide {
  display: flex;
  width: 100%;
  margin-top: 10px;
}

/* ── 라벨링 모달 (큰 이미지 + 박스 그리기/편집) ───────────────── */
.label-modal {
  position: relative;
}

/* 저장 확인 다이얼로그 (모달 내부 오버레이) */
.confirm-save {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 22, 0.5);
}

.confirm-save[hidden] {
  display: none;
}

.confirm-box {
  width: min(360px, 86%);
  padding: 22px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(8, 12, 22, 0.35);
  text-align: center;
}

.confirm-box p {
  margin: 0 0 18px;
  font-weight: 700;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.label-modal .modal-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 0;
  min-height: 0;
}

.canvas-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: #0c111c;
  overflow: auto;
}

/* stage는 이미지에 딱 맞게 줄어들어, 박스 좌표(%)가 이미지에 정확히 정렬된다. */
.canvas-stage {
  position: relative;
  display: inline-block;
  line-height: 0;
  cursor: crosshair;
  touch-action: none;
}

.canvas-img {
  display: block;
  max-width: 100%;
  max-height: 72vh;
  width: auto;
  height: auto;
  border-radius: 6px;
  user-select: none;
  -webkit-user-drag: none;
}

.canvas-img:not([src]),
.canvas-img[src=""] {
  display: none;
}

.canvas-fallback {
  display: grid;
  place-items: center;
  width: 460px;
  max-width: 70vw;
  height: 300px;
  color: #8a97ad;
  font-weight: 700;
  background: #141b28;
  border: 1px dashed #2a3852;
  border-radius: 8px;
  line-height: 1.5;
  text-align: center;
  padding: 0 20px;
}

.canvas-stage.has-image .canvas-fallback {
  display: none;
}

.canvas-boxes {
  position: absolute;
  inset: 0;
}

.draw-box {
  position: absolute;
  border: 2px solid var(--blue);
  background: rgba(37, 99, 255, 0.16);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.draw-box.selected {
  border-color: var(--cyan);
  background: rgba(16, 212, 210, 0.2);
}

.draw-box .tag {
  position: absolute;
  top: -19px;
  left: -2px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  line-height: 1.5;
}

.label-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-left: 1px solid var(--line);
  overflow: auto;
}

.label-side .field {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: #475569;
}

.label-side .field input[type="text"],
.label-side .modal-class {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  font-weight: 600;
}

.modal-actions,
.modal-export {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal-export {
  margin-top: auto;
}

.label-side h4 {
  margin: 6px 0 0;
  font-size: 13px;
}

.box-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  max-height: 34vh;
  overflow: auto;
}

.box-list li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--line-soft, #eef2f6);
  border-radius: 7px;
  background: #fff;
}

.box-list li.selected {
  border-color: var(--blue);
  background: #f3f7ff;
}

.box-list input {
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  font-weight: 700;
}

.box-list .conf {
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
}

.box-list .del {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: #fdeaea;
  color: var(--red);
  font-weight: 900;
  cursor: pointer;
}

.modal-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.btn.flat {
  border-color: transparent;
  background: #eef1f6;
  color: #475569;
}

.result-hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.road {
  position: absolute;
  left: 54px;
  right: 54px;
  bottom: -20px;
  height: 162px;
  clip-path: polygon(36% 0, 64% 0, 100% 100%, 0 100%);
  background: #2c3750;
}

.lane {
  position: absolute;
  left: 50%;
  top: 46px;
  width: 4px;
  height: 28px;
  border-radius: 999px;
  background: #8d98ad;
}

.sample {
  display: flex;
  justify-content: space-between;
  margin: 8px 0 16px;
  color: #718097;
}

.sample a {
  color: var(--blue);
  font-weight: 900;
}

.label-panel h3 {
  margin: 14px 0 10px;
}

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

.radio-list label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #334155;
  font-weight: 900;
}

.radio-list label.active {
  border-color: #85a6ff;
  background: #eff5ff;
  color: var(--blue);
}

.radio-list span {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border: 2px solid #b8c3d5;
  border-radius: 50%;
}

.radio-list label.active span {
  border-color: var(--blue);
  background: var(--blue);
}

.radio-list label.active span::after {
  content: "✓";
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

textarea {
  width: 100%;
  height: 78px;
  resize: none;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.label-panel .btn {
  display: flex;
  width: 100%;
  margin-top: 16px;
}

.result-panel {
  padding: 22px 26px;
}

.result-card {
  padding: 18px;
  border: 2px solid var(--blue);
}

.answer-head,
.answer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.answer-head h3 {
  margin: 0;
  font-size: 17px;
}

.finding-list {
  margin: 14px 0 18px;
  padding: 0 0 14px;
  border-bottom: 1px solid #e7ecf4;
  list-style: none;
}

.finding-list li {
  margin: 10px 0;
  color: #334155;
  font-size: 14px;
}

.badge {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  margin-right: 12px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
}

.badge.red {
  background: var(--red);
}

.badge.orange {
  background: var(--orange);
}

@media (max-width: 1200px) {
  .label-layout {
    grid-template-columns: 1fr;
  }
}
