/* =========================================================
   FormYar — form builder workspace
   ========================================================= */

.builder-body {
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}
.builder-shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ============ topbar ============ */
.builder-topbar {
  height: 64px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 70;
}
.bt-back {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: 0.16s;
  flex: none;
}
.bt-back:hover {
  background: var(--bg-2);
  color: var(--ink);
}
.bt-back .icon {
  width: 18px;
  height: 18px;
}
.bt-brand {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: none;
  padding-inline-end: 6px;
}
.bt-brand .brand-mark {
  width: 29px;
  height: 29px;
  border-radius: 9px;
}
.bt-brand .brand-mark svg {
  width: 16px;
  height: 16px;
}
.bt-brand b {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.bt-title-wrap {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  max-width: 430px;
}
.bt-title-input {
  border: 1px solid transparent;
  background: transparent;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink);
  padding: 2px 7px;
  margin-inline-start: -7px;
  border-radius: 7px;
  outline: 0;
  width: 100%;
  text-overflow: ellipsis;
  transition: 0.15s;
  line-height: 1.6;
}
.bt-title-input:hover {
  background: var(--bg);
}
.bt-title-input:focus {
  background: var(--card);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 11%, transparent);
}
.bt-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 9.5px;
  color: var(--muted-2);
  padding-inline-start: 1px;
  line-height: 1.4;
}
.bt-meta .save-state {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.bt-meta .save-state .icon {
  width: 11px;
  height: 11px;
}
.bt-meta .save-state.saving {
  color: var(--amber);
}
.bt-meta .save-state.saved {
  color: var(--mint);
}
.bt-meta .dot-sep {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--line-2);
}
.bt-actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}
.bt-actions .btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}
.bt-actions .btn-icon .icon {
  width: 17px;
  height: 17px;
}
.bt-divider {
  width: 1px;
  height: 24px;
  background: var(--line);
  margin-inline: 3px;
  flex: none;
}
.bt-actions .btn-sm {
  min-height: 34px;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 9px;
}
.bt-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 9.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  flex: none;
}
.bt-status::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.bt-status.published {
  background: var(--mint-soft);
  color: #047857;
}
[data-theme="dark"] .bt-status.published {
  color: var(--mint);
}
.bt-status.draft {
  background: var(--amber-soft);
  color: #a16207;
}
[data-theme="dark"] .bt-status.draft {
  color: var(--amber);
}
.bt-status.closed {
  background: var(--bg-2);
  color: var(--muted);
}
.bt-undo-redo {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 2px;
  gap: 1px;
}
.bt-undo-redo button {
  width: 29px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: 0.14s;
}
.bt-undo-redo button:hover:not(:disabled) {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}
.bt-undo-redo button:disabled {
  opacity: 0.35;
  cursor: default;
}
.bt-undo-redo .icon {
  width: 15px;
  height: 15px;
}
.device-toggle {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 2px;
  gap: 1px;
}
.device-toggle button {
  width: 30px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: var(--muted-2);
  transition: 0.14s;
}
.device-toggle button.active {
  background: var(--card);
  color: var(--brand);
  box-shadow: var(--shadow-xs);
}
.device-toggle .icon {
  width: 15px;
  height: 15px;
}

/* ============ main 3-pane grid ============ */
.builder-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr) 336px;
  background: var(--bg);
}

