@font-face {
  font-family: "HelveticaNeueRoman";
  src: url("../assets/fonts/HelveticaNeueLTStd-Roman.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "HelveticaNeueHv";
  src: url("/assets/fonts/HelveticaNeueLTStd-Hv.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "HelveticaNeueMd";
  src: url("/assets/fonts/HelveticaNeueLTStd-Md.otf") format("opentype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --page-margin: 32px;
  --gutter: 16px;
  --text-size: 18px;
  --tracking: -0.02em;
  --off-black: rgba(0, 0, 0, 0.2);
  --on-black: rgba(0, 0, 0, 1);
  --bg: #fff;
  --fg: #000;

  --left-meta-space: 36px;
  --right-meta-space: 58px;
  --square-size: 12px;
}

html.dark-mode {
  --off-black: rgba(255, 255, 255, 0.2);
  --on-black: rgba(255, 255, 255, 1);
  --bg: #000;
  --fg: #fff;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  font-family: "HelveticaNeueRoman", Helvetica, Arial, sans-serif;
}

body {
  overflow: hidden;
  color: var(--fg);
}

#app {
  width: 100%;
  height: 100%;
  padding: var(--page-margin);
  box-sizing: border-box;
  position: relative;
  background: var(--bg);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  row-gap: var(--gutter);
}

html,
body,
a,
button,
input,
textarea,
select,
label,
canvas,
[role="button"] {
  cursor: none !important;
}

#fp-cursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 10px;
  height: 10px;
  background: var(--fg);
  pointer-events: none;
  z-index: 999999;
  opacity: 0;
  transform: translate(-9999px, -9999px);
  transition: opacity 120ms ease;
}

#fp-cursor.is-visible {
  opacity: 1;
}

@media (pointer: coarse) {
  html,
  body,
  a,
  button,
  input,
  textarea,
  select,
  label,
  canvas,
  [role="button"] {
    cursor: auto !important;
  }

  #fp-cursor {
    display: none;
  }
}

/* NAV */
#nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
}

#nav-logo-button {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: default;
}

#nav-logo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: default;
}

#nav-logo {
  width: 34px;
  height: 34px;
  display: block;
}

#nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  white-space: nowrap;
}

.nav-link,
.nav-slash {
  font-family: "HelveticaNeueRoman", Helvetica, Arial, sans-serif;
  font-size: calc(var(--text-size) + 0px);
  text-transform: uppercase;
  line-height: 1;
  letter-spacing: 0;
  color: var(--fg);
}

.nav-link {
  display: inline;
  text-decoration: none;
  margin: 0;
  padding: 0;
  opacity: 1;
  transition: opacity 180ms ease;
}

.nav-link:hover,
.nav-link:focus-visible {
  opacity: 0.45;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  outline: none;
}

.nav-link[aria-current="page"] {
  opacity: 0.45;
}

.nav-link[aria-current="page"]:hover,
.nav-link[aria-current="page"]:focus-visible {
  opacity: 0.45;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  outline: none;
}

.nav-slash {
  display: inline;
  margin: 0 1px;
  padding: 0;
  user-select: none;
}

/* MAIN LAYOUT */
#layout {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: var(--gutter);
  align-items: start;
  margin: 0 auto;
  overflow: hidden;
  min-height: 0;
}

#edited-panel {
  width: 100%;
  min-width: 0;
  min-height: 0;
  align-self: start;
  padding-bottom: 0;
  box-sizing: border-box;
  position: relative;
}

#editor-mobile-secondary,
#menu-mobile-stack {
  display: none;
}

#right-column {
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: 100%;
  align-self: start;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

#original-panel {
  width: 100%;
  min-width: 0;
  min-height: 0;
  align-self: start;
  padding-bottom: var(--right-meta-space);
  box-sizing: border-box;
  margin: 0;
  position: relative;
  z-index: 2;
}

#menu-panel {
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: relative;
}

#edited-frame,
#original-frame {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: transparent;
  overflow: visible;
  position: relative;
  margin: 0;
}

#canvas-container {
  width: 100%;
  overflow: hidden;
  position: relative;
}

#canvas-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

