:root {
  --accent: #2563eb;
  --dark: #0d0d0f;
  --surface: #16171a;
  --surface2: #1e1f24;
  --border: rgba(37, 99, 235, 0.15);
  --border2: rgba(37, 99, 235, 0.08);
  --white: #f0f0f2;
  --muted: rgba(240, 240, 242, 0.45);
  --green: #48bb78;
  --red: #8eaceb;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Inter", sans-serif;
  background: var(--dark);
  color: var(--white);
  display: flex;
  flex-direction: column;
}

.header {
  padding: 20px 100px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(13, 13, 15, 0.98);
  flex-shrink: 0;
  z-index: 200;

  a {
    display: inline-block;
    text-decoration: none;
    color: inherit;
  }
}

.header-title {
  font-family: "Syne", sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
}

.header-title span {
  color: var(--accent);
}

.header-title small {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.75rem;
}

.btn-copy {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #111;
  border: none;
  border-radius: 7px;
  padding: 8px 16px;
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  transition:
    opacity 0.2s,
    transform 0.15s;
}

.btn-copy:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.btn-copy.copied {
  background: var(--green);
  color: #fff;
}

.btn-gmail {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 14px;
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-gmail:hover {
  background: rgba(37, 99, 235, 0.08);
  border-color: var(--accent);
}

.btn-gmail.copied {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.btn-new {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 14px;
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-new:hover {
  border-color: var(--red);
  color: var(--red);
  background: rgba(129, 178, 252, 0.06);
}

.workspace {
  display: grid;
  grid-template-columns: 460px 1fr;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 14px 60px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.section-label {
  font-size: .875rem;
  font-weight: 700;
  letter-spacing: 0.05rem;
  /* text-transform: uppercase; */
  color: var(--accent);
  margin-bottom: 0.6rem;
}

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

.field label {
  font-size: 0.73rem;
  font-weight: 500;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.field input[type="text"],
.field input[type="url"],
.field textarea {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 7px;
  color: var(--white);
  font-family: "Inter", sans-serif;
  font-size: 0.8rem;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
}

.field textarea {
  resize: none;
  font-size: 0.75rem;
  line-height: 1.5;
  overflow: hidden;
  min-height: 40px;
}

.color-row {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 6px;
  align-items: end;
}

.field input[type="color"] {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 7px;
  height: 34px;
  width: 100%;
  padding: 3px 4px;
  cursor: pointer;
  outline: none;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.three-col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 7px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.2s;
}

.toggle-row:hover {
  border-color: var(--accent);
}

.toggle-row input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.toggle-row span {
  font-size: 0.78rem;
  color: var(--muted);
}

.divider-line {
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(37, 99, 235, 0.15),
    transparent
  );
  flex-shrink: 0;
}

/* BLOCKS */
.block-wrap {
  border: 1px solid var(--border2);
  border-radius: 9px;
  overflow: hidden;
  background: var(--dark);
}

.block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  background: rgba(37, 99, 235, 0.05);
  border-bottom: 1px solid var(--border2);
  gap: 6px;
}

.block-label {
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.block-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.seg-btn {
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 7px;
  transition: all 0.15s;
  font-family: "Inter", sans-serif;
}

.seg-btn:hover {
  border-color: rgba(37, 99, 235, 0.3);
  color: var(--white);
}

.seg-btn.active {
  background: rgba(37, 99, 235, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.block-remove {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px 5px;
  border-radius: 4px;
  transition: all 0.15s;
  line-height: 1;
}

.block-remove:hover {
  color: var(--red);
  background: rgba(252, 129, 129, 0.1);
}

.rich-toolbar {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  padding: 5px 6px;
  background: #111113;
  border-bottom: 1px solid var(--border2);
  align-items: center;
}

.tb-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-family: "Inter", sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 6px;
  transition: all 0.15s;
  white-space: nowrap;
}

.tb-btn:hover {
  background: var(--surface2);
  border-color: var(--border2);
  color: var(--white);
}

.tb-sep {
  width: 1px;
  background: var(--border2);
  margin: 2px 1px;
  align-self: stretch;
  flex-shrink: 0;
}

.tb-size {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 4px;
  color: var(--white);
  font-family: "Inter", sans-serif;
  font-size: 0.68rem;
  padding: 3px 4px;
  outline: none;
  width: 50px;
  cursor: pointer;
  height: 24px;
}

.color-trigger {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  font-family: "Inter", sans-serif;
  transition: all 0.15s;
  white-space: nowrap;
}

.color-trigger:hover {
  background: var(--surface2);
  border-color: rgba(37, 99, 235, 0.2);
  color: var(--white);
}

.color-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

/* editor visual */
.editor {
  min-height: 80px;
  background: var(--surface2);
  border: none;
  padding: 9px 10px;
  outline: none;
  font-size: 0.8rem;
  line-height: 1.65;
  color: var(--white);
  overflow-y: auto;
}

.editor:focus {
  outline: 1px solid rgba(37, 99, 235, 0.3);
  outline-offset: -1px;
}

.editor a {
  color: var(--accent);
}

.editor ul,
.editor ol {
  padding-left: 18px;
}

.btn-add-block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px dashed rgba(37, 99, 235, 0.2);
  border-radius: 7px;
  color: var(--muted);
  font-family: "Inter", sans-serif;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}

.btn-add-block:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(37, 99, 235, 0.04);
}

.optional-block {
  border: 1px dashed rgba(37, 99, 235, 0.15);
  border-radius: 9px;
  padding: 11px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.optional-block.enabled {
  border-color: var(--accent);
  border-style: solid;
}

.btn-insert-var {
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: 5px;
  color: var(--accent);
  cursor: pointer;
  font-family: "Inter", sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 7px;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-insert-var:hover {
  background: rgba(37, 99, 235, 0.16);
}

/* social toggles */
.titulo-social {
  margin-top: 0.6rem;
}

.social-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.social-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.social-check {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 5px 9px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.social-check input[type="checkbox"] {
  accent-color: var(--accent);
  width: 13px;
  height: 13px;
  cursor: pointer;
}

.social-check span {
  font-size: 0.72rem;
  color: var(--muted);
}

.social-check:hover {
  border-color: var(--accent);
}

.social-url {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--white);
  font-family: "Inter", sans-serif;
  font-size: 0.75rem;
  padding: 5px 9px;
  outline: none;
  transition: border-color 0.2s;
}

.social-url:focus {
  border-color: var(--accent);
}

/* COLOR POPUP */
#globalColorPopup {
  display: none;
  position: fixed;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px;
  gap: 8px;
  flex-direction: column;
  width: 200px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

#globalColorPopup.open {
  display: flex;
}

#globalColorPopup input[type="color"] {
  width: 100%;
  height: 100px;
  border: none;
  cursor: pointer;
  border-radius: 6px;
  padding: 0;
}

.color-popup-hex {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--white);
  font-family: "Inter", sans-serif;
  font-size: 0.78rem;
  padding: 6px 8px;
  outline: none;
  width: 100%;
  transition: border-color 0.2s;
}

.color-popup-hex:focus {
  border-color: var(--accent);
}

.popup-btns {
  display: flex;
  gap: 6px;
}

.btn-apply-color {
  flex: 1;
  background: var(--accent);
  color: #111;
  border: none;
  border-radius: 6px;
  padding: 7px;
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-apply-color:hover {
  opacity: 0.85;
}

.btn-reset-color {
  flex: 1;
  background: rgba(252, 129, 129, 0.12);
  color: var(--red);
  border: 1px solid rgba(252, 129, 129, 0.25);
  border-radius: 6px;
  padding: 7px;
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-reset-color:hover {
  background: rgba(252, 129, 129, 0.2);
}

/* PREVIEW */
.preview-area {
  background: #1c1c1e;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.preview-topbar {
  background: #111113;
  border-bottom: 1px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 0;
  flex-shrink: 0;
}

.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.view-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-family: "Inter", sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 7px 18px;
  transition: all 0.2s;
}

.view-btn.active {
  background: var(--accent);
  color: #111;
}

.view-btn:not(.active):hover {
  background: rgba(37, 99, 235, 0.08);
  color: var(--white);
}

/* SCROLL FIX: o scroll é da preview-scroll-area, o iframe cresce com o conteúdo */
.preview-scroll-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: 24px 16px 40px;
  align-items: flex-start;
}

.preview-frame-wrap {
  width: 100%;
  max-width: 660px;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  transition: max-width 0.3s ease;
  flex-shrink: 0;
}

.preview-frame-wrap.mobile {
  max-width: 420px;
}

#previewFrame {
  width: 100%;
  border: none;
  display: block;
  background: #181818;
  min-height: 200px;
}