/* The editor is neutral so it stays readable while experimenting with colours. */
.theme-launch:not(.button) {
  border: 1px solid #b9c5bd;
  background: #fffdf8;
  color: #243c37;
  border-radius: 999px;
  padding: 9px 16px;
  font:
    700 14px/1.4 system-ui,
    sans-serif;
  cursor: pointer;
  min-height: 44px;
  white-space: nowrap;
}
.theme-launch:focus-visible,
.theme-dialog :focus-visible {
  outline: 3px solid #8d452d;
  outline-offset: 3px;
}
.theme-dialog {
  width: min(660px, calc(100% - 24px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid #bac8bf;
  border-radius: 24px;
  background: #fffdf8;
  color: #243c37;
  box-shadow: 0 24px 100px #142a2540;
  overflow: auto;
  overscroll-behavior: contain;
  z-index: 1000;
  font:
    15px/1.5 system-ui,
    sans-serif;
}
.theme-dialog::backdrop {
  background: #172b256b;
}
.theme-form {
  padding: 28px;
}
.theme-form header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.theme-kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: #56675f;
}
.theme-form h2 {
  font:
    750 30px/1.2 system-ui,
    sans-serif;
  letter-spacing: -1px;
  margin: 4px 0 16px;
}
.theme-form p {
  font:
    14px/1.6 system-ui,
    sans-serif;
  color: #52635a;
  margin: 0 0 16px;
}
.theme-form .theme-close {
  font-size: 28px;
  padding: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
}
.theme-form button,
.theme-import {
  font:
    650 14px/1.4 system-ui,
    sans-serif;
  color: #243c37;
  background: #edf1e9;
  border: 1px solid #bbc8be;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  min-height: 44px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-form fieldset {
  border: 0;
  margin: 16px 0;
  padding: 0;
  min-width: 0;
}
.theme-form legend {
  font-weight: 700;
  margin-bottom: 12px;
}
.theme-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.theme-preset {
  position: relative;
  padding: 16px;
  border: 1px solid #bbc8be;
  border-radius: 14px;
  display: grid;
  gap: 8px;
  cursor: pointer;
}
.theme-preset:has(input:checked) {
  outline: 2px solid #243c37;
  outline-offset: 1px;
  background: #edf1e9;
}
.theme-preset input {
  position: absolute;
  right: 12px;
  top: 12px;
  accent-color: #243c37;
}
.theme-preset > span:last-child {
  font-size: 12px;
  color: #52635a;
  line-height: 1.5;
}
.theme-swatch {
  display: flex;
  gap: 5px;
  padding-right: 24px;
}
.theme-swatch i {
  width: 24px;
  height: 24px;
  border: 1px solid #0002;
  border-radius: 50%;
  background: #75618d;
}
.theme-swatch-classic i:nth-child(2) {
  background: #eaf0e4;
}
.theme-swatch-classic i:nth-child(3) {
  background: #fafbf8;
}
.theme-swatch-little-wins i {
  background: #243c37;
}
.theme-swatch-little-wins i:nth-child(2) {
  background: #d65c3f;
}
.theme-swatch-little-wins i:nth-child(3) {
  background: #faf7f0;
}
.theme-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 24px 0;
}
.theme-fields label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}
.theme-fields select,
.theme-fields input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid #bbc8be;
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  color: #243c37;
  font:
    14px system-ui,
    sans-serif;
}
.theme-fields input[type="color"] {
  padding: 5px;
  cursor: pointer;
}
.theme-preview {
  background: var(--theme-paper);
  color: #243c37;
  border: 1px solid #bbc8be;
  border-radius: var(--theme-radius, 18px);
  padding: 20px;
}
.theme-preview img {
  display: block;
  margin: -10px 0 8px;
}
.theme-preview h3 {
  font-family: var(--font-heading, Fraunces, Georgia, serif);
  font-size: 24px;
  line-height: 1.25;
  margin: 0 0 10px;
  font-weight: 700;
}
.theme-preview p {
  font-family: var(--font-body, "Nunito Sans", Nunito, sans-serif);
}
.theme-example-button {
  display: inline-block;
  background: var(--theme-accent);
  color: var(--theme-on-accent);
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
}
.theme-form .theme-status {
  min-height: 44px;
  font-size: 12px;
  margin: 14px 0;
}
.theme-file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.theme-form footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid #bbc8be;
}
.theme-form .theme-save {
  background: #243c37;
  color: #fff;
  border-color: #243c37;
}
.theme-dialog [hidden] {
  display: none !important;
}
#app-themes {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 35;
}
#website-themes {
  margin: 16px 0 24px;
}
@media (max-width: 600px) {
  .theme-form {
    padding: 20px;
  }
  .theme-fields {
    gap: 12px;
  }
  .theme-presets {
    gap: 10px;
  }
  .theme-preset {
    padding: 14px 10px;
  }
  .theme-fields label:last-child {
    grid-column: 1/-1;
  }
  #app-themes {
    bottom: calc(82px + env(safe-area-inset-bottom));
    right: 12px;
  }
  .theme-launch:not(.button) {
    font-size: 12px;
    padding: 8px 12px;
  }
}