/* ============ side panels ============ */
.builder-panel {
  background: var(--card);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.palette-panel {
  border-inline-end: 1px solid var(--line);
}
.inspector-panel {
  border-inline-start: 1px solid var(--line);
}
.bp-head {
  height: 48px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}
.bp-tabs,
.ins-tabs {
  display: flex;
  gap: 1px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}
.bp-tabs::-webkit-scrollbar,
.ins-tabs::-webkit-scrollbar {
  display: none;
}
.bp-tab,
.ins-tab {
  flex: none;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted-2);
  padding: 6px 10px;
  border-radius: 7px;
  transition: 0.15s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.bp-tab .icon,
.ins-tab .icon {
  width: 14px;
  height: 14px;
}
.bp-tab:hover,
.ins-tab:hover {
  background: var(--bg);
  color: var(--ink);
}
.bp-tab.active,
.ins-tab.active {
  background: var(--brand-soft);
  color: var(--brand);
}
.ins-tabs {
  gap: 0;
}
.ins-tab {
  padding: 6px 8px;
  font-size: 11px;
  border-radius: 0;
  position: relative;
  flex: 1;
  justify-content: center;
}
.ins-tab.active {
  background: transparent;
  color: var(--brand);
}
.ins-tab.active::after {
  content: "";
  position: absolute;
  bottom: -13px;
  inset-inline: 4px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand);
}
.bp-close {
  display: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
}
.bp-close .icon {
  width: 15px;
  height: 15px;
}
.bp-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  scrollbar-width: thin;
}
.bp-search {
  padding: 10px 12px 2px;
  flex: none;
}
.bp-search .search-box {
  position: relative;
}
.bp-search .icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  inset-inline-start: 10px;
  width: 14px;
  height: 14px;
  color: var(--muted-2);
}
.bp-search input {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  font-size: 11px;
  padding: 0 32px 0 10px;
  outline: 0;
}
.bp-search input:focus {
  border-color: var(--brand);
  background: var(--card);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 10%, transparent);
}

/* ============ palette ============ */
.palette-group {
  margin-bottom: 13px;
}
.palette-group-title {
  font-size: 9.5px;
  font-weight: 800;
  color: var(--muted-2);
  letter-spacing: 0.04em;
  padding: 2px 4px 6px;
}
.palette-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}
.palette-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-2);
  text-align: right;
  cursor: grab;
  transition: 0.14s;
  min-width: 0;
  user-select: none;
}
.palette-item .icon {
  width: 15px;
  height: 15px;
  color: var(--muted-2);
  flex: none;
  transition: 0.14s;
}
.palette-item:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  transform: translateY(-1px);
}
.palette-item:hover .icon {
  color: var(--brand);
}
.palette-item:active {
  cursor: grabbing;
}
.palette-item.dragging {
  opacity: 0.5;
}
.palette-item span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.palette-note {
  font-size: 9.5px;
  line-height: 1.8;
  color: var(--muted-2);
  background: var(--bg);
  border-radius: 9px;
  padding: 9px 10px;
  display: flex;
  gap: 6px;
  align-items: flex-start;
  margin-top: 4px;
}
.palette-note .icon {
  width: 13px;
  height: 13px;
  flex: none;
  margin-top: 2px;
  color: var(--brand);
}
.palette-cta {
  margin-top: 10px;
  border: 1px dashed var(--line-2);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}
.palette-cta a {
  font-size: 10px;
  font-weight: 700;
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.palette-cta a .icon {
  width: 12px;
  height: 12px;
}
.palette-cta p {
  font-size: 9px;
  color: var(--muted-2);
  margin-top: 2px;
}

/* ============ canvas ============ */
.builder-canvas {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}
.canvas-topline {
  height: 42px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
  font-size: 10.5px;
  color: var(--muted-2);
}
.canvas-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.canvas-status .live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mint) 18%, transparent);
  animation: livePulse 2.2s infinite;
}
@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--mint) 18%, transparent); }
  50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--mint) 4%, transparent); }
}
.canvas-status em {
  font-style: normal;
  color: var(--muted-2);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0 7px;
  font-size: 9px;
}
.canvas-topline .spacer {
  flex: 1;
}
.canvas-tip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 9.5px;
}
.canvas-tip .icon {
  width: 12px;
  height: 12px;
}
.canvas-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 26px 24px 70px;
  background-image: radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--line-2) 62%, transparent) 1px, transparent 0);
  background-size: 20px 20px;
  scrollbar-width: thin;
}
.canvas-frame {
  max-width: 720px;
  margin-inline: auto;
  transition: max-width 0.35s var(--ease);
}
.canvas-frame.device-mobile {
  max-width: 398px;
}
.canvas-frame.device-mobile .fy-form-hero,
.canvas-frame.device-mobile .fy-form-hero.has-cover {
  border-radius: 20px 20px 0 0;
  padding: 24px 20px 48px;
  min-height: 164px;
}
.canvas-frame.device-mobile .fy-form-hero.has-cover {
  min-height: 226px;
}
.canvas-frame.device-mobile .fy-form-hero h1 {
  font-size: 20px;
}
.canvas-frame.device-mobile .fy-form-hero p {
  font-size: 11.5px;
  line-height: 1.8;
}
.canvas-frame.device-mobile .fy-form-card {
  border-radius: 0 0 20px 20px;
}
.canvas-frame.device-mobile .fy-form {
  padding: 22px 17px 24px;
}
.canvas-frame.device-mobile .fy-fields {
  gap: 21px;
}
.canvas-frame.device-mobile .fy-row {
  grid-template-columns: 1fr;
  gap: 21px;
}
.canvas-frame.device-mobile .fy-label {
  font-size: 13px;
}
.canvas-frame.device-mobile .fy-hero-meta span:nth-child(2) {
  display: none;
}
.canvas-frame.device-mobile .fy-submit {
  min-height: 50px;
  font-size: 14px;
}
.canvas-empty {
  border: 2px dashed var(--line-2);
  border-radius: 16px;
  padding: 44px 20px;
  text-align: center;
  color: var(--muted-2);
  background: color-mix(in srgb, var(--card) 60%, transparent);
  cursor: pointer;
  transition: 0.18s;
}
.canvas-empty:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}
.canvas-empty .ce-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  margin: 0 auto 10px;
  color: var(--muted-2);
}
.canvas-empty .ce-icon .icon {
  width: 22px;
  height: 22px;
}
.canvas-empty b {
  display: block;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-bottom: 2px;
}
.canvas-empty span {
  font-size: 10.5px;
}
.canvas-scroll.drag-active {
  background-color: color-mix(in srgb, var(--brand) 3%, var(--bg));
}

