* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  margin: 0;
  padding: 0;
  height: var(--app-height);
  overflow-y: auto;
  font-family: arial, system-ui, sans-serif;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
}



input, textarea, select, button {
  font-size: 1rem;
}



body.centered {
  justify-content: center;
  align-items: center;
}
.login-wrapper {
  width: 100%;
  max-width: 320px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.login-form input {
  padding: .6rem;
  border: 1px solid #ccc;
  border-radius: 8px;
}
.login-form button {
  padding: .6rem;
  border: none;
  border-radius: 8px;
  background: #2e2e38;
  color: #fff;
  font-size: 1rem;
}
.error {
  color: red;
  text-align: center;
}


header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  padding: .5rem .75rem;
  background: #f8f8f8;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

header img.logo {
  position: absolute;
  left: .75rem;
  height: 32px;
  width: auto;
}
header form.logout {
  position: absolute;
  right: .75rem;
}
header form.logout button {
  background: none;
  border: none;
  color: #2e2e38;
  font-size: .9rem;
}


main {
  margin-top: 60px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding: .75rem;
  max-height: calc(var(--app-height) - 60px);
  overflow-y: auto;
  padding-bottom: 90px;
}


.capture-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem 0;
}


#capture-wrapper {
  position: relative;
  width: 100%;
  max-width: 100%;
  background: #e5e5ea;
  overflow: hidden;
}

#capture-wrapper.ratio-1-1 {
  aspect-ratio: 1 / 1;
  max-width: 80vmin;
}

#capture-wrapper.ratio-4-5 {
  aspect-ratio: 4 / 5;
  max-width: 64vmin;
}

#capture-wrapper.ratio-9-16 {
  aspect-ratio: 9 / 16;
  max-width: 45vmin;
}

#capture, #video, #sticker-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#sticker-layer {
  position: absolute;
  inset: 0;
}

#sticker-layer .banner-img {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: auto;
  z-index: 0;
  pointer-events: none;
  user-select: none;
}

.banner {
  margin-top: .5em;
  margin-bottom: 1.5em;
}

.sticker {
  top: 10%;
  left: 10%; 
  /*width: 30%;*/
  width: 300px;
}

#palette, #palette-text {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .5rem;
}
.palette-item {
  height: 60px;
  width: 60px;
  border-radius: 8px;
  object-fit: contain;
  border: 2px solid transparent;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f0f0;
  font-size: .75rem;
}
.palette-item:hover {
  border-color: #2e2e38;
}

#banner-palette {
  display: flex;
  flex-direction: row;
  gap: 8px;
  justify-content: flex-start;
  align-items: center;
  margin-top: 0.5rem;
  margin-bottom: 1.5em;
}

.palette-banner {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  border: 2px solid transparent;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.palette-banner:hover {
  border-color: #2e2e38;
}
.palette-banner.active {
  border-color: #2e2e38;
}


.text-palette {
  margin-top: 1.5rem;
}

.draggable {
  position: absolute;
  touch-action: none;
  cursor: move;
}
.draggable.text {
  padding: .25rem .5rem;
  border-radius: 4px;
  font-weight: 600;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 100%; 
}
.draggable.text.selected {
  outline: 2px dashed #2e2e38;
  outline-offset: 2px;
}

#leftCol {
  display: flex;
  flex-direction: column;
  flex: 1;
}


#controls {
  padding: 1rem;
  border-top: 1px solid #ccc;
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-top: .5rem;
}
#controls button,
#controls input[type="file"] {
  flex: 1 1 auto;
  padding: .5rem;
  border: none;
  border-radius: 8px;
  font-size: .85rem;
}
#controls button {
  background: #2e2e38;
  color: #fff;
}
#controls input[type="file"] {
  background: #f2f2f7;
}

.color-dropdown {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 4px;
  background: #f5f5f5;
  border: 1px solid #ccc;
  border-radius: 4px;
  width: 95px;
  margin-top: 4px;
}

.text-box {
  position: absolute;
  display: inline-block;
}

.inline-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
  padding: 6px;
  background: #f0f0f0;
  border-radius: 8px;
  max-width: 300px;
  font-family: arial, sans-serif;
  font-size: 14px;
}

.inline-controls button {
  font-size: 21px;
  padding: 9px 14px;
  cursor: pointer;
  border-radius: 4px;
  border: 1px solid #aaa;
  background: white;
  user-select: none;
}

.control-row > button {
  width: 30px;
  height: 30px;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
}

.control-row-txt > button {
  width: 30px;
  height: 30px;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
}

