:root {
  color-scheme: light;

  --ink: #292621;
  --paper: #f2eee5;
  --paper-light: #faf7f0;
  --pink: #e99cba;
  --pink-dark: #913b61;
  --muted: #746e65;
  --line: #d7d0c4;
  --studio: #d9cebe;

  --font-body: Arial, Helvetica, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
  --font-mono: "Courier New", Courier, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 20px;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea,
summary {
  -webkit-tap-highlight-color: transparent;
}

button,
a {
  touch-action: manipulation;
}

button,
input,
select,
textarea {
  border-radius: 0;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--pink-dark);
  outline-offset: 4px;
}

a {
  color: inherit;
}

img,
canvas {
  display: block;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

::selection {
  background: #e99cba;
  color: #292621;
}

/* Header */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 106px;
  padding: 24px 42px;
  border-bottom: 1px solid var(--ink);
  background: var(--paper);
}

.brand {
  display: inline-flex;
  flex-direction: column;
  flex-shrink: 0;
  text-decoration: none;
  font-size: 23px;
  font-weight: 900;
  line-height: .88;
  letter-spacing: -1.5px;
}

.brand-bottom {
  color: var(--pink-dark);
}

.header-center {
  display: grid;
  gap: 6px;
  text-align: center;
}

.header-caption {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.4px;
}

.header-subtitle {
  font-family: var(--font-serif);
  font-size: 18px;
  font-style: italic;
}

