:root {
  --bg: #f7f1e8;
  --bg-strong: #efe4d3;
  --surface: rgba(255, 252, 247, 0.82);
  --surface-strong: #fffdf9;
  --ink: #1f2937;
  --muted: #6b7280;
  --accent: #c75c2a;
  --accent-dark: #9c431b;
  --line: rgba(31, 41, 55, 0.12);
  --shadow: 0 24px 60px rgba(92, 54, 21, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(199, 92, 42, 0.18), transparent 24%),
    radial-gradient(circle at bottom right, rgba(39, 143, 122, 0.18), transparent 26%),
    linear-gradient(135deg, #f6ecdf 0%, #f9f6f0 45%, #efe6d9 100%);
}

.app-shell {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 32px 24px;
  border-right: 1px solid var(--line);
  background: rgba(255, 249, 240, 0.76);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-dark);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Fraunces", serif;
}

h1 {
  font-size: 2.4rem;
  line-height: 1;
}

.lead,
.panel p,
#status-text {
  color: var(--muted);
}

.upload-card,
.panel {
  border: 1px solid rgba(199, 92, 42, 0.15);
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.upload-card {
  padding: 20px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.upload-title {
  font-weight: 700;
}

.upload-copy {
  color: var(--muted);
  font-size: 0.95rem;
}

.panel {
  padding: 18px;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.pill {
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(199, 92, 42, 0.1);
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 700;
}

.tool-btn,
.primary-btn,
.ghost-btn {
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 13px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

.tool-btn,
.ghost-btn {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent) 0%, #df7d36 100%);
  color: #fff;
  margin-top: 12px;
}

.tool-btn:hover,
.primary-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

.tool-btn:disabled,
.primary-btn:disabled,
.ghost-btn:disabled,
.tool-upload.disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.tool-upload {
  display: block;
  text-align: center;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.field span {
  font-size: 0.92rem;
  font-weight: 700;
}

textarea,
input[type="range"],
input[type="color"] {
  width: 100%;
}

textarea {
  resize: vertical;
  min-height: 88px;
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 12px;
  font: inherit;
}

input[type="color"] {
  height: 42px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.muted-panel {
  margin-top: auto;
}

.workspace {
  padding: 28px 28px 48px;
  overflow: hidden;
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 24px;
}

.workspace-header h2 {
  font-size: 2rem;
}

.empty-state {
  min-height: 72vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px;
  border: 1px dashed rgba(31, 41, 55, 0.16);
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.34);
}

.empty-art {
  width: 140px;
  height: 140px;
  margin-bottom: 18px;
  border-radius: 32px;
  background:
    linear-gradient(135deg, rgba(199, 92, 42, 0.9), rgba(223, 125, 54, 0.28)),
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.7) 0,
      rgba(255, 255, 255, 0.7) 10px,
      transparent 10px,
      transparent 20px
    );
  transform: rotate(-8deg);
}

.pages-root {
  display: none;
  flex-direction: column;
  gap: 28px;
  max-height: calc(100vh - 120px);
  overflow: auto;
  padding-right: 14px;
}

.page-card {
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(31, 41, 55, 0.09);
  border-radius: 28px;
  padding: 20px;
  box-shadow: 0 24px 50px rgba(70, 50, 28, 0.1);
}

.page-card.active {
  outline: 2px solid rgba(199, 92, 42, 0.45);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.page-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.page-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 18px;
}

.overlay-layer {
  position: absolute;
  inset: 0;
}

.overlay-item {
  position: absolute;
  min-width: 40px;
  min-height: 40px;
  cursor: move;
  user-select: none;
  border: 2px solid transparent;
  border-radius: 10px;
}

.overlay-item.selected {
  border-color: rgba(199, 92, 42, 0.8);
}

.overlay-item.existing-item:hover {
  border-color: rgba(199, 92, 42, 0.3);
}

.overlay-item.deleted {
  display: none;
}

.overlay-text {
  padding: 8px 10px;
  background: rgba(255, 252, 247, 0.8);
  border-radius: 12px;
  white-space: pre-wrap;
  line-height: 1.25;
}

.overlay-text.existing-text {
  padding: 2px 4px;
  background: transparent;
  color: transparent;
}

.overlay-item.selected .overlay-text.existing-text,
.overlay-item.edited .overlay-text.existing-text {
  background: rgba(255, 252, 247, 0.88);
  color: inherit;
}

.resize-handle {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  cursor: nwse-resize;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    padding: 20px;
  }

  .workspace-header {
    flex-direction: column;
    align-items: start;
  }
}