#original-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left top;
  display: block;
  background: transparent;
}

.floating-meta {
  position: absolute;
  left: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  width: 100%;
  pointer-events: auto;
  z-index: 3;
}

.layer-selector-row {
  position: absolute;
  left: 0;
  display: none;
  align-items: center;
  gap: 3px;
  width: 100%;
  pointer-events: auto;
  z-index: 3;
}

#edited-meta {
  position: fixed;
  bottom: 16px;
  left: 0;
  width: 0;
  z-index: 9999;
  pointer-events: auto;
}

.meta-button {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  font-family: "HelveticaNeueRoman", Helvetica, Arial, sans-serif;
  font-size: var(--text-size);
  letter-spacing: var(--tracking);
  line-height: 1;
  color: var(--fg);
  text-align: left;
  text-transform: uppercase;
  cursor: default;
}

.meta-right {
  text-align: right;
}

#download-button,
#change-base-button,
#add-image-button,
#mobile-download-button,
#mobile-change-base-button,
#mobile-add-image-button {
  width: auto;
  min-height: calc(var(--text-size) + 8px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  line-height: 0;
  color: transparent;
  cursor: pointer;
}

#mobile-reset-button,
#mobile-regenerate-button {
  width: auto;
  min-height: calc(var(--text-size) + 8px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  line-height: 0;
  color: transparent;
  cursor: pointer;
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
}

#original-meta-left {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

#change-base-button,
#add-image-button {
  justify-content: flex-start;
}

#download-button {
  justify-content: flex-end;
}

#download-button::before,
#change-base-button::before,
#add-image-button::before,
#mobile-download-button::before,
#mobile-change-base-button::before,
#mobile-add-image-button::before,
#mobile-reset-button::before,
#mobile-regenerate-button::before {
  content: "";
  display: block;
  width: 24px;
  height: 24px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

#download-button::before,
#mobile-download-button::before {
  background-image: url("/assets/icons/down_b.svg");
}

#change-base-button::before,
#mobile-change-base-button::before {
  background-image: url("/assets/icons/up_b.svg");
}

#add-image-button::before,
#mobile-add-image-button::before {
  background-image: url("/assets/icons/add_imgb.png");
}

#mobile-reset-button::before {
  background-image: url("/assets/icons/reset_b.png");
}

#mobile-regenerate-button::before {
  background-image: url("/assets/icons/gen_b.png");
}

html.dark-mode #download-button::before,
html.dark-mode #mobile-download-button::before {
  background-image: url("/assets/icons/down_w.svg");
}

html.dark-mode #change-base-button::before,
html.dark-mode #mobile-change-base-button::before {
  background-image: url("/assets/icons/up_w.svg");
}

html.dark-mode #add-image-button::before,
html.dark-mode #mobile-add-image-button::before {
  background-image: url("/assets/icons/add_imgw.png");
}

html.dark-mode #mobile-reset-button::before {
  background-image: url("/assets/icons/reset_w.png");
}

html.dark-mode #mobile-regenerate-button::before {
  background-image: url("/assets/icons/gen_w.png");
}

#menu-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-top: 0;
  padding-bottom: 16px;
  box-sizing: border-box;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#menu-columns::-webkit-scrollbar {
  display: none;
}

.menu-col {
  min-width: 0;
  align-self: start;
}

.menu-toolbar,
.mobile-menu-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 8px;
  margin-bottom: 8px;
}

.menu-toolbar-label {
  font-size: var(--text-size);
  letter-spacing: var(--tracking);
  line-height: 1;
  color: var(--fg);
  text-transform: uppercase;
}

.menu-divider {
  width: 100%;
  height: 1px;
  background: var(--fg);
  margin-bottom: 8px;
}

.menu-square {
  width: var(--square-size);
  height: var(--square-size);
  border: none;
  background: var(--off-black);
  padding: 0;
  margin: 0;
  appearance: none;
  cursor: pointer;
  flex: 0 0 auto;
}

.menu-square:hover,
.menu-square:focus-visible {
  background: var(--on-black);
  outline: none;
}

.control-block {
  margin-bottom: 10px;
}

