:root {
  font-family: "Inter", system-ui, sans-serif;
  color: #102a43;
  background: #f7f9fc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

header {
  margin-bottom: 20px;
}

.layout {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(300px, 1.4fr) minmax(280px, 1fr);
  align-items: start;
}

.map-panel,
.control-panel {
  background: #ffffff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.map-container {
  border: 1px solid #d9e2ec;
  border-radius: 8px;
  min-height: 360px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
}

.map-container svg {
  width: 100%;
  height: auto;
  max-height: 520px;
}

.map-container path {
  fill: #cbd5e1;
  stroke: #334155;
  stroke-width: 0.5;
  cursor: pointer;
  transition: fill 0.2s ease, stroke 0.2s ease;
}

.map-container path:hover {
  fill: #93c5fd;
}

.map-container path.selected {
  fill: #38bdf8;
  stroke: #0369a1;
}

.controls {
  display: grid;
  gap: 16px;
}

.field-group {
  display: grid;
  gap: 8px;
}

fieldset {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.selected-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 24px;
  display: grid;
  gap: 8px;
}

.selected-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f1f5f9;
  border-radius: 6px;
  padding: 8px 12px;
  gap: 12px;
  cursor: pointer;
}

.selected-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.selected-thumb svg {
  width: 40px;
  height: 40px;
}

.selected-meta {
  flex: 1;
  display: grid;
  gap: 6px;
}

.selection-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.selected-size-text {
  font-size: 0.8rem;
  color: #475569;
}

.selected-size {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.size-field {
  display: grid;
  gap: 4px;
  font-size: 0.75rem;
  color: #334155;
}

.size-field input {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
}

.size-unit {
  font-size: 0.7rem;
  color: #64748b;
}

button {
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  background: #2563eb;
  color: white;
  cursor: pointer;
}

button.secondary {
  background: #94a3b8;
}

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

.download {
  margin-top: 16px;
  width: 100%;
  font-size: 1rem;
}

.status {
  margin-top: 12px;
  min-height: 20px;
  color: #475569;
}

.hint {
  margin: 0;
  font-size: 0.85rem;
  color: #64748b;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  border: 0;
  padding: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
}

.lightbox {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.lightbox.open {
  display: flex;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(15, 23, 42, 0.6);
}

.lightbox-surface {
  position: relative;
  z-index: 1;
  background: #ffffff;
  border-radius: 16px;
  padding: 20px;
  min-width: min(90vw, 700px);
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  display: grid;
  gap: 16px;
}

.lightbox-close {
  justify-self: end;
  background: #e2e8f0;
  color: #0f172a;
}

.lightbox-body {
  display: grid;
  gap: 12px;
}

.lightbox-stage {
  display: grid;
  grid-template-columns: 48px 1fr;
  grid-template-rows: 32px 1fr;
  gap: 8px;
  align-items: stretch;
}

.lightbox-canvas {
  grid-column: 2 / 3;
  grid-row: 2 / 3;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
}

.lightbox-canvas svg {
  width: 80%;
  height: 80%;
}

.ruler {
  background: #e2e8f0;
  border-radius: 8px;
  font-size: 0.7rem;
  color: #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.ruler-horizontal {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  background-image: repeating-linear-gradient(
    to right,
    rgba(15, 23, 42, 0.3) 0,
    rgba(15, 23, 42, 0.3) 1px,
    transparent 1px,
    transparent 12px
  );
}

.ruler-vertical {
  grid-column: 1 / 2;
  grid-row: 2 / 3;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(15, 23, 42, 0.3) 0,
    rgba(15, 23, 42, 0.3) 1px,
    transparent 1px,
    transparent 12px
  );
}

.lightbox-meta {
  font-size: 0.85rem;
  color: #475569;
}
