#editor-page {
  display: flex;
  flex: 1;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  transition: transform 420ms cubic-bezier(0.22, 0.68, 0, 1);
}

#preview-page {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: #fff;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 420ms cubic-bezier(0.22, 0.68, 0, 1), visibility 0s 420ms;
  color: #343a40;
  font-size: 13px;
}

body.preview-open #editor-page { transform: translateX(-100%); }
body.preview-open #preview-page { transform: translateX(0); visibility: visible; transition-delay: 0s; }
#preview-page [hidden] { display: none !important; }
#preview-page button { font: inherit; cursor: pointer; }
#preview-page button:disabled { cursor: not-allowed; opacity: 0.5; }
#preview-page button:focus-visible, #preview-viewport:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }
#preview-page img { display: block; width: 19px; height: 19px; flex-shrink: 0; }

.preview-header {
  display: flex;
  align-items: center;
  gap: 24px;
  height: var(--preview-header-height, 72px);
  min-height: var(--preview-header-height, 72px);
  flex-shrink: 0;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-color);
  background: #fff;
}
#top-bar #generate-btn,
.preview-back { display: flex; flex-shrink: 0; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--border-color); border-radius: 5px; color: #41484e; background: #fff; font-size: 13px; font-weight: 400; white-space: nowrap; }
#top-bar #generate-btn:hover,
.preview-back:hover { background: #f5f6f7; border-color: #adb5bd; transform: none; }
#top-bar #generate-btn { border-color: #ef941a; background: var(--orange); color: #382608; font-weight: 500; }
#top-bar #generate-btn:hover { border-color: #e58a13; background: #f5a433; }
#top-bar #generate-btn:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }
#generate-btn img { display: block; flex-shrink: 0; width: 19px; height: 19px; transform: rotate(180deg); }
.preview-brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; }
#preview-page .preview-brand img { width: 30px; height: 30px; }
.preview-status-dot { display: inline-block; flex-shrink: 0; width: 6px; height: 6px; border-radius: 50%; background: #39866e; }
#preview-page[data-state="loading"] .preview-status-dot,
#preview-page[data-state="encoding"] .preview-status-dot { background: var(--orange); }
#preview-page[data-state="error"] .preview-status-dot { background: #c95353; }

.preview-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px minmax(0, 1fr); }
.export-panel { display: flex; flex-direction: column; gap: 26px; padding: 28px 24px 24px; border-right: 1px solid var(--border-color); overflow-y: auto; scrollbar-width: thin; }
.export-panel > * { flex-shrink: 0; }
.preview-eyebrow { color: #8a9299; font-size: 10px; font-weight: 600; }
.export-panel-heading h1 { margin-top: 4px; font-size: 22px; line-height: 1.4; font-weight: 600; }
.export-field label, .export-dimensions legend, .export-summary h2 { display: block; margin-bottom: 10px; color: #59616a; font-size: 12px; font-weight: 500; }
.export-filename { display: flex; align-items: center; border: 1px solid #d7dce0; border-radius: 5px; min-width: 0; background: #fafbfc; }
.export-filename:focus-within { border-color: var(--orange); box-shadow: 0 0 0 2px #f8991e18; }
#filename-input { flex: 1; width: 100%; min-width: 0; padding: 10px; border: 0; outline: none; background: transparent; font-size: 12px; color: #343a40; }
.export-filename > span { padding: 0 10px 0 2px; font-size: 11px; color: #8a9299; }
.export-dimensions { min-width: 0; border: 0; }
.export-mode-list { display: flex; flex-direction: column; gap: 6px; }
.export-mode-option { display: flex; align-items: center; gap: 9px; min-height: 44px; padding: 10px; border: 1px solid #e1e5e8; border-radius: 5px; background: #fff; color: #59616a; text-align: left; }
#preview-page .export-mode-option img { width: 17px; height: 17px; opacity: 0.65; }
.export-mode-option > span:nth-child(2) { flex: 1; }
.export-mode-option small { color: #8a9299; font-size: 10px; white-space: nowrap; }
.export-mode-option:hover { background: #fafbfc; }
.export-mode-option.selected { border-color: #efbd7d; background: #fff6e9; color: #704307; }
.export-mode-mark { flex: 0 0 12px; width: 12px; height: 12px; border: 1px solid #c8ced3; border-radius: 50%; }
.selected .export-mode-mark { border: 4px solid var(--orange); }
.export-size-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-top: 12px; }
.export-size-fields > label { min-width: 0; color: #59616a; font-size: 11px; }
.export-size-input { display: flex; align-items: center; gap: 4px; margin-top: 5px; padding: 8px; border: 1px solid #d7dce0; border-radius: 4px; background: #fafbfc; }
.export-size-input:focus-within { outline: 2px solid var(--orange); outline-offset: -1px; }
.export-size-input input { width: 100%; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent; color: #343a40; font-size: 12px; }
.export-size-input span { color: #8a9299; font-size: 10px; }
#export-size-error { margin-top: 8px; color: #c95353; font-size: 11px; }
.export-summary { padding-top: 22px; border-top: 1px solid #e9ecef; }
.export-summary dl { display: flex; flex-direction: column; gap: 11px; font-size: 12px; }
.export-summary dl > div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.export-summary dt { color: #848c94; }
.export-summary dd { color: #444c54; font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; }
.export-file-info { display: flex; align-items: center; gap: 12px; margin-top: auto; padding-top: 22px; border-top: 1px solid #e9ecef; }
.export-file-badge { display: grid; place-items: center; width: 38px; height: 44px; border: 1px solid #dce7e2; border-radius: 4px; background: #f0f7f3; color: #3b7560; font-size: 10px; font-weight: 600; }
.export-file-info > div { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.export-file-info strong { color: #59616a; font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
.export-file-info span:not(.export-file-badge) { color: #8a9299; font-size: 11px; }
.export-actions { position: sticky; bottom: -24px; z-index: 2; display: grid; gap: 8px; padding: 12px 0 24px; margin-bottom: -24px; background: #fff; }
.preview-primary, .preview-secondary { display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 42px; padding: 10px 12px; border-radius: 5px; font-weight: 500 !important; }
.preview-primary { border: 1px solid #ef941a; background: var(--orange); color: #382608; }
.preview-primary:hover:not(:disabled) { background: #f5a433; }
.preview-secondary { border: 1px solid #dce1e5; background: #fff; color: #59616a; }
.preview-secondary:hover:not(:disabled) { background: #f5f6f7; }
#preview-page .preview-secondary:disabled { opacity: 0.7; }
.preview-secondary small { margin-left: auto; padding: 2px 5px; border-radius: 3px; background: #f0f2f4; color: #8a9299; font-size: 9px; }
#preview-page .preview-secondary img { opacity: 0.6; }

.preview-workspace { position: relative; display: grid; grid-template-rows: 56px minmax(0, 1fr) 30px; min-width: 0; min-height: 0; overflow: hidden; background: #edf0f2; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 20px; border-bottom: 1px solid #dce1e5; background: #fafbfc; z-index: 2; }
.preview-document { display: flex; min-width: 0; align-items: center; gap: 8px; color: #7e8790; font-size: 11px; }
.preview-document span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#preview-page .preview-document img { width: 15px; height: 15px; opacity: 0.45; }
.preview-tools { display: flex; flex-shrink: 0; align-items: center; gap: 3px; }
.preview-tool { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid transparent; border-radius: 4px; background: transparent; }
.preview-tool:hover:not(:disabled), .preview-tool.active { border-color: #dce1e5; background: #fff; }
#preview-page .preview-tool img { width: 17px; height: 17px; opacity: 0.6; }
.preview-tool-divider { width: 1px; height: 20px; margin: 0 6px; background: #dce1e5; }
.preview-zoom-field { display: flex; align-items: center; justify-content: center; width: 66px; height: 30px; border: 1px solid #dce1e5; border-radius: 4px; background: #fff; color: #848c94; font-size: 11px; }
#preview-zoom { width: 38px; min-width: 0; padding: 0; border: 0; outline: none; color: #59616a; background: transparent; font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; appearance: textfield; }
#preview-zoom::-webkit-inner-spin-button, #preview-zoom::-webkit-outer-spin-button { appearance: none; margin: 0; }
.preview-zoom-field:focus-within { outline: 2px solid var(--orange); }
#preview-viewport { overflow: auto; min-width: 0; min-height: 0; overscroll-behavior: contain; scrollbar-color: #bdc6ce #e7ebee; scrollbar-width: thin; background-image: linear-gradient(#dce1e560 1px, transparent 1px), linear-gradient(90deg, #dce1e560 1px, transparent 1px); background-size: 24px 24px; cursor: grab; }
#preview-viewport.is-panning { cursor: grabbing; user-select: none; }
#preview-stage { position: relative; display: grid; place-items: center; min-width: 100%; min-height: 100%; }
#preview-paper { flex-shrink: 0; background: white; outline: 1px solid #dfe3e6; box-shadow: 0 8px 36px #29343e14, 0 1px 3px #29343e0d; }
#preview-canvas { display: block; width: 100%; height: 100%; }
.preview-statusbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 20px; border-top: 1px solid #dce1e5; background: #fafbfc; color: #8a9299; font-size: 10px; }
.preview-statusbar > span:first-child { display: flex; align-items: center; gap: 7px; }
#preview-state { position: absolute; inset: 56px 0 30px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 28px; background: #edf0f2; text-align: center; }
#preview-state-icon { width: 28px !important; height: 28px !important; opacity: 0.55; }
#preview-state.is-loading #preview-state-icon { animation: preview-spin 1.2s linear infinite; }
#preview-state strong { font-weight: 500; }
#preview-state p { max-width: 340px; color: #7e8790; font-size: 12px; }
#preview-state p:empty { display: none; }
@keyframes preview-spin { to { transform: rotate(360deg); } }

@media (max-width: 1000px) {
  .preview-layout { grid-template-columns: 260px minmax(0, 1fr); }
  .export-panel { padding: 24px 18px 18px; gap: 22px; }
  .preview-document { display: none; }
  .preview-toolbar { justify-content: flex-end; padding: 8px 12px; }
}
@media (max-width: 640px) {
  .preview-header { gap: 14px; padding: 10px 14px; }
  .preview-back { padding: 8px; }
  .preview-brand { font-size: 13px; gap: 8px; }
  #preview-page .preview-brand img { width: 24px; height: 24px; }
  .preview-layout { display: flex; flex-direction: column; }
  .preview-workspace { order: 0; flex: 1; min-height: 220px; }
  .export-panel { order: 1; flex: 0 1 auto; max-height: 43dvh; gap: 18px; padding: 16px; border-right: 0; border-top: 1px solid #dce1e5; }
  .export-panel-heading { display: none; }
  .export-mode-list { flex-direction: row; gap: 5px; }
  .export-mode-option { flex: 1; min-width: 0; flex-direction: column; gap: 6px; padding: 8px 3px; font-size: 10px !important; text-align: center; }
  .export-mode-option small, .export-mode-mark { display: none; }
  .export-field label, .export-dimensions legend { margin-bottom: 6px; }
  .export-summary { padding-top: 16px; }
  .export-actions { position: sticky; bottom: -16px; padding: 10px 0 16px; margin-bottom: -16px; grid-template-columns: 1fr 1fr; background: #fff; z-index: 2; }
  .preview-secondary small { font-size: 8px; }
  .preview-toolbar { justify-content: center; }
  .preview-statusbar { padding: 0 12px; font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  #editor-page, #preview-page { transition: none; }
  #preview-state.is-loading #preview-state-icon { animation: none; }
}
