@font-face {
  font-family: "Lato";
  src: url("assets/Lato-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Lato";
  src: url("assets/Lato-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  --blue: #052956;
  --beige: #f7f1e8;
  --cream: #fcfaf6;
  --ink: #10253f;
  --muted: #65768b;
  --chip-color: #e73b2f;
  --chip-background: #fce9e8;
  font-family: "Lato", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  display: grid;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  padding: 12px 16px 16px;
  align-content: start;
  justify-items: center;
  color: var(--ink);
  background: #f7f1e8;
}
body.crop-open { overflow: hidden; }

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.builder-card {
  position: relative;
  width: min(720px, 100%);
  padding: 16px 16px 24px;
  border: 1px solid rgba(5,41,86,.12);
  border-radius: 18px;
  background: rgba(252,250,246,.98);
}

.preview-stage {
  position: relative;
  display: grid;
  min-height: 503px;
  padding: 44px;
  overflow: visible;
  place-items: center;
  border: 1px solid #e0e4e8;
  border-radius: 14px;
  background-color: #e8edf2;
  background-image: linear-gradient(45deg, rgba(255,255,255,.4) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.4) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.4) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.4) 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}
.thumbnail {
  --thumb-scale: 2.75;
  position: relative;
  display: flex;
  flex: none;
  flex-direction: column;
  width: calc(150px * var(--thumb-scale));
  height: calc(150px * var(--thumb-scale));
  padding-bottom: calc(6px * var(--thumb-scale));
  overflow: visible;
  border: calc(.5px * var(--thumb-scale)) solid var(--blue);
  border-radius: calc(8px * var(--thumb-scale));
  background-color: var(--beige);
  background-image: url("assets/flower-background.png");
  background-size: 104.5% 104.5%;
  background-position: center 20%;
  box-shadow: 0 calc(2px * var(--thumb-scale)) calc(3px * var(--thumb-scale)) rgba(0,0,0,.25);
  color: var(--blue);
}
.thumbnail.is-wide { --thumb-scale: 2; width: calc(300px * var(--thumb-scale)); background-size: 104.5% auto; background-position: center 93.5%; }

.thumbnail::before {
  position: absolute;
  z-index: 3;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
  content: "";
  pointer-events: none;
}

