:root {
  --bg: #eef3f7;
  --panel: #ffffff;
  --panel-alt: #0f172a;
  --panel-soft: #f8fbfd;
  --line: #d6e2ea;
  --text: #163042;
  --muted: #64748b;
  --accent: #027fc0;
  --accent-strong: #025f91;
  --success: #0d9488;
  --danger: #dc2626;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --radius: 18px;
  --editor-panel-height: calc(100vh - 148px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at top left, rgba(2, 127, 192, 0.16), transparent 30%),
    linear-gradient(180deg, #f7fbfd 0%, var(--bg) 100%);
  color: var(--text);
  font-family: "SF Pro Display", "Segoe UI", sans-serif;
}

body {
  padding: 16px;
  overflow-x: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

#app {
  display: flex;
  flex-direction: column;
  gap: 12px;
}


.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 460px) minmax(400px, 1fr);
  gap: 20px;
  align-items: start;
  margin-bottom: 106px;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(214, 226, 234, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.landing-page {
  min-height: calc(100vh - 32px);
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  justify-items: center;
  padding: 28px 16px;
}

.landing-panel {
  grid-row: 2;
  width: min(520px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.landing-brand .preview-brand {
  justify-self: center;
}

.landing-brand .preview-brand svg {
  width: min(280px, 74vw);
}

.landing-brand .designer-credit {
  display: none;
}

.landing-hook {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

.landing-credit {
  grid-row: 3;
  align-self: end;
  display: inline-flex;
  gap: 5px;
  align-items: baseline;
  color: #007fc0;
  font-size: 0.76rem;
  line-height: 1.2;
}

.newsletter-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 4px;
}

.newsletter-card {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  font-weight: 800;
  text-align: left;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
}

.newsletter-card.active:hover {
  border-color: #9bd4ee;
  background: #eef8fd;
}

.newsletter-card.inactive {
  cursor: not-allowed;
  opacity: 0.56;
  box-shadow: none;
}

.newsletter-index {
  width: 34px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
}

.editor-shell {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: var(--editor-panel-height);
}

.section {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
  overflow: hidden;
  position: relative;
  transition: margin 0.18s ease, border-color 0.18s ease, background-color 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
}

.section summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  font-weight: 700;
  cursor: pointer;
}

.section summary::-webkit-details-marker {
  display: none;
}

.section-body {
  padding: 0 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.draggable-section summary {
  cursor: grab;
}

.draggable-section summary:active {
  cursor: grabbing;
}

.draggable-section.dragging {
  opacity: 0.42;
}

.draggable-section.dragging-active {
  transform: scale(0.99);
  border-color: #9bd4ee;
  background: #eef8fd;
}

.draggable-section.drop-before {
  margin-top: 14px;
  border-top-color: var(--accent);
}

.draggable-section.drop-after {
  margin-bottom: 14px;
  border-bottom-color: var(--accent);
}

.draggable-section.drop-before::before,
.draggable-section.drop-after::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(2, 127, 192, 0.12);
  pointer-events: none;
}

.draggable-section.drop-before::before {
  top: -9px;
}

.draggable-section.drop-after::after {
  bottom: -9px;
}

.drag-handle {
  display: none;
}

.section-meta {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  padding: 11px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(2, 127, 192, 0.12);
}

.check-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 700;
}

.check-field.full {
  grid-column: 1 / -1;
}

.check-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.subcard {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.subcard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.subcard-title {
  font-weight: 800;
  font-size: 0.96rem;
}

.link-editor {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.link-card {
  background: #f8fbfd;
}

.subcard-tools,
.toolbar,
.bottom-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.component-actions {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.component-move-tools {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 6px;
}

.move-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #9bd4ee;
  border-radius: 8px;
  background: #dff2fb;
  color: #003f63;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.move-btn:hover:not(:disabled) {
  background: #ccebf8;
}

.move-btn:disabled {
  cursor: not-allowed;
  opacity: 0.38;
  background: #f1f5f9;
  color: var(--muted);
  border-color: #cbd5e1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 0.84rem;
  font-weight: 800;
  background: #dff2fb;
  color: #025f91;
  border: 1px solid #9bd4ee;
}

.btn:hover {
  background: #ccebf8;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn.primary:hover {
  background: var(--accent-strong);
}

.btn.danger {
  background: #fff1f2;
  color: #b91c1c;
  border-color: #fecdd3;
}

.btn.danger:hover {
  background: #ffe4e6;
}

.btn.ghost {
  background: #f1f5f9;
  color: var(--text);
  border-color: #cbd5e1;
}

.bottom-actions .btn {
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.92rem;
}

.preview-shell {
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  height: var(--editor-panel-height);
  min-height: 0;
  position: sticky;
  top: 16px;
}

.preview-head {
  display: grid;
  grid-template-columns: minmax(132px, 1fr) auto minmax(132px, 1fr);
  align-items: center;
  gap: 12px;
}

.preview-brand {
  justify-self: start;
  text-align: center;
}

.preview-brand svg {
  display: block;
  width: 118px;
  height: auto;
  margin: 0 auto;
}

.preview-head .designer-credit {
  display: none;
}

.preview-title {
  justify-self: center;
  margin: 0;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.designer-credit {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  margin-top: 7px;
  color: #007fc0;
  font-size: 0.76rem;
  line-height: 1.15;
  white-space: nowrap;
}

.designer-label {
  font-weight: 300;
}

.designer-name {
  display: block;
  font-weight: 800;
}

.preview-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-self: end;
}

.history-tools {
  display: inline-flex;
  gap: 6px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #9bd4ee;
  border-radius: 9px;
  background: #dff2fb;
  color: #003f63;
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  display: block;
  flex: 0 0 auto;
  pointer-events: none;
}

.icon-btn:hover:not(:disabled) {
  background: #ccebf8;
  color: #002f4a;
}

.icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  background: #f1f5f9;
  color: var(--muted);
  border-color: #cbd5e1;
}

.segmented {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: #edf4f8;
  border: 1px solid var(--line);
}

.segmented-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  padding: 9px 14px;
  border-radius: 999px;
}

.segmented-btn.active {
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.preview-stage {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  overscroll-behavior: contain;
}

.preview-stage.mobile {
  align-items: center;
}

.preview-frame-shell {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.preview-frame-shell.mobile {
  width: 425px;
  max-width: 100%;
}

.preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  display: block;
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--success);
  background: rgba(13, 148, 136, 0.12);
}

.bottom-bar {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 34px;
  z-index: 10;
}

.editor-credit {
  display: inline-flex;
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 10px;
  z-index: 10;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin: 0;
  color: #007fc0;
  font-size: 0.76rem;
  line-height: 1.15;
  white-space: nowrap;
}

.bottom-actions {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(214, 226, 234, 0.8);
  box-shadow: var(--shadow);
  border-radius: 18px;
  padding: 14px 16px;
  justify-content: space-between;
  align-items: center;
}

.bottom-copy {
  min-width: 180px;
}

.bottom-copy-editable {
  min-width: 132px;
}

.bottom-copy.copied,
.bottom-copy-editable.copied {
  animation: copyPulse 0.28s ease;
}

@keyframes copyPulse {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.025);
  }
  100% {
    transform: scale(1);
  }
}

.bottom-toolbar {
  margin-left: auto;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.28);
}

.confirm-dialog {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  padding: 18px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
}

.confirm-dialog h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 1rem;
}

.confirm-dialog p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.small {
  font-size: 0.78rem;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .preview-shell {
    height: auto;
    min-height: auto;
    position: static;
  }

  .editor-shell {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  body {
    padding: 14px;
  }

  .workspace {
    margin-bottom: 154px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .bottom-bar {
    left: 14px;
    right: 14px;
    bottom: 34px;
  }

  .editor-credit {
    left: 14px;
    right: 14px;
    bottom: 10px;
  }

  .bottom-actions,
  .preview-head,
  .subcard-head {
    align-items: stretch;
  }

  .preview-head {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .preview-brand {
    justify-self: center;
  }

  .preview-tools {
    width: 100%;
    justify-content: space-between;
    justify-self: stretch;
  }

  .bottom-copy {
    width: 100%;
  }
}
