/* The QR designer.
   ------------------------------------------------------------------
   Two columns: the code stays put on the left while the controls
   scroll on the right, because the whole point of a live preview is
   being able to see it at the moment you change something. On a phone
   the preview pins itself to the top of the viewport instead, which
   does the same job in the space available. */

.designer {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 22px;
  align-items: start;
  margin: 14px 0 8px;
}
@media (max-width: 860px) {
  .designer { grid-template-columns: 1fr; gap: 14px; }
}

.dpane {
  position: sticky;
  top: 16px;
  background: var(--card, #fff);
  border: 1px solid var(--line, #e4e4de);
  border-radius: 14px;
  padding: 16px;
}
@media (max-width: 860px) {
  /* Pinned to the top on a phone, and only as tall as it needs to be,
     so the controls underneath still have room to work in. */
  .dpane { position: sticky; top: 0; z-index: 5; padding: 12px;
           display: grid; grid-template-columns: 118px 1fr; gap: 12px;
           align-items: center; }
}

.dpreview {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  line-height: 0;
  transition: opacity .12s ease;
}
.dpreview svg { width: 100%; height: auto; display: block; }
.dpreview.busy { opacity: .55; }

/* A quiet marker that something is being redrawn. It has to be quiet:
   this fires on every keystroke of a colour picker. */
.dpreview::after {
  content: "";
  position: absolute;
  inset: auto 8px 8px auto;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent, #125a50);
  opacity: 0;
  transition: opacity .12s ease;
}
.dpreview.busy::after { opacity: .6; }

.dcaption {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--muted, #6b6b64);
  line-height: 1.45;
}
@media (max-width: 860px) { .dcaption { margin: 0; } }

/* What the renderer changed and why. Only appears when it has something
   to say, so an empty one takes no space at all. */
.dnote {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  background: var(--warnbg, #fdf6e3);
  border: 1px solid var(--warnline, #e8d9a8);
  color: var(--warnink, #6b5618);
  font-size: 12.5px;
  line-height: 1.5;
}
.dnote:empty { display: none; }

.dfail {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--bad, #a2361f);
}
.dfail:empty { display: none; }

/* ------------------------------------------------------------------
   Grouping. The editor has a lot of controls and they are not equally
   important, so they are boxed by what they change rather than run
   together as one long column of fields. */

.dgroup { border-top: 1px solid var(--line, #e4e4de); padding-top: 16px; margin-top: 18px; }
.dgroup:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.dgroup > h3 {
  margin: 0 0 4px;
  font-size: 14px;
  letter-spacing: .01em;
}
.dgroup > .help { margin-top: 0; margin-bottom: 12px; }

/* ------------------------------------------------------------------
   Shape pickers. Radios drawn as cards, so the whole tile is the hit
   area rather than a small circle beside it. */

.dstyles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.dstyle {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px 8px;
  border: 1.5px solid var(--line, #e4e4de);
  border-radius: 11px;
  background: var(--card, #fff);
  cursor: pointer;
  text-align: center;
  transition: border-color .12s ease, background .12s ease;
}
.dstyle:hover { border-color: var(--accent, #125a50); }
.dstyle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dstyle svg { display: block; }
.dstyle .nm { font-size: 11.5px; color: var(--muted, #6b6b64); line-height: 1.25; }

.dstyle:has(input:checked) {
  border-color: var(--accent, #125a50);
  background: var(--accenttint, #eef4f2);
}
.dstyle:has(input:checked) .nm { color: var(--ink, #1c1c19); font-weight: 600; }
/* Keyboard users get the same outline they would on any other control. */
.dstyle:has(input:focus-visible) { outline: 2px solid var(--accent, #125a50); outline-offset: 2px; }

/* ------------------------------------------------------------------
   Colours. A swatch and its hex, side by side, because people paste
   brand hex codes far more often than they hunt in a colour wheel. */

.dcolor { display: flex; align-items: center; gap: 8px; }
.dcolor input[type=color] {
  width: 44px; height: 34px; padding: 2px;
  border: 1px solid var(--line, #e4e4de);
  border-radius: 8px; background: var(--card, #fff); cursor: pointer;
}
.dcolor input[type=text] {
  width: 8.5em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  text-transform: lowercase;
}

/* Palettes. Small enough to sit in a row, big enough to read. */
.dpal { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.dpalbtn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 11px 6px 8px;
  border: 1.5px solid var(--line, #e4e4de);
  border-radius: 999px;
  background: var(--card, #fff);
  font: inherit; font-size: 12.5px;
  color: var(--ink, #1c1c19);
  cursor: pointer;
}
.dpalbtn:hover { border-color: var(--accent, #125a50); }
.dpalbtn i {
  width: 13px; height: 13px; border-radius: 4px;
  border: 1px solid rgba(128, 128, 128, .35);
  display: inline-block;
}

/* The save bar stays reachable without scrolling back up. */
.dsave {
  position: sticky; bottom: 0;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 0 4px;
  margin-top: 18px;
  background: linear-gradient(to bottom, transparent, var(--bg, #f5f5f2) 30%);
}
