:root {
  --bg: #f3f3f3;
  --panel: #ffffff;
  --text: #21303a;
  --muted: #6c757d;
  --line: #bf7348;
  --accent: #f38c52;
}

* {
  box-sizing: border-box;
  font-family: 'Montserrat', sans-serif;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  height: 100%;
}

.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
}

.panel {
  background: var(--panel);
  border-right: 2px solid var(--line);
  padding: 18px;
  overflow: auto;
}

.panel h1 {
  margin: 0;
  font-size: 1.4rem;
}

.subtitle {
  margin: 6px 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.fields {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}

input, select {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 0;
  padding: 8px;
  background: #fff;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--accent);
  height: 20px;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: linear-gradient(90deg, #e8e8e8 0%, #dadada 100%);
  border: 1px solid #cfcfcf;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  background: var(--accent);
  border: 1px solid #c46832;
  transition: transform 0.15s ease;
}

input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.15);
}

input[type="range"]::-moz-range-track {
  height: 6px;
  background: #dadada;
  border: 1px solid #cfcfcf;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border: 1px solid #c46832;
}

input[type="color"] {
  height: 38px;
  padding: 3px;
}

span[data-value] {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
}

.viewport-wrap {
  position: relative;
  min-width: 0;
}

#viewport {
  width: 100%;
  height: 100vh;
  background: #ececec;
}

.hint {
  position: absolute;
  left: 16px;
  bottom: 16px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid var(--line);
  padding: 8px 10px;
  font-size: 0.8rem;
  color: #333;
}

.conditional-control.hidden {
  display: none;
}

.element-tools {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 280px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid var(--line);
  padding: 10px;
  display: grid;
  gap: 8px;
  z-index: 20;
}

.element-tools.hidden {
  display: none;
}

.element-tools h3 {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.element-tools label {
  font-size: 0.82rem;
  gap: 4px;
}

.element-tools button {
  border: 2px solid var(--line);
  border-radius: 0;
  background: #fff;
  padding: 8px;
  font-weight: 700;
  cursor: pointer;
}

.element-tools button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.add-btn {
  position: absolute;
  width: 30px;
  height: 30px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--accent);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transform: translate(-50%, -50%);
  z-index: 22;
}

.insert-actions .add-btn {
  position: static;
  width: auto;
  height: auto;
  transform: none;
  font-size: 1rem;
  line-height: 1.2;
}

.add-btn.hidden {
  display: none;
}

.insert-tools {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 260px;
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid var(--line);
  padding: 10px;
  display: grid;
  gap: 8px;
  z-index: 21;
}

.insert-tools.hidden {
  display: none;
}

.insert-tools label {
  font-size: 0.82rem;
  gap: 4px;
}

.insert-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.share-box {
  display: grid;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid #e2d6cf;
}

.share-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.share-actions button {
  border: 2px solid var(--line);
  border-radius: 0;
  background: #fff;
  padding: 8px;
  font-weight: 700;
  cursor: pointer;
}

#shareLink {
  font-size: 0.85rem;
  padding: 8px;
}

.element-tools select,
.insert-tools select {
  width: 100%;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .panel {
    border-right: none;
    border-bottom: 2px solid var(--line);
  }

  #viewport {
    height: 72vh;
  }

  .element-tools,
  .insert-tools {
    width: min(300px, calc(100vw - 24px));
  }
}
