:root {
  color: #f1f5f9;
  background: #000000;
  font-family:
    Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  background: #000000;
  display: flex;
  flex-direction: column;
  height: 100%;
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
}

button,
input {
  font: inherit;
}

.v2-shell {
  box-sizing: border-box;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  margin: 0 auto;
  max-width: 1820px;
  min-height: 0;
  overflow: hidden;
  padding: 24px;
  width: 100%;
}

.v2-board-stack > .v2-hero {
  flex-shrink: 0;
}

.v2-hero,
.map-card,
.board-card {
  background: #72727a;
  border: 1px solid #5c5c64;
  border-radius: 24px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  color: #f9fafb;
}

.v2-hero {
  align-items: center;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 26px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: 28px;
  margin-bottom: 0;
}

.v2-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.primary-button,
.secondary-link,
.icon-button {
  border-radius: 999px;
  cursor: pointer;
  font-weight: 900;
  padding: 13px 18px;
}

.primary-button {
  background: #2563eb;
  border: 0;
  color: #ffffff;
}

.secondary-link {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1d4ed8;
  display: inline-block;
  text-align: center;
  text-decoration: none;
}

button.secondary-link {
  cursor: pointer;
  font: inherit;
}

.secondary-link:hover {
  background: #f8fafc;
}

.section-heading {
  align-items: center;
  border-bottom: 1px solid #5c5c64;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 18px 20px;
}

.section-heading h2 {
  color: #f9fafb;
  font-size: 18px;
  margin-bottom: 4px;
}

.section-heading p {
  color: #e5e7eb;
  font-size: 13px;
  margin-bottom: 0;
}

.map-provider-hint {
  color: #b45309;
  font-size: 12px;
  line-height: 1.4;
  margin: 10px 0 0;
  max-width: 52rem;
}

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.map-layer-button.is-active {
  background: #1d4ed8;
  border-color: #1e40af;
  color: #ffffff;
}

.records-map {
  border-radius: 0 0 24px 24px;
  height: 420px;
  overflow: hidden;
}

/* 왼쪽 지도(전체 높이)·오른쪽: 헤더+보드(동일 폭). 좁으면 세로 스택. */
.v2-board-stack {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  min-width: 0;
}

.v2-board-stack .v2-hero {
  margin-top: 0;
}

.v2-map-board-layout {
  align-items: stretch;
  display: flex;
  flex: 1 1 auto;
  flex-direction: row;
  gap: 16px;
  margin-top: 0;
  min-height: 0;
}

.v2-map-board-layout .map-card,
.v2-map-board-layout .board-card,
.v2-map-board-layout .v2-hero {
  margin-top: 0;
}

.v2-map-board-layout .map-card {
  display: flex;
  flex: 0 0 clamp(280px, 32vw, 440px);
  flex-direction: column;
  min-height: 0;
}

.v2-map-board-layout--map-hidden .map-card {
  display: none;
}

.v2-map-board-layout--map-hidden .v2-board-stack {
  flex: 1 1 auto;
  max-width: 100%;
  min-width: 0;
}

.v2-map-board-layout .map-card .records-map {
  flex: 1 1 auto;
  height: auto;
  min-height: 160px;
}

.v2-map-board-layout .board-card {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.v2-map-board-layout .board-card .section-heading {
  flex-shrink: 0;
}

.v2-map-board-layout .board-scroll {
  flex: 1 1 auto;
  min-height: 0;
}

@media (max-width: 960px) {
  .v2-map-board-layout {
    flex-direction: column;
    min-height: 0;
  }

  .v2-map-board-layout .v2-board-stack {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
  }

  .v2-map-board-layout .map-card {
    flex: 0 0 auto;
    max-width: 100%;
  }

  .v2-map-board-layout .map-card .records-map {
    flex: none;
    height: 360px;
    min-height: 240px;
  }

}

/* Keep the map usable even if the external Leaflet CSS is slow or blocked. */
.leaflet-container {
  font-family: inherit;
  overflow: hidden;
  position: relative;
  z-index: 0;
}

/* Leaflet pane z-order: 위성 타일 등으로 바꿔도 마커·팝업이 타일 위에 오도록 고정 */
.leaflet-container .leaflet-tile-pane {
  z-index: 200 !important;
}

.leaflet-container .leaflet-overlay-pane {
  z-index: 400 !important;
}

.leaflet-container .leaflet-shadow-pane {
  z-index: 500 !important;
}

.leaflet-container .leaflet-marker-pane {
  z-index: 600 !important;
}

.leaflet-container .leaflet-tooltip-pane {
  z-index: 650 !important;
}

.leaflet-container .leaflet-popup-pane {
  z-index: 700 !important;
}

.leaflet-pane,
.leaflet-map-pane,
.leaflet-tile,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  left: 0;
  position: absolute;
  top: 0;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
}