/* hide canvas-only field chrome inside modals */
.preview-stage .fy-field-tools,
.preview-stage .fy-field-drag {
  display: none !important;
}

/* ============ inspector content ============ */
.ins-body {
  padding: 12px 13px 34px;
}
.ins-empty {
  padding: 46px 18px;
  text-align: center;
  color: var(--muted-2);
}
.ins-empty .ie-icon {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  background: var(--bg);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  margin: 0 auto 11px;
  color: var(--muted-2);
}
.ins-empty .ie-icon .icon {
  width: 24px;
  height: 24px;
}
.ins-empty b {
  display: block;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-bottom: 3px;
}
.ins-empty p {
  font-size: 10.5px;
  line-height: 1.9;
  max-width: 210px;
  margin-inline: auto;
}
.ins-section {
  margin-bottom: 15px;
}
.ins-section:last-child {
  margin-bottom: 0;
}
.ins-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 800;
  color: var(--muted-2);
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}
.ins-section-title .tag {
  margin-inline-start: auto;
  font-size: 8.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  padding: 1px 7px;
  border-radius: 20px;
  letter-spacing: 0;
}
.ins-field {
  margin-bottom: 9px;
}
.ins-field:last-child {
  margin-bottom: 0;
}
.ins-field > label,
.ins-label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}
.ins-input,
.ins-select,
.ins-textarea {
  width: 100%;
  min-height: 35px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11.5px;
  color: var(--ink);
  outline: 0;
  transition: 0.15s;
}
.ins-textarea {
  min-height: 62px;
  resize: vertical;
  line-height: 1.8;
}
.ins-input:focus,
.ins-select:focus,
.ins-textarea:focus {
  border-color: var(--brand);
  background: var(--card);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 10%, transparent);
}
.ins-select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b92ad' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 9px center;
  padding-left: 28px;
}
.ins-grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ins-help {
  font-size: 9px;
  color: var(--muted-2);
  line-height: 1.7;
  margin-top: 3px;
}
.ins-switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}
.ins-switch-row:last-child {
  border-bottom: 0;
}
.ins-switch-row .is-text {
  flex: 1;
  min-width: 0;
}
.ins-switch-row .is-text b {
  font-size: 11px;
  font-weight: 700;
  display: block;
  color: var(--ink-2);
}
.ins-switch-row .is-text small {
  font-size: 9px;
  color: var(--muted-2);
  display: block;
  line-height: 1.6;
}
.tgl {
  position: relative;
  width: 38px;
  height: 22px;
  flex: none;
  display: inline-block;
  cursor: pointer;
}
.tgl input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.tgl i {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: var(--line-2);
  transition: 0.2s;
}
.tgl i::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  inset-inline-start: 3px;
  transition: 0.2s var(--ease);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.tgl input:checked + i {
  background: var(--brand);
}
.tgl input:checked + i::after {
  inset-inline-start: 19px;
}
.seg {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.seg button {
  flex: 1;
  min-height: 28px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: 0.14s;
}
.seg button .icon {
  width: 13px;
  height: 13px;
}
.seg button.active {
  background: var(--card);
  color: var(--brand);
  box-shadow: var(--shadow-xs);
}
.ins-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 9px;
}
.ins-option-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
}
.ins-option-row .opt-drag {
  color: var(--muted-2);
  width: 18px;
  height: 26px;
  display: grid;
  place-items: center;
  flex: none;
  cursor: grab;
}
.ins-option-row .opt-drag .icon {
  width: 12px;
  height: 12px;
}
.ins-option-row .ins-input {
  flex: 1;
  min-width: 0;
  min-height: 31px;
  font-size: 10.5px;
}
.ins-option-row .opt-correct {
  position: relative;
  width: 25px;
  height: 25px;
  border-radius: 6px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--muted-2);
  flex: none;
  cursor: pointer;
  transition: 0.14s;
}
.ins-option-row .opt-correct input {
  position: absolute;
  opacity: 0;
}
.ins-option-row .opt-correct .icon {
  width: 12px;
  height: 12px;
}
.ins-option-row .opt-correct:has(input:checked) {
  background: var(--mint-soft);
  border-color: var(--mint);
  color: #047857;
}
[data-theme="dark"] .ins-option-row .opt-correct:has(input:checked) {
  color: var(--mint);
}
.ins-option-row .opt-del {
  width: 25px;
  height: 25px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--muted-2);
  flex: none;
}
.ins-option-row .opt-del:hover {
  background: var(--coral-soft);
  color: #e11d48;
}
.ins-option-row .opt-del .icon {
  width: 12px;
  height: 12px;
}
.ins-add-option {
  width: 100%;
  min-height: 30px;
  border: 1px dashed var(--line-2);
  border-radius: 7px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 2px;
  transition: 0.14s;
}
.ins-add-option:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}
.ins-add-option .icon {
  width: 12px;
  height: 12px;
}
.quiz-hint {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  font-size: 9px;
  color: #047857;
  background: var(--mint-soft);
  border-radius: 7px;
  padding: 6px 8px;
  line-height: 1.7;
  margin-bottom: 7px;
}
[data-theme="dark"] .quiz-hint {
  color: var(--mint);
}
.quiz-hint .icon {
  width: 12px;
  height: 12px;
  flex: none;
  margin-top: 1px;
}
.ins-footer-actions {
  display: flex;
  gap: 6px;
  padding-top: 4px;
}
.ins-footer-actions .btn {
  flex: 1;
  min-height: 34px;
  font-size: 10.5px;
  padding: 4px 9px;
}
.ins-danger-btn {
  color: #dc2626 !important;
  border-color: color-mix(in srgb, #dc2626 25%, var(--line)) !important;
}
.ins-danger-btn:hover {
  background: var(--coral-soft) !important;
}
[data-theme="dark"] .ins-danger-btn {
  color: #f87171 !important;
}

/* swatches */
.ins-swatches {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}
.swatch {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  transition: 0.15s;
  position: relative;
}
.swatch:hover {
  transform: scale(1.1);
}
.swatch.active {
  border-color: var(--card);
  box-shadow: 0 0 0 2px var(--ink);
}
.color-input {
  width: 34px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  padding: 2px;
  cursor: pointer;
}
.range-row {
  display: flex;
  align-items: center;
  gap: 9px;
}
.range-row input[type="range"] {
  flex: 1;
  accent-color: var(--brand);
  height: 4px;
}
.range-row output {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  min-width: 30px;
  text-align: center;
  background: var(--bg);
  border-radius: 5px;
  padding: 1px 4px;
}
.cover-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}
.cover-opt {
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16/10;
  background: var(--bg-2);
  position: relative;
  transition: 0.15s;
}
.cover-opt img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cover-opt:hover {
  transform: translateY(-1px);
  border-color: var(--line-2);
}
.cover-opt.active {
  border-color: var(--brand);
}
.cover-opt.no-cover {
  display: grid;
  place-items: center;
  color: var(--muted-2);
  font-size: 9px;
  background: linear-gradient(135deg, var(--brand-soft), var(--mint-soft));
}
.cover-opt.no-cover .icon {
  width: 15px;
  height: 15px;
}

