:root {
  color-scheme: light;
  --ink: #231815;
  --muted: #6f5d4a;
  --paper: #fff8ec;
  --panel: #fffdf7;
  --accent: #f47b20;
  --accent-dark: #a8480e;
  --poster-aspect-ratio: 1240 / 1754;
  --poster-aspect-number: 0.707;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 220, 132, 0.45), transparent 28%),
    linear-gradient(130deg, #fff4d7 0%, #f9e7ff 45%, #dff7ff 100%);
  font-family: "Chalkboard SE", "Comic Sans MS", "Marker Felt", system-ui, sans-serif;
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 22px;
  min-height: 100vh;
  padding: 22px;
}

.control-panel {
  min-width: 0;
  align-self: start;
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 3px solid #26170e;
  border-radius: 18px 12px 22px 14px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.45) 1px, transparent 1px) 0 0 / 18px 18px,
    var(--panel);
  box-shadow: 8px 9px 0 rgba(35, 24, 21, 0.16);
}

.brand-block {
  display: grid;
  gap: 6px;
}

.eyebrow {
  margin: 0;
  color: var(--accent-dark);
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.brand-block p:last-child {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-size: 14px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  border: 2px solid #2b1b12;
  border-radius: 12px 10px 13px 9px;
  background: #fffdfa;
  padding: 10px 12px;
  color: var(--ink);
  outline: none;
  box-shadow: 3px 4px 0 rgba(35, 24, 21, 0.12);
}

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

.photo-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.photo-mode button,
.primary-action {
  border: 2px solid #231815;
  border-radius: 999px;
  background: #fff;
  padding: 10px 12px;
  cursor: pointer;
  box-shadow: 3px 4px 0 rgba(35, 24, 21, 0.16);
}

.photo-mode button.active {
  background: #ffe17a;
}

.primary-action {
  background: var(--accent);
  color: #fff8ec;
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(0,0,0,0.25);
}

.warnings {
  min-height: 22px;
  color: #9b2415;
  font-size: 13px;
  line-height: 1.35;
}

.preview-panel {
  display: grid;
  place-items: center;
  min-width: 0;
}

.poster-stage {
  width: min(100%, calc(78vh * var(--poster-aspect-number)));
  max-width: 720px;
  aspect-ratio: var(--poster-aspect-ratio);
  filter: drop-shadow(0 18px 28px rgba(77, 42, 18, 0.28));
}

.poster-root,
.poster-root svg {
  width: 100%;
  height: 100%;
  display: block;
}

body.poster-only-mode {
  overflow: hidden;
  background: #eee5d6;
}

.poster-only-mode .app-shell {
  min-height: 100vh;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
}

.poster-only-mode .control-panel {
  display: none;
}

.poster-only-mode .preview-panel {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
}

.poster-only-mode .poster-stage {
  width: min(96vw, calc(96vh * var(--poster-aspect-number)));
  max-width: none;
  margin: 0;
  aspect-ratio: var(--poster-aspect-ratio);
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    padding: 12px;
    overflow: hidden;
    width: 100%;
    max-width: 100vw;
  }

  .control-panel,
  .preview-panel {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    justify-self: center;
  }

  .preview-panel {
    order: -1;
    justify-items: start;
  }

  .poster-stage {
    width: min(290px, calc(100vw - 96px));
    max-width: 290px;
    margin-left: 0;
  }

  .poster-only-mode .preview-panel {
    width: 100vw;
    max-width: none;
    height: 100vh;
    justify-items: center;
  }

  .poster-only-mode .poster-stage {
    width: min(96vw, calc(96vh * var(--poster-aspect-number)));
    max-width: none;
  }

  .control-panel {
    padding: 16px;
  }
}

.annotator-page {
  background: #efe7d6;
  overflow: hidden;
}

.annotator-shell {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 16px;
  height: 100vh;
  padding: 16px;
}

.annotator-panel {
  min-width: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 16px;
  border: 2px solid #231815;
  background: #fffdf7;
}

.annotator-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 8px;
}

.annotator-actions button {
  border: 2px solid #231815;
  border-radius: 8px;
  background: #fff;
  padding: 9px 8px;
  cursor: pointer;
  box-shadow: 2px 3px 0 rgba(35, 24, 21, 0.14);
}

.annotator-actions button:last-child {
  background: #f47b20;
  color: #fff8ec;
  font-weight: 900;
}

.annotator-editor {
  display: grid;
  gap: 10px;
}

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

.annotator-panel h1,
.annotator-panel p {
  margin: 0;
}

.annotator-panel h1 {
  font-size: 22px;
}

.annotator-panel p {
  color: var(--muted);
  line-height: 1.45;
}

.annotator-workbench {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
}

.annotator-canvas-wrap {
  width: min(100%, calc(96vh * 1664 / 2496));
  aspect-ratio: 1664 / 2496;
  box-shadow: 0 16px 34px rgba(35, 24, 21, 0.22);
  background: #fff;
}

#annotatorCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.annotator-output {
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  padding: 10px;
  border: 1px solid rgba(35, 24, 21, 0.22);
  background: #fff8ec;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