.thumbnail-image-wrap {
  position: relative;
  flex: 0 0 calc(76px * var(--thumb-scale));
  height: calc(76px * var(--thumb-scale));
  overflow: hidden;
  border-radius: calc(7px * var(--thumb-scale)) calc(7px * var(--thumb-scale)) 0 0;
}
.thumbnail-image-wrap.is-empty { background-color: #e8edf2; background-image: linear-gradient(45deg, rgba(255,255,255,.5) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.5) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.5) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.5) 75%); background-size: calc(12px * var(--thumb-scale)) calc(12px * var(--thumb-scale)); background-position: 0 0, 0 calc(6px * var(--thumb-scale)), calc(6px * var(--thumb-scale)) calc(-6px * var(--thumb-scale)), calc(-6px * var(--thumb-scale)) 0; }

.thumbnail-image-wrap::after {
  position: absolute;
  z-index: 1;
  inset: 0;
  box-shadow: inset 0 0 calc(10px * var(--thumb-scale)) calc(-2px * var(--thumb-scale)) rgba(0,0,0,.3);
  content: "";
  pointer-events: none;
}

.thumbnail-image-wrap > img { position: absolute; display: block; max-width: none; user-select: none; }
.thumbnail-image-wrap > img[hidden] { display: none; }

.image-actions {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(4px * var(--thumb-scale));
  opacity: 0;
  pointer-events: none;
  background: rgba(5,41,86,.78);
  transition: opacity .16s ease;
}

.thumbnail-image-wrap:hover .image-actions,
.thumbnail-image-wrap:focus-within .image-actions,
.thumbnail-image-wrap.controls-visible .image-actions { opacity: 1; pointer-events: auto; }
.thumbnail-image-wrap.is-empty .image-actions { opacity: 1; pointer-events: auto; }
.thumbnail-image-wrap.is-empty .image-action { background: rgba(5,41,86,.62); }
.image-action { display: flex; align-items: center; gap: calc(2px * var(--thumb-scale)); padding: calc(3px * var(--thumb-scale)); border: 1px solid rgba(255,255,255,.65); border-radius: calc(4px * var(--thumb-scale)); color: white; background: rgba(5,41,86,.36); font-size: calc(5px * var(--thumb-scale)); font-weight: 700; line-height: 1; cursor: pointer; }
.image-action[hidden] { display: none; }
.image-action:hover, .image-action:focus-visible { background: rgba(255,255,255,.16); outline: none; }
.image-action-icon { display: grid; width: calc(10px * var(--thumb-scale)); height: calc(10px * var(--thumb-scale)); place-items: center; }
.image-action-icon img { width: 100%; height: 100%; filter: brightness(0) invert(1); }

.thumbnail-copy {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding: calc(4px * var(--thumb-scale)) calc(8px * var(--thumb-scale)) 0;
}

.thumbnail-text { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; gap: calc(2px * var(--thumb-scale)); overflow: hidden; }
.inline-editable { position: relative; outline: 0; cursor: text; transition: background .14s, box-shadow .14s; }
.inline-editable:hover, .inline-editable:focus { border-radius: calc(2px * var(--thumb-scale)); background: rgba(255,255,255,.58); box-shadow: 0 0 0 calc(1px * var(--thumb-scale)) rgba(5,41,86,.18); }
.inline-editable:empty::before { color: rgba(5,41,86,.48); content: attr(data-placeholder); }

.thumbnail-title {
  display: -webkit-box;
  flex: none;
  max-height: calc(26.4px * var(--thumb-scale));
  margin: 0;
  overflow: hidden;
  color: inherit;
  font-size: calc(12px * var(--thumb-scale));
  font-weight: 700;
  line-height: 1.1;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  text-transform: capitalize;
}

.thumbnail-description {
  display: -webkit-box;
  flex: none;
  max-height: calc(27.6px * var(--thumb-scale));
  margin: 0;
  overflow: hidden;
  color: inherit;
  font-size: calc(8px * var(--thumb-scale));
  font-weight: 400;
  line-height: 1.15;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.thumbnail-title.title-two-lines + .thumbnail-description { max-height: calc(18.4px * var(--thumb-scale)); -webkit-line-clamp: 2; }

.thumbnail-footer { position: relative; z-index: 5; display: flex; flex: none; align-items: center; justify-content: space-between; width: 100%; min-height: calc(14px * var(--thumb-scale)); margin-top: calc(3px * var(--thumb-scale)); }

.date-picker { position: relative; }
.date-control { display: block; padding: 0; border: 0; border-radius: calc(2px * var(--thumb-scale)); color: inherit; background: transparent; font-size: calc(8px * var(--thumb-scale)); font-weight: 700; line-height: normal; cursor: pointer; }
.date-control:hover, .date-control:focus-within { background: rgba(255,255,255,.6); box-shadow: 0 0 0 calc(1px * var(--thumb-scale)) rgba(5,41,86,.18); }
.date-menu {
  position: absolute;
  z-index: 20;
  bottom: calc(18px * var(--thumb-scale));
  left: 0;
  width: calc(82px * var(--thumb-scale));
  padding: calc(4px * var(--thumb-scale));
  border: 1px solid #d5dbe3;
  border-radius: calc(4px * var(--thumb-scale));
  background: white;
  box-shadow: 0 calc(5px * var(--thumb-scale)) calc(14px * var(--thumb-scale)) rgba(16,37,63,.2);
}
.date-menu[hidden] { display: none; }
.date-menu input { width: 100%; min-width: 0; padding: calc(3px * var(--thumb-scale)); border: 1px solid #bcc7d3; border-radius: calc(2px * var(--thumb-scale)); color: var(--blue); background: white; font-size: calc(6px * var(--thumb-scale)); cursor: pointer; }

.chip-picker { position: relative; }
.type-chip { --chip-color: #e73b2f; --chip-background: #fce9e8; display: flex; align-items: center; justify-content: center; gap: calc(3px * var(--thumb-scale)); padding: calc(2px * var(--thumb-scale)) calc(6px * var(--thumb-scale)); border: calc(.5px * var(--thumb-scale)) solid var(--chip-color); border-radius: 75px; background: var(--chip-background); color: var(--chip-color); font-size: calc(8px * var(--thumb-scale)); font-weight: 700; line-height: normal; cursor: pointer; }
.type-chip-empty { --chip-color: #052956; --chip-background: rgba(255,255,255,.32); border-width: calc(1px * var(--thumb-scale)); border-style: dotted; }
.type-chip img { display: block; width: calc(var(--chip-icon-size, 10.8px) * var(--thumb-scale)); height: calc(var(--chip-icon-size, 10.8px) * var(--thumb-scale)); }
.type-chip img[hidden] { display: none; }
.type-chip:hover, .type-chip:focus-visible { box-shadow: 0 0 0 calc(1px * var(--thumb-scale)) rgba(5,41,86,.18); outline: none; }

.chip-menu { position: absolute; z-index: 20; right: 0; bottom: calc(18px * var(--thumb-scale)); display: grid; width: calc(104px * var(--thumb-scale)); max-height: calc(128px * var(--thumb-scale)); grid-template-columns: 1fr 1fr; gap: calc(3px * var(--thumb-scale)); padding: calc(5px * var(--thumb-scale)); overflow-y: auto; border: 1px solid #d5dbe3; border-radius: calc(5px * var(--thumb-scale)); background: white; box-shadow: 0 calc(5px * var(--thumb-scale)) calc(14px * var(--thumb-scale)) rgba(16,37,63,.2); }
.chip-menu[hidden] { display: none; }
.chip-option { display: flex; align-items: center; gap: calc(3px * var(--thumb-scale)); min-width: 0; padding: calc(3px * var(--thumb-scale)); border: 0; border-radius: calc(3px * var(--thumb-scale)); background: transparent; color: var(--ink); font-size: calc(5px * var(--thumb-scale)); text-align: left; cursor: pointer; }
.chip-option:hover, .chip-option:focus-visible { background: #eef2f6; outline: none; }
.chip-option img { flex: none; width: calc(8px * var(--thumb-scale)); height: calc(8px * var(--thumb-scale)); }
.chip-option span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.widget-messages { width: min(720px, 100%); padding: 0 30px; }
.field-error { margin: 4px 2px 0; color: #c9362c; font-size: 11px; }
.field-error:empty, #export-status:empty { display: none; }

.layout-toggle { display: grid; width: 220px; grid-template-columns: 1fr 1fr; gap: 3px; margin: 14px auto 0; padding: 3px; border: 1px solid rgba(5,41,86,.14); border-radius: 8px; background: #e8edf2; }
.layout-option { padding: 7px 10px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; cursor: pointer; }
.layout-option:hover, .layout-option:focus-visible { color: var(--blue); outline: none; }
.layout-option.is-active { color: var(--blue); background: white; box-shadow: 0 1px 4px rgba(5,41,86,.12); }

.download-row { display: flex; align-items: flex-start; justify-content: center; margin-top: 10px; }
.download-action { display: flex; flex: 0 0 220px; flex-direction: column; width: 220px; }
#export-status { margin: 4px 2px 0; color: var(--muted); font-size: 11px; line-height: 1.35; overflow-wrap: anywhere; }
#export-status[data-state="error"] { color: #a52b24; }
#download-button { display: flex; align-items: center; justify-content: center; gap: 24px; width: 100%; min-width: 0; padding: 13px 16px; border: 0; border-radius: 8px; background: var(--blue); color: white; font-weight: 700; white-space: nowrap; cursor: pointer; box-shadow: 0 6px 16px rgba(5,41,86,.18); }
#download-button:hover { background: #0a376d; }
#download-button:disabled { opacity: .65; cursor: wait; }
#download-button img { width: 18px; height: 18px; filter: brightness(0) invert(1); }

.crop-modal { position: absolute; z-index: 100; inset: 0; display: grid; padding: 16px; overflow: hidden; border-radius: inherit; background: rgba(252,250,246,.98); }
.crop-modal[hidden] { display: none; }
.crop-panel { display: flex; width: 100%; min-height: 0; padding: 22px; flex-direction: column; overflow-y: auto; border: 1px solid #e0e4e8; border-radius: 14px; background: var(--cream); }
.crop-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.crop-header h2 { margin: 0 0 4px; color: var(--blue); font-size: 20px; }
.crop-header p { margin: 0; color: var(--muted); font-size: 13px; }
.crop-close { flex: none; padding: 0; border: 0; color: var(--blue); background: transparent; font-size: 28px; line-height: .8; cursor: pointer; }
.crop-viewport { position: relative; width: 100%; aspect-ratio: 150 / 76; overflow: hidden; border: 0; border-radius: 8px; background: #dfe5eb; box-shadow: 0 0 0 2px white, 0 0 0 3px rgba(5,41,86,.2); cursor: grab; touch-action: none; }
.crop-viewport.is-wide { aspect-ratio: 300 / 76; }
.crop-viewport:active { cursor: grabbing; }
.crop-viewport img { position: absolute; display: block; max-width: none; pointer-events: none; user-select: none; }
.zoom-control { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; margin: 18px 0; color: var(--blue); font-size: 13px; font-weight: 700; }
.zoom-control input { width: 100%; accent-color: var(--blue); }
.crop-buttons, .crop-buttons > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.crop-buttons button { padding: 9px 14px; border: 1px solid rgba(5,41,86,.2); border-radius: 7px; color: var(--blue); background: white; font-weight: 700; cursor: pointer; }
#crop-apply { border-color: var(--blue); color: white; background: var(--blue); }

.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

@media (max-width: 700px) {
  body { padding: 8px; }
  .builder-card { padding: 12px 12px 20px; border-radius: 14px; }
  .widget-messages { padding: 0 12px; }
  .preview-stage { min-height: 396px; padding: 28px 18px; }
  .thumbnail { --thumb-scale: 2.25; }
  .thumbnail.is-wide { --thumb-scale: 1.9; }
  .crop-modal { padding: 12px; }
}

@media (max-width: 480px) {
  body { display: block; padding: 0; background: var(--beige); }
  .builder-card { width: 100%; padding: 8px 8px 20px; border: 0; border-radius: 0; box-shadow: none; }
  .widget-messages { padding: 0 8px 12px; }
  .preview-stage { min-height: 340px; padding: 24px 10px; }
  .thumbnail { --thumb-scale: 1.9; }
  .thumbnail.is-wide { --thumb-scale: 1.35; }
  .download-row { align-items: stretch; flex-direction: column; }
  .download-action { flex-basis: auto; width: 100%; }
  #download-button { width: 100%; }
  .crop-modal { padding: 8px; }
  .crop-panel { padding: 16px; }
  .crop-buttons { align-items: stretch; flex-direction: column; }
  .crop-buttons > div { width: 100%; }
  .crop-buttons > div button { flex: 1; }
}

@media (max-width: 420px) {
  .thumbnail.is-wide { --thumb-scale: 1.15; }
}

@media (max-width: 360px) {
  .thumbnail.is-wide { --thumb-scale: .95; }
}