.leaflet-tile {
  border: 0;
  filter: inherit;
  height: 256px;
  max-width: none;
  width: 256px;
}

.leaflet-tile-container img {
  display: block;
}

.leaflet-marker-icon,
.leaflet-marker-shadow {
  display: block;
}

.leaflet-control-container .leaflet-top,
.leaflet-control-container .leaflet-bottom {
  pointer-events: none;
  position: absolute;
  z-index: 1000;
}

.leaflet-top {
  top: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-control {
  clear: both;
  float: left;
  pointer-events: auto;
}

.leaflet-right .leaflet-control {
  float: right;
}

.leaflet-top .leaflet-control {
  margin-top: 10px;
}

.leaflet-bottom .leaflet-control {
  margin-bottom: 10px;
}

.leaflet-left .leaflet-control {
  margin-left: 10px;
}

.leaflet-right .leaflet-control {
  margin-right: 10px;
}

.record-marker {
  align-items: center;
  background: #2563eb;
  border: 3px solid #ffffff;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
  color: #ffffff;
  display: flex;
  font-size: 13px;
  font-weight: 900;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.record-marker.selected-marker {
  background: #dc2626;
  box-shadow: 0 10px 28px rgba(220, 38, 38, 0.42);
  transform: scale(1.16);
}

.board-tools {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.tool-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.tool-button {
  align-items: center;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-sizing: border-box;
  color: #0f172a;
  cursor: pointer;
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  justify-content: center;
  line-height: 1.2;
  padding: 9px 14px;
}

.board-scroll {
  overflow: auto;
}

.record-board {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1240px;
  width: 100%;
}

.record-board th {
  background: #5e5e66;
  border-bottom: 1px solid #52525a;
  color: #f3f4f6;
  font-size: 13px;
  padding: 12px;
  position: sticky;
  text-align: left;
  top: 0;
  z-index: 1;
}

.board-col-header-toggle {
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: #f3f4f6;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  line-height: 1.35;
  margin: 0;
  padding: 4px 6px;
  text-align: left;
  width: 100%;
}

.board-col-header-toggle:hover {
  background: rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
}

.board-col-header-toggle:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.record-board th.board-col--collapsed {
  max-width: 2.75rem;
  min-width: 2.75rem;
  padding: 8px 4px;
  text-align: center;
  vertical-align: middle;
  width: 2.75rem;
}

.record-board th.board-col--collapsed .board-col-header-toggle {
  background: #52525a;
  color: #e5e7eb;
  font-weight: 600;
  min-height: 5.5rem;
  padding: 6px 2px;
  text-align: center;
  text-orientation: mixed;
  white-space: nowrap;
  width: 100%;
  writing-mode: vertical-rl;
}

.record-board th.board-col--collapsed .board-col-header-toggle:hover {
  background: #46464e;
  color: #ffffff;
}

/* 본문 칸은 display:none 금지: 열이 <thead>와 개수가 맞지 않아 뒤쪽 열이 밀린다. */
.record-board td.board-col--collapsed {
  border-bottom: 1px solid #e2e8f0;
  box-sizing: border-box;
  font-size: 0;
  line-height: 0;
  max-width: 2.75rem;
  min-width: 2.75rem;
  overflow: hidden;
  padding: 0 !important;
  vertical-align: middle;
  width: 2.75rem;
}

.record-board td.board-col--collapsed > * {
  display: none !important;
}

.record-board td {
  background: #f1f5f9;
  border-bottom: 1px solid #d1d5db;
  padding: 14px 12px;
  vertical-align: top;
}

.record-board tr:hover td {
  background: #f8fafc;
}

.record-board tr {
  cursor: pointer;
}

.record-board tr.selected-row td {
  background: #eff6ff;
  border-bottom-color: #bfdbfe;
  border-top: 1px solid #bfdbfe;
}

.record-board tr:focus-visible td {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

.survey-number-cell {
  min-width: 64px;
  text-align: center;
  white-space: nowrap;
}

.survey-badge {
  color: #0f172a;
  font-size: 16px;
}

.subject-number-cell {
  min-width: 88px;
}

.subject-number-input {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 12px;
  max-width: 88px;
  padding: 4px 6px;
  width: 100%;
}

.subject-number-input::placeholder {
  color: #94a3b8;
  font-size: 10px;
}

.subject-number-input:focus {
  border-color: #2563eb;
  outline: 2px solid rgba(37, 99, 235, 0.25);
  outline-offset: 0;
}

.remarks-cell {
  min-width: 140px;
  vertical-align: top;
}

.remarks-input {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-sizing: border-box;
  display: block;
  font: inherit;
  line-height: 1.45;
  max-width: 260px;
  min-height: 72px;
  padding: 8px 10px;
  resize: vertical;
  width: 100%;
}

.remarks-input:focus {
  border-color: #2563eb;
  outline: 2px solid rgba(37, 99, 235, 0.25);
  outline-offset: 0;
}

.text-cell {
  max-width: min(520px, 38vw);
  min-width: 240px;
}

.ai-result-cell.text-cell {
  max-width: min(300px, 24vw);
  min-width: 200px;
}

.text-preview-button {
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  background: transparent;
  border: 0;
  color: #334155;
  cursor: zoom-in;
  display: -webkit-box;
  line-height: 1.5;
  max-height: 7.5em;
  overflow: hidden;
  padding: 0;
  text-align: left;
  white-space: pre-wrap;
  width: 100%;
}

.text-preview-button:hover {
  color: #1d4ed8;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ai-result-cell .text-preview-button {
  color: #312e81;
  font-weight: 700;
}

.empty-text {
  color: #94a3b8;
}

.photo-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 360px;
}

.photo-strip--empty {
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  box-sizing: border-box;
  min-height: 120px;
  min-width: 240px;
}

.thumb-button {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  cursor: zoom-in;
  overflow: hidden;
  padding: 0;
  text-align: left;
  width: 118px;
}

.thumb-button[draggable="true"] {
  cursor: grab;
}

.thumb-button[draggable="true"]:active {
  cursor: grabbing;
}

.photo-strip--drag-over {
  background: #eff6ff;
  border-radius: 12px;
  outline: 2px dashed #2563eb;
  outline-offset: 4px;
}

.delete-col,
.delete-cell {
  text-align: center;
  white-space: nowrap;
  width: 88px;
}

.record-delete-button {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
  padding-inline: 10px;
}

.record-delete-button:hover {
  background: #fee2e2;
}

.thumb-button img {
  aspect-ratio: 4 / 3;
  background: #cbd5e1;
  display: block;
  object-fit: cover;
  width: 100%;
}

.thumb-button .thumb-missing {
  align-items: center;
  aspect-ratio: 4 / 3;
  background: #fee2e2;
  box-sizing: border-box;
  color: #991b1b;
  display: flex;
  font-size: 11px;
  font-weight: 800;
  justify-content: center;
  line-height: 1.3;
  padding: 8px;
  text-align: center;
  width: 100%;
}

.thumb-caption {
  color: #334155;
  display: block;
  font-size: 11px;
  font-weight: 800;
  padding: 8px;
}

.photo-more-button {
  align-self: stretch;
  background: #eff6ff;
  border: 1px dashed #93c5fd;
  border-radius: 14px;
  color: #1d4ed8;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  min-height: 112px;
  padding: 12px;
  width: 118px;
}

.audio-list {
  display: grid;
  gap: 10px;
  min-width: 200px;
}

.record-board td:has(.audio-list) {
  min-width: 210px;
}

.audio-item {
  border: 1px solid #fecdd3;
  border-radius: 14px;
  background: #fff1f2;
  padding: 10px;
}

.audio-label {
  color: #9f1239;
  display: block;
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 8px;
}

.audio-player {
  display: block;
  height: 34px;
  max-width: 240px;
  width: 100%;
}

.photo-modal[hidden],
.text-modal[hidden] {
  display: none;
}

.photo-modal,
.text-modal {
  inset: 0;
  position: fixed;
  z-index: 50;
}

.photo-modal-backdrop {
  background: rgba(15, 23, 42, 0.74);
  inset: 0;
  position: absolute;
}

.photo-modal-dialog {
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.45);
  display: flex;
  flex-direction: column;
  left: 50%;
  max-height: calc(100vh - 32px);
  max-width: min(1480px, calc(100vw - 32px));
  overflow: hidden;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
}

.photo-modal-toolbar {
  align-items: center;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  justify-content: flex-start;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 12px;
}

.photo-modal-toolbar__main {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 4px;
  min-width: min-content;
}

.photo-modal-tool-group {
  align-items: center;
  display: inline-flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 3px;
}

.photo-modal-toolbar .tool-button,
.photo-modal-toolbar .photo-modal-color-trigger {
  align-items: center;
  border-radius: 6px;
  box-sizing: border-box;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 800;
  height: 28px;
  justify-content: center;
  line-height: 1.1;
  min-height: 28px;
  min-width: 0;
  padding: 0 7px;
  white-space: nowrap;
  width: auto;
}

.photo-modal-color-trigger {
  gap: 5px;
}

.photo-modal-color-trigger .photo-modal-color-preview {
  flex-shrink: 0;
  height: 12px;
  width: 12px;
}

.photo-modal-toolbar .photo-modal-label {
  color: #475569;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 800;
  margin: 0;
}

.photo-modal-toolbar input[type="range"] {
  flex: 0 0 auto;
  width: 68px;
}

.photo-modal-width-badge {
  color: #334155;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 800;
  min-width: 36px;
}

.photo-modal-color-wrap {
  display: inline-flex;
  flex: 0 0 auto;
  position: relative;
  vertical-align: middle;
}

.photo-modal-color-preview {
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  box-sizing: border-box;
  display: inline-block;
  flex-shrink: 0;
  height: 20px;
  width: 20px;
}

.photo-modal-color-popover {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.22);
  display: flex;
  flex-direction: column;
  gap: 10px;
  left: 0;
  min-width: 216px;
  padding: 12px;
  position: absolute;
  top: calc(100% + 6px);
  z-index: 60;
}

.photo-modal-color-popover[hidden] {
  display: none !important;
}

.photo-modal-color-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, 1fr);
}

