:root {
  --paper-width: 11in;
  --paper-height: 8.5in;
  --safe-margin: 4mm;
  --x-offset: 0mm;
  --y-offset: 0mm;
  --ink: #202124;
  --muted: #68707a;
  --line: #d7dce2;
  --panel: #ffffff;
  --surface: #f4f6f8;
  --accent: #1b6b6f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--surface);
  font-family: Arial, sans-serif;
}

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

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  min-height: 36px;
  padding: 0 12px;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

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

.app-header h1 {
  font-size: 22px;
  line-height: 1.1;
  margin: 0;
}

.app-header p {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.app-shell {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(280px, 340px) 1fr;
  padding: 18px;
}

.controls {
  align-self: start;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 18px;
  padding: 16px;
}

.controls section {
  display: grid;
  gap: 12px;
}

.controls h2 {
  font-size: 14px;
  margin: 0;
  text-transform: uppercase;
}

.help-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

details {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

details + details {
  margin-top: 8px;
}

summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

details p,
details li {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

details p {
  margin: 8px 0 0;
}

details ol,
details ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

label,
.file-control {
  display: grid;
  gap: 6px;
}

label span,
.file-control span {
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  min-height: 36px;
  padding: 8px;
  width: 100%;
}

textarea {
  line-height: 1.35;
  resize: vertical;
}

.emoticon-picker {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(8, minmax(0, 1fr));
}

.emoticon-picker button {
  align-items: center;
  display: inline-flex;
  font-size: 18px;
  justify-content: center;
  min-height: 34px;
  padding: 0;
}

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

.check-row {
  align-items: center;
  display: flex;
  gap: 8px;
}

.check-row input {
  min-height: auto;
  width: auto;
}

.preview-wrap {
  min-width: 0;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tabs button.active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.print-stack {
  display: grid;
  justify-content: center;
  overflow: auto;
  padding: 6px;
}

.paper {
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(25, 33, 38, 0.18);
  display: none;
  height: min(76vh, calc(8.5 / 11 * (100vw - 430px)));
  min-height: 360px;
  position: relative;
  width: min(calc(100vw - 430px), calc(11 / 8.5 * 76vh));
}

.paper.active {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.panel {
  display: grid;
  min-width: 0;
  overflow: hidden;
  padding: var(--safe-margin);
  position: relative;
}

.panel::after {
  border: 1px dashed rgba(27, 107, 111, 0.42);
  content: "";
  inset: var(--safe-margin);
  pointer-events: none;
  position: absolute;
}

.hide-guides .panel::after,
.hide-guides .fold-line,
.hide-guides .panel-label {
  display: none;
}

.fold-line {
  border-left: 1px dashed #9aa4af;
  bottom: 0;
  left: 50%;
  pointer-events: none;
  position: absolute;
  top: 0;
  z-index: 5;
}

.panel-label {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  left: 10px;
  padding: 4px 8px;
  position: absolute;
  top: 10px;
  z-index: 4;
}

.image-slot {
  align-items: center;
  border: 1px solid #dfe4ea;
  color: var(--muted);
  display: grid;
  justify-items: center;
  min-height: 0;
  overflow: hidden;
  text-align: center;
}

.image-slot img {
  display: block;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.fill-slot {
  border: 0;
  height: 100%;
  width: 100%;
}

.fill-slot img {
  object-fit: cover;
}

.icon-slot {
  align-self: center;
  height: 1.25in;
  justify-self: center;
  width: 1.25in;
}

.small-slot {
  min-height: 1in;
  width: 2.2in;
}

.small-slot img {
  height: auto;
  object-fit: contain;
  width: 100%;
}

.inside-left-panel {
  align-items: center;
  justify-items: center;
}

.inside-left-content {
  align-items: center;
  display: grid;
  justify-items: center;
  max-width: 88%;
}

.inside-caption {
  color: var(--ink);
  line-height: 1.25;
  max-width: 4.2in;
  text-align: center;
  white-space: pre-wrap;
}

.message-panel {
  align-items: center;
  justify-items: center;
}

.message-preview {
  max-width: 84%;
  text-align: center;
  white-space: pre-wrap;
}

.print-outside .paper,
.print-inside .paper {
  display: none;
}

.print-outside #outsidePage,
.print-inside #insidePage {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 900px) {
  .app-header,
  .app-shell {
    display: grid;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .paper {
    height: calc((100vw - 48px) * 8.5 / 11);
    min-height: 260px;
    width: calc(100vw - 48px);
  }
}

@page {
  size: letter landscape;
  margin: 0;
}

@media print {
  body {
    background: #ffffff;
  }

  .app-header,
  .controls,
  .tabs {
    display: none !important;
  }

  .app-shell,
  .preview-wrap,
  .print-stack {
    display: block;
    margin: 0;
    padding: 0;
  }

  .paper,
  .paper.active {
    box-shadow: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: var(--paper-height);
    min-height: 0;
    page-break-after: always;
    transform: translate(var(--x-offset), var(--y-offset));
    transform-origin: top left;
    width: var(--paper-width);
  }

  .rotate-inside.print-inside #insidePage {
    transform: translate(var(--x-offset), var(--y-offset)) rotate(180deg);
    transform-origin: center center;
  }

  .print-outside .paper,
  .print-inside .paper {
    display: none;
  }

  .print-outside #outsidePage,
  .print-inside #insidePage {
    display: grid;
  }

  .fold-line,
  .panel::after,
  .panel-label {
    display: none !important;
  }
}