.control-block.is-disabled {
  opacity: 0.24;
}

.control-label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--text-size);
  letter-spacing: var(--tracking);
  line-height: 1;
  text-transform: uppercase;
  color: var(--fg);
}

.control-row {
  display: flex;
  align-items: center;
}

.pixel-bar {
  display: flex;
  gap: 3px;
  align-items: center;
  flex-wrap: nowrap;
}

.pixel-step,
.layer-step,
.toggle-square {
  width: var(--square-size);
  height: var(--square-size);
  border: none;
  background: var(--off-black);
  padding: 0;
  margin: 0;
  appearance: none;
  cursor: pointer;
  flex: 0 0 auto;
}

.pixel-step.is-on,
.layer-step.is-on,
.toggle-square.is-on {
  background: var(--on-black);
}

.toggle-square {
  border-radius: 0;
}

.color-picker-input {
  width: var(--square-size);
  height: var(--square-size);
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  display: block;
  flex: 0 0 auto;
}

.color-picker-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-picker-input::-webkit-color-swatch {
  border: none;
}

.color-picker-input::-moz-color-swatch {
  border: none;
}

.text-input-control {
  width: 100%;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--fg);
  font-family: "HelveticaNeueRoman", Helvetica, Arial, sans-serif;
  font-size: var(--text-size);
  letter-spacing: var(--tracking);
  line-height: 1;
  text-transform: uppercase;
  padding: 0;
  margin: 0;
}

.mobile-accordion-section {
  border-top: 1px solid var(--fg);
}

.mobile-accordion-section:last-child {
  border-bottom: 1px solid var(--fg);
}

.mobile-accordion-header {
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 28px;
  align-items: center;
  column-gap: 0;
  appearance: none;
  border: none;
  background: transparent;
  padding: 12px 0;
  margin: 0;
  color: var(--fg);
  text-align: left;
}

.mobile-accordion-number {
  font-family: "HelveticaNeueRoman", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--fg);
  justify-self: start;
  transform: translateY(3px);
}

.mobile-accordion-title {
  font-family: "HelveticaNeueMd", "HelveticaNeueRoman", Helvetica, Arial, sans-serif;
  font-size: clamp(24px, 4.5vw, 32px);
  line-height: 0.92;
  letter-spacing: -0.05em;
  text-transform: uppercase;
  color: #a6a6a6;
  justify-self: start;
  text-align: left;
  margin: 0 0 0 -4px;
  padding: 0;
  transform: translateY(4px);
}

.mobile-accordion-toggle {
  font-family: "HelveticaNeueRoman", Helvetica, Arial, sans-serif;
  font-size: 28px;
  line-height: 1;
  color: var(--fg);
  justify-self: end;
}

.mobile-accordion-section.is-open .mobile-accordion-title {
  color: var(--fg);
}

.mobile-accordion-body {
  display: none;
  padding: 0 0 8px 0;
}

.mobile-accordion-section.is-open .mobile-accordion-body {
  display: block;
}

.mobile-empty-state {
  height: 6px;
}

.mobile-slider-wrap {
  width: 100%;
}

.mobile-slider {
  width: 100%;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
}

.mobile-slider:focus {
  outline: none;
}

.mobile-slider::-webkit-slider-runnable-track {
  height: 3px;
  background: #a6a6a6;
  border: none;
}

.mobile-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--fg);
  border: none;
  margin-top: -7.5px;
}

.mobile-slider::-moz-range-track {
  height: 3px;
  background: #a6a6a6;
  border: none;
}

.mobile-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--fg);
  border: none;
  border-radius: 0;
}

.mobile-select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--fg);
  border-radius: 0;
  background-color: var(--bg);
  color: var(--fg);
  font-family: "HelveticaNeueRoman", Helvetica, Arial, sans-serif;
  font-size: var(--text-size);
  line-height: 1;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  padding: 7px 34px 7px 10px;
  outline: none;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--fg) 50%),
    linear-gradient(135deg, var(--fg) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.mobile-select option {
  background: var(--bg);
  color: var(--fg);
}

.mobile-select:focus {
  outline: none;
}

.mobile-select:disabled {
  opacity: 0.24;
}

.mobile-select::-ms-expand {
  display: none;
}

html.dark-mode .mobile-select {
  background-color: var(--bg);
  color: var(--fg);
  border-color: var(--fg);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--fg) 50%),
    linear-gradient(135deg, var(--fg) 50%, transparent 50%);
}