/* logic */
.logic-intro {
  background: linear-gradient(135deg, var(--brand-soft), color-mix(in srgb, var(--violet) 9%, var(--card)));
  border: 1px solid color-mix(in srgb, var(--brand) 14%, var(--line));
  border-radius: 10px;
  padding: 10px;
  font-size: 9.5px;
  line-height: 1.8;
  color: var(--muted);
  margin-bottom: 11px;
}
.logic-intro b {
  color: var(--brand);
  display: block;
  font-size: 10.5px;
  margin-bottom: 1px;
}
.rule-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  padding: 9px 10px;
  margin-bottom: 7px;
  transition: 0.15s;
}
.rule-card:hover {
  border-color: var(--line-2);
  box-shadow: var(--shadow-xs);
}
.rule-card.disabled {
  opacity: 0.55;
}
.rule-top {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rule-badge {
  font-size: 8.5px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 20px;
  flex: none;
}
.rule-badge.show {
  background: var(--mint-soft);
  color: #047857;
}
.rule-badge.hide {
  background: var(--coral-soft);
  color: #be123c;
}
.rule-badge.require {
  background: var(--amber-soft);
  color: #a16207;
}
[data-theme="dark"] .rule-badge.show { color: var(--mint); }
[data-theme="dark"] .rule-badge.hide { color: var(--coral); }
[data-theme="dark"] .rule-badge.require { color: var(--amber); }
.rule-top .rule-target {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rule-top .tgl {
  margin-inline-start: auto;
  transform: scale(0.8);
  transform-origin: center;
}
.rule-desc {
  font-size: 9px;
  color: var(--muted-2);
  line-height: 1.7;
  margin-top: 3px;
}
.rule-desc b {
  color: var(--muted);
}
.rule-del {
  font-size: 8.5px;
  color: var(--muted-2);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 5px;
}
.rule-del:hover {
  color: #dc2626;
}
.rule-del .icon {
  width: 10px;
  height: 10px;
}
.logic-builder {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: var(--bg);
}
.logic-builder .ins-field > label {
  font-size: 9.5px;
}
.logic-builder .ins-select {
  min-height: 31px;
  font-size: 10px;
  background-color: var(--card);
}
.logic-empty {
  font-size: 10px;
  color: var(--muted-2);
  text-align: center;
  padding: 18px 8px;
  border: 1px dashed var(--line-2);
  border-radius: 9px;
  margin-bottom: 9px;
  line-height: 1.8;
}

/* share */
.share-status {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  background: var(--bg);
}
.share-status .ss-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  flex: none;
}
.share-status .ss-icon .icon {
  width: 15px;
  height: 15px;
}
.share-status .ss-body {
  flex: 1;
  min-width: 0;
}
.share-status b {
  font-size: 10.5px;
  display: block;
}
.share-status small {
  font-size: 9px;
  color: var(--muted-2);
}
.share-link-box {
  display: flex;
  gap: 5px;
}
.share-link-box input {
  flex: 1;
  min-width: 0;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  padding: 0 9px;
  font-size: 9.5px;
  direction: ltr;
  outline: 0;
}
.share-link-box .btn {
  min-height: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
}
.share-link-box .btn .icon {
  width: 14px;
  height: 14px;
}
.qr-box {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  padding: 11px;
  text-align: center;
  margin: 10px 0 7px;
}
.qr-box svg {
  margin-inline: auto;
  border-radius: 4px;
}
.qr-box p {
  font-size: 8.5px;
  color: #7a8199;
  margin-top: 5px;
}
.share-social {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}
.share-social button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 9.5px;
  font-weight: 600;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--card);
  transition: 0.14s;
}
.share-social button:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}
.share-social button .icon {
  width: 13px;
  height: 13px;
}
.embed-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  direction: ltr;
  min-height: 64px;
}
.share-note {
  font-size: 8.5px;
  color: var(--muted-2);
  line-height: 1.7;
  margin-top: 4px;
  display: flex;
  gap: 4px;
}
.share-note .icon {
  width: 11px;
  height: 11px;
  flex: none;
  margin-top: 1px;
}
.publish-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-top: 11px;
}
.publish-box h4 {
  font-size: 10.5px;
  margin-bottom: 3px;
}
.publish-box p {
  font-size: 9px;
  color: var(--muted-2);
  line-height: 1.7;
  margin-bottom: 8px;
}
.publish-box .btn {
  width: 100%;
  min-height: 34px;
  font-size: 11px;
  border-radius: 8px;
}

