@font-face {
  font-family: Nunito;
  src: url(assets/fonts/Nunito.ttf)
}

@font-face {
  font-family: Caprasimo;
  src: url(assets/fonts/Caprasimo.ttf)
}

@font-face {
  font-family: 'Bree Serif';
  src: url(assets/fonts/BreeSerif.ttf)
}

:root {
  --ink: #294537;
  --muted: #687367;
  --paper: #fffdf7;
  --cream: #f6f2e7;
  --line: #dedfd2;
  --gold: #ae792f;
  --accent: #355c43;
  --hover: #e8ecdf;
  --card: #f9f7ef;
  --input: #ffffff;
  --mat: #e4e7db;
  --dots: #cfd5c4;
  --selected: #e3ecdc;
  --danger: #96523a;
  color-scheme: light;
  font-family: Nunito,sans-serif;
  color: var(--ink);
  font-size: 14px;
  background: var(--cream)
}

:root[data-theme=dark] {
  --ink: #e5ecdf;
  --muted: #b5c0b2;
  --paper: #202a25;
  --cream: #161e1a;
  --line: #435046;
  --gold: #e4b467;
  --accent: #b1cda5;
  --hover: #35473b;
  --card: #29352e;
  --input: #17221c;
  --mat: #101813;
  --dots: #344339;
  --selected: #3b5140;
  --danger: #f0b095;
  color-scheme: dark;
}

* {
  box-sizing: border-box
}

body {
  margin: 0
}

button,input,textarea,select {
  font: inherit;
  color: inherit
}

button,select {
  cursor: pointer
}

button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 13px;
  font-weight: 750;
  transition: background .12s
}

button:hover {
  background: var(--hover)
}

button:disabled {
  opacity: .4;
  cursor: default
}

button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible {
  outline: 3px solid #b58236;
  outline-offset: 3px
}

h1,h2,p {
  margin: 0
}

h1 {
  font-family: Caprasimo,serif;
  font-size: 25px;
  font-weight: 400;
  letter-spacing: -.4px
}

h2 {
  font-size: 20px;
  line-height: 1.25;
  font-weight: 850
}

.eyebrow {
  display: block;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.6px;
  color: var(--gold);
  margin-bottom: 10px
}

p {
  color: var(--muted);
  line-height: 1.55
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 28px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  gap: 20px
}

.brand {
  display: flex;
  align-items: center;
  gap: 15px
}

.brand-star {
  font-size: 48px;
  color: var(--gold);
  line-height: 1
}

.brand p {
  font-size: 12px;
  margin-top: 4px
}

.file-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px
}

.file-actions #save-state {
  font-size: 12px;
  margin-right: 12px
}

.workspace {
  display: grid;
  grid-template-columns: 236px minmax(0,1fr) 248px;
  min-height: calc(100vh - 99px)
}

.panel {
  background: var(--paper);
  padding: 25px 18px
}

.library {
  border-right: 1px solid var(--line)
}

.inspector {
  border-left: 1px solid var(--line)
}

.panel-heading {
  margin-bottom: 22px
}

.panel-heading p {
  font-size: 12px;
  margin-top: 8px
}

.filters {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 18px
}

.filters button {
  border-color: transparent;
  font-size: 11px;
  padding: 5px 8px
}

.filters button[aria-pressed=true] {
  background: var(--ink);
  color: var(--paper)
}

.sticker-tray {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px
}

.sticker-choice {
  position: relative;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 6px 3px 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0
}

.sticker-choice:hover {
  background: var(--hover);
  border-color: var(--accent);
  transform: translateY(-1px)
}

.sticker-choice canvas {
  width: 85px;
  height: 96px;
  max-width: 100%;
  object-fit: contain;
  pointer-events: none
}

.sticker-choice span {
  font-size: 10px;
  line-height: 1.25;
  max-width: 90px;
  min-height: 24px;
  display: flex;
  align-items: center
}

.add-text {
  width: 100%;
  margin-top: 18px;
  background: var(--card)
}

.canvas-area {
  min-width: 0;
  padding: 23px 25px 30px
}

.canvas-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 19px;
  gap: 10px
}

.format-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 800
}

.format-label select {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 28px 9px 11px;
  font-size: 13px
}

.history {
  display: flex;
  gap: 5px
}

.history button {
  font-size: 23px;
  padding: 1px 10px;
  line-height: 1.4
}

.canvas-mat {
  padding: 27px;
  background: var(--mat);
  background-image: radial-gradient(var(--dots) .6px,transparent .6px);
  background-size: 9px 9px;
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  border-radius: 4px
}

.stage {
  position: relative;
  width: 100%;
  box-shadow: 0 4px 20px #32462a20;
  touch-action: none;
  background: #fcf7ec
}

.stage.social {
  max-width: 560px
}

.stage canvas {
  display: block;
  width: 100%;
  height: auto
}

#targets {
  position: absolute;
  inset: 0
}

