:root {
  color-scheme: dark;
  --box-border-color: rgba(255, 64, 64, 0.9);
  --box-fill-color: rgba(255, 64, 64, 0.12);
  --box-selected-border: #f9d65c;
  --box-selected-fill: rgba(249, 214, 92, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  background: #151515;
  color: #e6e6e6;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  padding: 16px;
  min-height: 100vh;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.canvas-shell {
  background: #1f1f1f;
  border: 1px solid #2e2e2e;
  border-radius: 8px;
  padding: 12px;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  max-width: var(--base-width, 1200px);
  aspect-ratio: var(--base-width-num, 1200) / var(--base-height-num, 800);
  margin: 0 auto;
  background: #101010;
  border: 1px solid #333;
  overflow: hidden;
}

#pdfCanvas,
#imageLayer,
.mapper-grid,
.box-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.mapper-grid {
  z-index: 2;
  display: none;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
}

#pdfCanvas {
  opacity: 1;
  background: #000;
}

#imageLayer {
  opacity: 1;
  user-select: none;
  pointer-events: none;
}

.box-layer {
  z-index: 3;
  cursor: crosshair;
}

.box-layer.select-mode {
  cursor: default;
}

.shape-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: all;
}

.map-shape {
  fill: var(--box-fill-color);
  stroke: var(--box-border-color);
  stroke-width: 0.4;
  stroke-linejoin: miter;
  stroke-linecap: square;
  shape-rendering: geometricPrecision;
  vector-effect: non-scaling-stroke;
  pointer-events: all;
}

.shape-group {
  pointer-events: none;
}

.shape-group .map-shape {
  pointer-events: all;
}

.shape-group.filtered-out {
  opacity: 0.15;
  pointer-events: none;
}

.shape-group.match .map-shape {
  stroke: #f9d65c;
  stroke-width: 0.6;
}

.map-shape-label {
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 1.1px;
  font-weight: 700;
  letter-spacing: 0.05px;
  text-transform: uppercase;
  fill: #ffffff;
  paint-order: stroke fill;
  stroke: rgba(0, 0, 0, 0.9);
  stroke-width: 0.3;
  stroke-linejoin: round;
  stroke-linecap: round;
  text-rendering: geometricPrecision;
  pointer-events: none;
  user-select: none;
}

.map-shape-icon {
  opacity: 0.75;
  pointer-events: none;
}

.map-shape.selected {
  fill: var(--box-selected-fill);
  stroke: var(--box-selected-border);
}

.draft-shape {
  fill: rgba(255, 255, 255, 0.08);
  stroke: rgba(255, 255, 255, 0.8);
  stroke-width: 0.4;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 1 1.2;
  pointer-events: none;
}

.map-box {
  position: absolute;
  border: 2px solid var(--box-border-color);
  background: var(--box-fill-color);
  border-radius: 0;
  color: #f5f5f5;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2px;
  pointer-events: auto;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

.map-box-icon {
  position: absolute;
  width: 46%;
  height: 46%;
  left: 27%;
  top: 27%;
  opacity: 0.65;
  object-fit: contain;
  pointer-events: none;
}

.map-box.selected {
  border-color: var(--box-selected-border);
  background: var(--box-selected-fill);
}

.status {
  font-size: 13px;
  color: #c6c6c6;
}

.panel {
  background: #1f1f1f;
  border: 1px solid #2e2e2e;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.panel h1 {
  font-size: 18px;
  margin: 0 0 4px 0;
}

.panel-home-link {
  margin: 0 0 12px 0;
  font-size: 13px;
}
.panel-home-link a {
  color: #7bb8f0;
  text-decoration: none;
}
.panel-home-link a:hover {
  text-decoration: underline;
}

.panel h2 {
  font-size: 16px;
  margin: 0 0 8px 0;
}

.panel section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label {
  font-size: 12px;
  color: #cfcfcf;
}

input[type="number"],
input[type="text"],
select,
textarea {
  width: 100%;
  padding: 6px 8px;
  background: #121212;
  color: #e6e6e6;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
}

textarea {
  min-height: 160px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
  resize: vertical;
}

.inline {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline > * {
  flex: 1;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.icon-palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 8px;
}

.icon-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 6px;
  background: #121212;
  color: #e6e6e6;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
}

.icon-choice img {
  width: 28px;
  height: 28px;
}

.icon-choice:hover {
  border-color: #6aaefc;
}

.button-grid .spacer {
  visibility: hidden;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

button {
  padding: 8px 10px;
  background: #2f2f2f;
  color: #e6e6e6;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  cursor: pointer;
}

button:hover {
  background: #3a3a3a;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.note {
  font-size: 11px;
  color: #9c9c9c;
  line-height: 1.4;
}

.preview-image {
  width: 100%;
  border: 1px solid #2e2e2e;
  border-radius: 6px;
  background: #0f0f0f;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}
