@font-face { font-family: 'KyivTypeSans-Heavy'; src: url('/web/fonts/KyivTypeSans-Heavy.otf') format('opentype'); }
@font-face { font-family: 'TBSGartek-Display'; src: url('/web/fonts/TBSGartek-Display.otf') format('opentype'); }
@font-face { font-family: 'AGaramondPro-Bold'; src: url('/web/fonts/AGaramondPro-Bold.otf') format('opentype'); }
@font-face { font-family: 'AuBordDeLaSeine'; src: url('/web/fonts/AuBordDeLaSeine.ttf') format('truetype'); }
@font-face { font-family: 'Oswald-SemiBold'; src: url('/web/fonts/Oswald-SemiBold.ttf') format('truetype'); }
@font-face { font-family: 'Roboto-Light'; src: url('/web/fonts/Roboto-Light.ttf') format('truetype'); }

.fre-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.fre-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.fre-container {
  background: #fefaf0;
  border-radius: 16px;
  width: 92vw;
  max-width: 1200px;
  height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}

.fre-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid #eee;
  background: #fff;
}
.fre-header-title {
  font-family: 'Oswald', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  text-transform: none;
  color: #1a1a1a;
}
.fre-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.fre-btn-save {
  font-family: 'Roboto', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 8px 28px;
  border-radius: 28px;
  border: none;
  cursor: pointer;
  background: #E67E50;
  color: #fff;
  transition: background 0.2s;
}
.fre-btn-save:hover { background: #d06a3e; }
.fre-btn-saved {
  background: #4a8c3f !important;
  transition: background 0.3s;
}
.fre-btn-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #999;
  font-size: 1.4rem;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.15s;
}
.fre-btn-close:hover { color: #333; }

.fre-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.fre-preview-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #f0ece4;
  overflow: hidden;
  position: relative;
}
.fre-zoom-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  z-index: 10;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  margin: 12px 0 8px 0;
}
.fre-zoom-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid #ddd;
  background: #fff;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  transition: background 0.15s, border-color 0.15s;
}
.fre-zoom-btn:hover {
  background: #f0f0f0;
  border-color: #999;
}
.fre-zoom-level {
  font-family: 'Roboto', sans-serif;
  font-size: 0.78rem;
  color: #666;
  min-width: 36px;
  text-align: center;
}
.fre-spread-wrapper {
  flex: 1;
  overflow: auto;
  cursor: grab;
  width: 100%;
}
.fre-spread-wrapper:active {
  cursor: grabbing;
}
.fre-spread-sizer {
  display: inline-block;
}
.fre-spread {
  display: flex;
  box-shadow: none;
  transform-origin: center center;
  width: 860px;
  height: 608px;
  flex-shrink: 0;
  transition: transform 0.12s ease;
}

.fre-page {
  width: 430px;
  height: 608px;
  position: relative;
  overflow: visible;
}

.fre-page-text {
  background: transparent;
  position: relative;
}
.fre-page-text::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: #fff;
  z-index: 0;
  pointer-events: none;
}

.fre-page-text-inner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: visible;
  z-index: 1;
}

.fre-category {
  font-family: 'Oswald-SemiBold', 'Oswald', sans-serif;
  font-size: 7.2px;
  text-transform: none;
  color: #1a1a1a;
  letter-spacing: 0.5px;
  position: absolute;
  top: 27px;
  left: 25px;
  right: 51px;
}

.fre-recipe-title {
  font-family: 'KyivTypeSans-Heavy', serif;
  font-size: 29px;
  color: #1a1a1a;
  line-height: 1.08;
  text-transform: none;
  position: absolute;
  left: 25px;
  right: 25px;
  overflow: visible;
}
.fre-title-line {
  display: block;
  white-space: nowrap;
}

