:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --line: #e7e4dc;
  --ink: #21180f;
  --ink-soft: #5f5448;
  --brand: #b26a3f;
  --brand-dark: #8d4f2a;
  --ok: #1f8f5f;
  --bad: #cc4b3f;
  --radius: 14px;
  --shadow: 0 12px 30px rgba(34, 28, 20, 0.08);
  --shell: #faf8f4;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: "Lato", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

.app-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hero-shell {
  background: radial-gradient(circle at 20% 20%, rgba(178, 106, 63, 0.15), transparent 38%),
              radial-gradient(circle at 85% 12%, rgba(96, 66, 38, 0.08), transparent 33%),
              var(--shell);
  border-bottom: 1px solid var(--line);
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem;
  max-width: 1180px;
  margin: 0 auto;
}

.brand {
  font-family: "Playfair Display", serif;
  font-size: 1.25rem;
  letter-spacing: 0.08em;
}

.nav-links {
  display: none;
  gap: 1rem;
  color: var(--ink-soft);
}

.btn {
  border: 0;
  border-radius: 999px;
  height: 44px;
  padding: 0 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.92rem;
}

.btn-primary {
  background: linear-gradient(140deg, var(--brand), var(--brand-dark));
  color: #fff;
}

.btn-ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.hero-content {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

.hero-content h1 {
  font-family: "Playfair Display", serif;
  font-size: clamp(2rem, 8vw, 3.5rem);
  line-height: 1.1;
  margin: 0.5rem 0;
}

.hero-content p {
  color: var(--ink-soft);
  max-width: 52ch;
  line-height: 1.6;
}

.feature-grid,
.plan-grid,
.dashboard-grid,
.admin-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: 1fr;
}

.section {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.card h3,
.card h4 {
  margin-top: 0;
}

.kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
  color: var(--ink-soft);
}

.price {
  font-size: 1.6rem;
  font-weight: 800;
}

.old-price {
  text-decoration: line-through;
  color: #8e8579;
  font-size: 0.9rem;
}

.form-shell {
  max-width: 540px;
  margin: 3rem auto;
  padding: 1rem;
}

.form-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.form-card h2 {
  margin-top: 0;
  font-family: "Playfair Display", serif;
}

.form-group {
  margin-bottom: 0.85rem;
}

label {
  display: block;
  font-size: 0.86rem;
  margin-bottom: 0.35rem;
  color: var(--ink-soft);
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 104px;
  resize: vertical;
}

.flash {
  border-radius: 10px;
  padding: 0.75rem;
  font-size: 0.9rem;
  margin-bottom: 0.8rem;
}

.flash-ok {
  background: #eaf8f1;
  color: #1d6f4c;
  border: 1px solid #c2e8d3;
}

.flash-bad {
  background: #ffefec;
  color: #8f3229;
  border: 1px solid #ffd2cb;
}

.app-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
}

.sidebar {
  background: #15120e;
  color: #f6efdf;
  padding: 1rem;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
}

.sidebar-toggle {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  color: #f6efdf;
  background: rgba(255, 255, 255, 0.08);
  min-height: 34px;
  padding: 0 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.sidebar-body {
  display: block;
}

.sidebar h2 {
  font-family: "Playfair Display", serif;
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.sidebar-head h2 {
  margin-bottom: 0.3rem;
}

.sidebar nav {
  display: grid;
  gap: 0.4rem;
}

.sidebar a {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 0.7rem;
  font-size: 0.92rem;
  color: #f6efdf;
}

.sidebar a.active,
.sidebar a:hover {
  background: rgba(178, 106, 63, 0.35);
  border-color: rgba(178, 106, 63, 0.7);
}

.main {
  padding: 1rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.topbar h1 {
  margin: 0;
  font-family: "Playfair Display", serif;
  font-size: clamp(1.2rem, 5vw, 1.8rem);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  border: 1px solid var(--line);
  background: #fff;
}

.badge-draft { color: #7f612d; }
.badge-published { color: var(--ok); }
.badge-failed { color: var(--bad); }

.invite-list {
  display: grid;
  gap: 0.8rem;
}

.invite-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.muted {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.builder-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: 1fr;
}

.builder-grid-v2 {
  align-items: start;
}

.builder-pane {
  min-width: 0;
  min-height: 56dvh;
  resize: vertical;
  overflow: auto;
}

.builder-resizer {
  display: none;
}

body.is-resizing-builder {
  cursor: col-resize;
  user-select: none;
}

.builder-tabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0.45rem;
  padding-bottom: 0.55rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--line);
}

.builder-tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0.48rem 0.8rem;
  border-radius: 999px;
  font-size: 0.84rem;
  white-space: nowrap;
  cursor: pointer;
}

.builder-tab.active {
  background: linear-gradient(140deg, var(--brand), var(--brand-dark));
  border-color: transparent;
  color: #fff;
}

.builder-panel {
  display: none;
  padding: 0.25rem 0;
}

.builder-panel.active {
  display: block;
}

.section-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.section-panel-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.panel-controls-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
}