.scene-target {
  position: absolute;
  cursor: grab;
  outline: 1px solid transparent;
  touch-action: none;
  border-radius: 1px
}

.scene-target:hover {
  outline: 1px dashed #638563
}

.scene-target.selected,.scene-target:focus-visible {
  outline: 2px solid #32654c;
  z-index: 1
}

.scene-target.dragging {
  cursor: grabbing
}

.resize-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  bottom: -7px;
  right: -7px;
  background: #fff;
  border: 2px solid #32654c;
  border-radius: 2px;
  cursor: nwse-resize;
  display: none;
  touch-action: none
}

.selected .resize-handle {
  display: block
}

.canvas-caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  gap: 8px
}

.canvas-caption button {
  border: none;
  font-size: 11px;
  padding: 5px 0;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px
}

.editing-hint {
  font-size: 12px;
  margin: 14px 0 0;
  text-align: center
}

.exports {
  margin-top: 28px;
  padding-top: 23px;
  border-top: 1px solid var(--line)
}

.exports h2 {
  font-family: 'Bree Serif',serif;
  font-size: 23px;
  font-weight: 400
}

.exports p {
  font-size: 12px;
  margin-top: 5px
}

.exports .eyebrow {
  margin-bottom: 6px
}

.export-buttons {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 9px;
  margin-top: 17px
}

.export-buttons button {
  background: var(--paper);
  text-align: left;
  padding: 13px 12px;
  border-color: var(--line)
}

.export-buttons button:hover {
  background: var(--hover)
}

.export-buttons strong {
  display: block;
  font-size: 12px
}

.export-buttons span {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 4px
}

.format-note {
  font-size: 10px;
  margin-top: 12px
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 15px;
  font-size: 11px;
  font-weight: 850
}

.field select,.field input,.field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--input);
  padding: 8px;
  font-size: 13px;
  font-weight: 500
}

.field textarea {
  resize: vertical;
  min-height: 80px
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px
}

.field-note {
  font-size: 10px;
  margin: -6px 0 15px;
  line-height: 1.4
}

.field input[type=range] {
  padding: 0;
  accent-color: var(--accent);
  min-height: 28px;
}

.field output {
  font-variant-numeric: tabular-nums;
}

.field input[type=color] {
  padding: 3px;
  height: 36px
}

.tool-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 9px
}

.tool-pair button,.wide {
  font-size: 11px;
  padding: 9px 5px
}

.wide {
  width: 100%
}

.wide[aria-pressed=true],#theme-toggle[aria-pressed=true] {
  background: var(--selected);
  border-color: var(--accent)
}

.danger {
  color: var(--danger)
}

.keyboard-note {
  margin-top: 25px;
  font-size: 11px;
  line-height: 1.6;
  padding-top: 18px;
  border-top: 1px solid var(--line)
}

fieldset {
  border: 0;
  padding: 0;
  margin: 20px 0 0;
  min-width: 0
}

fieldset:disabled {
  opacity: .5
}

.warning {
  font-size: 12px;
  padding: 10px 12px;
  background: #fff1d8;
  color: #805422;
  margin-top: 12px;
  border: 1px solid #d4b27d
}

#status {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: #294537;
  color: white;
  padding: 11px 20px;
  border-radius: 8px;
  max-width: min(90vw,650px);
  font-size: 13px;
  z-index: 50;
  box-shadow: 0 3px 15px #0002
}

#status:empty {
  display: none
}

dialog {
  width: min(970px,95vw);
  max-height: 94vh;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  background: var(--paper);
  color: var(--ink)
}

dialog::backdrop {
  background: #15271ecc
}

.preview-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 22px 25px
}

.preview-top .eyebrow {
  margin-bottom: 5px
}

.preview-top p {
  font-size: 12px;
  margin-top: 5px
}

.preview-mat {
  background: var(--mat);
  padding: 23px;
  display: flex;
  justify-content: center
}

.preview-mat img {
  max-width: 100%;
  max-height: 63vh;
  object-fit: contain;
  box-shadow: 0 2px 10px #0002
}

.preview-bottom {
  padding: 18px 25px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px
}

.preview-bottom p {
  font-size: 11px;
  max-width: 560px
}

.primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  white-space: nowrap
}

.primary:hover {
  background: var(--accent)
}

#print-sheet {
  display: none
}

[hidden] {
  display: none!important
}

