:root {
  --navy: #00497a;
  --orange: #eb864c;
  --orange-hover: #e2793a;
  --yellow: #faeb80;
  --ink: #151515;
  --bg: #fffdf8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

/* Header */

.site-header {
  background: var(--navy);
  padding: 12px 16px;
}

.site-header-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.site-logo {
  height: 40px;
  width: auto;
  display: block;
}

/* Page */

.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 16px 64px;
  text-align: center;
}

h1 {
  margin-bottom: 4px;
  font-weight: 800;
  color: var(--navy);
}

.subtitle {
  color: #555;
  margin-top: 0;
  margin-bottom: 24px;
  font-weight: 500;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0;
}

/* Buttons */

.btn {
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  border-radius: 0;
  border: 3px solid #000;
  padding: 13px 26px;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
  color: var(--ink);
  line-height: 1.2;
  transition: transform 0.08s ease, background-color 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--orange);
}

.btn-primary:hover:not(:disabled) {
  background: var(--orange-hover);
}

.btn-secondary {
  background: #fff;
}

.btn-secondary:hover:not(:disabled) {
  background: #f2f2f2;
}

.btn-ghost {
  background: transparent;
  border-width: 2px;
  padding: 8px 18px;
  font-size: 13px;
}

.btn-ghost:hover {
  background: #fff;
}

.btn:disabled {
  background: #e4e4e4;
  color: #9a9a9a;
  border-color: #bbb;
  cursor: not-allowed;
}

.btn-step {
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--yellow);
}

.btn-step:hover:not(:disabled) {
  background: #f5e05c;
}

.btn-step:disabled {
  background: #eee;
  color: #aaa;
  border-color: #ccc;
}

/* Stage */

.editor-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
  margin-top: 8px;
}

.stage-column {
  display: flex;
  justify-content: center;
}

.stage-wrapper {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  background: #fff;
  border: 3px solid #000;
  border-radius: 0;
  overflow: hidden;
  touch-action: none;
}

/* Fabric.js wraps the canvas in a .canvas-container div and sets inline
   pixel width/height on it and on both internal canvas layers matching the
   logical 1080x1080 resolution. Force everything to scale down to the
   wrapper's display size while the underlying resolution stays 1080x1080,
   so exported PNGs stay full quality. */
.stage-wrapper .canvas-container {
  width: 100% !important;
  height: 100% !important;
}

.stage-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  touch-action: none;
}

/* Sidebar (desktop/tablet) */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #fff;
  border: 3px solid #000;
  border-radius: 0;
  padding: 20px;
  text-align: left;
}

.sidebar > .btn {
  width: 100%;
  text-align: center;
}

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.zoom-controls {
  margin: 0;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
}

#zoom-slider {
  flex: 1;
  max-width: none;
  accent-color: var(--orange);
}

@media (min-width: 768px) {
  .stage-wrapper {
    max-width: 560px;
  }

  .editor-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
  }

  .sidebar {
    position: sticky;
    top: 24px;
  }
}

/* Caption page */

.caption-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  max-width: 480px;
  margin: 0 auto 20px;
}

.caption-fields label {
  font-weight: 700;
  font-size: 14px;
  margin-top: 10px;
  color: var(--navy);
}

.caption-fields input {
  padding: 12px 14px;
  font-size: 15px;
  border: 2px solid #000;
  border-radius: 0;
  font-family: inherit;
}

.caption-fields input:focus {
  outline: 3px solid var(--yellow);
  outline-offset: 1px;
}

.caption-preview-wrapper {
  max-width: 600px;
  margin: 0 auto 8px;
  background: #fff;
  border: 3px solid #000;
  border-radius: 0;
  padding: 4px;
}

.caption-preview {
  margin: 0;
  padding: 20px;
  text-align: left;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: inherit;
  user-select: text;
}

.status {
  min-height: 20px;
  color: #1a7a3c;
  font-weight: 700;
  margin-top: 4px;
}