.fre-indications {
  display: flex;
  justify-content: space-between;
  padding: 0;
  position: absolute;
  top: 142px;
  left: 25px;
  right: 51px;
}
.fre-indication-item {
  display: flex;
  flex-direction: column;
  min-width: 40px;
  align-items: center;
  text-align: center;
}
.fre-indication-label {
  font-family: 'Oswald-SemiBold', 'Oswald', sans-serif;
  font-size: 6.5px;
  text-transform: none;
  color: #1a1a1a;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}
.fre-indication-value {
  font-family: 'Roboto-Light', 'Roboto', sans-serif;
  font-size: 6.5px;
  color: #333;
}
.fre-indications-line {
  height: 0.5px;
  background: #b7b5b5;
  position: absolute;
  top: 173px;
  left: 25px;
  right: 51px;
}

.fre-content-columns {
  display: flex;
  gap: 16px;
  position: absolute;
  top: 194px;
  left: 25px;
  right: 39px;
}

.fre-ingredients-col {
  width: 119px;
  flex-shrink: 0;
}
.fre-steps-col {
  width: 231px;
  flex-shrink: 0;
}

.fre-section-title {
  font-family: 'Oswald-SemiBold', 'Oswald', sans-serif;
  font-size: 6.5px;
  text-transform: none;
  color: #1a1a1a;
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.fre-zone-frame {
  height: 316px;
  border-radius: 3px;
  padding: 4px;
  position: relative;
  overflow: visible;
}
.fre-zone-frame.fre-frame-ok {
  border: 1px dashed #4CAF50;
}
.fre-zone-frame.fre-frame-overflow {
  border: 1px dashed #e53935;
}
.fre-zone-content {
  position: relative;
}

.fre-zone-status {
  font-family: 'Roboto', sans-serif;
  font-size: 0.75rem;
  margin-top: 4px;
  font-weight: 500;
}
.fre-zone-status.ok {
  color: #4CAF50;
}
.fre-zone-status.overflow {
  color: #e53935;
}

.fre-ai-reduce-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 10px 16px;
  font-family: 'Roboto', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: #7a6520;
  background: rgba(240, 200, 80, 0.25);
  border: 1px solid rgba(220, 180, 60, 0.35);
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.fre-ai-reduce-btn:hover {
  background: rgba(240, 200, 80, 0.4);
  border-color: rgba(220, 180, 60, 0.55);
}
.fre-ai-reduce-btn.fre-ai-reducing {
  opacity: 0.6;
  cursor: not-allowed;
}
.fre-ai-undo-btn {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 8px 16px;
  font-family: 'Roboto', sans-serif;
  font-size: 0.8rem;
  font-weight: 400;
  color: #666;
  background: transparent;
  border: 1px solid #ccc;
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.fre-ai-undo-btn:hover {
  background: #f5f5f5;
  color: #333;
}

.fre-ingredient-line, .fre-step-line {
  font-family: 'Roboto-Light', 'Roboto', sans-serif;
  font-size: 6.5px;
  color: #333;
  line-height: 1.36;
  text-align: justify;
}
.fre-empty-line {
  line-height: 1.36;
}

.fre-page-photo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}
.fre-modify-photo-btn {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-family: 'Roboto', sans-serif;
  font-size: 8px;
  font-weight: 500;
  padding: 4px 16px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  background: #efd6c4;
  color: #1a1a1a;
  letter-spacing: 0.3px;
  transition: background 0.15s;
}
.fre-modify-photo-btn:hover {
  background: #e5c8b0;
}

.fre-photo-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.fre-photo-img {
  object-fit: cover;
}
.fre-photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px dashed rgba(255,255,255,0.5);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-family: 'Roboto', sans-serif;
  font-size: 0.85rem;
}
.fre-photo-placeholder:hover {
  border-color: #fff;
  background: rgba(255,255,255,0.08);
}
.fre-photo-placeholder svg {
  opacity: 0.7;
}

.fre-personal-note {
  position: absolute;
  bottom: 10%;
  left: 9.5%;
  right: 9.5%;
  text-align: center;
  font-family: 'AuBordDeLaSeine', cursive;
  font-size: 8.7px;
  color: #333;
  line-height: 1.4;
}

.fre-panel {
  width: 380px;
  background: #fff;
  border-left: 1px solid #eee;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.fre-tabs {
  display: flex;
  border-bottom: 1px solid #eee;
}
.fre-tab {
  flex: 1;
  padding: 12px 8px;
  text-align: center;
  font-family: 'Oswald', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.5px;
  color: #999;
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.fre-tab.active {
  color: #1a1a1a;
  border-bottom-color: var(--primary);
}
.fre-tab:hover:not(.active) {
  color: #666;
}

.fre-panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.fre-field-group {
  margin-bottom: 18px;
}
.fre-field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.fre-field-label {
  font-family: 'Roboto', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  color: #1a1a1a;
}
.fre-field-counter {
  font-family: 'Roboto', sans-serif;
  font-size: 0.72rem;
}
.fre-field-counter.ok { color: #4CAF50; }
.fre-field-counter.max { color: #e53935; }

.fre-field-input, .fre-field-textarea {
  border: 1.5px solid #4CAF50;
}
.fre-field-input.overflow, .fre-field-textarea.overflow {
  border-color: #e53935 !important;
}

.fre-field-input {
  width: 100%;
  font-family: 'Roboto', sans-serif;
  font-size: 0.88rem;
  padding: 10px 12px;
  border: 1.5px solid #4CAF50;
  border-radius: 8px;
  background: #fafafa;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.fre-field-input:focus {
  background: #fff;
}
select.fre-category-select {
  cursor: pointer;
  appearance: auto;
  -webkit-appearance: menulist;
  -moz-appearance: menulist;
}

.fre-field-textarea {
  width: 100%;
  font-family: 'Roboto', sans-serif;
  font-size: 0.85rem;
  padding: 10px 12px;
  border: 1.5px solid #4CAF50;
  border-radius: 8px;
  background: #fafafa;
  outline: none;
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.fre-field-textarea:focus {
  background: #fff;
}

.fre-field-hint {
  font-family: 'Roboto', sans-serif;
  font-size: 0.72rem;
  color: #999;
  margin: 0 0 6px 0;
  font-style: italic;
}

.fre-time-row {
  display: flex;
  gap: 10px;
}
.fre-time-field {
  flex: 1;
}
.fre-time-input {
  width: 100%;
  font-family: 'Roboto', sans-serif;
  font-size: 0.88rem;
  padding: 8px 10px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  background: #fafafa;
  outline: none;
  text-align: center;
  box-sizing: border-box;
}
.fre-time-input:focus { border-color: var(--primary); }

.fre-color-row {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.fre-color-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fre-color-circle:hover { transform: scale(1.1); }
.fre-color-circle.selected {
  border-color: #1a1a1a;
}
.fre-color-circle .check-icon {
  color: #fff;
  font-size: 14px;
  font-weight: 400;
}

.fre-format-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.fre-format-btn {
  flex: 1;
  padding: 10px 12px;
  font-family: 'Roboto', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  background: #fafafa;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.fre-format-btn:hover { border-color: #999; }
.fre-format-btn.selected {
  border-color: var(--primary);
  background: #fff5f0;
  color: var(--primary);
}
.fre-format-icon {
  border: 1.5px solid #999;
  border-radius: 2px;
}
.fre-format-icon.portrait { width: 14px; height: 18px; }
.fre-format-icon.landscape { width: 18px; height: 14px; }
.fre-format-btn.selected .fre-format-icon {
  border-color: var(--primary);
}

.fre-font-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.fre-font-btn {
  flex: 1;
  padding: 10px 8px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  background: #fafafa;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.fre-font-btn:hover { border-color: #999; }
.fre-font-btn.selected {
  border-color: var(--primary);
  background: #fff5f0;
}
.fre-font-preview {
  font-size: 1.2rem;
  color: #1a1a1a;
  display: block;
  margin-bottom: 2px;
}
.fre-font-name {
  font-family: 'Roboto', sans-serif;
  font-size: 0.7rem;
  color: #999;
  display: block;
}
.fre-font-btn.selected .fre-font-name { color: var(--primary); }

.fre-photo-upload-area {
  margin-top: 4px;
  border: 2px dashed #ddd;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.fre-photo-upload-area:hover {
  border-color: var(--primary);
  background: #fff5f0;
}
.fre-photo-upload-text {
  font-family: 'Roboto', sans-serif;
  font-size: 0.85rem;
  color: #999;
}
.fre-photo-upload-area.has-photo {
  border-style: solid;
  border-color: #4CAF50;
  padding: 8px;
}
.fre-photo-upload-area.has-photo img {
  max-width: 100%;
  max-height: 120px;
  border-radius: 4px;
  object-fit: cover;
}
.fre-photo-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: center;
}
.fre-photo-action-btn {
  font-family: 'Roboto', sans-serif;
  font-size: 0.78rem;
  padding: 4px 12px;
  border-radius: 16px;
  border: 1px solid #ddd;
  background: #fff;
  cursor: pointer;
  color: #666;
  transition: all 0.15s;
}
.fre-photo-action-btn:hover { border-color: var(--primary); color: var(--primary); }
.fre-photo-action-btn.danger:hover { border-color: #e53935; color: #e53935; }

.fre-ai-generate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 10px;
  padding: 10px 16px;
  font-family: 'Roboto', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: #fff;
  background: linear-gradient(135deg, #839363, #6b7a50);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.fre-ai-generate-btn:hover {
  background: linear-gradient(135deg, #6b7a50, #5a6944);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(131, 147, 99, 0.35);
}
.fre-ai-generate-btn:disabled {
  cursor: not-allowed;
  opacity: 0.85;
  transform: none;
  box-shadow: none;
}
.fre-ai-generate-btn.loading {
  background: linear-gradient(135deg, #a0a0a0, #888);
}
.fre-ai-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: fre-spin 0.7s linear infinite;
  margin-right: 4px;
  flex-shrink: 0;
}
@keyframes fre-spin {
  to { transform: rotate(360deg); }
}
