:root {
  --accent: #2b6cb0;
  --border: #cbd5e0;
  --bg: #f7fafc;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: #1a202c;
}

.panel {
  max-width: 700px;
  margin: 0 auto;
  padding: 24px 24px 8px;
}

.panel h1 {
  font-size: 22px;
  margin-bottom: 16px;
}

.field {
  margin-bottom: 14px;
}

.field > label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}

.field > label.inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  cursor: pointer;
}

textarea,
input[type="text"] {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

textarea {
  resize: vertical;
}

input[type="range"] {
  width: 100%;
}

select {
  font-family: inherit;
  font-size: 14px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

/* ----- editor ----- */

.editor-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 0 0 14px;
  margin-bottom: 18px;
  overflow: hidden;
}

.side-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: #edf2f7;
}

.tab {
  flex: 1;
  padding: 12px 10px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 14px;
  font-weight: 600;
  color: #4a5568;
  cursor: pointer;
}

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

.back-mode {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 0;
  font-size: 14px;
}

.back-mode label {
  font-weight: 600;
}

.editor-hint {
  font-size: 13px;
  color: #718096;
  margin: 10px 16px 0;
}

.editor-hint:empty {
  display: none;
}

.canvas-wrap {
  overflow: auto;
  padding: 16px;
  background: repeating-conic-gradient(#f1f5f9 0% 25%, #ffffff 0% 50%) 50% / 16px 16px;
}

.editor-half {
  position: relative;
  margin: 0 auto;
  background: #fff;
  border: 1px dashed #a0aec0;
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  outline: none;
}

.editor-half.locked {
  opacity: 0.65;
}

.editor-half:focus-visible {
  box-shadow: 0 0 0 2px rgba(43, 108, 176, 0.4);
}

.editor-el {
  cursor: move;
  outline: 1px dashed transparent;
  outline-offset: 3px;
}

.editor-half:not(.locked) .editor-el:hover {
  outline-color: #a0aec0;
}

.editor-el.selected {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.editor-half.locked .editor-el {
  cursor: default;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 16px 0;
}

.props {
  padding: 14px 16px 0;
  margin-top: 12px;
  border-top: 1px solid var(--border);
}

.props-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 10px;
}

.props-empty {
  font-size: 13px;
  color: #718096;
  margin: 0;
}

.props-pos {
  font-size: 12px;
  color: #718096;
  margin: 0 0 12px;
}

/* gallery */

.gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.thumb {
  width: 54px;
  height: 54px;
  padding: 4px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.thumb.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(43, 108, 176, 0.25);
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.upload-note {
  font-size: 13px;
  color: #4a5568;
}

/* sizes */

fieldset.sizes {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px 4px;
  margin: 0 0 18px;
  background: #fff;
}

fieldset.sizes legend {
  font-weight: 600;
  font-size: 14px;
  padding: 0 6px;
}

/* buttons */

button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
}

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

button.secondary {
  background: #e2e8f0;
  color: #2d3748;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 500;
}

button.danger {
  background: #fed7d7;
  color: #9b2c2c;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 500;
}

.count {
  font-size: 13px;
  color: #4a5568;
  margin-left: 10px;
}

.hint {
  font-size: 13px;
  color: #4a5568;
}

/* ----- positioned elements (editor + card) ----- */

.el {
  position: absolute;
  transform: translate(-50%, -50%);
  max-width: 96%;
  text-align: center;
  line-height: 1.1;
  word-break: break-word;
  user-select: none;
}

img.el {
  object-fit: contain;
  height: auto;
}

/* ----- cards (preview + print) ----- */

#labels-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8mm;
  justify-content: center;
  align-items: flex-start;
  padding: 16px 24px 40px;
}

.tent-card {
  border: 1px dashed #a0aec0;
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
  page-break-inside: avoid;
  break-inside: avoid;
}

.tent-half {
  position: relative;
  overflow: hidden;
}

.tent-half.top {
  transform: rotate(180deg);
}

.tent-fold-line {
  border-top: 1px dashed #a0aec0;
  width: 100%;
}

/* ----- print ----- */

@media print {
  @page {
    size: A4;
    margin: 10mm;
  }

  .no-print {
    display: none !important;
  }

  body {
    background: #fff;
  }

  #labels-container {
    padding: 0;
    gap: 5mm;
  }
}