.photo-modal-color-swatch {
  border: 2px solid rgba(15, 23, 42, 0.22);
  border-radius: 10px;
  cursor: pointer;
  height: 40px;
  margin: 0;
  padding: 0;
}

.photo-modal-color-swatch--light {
  border-color: #94a3b8;
}

.photo-modal-color-swatch:hover,
.photo-modal-color-swatch:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.photo-modal-color-swatch[aria-selected="true"] {
  box-shadow:
    0 0 0 2px #ffffff,
    0 0 0 4px #1e293b;
}

.photo-modal-color-close-btn {
  align-self: stretch;
  font-size: 13px;
}

.photo-modal-danger {
  background: #fef2f2 !important;
  border-color: #fecaca !important;
  color: #991b1b !important;
}

.photo-modal-danger:hover {
  background: #fee2e2 !important;
}

.photo-modal-toolbar .tool-button[aria-pressed="true"] {
  background: #1d4ed8;
  border-color: #1e40af;
  color: #ffffff;
}

.photo-modal-viewport {
  align-items: center;
  background: #0f172a;
  display: flex;
  flex: 1;
  justify-content: center;
  min-height: 200px;
  overflow: hidden;
  position: relative;
  touch-action: none;
}

.photo-modal-viewport:not(.photo-modal-viewport--pen) {
  cursor: grab;
}

