:root {
  --app-bg: #f3f3f7;
  --app-bg-strong: #ececf2;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --line: #d9dbe7;
  --line-strong: #c8cbda;
  --text: #202330;
  --muted: #73788c;
  --accent: #865dff;
  --accent-soft: rgba(134, 93, 255, 0.14);
  --accent-strong: #6f46ea;
  --shadow: 0 22px 50px rgba(75, 82, 110, 0.14);
  --shadow-soft: 0 10px 24px rgba(75, 82, 110, 0.1);
  --canvas-shadow: 0 34px 70px rgba(24, 25, 33, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  background:
    radial-gradient(circle at top right, rgba(134, 93, 255, 0.08), transparent 24%),
    linear-gradient(180deg, #f7f7fb 0%, #f0f1f6 100%);
  color: var(--text);
  font-family: "Jost", "Avenir Next", "Segoe UI", sans-serif;
}

body {
  overflow: hidden;
}

body.has-dialog-open {
  overflow: hidden;
}

body.has-mobile-layout-modal-open {
  overflow: hidden;
}

html.server-render-mode,
body.server-render-mode {
  overflow: auto;
  background: #ffffff;
}

body.server-render-mode .mobile-editor-notice,
body.server-render-mode .sidebar-panel,
body.server-render-mode .workspace-meta,
body.server-render-mode .floating-toolbar,
body.server-render-mode .layout-stack {
  display: none !important;
}

body.server-render-mode .app-shell {
  display: block;
  height: auto;
  min-height: 1200px;
  padding: 0;
}

body.server-render-mode .studio-shell,
body.server-render-mode .workspace-panel,
body.server-render-mode .workspace-stage,
body.server-render-mode .print-stage {
  display: block;
  height: auto;
  min-height: 0;
  gap: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

body.server-render-mode .print-canvas {
  width: 1800px;
  max-width: none;
  max-height: none;
  aspect-ratio: 3 / 2;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

a {
  color: inherit;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

code {
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
  font-size: 0.9em;
}

.app-shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  padding: 8px 14px 12px;
}

.mobile-editor-notice {
  display: none;
}

.mobile-layout-modal {
  display: none;
}

.ruler-shell {
  display: none !important;
}

.ruler-gutter {
  min-height: 26px;
}

.ruler-track {
  display: grid;
  grid-template-columns: repeat(19, minmax(0, 1fr));
  min-height: 26px;
  border: 1px solid rgba(201, 204, 218, 0.9);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.ruler-mark {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 4px 0 0 5px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
}

.ruler-mark::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 1px;
  height: 8px;
  background: rgba(140, 145, 165, 0.7);
}

.studio-shell {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  height: 100%;
  min-height: 0;
}

.sidebar-panel,
.workspace-stage {
  border: 1px solid rgba(205, 208, 220, 0.92);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sidebar-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  max-height: none;
  padding: 12px;
  border-radius: 24px;
  overflow: hidden;
}

.sidebar-header,
.workspace-meta,
.library-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-kicker,
.section-label {
  margin: 0;
  color: var(--accent-strong);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sidebar-header h1,
.workspace-meta h2 {
  margin: 2px 0 0;
  line-height: 1;
}

.sidebar-header h1 {
  font-size: 1.2rem;
}

.workspace-meta {
  align-items: flex-start;
  margin-bottom: 4px;
}

.workspace-meta .panel-kicker {
  display: none;
}

.workspace-meta h2 {
  font-size: clamp(0.92rem, 1.2vw, 1.25rem);
}

.workspace-hint {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.25;
}

.meta-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.meta-pill,
.library-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(134, 93, 255, 0.1);
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 700;
}

.icon-button,
.pill-button,
.segment-button,
.toolbar-layer,
.format-button,
.toolbar-action,
.step-button,
.layout-card {
  border: 1px solid transparent;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease, background 150ms ease;
}

.icon-button:hover,
.pill-button:hover,
.segment-button:hover,
.toolbar-layer:hover,
.format-button:hover,
.toolbar-action:hover,
.step-button:hover,
.layout-card:hover {
  transform: translateY(-1px);
}
.section-note,
.strip-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.control-stack {
  display: grid;
  gap: 12px;
  min-height: 0;
  height: 100%;
}

.sidebar-layout-controls {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.sidebar-gallery-block {
  min-height: 0;
  align-content: start;
}

.sidebar-gallery-block .gallery-grid {
  align-content: start;
  height: 100%;
}

.section-block {
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid #ececf3;
}

.section-block:first-child {
  padding-top: 0;
  border-top: 0;
}

.pill-group,
.segment-control {
  display: grid;
  gap: 10px;
}

.pill-group {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segment-control {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pill-button,
.segment-button,
.primary-button {
  min-height: 40px;
  border-radius: 14px;
  font-size: 0.88rem;
  font-weight: 700;
}

.pill-button,
.segment-button {
  background: #f5f6fb;
  border-color: #e4e6ef;
  color: var(--muted);
}

.pill-button.is-active,
.segment-button.is-active,
.toolbar-layer.is-active,
.format-button.is-active {
  background: rgba(134, 93, 255, 0.14);
  border-color: rgba(134, 93, 255, 0.24);
  color: var(--accent-strong);
}

.primary-button {
  border: 0;
  color: #ffffff;
  background: linear-gradient(135deg, #8a63ff, #6b52e5);
  box-shadow: 0 16px 30px rgba(111, 70, 234, 0.24);
}

.field,
.range-field {
  display: grid;
  gap: 8px;
}

.field span,
.range-field span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
}

.field input[type="text"],
.field input[type="search"],
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  background: #ffffff;
  color: var(--text);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

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

.field input:focus,
.field textarea:focus,
.field input[type="search"]:focus {
  border-color: rgba(134, 93, 255, 0.32);
  box-shadow: 0 0 0 4px rgba(134, 93, 255, 0.12);
}

.range-field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.workspace-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 6px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.floating-toolbar {
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 100%;
  justify-content: flex-start;
  max-width: 100%;
  margin: 0;
  padding: 4px 5px;
  overflow: visible;
  border: 1px solid rgba(202, 205, 218, 0.96);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.toolbar-row.toolbar-row-controls {
  overflow: visible;
}

.toolbar-group {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
  flex: 0 0 auto;
  gap: 5px;
  padding-right: 6px;
  border-right: 1px solid #ececf4;
}

.toolbar-group:last-child {
  padding-right: 0;
  border-right: 0;
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  z-index: 40;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(17, 19, 26, 0.94);
  color: #ffffff;
  font-size: 0.67rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -4px);
  transition: opacity 140ms ease, transform 140ms ease;
  box-shadow: 0 10px 24px rgba(8, 11, 19, 0.18);
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toolbar-tooltip-anchor {
  position: relative;
  display: inline-flex;
}

.toolbar-layer,
.format-button,
.step-button,
.toolbar-action {
  min-height: 27px;
  padding: 0 9px;
  border-radius: 10px;
  background: #f4f5fa;
  border-color: #e6e7f0;
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 700;
}

.toolbar-layer-group {
  flex-wrap: nowrap;
}

.toolbar-visibility-group {
  flex-wrap: nowrap;
}

.line-add-group {
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
}

.line-toggle-button.is-add {
  background: #ffffff;
  border-style: dashed;
}

.line-toggle-button.is-remove {
  background: rgba(255, 235, 240, 0.92);
  border-color: rgba(224, 127, 155, 0.34);
  color: #a83f60;
}

.line-toggle-button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

.toolbar-typography select,
.size-stepper {
  height: 27px;
}

.toolbar-typography select,
.size-stepper input {
  border: 1px solid #dde0ea;
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
}

.toolbar-typography select {
  min-width: 128px;
  max-width: 154px;
  padding: 0 8px;
  outline: none;
  font-size: 0.82rem;
  font-weight: 600;
}

.toolbar-row-controls .toolbar-group:last-child {
  border-right: 0;
  padding-right: 0;
}

.toolbar-typography select option {
  font-size: 0.94rem;
}

.font-select-popover {
  position: relative;
}

.font-select-trigger {
  display: inline-flex;
  align-items: center;
  min-width: 186px;
  max-width: 210px;
  height: 27px;
  padding: 0 10px;
  border: 1px solid #dde0ea;
  border-radius: 10px;
  background: #ffffff;
  color: #1a1d27;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.font-select-trigger::after {
  content: "▾";
  margin-left: 8px;
  color: #6f7488;
  font-size: 0.72rem;
}

.font-select-trigger:disabled {
  opacity: 0.55;
}

.font-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: min(340px, 72vw);
  max-height: min(56vh, 420px);
  overflow: auto;
  padding: 8px;
  border: 1px solid rgba(193, 197, 213, 0.94);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 22px 40px rgba(45, 53, 86, 0.2);
  z-index: 50;
}

.font-select-group {
  display: grid;
  gap: 4px;
}

.font-select-group + .font-select-group {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(220, 224, 236, 0.88);
}

.font-select-group-label {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #7d8398;
  padding: 2px 6px;
}

.font-select-option {
  display: block;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  padding: 6px 8px;
  font-size: 0.95rem;
  font-weight: 400;
  color: #1b1f2c;
}

.font-select-option:hover {
  background: rgba(134, 93, 255, 0.08);
}

.font-select-option.is-active {
  border-color: rgba(134, 93, 255, 0.3);
  background: rgba(134, 93, 255, 0.14);
}

.font-preview-chip {
  display: inline-flex;
  align-items: center;
  min-width: 122px;
  max-width: 168px;
  height: 27px;
  padding: 0 10px;
  overflow: hidden;
  border: 1px solid #dde0ea;
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.font-preview-chip.is-disabled {
  opacity: 0.55;
}

.size-stepper {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid #dde0ea;
}

.size-stepper input {
  width: 46px;
  height: 100%;
  border: 0;
  padding: 0 4px;
  text-align: center;
  outline: none;
}

.size-stepper input::-webkit-outer-spin-button,
.size-stepper input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.step-button {
  min-width: 26px;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: #ffffff;
}

.color-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 27px;
  height: 27px;
  padding: 2px;
  border: 1px solid #e6e7f0;
  border-radius: 10px;
  background: #ffffff;
}

.color-button input[type="color"] {
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  background: transparent;
}

.history-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 31px;
  padding: 0;
  background: #ffffff;
  border: 1px solid #e6e7f0;
  color: var(--accent-strong);
  line-height: 0;
}

.history-button:hover {
  background: rgba(134, 93, 255, 0.08);
  border-color: rgba(134, 93, 255, 0.18);
}

.history-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.history-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.history-button:disabled .history-icon {
  stroke: #b8bfd0;
}

.workspace-stage {
  display: grid;
  min-height: 0;
  height: 100%;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(241, 242, 248, 0.96)),
    radial-gradient(circle at top left, rgba(134, 93, 255, 0.08), transparent 24%);
  overflow: hidden;
}

.print-stage {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 18px;
  min-height: 0;
  height: 100%;
  padding: 11px 10px 8px;
}

.layout-stack {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 12px;
  flex: 0 0 auto;
  width: 188px;
  min-height: 0;
  height: 100%;
}

.layout-image-tools {
  display: grid;
  gap: 8px;
}

.layout-shipping-tools {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.layout-submit-wrap {
  position: relative;
}

.layout-submit-hint {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  min-width: 176px;
  max-width: 220px;
  padding: 7px 9px;
  border-radius: 10px;
  border: 1px solid rgba(193, 197, 213, 0.95);
  background: rgba(255, 255, 255, 0.98);
  color: #4d5369;
  font-size: 0.67rem;
  line-height: 1.28;
  text-align: center;
  box-shadow: 0 10px 24px rgba(33, 39, 58, 0.14);
  pointer-events: none;
  opacity: 0;
  transition: opacity 140ms ease, transform 140ms ease;
  z-index: 10;
}

.layout-submit-hint.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(-1px);
}

.layout-stack-submit-action,
.layout-stack-add-action {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(193, 197, 213, 0.92);
  border-radius: 16px;
  font-size: 0.84rem;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
}

.layout-image-files {
  display: grid;
  gap: 6px;
}

.layout-image-file {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 4px;
  border: 1px solid rgba(193, 197, 213, 0.92);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
}

.layout-image-file.is-active {
  border-color: rgba(134, 93, 255, 0.52);
  background: rgba(134, 93, 255, 0.08);
}

.layout-image-file-thumb {
  width: 52px;
  height: 34px;
  border-radius: 7px;
  object-fit: cover;
  border: 1px solid rgba(203, 206, 219, 0.95);
  background: #f2f3f8;
}

.layout-image-file-name {
  color: #262b38;
  font-size: 0.66rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.layout-image-file-select,
.layout-image-file-remove,
.layout-image-file-rotate {
  min-height: 22px;
  border: 1px solid rgba(198, 202, 216, 0.96);
  border-radius: 8px;
  background: #ffffff;
  font-size: 0.64rem;
  font-weight: 700;
  padding: 0 7px;
}

.layout-image-file-remove {
  color: #8e314f;
}

.layout-image-file-actions {
  display: grid;
  gap: 4px;
}

.layout-image-file-rotate {
  color: #3c4460;
}

.layout-image-files-empty {
  border: 1px dashed rgba(198, 202, 216, 0.96);
  border-radius: 10px;
  padding: 8px;
  color: #848aa0;
  font-size: 0.66rem;
  line-height: 1.25;
  text-align: center;
}

.layout-stack-submit-action {
  background: linear-gradient(135deg, #8a63ff, #6b52e5);
  border-color: rgba(111, 70, 234, 0.32);
  color: #ffffff;
}

.layout-stack-add-action {
  background: linear-gradient(180deg, #ffffff, #f0f2f7);
  color: #1a1d27;
}

.layout-stack-submit-action:disabled,
.layout-stack-add-action:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.layout-stack-list {
  display: grid;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
  padding-right: 2px;
}

.layout-stack-empty {
  padding: 16px 14px;
  border: 1px dashed rgba(193, 197, 213, 0.92);
  border-radius: 18px;
  background: rgba(250, 250, 253, 0.88);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  text-align: center;
}

.layout-stack-item {
  position: relative;
}

.layout-stack-preview {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "thumb thumb"
    "index meta";
  align-items: end;
  gap: 9px;
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(193, 197, 213, 0.92);
  border-radius: 22px;
  background: rgba(250, 250, 253, 0.96);
  box-shadow: var(--shadow-soft);
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease, background 150ms ease;
}

.layout-stack-preview:hover {
  transform: translateY(-1px);
  border-color: rgba(142, 148, 175, 0.9);
  box-shadow: 0 18px 30px rgba(75, 82, 110, 0.14);
}

.layout-stack-item.is-current .layout-stack-preview {
  border-width: 2px;
  border-color: #8d93a8;
  background: #ffffff;
}

.layout-stack-thumb-frame {
  grid-area: thumb;
  display: block;
  overflow: hidden;
  border-radius: 14px;
  background: #f6f6f9;
  box-shadow: inset 0 0 0 1px rgba(205, 208, 220, 0.96);
}

.layout-stack-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: contain;
  object-position: center;
}

.layout-stack-thumb-live {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  pointer-events: none;
}

.layout-stack-thumb-mirror-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.layout-stack-thumb-mirror-canvas {
  box-shadow: none;
  pointer-events: none;
}

.layout-stack-thumb-mirror-canvas .selection-frame {
  display: none !important;
}

.layout-stack-index {
  grid-area: index;
  color: #111317;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  align-self: end;
  justify-self: start;
  min-width: 1ch;
  margin-left: 2px;
}

.layout-stack-meta {
  grid-area: meta;
  display: grid;
  gap: 2px;
  text-align: left;
  align-self: end;
  justify-self: start;
  min-width: 0;
  margin-left: 8px;
}

.layout-stack-name {
  color: #181b23;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.25;
}

.layout-stack-note {
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.25;
}

.layout-stack-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(193, 197, 213, 0.92);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #8e314f;
  font-size: 1.1rem;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(75, 82, 110, 0.12);
}

.layout-stack-delete:hover {
  background: #fff3f6;
  border-color: rgba(210, 101, 134, 0.42);
}

.print-canvas {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  width: min(100%, 980px, calc((100vh - 146px) * 1.5));
  max-height: calc(100vh - 146px);
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: 8px;
  background: #f8f8f8;
  box-shadow: var(--canvas-shadow);
}

.submit-dialog {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
}

.submit-dialog[hidden] {
  display: none;
}

.submit-dialog-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(23, 26, 36, 0.42);
  backdrop-filter: blur(8px);
}

.submit-dialog-card {
  position: relative;
  z-index: 1;
  width: min(100%, 460px);
  padding: 24px 24px 22px;
  border: 1px solid rgba(214, 218, 232, 0.96);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 26px 60px rgba(34, 41, 68, 0.2);
}

.submit-dialog-kicker {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.submit-dialog-card h2 {
  margin: 0;
  color: #171a23;
  font-size: 1.5rem;
  line-height: 1.1;
}

.submit-dialog-message {
  margin-top: 14px;
  color: #4f5569;
  font-size: 0.96rem;
  line-height: 1.45;
}

.submit-dialog-message p {
  margin: 0 0 12px;
}

.submit-dialog-message p:last-child {
  margin-bottom: 0;
}

.submit-dialog-layouts {
  margin: 0 0 12px;
  padding-left: 20px;
}

.submit-dialog-field {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  color: #3f4659;
  font-size: 0.9rem;
  font-weight: 600;
}

.submit-dialog-field input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(198, 202, 216, 0.96);
  border-radius: 12px;
  background: #ffffff;
  color: #171a23;
  outline: none;
}

.submit-dialog-field input:focus {
  border-color: rgba(134, 93, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(134, 93, 255, 0.16);
}

.submit-dialog-field.is-invalid {
  color: #9f2b2b;
}

.submit-dialog-field.is-invalid input {
  border-color: rgba(224, 82, 82, 0.72);
  box-shadow: 0 0 0 3px rgba(224, 82, 82, 0.16);
}

.submit-dialog-field-hint {
  margin: 2px 0 0;
  color: #9f2b2b;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
}

.submit-dialog-field-hint[hidden] {
  display: none;
}

.submit-dialog-status {
  margin-top: 12px;
  min-height: 40px;
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 10px 12px;
  font-size: 0.9rem;
  line-height: 1.35;
}

.submit-dialog-status[hidden] {
  display: none;
}

.submit-dialog-status.is-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  border-color: rgba(93, 126, 255, 0.34);
  background: rgba(93, 126, 255, 0.1);
  color: #2e4ea7;
}

.submit-dialog-status.is-progress::before {
  content: "";
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(46, 78, 167, 0.2);
  border-top-color: #2e4ea7;
  animation: submit-spin 0.8s linear infinite;
}

.submit-dialog-status.is-success {
  border-color: rgba(45, 168, 111, 0.4);
  background: rgba(45, 168, 111, 0.11);
  color: #1c7e52;
}

.submit-dialog-status.is-warning {
  border-color: rgba(229, 158, 57, 0.4);
  background: rgba(229, 158, 57, 0.12);
  color: #946017;
}

.submit-dialog-status.is-error {
  border-color: rgba(224, 82, 82, 0.42);
  background: rgba(224, 82, 82, 0.12);
  color: #9f2b2b;
}

@keyframes submit-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.submit-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

.submit-dialog-secondary,
.submit-dialog-primary {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 14px;
  font: inherit;
  font-weight: 700;
}

.submit-dialog-secondary {
  border: 1px solid rgba(198, 202, 216, 0.96);
  background: #f4f5fa;
  color: #1f2330;
}

.submit-dialog-primary {
  border: 0;
  background: linear-gradient(135deg, #8a63ff, #6b52e5);
  color: #ffffff;
  box-shadow: 0 16px 28px rgba(111, 70, 234, 0.22);
}

.preview-photo-fill {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.preview-photo-fill[data-fill-mode="overlay"] {
  z-index: 2;
}

.preview-photo-fill .photo-fill-slot {
  position: absolute;
  overflow: hidden;
}

.preview-photo-fill .photo-fill-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  transform: scale(1.16);
  transform-origin: center top;
}

.print-canvas img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.print-canvas img {
  object-fit: contain;
  object-position: center;
}

#previewImage {
  z-index: 1;
}

.toolbar-action {
  background: linear-gradient(135deg, #8a63ff, #6b52e5);
  border: 0;
  color: #ffffff;
}

.toolbar-action-secondary {
  background: #f4f5fa;
  border: 1px solid #e6e7f0;
  color: var(--text);
}

.toolbar-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.preview-copy {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.layer-shell {
  position: absolute;
  z-index: 3;
  min-width: 2ch;
  max-width: 76%;
  min-height: 1.2%;
  overflow: visible;
  pointer-events: auto;
}

.selection-frame {
  position: absolute;
  inset: -1px;
  border: 2px solid rgba(134, 93, 255, 0.78);
  border-radius: 8px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 140ms ease, box-shadow 140ms ease, transform 140ms ease;
  pointer-events: none;
}

.layer-shell.is-active-layer {
  z-index: 5;
}

.layer-shell.is-active-layer .selection-frame,
.layer-shell.is-interacting .selection-frame {
  opacity: 1;
  visibility: visible;
  border-color: rgba(134, 93, 255, 0.78);
  box-shadow: 0 0 0 1px rgba(134, 93, 255, 0.22), 0 12px 30px rgba(33, 23, 78, 0.18);
}

.custom-image-shell {
  position: absolute;
  z-index: 4;
  overflow: visible;
  pointer-events: auto;
}

.custom-image-shell img {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
  user-select: none;
  pointer-events: none;
}

.custom-image-shell .custom-image-frame {
  inset: -8px;
}

.custom-image-shell.is-active .selection-frame {
  opacity: 1;
  visibility: visible;
  box-shadow: 0 0 0 1px rgba(134, 93, 255, 0.22), 0 12px 30px rgba(33, 23, 78, 0.18);
}

.layer-edge-handle,
.layer-resize-handle {
  position: absolute;
  border: 0;
  background: transparent;
  pointer-events: auto;
  touch-action: none;
}

.layer-resize-handle {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(134, 93, 255, 0.9);
  border-radius: 50%;
  background: #ffffff;
  z-index: 30;
}

.layer-edge-handle {
  z-index: 20;
}

.layer-edge-handle[data-layer-action="drag"] {
  cursor: move;
}

.layer-edge-handle.is-s {
  left: 50%;
  width: 40px;
  height: 16px;
  transform: translateX(-50%);
}

.layer-edge-handle.is-n {
  left: 50%;
  width: 40px;
  height: 16px;
  transform: translateX(-50%);
}

.layer-edge-handle.is-e,
.layer-edge-handle.is-w {
  top: 50%;
  width: 16px;
  height: 64px;
  transform: translateY(-50%);
}

.layer-edge-handle.is-e {
  right: -10px;
  cursor: ew-resize;
}

.layer-edge-handle.is-s {
  bottom: -10px;
  cursor: ns-resize;
}

.layer-edge-handle.is-n {
  top: -10px;
  cursor: ns-resize;
}

.layer-edge-handle.is-w {
  left: -10px;
  cursor: ew-resize;
}

.layer-edge-handle[data-layer-action="drag"].is-n,
.layer-edge-handle[data-layer-action="drag"].is-e,
.layer-edge-handle[data-layer-action="drag"].is-s,
.layer-edge-handle[data-layer-action="drag"].is-w {
  cursor: move;
}

.layer-edge-handle[data-layer-action="drag"].is-n,
.layer-edge-handle[data-layer-action="drag"].is-s {
  left: -10px;
  right: -10px;
  width: auto;
  height: 18px;
  transform: none;
}

.layer-edge-handle[data-layer-action="drag"].is-n {
  top: -10px;
}

.layer-edge-handle[data-layer-action="drag"].is-s {
  bottom: -10px;
}

.layer-edge-handle[data-layer-action="drag"].is-e,
.layer-edge-handle[data-layer-action="drag"].is-w {
  top: -10px;
  bottom: -10px;
  width: 18px;
  height: auto;
  transform: none;
}

.layer-edge-handle[data-layer-action="drag"].is-e {
  right: -10px;
}

.layer-edge-handle[data-layer-action="drag"].is-w {
  left: -10px;
}

.layer-resize-handle.is-nw {
  top: -10px;
  left: -10px;
  cursor: nwse-resize;
}

.layer-resize-handle.is-ne {
  top: -10px;
  right: -10px;
  cursor: nesw-resize;
}

.layer-resize-handle.is-sw {
  bottom: -10px;
  left: -10px;
  cursor: nesw-resize;
}

.layer-resize-handle.is-se {
  right: -10px;
  bottom: -10px;
  cursor: nwse-resize;
}

.preview-title,
.preview-subtitle,
.preview-meta-line,
.preview-text-layer {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 8px 10px;
  outline: none;
  cursor: text;
  white-space: pre;
  overflow-wrap: normal;
  word-break: keep-all;
  overflow: hidden;
  pointer-events: auto;
}

.preview-title {
  font-size: 86px;
  line-height: 0.94;
  letter-spacing: -0.04em;
}

.preview-subtitle {
  font-size: 32px;
  line-height: 1.18;
}

.preview-meta-line {
  font-size: 24px;
  line-height: 1.14;
  letter-spacing: 0.08em;
}

.preview-text-layer {
  font-size: 30px;
  line-height: 1.18;
}

[data-layer-target][contenteditable="true"]:focus {
  outline: none;
}

[data-layer-target].is-empty::before {
  content: attr(data-placeholder);
  color: rgba(255, 255, 255, 0.92);
  font-weight: 600;
}

.gallery-grid {
  display: grid;
  gap: 10px;
  margin-top: 0;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.layout-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border-color: #e3e5ef;
  border-radius: 14px;
  background: #fafaff;
  color: inherit;
  text-align: left;
  box-shadow: 0 8px 18px rgba(75, 82, 110, 0.06);
}

.layout-card.is-active {
  border-color: rgba(134, 93, 255, 0.34);
  background: rgba(134, 93, 255, 0.12);
}

.layout-card.is-active .layout-thumb {
  transform: scale(0.92);
}

.layout-card-upload {
  border-style: dashed;
  border-color: #d6d9e6;
  background: linear-gradient(180deg, #ffffff, #f7f8fc);
}

.layout-card-upload:hover {
  border-color: rgba(134, 93, 255, 0.42);
  background: rgba(134, 93, 255, 0.08);
}

.layout-thumb {
  width: 100%;
  height: 56px;
  border-radius: 14px;
  object-fit: contain;
  object-position: center;
  background: #f1f2f8;
  transition: transform 150ms ease;
}

.layout-upload-thumb {
  display: grid;
  place-items: center;
  border: 1px dashed #d6d9e6;
  background: linear-gradient(180deg, #ffffff, #f8f9fd);
}

.layout-upload-plus {
  color: var(--accent-strong);
  font-size: 1.65rem;
  font-weight: 500;
  line-height: 1;
}

.layout-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.layout-title {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.2;
}

.layout-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.3;
}

.layout-upload-description {
  margin: 0;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.35;
}

.layout-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.layout-tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(134, 93, 255, 0.09);
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 700;
}

.empty-state {
  width: 100%;
  padding: 18px;
  border: 1px dashed #d8dbe7;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
  }

  .ruler-shell,
  .studio-shell {
    grid-template-columns: 1fr;
  }

  .ruler-gutter {
    display: none;
  }

  .sidebar-panel {
    position: static;
    min-height: auto;
    height: auto;
  }

  .floating-toolbar {
    width: 100%;
    justify-content: flex-start;
  }

  .workspace-panel {
    height: auto;
  }

  .workspace-stage {
    height: auto;
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 10px 10px 18px;
  }

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

  .meta-pills {
    justify-content: flex-start;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout-card {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .layout-thumb {
    height: auto;
    aspect-ratio: 3 / 2;
  }

  .toolbar-group {
    border-right: 0;
    padding-right: 0;
  }

  .print-stage {
    flex-direction: column;
    min-height: auto;
    padding: 24px 18px 28px;
  }

  .layout-stack {
    width: min(100%, 220px);
  }

  .layout-stack-list {
    width: 100%;
  }

  .print-canvas {
    width: min(100%, 980px);
    max-height: none;
  }

  .layer-shell {
    max-width: 84%;
  }

  .layer-edge-handle.is-s {
    width: 34px;
  }

  .layer-edge-handle.is-n {
    width: 34px;
  }

  .layer-edge-handle.is-e,
  .layer-edge-handle.is-w {
    height: 56px;
  }
}

@media (max-width: 680px) {
  .sidebar-panel,
  .workspace-stage {
    border-radius: 22px;
  }

  .pill-group {
    grid-template-columns: 1fr;
  }

  .segment-control {
    grid-template-columns: 1fr;
  }

  .layout-title {
    font-size: 0.84rem;
  }

  .layer-shell {
    max-width: 92%;
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .mobile-editor-notice {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 120;
    display: block;
    margin: 0;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 14px 14px;
    border-bottom: 1px solid rgba(176, 180, 200, 0.9);
    background: rgba(30, 34, 51, 0.95);
    color: #ffffff;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.3;
  }

  .app-shell {
    grid-template-rows: auto;
    height: auto;
    min-height: calc(100dvh - 46px);
    padding: 84px 10px 16px;
  }

  .studio-shell {
    display: block;
    height: auto;
  }

  .workspace-panel {
    display: none;
  }

  .sidebar-panel {
    padding: 12px 10px;
    border-radius: 18px;
    overflow: visible;
  }

  .sidebar-gallery-block .section-label,
  .section-note {
    display: none;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .layout-card {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px;
  }

  .layout-thumb {
    width: 100%;
    aspect-ratio: 3 / 2;
    height: auto;
  }

  .layout-title {
    font-size: 0.86rem;
  }

  .layout-subtitle {
    font-size: 0.68rem;
  }

  .layout-card-upload {
    display: none;
  }

  .mobile-layout-modal[hidden] {
    display: none;
  }

  .mobile-layout-modal {
    position: fixed;
    inset: 0;
    z-index: 180;
    display: grid;
    place-items: center;
    padding: 16px;
  }

  .mobile-layout-modal-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(10, 12, 20, 0.96);
  }

  .mobile-layout-modal-card {
    position: relative;
    z-index: 1;
    width: min(100%, 980px);
    max-height: calc(100dvh - 36px);
    display: grid;
    gap: 10px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .mobile-layout-modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(173, 178, 203, 0.9);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    color: #2a314a;
    font-size: 1.4rem;
    line-height: 1;
    font-weight: 500;
  }

  #mobileLayoutPreviewImage {
    width: 100%;
    max-height: calc(100dvh - 130px);
    object-fit: contain;
    border-radius: 0;
    background: transparent;
  }

  .mobile-layout-modal-title {
    margin: 0;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 600;
    color: #2a314a;
    padding: 0 28px 2px;
  }
}
