:root {
  color: var(--spt-ink);
  font-family: var(--spt-font-sans);
  background: var(--spt-workspace);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--spt-workspace);
}

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

.spt-mobile-app {
  height: var(--spt-mobile-viewport-height, 100dvh);
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  background: var(--spt-surface);
}

.spt-mobile-install-suggestion {
  grid-row: 2;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--spt-border);
  background: var(--spt-surface-raised);
  color: var(--spt-ink-soft);
  font-size: 12px;
}

.spt-mobile-install-suggestion[hidden] {
  display: none;
}

.spt-mobile-install-suggestion p {
  margin: 0;
}

.spt-mobile-install-suggestion button {
  min-height: 36px;
  flex: 0 0 auto;
  border: 1px solid var(--spt-border-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--spt-ink);
}

.spt-mobile-header {
  grid-row: 1;
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 58px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--spt-border);
  background: var(--spt-surface);
}

.spt-mobile-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}

.spt-mobile-brand img {
  width: 30px;
  height: 30px;
}

.spt-mobile-explore {
  color: var(--spt-ink-soft);
  font-size: 12px;
  text-align: right;
}

.spt-mobile-main {
  grid-row: 3;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.spt-mobile-setup {
  height: 100%;
  min-height: 0;
}

.spt-mobile-setup .spt-quick-collage-layer {
  position: static;
  height: 100%;
  min-height: 0;
  padding: 14px;
  background: transparent;
}

.spt-mobile-setup .spt-quick-collage {
  width: 100%;
  max-width: 520px;
  max-height: 100%;
  border: 0;
}

.spt-mobile-result {
  height: 100%;
  min-height: 0;
  padding: 14px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
  gap: 8px;
  overflow: hidden;
}

.spt-mobile-result[hidden] {
  display: none;
}

.spt-mobile-canvas-wrap {
  position: relative;
  min-width: 1px;
  min-height: 1px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: var(--spt-shadow-soft);
  touch-action: none;
}

.spt-mobile-canvas-wrap .spt-collage-preview-layer {
  position: absolute;
  inset: 0;
}

.spt-mobile-status {
  min-height: 18px;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--spt-muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
}

.spt-mobile-actions {
  grid-row: 4;
  position: sticky;
  z-index: 20;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--spt-border);
  background: var(--spt-surface);
}

.spt-mobile-actions[hidden] {
  display: none;
}

.spt-mobile-actions button,
.spt-mobile-editor button {
  min-height: 44px;
  border: 1px solid var(--spt-border-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--spt-ink);
}

.spt-mobile-actions button.is-primary,
.spt-mobile-editor button.is-primary {
  border-color: var(--spt-focus);
  background: var(--spt-focus);
  color: #ffffff;
}

.spt-mobile-editor-layer {
  position: fixed;
  z-index: 50;
  inset: var(--spt-mobile-editor-viewport-top, 0) 0 auto;
  height: var(--spt-mobile-editor-viewport-height, 100dvh);
  padding: max(10px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom));
  overflow: hidden;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
}

.spt-mobile-editor-layer[hidden] {
  display: none;
}

.spt-mobile-editor {
  width: min(100%, 420px);
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 16px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid var(--spt-border-strong);
  border-radius: 6px;
  background: var(--spt-surface-raised);
}

.spt-mobile-editor h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.spt-mobile-editor__body {
  min-height: 0;
  overflow: auto;
  padding: 0 2px 12px;
  overscroll-behavior: contain;
}

.spt-mobile-editor label {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 700;
}

.spt-mobile-editor label[hidden] {
  display: none;
}

.spt-mobile-editor textarea,
.spt-mobile-editor select {
  width: 100%;
  min-height: 44px;
  padding: 9px;
  border: 1px solid var(--spt-border-strong);
  border-radius: 4px;
  background: #ffffff;
  font-size: 16px;
}

.spt-mobile-editor .spt-mobile-color {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.spt-mobile-editor input[type="color"] {
  width: 48px;
  height: 44px;
  padding: 3px;
  appearance: none;
  border: 1px solid var(--spt-border-strong);
  border-radius: 6px;
  background: #ffffff;
}

.spt-mobile-editor input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.spt-mobile-editor input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 3px;
}

.spt-mobile-editor input[type="color"]::-moz-color-swatch {
  border: 0;
  border-radius: 3px;
}

.spt-mobile-editor .spt-mobile-check {
  grid-template-columns: auto 1fr;
  align-items: center;
  font-weight: 400;
}

.spt-mobile-editor p {
  min-height: 18px;
  color: var(--spt-ink-soft);
  font-size: 12px;
}

.spt-mobile-editor footer {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--spt-border);
}

.spt-mobile-editor-layer[data-mobile-editor-mode="setup"] footer {
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 700px) {
  body {
    padding: 24px;
  }

  .spt-mobile-app {
    width: min(100%, 720px);
    height: calc(var(--spt-mobile-viewport-height, 100dvh) - 48px);
    min-height: 0;
    margin: 0 auto;
    border: 1px solid var(--spt-border-strong);
    box-shadow: var(--spt-shadow-soft);
  }
}
