.row-builder-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.row-builder-modal.open {
  display: flex;
}

.row-builder-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

.row-builder-panel {
  position: relative;
  width: min(720px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 44px rgba(0, 0, 0, 0.24);
  font-size: 20px;
  line-height: 1.45;
}

.row-builder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.15rem;
}

.row-builder-header h2 {
  margin: 0;
  font-size: 1.65rem;
}

.row-builder-body {
  padding: 1.15rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.row-builder-step[hidden] {
  display: none !important;
}

.row-builder-step {
  opacity: 0;
  transform: translateY(8px);
  will-change: opacity, transform;
}

.row-builder-step.is-active {
  opacity: 1;
  transform: translateY(0);
}

.row-builder-step.is-leaving {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

.row-builder-subtitle {
  margin: 0 0 0.8rem 0;
  font-size: 1em;
}

.row-builder-tools-fallback {
  display: none;
}

.row-builder-step-nav {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 1rem;
}

.row-builder-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 999px;
  padding: 0.7rem 1rem;
  font-family: inherit;
  font-size: 1em;
  font-weight: 800;
  cursor: pointer;
}

.row-type-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.row-builder-step-type .row-type-options {
  margin-bottom: 0;
}

.row-type-option {
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 14px;
  padding: 1rem 0.85rem;
  font-family: inherit;
  font-size: 1em;
  cursor: pointer;
  background: #fff;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  color: #111;
  min-height: 180px;
}

.row-type-option.active {
  border-color: rgba(0, 0, 0, 0.45);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);
}

.row-type-option-icon {
  width: 72px;
  min-width: 72px;
  height: 72px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 0, 0, 0.16);
}

.row-type-option-icon i {
  font-size: 1.8rem;
  line-height: 1;
}

.row-type-option-text {
  font-weight: 700;
  font-size: 1em;
}

.preview-theme-row {
  display: flex;
  width: 100%;
  min-height: 88px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.preview-theme-column {
  width: 50%;
  flex: 0 0 50%;
  box-sizing: border-box;
}

.preview-theme-left {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  padding: 0.45rem;
}

.preview-theme-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.08);
}

.preview-theme-icon i {
  font-size: 1.1rem;
}

.preview-theme-map {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  background:
    linear-gradient(180deg, rgba(125, 176, 114, 0.24), rgba(125, 176, 114, 0.08)),
    repeating-linear-gradient(
      45deg,
      rgba(46, 83, 38, 0.14) 0,
      rgba(46, 83, 38, 0.14) 8px,
      rgba(255, 255, 255, 0.08) 8px,
      rgba(255, 255, 255, 0.08) 16px
    );
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.7rem;
  font-weight: 800;
}

.preview-theme-right {
  position: relative;
  padding: 0.58rem 0.62rem;
  display: inline-flex;
  align-items: center;
}

.preview-theme-text {
  font-size: 0.82rem;
  line-height: 1.35;
}

.preview-theme-text ul {
  margin: 0.34rem 0 0;
  padding-left: 1rem;
}

.preview-theme-heading {
  border-radius: 8px;
  padding: 0.65rem 0.7rem;
  font-weight: 800;
  text-align: center;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.preview-numbered {
  position: relative;
}

.preview-number-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-height: 24px;
  min-width: 24px;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9em;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.preview-number-label-right {
  max-width: calc(100% - 12px);
}

.row-inline-choice {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.row-inline-choice.row-inline-choice-dual {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.row-choice-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  background: #fff;
  padding: 0.7rem 0.8rem;
  font-size: 1rem;
  cursor: pointer;
  color: #111;
}

.row-inline-choice label.row-choice-pill:nth-child(even) {
  background: #fff;
  color: #111;
}

.row-choice-pill input[type="radio"] {
  width: auto;
  display: inline-block;
  margin: 0;
}

.row-display-choice-pill {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  margin-bottom: 0;
  align-items: stretch;
}

.row-display-choice-pill input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
  margin: 0;
}

.row-display-choice-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  min-height: 148px;
  border: 1px solid rgba(0, 0, 0, 0.24);
  border-radius: 10px;
  background: #fff;
  padding: 0.75rem;
  box-sizing: border-box;
}