.color-swatch {
  width: 30px;
  height: 30px;
  border: 1px solid #aaa;
  border-radius: 4px;
  cursor: pointer;
}

.inline-controls input[type="range"] {
  height: 20px;
  width: 150px;
  cursor: pointer;
}

.control-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 5px;
}

.control-row-txt {
  display: flex;
  flex-direction: row;
}

.control-label {
  font-weight: bold;
  margin-bottom: 4px;
}

.color-combined-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.color-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.color-row.center {
  justify-content: center;
}
.control-label.center {
  text-align: center;
}


.color-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

#bgAlphaSlider, #fontSlider {
  width: 150px;
  height: 28px;
  cursor: pointer;
  background-color: #f0f0f0;
}

#bgAlphaSlider::-webkit-slider-thumb {
  width: 28px;
  height: 28px;
  background: #666;
  border-radius: 50%;
  cursor: pointer;
  margin-top: -10px;
  -webkit-appearance: none;
}

#bgAlphaSlider::-webkit-slider-runnable-track {
  height: 8px;
  background: #ccc;
  border-radius: 4px;
}

#bgAlphaSlider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  background: #666;
  border-radius: 50%;
  cursor: pointer;
}

#bgAlphaSlider::-moz-range-track {
  height: 8px;
  background: #ccc;
  border-radius: 4px;
}

#fontSlider::-webkit-slider-thumb {
  width: 28px;
  height: 28px;
  background: #666;
  border-radius: 50%;
  cursor: pointer;
  margin-top: -10px;
  -webkit-appearance: none;
}

#fontSlider::-webkit-slider-runnable-track {
  height: 8px;
  background: #ccc;
  border-radius: 4px;
}

#fontSlider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  background: #666;
  border-radius: 50%;
  cursor: pointer;
}

#fontSlider::-moz-range-track {
  height: 8px;
  background: #ccc;
  border-radius: 4px;
}


.font-size-input {
  width: 50px;
}

button {
  margin-right: 6px;
}

button.active {
  background-color: #444;
  color: white;
}


.color-swatch.selected {
  border-color: #333;
}

.text-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
}

.drag-handle {
  cursor: grab;
  user-select: none;
}

.text-content {
  user-select: text;
}


#format-controls .format-switch {
  display: flex;
  gap: 10px;
  margin-bottom: 1.5em;
}

.format-controls {
  margin-bottom: 1.5em;
  margin-top: .5rem;
}

.format-btn {
  padding: 8px 16px;
  font-size: 14px;
  border: 2px solid #ccc;
  background-color: #f0f0f0;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.format-btn:hover {
  background-color: #e0e0e0;
}

.format-btn.active {
  background-color: #333;
  color: #fff;
  border-color: #333;
}

.custom-checkbox {
  width: 18px;
  height: 18px;
  border: 2px solid #999;
  border-radius: 4px;
  background: #fff;
  position: relative;
  transition: all 0.2s ease;
}

.custom-checkbox::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 4px;
  width: 5px;
  height: 10px;
  border: solid #333;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  opacity: 0;
  transition: opacity 0.2s ease;
}


@media (min-width: 768px) {
  main {
    flex-direction: row;
  }
  #leftCol {
    flex: 1 1 60%;
    height: auto;
  }
  #rightCol {
    flex: 1 1 40%;
    padding-left: 1rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overflow-y: auto;
    padding-top: 1rem;
  }
  #palette {
    display: grid;
    grid-template-columns: repeat(2, 60px);
    grid-template-rows: repeat(2, 60px);
    gap: 0.5rem;
    margin-top: 0.5rem;
  }
  #palette, #palette-text {
    flex-direction: column;
    align-items: flex-start;
    overflow-y: auto;
    max-height: 50vh;
  }
  #text-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
}

@media (max-width: 768px) {
  .sticker {
    /*width: 50%;*/
    width: 175px;
  }
}

@media (max-width: 600px) {
  #text-controls label,
  #text-controls .text-style-buttons {
    width: 100%;
  }

  
  #text-controls select,
  #text-controls textarea,
  #text-controls input[type="range"] {
    width: 100%;
  }

  
  .text-style-buttons {
    flex-direction: column; 
    gap: .5rem; 
  }
  .text-style-buttons button {
    width: 100%; 
  }
}

@media (max-width: 480px) {
  #capture-wrapper.ratio-1-1,
  #capture-wrapper.ratio-4-5,
  #capture-wrapper.ratio-9-16 {
    max-width: 95vmin;
  }
}
