* {
  user-select: none;
}

:root {
  --bg-color: #fceee4;
  --bg-secondary: #fff0ea;
  --text-color: #000;
  --border-color: #ccc;
  --button-bg: #ff9a8b;
  --button-color: #fff;
  --grid-bg: #fff;
  --grid-selected: #000;
}

body.dark {
  --bg-color: #1e1e1e;
  --bg-secondary: #2b2b2b;
  --text-color: #fff;
  --border-color: #555;
  --button-bg: #ff5c5c;
  --button-color: #fff;
  --grid-bg: #333;
  --grid-selected: #fff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0
}

body {
  font-family: sans-serif;
  background: #fceee4;
  flex-direction: column;
}

.top-bar {
  position: relative;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 10px 0;
}

.top-bar .sidebar-header {
  margin: 0 auto;
  text-align: center;
}

.top-bar .sidebar-header h2 {
  margin: 0;
  font-size: 18px;
  color: var(--text-color);
}

.top-bar .theme-switch {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
}


.container {
  flex: 1;
  display: flex;
  overflow: hidden;
  padding: 20px;
  gap: 20px;
}

.preview {
  width: 420px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.palette-container {
  width: 100%;
  display: flex;
  gap: 16px;
  margin-top: 12px;
  flex-direction: column;
  align-items: center;
}
.palette-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.palette-item label {
  font-size: 14px;
}
.swatches {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.swatch {
  width: 20px;
  height: 20px;
  border: 1px solid #aaa;
  border-radius: 4px;
  cursor: pointer;
}

.sidebar {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
  justify-content: space-between;
}

.palette {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.palette label {
  font-size: 14px;
  white-space: nowrap;
}

.categories-container {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  padding-right: 4px;
}

.category-section {
  display: flex;
  flex-direction: column;
}

.category-section h3 {
  position: absolute;
  font-size: 14px;
  text-align: left;
  margin: 0px 0 0 0px;
  border-radius: 4px;
}

.grid-wrapper {
  border-radius: 0px 26px 15px 15px;
  overflow: hidden;
}

.grid {
  display: flex;
  gap: 10px;
  overflow-x: scroll;
  padding: 15px 10px 0px 10px;
  background: white;
}

.grid img {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  object-fit: contain;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 8px;
}

.thumb-wrapper {
  position: relative;
  display: inline-block;
  width: 64px;
  height: 64px;
  margin: 4px;
  overflow: visible;
  border-radius: 8px;
  border: 2px solid transparent;
  box-sizing: border-box;
  border-color: var(--bg-secondary);
}

.thumb-wrapper img.thumb-bg {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0.3;
  pointer-events: none;
  z-index: 0;
}

.thumb-wrapper.selected {
  border-color: #000;
}

.thumb-wrapper img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  display: block;
  transition: transform 0.2s;
  margin-left: -2px;
  margin-top: -2px;
}

.thumb-wrapper.zoom-mount {
  position: relative;
  overflow: hidden;
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  display: inline-block;
}

.thumb-wrapper.zoom-mount img {
  transform: scale(2.5);
  transform-origin: center bottom;
  pointer-events: auto;
  display: block;
  width: 64px;
  height: 64px;
}

#avatarName {
  padding: 8px;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid #aaa;
}

.btn-save {
  padding: 10px;
  background: #ff9a8b;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.btn-save[disabled] {
  background: #ccc !important;
  cursor: not-allowed;
  opacity: 0.6;
}

#statusTile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 12px;
  padding: 10px;
  background: var(--bg-secondary);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

#statusTile:last-child {
  margin-bottom: 0px;
}

#statusTile .status-name {
  position: absolute;
  top: 0px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  font-weight: bold;
  color: var(--text-color);
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 1;
}

#statusTile .status-text {
  font-size: 14px;
  color: var(--text-color);
}

#statusTile .status-avatar {
  display: flex;
  align-items: center;
  gap: 6px;
}

#statusTile .status-avatar img,
#statusTile .status-avatar .placeholder-avatar,
#statusTile .status-avatar canvas {
  border-radius: 25%;
  border: 1px solid var(--border-color);
  width: 64px;
  height: 64px;
  object-fit: cover;
  cursor: pointer;
}

#statusTile .placeholder-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ccc;
  color: #666;
  font-weight: bold;
}


.theme-switch {
  position: fixed;
  top: 10px;
  left: 10px;
  width: 50px;
  height: 26px;
  z-index: 100;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  background-color: #ccc;
  border-radius: 26px;
  height: 100%;
  width: 100%;
  transition: 0.4s;
}
.slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.4s;
}
input:checked + .slider {
  background-color: #4caf50;
}
input:checked + .slider::before {
  transform: translateX(24px);
}

.theme-switch input:checked + .slider {
  background-color: #444;
}
.theme-switch input:checked + .slider:before {
  background-color: #fff;
}

.theme-switch input:not(:checked) + .slider {
  background-color: #ccc;
}
.theme-switch input:not(:checked) + .slider:before {
  background-color: #000;
}

/* head */
@keyframes bob-head {
  from {
    transform: translateY(0)
  }

  to {
    transform: translateY(-5px)
  }
}

#avatarPreview {
  position: relative;
  width: 400px;
  height: 400px;
  transform-origin: center bottom;
  animation: bob-head 4s ease-in-out infinite alternate;
}

/* hair */
@keyframes sway-back-hair {
  from {
    transform: translateX(0)
  }

  to {
    transform: translateX(4px)
  }
}

.preview-layer.back_hair {
  animation: sway-back-hair 6s ease-in-out infinite alternate;
}

@keyframes sway-front-hair {
  from {
    transform: translateX(0)
  }

  to {
    transform: translateX(4px)
  }
}

.preview-layer.front_hair {
  animation: sway-front-hair 4s ease-in-out infinite alternate;
}



@keyframes scale-mouth {
  from { transform: scaleX(1)     scaleY(1); }
  to   { transform: scaleX(1.03) scaleY(0.97); }
}

.preview-layer.mount {
  transform-origin: center 80%;
  animation: scale-mouth 1s ease-in-out infinite alternate;
}

/* eyes */
@keyframes blink-fast {

  0%,
  98%,
  100% {
    transform: scaleY(1)
  }

  99% {
    transform: scaleY(0.1)
  }
}

.preview-layer.eyes {
  transform-origin: center 65%;
  animation: blink-fast 8s ease-in-out infinite;
}




body {
  background: var(--bg-color);
  color: var(--text-color);
}



.category-section h3 {
  text-shadow: 1px 1px 2px var(--bg-secondary);
}

.grid {
  background: var(--grid-bg);
}

.thumb-wrapper.selected {
  border-color: var(--grid-selected);
}

.btn-save {
  background: var(--button-bg);
  color: var(--button-color);
}

body.dark ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

body.dark ::-webkit-scrollbar-track {
  background: #1a1a1a;
}

body.dark ::-webkit-scrollbar-thumb {
  background-color: #444;
  border-radius: 6px;
  border: 2px solid #1a1a1a;
}

body.dark {
  scrollbar-color: #444 #1a1a1a;
  scrollbar-width: thin;
}

