:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --code: #ffffff;
  --line: rgba(0, 0, 0, .12);
  --text: #111827;
  --sub: #856259;
  --topbar: #ffffff;
  --primary: #fa9403;
  --muted: #667085;
}

html[data-theme="dark"] {
  --bg: #000;
  --surface: #000;
  --code: #444;
  --line: rgba(255, 255, 255, .16);
  --text: #e5e7eb;
  --sub: #d9b8a0;
  --topbar: #000;
  --muted: #9ca3af;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }

.dt-topbar {
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--topbar);
  border-bottom: 1px solid var(--line);
}
.dt-brand { display: flex; align-items: center; gap: 12px; }
.dt-logotop { width: 500px; max-width: 100%; height: auto; display: block; }
.dt-title { color: var(--sub); font-weight: 700; }
.dt-actions { display: flex; gap: 8px; align-items: center; }

.dt-secondary-btn,
button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
}
.dt-secondary-btn:hover,
button:hover { border-color: var(--primary); color: var(--primary); }

.dt-main { width: 100%; margin: 18px 0; padding: 0 14px 40px; }

.cp-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 16px;
  align-items: start;
}

.cp-stage,
.cp-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: var(--surface);
}

.cp-panel h1,
.cp-panel h2,
.cp-presets-box h2 {
  margin: 0 0 10px;
  color: var(--sub);
  font-weight: 600;
}

.cp-preview-wrap {
  position: relative;
  min-height: 600px;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.cp-preview-grid {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, rgba(127, 127, 127, .12) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(127, 127, 127, .12) 1px, transparent 1px);
  background-size: 24px 24px;
}

.cp-preview-surface {
  position: relative;
  width: min(88%, 680px);
  aspect-ratio: 16 / 9;
  transform-origin: 50% 50%;
}

.cp-target {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, #fa9403, #ef6c00);
}

.cp-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.cp-overlay polygon,
.cp-overlay circle,
.cp-overlay ellipse,
.cp-overlay rect {
  fill: none;
  stroke: rgba(255, 255, 255, .9);
  stroke-width: 1.2;
  stroke-dasharray: 2 2;
}

.cp-handles {
  position: absolute;
  inset: 0;
}

.cp-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid #fff;
  background: color-mix(in srgb, var(--primary) 65%, #000);
  transform: translate(-50%, -50%);
  cursor: grab;
  box-shadow: 0 0 0 1px rgba(0,0,0,.3);
}
.cp-handle:active { cursor: grabbing; }

.cp-row { display: grid; gap: 10px; margin-bottom: 12px; }
.cp-row.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: block; font-size: 12px; font-weight: 700; }
input[type="range"] { width: 100%; margin-top: 6px; }
input[type="color"] {
  width: 100%;
  margin-top: 6px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 2px;
}
select,
input[type="text"],
textarea {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  background: var(--code);
  color: var(--text);
  font-size: 13px;
}
textarea {
  min-height: 130px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.cp-mini { display: inline-block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.cp-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.cp-feedback { min-height: 20px; color: #22c55e; font-weight: 700; margin: 8px 0 0; }

.cp-preset-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.cp-preset {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 8px;
  text-align: left;
}
.cp-preset .swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  background: linear-gradient(145deg, #fa9403, #ef6c00);
  margin-bottom: 6px;
}
.cp-preset .name { font-size: 11px; font-weight: 700; color: var(--text); }

.cp-dropzone {
  width: 100%;
  margin-top: 6px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 14px 12px;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  cursor: pointer;
}
.cp-dropzone:hover,
.cp-dropzone.dragover {
  border-color: var(--primary);
  color: var(--text);
}

.is-hidden { display: none !important; }

@media (max-width: 1200px) {
  .cp-shell { grid-template-columns: 1fr; }
  .cp-preset-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .cp-row.two,
  .cp-preset-list { grid-template-columns: 1fr; }
  .cp-preview-wrap { min-height: 420px; }
}