.header-link {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.header-link span {
  font-size: 20px;
}

/* Main layout */

.app-layout {
  display: grid;
  grid-template-columns: 365px minmax(0, 1fr);
  max-width: 1920px;
  margin: 0 auto;
}

.editor {
  min-width: 0;
  border-right: 1px solid var(--ink);
  background: var(--paper-light);
}

.editor-intro {
  padding: 32px 28px 26px;
}

.eyebrow {
  display: block;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 1.4px;
}

.editor-intro h1 {
  margin: 20px 0 17px;
  font-family: var(--font-serif);
  font-size: 48px;
  font-weight: 400;
  line-height: .98;
  letter-spacing: -2.7px;
}

.editor-intro h1 em {
  color: var(--pink-dark);
}

.editor-description {
  max-width: 290px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

/* Editor sections */

.editor-section {
  border-top: 1px solid var(--line);
}

.editor-section > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 65px;
  padding: 18px 28px;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.editor-section > summary::-webkit-details-marker {
  display: none;
}

.section-number {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

.section-title {
  flex: 1;
  font-size: 15px;
  font-weight: 700;
}

.section-toggle {
  font-size: 23px;
  font-weight: 400;
  line-height: 1;
  transition: transform 180ms ease;
}

.editor-section[open] .section-toggle {
  transform: rotate(45deg);
}

.section-content {
  display: grid;
  gap: 20px;
  padding: 0 28px 25px;
}

.bare-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.bare-fieldset legend {
  margin-bottom: 11px;
  padding: 0;
}

.field-label {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

/* Edition picker */

.edition-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.edition-option {
  position: relative;
  min-width: 0;
  cursor: pointer;
}

.edition-option > input,
.segmented-control input,
.color-option > input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.edition-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 5px 5px 10px;
  border: 1px solid var(--line);
  background: #eee8dd;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease;
}

.edition-image {
  display: block;
  height: 87px;
  overflow: hidden;
  background: #e3dacd;
}

.edition-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 240ms ease;
}

.edition-name {
  padding: 10px 1px 0;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.edition-caption {
  margin-top: 4px;
  color: #71675d;
  font-size: 9px;
  line-height: 1.3;
  text-align: center;
}

.edition-option:hover .edition-card {
  transform: translateY(-3px);
}

.edition-option:hover img {
  transform: scale(1.04);
}

.edition-option input:checked + .edition-card {
  border-color: var(--ink);
  background: #f4d6e1;
  box-shadow: 3px 3px 0 var(--ink);
}

.edition-option input:focus-visible + .edition-card {
  outline: 3px solid var(--pink-dark);
  outline-offset: 4px;
}

/* Form controls */

.field {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.field input,
.field textarea,
.quality-field select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  background: #fffdf7;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.4;
  transition:
    border-color 180ms ease,
    background-color 180ms ease;
}

.field input:hover,
.field textarea:hover,
.quality-field select:hover {
  border-color: #a79b8c;
}

.field input:focus,
.field textarea:focus,
.quality-field select:focus {
  background: #ffffff;
  border-color: var(--pink-dark);
}

.field input::placeholder,
.field textarea::placeholder {
  color: #958a7c;
  opacity: 1;
}

.field textarea {
  resize: vertical;
  min-height: 80px;
  max-height: 200px;
}

.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.optional {
  margin-left: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.character-count {
  justify-self: end;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
}

.segmented-control label {
  position: relative;
  min-width: 0;
  cursor: pointer;
}

.segmented-control span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 6px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  transition:
    background-color 180ms ease,
    color 180ms ease;
}

.segmented-control input:checked + span {
  background: var(--ink);
  color: var(--paper-light);
}

.segmented-control input:focus-visible + span {
  outline: 3px solid var(--pink-dark);
  outline-offset: 4px;
}

/* Finishing touches */

.color-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.color-option {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 9px;
  cursor: pointer;
}

.color-swatch {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(41, 38, 33, .25);
  border-radius: 50%;
  background: var(--swatch);
  transition: box-shadow 180ms ease;
}

.color-option > span:last-child {
  font-size: 11px;
}

.color-option input:checked + .color-swatch {
  box-shadow:
    0 0 0 3px var(--paper-light),
    0 0 0 4px var(--ink);
}

.color-option input:focus-visible + .color-swatch {
  outline: 3px solid var(--pink-dark);
  outline-offset: 5px;
}

.range-field {
  display: grid;
  gap: 12px;
}

.range-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.range-heading output {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

.range-field input {
  width: 100%;
  margin: 0;
  accent-color: var(--pink-dark);
  cursor: pointer;
}

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 12px;
  line-height: 1.5;
  cursor: pointer;
}

.checkbox-field input {
  margin: 2px 0 0;
  accent-color: var(--pink-dark);
}

.editor-bottom {
  padding: 22px 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
}

/* Preview */

.preview-panel {
  min-width: 0;
  padding: 34px clamp(24px, 4vw, 70px) 24px;
  background: var(--studio);
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent 3px,
      rgba(44, 31, 17, .025) 3px,
      rgba(44, 31, 17, .025) 4px
    ),
    radial-gradient(
      ellipse at 50% 25%,
      rgba(255, 252, 236, .56),
      transparent 70%
    );
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.preview-header h2 {
  margin: 9px 0 0;
  font-family: var(--font-serif);
  font-size: clamp(25px, 2.8vw, 39px);
  font-weight: 400;
  letter-spacing: -1.2px;
}

.edition-badge {
  flex-shrink: 0;
  padding: 8px 10px;
  border: 1px solid #9e8f7b;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .6px;
  transform: rotate(3deg);
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 51px;
  border-top: 1px solid #ac9d89;
  border-bottom: 1px solid #ac9d89;
}

.preview-format {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.icon-button,
.text-button {
  min-height: 36px;
  border: 0;
  background: transparent;
}

.icon-button {
  width: 32px;
  padding: 0;
  font-size: 23px;
}

.text-button {
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 700;
}

.icon-button:hover,
.text-button:hover {
  background: rgba(255, 255, 255, .35);
}

.icon-button:disabled {
  opacity: .3;
  cursor: default;
}

.zoom-value {
  min-width: 41px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
}

.toolbar-divider {
  width: 1px;
  height: 19px;
  margin: 0 6px;
  background: #ac9d89;
}

.preview-viewport {
  width: 100%;
  overflow: auto;
  overscroll-behavior: contain;
}

.preview-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 470px;
  padding: 55px 24px 45px;
}

.artwork-wrap {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  max-width: 1100px;
  box-shadow:
    1px 2px 2px rgba(34, 24, 12, .17),
    8px 17px 23px rgba(34, 24, 12, .19),
    17px 35px 55px rgba(34, 24, 12, .15);
}

.artwork-wrap.is-card {
  max-width: 360px;
}

#ticket {
  width: 100%;
  height: auto;
  background: #f2eee5;
}

.preview-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 4px 0 29px;
}

.caption-script {
  font-family: var(--font-serif);
  font-size: clamp(25px, 3vw, 39px);
  font-style: italic;
  letter-spacing: -1.5px;
  transform: rotate(-4deg);
}

.caption-note {
  color: #766957;
  font-size: 12px;
  text-align: right;
}

/* Export */

.export-panel {
  max-width: 850px;
  margin: 0 auto;
  padding: 25px;
  border: 1px solid #b3a692;
  background: rgba(250, 246, 235, .8);
  box-shadow: 0 5px 15px rgba(50, 35, 16, .035);
}

.export-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.export-heading h3 {
  margin: 7px 0 0;
  font-family: var(--font-serif);
  font-size: 25px;
  font-weight: 400;
  letter-spacing: -.7px;
}

.file-badge {
  padding: 11px 9px;
  border: 1px solid var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
}

.export-controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 0;
}

