/* One viewport budget, owned by the site header and shared by desktop/mobile/iframe. */
:root { --td-editor-header-height: 64px; }
.create-admin-editor-container { --td-editor-header-height: 0px; }
@media (max-width: 1180px) { :root { --td-editor-header-height: 58px; } }
:is(.create-editor-container, .create-admin-editor-container):has(.td-editor-shell, .td-mobile-editor-shell) {
  height: 100dvh; min-height: 0; overflow: clip;
}
#create-renewal-app:has(.td-editor-shell, .td-mobile-editor-shell),
#create-renewal-app .td-app:has(.td-editor-shell, .td-mobile-editor-shell) {
  display: block; height: calc(100dvh - var(--td-editor-header-height));
  min-height: 0; max-height: calc(100dvh - var(--td-editor-header-height));
  padding: 0; overflow: clip !important; box-sizing: border-box;
}
.td-editor-shell-body { overflow: clip; }
.td-left-panel-body, .td-left-panel-body * { box-sizing: border-box; min-width: 0; }
.td-left-panel-body { overflow-wrap: anywhere; }
.td-left-panel-body :is(input, select, textarea, .td-settings-panel, .td-settings-pane) { max-width: 100%; }
.td-left-panel-body .td-settings-pane { padding: 0; }
.td-left-panel-body .td-range-input { min-width: 0; }
.td-left-panel-body :is(.td-field, .td-inner-section, .td-settings-panel) { min-width: 0; }
.td-left-rail .td-shell-rail-divider { flex: 0 0 1px; align-self: stretch; height: 1px; margin: 6px 0; background: #dedade; }
.td-mobile-shell-nav .td-shell-rail-divider { flex: 0 0 1px; align-self: center; width: 1px; height: 32px; margin: 0 4px; }
.td-left-panel .td-fill-picker .td-swatches { grid-template-columns: repeat(auto-fill, 32px); gap: 6px; }
.td-left-panel .td-fill-picker .td-swatch,
.td-left-panel .td-fill-picker .td-color-plus-button { width: 32px; height: 32px; }
.td-left-panel-main { display: flex; flex: 1; flex-direction: column; min-height: 0; min-width: 0; }
.td-shell-text-input > .td-switch-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; margin: 0; }
/* Desktop shell. */
@media (min-width: 1181px) {
  .td-app:has(.td-editor-shell) { padding: 0; }
  .td-editor-shell {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    box-sizing: border-box;
    height: 100%;
    overflow: clip;
    min-height: 0;
    background: #fff;
  }
  .td-editor-shell-body {
    position: relative;
    --td-left-panel-width: 360px;
    display: grid;
    grid-template-columns: 80px 0 minmax(0, 1fr) var(--td-layer-width, 280px);
    min-width: 0;
    min-height: 0;
    transition: grid-template-columns 260ms cubic-bezier(.2, .72, .25, 1);
  }
  .td-editor-shell.has-left-panel .td-editor-shell-body { grid-template-columns: 80px var(--td-left-panel-width) minmax(0, 1fr) var(--td-layer-width, 280px); }
  .td-left-rail { grid-column: 1; min-height: 0; overflow-y: auto; overflow-x: clip; display: flex; flex-direction: column; gap: 4px; align-items: center; padding: 12px 7px; background: #fff; border-right: 1px solid #dedade; }
  .td-left-rail .td-shell-button { flex-direction: column; width: 65px; height: 65px; min-height: 65px; padding: 8px 4px; font-size: 12px; font-weight: 900; }
  .td-left-rail svg { width: 22px; height: 22px; }
  .td-left-panel { position: relative; z-index: 92; grid-column: 2; display: flex; flex-direction: column; min-height: 0; min-width: 0; border-right: 1px solid #dedade; }
  .td-editor-shell.has-toolbar-panel-overlay:not(.has-toolbar-panel-needs-space) .td-left-panel {
    position: absolute; z-index: 92; top: 56px; bottom: 0; left: 0;
    width: var(--td-left-panel-width); border-right: 1px solid #dedade;
    background: #fff; box-shadow: 4px 0 18px #241f2026;
  }
  .td-left-panel-detail-overlay { position: absolute; z-index: 4; inset: 0; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #fff; box-shadow: 4px 0 18px #241f2026; }
  .td-shell-panel-collapse { position: absolute; z-index: 5; right: -14px; top: 50%; display: grid; place-items: center; width: 28px; height: 48px; padding: 0; transform: translateY(-50%); border: 1px solid #dedade; border-radius: 0 8px 8px 0; background: #fff; color: #655d62; cursor: pointer; box-shadow: 1px 1px 4px #00000014; }
  .td-shell-panel-collapse svg { width: 18px; height: 18px; transform: rotate(180deg); }
  .td-shell-panel-collapse:hover, .td-shell-panel-collapse:focus-visible { color: #b53970; border-color: #b53970; outline: none; }
  .td-left-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 52px; flex: none; box-sizing: border-box; padding: 8px 12px; border-bottom: 1px solid #e7e0e3; font-size: 15px; font-weight: 900; color: #241f20; }
  .td-left-panel-header .td-shell-button { width: 36px; height: 36px; }
  .td-left-panel-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior-y: contain; touch-action: pan-y; padding: 12px; scrollbar-gutter: stable both-edges; }
  .td-left-panel .td-settings-panel { border: 0; padding: 0; }
  .td-left-panel .td-settings-pane { padding: 0; }
  .td-left-panel .td-palette-groups .td-swatches { grid-template-columns: repeat(auto-fill, 32px); gap: 8px; }
  .td-left-panel .td-stamp-picker { height: 100%; max-height: none; min-height: 0; margin: 0; border: 0; padding: 0; overflow-y: auto; }
  .td-left-panel .create-desktop-sidebar { height: auto; grid-template-rows: auto minmax(0, 1fr); }
  .td-shell-text-input, .td-shell-text-input form, .td-shell-upload { display: grid; gap: 12px; }
  .td-shell-text-input textarea { width: 100%; min-height: 120px; resize: vertical; padding: 10px; border: 1px solid #c9c3c7; border-radius: 6px; }
  .td-shell-upload p { font-size: 12px; line-height: 1.7; color: #655d62; }
  .td-editor-shell .td-preview-column { grid-column: 3; min-width: 0; min-height: 0; height: 100%; box-sizing: border-box; overflow: clip; padding: 0; background: #f3f3f4; display: flex; flex-direction: column; }
  .td-editor-shell .td-context-toolbar { flex: 0 0 56px; background: #fff; }
  .td-editor-shell .td-preview-panel { background: #f3f3f4; min-width: 0; padding: 0; border-radius: 0; flex: 1 1 0; }
  .td-editor-shell .td-preview-stage-wrap { margin: 0; }
  .td-layer-column { grid-column: 4; min-width: 0; min-height: 0; overflow-y: auto; overflow-x: hidden; border-left: 1px solid #dedade; padding: 0; background: #fff; }
  .td-layer-column { display: grid; grid-template-rows: minmax(0, 1fr); overflow: hidden; }
  .td-layer-column > .td-layer-reopen, .td-layer-column > .td-layer-expanded {
    grid-area: 1 / 1; min-width: 0; min-height: 0;
    transition: opacity 180ms ease, transform 240ms cubic-bezier(.2, .8, .2, 1), visibility 0s;
  }
  .td-layer-column > .td-layer-reopen { align-self: start; }
  .td-layer-column > .td-layer-expanded { overflow: auto; }
  .td-layer-column.is-collapsed > .td-layer-expanded,
  .td-layer-column:not(.is-collapsed) > .td-layer-reopen {
    opacity: 0; transform: translateX(8px); visibility: hidden; pointer-events: none;
    transition: opacity 160ms ease, transform 200ms cubic-bezier(.2, .8, .2, 1), visibility 0s linear 200ms;
  }
  .td-layer-column.is-collapsed > .td-layer-reopen,
  .td-layer-column:not(.is-collapsed) > .td-layer-expanded {
    opacity: 1; transform: translateX(0); visibility: visible; pointer-events: auto;
  }
  /* Frameless list that uses the full column width; the heading matches the left panel heading. */
  .td-layer-column .td-layer-panel { padding: 0; }
  .td-layer-column .td-layer-panel-inner { border: 0; border-radius: 0; background: transparent; padding: 0; }
  .td-layer-column .td-layer-panel-header { height: 52px; margin: 0; padding: 8px 8px 8px 12px; box-sizing: border-box; border-bottom: 1px solid #e7e0e3; font-size: 15px; font-weight: 900; color: #241f20; }
  .td-layer-column .td-layer-list { padding: 8px; gap: 6px; }
  /* Desktop reorders by dragging, so the step arrows are not needed. */
  .td-layer-column .td-layer-move-controls { display: none; }
  /* The host template previously reserved a separate portal/sidebar column. */
  :is(.create-editor-container, .create-admin-editor-container) .create-editor-main:has(.td-editor-shell) { grid-template-columns: minmax(0, 1fr); }
  .create-admin-editor-container .td-editor-shell .td-preview-column { padding: 0 !important; background: #f3f3f4 !important; }
  .create-admin-editor-container .td-editor-shell .td-preview-panel { background: #f3f3f4 !important; }
  .td-editor-shell-body:has(.td-layer-column.is-collapsed) { --td-layer-width: 48px; }
  .td-layer-column.is-collapsed { padding: 8px 4px; }
  .td-layer-column .td-layer-list { grid-template-columns: minmax(0, 1fr); }
  .td-layer-column .td-layer-row.is-child { width: calc(100% - 28px); }
  .td-layer-column .td-layer-row { width: 100%; display: flex; gap: 4px; position: relative; }
  .td-layer-column .td-layer-grip { flex: 0 0 16px; }
  .td-layer-column .td-layer-name { display: flex; flex: 1; min-width: 0; gap: 6px; }
  .td-layer-column .td-layer-type, .td-layer-column .td-layer-media, .td-layer-column .td-layer-thumb { flex: none; }
  .td-layer-column .td-layer-label { display: block; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .td-left-panel .td-font-picker-field.is-inline .td-font-menu { position: static; margin: 0; padding: 0; border: 0; box-shadow: none; }
  .td-left-panel .td-font-picker-field.is-inline .td-font-menu-list { max-height: none; overflow: visible; }
  .td-left-panel .td-stamp-row-scroll { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); overflow-x: hidden; }
  .td-left-panel .td-stamp-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); min-width: 0; }
  .td-left-panel .td-stamp-grid > * { min-width: 0; max-width: 100%; }
}

/* Keep the preview inside its grid row even when host styles reserve a full-height stage. */
.td-editor-shell .td-preview-column .td-preview-panel {
  display: flex; flex-direction: column; height: 100%; min-height: 0; max-height: 100%; box-sizing: border-box; overflow: clip;
}
.td-editor-shell .td-preview-panel .td-preview-stage-wrap {
  flex: 1 1 0; height: auto !important; min-height: 0 !important; overflow: clip;
}
.td-editor-shell .td-preview-panel .td-preview-stage { max-height: 100%; box-sizing: border-box; }
.td-app.is-paywall-locked .td-editor-shell .td-preview-column { min-height: 0; overflow-y: auto; }
.td-app.is-paywall-locked .td-editor-shell .td-preview-panel { height: auto; max-height: none; overflow: visible; }

@keyframes td-shell-panel-enter {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes td-shell-toolbar-enter {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}
.td-editor-shell .td-left-panel-main,
.td-editor-shell .td-left-panel-detail-overlay { animation: td-shell-panel-enter 210ms cubic-bezier(.2, .8, .2, 1) both; }
.td-editor-shell .td-context-toolbar { animation: td-shell-toolbar-enter 170ms ease-out both; }
@media (prefers-reduced-motion: reduce) {
  .td-editor-shell-body,
  .td-editor-shell .td-left-panel-main,
  .td-editor-shell .td-left-panel-detail-overlay,
  .td-editor-shell .td-context-toolbar,
  .td-layer-column > .td-layer-reopen,
  .td-layer-column > .td-layer-expanded,
  .td-mobile-editor-shell .td-mobile-shell-sheet { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