html.dark-mode .mobile-select option {
  background: #000;
  color: #fff;
}

#dark-mode-button {
  position: absolute;
  right: var(--page-margin);
  bottom: var(--gutter);
  width: calc(var(--square-size) + 2px);
  height: calc(var(--square-size) + 2px);
  border: none;
  padding: 0;
  margin: 0;
  background: var(--off-black);
  appearance: none;
  cursor: pointer;
  z-index: 20;
}

#dark-mode-button.is-on {
  background: var(--on-black);
}

/* ---------------------------------
   Shared app transitions
---------------------------------- */

#app-page-transition,
#editor-page-transition,
#archive-page-transition {
  position: fixed;
  inset: 0;
  background: var(--fg);
  z-index: 100000;
  pointer-events: none;
  will-change: clip-path;
}

#app-page-transition {
  clip-path: inset(100% 0 0 0);
}

#app-page-transition.is-active {
  animation: appExitSlideUp 700ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes appExitSlideUp {
  from {
    clip-path: inset(100% 0 0 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

#editor-page-transition,
#archive-page-transition {
  clip-path: inset(0 0 0 0);
}

/* ---------------------------------
   Fade-out to home
---------------------------------- */

body.app-home-fade-exit #app {
  animation: appFadeOutToHome 900ms ease forwards;
}

@keyframes appFadeOutToHome {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* ---------------------------------
   Shared intro wipe
---------------------------------- */

body.editor-intro #editor-page-transition,
body.archive-intro #archive-page-transition {
  animation: appIntroSlideDown 2000ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: 500ms;
}

@keyframes appIntroSlideDown {
  from {
    clip-path: inset(0 0 0 0);
  }
  to {
    clip-path: inset(100% 0 0 0);
  }
}

/* ---------------------------------
   Shared fade keyframes
---------------------------------- */

@keyframes editorFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ---------------------------------
   Editor intro fade
---------------------------------- */

body.editor-preload #app > * {
  opacity: 0 !important;
}

body.editor-intro #nav,
body.editor-intro #edited-frame,
body.editor-intro #original-frame,
body.editor-intro #menu-panel,
body.editor-intro #edited-meta,
body.editor-intro #dark-mode-button {
  opacity: 0;
}

body.editor-intro.editor-intro-ready #nav {
  animation: editorFadeIn 1400ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: 500ms;
}

body.editor-intro.editor-intro-ready #edited-frame,
body.editor-intro.editor-intro-ready #original-frame {
  animation: editorFadeIn 1600ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: 680ms;
}

body.editor-intro.editor-intro-ready #menu-panel {
  animation: editorFadeIn 1700ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: 860ms;
}

body.editor-intro.editor-intro-ready #edited-meta,
body.editor-intro.editor-intro-ready #dark-mode-button {
  animation: editorFadeIn 1500ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: 1060ms;
}

/* ---------------------------------
   Archive intro fade
---------------------------------- */

body.archive-preload #app > * {
  opacity: 0 !important;
}

body.archive-intro #nav,
body.archive-intro #archive-main,
body.archive-intro #dark-mode-button {
  opacity: 0;
}

body.archive-intro.archive-intro-ready #nav {
  animation: editorFadeIn 1400ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: 500ms;
}

body.archive-intro.archive-intro-ready #archive-main {
  animation: editorFadeIn 1600ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: 680ms;
}

body.archive-intro.archive-intro-ready #dark-mode-button {
  animation: editorFadeIn 1500ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: 1060ms;
}

/* ---------------------------------
   Lens intro fade only
---------------------------------- */

body.lens-preload #app > * {
  opacity: 0 !important;
}

body.lens-intro #nav,
body.lens-intro #lens-main,
body.lens-intro #dark-mode-button {
  opacity: 0;
}

body.lens-intro.lens-intro-ready #nav {
  animation: editorFadeIn 1400ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: 500ms;
}