/* ============ mobile ============ */
.panel-backdrop {
  display: none;
}
.builder-mobile-bar {
  display: none;
}
.builder-mobile-bar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 9px;
  font-weight: 600;
  color: var(--muted-2);
  padding: 5px 2px;
  border-radius: 9px;
}
.builder-mobile-bar button .icon {
  width: 19px;
  height: 19px;
}
.builder-mobile-bar button.active {
  color: var(--brand);
}
.builder-mobile-bar button.primary {
  color: var(--brand);
}

/* preview & publish modals */
.preview-modal .modal-panel {
  width: min(1060px, 100%);
  height: min(90vh, 900px);
  display: flex;
  flex-direction: column;
}
.preview-modal .modal-body {
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: 0 0 18px 18px;
  background: var(--bg);
}
.preview-stage {
  height: 100%;
  overflow-y: auto;
  padding: 18px;
  background-image: radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--line-2) 62%, transparent) 1px, transparent 0);
  background-size: 20px 20px;
}
.preview-stage .fy-public {
  min-height: 0;
  padding: 0;
  background: transparent;
  max-width: 720px;
  margin-inline: auto;
}
.preview-stage .fy-public::before {
  display: none;
}
.preview-stage .fy-form-hero {
  border-radius: 20px 20px 0 0;
}
.preview-stage .fy-form-card {
  box-shadow: 0 24px 60px -30px rgba(16, 21, 50, 0.35);
}
.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  flex: none;
}
.preview-toolbar span {
  font-size: 10.5px;
  color: var(--muted-2);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.preview-toolbar span .icon {
  width: 13px;
  height: 13px;
}
.preview-toolbar .spacer {
  flex: 1;
}
.publish-modal .modal-panel {
  width: min(540px, 100%);
}
.publish-hero {
  text-align: center;
  padding: 6px 0 12px;
}
.publish-hero .ph-icon {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--mint-soft);
  color: #047857;
  display: grid;
  place-items: center;
  margin: 0 auto 10px;
}
[data-theme="dark"] .publish-hero .ph-icon {
  color: var(--mint);
}
.publish-hero .ph-icon .icon {
  width: 27px;
  height: 27px;
}
.publish-hero h3 {
  font-size: 16px;
}
.publish-hero p {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.9;
  margin-top: 3px;
}
.publish-link {
  display: flex;
  gap: 5px;
  margin-top: 10px;
}
.publish-link input {
  flex: 1;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 9px;
  padding: 0 10px;
  font-size: 10px;
  direction: ltr;
}
.publish-link .btn {
  min-height: 38px;
  height: 38px;
  padding: 0 12px;
}
.publish-link .btn .icon {
  width: 15px;
  height: 15px;
}
.publish-checks {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  text-align: right;
}
.publish-checks span {
  font-size: 10px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.publish-checks span .icon {
  width: 13px;
  height: 13px;
  color: var(--mint);
}

/* confirmation modal */
.confirm-modal .modal-panel {
  width: min(420px, 100%);
}

/* ============ responsive ============ */
@media (max-width: 1240px) {
  .builder-main {
    grid-template-columns: 228px minmax(0, 1fr) 310px;
  }
  .bt-brand b {
    display: none;
  }
}
@media (max-width: 1080px) {
  .builder-main {
    grid-template-columns: 216px minmax(0, 1fr) 292px;
  }
  .bt-actions .btn .btn-label {
    display: none;
  }
  .bt-actions .btn-sm {
    padding: 5px 9px;
  }
  .bt-actions .btn-sm .icon {
    width: 15px;
    height: 15px;
  }
  .canvas-scroll {
    padding-inline: 16px;
  }
  .canvas-tip {
    display: none;
  }
}
@media (max-width: 900px) {
  .builder-topbar {
    height: 58px;
    padding-inline: 9px;
    gap: 6px;
  }
  .bt-brand,
  .bt-status,
  .bt-divider,
  .bt-undo-redo,
  .device-toggle {
    display: none;
  }
  .bt-title-wrap {
    max-width: none;
  }
  .bt-title-input {
    font-size: 12.5px;
  }
  .bt-meta {
    font-size: 8.5px;
  }
  .bt-actions .btn-primary,
  .bt-actions .btn-outline {
    min-height: 32px;
    padding: 4px 10px;
    font-size: 11px;
  }
  .bt-actions #shareTopBtn {
    display: none;
  }
  .bt-actions #previewTopBtn .btn-label {
    display: none;
  }
  .bt-actions #previewTopBtn {
    padding: 4px 8px;
  }
  .builder-main {
    display: block;
    position: relative;
  }
  .builder-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    width: min(342px, 90vw);
    z-index: 120;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s var(--ease);
    display: flex;
  }
  .palette-panel {
    inset-inline-start: 0;
    transform: translateX(105%);
    border-inline-end: 1px solid var(--line);
    border-start-end-radius: 0;
    border-end-end-radius: 0;
  }
  .inspector-panel {
    inset-inline-end: 0;
    transform: translateX(-105%);
    border-inline-start: 1px solid var(--line);
  }
  .palette-panel.open,
  .inspector-panel.open {
    transform: translateX(0);
  }
  .bp-close {
    display: inline-flex;
  }
  .bp-body,
  .ins-body {
    padding-bottom: 30px;
  }
  .panel-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(8, 11, 28, 0.5);
    backdrop-filter: blur(3px);
    z-index: 110;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }
  .panel-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }
  .builder-canvas {
    height: 100%;
  }
  .canvas-topline {
    height: 36px;
    padding-inline: 13px;
    font-size: 9.5px;
  }
  .canvas-scroll {
    padding: 14px 11px 78px;
  }
  .canvas-frame {
    max-width: 100%;
  }
  .builder-mobile-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    inset-inline: 0;
    z-index: 80;
    background: color-mix(in srgb, var(--card) 94%, transparent);
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--line);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    gap: 3px;
  }
  .builder-shell {
    padding-bottom: 0;
  }
  .preview-modal {
    padding: 0;
  }
  .preview-modal .modal-panel {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .preview-modal .modal-body {
    border-radius: 0;
  }
  .preview-stage {
    padding: 8px;
  }
  /* keep the mobile preview header compact: title + close only */
  .preview-modal .modal-head .preview-toolbar {
    display: none;
  }
}
@media (max-width: 520px) {
  .bt-back {
    width: 30px;
  }
  .bt-meta .dot-sep,
  .bt-meta .word-count {
    display: none;
  }
  .bt-actions #previewTopBtn {
    display: none;
  }
  .bt-actions .btn-primary .btn-label {
    display: inline;
  }
  .canvas-frame.device-mobile {
    max-width: 100%;
  }
  .canvas-scroll {
    padding-inline: 8px;
  }
}

