* {
  box-sizing: border-box;
}

:root {
  --kvibe-surface: #12141c;
  --kvibe-card: #1b1e2b;
  --kvibe-card-2: #232739;
  --kvibe-line: #2e3348;
  --kvibe-text: #eef0f8;
  --kvibe-muted: #9aa1bd;
  --kvibe-accent: #ff5fa2;
  --kvibe-accent-2: #7c6cff;
  --kvibe-danger: #ff5f5f;
  --radius: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--kvibe-text);
  background-color: var(--kvibe-surface);
  background-image: radial-gradient(rgba(80, 84, 110, 0.35) 1px, transparent 1px);
  background-size: 22px 22px;
}

button {
  font: inherit;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(20, 22, 32, 0.9);
  border-bottom: 1px solid var(--kvibe-line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.topbar__title {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.3px;
}

.topbar__actions {
  display: flex;
  gap: 10px;
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(320px, 560px) minmax(300px, 1fr);
  gap: 20px;
  padding: 20px;
  align-items: start;
  max-width: 1280px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.stage,
.panel {
  background: var(--kvibe-card);
  border: 1px solid var(--kvibe-line);
  border-radius: var(--radius);
  padding: 16px;
}

.canvas-wrap {
  display: flex;
  justify-content: center;
}

#avatarCanvas {
  width: min(100%, 460px);
  height: auto;
  aspect-ratio: 1;
  border-radius: 20px;
  background: #2b2f45;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

/* ---------- Inputs ---------- */
.profile-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.text-input,
.select-input {
  background: var(--kvibe-card-2);
  border: 1px solid var(--kvibe-line);
  color: var(--kvibe-text);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}

.text-input {
  flex: 1 1 160px;
  min-width: 0;
}

.text-input:focus,
.select-input:focus {
  border-color: var(--kvibe-accent-2);
}

.select-input {
  flex: 1 1 130px;
  cursor: pointer;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  color: #fff;
  transition: transform 0.12s ease, filter 0.12s ease, background 0.12s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.btn:active {
  transform: translateY(0);
}

.btn--primary {
  background: linear-gradient(135deg, var(--kvibe-accent), var(--kvibe-accent-2));
}

.btn--ghost {
  background: var(--kvibe-card-2);
  border-color: var(--kvibe-line);
  color: var(--kvibe-text);
}

.btn--danger {
  background: rgba(255, 95, 95, 0.15);
  border-color: rgba(255, 95, 95, 0.5);
  color: #ffb3b3;
}

/* ---------- Gallery ---------- */
.gallery-block {
  margin-top: 18px;
}

.gallery-block__head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gallery-block__head h2 {
  margin: 0;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--kvibe-muted);
}

.pill {
  background: var(--kvibe-accent-2);
  border-radius: 999px;
  font-size: 12px;
  padding: 2px 9px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.gallery-item {
  position: relative;
  background: var(--kvibe-card-2);
  border: 1px solid var(--kvibe-line);
  border-radius: 12px;
  padding: 6px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease;
}

.gallery-item:hover {
  border-color: var(--kvibe-accent);
  transform: translateY(-2px);
}

.gallery-item img {
  width: 100%;
  border-radius: 8px;
  display: block;
}

.gallery-item__name {
  font-size: 11px;
  color: var(--kvibe-muted);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-item__del {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--kvibe-danger);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.gallery-item:hover .gallery-item__del {
  opacity: 1;
}

.hint {
  color: var(--kvibe-muted);
  font-size: 13px;
}

/* ---------- Panel / tabs ---------- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  background: var(--kvibe-card-2);
  border: 1px solid var(--kvibe-line);
  color: var(--kvibe-muted);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.12s ease;
}

.tab:hover {
  color: var(--kvibe-text);
  border-color: var(--kvibe-accent-2);
}

.tab.is-active {
  background: linear-gradient(135deg, var(--kvibe-accent), var(--kvibe-accent-2));
  border-color: transparent;
  color: #fff;
}

.options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 10px;
  min-height: 120px;
}

.option {
  background: var(--kvibe-card-2);
  border: 2px solid var(--kvibe-line);
  border-radius: 12px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--kvibe-text);
  transition: border-color 0.12s ease, transform 0.12s ease;
}

.option:hover {
  transform: translateY(-2px);
  border-color: var(--kvibe-accent-2);
}

.option.is-active {
  border-color: var(--kvibe-accent);
  box-shadow: 0 0 0 3px rgba(255, 95, 92, 0.2);
}

.option canvas {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  background: #33384f;
}

.option__label {
  font-size: 11px;
  color: var(--kvibe-muted);
  text-align: center;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(120px);
  background: linear-gradient(135deg, var(--kvibe-accent), var(--kvibe-accent-2));
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: none;
  z-index: 50;
}

.toast.is-show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