.quality-field {
  display: grid;
  gap: 7px;
  width: min(280px, 65%);
}

.quality-field select {
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
}

.file-information {
  display: grid;
  gap: 7px;
  padding-bottom: 4px;
  text-align: right;
}

.file-information strong {
  font-family: var(--font-mono);
  font-size: 13px;
}

.file-information > span {
  color: var(--muted);
  font-size: 11px;
}

.download-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.download-button,
.open-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  min-height: 52px;
  padding: 13px 18px;
  border: 1px solid var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.download-button {
  justify-content: space-between;
  background: var(--pink);
  box-shadow: 3px 3px 0 var(--ink);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease;
}

.download-button > span:last-child {
  font-size: 22px;
}

.download-button:hover:not(.is-disabled) {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--ink);
}

.download-button:active:not(.is-disabled) {
  transform: translate(3px, 3px);
  box-shadow: none;
}

.open-button {
  background: transparent;
  font-size: 12px;
}

.open-button:hover:not(.is-disabled) {
  background: #fffdf7;
}

.is-disabled {
  opacity: .45;
  cursor: wait;
}

.status-message {
  min-height: 32px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.status-message.is-error {
  color: #9b2e41;
}

.retry-button {
  margin-top: 8px;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: none;
  font-size: 13px;
  font-weight: 700;
}

.preview-footer {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  padding: 25px 0 0;
  color: #746957;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.6;
}

.preview-footer p {
  margin: 0;
  text-align: right;
}

/* Expanded preview */

.preview-dialog {
  width: min(1400px, 94vw);
  max-height: 94vh;
  margin: auto;
  padding: 0;
  border: 1px solid #827463;
  background: #e1d6c5;
  color: var(--ink);
}

.preview-dialog::backdrop {
  background: rgba(20, 17, 13, .84);
}

.dialog-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 20px;
  border-bottom: 1px solid #a59885;
  font-family: var(--font-mono);
  font-size: 12px;
}

.dialog-close {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid #a59885;
  background: #f2eee5;
  font-size: 13px;
}

.dialog-artwork {
  display: flex;
  justify-content: center;
  padding: 30px;
}

#expanded-ticket {
  width: 100%;
  height: auto;
  object-fit: contain;
}

#expanded-ticket.is-card {
  width: min(430px, 100%);
}

/* Responsive */