.photo-modal-viewport:not(.photo-modal-viewport--pen):active {
  cursor: grabbing;
}

.photo-modal-viewport.photo-modal-viewport--pen {
  cursor: crosshair;
}

.photo-modal-viewport.photo-modal-viewport--pen.photo-modal-viewport--text-tool {
  cursor: text;
}

.photo-modal-scene {
  transform-origin: center center;
  will-change: transform;
}

.photo-modal-scene-inner {
  display: inline-block;
  line-height: 0;
  position: relative;
  vertical-align: top;
}

.photo-modal-scene-inner img {
  -webkit-user-drag: none;
  background: #0f172a;
  display: block;
  max-height: calc(100vh - 140px);
  max-width: min(100%, calc(100vw - 32px));
  height: auto;
  object-fit: contain;
  user-select: none;
  width: auto;
}

#photo-modal-draw-canvas {
  box-sizing: border-box;
  left: 0;
  pointer-events: none;
  position: absolute;
  top: 0;
  touch-action: none;
}

#photo-modal-draw-canvas.photo-modal-canvas--pen {
  pointer-events: auto;
}

.photo-modal-header {
  align-items: center;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 16px 18px;
}

.photo-modal-header-actions {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  flex-wrap: nowrap;
  gap: 6px;
}

.photo-modal-header-actions .icon-button {
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  padding: 6px 10px;
  white-space: nowrap;
}

.photo-modal-header-actions .icon-button.photo-modal-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.photo-modal-header-actions .icon-button.photo-modal-danger:hover {
  background: #fee2e2;
}

.photo-modal-header-actions .icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.photo-modal-header h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.photo-modal-header p {
  color: #64748b;
  font-size: 13px;
  margin-bottom: 0;
}

.icon-button {
  background: #e2e8f0;
  border: 0;
  color: #0f172a;
}


.text-modal-dialog {
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.45);
  left: 50%;
  max-height: calc(100vh - 48px);
  max-width: min(900px, calc(100vw - 48px));
  overflow: hidden;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
}

.text-modal-dialog pre {
  color: #0f172a;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.7;
  margin: 0;
  max-height: calc(100vh - 160px);
  overflow: auto;
  padding: 20px;
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  .v2-shell {
    padding: 14px;
  }

  .v2-hero,
  .section-heading {
    display: block;
  }

  .v2-actions,
  .board-tools {
    margin-top: 14px;
  }

  .primary-button,
  .secondary-link,
  .tool-button,
  .board-tools textarea {
    width: 100%;
  }
}