.design-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0.85rem;
  margin-bottom: 0.8rem;
}

.design-card h3 {
  margin: 0 0 0.55rem;
  font-size: 0.98rem;
}

.design-card h4 {
  margin: 0.55rem 0 0.45rem;
  font-size: 0.86rem;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

.design-field-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: 1fr;
}

.color-input-pair {
  display: grid;
  grid-template-columns: 34px minmax(110px, 170px);
  gap: 0.45rem;
  align-items: center;
  justify-content: flex-start;
}

.color-input-pair input[type="color"] {
  min-height: 34px;
  border-radius: 9px;
  border: 1px solid var(--line);
  padding: 0.06rem;
  background: #fff;
}

.color-code-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  min-height: 34px;
  max-width: 170px;
  padding: 0.45rem 0.55rem;
  font-size: 0.78rem;
}

.font-preview-sample {
  margin: 0.38rem 0 0;
  border: 1px dashed #d8d1c4;
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  background: #fcfaf6;
  color: #2f2418;
  font-size: 1.04rem;
  line-height: 1.3;
}

.design-section-list {
  display: grid;
  gap: 0.55rem;
}

.design-section-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.design-section-item summary {
  list-style: none;
  cursor: pointer;
  padding: 0.65rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.design-section-item summary::-webkit-details-marker {
  display: none;
}

.design-section-item summary strong {
  font-size: 0.92rem;
}

.design-section-body {
  border-top: 1px solid var(--line);
  padding: 0.65rem;
}

.palette-grid {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.palette-chip {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0.45rem;
  text-align: left;
  display: grid;
  gap: 0.3rem;
  cursor: pointer;
}

.palette-chip.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(178, 106, 63, 0.2);
}

.palette-chip strong {
  font-size: 0.8rem;
  color: var(--ink);
}

.palette-chip-swatches {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.palette-chip-swatches span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.14);
  display: inline-block;
}

.section-design-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf8;
  margin-bottom: 0.85rem;
}

.section-design-collapsible {
  padding: 0;
  overflow: hidden;
}

.section-design-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.72rem 0.78rem;
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--ink);
}

.section-design-summary::-webkit-details-marker {
  display: none;
}

.section-design-summary::after {
  content: '\203A';
  font-size: 1.05rem;
  line-height: 1;
  color: var(--ink-soft);
  transform: rotate(90deg);
  transition: transform 0.2s ease;
}

.section-design-collapsible[open] .section-design-summary::after {
  transform: rotate(-90deg);
}

.section-design-collapsible-body {
  border-top: 1px solid var(--line);
  padding: 0.75rem;
}

.section-design-box h4 {
  margin: 0 0 0.35rem;
  font-size: 0.94rem;
}

.bottom-bar-item-card {
  margin-bottom: 0.65rem;
}

.section-design-grid-wrap {
  display: grid;
  gap: 0.65rem;
}

.section-design-group {
  border: 1px dashed #d8d0c4;
  border-radius: 10px;
  background: #fff;
  padding: 0.55rem;
}

.section-design-group h5 {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.section-builder-stack {
  display: grid;
  gap: 0.8rem;
}

.section-builder-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0.85rem;
}

.section-builder-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}

.section-builder-head h3 {
  margin: 0;
  font-size: 1rem;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
  color: var(--ink);
  font-size: 0.9rem;
}

.inline-check input[type="checkbox"] {
  width: auto;
  min-height: auto;
}

.switch-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  font-size: 0.88rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 30px;
  margin: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  background: #d4cec2;
  border-radius: 999px;
  transition: 0.2s ease;
}

.switch-slider:before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 4px;
  top: 4px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s ease;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.24);
}

.switch input:checked + .switch-slider {
  background: linear-gradient(140deg, var(--brand), var(--brand-dark));
}

.switch input:checked + .switch-slider:before {
  transform: translateX(22px);
}

.switch input:disabled + .switch-slider {
  opacity: 0.55;
}

.form-row-2 {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: 1fr;
}

.form-row-3 {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: 1fr;
}

.media-input-group {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
  align-items: center;
}

.media-input-group .btn {
  height: 40px;
  padding: 0 0.8rem;
}

.repeater {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  background: #fcfbf8;
  margin-bottom: 0.85rem;
}

.repeater-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
  flex-wrap: wrap;
}

.repeater-head h4 {
  margin: 0;
  font-size: 0.94rem;
}

.repeater-list {
  display: grid;
  gap: 0.6rem;
}

.repeater-row {
  border: 1px dashed #d8d2c7;
  border-radius: 10px;
  background: #fff;
  padding: 0.65rem;
}

.repeater-row .repeater-remove {
  height: 34px;
  font-size: 0.82rem;
}

.matrix-cell {
  display: grid;
  gap: 0.3rem;
  min-width: 150px;
}

.asset-thumb {
  width: 92px;
  height: 62px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f3f0ea;
}

