:root {
  --ink: #111827;
  --ink-soft: #4b5563;
  --ink-faint: #6b7280;
  --line: #e5e7eb;
  --surface: #ffffff;
  --canvas: #f5f6fa;
  --accent: #4f46e5;
  --accent-dark: #4338ca;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 8px 24px rgba(17, 24, 39, .06);
}

html {
  font-size: 16px;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

.app-container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ---------- header ---------- */

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 60px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 650;
  letter-spacing: -.01em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
}

.brand-mark svg {
  width: 19px;
  height: 19px;
}

.app-nav {
  display: flex;
  gap: 1.25rem;
  font-size: .925rem;
}

.app-nav a {
  color: var(--ink-soft);
  text-decoration: none;
}

.app-nav a:hover {
  color: var(--ink);
}

.app-main {
  flex: 1 0 auto;
  padding-top: 2.5rem;
  padding-bottom: 3.5rem;
}

/* ---------- hero ---------- */

.hero {
  max-width: 46rem;
  margin-bottom: 2rem;
}

.hero h1 {
  font-size: clamp(1.9rem, 4.5vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -.025em;
  margin: .75rem 0 .6rem;
}

.hero-lead {
  color: var(--ink);
  font-weight: 600;
}

.hero-sub {
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1.6;
  margin: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  margin: 0;
  padding: .35rem .75rem .35rem .6rem;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--accent-dark);
  border: 1px solid #e0e7ff;
  font-size: .82rem;
  font-weight: 550;
}

.pill svg {
  width: 15px;
  height: 15px;
}

/* ---------- dropzone ---------- */

.dropzone {
  background: var(--surface);
  border: 2px dashed #d1d5db;
  border-radius: var(--radius);
  padding: 3rem 1.5rem;
  text-align: center;
  transition: border-color .15s, background .15s;
}

.dropzone.is-over {
  border-color: var(--accent);
  background: #f5f3ff;
}

.dropzone-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  border-radius: 14px;
  background: #eef2ff;
  color: var(--accent);
}

.dropzone-icon svg {
  width: 28px;
  height: 28px;
}

.dropzone-title {
  font-size: 1.2rem;
  font-weight: 650;
  margin: 0 0 .35rem;
}

.dropzone-sub {
  color: var(--ink-faint);
  margin: 0 0 1.25rem;
  font-size: .95rem;
}

.dropzone-note {
  margin: 1rem 0 0;
  font-size: .84rem;
  color: var(--ink-faint);
}

/* ---------- editor ---------- */

.editor {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
  scroll-margin-top: 76px; /* clear the sticky header when scrolled into view */
}

.dropzone {
  scroll-margin-top: 76px;
}

.is-hidden {
  display: none !important;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.15rem 1.25rem;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-title {
  font-size: .8rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-faint);
  margin: 0;
}

.panel-meta {
  margin: .3rem 0 0;
  font-size: .85rem;
  color: var(--ink-soft);
  word-break: break-all;
}

.preview-stage {
  border-radius: 12px;
  padding: .5rem;
  background:
    repeating-conic-gradient(#eceef3 0% 25%, #f8f9fb 0% 50%) 50% / 18px 18px;
  border: 1px solid var(--line);
  display: flex;
  justify-content: center;
}

.preview-stage canvas {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 4px 18px rgba(17, 24, 39, .12);
}

.editor-controls .panel {
  position: sticky;
  top: 76px;
}

/* ---------- fields ---------- */

.field {
  margin-bottom: 1.05rem;
}

.field label,
.toggle span {
  display: block;
  font-size: .875rem;
  font-weight: 550;
  color: var(--ink);
  margin-bottom: .4rem;
}

.value {
  float: right;
  font-weight: 500;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.text-input {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: .95rem;
  color: var(--ink);
  background: #fff;
}

.text-input:focus,
input[type=range]:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.text-input:focus {
  border-color: var(--accent);
  outline-offset: 0;
}

input[type=range] {
  width: 100%;
  accent-color: var(--accent);
}

.colour-row {
  display: flex;
  align-items: center;
  gap: .6rem;
}

input[type=color] {
  width: 46px;
  height: 34px;
  padding: 2px;
  border: 1px solid #d1d5db;
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
}

.swatches {
  display: flex;
  gap: .4rem;
}

.swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(17, 24, 39, .18);
  background: var(--s);
  padding: 0;
  cursor: pointer;
}

.swatch:hover {
  transform: scale(1.12);
}

.toggle {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: 0 0 1.25rem;
  cursor: pointer;
}

.toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.toggle span {
  margin: 0;
  font-weight: 500;
}

/* ---------- buttons ---------- */

.btn-solid {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .65rem 1.15rem;
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.btn-solid:hover {
  background: var(--accent-dark);
}

.btn-solid svg {
  width: 17px;
  height: 17px;
}

.btn-block {
  width: 100%;
}

.btn-ghost {
  padding: .4rem .8rem;
  border: 1px solid #d1d5db;
  border-radius: 9px;
  background: #fff;
  color: var(--ink-soft);
  font-size: .85rem;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}

.btn-ghost:hover {
  border-color: #9ca3af;
  color: var(--ink);
}

.linky {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.panel-foot {
  margin: .9rem 0 0;
  font-size: .8rem;
  line-height: 1.5;
  color: var(--ink-faint);
}

/* ---------- assurance ---------- */

.assurance {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.assurance h2 {
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -.015em;
  margin: 0 0 1.1rem;
}

.assurance-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.assurance-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.1rem;
}

.assurance-card h3 {
  font-size: .95rem;
  font-weight: 650;
  margin: 0 0 .4rem;
}

.assurance-card p {
  margin: 0;
  font-size: .9rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

/* ---------- prose (privacy page) ---------- */

.prose {
  max-width: 44rem;
}

.prose h1 {
  font-size: clamp(1.7rem, 4vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: .75rem;
}

.prose h2 {
  font-size: 1.1rem;
  font-weight: 650;
  margin: 2rem 0 .5rem;
}

.prose p,
.prose li {
  color: var(--ink-soft);
  line-height: 1.65;
}

/* ---------- footer ---------- */

.app-footer {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 1.5rem 0;
  font-size: .875rem;
  color: var(--ink-soft);
}

.app-footer strong {
  color: var(--ink);
}

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

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .editor {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Keep the image in view while the controls are being dragged. */
  .editor-preview {
    position: sticky;
    top: 60px;
    z-index: 10;
    background: var(--canvas);
    padding-bottom: .75rem;
  }

  .preview-stage {
    max-height: 38vh;
  }

  .preview-stage canvas {
    max-height: calc(38vh - 1rem);
    width: auto;
    object-fit: contain;
  }

  .editor-controls .panel {
    position: static;
  }
}

@media (max-width: 560px) {
  .app-main {
    padding-top: 1.75rem;
  }

  .dropzone {
    padding: 2.25rem 1rem;
  }
}
