body {
  font-family: system-ui, sans-serif;
  margin: 0;
  padding: 24px;
  background: #fafafa;
  color: #111;
}
.card {
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  margin: 12px 0;
  background: #fff;
}
.btn {
  padding: 8px 16px;
  border-radius: 9999px;
  border: 1px solid #ccc;
  cursor: pointer;
  background: #fff;
  font-weight: 600;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  white-space: normal; /* allow wrapping instead of spilling */
  text-align: center;
  word-break: break-word;
  overflow-wrap: anywhere;
  transition:
    background 0.15s,
    box-shadow 0.15s,
    transform 0.15s,
    border-color 0.2s;
}
.btn:hover:not(:disabled) {
  background: #f5f5f5;
  border-color: #bbb;
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:focus-visible {
  outline: 2px solid #111;
  outline-offset: 3px;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Vertical (title + desc) button variant */
.btnStack {
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 12px 18px;
  border-radius: 20px;
}
.btnStack .btnTitle {
  font-weight: 600;
  line-height: 1.2;
}
.btnStack .btnDesc {
  font-size: 0.75rem;
  line-height: 1.25;
  opacity: 0.75;
  margin-top: 2px;
}
.avatar {
  width: 96px;
  height: 96px;
  border-radius: 9999px;
  object-fit: cover;
}
.center {
  max-width: 720px;
  margin: 0 auto;
}
.small {
  opacity: 0.7;
  font-size: 0.9rem;
}
input[type="text"] {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid #ccc;
}
a textarea,
textarea {
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid #ccc;
  font: inherit;
  resize: vertical;
  box-sizing: border-box;
}
.linkRow {
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr 1fr 1fr auto;
  align-items: center;
  margin-top: 8px;
}
.linkRow input {
  width: 100%;
}
.linkRow .removeBtn {
  padding: 6px 10px;
}
.smallBtn {
  font-size: 0.8rem;
  padding: 6px 10px;
}
.linkRow button {
  border: 1px solid #ddd;
}
.avatarRow input[type="file"] {
  font-size: 0.8rem;
}
a {
  color: inherit;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.customEditorLayout {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.customEditorMain {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.customEditorSection {
  display: flex;
  flex-direction: column;
}

.savedConfigPanel {
  flex-shrink: 0;
  width: 260px;
  border-radius: 16px;
  border: 1px solid #ebebeb;
  background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
  padding: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 1px 4px rgba(0, 0, 0, 0.06);
}

.savedConfigList {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.savedConfigPanelStatus {
  color: #444;
}

.savedConfigSlot {
  border: 1px solid #e4e4e4;
  border-radius: 14px;
  padding: 12px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.savedConfigSlotHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.savedConfigSlotHeader .slotTitle {
  font-weight: 600;
}

.savedConfigName {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid #d7d7d7;
  font: inherit;
}

.savedConfigSlotButtons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.savedConfigSlotButtons .btn {
  flex: 1 0 auto;
  justify-content: center;
}

.savedConfigMeta {
  margin: 8px 0 0;
  min-height: 1.2em;
}

/* ---------------- Link cards (user links) --------------- */
#links {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}
#links a.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid #e2e2e2;
  border-radius: 18px;
  transition:
    background 0.25s,
    box-shadow 0.25s,
    transform 0.18s,
    border-color 0.25s;
  text-decoration: none;
  background: #fff;
  overflow-wrap: anywhere;
}
#links a.card strong {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
  display: block;
  max-width: 100%;
  /* If the title is extremely long, allow wrapping cleanly */
  word-break: break-word;
}
#links a.card div {
  font-size: 0.8rem;
  line-height: 1.3;
  color: #555;
  max-width: 100%;
}
#links a.card:hover {
  text-decoration: none;
  background: #f9f9f9;
  border-color: #d0d0d0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}
#links a.card:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
#links a.card:focus-visible {
  outline: 2px solid #111;
  outline-offset: 3px;
}

/* Avoid inherited underline on hover for inner strong */
#links a.card strong:hover {
  text-decoration: none;
}

/* Responsive tweaks */
@media (max-width: 480px) {
  .btn {
    padding: 10px 14px;
  }
  #links a.card {
    padding: 14px 16px;
  }
}

@media (max-width: 860px) {
  .customEditorLayout {
    flex-direction: column;
  }
  .savedConfigPanel {
    width: 100%;
  }
  .savedConfigSlotButtons .btn {
    flex: 1 1 calc(33% - 4px);
  }
}

/* -------- Avatar crop modal -------- */
#cropModalOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 5000;
}
.cropModal {
  background: #fff;
  border-radius: 20px;
  padding: 20px 22px 22px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  animation: popIn 0.25s ease;
}
@keyframes popIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.cropStageWrapper {
  position: relative;
}
#cropCanvas {
  width: 100%;
  height: auto;
  border-radius: 16px;
  background: #111;
  cursor: grab;
  touch-action: none;
}
#cropCanvas:active {
  cursor: grabbing;
}
.cropHint {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  pointer-events: none;
}
.cropSliderLabel {
  display: block;
  margin-top: 12px;
  font-size: 0.8rem;
}
  .cropSliderLabel input[type="range"] {
    width: 100%;
  }

/* -------- Badge system -------- */
.badge-container {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  line-height: 1.2;
  user-select: none;
  pointer-events: none; /* Prevent interaction to avoid manipulation */
}

.badge.owner {
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.badge.contributor {
  background: linear-gradient(135deg, #4ecdc4, #45b7aa);
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.badge.supporter {
  background: linear-gradient(135deg, #a55eea, #8e44ad);
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Badge hover effect for visual feedback but no interaction */
.badge:hover {
  transform: none;
  filter: brightness(1.05);
}

/* Responsive badge adjustments */
@media (max-width: 480px) {
  .badge-container {
    margin-left: 4px;
    gap: 4px;
  }
  
  .badge {
    font-size: 0.65rem;
    padding: 1px 6px;
  }
}