.row-display-choice-pill input[type="radio"]:checked + .row-display-choice-card {
  border-color: rgba(0, 0, 0, 0.78);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.16);
}

.row-display-choice-visual {
  width: 100%;
  min-height: 54px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.row-display-choice-media,
.row-display-choice-map-grid {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.row-display-choice-media {
  background: rgba(0, 0, 0, 0.08);
}

.row-display-choice-media-soft {
  background: rgba(0, 0, 0, 0.045);
}

.row-display-choice-map-grid {
  background:
    linear-gradient(180deg, rgba(122, 168, 106, 0.22), rgba(122, 168, 106, 0.08)),
    repeating-linear-gradient(
      45deg,
      rgba(37, 71, 32, 0.14) 0,
      rgba(37, 71, 32, 0.14) 8px,
      rgba(255, 255, 255, 0.06) 8px,
      rgba(255, 255, 255, 0.06) 16px
    );
}

.row-display-choice-text {
  background: rgba(0, 0, 0, 0.04);
}

.row-display-choice-visual-qr-document {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.row-display-choice-visual-qr-url {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.row-display-choice-title {
  font-size: 1em;
  font-weight: 800;
  line-height: 1.2;
}

.row-display-choice-desc {
  font-size: 1em;
  line-height: 1.35;
  opacity: 0.86;
}

.row-field-group {
  display: none;
}

.row-field-group.active {
  display: block;
}

.row-field-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
  font-size: 1em;
}

.row-field-group label i {
  margin-right: 0.35rem;
  opacity: 0.9;
}

.row-field-group input,
.row-field-group textarea {
  display: block;
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  font-family: inherit;
  font-size: 1em;
  background: #fff;
  color: #111;
  box-sizing: border-box;
}

.row-field-group textarea {
  resize: vertical;
}

.row-rich-input {
  display: block;
  width: 100%;
  min-height: 150px;
  margin-bottom: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  font-family: inherit;
  font-size: 1em;
  background: #fff;
  color: #111;
  box-sizing: border-box;
  line-height: 1.45;
}

.row-rich-input:empty::before {
  content: attr(data-placeholder);
  color: rgba(17, 17, 17, 0.5);
}

.row-builder-text-tools {
  border-radius: 8px;
  padding: 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(0, 0, 0, 0.2);
  flex-wrap: wrap;
}

.row-builder-text-tools.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.row-builder-tool-btn {
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 8px;
  min-width: 52px;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.row-builder-tool-btn:hover {
  filter: brightness(0.98);
  transform: translateY(-1px);
}

.row-builder-tool-btn i {
  line-height: 1;
}

.row-builder-link-panel {
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 10px;
  padding: 0.9rem;
  background: #fff;
  margin-bottom: 1rem;
}

.row-builder-link-panel label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
  font-size: 1em;
}

.row-builder-link-panel input {
  display: block;
  width: 100%;
  margin-bottom: 0.8rem;
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  font-family: inherit;
  font-size: 1em;
  box-sizing: border-box;
}

.row-builder-link-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.row-builder-error {
  min-height: 1.2rem;
  color: #9a1a1a;
  font-size: 1em;
}

.row-builder-actions {
  display: flex;
  flex-shrink: 0;
  justify-content: stretch;
  gap: 0.6rem;
  padding: 1rem 1.15rem 1.15rem;
  border-top: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.65);
}

.row-builder-actions[hidden] {
  display: none !important;
}

.row-builder-btn {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  font-family: inherit;
  cursor: pointer;
}

.row-builder-actions .row-builder-btn {
  width: 100%;
  min-height: 58px;
  font-size: 1em;
  font-weight: 800;
}

@media (max-width: 680px) {
  .row-type-options {
    grid-template-columns: 1fr;
  }

  .row-inline-choice.row-inline-choice-dual {
    grid-template-columns: 1fr;
  }
}