.theme-mode-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.theme-mode-options label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid #bbc8be;
  border-radius: 10px;
  padding: 12px 6px;
  min-height: 48px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}
.theme-mode-options label:has(input:checked) {
  background: #edf1e9;
  outline: 2px solid #243c37;
  outline-offset: 1px;
}
.theme-mode-options input {
  accent-color: #243c37;
  margin: 0;
}
.theme-form .theme-mode-help {
  font-size: 12px;
  margin: 12px 0 0;
}
:root[data-mode="dark"] .theme-mode-options label {
  border-color: var(--dark-line);
}
:root[data-mode="dark"] .theme-mode-options label:has(input:checked) {
  background: var(--dark-soft);
  outline-color: var(--theme-accent);
}
@media (max-width: 420px) {
  .theme-mode-options label {
    flex-wrap: wrap;
    font-size: 12px;
    gap: 5px;
  }
  .theme-mode-options label span {
    display: none;
  }
}

.theme-swatch {
  gap: 10px;
}
.theme-swatch img {
  width: 58px;
  height: 58px;
}
.theme-preview img {
  width: 80px;
  height: 80px;
}
:root[data-mode="dark"] .theme-dialog,
:root[data-mode="dark"] .theme-preset,
:root[data-mode="dark"] .theme-fields select,
:root[data-mode="dark"] .theme-fields input,
:root[data-mode="dark"] .theme-form button,
:root[data-mode="dark"] .theme-import,
:root[data-mode="dark"] .theme-launch:not(.button) {
  background: var(--brand-surface);
  color: var(--brand-forest);
  border-color: var(--border);
}
:root[data-mode="dark"] .theme-form p,
:root[data-mode="dark"] .theme-kicker,
:root[data-mode="dark"] .theme-preset > span:last-child {
  color: var(--muted);
}
:root[data-mode="dark"] .theme-preset:has(input:checked) {
  background: var(--brand-wash);
  outline-color: var(--brand-forest);
}
.theme-preview {
  color: var(--brand-forest);
}
:root .theme-form .theme-save {
  background: var(--theme-accent);
  color: var(--theme-on-accent);
}