body.lens-intro.lens-intro-ready #lens-main {
  animation: editorFadeIn 1600ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: 680ms;
}

body.lens-intro.lens-intro-ready #dark-mode-button {
  animation: editorFadeIn 1500ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: 1060ms;
}

#lens-main {
  width: 100%;
  height: 100%;
  min-height: 0;
}

@media (max-width: 1400px) {
  :root {
    --text-size: 16px;
    --square-size: 10px;
    --nav-text: 14px;
  }

  #menu-columns {
    gap: 20px;
  }
}

@media (max-width: 1100px) {
  :root {
    --text-size: 14px;
    --square-size: 9px;
    --nav-text: 12px;
  }

  #menu-columns {
    gap: 16px;
  }

  .pixel-bar {
    gap: 4px;
  }
}

@media (pointer: coarse) and (max-width: 900px) {
  #desktop-layer-selector,
  #desktop-action-row {
    display: none !important;
  }

  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body {
    --page-margin: 16px;
    --text-size: 15px;
    --square-size: 10px;
    overflow: hidden;
  }

  #app {
    display: block;
    min-height: 100svh;
    height: 100svh;
    overflow: hidden;
    padding: 0;
  }

  #nav {
    position: fixed;
    top: 18px;
    left: 16px;
    right: 16px;
    width: auto;
    z-index: 50;
  }

  #layout {
    position: relative;
    width: 100%;
    height: 100svh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-top: 0;
    padding-top: 58px;
    box-sizing: border-box;
  }

  #edited-panel,
  #right-column,
  #menu-panel {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  #edited-panel {
    flex: 0 0 auto;
    display: block;
    margin-bottom: 0;
    overflow: visible;
  }

  #edited-frame {
    width: 100vw;
    max-width: 100vw;
    margin-left: 0;
    margin-right: 0;
    aspect-ratio: auto;
    height: auto;
    overflow: hidden;
    background: transparent;
  }

  #canvas-container {
    width: 100%;
    height: auto !important;
    overflow: hidden;
  }

  #canvas-container canvas {
    display: block;
    width: 100% !important;
    height: auto !important;
    image-rendering: auto;
  }

  #edited-meta {
    display: none !important;
  }

  #editor-mobile-secondary {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
    padding: 4px 16px 0 16px;
    flex: 0 0 auto;
    box-sizing: border-box;
  }

  #mobile-layer-selector {
    position: static !important;
    left: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: auto !important;
    display: flex;
    gap: 6px;
  }

#editor-mobile-actions {
  display: block;
  width: 100%;
  position: relative;
  padding-top: 4px;
  min-height: 46px;
}

#editor-mobile-actions button {
  position: absolute;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transform: translateX(-50%);
}

#mobile-change-base-button {
  left: calc(0% + 12px);
}

#mobile-download-button {
  left: calc(25% + 6px);
}

#mobile-add-image-button {
  left: 50%;
}

#mobile-reset-button {
  left: calc(75% - 6px);
}