@media (min-width: 1600px) {
  .app-layout {
    grid-template-columns: 395px minmax(0, 1fr);
  }

  .preview-stage {
    min-height: 590px;
  }

  .edition-image {
    height: 105px;
  }
}

@media (max-width: 1100px) {
  .app-layout {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .editor-intro {
    padding: 28px 22px 24px;
  }

  .editor-intro h1 {
    font-size: 42px;
  }

  .editor-section > summary {
    padding: 17px 22px;
  }

  .section-content {
    padding: 0 22px 24px;
  }

  .edition-image {
    height: 72px;
  }

  .edition-caption {
    display: none;
  }

  .field-pair {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    padding-right: 24px;
    padding-left: 24px;
  }

  .preview-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 15px;
  }

  .preview-stage {
    min-height: 340px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .caption-note {
    display: none;
  }

  .export-panel {
    padding: 20px;
  }

  .download-actions {
    grid-template-columns: 1fr;
  }

  .preview-footer {
    flex-direction: column;
    gap: 5px;
  }

  .preview-footer p {
    text-align: left;
  }
}

@media (max-width: 760px) {
  .app-header {
    min-height: 86px;
    padding: 20px;
  }

  .brand {
    font-size: 20px;
  }

  .header-center {
    margin-left: auto;
    text-align: right;
  }

  .header-caption {
    max-width: 155px;
    font-size: 9px;
    letter-spacing: .6px;
  }

  .header-subtitle {
    font-size: 15px;
  }

  .header-link {
    display: none;
  }

  .app-layout {
    display: flex;
    flex-direction: column;
  }

  .editor {
    border-right: 0;
    border-bottom: 1px solid var(--ink);
  }

  .editor-intro {
    padding: 27px 24px 23px;
  }

  .editor-intro h1 {
    font-size: 43px;
  }

  .editor-description {
    max-width: 390px;
  }

  .editor-section > summary {
    padding: 17px 24px;
  }

  .section-content {
    padding: 0 24px 25px;
  }

  .edition-image {
    height: 120px;
  }

  .edition-name {
    font-size: 13px;
  }

  .edition-caption {
    display: block;
    font-size: 10px;
  }

  .field-pair {
    grid-template-columns: 1fr 1fr;
  }

  .field input,
  .field textarea,
  .quality-field select {
    font-size: 16px;
  }

  .preview-panel {
    padding: 28px 20px 22px;
  }

  .preview-header {
    flex-direction: row;
    align-items: center;
  }

  .preview-header h2 {
    max-width: 220px;
    font-size: 27px;
  }

  .edition-badge {
    max-width: 106px;
    font-size: 9px;
    line-height: 1.5;
  }

  .preview-stage {
    min-height: 0;
    padding: 36px 8px;
  }

  .artwork-wrap.is-card {
    max-width: 300px;
  }

  .preview-format {
    font-size: 9px;
  }

  .toolbar-actions {
    gap: 1px;
  }

  .text-button {
    padding-right: 6px;
    padding-left: 6px;
    font-size: 11px;
  }

  .toolbar-divider {
    margin: 0 3px;
  }

  .preview-caption {
    padding-bottom: 25px;
  }

  .caption-script {
    font-size: 31px;
  }

  .export-heading h3 {
    font-size: 23px;
  }

  .export-controls {
    gap: 12px;
  }

  .quality-field {
    width: 68%;
  }

  .quality-field select {
    font-size: 13px;
  }

  .download-actions {
    grid-template-columns: 1fr;
  }

  .dialog-artwork {
    padding: 12px;
  }
}

@media (max-width: 380px) {
  .field-pair {
    grid-template-columns: 1fr;
  }

  .edition-image {
    height: 94px;
  }

  .edition-caption {
    display: none;
  }

  .preview-format {
    display: none;
  }

  .preview-toolbar {
    justify-content: flex-end;
  }

  .edition-badge {
    display: none;
  }

  .export-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .quality-field {
    width: 100%;
  }

  .file-information {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}