:root {
  --cyan: #00a0e3;
  --navy: #363789;
  --ink: #1a2340;
  --muted: #6b7590;
  --line: #e7ebf5;
  --field: #f4f7fc;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(28, 40, 90, 0.08);
  --font: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(0, 160, 227, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(54, 55, 137, 0.08), transparent 55%),
    #f6f8fc;
  -webkit-font-smoothing: antialiased;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: baseline;
  gap: 18px;
  flex-wrap: wrap;
  padding: 20px 30px;
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.mark {
  font-size: 27px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--navy);
}
.mark b { color: var(--cyan); }
.studio {
  font-size: 16px;
  font-weight: 600;
  color: var(--cyan);
  letter-spacing: 0.3px;
}
.tag { margin: 0; color: var(--muted); font-size: 13.5px; }

/* ---------- layout ---------- */
main {
  flex: 1; /* grow to fill, so the footer sits at the bottom */
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 22px;
  padding: 6px 30px 40px;
  align-items: start; /* panels size to their own content */
}
/* mobile-only bottom-sheet bits are hidden on desktop */
.drawer-handle, .drawer-actions, .drawer-backdrop { display: none; }

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.controls { padding: 20px; }

.group { padding: 6px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.group:last-of-type { border-bottom: none; margin-bottom: 8px; }
.group-title {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 12px;
}

/* segmented control */
.segment {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--field);
  border-radius: 12px;
  padding: 5px;
  gap: 5px;
}
.segment input { display: none; }
.segment label {
  text-align: center;
  padding: 10px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.segment label small { font-weight: 500; font-size: 11px; opacity: 0.8; }
.segment input:checked + label {
  background: #fff;
  color: var(--navy);
  box-shadow: 0 2px 8px rgba(28, 40, 90, 0.12);
}

/* dropzone */
.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 118px;
  border: 2px dashed #c9d4ea;
  border-radius: 14px;
  background: var(--field);
  cursor: pointer;
  padding: 10px;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
}
.dropzone.dragover { border-color: var(--cyan); background: #eef8ff; }
.dropzone.has-logo {
  border-style: solid;
  /* checkerboard = "this area is transparent" (like Canva/Photoshop) */
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #dfe4ee 25%, transparent 25%),
    linear-gradient(-45deg, #dfe4ee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dfe4ee 75%),
    linear-gradient(-45deg, transparent 75%, #dfe4ee 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}
.drop-hint { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.drop-hint em { font-style: normal; opacity: 0.7; font-size: 11.5px; }
.plus {
  width: 34px; height: 34px; flex: none;
  border-radius: 50%;
  background: var(--cyan); color: #fff;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 300;
}
#logo-thumb { max-height: 110px; max-width: 100%; object-fit: contain; }

.logo-opts {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}
.logo-opts .check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.logo-opts .check input {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  border: 1.5px solid #c9d4ea;
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  position: relative;
  flex: none;
}
.logo-opts .check input:checked {
  background: var(--cyan);
  border-color: var(--cyan);
}
.logo-opts .check input:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid #fff; /* white tick */
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
#btn-logo-clear { margin: 0; color: #c0392b; }

/* fields */
.field { margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-weight: 600;
  font-size: 12.5px;
  margin-bottom: 6px;
  color: var(--ink);
}
.field label small { font-weight: 400; color: var(--muted); }
input[type="text"], textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  resize: vertical;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus, textarea:focus {
  outline: none;
  border-color: var(--cyan);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 160, 227, 0.14);
}
::placeholder { color: #a7b0c6; }

.link-btn {
  background: none; border: none; cursor: pointer;
  color: var(--cyan); font: inherit; font-weight: 600; font-size: 13px;
  padding: 4px 0;
}
.link-btn:hover { text-decoration: underline; }
#btn-logo-clear { display: block; margin-top: 8px; color: #c0392b; }

/* background colour picker */
.bg-row { display: flex; align-items: center; gap: 12px; }
.color-well {
  width: 46px; height: 46px; flex: none;
  border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 3px #fff;
  cursor: pointer;
}
.color-well input[type="color"] {
  width: 150%; height: 150%; margin: -25%;
  border: none; padding: 0; background: none; cursor: pointer;
}
.bg-row { flex-wrap: wrap; }
input.hex-input {
  width: 104px; flex: none;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}
.icon-btn {
  flex: none;
  padding: 9px 12px;
  font-size: 13px;
  white-space: nowrap;
}
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.swatches button {
  width: 26px; height: 26px; padding: 0;
  border-radius: 7px; border: 1px solid rgba(0,0,0,0.12);
  cursor: pointer;
}
.swatches button.active { outline: 2px solid var(--cyan); outline-offset: 2px; }
.logo-swatches { margin-top: 14px; }
.logo-swatches[hidden] { display: none; }
.mini-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.logo-swatches .swatches { margin-top: 6px; }

/* per-field show/hide toggle */
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.field-head label { margin-bottom: 0; }
.eye {
  border: none; background: none; cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 600;
  color: var(--cyan); padding: 2px 4px;
}
.eye.off { color: var(--muted); }
.field-off input, .field-off textarea { opacity: 0.45; }

/* extra (custom) fields */
.custom-list { display: flex; flex-direction: column; gap: 8px; }
.custom-row { display: flex; gap: 8px; align-items: stretch; }
.cf-icon {
  flex: none; width: 86px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--field); font: inherit; font-size: 13px; color: var(--ink); cursor: pointer;
}
.custom-row input[type="text"] { flex: 1; }
.cf-del {
  flex: none; width: 36px; padding: 0;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: #c0392b; font-size: 14px; cursor: pointer;
}
.cf-del:hover { background: #fff2f0; border-color: #f0b8b0; }
.add-field {
  margin-top: 10px; width: 100%;
  border: 1px dashed #c9d4ea; border-radius: 10px;
  background: var(--field); color: var(--navy);
  padding: 10px; font-weight: 600; font-size: 13.5px; cursor: pointer;
}
.add-field:hover { border-color: var(--cyan); color: var(--cyan); }


/* ---------- preview stage ---------- */
.stage-panel {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* stay pinned & centred in view while the form scrolls */
  position: sticky;
  top: 16px;
  height: calc(100vh - 32px);
}
.stage {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 30px;
  min-height: 0;
  background:
    radial-gradient(700px 400px at 50% 0%, #223, #11172b),
    #11172b;
}
#preview {
  max-height: calc(100vh - 160px);
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  background: #fff;
}
.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.meta { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.exports { display: flex; gap: 10px; }

button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 11px 18px;
  border-radius: 11px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  transition: transform 0.08s, box-shadow 0.15s, filter 0.15s;
}
button:hover { box-shadow: 0 4px 14px rgba(28, 40, 90, 0.12); }
button:active { transform: translateY(1px); }
button.primary {
  border: none;
  color: #fff;
  background: linear-gradient(135deg, var(--cyan), var(--navy));
}
button.primary:hover { filter: brightness(1.05); }

/* ─── Anuyog credit (mirrors the aerovwater site footer) ─── */
.anuyog-credit {
  background: #0a0806;
  padding: 22px 24px;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.anuyog-credit a {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  transition: opacity 0.3s;
}
.anuyog-credit a:hover { opacity: 0.85; }
.anuyog-credit img {
  height: 46px;
  width: auto;
  max-width: min(220px, 70vw);
  object-fit: contain;
}
.anuyog-credit span {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.anuyog-credit strong { font-weight: 700; color: rgba(255, 255, 255, 0.78); }

/* ============================================================
   MOBILE: sticker-first layout with a bottom-sheet of controls
   ============================================================ */
@media (max-width: 820px) {
  :root { --hdr: 54px; --peek: 64px; }

  body { display: block; min-height: 0; }

  .topbar {
    position: sticky; top: 0; z-index: 5;
    height: var(--hdr);
    padding: 0 18px;
    display: flex; align-items: center;
    background: #f6f8fc;
    border-bottom: 1px solid var(--line);
  }
  .topbar .tag, .brand .studio { display: none; }
  .mark { font-size: 22px; }

  main { display: block; padding: 0; }

  /* preview fills the space between the header and the collapsed sheet */
  .stage-panel {
    position: fixed;
    top: var(--hdr); left: 0; right: 0; bottom: var(--peek);
    border: none; border-radius: 0; box-shadow: none; background: transparent;
    z-index: 1;
  }
  .stage { height: 100%; min-height: 0; padding: 16px; border-radius: 0; }
  #preview { max-height: 100%; max-width: 100%; }
  .stage-bar { display: none; }

  /* the bottom sheet */
  .controls {
    position: fixed; left: 0; right: 0; bottom: 0;
    height: 88vh; max-height: 88vh;
    padding: 0 18px;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -12px 34px rgba(20, 32, 63, 0.20);
    transform: translateY(calc(100% - var(--peek)));
    transition: transform 0.34s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 4;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .controls.open { transform: translateY(0); }

  .drawer-handle {
    display: flex; flex-direction: column; align-items: center; gap: 7px;
    position: sticky; top: 0; z-index: 3;
    height: var(--peek); box-sizing: border-box;
    margin: 0 -18px; padding: 11px 0 9px;
    background: #fff; cursor: pointer;
  }
  .grip { width: 44px; height: 5px; border-radius: 3px; background: #cdd6e6; }
  .drawer-title {
    font-size: 12px; font-weight: 700; letter-spacing: 0.05em;
    text-transform: uppercase; color: var(--navy);
  }

  /* sticky export bar pinned to the bottom of the sheet */
  .drawer-actions {
    display: flex;
    position: sticky; bottom: 0; z-index: 3;
    margin: 10px -18px 0; padding: 12px 18px;
    background: #fff;
    box-shadow: 0 -8px 18px rgba(20, 32, 63, 0.07);
  }
  .drawer-actions .exports { display: flex; gap: 10px; width: 100%; }
  .drawer-actions .exports button { flex: 1; }

  .drawer-backdrop {
    display: block;
    position: fixed; inset: 0; z-index: 3;
    background: rgba(10, 15, 30, 0.34);
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s;
  }
  .drawer-backdrop.show { opacity: 1; pointer-events: auto; }

  footer.anuyog-credit { display: none; }
}