.copy-samples {
  display: grid;
  gap: 0.25rem;
  font-size: 0.82rem;
}

.copy-samples code {
  background: #f6f3ec;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
  display: inline-block;
}

.media-inline-form {
  display: grid;
  gap: 0.35rem;
}

.media-inline-form select {
  min-height: 36px;
  font-size: 0.85rem;
}

.section-control-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

.section-control-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem;
  background: #fff;
}

.preview-box {
  border: 1px dashed #b8a68f;
  border-radius: 12px;
  padding: 1rem;
  background: #fffdf8;
}

.preview-iframe-wrap {
  position: sticky;
  top: 0.8rem;
}

.preview-iframe {
  width: 100%;
  height: min(76dvh, 760px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.preset-picker-shell {
  display: grid;
  gap: 0.8rem;
}

.preset-picker-preview {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.preset-picker-list {
  display: grid;
  gap: 0.55rem;
  max-height: min(68dvh, 680px);
  overflow: auto;
}

.preset-picker-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  text-align: left;
  padding: 0.7rem;
  display: grid;
  gap: 0.32rem;
  cursor: pointer;
}

.preset-picker-item strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.preset-picker-item.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(178, 106, 63, 0.18);
  background: #fffaf6;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 14, 9, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1200;
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal-card {
  width: min(980px, 100%);
  max-height: 92dvh;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.modal-tabs {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0.7rem;
}

.modal-tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  font-size: 0.84rem;
}

.modal-tab.active {
  background: #201a14;
  color: #fff;
  border-color: #201a14;
}

.modal-panel {
  display: none;
}

.modal-panel.active {
  display: block;
}

.media-library-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.media-asset-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.45rem;
  text-align: left;
  cursor: pointer;
}

.media-asset-preview {
  width: 100%;
  height: 120px;
  border-radius: 8px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #f2efe9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-asset-preview img,
.media-asset-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-asset-fallback {
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.media-asset-meta {
  display: grid;
  gap: 0.12rem;
  margin-top: 0.45rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.media-asset-meta strong {
  color: var(--ink);
  font-size: 0.82rem;
}

.upload-progress-list {
  margin-top: 0.7rem;
  display: grid;
  gap: 0.45rem;
}

.upload-progress-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0.45rem 0.55rem;
}

.upload-progress-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.32rem;
  font-size: 0.8rem;
}

.upload-progress-item-name {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-progress-item-state {
  color: var(--ink-soft);
  font-weight: 700;
  flex-shrink: 0;
}

.upload-progress-item-bar {
  height: 7px;
  width: 100%;
  background: #ece8df;
  border-radius: 999px;
  overflow: hidden;
}

.upload-progress-item-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(140deg, var(--brand), var(--brand-dark));
  transition: width 0.15s ease;
}

.upload-progress-item.ok .upload-progress-item-state {
  color: var(--ok);
}

.upload-progress-item.fail .upload-progress-item-state {
  color: var(--bad);
}

.metric {
  font-size: 1.8rem;
  font-weight: 800;
  margin: 0.3rem 0;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th,
td {
  text-align: left;
  padding: 0.55rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

@media (min-width: 800px) {
  .nav-links {
    display: flex;
  }

  .feature-grid,
  .plan-grid,
  .dashboard-grid,
  .admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .builder-grid {
    grid-template-columns: 1.1fr 0.9fr;
  }

  .builder-grid-v2 {
    grid-template-columns: 1fr;
  }

  .section-control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-row-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .design-field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .palette-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .section-design-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-row-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .media-library-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .app-shell {
    grid-template-columns: 270px 1fr;
  }

  .sidebar-toggle {
    display: none;
  }

  .sidebar-body {
    max-height: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .main {
    padding: 1.25rem 1.5rem;
  }
}

@media (min-width: 1000px) {
  .preset-picker-shell {
    grid-template-columns: minmax(0, 1.2fr) minmax(270px, 0.8fr);
    align-items: start;
  }

  .builder-grid-v2 {
    --builder-left: 56%;
    grid-template-columns: minmax(420px, var(--builder-left)) 14px minmax(360px, 1fr);
    align-items: stretch;
  }

  .builder-resizer {
    display: block;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(178, 106, 63, 0.2), rgba(141, 79, 42, 0.35));
    border: 1px solid rgba(141, 79, 42, 0.35);
    cursor: col-resize;
    width: 14px;
    min-height: 68dvh;
    align-self: stretch;
  }

  .builder-resizer:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
  }

  .builder-pane {
    min-height: 68dvh;
  }
}

@media (max-width: 799px) {
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 0.85rem;
  }

  .sidebar.is-collapsed .sidebar-body {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    margin-top: 0;
  }

  .sidebar-body {
    margin-top: 0.55rem;
    max-height: 70dvh;
    overflow: auto;
    transition: max-height 0.22s ease, opacity 0.2s ease;
  }
}

@media (min-width: 1100px) {
  .feature-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-grid,
  .admin-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