.theme-presets {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.theme-preset {
  min-width: 0;
}
.theme-swatch {
  padding-right: 0;
}
@media (max-width: 440px) {
  .theme-form {
    padding: 18px;
  }
  .theme-preset {
    padding: 10px;
    font-size: 13px;
  }
  .theme-preset input {
    right: 6px;
    top: 8px;
  }
  .theme-swatch {
    gap: 6px;
    padding-top: 16px;
  }
  .theme-swatch img {
    width: 42px;
    height: 42px;
  }
}

/* Audience gallery: each card previews its own real colours, type and shapes. */
.theme-dialog {
  width: min(1200px, calc(100% - 28px));
  border-radius: 24px;
}
.theme-form {
  padding: 28px;
}
.theme-form > header {
  position: sticky;
  top: -28px;
  z-index: 3;
  background: #fffdf8;
  margin: -1px -1px 0;
  padding-top: 8px;
}
.theme-form .theme-intro {
  max-width: 690px;
  margin-bottom: 24px;
  font-size: 14px;
  line-height: 1.7;
}
.theme-instant-presets {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}
.theme-instant-preset {
  padding: 10px;
  gap: 8px;
  align-content: start;
  transition: border-color 0.15s;
  overflow: hidden;
}
.theme-instant-preset > input {
  top: 20px;
  right: 20px;
  z-index: 2;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #243c37;
  cursor: pointer;
}
.theme-instant-preset strong {
  font-size: 16px;
  line-height: 1.3;
  letter-spacing: -0.35px;
}
.theme-instant-preset .theme-audience {
  font-size: 10px;
  line-height: 1.3;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 750;
  color: #52635a;
  margin-top: 5px;
}
.theme-instant-preset .theme-description {
  font-size: 12px;
  line-height: 1.55;
  color: #52635a;
}
.instant-mini {
  display: block;
  position: relative;
  min-width: 0;
  padding: 12px;
  height: 148px;
  background: var(--preview-paper);
  color: var(--preview-ink);
  border-radius: var(--preview-radius);
  font-family: var(--preview-font);
  overflow: hidden;
  isolation: isolate;
}
.instant-mini:before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.5;
  pointer-events: none;
}
.instant-mini-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 22px;
  height: 26px;
  margin-bottom: 8px;
}
.instant-mini-top img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}
.instant-mini-spark {
  font-size: 24px;
  line-height: 1;
  color: var(--preview-action);
}
.instant-mini-title {
  display: block;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.8px;
  line-height: 1.25;
  margin-bottom: 9px;
}
.instant-mini-card {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: calc(var(--preview-radius) * 0.55);
  background: var(--preview-wash);
  color: var(--preview-ink);
  padding: 10px 8px;
  font:
    650 9px/1.3 system-ui,
    sans-serif;
}
.instant-mini-card > span:last-child {
  margin-left: auto;
  font-weight: 800;
  white-space: nowrap;
}
.instant-mini-tick {
  display: grid;
  place-items: center;
  border-radius: 50%;
  height: 19px;
  width: 19px;
  border: 1px solid currentColor;
  flex-shrink: 0;
}
.instant-mini-line {
  display: block;
  width: 44px;
  height: 3px;
  border-radius: 5px;
  background: currentColor;
  opacity: 0.22;
  margin-top: 5px;
}
.instant-mini-progress {
  display: block;
  height: 5px;
  background: var(--preview-wash);
  border-radius: 10px;
  margin-top: 9px;
  overflow: hidden;
}
.instant-mini-progress i {
  display: block;
  height: 100%;
  width: 65%;
  background: var(--preview-action);
  border-radius: 10px;
}
[data-motif="sunshine"] .instant-mini:before {
  background: radial-gradient(
    circle at 92% 6%,
    var(--preview-decoration) 0 34px,
    transparent 35px
  );
}
[data-motif="clouds"] .instant-mini:before {
  background:
    radial-gradient(
      ellipse at 85% 22%,
      var(--preview-decoration) 0 35px,
      transparent 36px
    ),
    radial-gradient(
      ellipse at 101% 5%,
      var(--preview-decoration) 0 43px,
      transparent 44px
    );
}
[data-motif="waves"] .instant-mini:before {
  background: repeating-radial-gradient(
    ellipse at 120% 0%,
    transparent 0 16px,
    var(--preview-decoration) 17px 18px,
    transparent 19px 34px
  );
  opacity: 0.25;
}
[data-motif="petals"] .instant-mini:before {
  background:
    radial-gradient(
      ellipse at 88% 18%,
      var(--preview-decoration) 0 14px,
      transparent 15px
    ),
    radial-gradient(
      ellipse at 99% 32%,
      var(--preview-decoration) 0 14px,
      transparent 15px
    ),
    radial-gradient(
      ellipse at 101% 6%,
      var(--preview-decoration) 0 14px,
      transparent 15px
    );
}
[data-motif="orbit"] .instant-mini:before {
  background: repeating-radial-gradient(
    circle at 100% 0,
    transparent 0 20px,
    var(--preview-decoration) 21px 22px,
    transparent 23px 40px
  );
  opacity: 0.2;
}
[data-motif="arches"] .instant-mini:before {
  background: radial-gradient(
    ellipse at 97% 4%,
    var(--preview-decoration) 0 30px,
    transparent 31px
  );
  opacity: 0.35;
}
[data-motif="grid"] .instant-mini:before {
  background-image:
    linear-gradient(var(--preview-decoration) 1px, transparent 1px),
    linear-gradient(90deg, var(--preview-decoration) 1px, transparent 1px);
  background-size: 20px 20px;
  opacity: 0.16;
}
[data-motif="linen"] .instant-mini:before {
  background: repeating-linear-gradient(
    112deg,
    transparent 0 15px,
    var(--preview-decoration) 16px 17px
  );
  opacity: 0.18;
}
.theme-brand-options,
.theme-customise {
  border: 1px solid #bbc8be;
  border-radius: 14px;
  margin: 20px 0;
  padding: 14px 16px;
}
.theme-brand-options > summary,
.theme-customise > summary {
  font:
    700 14px/1.4 system-ui,
    sans-serif;
  cursor: pointer;
  list-style: revert;
  display: list-item;
}
.theme-brand-options .theme-presets {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 18px;
  gap: 12px;
}
.theme-brand-options .theme-swatch img {
  width: 36px;
  height: 36px;
}
.theme-brand-options .theme-preset {
  font-size: 13px;
  padding: 12px;
}
.theme-brand-options .theme-preset > span:last-child {
  font-size: 11px;
}
.theme-customise .theme-fields {
  margin-bottom: 4px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.theme-form .theme-preview {
  display: grid;
  grid-template-columns: 58px 1fr;
  column-gap: 16px;
  padding: 18px 20px;
  margin-top: 22px;
}
.theme-form .theme-preview img {
  grid-column: 1;
  grid-row: 1/5;
  width: 54px;
  height: 54px;
  margin: 0;
  align-self: center;
}
.theme-form .theme-preview h3,
.theme-form .theme-preview > p,
.theme-form .theme-preview .theme-example-button {
  grid-column: 2;
}
.theme-form .theme-preview .theme-preview-name {
  font:
    700 11px/1.5 system-ui,
    sans-serif;
  letter-spacing: 0.03em;
  margin: 0 0 6px;
  color: var(--brand-forest, #243c37);
}
.theme-form .theme-preview h3 {
  font-weight: 800;
  margin-bottom: 6px;
}
.theme-form .theme-preview .theme-example-button {
  justify-self: start;
  font-size: 13px;
  margin-top: 3px;
}
.theme-form > footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  padding: 14px 0;
  background: #fffdf8;
  margin-bottom: 0;
}
.theme-form .theme-mode-help {
  margin-top: 10px;
}
:root[data-mode="dark"] .theme-form > header,
:root[data-mode="dark"] .theme-form > footer {
  background: var(--brand-surface);
}
:root[data-mode="dark"] .theme-brand-options,
:root[data-mode="dark"] .theme-customise {
  border-color: var(--border);
}
:root[data-mode="dark"] .theme-instant-preset .theme-audience,
:root[data-mode="dark"] .theme-instant-preset .theme-description {
  color: var(--muted);
}
:root[data-mode="dark"] .theme-preview {
  border-color: var(--border);
}
@media (min-width: 801px) and (max-width: 1100px) {
  .theme-instant-presets {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 800px) {
  .theme-instant-presets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .theme-brand-options .theme-presets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .theme-customise .theme-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 440px) {
  .theme-dialog {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px);
  }
  .theme-form {
    padding: 16px;
  }
  .theme-form > header {
    top: -16px;
  }
  .theme-instant-presets {
    gap: 10px;
  }
  .theme-instant-preset {
    padding: 8px;
  }
  .theme-instant-preset > input {
    top: 16px;
    right: 16px;
  }
  .instant-mini {
    padding: 9px;
    height: 142px;
  }
  .instant-mini-title {
    font-size: 18px;
  }
  .instant-mini-card {
    font-size: 8px;
    gap: 4px;
    padding: 9px 6px;
  }
  .instant-mini-tick {
    width: 16px;
    height: 16px;
  }
  .theme-instant-preset strong {
    font-size: 14px;
  }
  .theme-instant-preset .theme-description {
    font-size: 11px;
  }
  .theme-form > footer {
    bottom: 0;
    padding: 12px 0;
  }
  .theme-form .theme-preview {
    grid-template-columns: 1fr;
    padding: 16px;
  }
  .theme-form .theme-preview img {
    display: none;
  }
  .theme-form .theme-preview h3,
  .theme-form .theme-preview > p,
  .theme-form .theme-preview .theme-example-button {
    grid-column: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .theme-instant-preset {
    transition: none;
  }
}

:root[data-mode="dark"] .theme-instant-preset > input {
  accent-color: var(--theme-accent);
}

.theme-form .theme-preview h3 {
  font-weight: var(--theme-heading-weight, 800);
}
.theme-preset[data-preset="rose-quartz"] .instant-mini-title,
.theme-preset[data-preset="quiet-sunday"] .instant-mini-title {
  font-weight: 500;
}