#mobile-regenerate-button {
  left: calc(100% - 12px);
}

  #mobile-change-base-button::after,
  #mobile-download-button::after,
  #mobile-add-image-button::after,
  #mobile-reset-button::after,
  #mobile-regenerate-button::after {
    display: block;
    margin-top: 3px;
    transform: translateY(1px);
    font-family: "HelveticaNeueRoman", Helvetica, Arial, sans-serif;
    font-size: 9px;
    line-height: 1;
    letter-spacing: -0.02em;
    color: var(--fg);
    opacity: 0.72;
    text-transform: uppercase;
    white-space: nowrap;
  }

  #mobile-change-base-button::after {
    content: "UPLOAD";
  }

  #mobile-download-button::after {
    content: "DOWNLOAD";
  }

  #mobile-add-image-button::after {
    content: "ADD IMAGE";
  }

  #mobile-reset-button::after {
    content: "RESET";
  }

  #mobile-regenerate-button::after {
    content: "GENERATE";
  }

  #original-panel {
    display: none !important;
  }

  #right-column {
    display: block !important;
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0 16px 16px 16px;
    box-sizing: border-box;
  }

  #menu-panel {
    display: block !important;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
  }

  #menu-mobile-stack {
    display: flex !important;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    border-top: 1px solid var(--fg);
    padding-top: 0;
    overflow: hidden;
  }

  #menu-mobile-controls {
    display: block;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  #menu-mobile-controls::-webkit-scrollbar {
    display: none;
  }

  #menu-mobile-controls .mobile-accordion-section:first-child {
    border-top: none;
  }

  #menu-mobile-controls .control-block:last-child {
    margin-bottom: 0;
  }

  #menu-columns {
    display: none !important;
  }

  .mobile-select {
    min-height: 30px;
    font-size: 15px;
    padding: 6px 30px 6px 8px;
    background-position:
      calc(100% - 16px) calc(50% - 2px),
      calc(100% - 10px) calc(50% - 2px);
    background-size: 6px 6px, 6px 6px;
  }

  .toggle-square {
    width: 18px;
    height: 18px;
  }

  #dark-mode-button {
    position: fixed;
    top: 24px;
    left: 16px;
    right: auto;
    bottom: auto;
    width: 22px;
    height: 22px;
    z-index: 100;
  }
}

@media (pointer: coarse) and (max-width: 600px) {
  #editor-mobile-secondary {
    gap: 8px;
    margin-top: 14px;
    padding-top: 4px;
  }

  #dark-mode-button {
    width: 20px;
    height: 20px;
  }

  .mobile-accordion-title {
    font-size: 24px;
  }

  .mobile-accordion-header {
    padding: 12px 0;
  }
}

/* ---------------------------------
   Desktop top action row
---------------------------------- */
#desktop-action-row {
  display: none;
}

#desktop-change-base-button,
#desktop-download-button,
#desktop-add-image-button,
#desktop-reset-button,
#desktop-regenerate-button {
  width: auto;
  min-height: calc(var(--text-size) + 8px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  line-height: 0;
  color: transparent;
  cursor: pointer;
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
}

#desktop-change-base-button::before,
#desktop-download-button::before,
#desktop-add-image-button::before,
#desktop-reset-button::before,
#desktop-regenerate-button::before {
  content: "";
  display: block;
  width: 24px;
  height: 24px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

#desktop-change-base-button::before {
  background-image: url("/assets/icons/up_b.svg");
}

#desktop-download-button::before {
  background-image: url("/assets/icons/down_b.svg");
}

#desktop-add-image-button::before {
  background-image: url("/assets/icons/add_imgb.png");
}

#desktop-reset-button::before {
  background-image: url("/assets/icons/reset_b.png");
}

#desktop-regenerate-button::before {
  background-image: url("/assets/icons/gen_b.png");
}

html.dark-mode #desktop-change-base-button::before {
  background-image: url("/assets/icons/up_w.svg");
}

html.dark-mode #desktop-download-button::before {
  background-image: url("/assets/icons/down_w.svg");
}

html.dark-mode #desktop-add-image-button::before {
  background-image: url("/assets/icons/add_imgw.png");
}

html.dark-mode #desktop-reset-button::before {
  background-image: url("/assets/icons/reset_w.png");
}

html.dark-mode #desktop-regenerate-button::before {
  background-image: url("/assets/icons/gen_w.png");
}