.personal-invitation { margin: 0 0 20px; padding: 0 0 18px; border-bottom: 1px solid var(--line); }
.personal-intro { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.personal-intro p { font-size: 13px; margin: 5px 0 0; color: var(--muted); }
.personal-intro button { flex-shrink: 0; color: var(--paper); background: var(--ink); }
#personal-editor { margin-top: 12px; }
#personal-message-value { width: 100%; resize: vertical; min-height: 70px; padding: 12px; color: var(--ink); background: var(--input); border: 1px solid var(--line); border-radius: 5px; font: inherit; }
.personal-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.personal-actions button { font-size: 12px; padding: 5px 0; border: 0; text-decoration: underline; text-underline-offset: 3px; }
@media(max-width:1150px) { .personal-intro { align-items: flex-start; flex-direction: column; gap: 10px; } }

@media(min-width:1700px) {
  .workspace {
    grid-template-columns: 270px minmax(0,1fr) 280px
  }
  .canvas-area {
    padding: 25px 40px
  }
  .sticker-choice canvas {
    width: 100px;
    height: 115px
  }
}

@media(max-width:1150px) {
  .workspace {
    grid-template-columns: 190px minmax(0,1fr) 210px
  }
  .panel {
    padding: 20px 12px
  }
  .canvas-area {
    padding: 20px 14px
  }
  .canvas-mat {
    padding: 17px
  }
  .format-label {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px
  }
  .sticker-choice canvas {
    width: 70px;
    height: 82px
  }
  .file-actions #save-state:not([data-error]) {
    display: none
  }
  .export-buttons {
    gap: 6px
  }
  .export-buttons button {
    padding: 10px 7px
  }
}

@media(max-width:850px) {
  .workspace {
    grid-template-columns: 180px minmax(0,1fr)
  }
  .inspector {
    grid-column: 1/-1;
    border-left: none;
    border-top: 1px solid var(--line);
    display: block;
    padding: 22px
  }
  .inspector fieldset {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 15px
  }
  .inspector #text-controls {
    grid-row: span 4
  }
  .inspector .panel-heading {
    margin-bottom: 12px
  }
  .keyboard-note {
    margin-top: 10px
  }
  .app-header {
    padding: 15px 18px
  }
  h1 {
    font-size: 22px
  }
}

@media(max-width:600px) {
  .app-header {
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px
  }
  .brand-star {
    font-size: 38px
  }
  .brand p {
    font-size: 11px
  }
  .file-actions {
    width: 100%
  }
  .file-actions button {
    padding: 6px 12px;
    font-size: 12px
  }
  .workspace {
    display: flex;
    flex-direction: column
  }
  .canvas-area {
    order: 0;
    padding: 16px 12px
  }
  .canvas-mat {
    padding: 11px
  }
  .library {
    order: 1;
    border-right: none;
    border-top: 1px solid var(--line);
    padding: 22px 16px
  }
  .inspector {
    order: 2;
    padding: 22px 16px
  }
  .sticker-tray {
    grid-template-columns: repeat(4,minmax(0,1fr));
    gap: 7px
  }
  .sticker-choice canvas {
    height: 83px
  }
  .panel-heading {
    margin-bottom: 12px
  }
  .panel-heading p {
    margin-top: 5px
  }
  .filters {
    margin-bottom: 12px
  }
  .canvas-toolbar {
    margin-bottom: 13px
  }
  .format-label {
    flex-direction: row;
    align-items: center
  }
  .format-label select {
    font-size: 12px;
    max-width: 185px
  }
  .history button {
    padding: 1px 8px
  }
  .exports {
    margin-top: 20px;
    padding-top: 18px
  }
  .exports h2 {
    font-size: 21px
  }
  .export-buttons strong {
    font-size: 11px
  }
  .export-buttons span {
    font-size: 9px
  }
  .editing-hint {
    font-size: 10px
  }
  .canvas-caption {
    font-size: 10px
  }
  .preview-top {
    padding: 16px;
    align-items: flex-start
  }
  .preview-top h2 {
    font-size: 19px
  }
  .preview-top button {
    font-size: 11px;
    white-space: nowrap;
    padding: 7px
  }
  .preview-bottom {
    padding: 16px;
    flex-direction: column;
    align-items: stretch
  }
  .preview-mat {
    padding: 10px
  }
  .inspector fieldset {
    display: block
  }
  .inspector .field-row {
    grid-template-columns: 1fr 1fr
  }
}

@media(prefers-reduced-motion:reduce) {
  * {
    transition: none!important
  }
}

@media print {
  html,body {
    margin: 0!important;
    padding: 0!important;
    background: white!important;
    color-scheme: light
  }
  body>* {
    display: none!important
  }
  body>#print-sheet {
    display: block!important
  }
  #print-sheet img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain
  }
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact
  }
}

.template-picker { margin-bottom: 22px; }
.template-choices { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.template-choices button { padding: 7px; text-align: left; background: var(--paper); min-width: 0; }
.template-choices button[aria-pressed=true] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); background: var(--selected); }
.template-choices canvas { width: 100%; height: auto; display: block; border-radius: 3px; margin-bottom: 8px; }
.template-choices strong { display: block; font-size: 12px; }
.template-choices span { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; }
.template-picker p { font-size: 11px; margin-top: 10px; }
.photo-credit { font-size: 10px; margin-top: 14px; }
.photo-credit a { color: var(--muted); text-underline-offset: 2px; }
@media(max-width:600px) {
  .template-choices { gap: 8px; }
  .template-choices button { padding: 5px; }
  .template-choices strong { font-size: 10px; }
  .template-choices span { display: none; }
}