/* ---------- builder publishing bridge ---------- */
.publish-mode-links {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-top: 14px;
}
.publish-mode-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 5px;
  font-size: 9px;
  color: var(--muted);
  background: var(--surface-2);
  text-align: center;
}
.publish-mode-link .icon { width: 14px; height: 14px; }
.publish-mode-link:hover { border-color: var(--accent-line, var(--line)); color: var(--text); }
.publish-mode-link.active { background: var(--accent-soft, rgba(4, 120, 87,.08)); border-color: var(--accent-line, var(--line)); color: var(--accent); font-weight: 700; }
.publish-mode-link.landing { grid-column: span 4; flex-direction: row; justify-content: center; gap: 6px; }
.publish-settings-cta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  margin-top: 8px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.psc-icon { width: 29px; height: 29px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--surface); color: var(--accent); }
.psc-icon .icon { width: 14px; height: 14px; }
.psc-copy { flex: 1; min-width: 0; }
.psc-copy b { display: block; font-size: 9.5px; }
.psc-copy small { display: block; font-size: 8px; color: var(--muted-2); line-height: 1.6; }
.publish-settings-cta .btn { flex: none; }
@media (max-width: 480px) {
  .publish-settings-cta { flex-wrap: wrap; }
  .publish-settings-cta .btn { width: 100%; justify-content: center; }
}