@media (pointer: fine) and (min-width: 901px) {
  #original-panel {
    padding-bottom: 0;
  }

  #original-meta {
    display: none !important;
  }

  #menu-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding-top: 8px;
  }

  #desktop-layer-selector {
    position: static;
    display: none;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    width: auto;
    padding: 0 0 6px 0;
    flex: 0 0 auto;
  }

  #desktop-action-row {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr auto 1fr auto 1fr auto;
    align-items: start;
    width: 100%;
    padding: 6px 0 10px 0;
    border-bottom: 1px solid var(--fg);
    box-sizing: border-box;
    flex: 0 0 auto;
    overflow: visible;
  }

  #desktop-change-base-button { grid-column: 1; justify-self: start; }
  #desktop-download-button { grid-column: 3; justify-self: center; }
  #desktop-add-image-button { grid-column: 5; justify-self: center; }
  #desktop-reset-button { grid-column: 7; justify-self: center; }
  #desktop-regenerate-button { grid-column: 9; justify-self: end; }

  .desktop-icon-button {
    position: static;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    transform: none;
    min-width: 0;
    flex: 0 0 auto;
    padding: 0;
    margin: 0;
  }

  .desktop-icon-button::before {
    width: 24px;
    height: 24px;
    background-size: contain;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    transform: translateY(0);
  }

  .desktop-icon-button::after {
    display: block;
    margin-top: 3px;
    font-family: "HelveticaNeueRoman", Helvetica, Arial, sans-serif;
    font-size: 10px;
    line-height: 1;
    letter-spacing: -0.02em;
    color: var(--fg);
    opacity: 0.72;
    text-transform: uppercase;
    white-space: nowrap;
  }

  #desktop-change-base-button::after {
    content: "UPLOAD";
  }

  #desktop-download-button::after {
    content: "DOWNLOAD";
  }

  #desktop-add-image-button::after {
    content: "ADD IMAGE";
  }

  #desktop-reset-button::after {
    content: "RESET";
  }

  #desktop-regenerate-button::after {
    content: "GENERATE";
  }

  #menu-mobile-stack {
    display: flex !important;
    flex-direction: column;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    padding-top: 0;
    overflow: hidden;
  }

  #menu-mobile-controls {
    display: block;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px 0 36px 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  #menu-mobile-controls::-webkit-scrollbar {
    display: none;
  }

  #menu-columns {
    display: none !important;
  }

  .mobile-accordion-section:first-child {
    border-top: none;
  }

  .mobile-accordion-header {
    grid-template-columns: 38px minmax(0, 1fr) 32px;
    padding: 15px 0;
  }

  .mobile-accordion-number {
    font-size: 14px;
    line-height: 1;
    transform: translateY(3px);
  }

  .mobile-accordion-title {
    font-family: "HelveticaNeueMd", "HelveticaNeueRoman", Helvetica, Arial, sans-serif;
    font-size: 21px;
    line-height: 1;
    letter-spacing: var(--tracking);
    margin: 0 0 0 -6px;
    transform: translateY(3px);
  }

  .mobile-accordion-toggle {
    font-size: 30px;
    line-height: 1;
    transform: translateY(1px);
  }

  .mobile-accordion-body {
    padding: 6px 0 12px 0;
  }

  .control-block {
    margin-bottom: 12px;
  }

  .toggle-square,
  .color-picker-input,
  .mobile-slider::-webkit-slider-thumb,
  .mobile-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
  }

  .control-label {
    margin-bottom: 8px;
  }

  .mobile-slider-wrap,
  .control-row {
    width: 100%;
  }

  .mobile-slider,
  .mobile-select,
  .text-input-control {
    width: 100%;
    box-sizing: border-box;
  }


  .toggle-square {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    min-height: 18px !important;
    flex: 0 0 18px !important;
    display: inline-block;
    box-sizing: border-box;
    vertical-align: middle;
  }

}


/* ---------------------------------
   Desktop: tighten preview-to-toolbar spacing on shorter/wider screens
---------------------------------- */
@media (pointer: fine) and (min-width: 901px) and (max-height: 950px) {
  #right-column {
    gap: 6px;
  }

  #original-panel {
    padding-bottom: 0 !important;
  }

  #menu-panel {
    margin-top: -10px;
    padding-top: 0;
  }

  #menu-mobile-stack {
    border-top-width: 1px;
  }

  .mobile-accordion-header {
    padding: 9px 0;
  }

  .mobile-accordion-body {
    padding: 1px 0 8px 0;
  }

  .control-block {
    margin-bottom: 10px;
  }

  .control-label {
    margin-bottom: 6px;
  }
}

/* ---------------------------------
   Desktop: add preview-to-toolbar breathing room for tall images on wide screens
---------------------------------- */
@media (pointer: fine) and (min-width: 901px) and (min-aspect-ratio: 16/10) {
  body.desktop-preview-is-tall #menu-panel {
    padding-top: 12px;
  }
}
