/* The things you drop on the canvas. These render as an iOS-flavored device
   preview and intentionally do NOT follow the editor theme. Only the
   selection/hover chrome (--select) does. Structured types get their inner
   markup from js/renderers.js. */

.screen-element {
  position: absolute;
  border: none;
  border-radius: 6px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: box-shadow 0.1s ease;
}
.screen-element:hover { box-shadow: 0 0 0 1px var(--select-soft); }
.screen-element.selected {
  outline: 2px solid var(--select);
  outline-offset: 1px;
}
.screen-element.dragging,
.screen-element.resizing {
  cursor: grabbing;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
  z-index: 10;
  opacity: 0.92;
}

/* Content wrapper clips overflow so the resize handle (positioned just
   outside the element's own box) never gets clipped along with it. */
.element-content {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: inherit;
  padding: 4px 10px;
  font-size: 14px;
  font-weight: 400;
  white-space: pre-wrap;
  display: flex;
  align-items: center;
}

.resize-handle {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: transparent;
  cursor: nwse-resize;
  display: none;
}
.resize-handle::after {
  content: '';
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 9px;
  height: 9px;
  background: var(--select);
  border: 2px solid #fff;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.screen-element.selected .resize-handle { display: block; }

/* Shared helpers used by renderers.js */
.r-icon { display: inline-flex; flex: none; align-items: center; justify-content: center; }
.r-grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-svg { display: block; flex: 1; min-height: 0; min-width: 0; }
.r-svg svg { display: block; }

/* ---------- Basics ---------- */
.el-type-text .element-content { padding: 0; font-size: 15px; color: #1C1C1E; }

.el-type-heading .element-content {
  padding: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.15;
}
.el-type-paragraph .element-content {
  padding: 0;
  align-items: flex-start;
  font-size: 15px;
  line-height: 1.45;
  white-space: normal;
}
.el-type-link .element-content { padding: 0; font-size: 15px; font-weight: 500; }

.el-type-divider .element-content { padding: 0; gap: 10px; }
.r-line { flex: 1; height: 1px; background: currentColor; opacity: 0.35; }
.r-line-text { font-size: 12px; }

.el-type-quote { border-radius: 10px; }
.el-type-quote .element-content {
  border-left: 4px solid #007AFF;
  border-radius: 0 10px 10px 0;
  padding: 10px 14px;
  font-style: italic;
  font-size: 14px;
  line-height: 1.4;
}
.el-type-code { border-radius: 10px; }
.el-type-code .element-content {
  align-items: flex-start;
  padding: 12px 14px;
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
}

/* ---------- Buttons & actions ---------- */
.el-type-button { border-radius: 12px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.el-type-button .element-content {
  justify-content: center;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.1px;
}
.el-type-outlinebtn { border-radius: 12px; border: 1.5px solid currentColor; }
.el-type-outlinebtn .element-content {
  justify-content: center;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
}
.el-type-fab { border-radius: 50%; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28); }
.el-type-fab .element-content { justify-content: center; padding: 0; font-size: 28px; font-weight: 300; }

.el-type-segmented { border-radius: 9px; }
.el-type-segmented .element-content { padding: 2px; gap: 2px; }
.r-seg {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  border-radius: 7px;
}
.r-seg.active { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); font-weight: 600; }

.el-type-chips .element-content { padding: 0; gap: 8px; }
.r-chip {
  padding: 4px 12px;
  border: 1px solid;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.el-type-badge { border-radius: 999px; }
.el-type-badge .element-content { justify-content: center; padding: 0 8px; font-size: 12px; font-weight: 700; }

/* ---------- Forms ---------- */
.el-type-input { border-radius: 10px; }
.el-type-input .element-content { font-size: 15px; }

.el-type-textarea { border-radius: 10px; }
.el-type-textarea .element-content { align-items: flex-start; padding: 12px 14px; font-size: 15px; }

.el-type-searchbar { border-radius: 10px; }
.el-type-searchbar .element-content { gap: 8px; padding: 0 12px; font-size: 15px; }

.el-type-select { border-radius: 10px; }
.el-type-select .element-content { gap: 8px; font-size: 15px; }

.el-type-radio .element-content {
  flex-direction: column;
  align-items: stretch;
  justify-content: space-around;
  padding: 2px 4px;
}
.r-radio-row { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.r-radio {
  position: relative;
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #C7C7CC;
}
.r-radio.on { border-color: #007AFF; }
.r-radio.on::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: #007AFF; }

.el-type-checkbox { position: relative; }
.el-type-checkbox .element-content { padding-right: 60px; font-size: 15px; }
.el-type-checkbox::before {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 24px;
  border-radius: 12px;
  background: #34C759;
}
.el-type-checkbox::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.el-type-slider .element-content,
.el-type-progress .element-content { padding: 0 11px; }
.r-track { position: relative; flex: 1; height: 4px; border-radius: 2px; background: #D1D1D6; }
.r-track-thick { height: 10px; border-radius: 999px; }
.r-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; }
.r-thumb {
  position: absolute;
  top: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.el-type-stepper { border-radius: 10px; }
.el-type-stepper .element-content { padding: 0; justify-content: space-between; }
.r-step-btn { flex: none; width: 36px; text-align: center; font-size: 20px; color: #007AFF; }
.r-step-val { flex: 1; text-align: center; font-size: 15px; font-weight: 600; }

.el-type-datepicker { border-radius: 10px; }
.el-type-datepicker .element-content { gap: 10px; font-size: 15px; }

.el-type-rating .element-content { padding: 0; gap: 3px; }
.r-star { font-size: 22px; line-height: 1; color: #D1D1D6; }
.r-star.on { color: inherit; }

.el-type-upload { border-radius: 12px; border: 1.5px dashed #C7C7CC; }
.el-type-upload .element-content {
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  text-align: center;
  font-size: 13px;
}

/* ---------- Navigation ---------- */
.el-type-navbar { border-radius: 0; box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.08); }
.el-type-navbar .element-content { justify-content: center; font-size: 17px; font-weight: 600; }

.el-type-header { border-radius: 0; box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.08); }
.el-type-header .element-content { padding: 0 14px; gap: 8px; }
.r-hdr-side { flex: 1; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-hdr-side.r-right { text-align: right; }
.r-hdr-title {
  flex: 2;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.el-type-statusbar { border-radius: 0; }
.el-type-statusbar .element-content { padding: 0 22px; justify-content: space-between; font-size: 15px; font-weight: 600; }
.r-status-icons { display: flex; align-items: center; gap: 6px; }

.el-type-tabbar { box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.08); }
.el-type-tabbar .element-content { padding: 0; align-items: stretch; }
.tab-segment {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  color: inherit;
}
.tab-segment.active { color: #007AFF; font-weight: 600; }

.el-type-tabs { border-radius: 0; box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1); }
.el-type-tabs .element-content { padding: 0; align-items: stretch; }
.r-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
}
.r-tab.active { color: #007AFF; border-bottom-color: #007AFF; font-weight: 600; }

.el-type-sidebar { border-radius: 0; }
.el-type-sidebar .element-content { flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 16px 8px; gap: 2px; }
.r-side-item { padding: 9px 12px; border-radius: 8px; font-size: 14px; opacity: 0.85; }
.r-side-item.active { background: rgba(127, 127, 127, 0.22); opacity: 1; font-weight: 600; }

.el-type-breadcrumbs .element-content { padding: 0; gap: 6px; font-size: 14px; }
.r-crumb-sep { opacity: 0.6; }
.r-crumb.last { font-weight: 600; }

.el-type-pagination .element-content { padding: 0; gap: 6px; }
.r-page {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(60, 60, 67, 0.25);
  border-radius: 8px;
  font-size: 14px;
}
.r-page.active { background: #007AFF; border-color: #007AFF; color: #fff; }

.el-type-steps .element-content { padding: 0 4px; align-items: flex-start; }
.r-step { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: none; min-width: 48px; }
.r-step-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #C7C7CC;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #8E8E93;
}
.r-step.active .r-step-dot { background: #007AFF; border-color: #007AFF; color: #fff; }
.r-step-label { font-size: 11px; text-align: center; white-space: nowrap; }
.r-step-line { flex: 1; height: 2px; margin-top: 12px; background: #D1D1D6; }

.el-type-accordion { border-radius: 12px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1); }
.el-type-accordion .element-content { flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 0; }
.r-acc-head { display: flex; align-items: center; gap: 8px; padding: 13px 16px; font-size: 15px; font-weight: 600; flex: none; }
.r-acc-body { padding: 0 16px 14px; font-size: 14px; line-height: 1.4; opacity: 0.75; white-space: normal; }

/* ---------- Content ---------- */
.el-type-card { border-radius: 14px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08); }
.el-type-card .element-content { align-items: flex-start; padding: 14px 16px; font-size: 15px; font-weight: 600; }

.el-type-image { border-radius: 10px; }
.el-type-image .element-content { flex-direction: column; justify-content: center; gap: 4px; }
.image-caption { font-size: 11px; color: #8E8E93; }

.el-type-mediacard { border-radius: 14px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08); }
.el-type-mediacard .element-content { flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 0; }
.r-media { flex: 1; min-height: 40px; display: flex; align-items: center; justify-content: center; background: #E5E5EA; color: #8E8E93; }
.r-mc-body { flex: none; padding: 12px 16px 14px; }
.r-mc-title { font-size: 16px; font-weight: 600; }
.r-mc-desc { margin-top: 2px; font-size: 13px; opacity: 0.7; white-space: normal; }

.el-type-list { border-radius: 12px; }
.el-type-list .element-content { flex-direction: column; align-items: stretch; padding: 0; overflow: auto; }
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  font-size: 15px;
  border-bottom: 1px solid rgba(60, 60, 67, 0.1);
  flex: none;
}
.list-row:last-child { border-bottom: none; }
.list-chevron { color: #C7C7CC; font-size: 15px; margin-left: 8px; }

.el-type-avatar { border-radius: 50%; }
.el-type-avatar .element-content { justify-content: center; padding: 0; font-size: 18px; font-weight: 600; }

.el-type-stat { border-radius: 14px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08); }
.el-type-stat .element-content { flex-direction: column; align-items: flex-start; justify-content: center; padding: 10px 14px; gap: 2px; }
.r-stat-cap { font-size: 12px; opacity: 0.65; }
.r-stat-val { font-size: 24px; font-weight: 700; line-height: 1.1; }
.r-stat-delta { font-size: 12px; font-weight: 600; }
.r-stat-delta.pos { color: #34C759; }
.r-stat-delta.neg { color: #FF3B30; }

.el-type-table { border-radius: 12px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1); }
.el-type-table .element-content { flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 0; }
.r-row { display: grid; flex: none; }
.r-row.head { font-weight: 700; font-size: 12px; background: rgba(127, 127, 127, 0.12); }
.r-cell {
  padding: 9px 12px;
  font-size: 13px;
  border-bottom: 1px solid rgba(60, 60, 67, 0.1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.el-type-pricing { border-radius: 16px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); }
.el-type-pricing .element-content { flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 18px 16px; gap: 8px; }
.r-plan { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.7; }
.r-price { font-size: 28px; font-weight: 800; }
.r-feature { font-size: 13px; }

/* ---------- Media ---------- */
.el-type-video { border-radius: 12px; }
.el-type-video .element-content { position: relative; justify-content: center; padding: 0; }
.r-play {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  border: 2px solid rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}
.r-video-title { position: absolute; left: 14px; top: 12px; font-size: 13px; font-weight: 600; opacity: 0.9; }
.r-scrub { position: absolute; left: 14px; right: 14px; bottom: 12px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.3); }
.r-scrub-fill { width: 35%; height: 100%; border-radius: 2px; background: #fff; }

.el-type-map { border-radius: 12px; }
.el-type-map .element-content {
  position: relative;
  justify-content: center;
  padding: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.55) 2px, transparent 2px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.55) 2px, transparent 2px);
  background-size: 46px 46px;
}
.r-map-label {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #1C1C1E;
  font-size: 12px;
  font-weight: 600;
}

.el-type-carousel { border-radius: 14px; }
.el-type-carousel .element-content { position: relative; padding: 0; }
.r-car-media { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.r-car-caption { position: absolute; left: 14px; bottom: 30px; font-size: 13px; font-weight: 600; }
.r-dots { position: absolute; left: 0; right: 0; bottom: 10px; display: flex; justify-content: center; gap: 6px; }
.r-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(0, 0, 0, 0.25); }
.r-dot.active { background: #007AFF; }

/* ---------- Data & status ---------- */
.el-type-barchart,
.el-type-linechart { border-radius: 14px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08); }
.el-type-barchart .element-content,
.el-type-linechart .element-content { flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 14px; }
.r-chart-title { flex: none; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.r-bars { flex: 1; display: flex; align-items: flex-end; gap: 8px; min-height: 0; }
.r-bar { flex: 1; border-radius: 5px 5px 2px 2px; background: #B7D4FF; }
.r-bar.hi { background: #007AFF; }

.el-type-donut { border-radius: 14px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08); }
.el-type-donut .element-content { position: relative; justify-content: center; padding: 0; }
.el-type-donut .r-donut-ring { position: absolute; inset: 14px; }
.r-donut-label { position: relative; font-size: 22px; font-weight: 700; }

.el-type-spinner .element-content { padding: 0; }
.el-type-spinner .element-content::before {
  content: '';
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 4px solid currentColor;
  border-right-color: transparent;
}

.el-type-skeleton .element-content { flex-direction: column; align-items: stretch; justify-content: center; gap: 10px; padding: 4px 0; }
.r-skel { height: 14px; border-radius: 7px; background: currentColor; }

/* ---------- Feedback & chat ---------- */
.el-type-banner { border-radius: 12px; }
.el-type-banner .element-content { gap: 10px; padding: 8px 14px; font-size: 14px; font-weight: 500; white-space: normal; }
.r-banner-dot {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
}

.el-type-toast { border-radius: 999px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); }
.el-type-toast .element-content { justify-content: center; padding: 0 18px; font-size: 14px; font-weight: 500; }

.el-type-modal { border-radius: 16px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.28); }
.el-type-modal .element-content { flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 0; }
.r-modal-body { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px; padding: 16px 20px; text-align: center; }
.r-modal-title { font-size: 17px; font-weight: 700; }
.r-modal-msg { font-size: 13px; opacity: 0.7; white-space: normal; }
.r-modal-actions { display: flex; flex: none; border-top: 1px solid rgba(60, 60, 67, 0.18); }
.r-modal-btn { flex: 1; padding: 12px; text-align: center; font-size: 16px; color: #007AFF; border-left: 1px solid rgba(60, 60, 67, 0.18); }
.r-modal-btn:first-child { border-left: none; }
.r-modal-btn.strong { font-weight: 600; }

.el-type-bubble { border-radius: 18px 18px 18px 5px; }
.el-type-bubblesent { border-radius: 18px 18px 5px 18px; }
.el-type-bubble .element-content,
.el-type-bubblesent .element-content { padding: 8px 14px; font-size: 15px; white-space: normal; }
