:root {
  --bg: #ececec;
  --panel: rgba(255, 255, 255, 0.93);
  --card: #fbfbfb;
  --ink: #1f1f1f;
  --muted: #6d6d6d;
  --line: #dddddd;
  --yellow: #ffd400;
  --violet: #30205d;
  --danger: #a63a3a;
  --shadow: 0 28px 60px rgba(0, 0, 0, 0.14);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 212, 0, 0.18), transparent 20%),
    linear-gradient(180deg, #f7f7f7 0%, #e4e4e4 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

img,
canvas {
  display: block;
  max-width: 100%;
}

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

.editor-panel {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 30px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.panel-top h1,
.preview-toolbar h2 {
  margin: 0;
  line-height: 1.02;
  font-size: clamp(1.85rem, 2vw, 2.45rem);
}

.panel-copy {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.editor-form {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.form-card,
.dynamic-card {
  background: var(--card);
  border: 1px solid #e3e3e3;
  border-radius: 22px;
  padding: 18px;
}

.form-card h2,
.dynamic-head h3 {
  margin: 0;
  font-size: 1rem;
}

.section-head,
.dynamic-head,
.editor-actions,
.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

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

.field input,
.field textarea,
.ingredient-row input {
  width: 100%;
  border: 1px solid #d0d0d0;
  border-radius: 14px;
  padding: 11px 13px;
  background: #fff;
  color: var(--ink);
}

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

.field input:focus,
.field textarea:focus,
.ingredient-row input:focus {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(48, 32, 93, 0.12);
}

.upload-preview {
  min-height: 176px;
  margin-top: 14px;
  border: 1px dashed #c7c7c7;
  border-radius: 18px;
  background: #fff;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.upload-preview.has-image img {
  display: block;
}

.upload-preview.has-image p {
  display: none;
}

.upload-preview p {
  margin: 0;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.photo-controls {
  display: none;
}

.photo-controls.visible {
  display: grid;
}

.field input[type="range"] {
  border: none;
  border-radius: 0;
  padding: 4px 0;
  background: transparent;
  accent-color: var(--violet);
  cursor: pointer;
}

.field input[type="range"]:focus {
  box-shadow: none;
  border: none;
  outline: none;
}

.static-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.editor-stack {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.ingredient-row {
  display: grid;
  grid-template-columns: minmax(0, 9fr) minmax(58px, 1fr) auto;
  gap: 10px;
  margin-top: 10px;
}

.add-ingredient,
.add-method {
  display: block;
  width: 100%;
  min-height: 52px;
  margin-top: 12px;
  text-align: center;
}

.recipe-method-field[hidden] {
  display: none;
}

.recipe-text-sections {
  margin-top: 14px;
}

.add-recipe-text-section {
  width: 100%;
  min-height: 52px;
  margin-top: 12px;
  text-align: center;
}

.section-add-btn {
  margin-top: 14px;
}

.between-sections-btn {
  margin-top: -2px;
  margin-bottom: -2px;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
}

.primary-btn {
  background: var(--violet);
  color: #fff;
}

.word-btn {
  background: #1a6e36;
  color: #fff;
}

.secondary-btn {
  background: var(--yellow);
  color: #111;
}

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

.danger-btn {
  background: transparent;
  color: var(--danger);
  padding: 0;
}

.icon-danger-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
  font-weight: 500;
  color: #d33f3f;
}

.icon-danger-btn:hover {
  background: rgba(211, 63, 63, 0.08);
}

.remove-text-field-btn {
  align-self: flex-start;
  margin-top: 14px;
  padding: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: #d33f3f;
}

.remove-recipe-btn {
  align-self: flex-start;
  margin-top: 14px;
  padding: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: #d33f3f;
}

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

.preview-toolbar {
  margin-bottom: 14px;
}

.preview-status {
  color: var(--muted);
  font-size: 0.9rem;
}

.preview-pages {
  display: grid;
  gap: 24px;
}

.preview-page {
  width: min(100%, 760px);
  margin: 0 auto;
}

.preview-canvas {
  width: 100%;
  height: auto;
  background: #fff;
  box-shadow: var(--shadow);
}

.page-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

  .editor-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
    gap: 16px;
  }

  .editor-panel {
    padding: 18px;
    border-radius: 24px;
  }

  .section-head,
  .dynamic-head,
  .editor-actions,
  .preview-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .ingredient-row {
    grid-template-columns: 1fr;
  }
}
