:root {
  --ui-bg: rgba(255, 255, 255, 0.94);
  --ui-border: rgba(255, 255, 255, 0.7);
  --ui-shadow: 0 1.2rem 2.5rem rgba(0, 0, 0, 0.12);
  --ui-text: #1e1e1e;
  --ui-muted: #666;
  --ui-backdrop: rgba(0, 0, 0, 0.35);
  --ui-button: rgba(255, 255, 255, 0.95);
  --ui-button-hover: rgba(255, 255, 255, 1);
  --ui-accent: #111;
  --radius-xl: 1.6rem;
  --radius-lg: 1.1rem;
  --radius-md: 0.9rem;
  --radius-sm: 0.75rem;
  --transition: 220ms ease;
  --font-stack: "Poppins", "Inter", "Segoe UI", sans-serif;
  --font-serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-rounded: "Nunito", "Avenir Next Rounded", "Trebuchet MS", sans-serif;
  --font-display: "DM Serif Display", "Georgia", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  background: transparent !important;
  overflow: hidden;
  font-family: var(--font-stack);
  color: var(--ui-text);
}

body {
  display: grid;
  place-items: center;
}

.widget-shell {
  width: 100%;
  height: 100%;
  background: #221e1d;
  position: relative;
  overflow: hidden;
}

.widget-shell.dark-mode {
  background: #221e1d;
}

.top-right-controls {
  position: absolute;
  bottom: 18px;
  right: 18px;
  z-index: 60;
  display: flex;
  gap: 10px;
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.icon-btn {
  border: 1px solid rgba(237, 227, 208, 0.16);
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(0.8rem);
  -webkit-backdrop-filter: blur(0.8rem);
  color: #ffffff;

  /* Change these 3 numbers if you want them bigger/smaller */
  width: clamp(34px, 3.6vw, 44px);
  height: clamp(34px, 3.6vw, 44px);

  border-radius: 999px;
  box-shadow: 0 0.8rem 1.8rem rgba(0, 0, 0, 0.28);
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), border-color var(--transition);
  display: grid;
  place-items: center;
  padding: 0;
  flex: 0 0 auto;
}

.icon-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.18);
}

.icon-btn img {
  width: 52%;
  height: 52%;
  object-fit: contain;
  pointer-events: none;
  filter: brightness(0) invert(1);
}

.scale-wrap {
  position: absolute;
  left: 0;
  top: 0;
  width: 1400px;
  height: 900px;
  transform-origin: top left;
  will-change: transform;
  pointer-events: auto;
}

.stage {
  position: relative;
  width: 1400px;
  height: 900px;
  min-height: 900px;
  background: transparent;
}

.header-area {
  position: absolute;
  top: 26px;
  left: 120px;
  right: 120px;
  z-index: 10;
}

.progress-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
}

.progress-track {
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: #c7a08c;
  transition: width 300ms ease, background 300ms ease;
}

.progress-percent {
  font-size: 20px;
  font-weight: 700;
  color: #ede3d0;
  min-width: 62px;
  text-align: right;
}

.progress-label {
  margin-top: 8px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: #ede3d0;
}

.preview-save-row {
  display: flex;
  justify-content: center;
  margin-top: 10px;
  min-height: 42px;
}

.save-preview-btn {
  border: none;
  border-radius: 999px;
  background: #00b256;
  color: #fff;
  font: inherit;
  font-weight: 700;
  padding: 0.8rem 1.15rem;
  cursor: pointer;
  transition: transform var(--transition), opacity var(--transition), background var(--transition);
}

.save-preview-btn:hover {
  transform: translateY(-1px);
  background: #00994a;
}

.shelves-scroll {
  position: absolute;
  top: 130px;
  left: 0;
  right: 0;
  bottom: 18px;

  overflow-y: auto;
  overflow-x: hidden;

  padding: 8px 0 16px;

  /* Hide scrollbar by default */
  scrollbar-width: none;

  opacity: 1;
}

/* Webkit scrollbar */
.shelves-scroll::-webkit-scrollbar {
  width: 0px;
  background: transparent;
}

/* Show scrollbar only on hover */
.shelves-scroll:hover {
  scrollbar-width: thin;
}

.shelves-scroll:hover::-webkit-scrollbar {
  width: 8px;
}

.shelves-scroll:hover::-webkit-scrollbar-track {
  background: transparent;
}

.shelves-scroll:hover::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
}

.shelves-scroll:hover::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.38);
}

.shelves-container {
  width: 100%;
  padding: 0 18px 12px;
}

.shelf-row {
  position: relative;
  width: 100%;
  padding-top: 42px;
  margin-bottom: 64px;
}

.books-row {
  position: relative;
  display: flex;
  align-items: end;
  gap: 4px;
  min-height: 300px;
}

.shelf-board {
  position: relative;
  width: 100%;
  height: 22px;
  border-radius: 0;
  background: linear-gradient(to bottom, rgba(140, 96, 66, 0.95), rgba(120, 82, 56, 0.95));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  margin-top: 2px;
}

.shelf-board::after {
  content: "";
  position: absolute;
  inset: auto 0 -5px 0;
  height: 5px;
  background: rgba(0, 0, 0, 0.18);
}

.book-spine {
  position: relative;
  flex: 0 0 auto;
  border: 3px solid #000000;
  border-bottom-width: 3px;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  transition: transform var(--transition), filter var(--transition), background var(--transition);
}

.book-spine:hover {
  transform: translateY(-2px);
  filter: brightness(1.02);
}

.book-spine.placeholder {
  cursor: default;
}

.book-spine.placeholder:hover {
  transform: none;
  filter: none;
}

.book-spine-text {
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%) rotate(-90deg);
  transform-origin: center center;
  text-align: center;
  padding: 0;
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.01em;
  overflow: hidden;
  white-space: normal;
  word-break: break-word;
}

.book-spine-text.small {
  font-size: 18px;
}

.book-spine-text.medium {
  font-size: 22px;
}

.book-spine-text.large {
  font-size: 26px;
}

.decor-slot {
  position: absolute;
  bottom: 22px;
  width: 130px;
  height: 130px;
  display: grid;
  place-items: end center;
  pointer-events: none;
  z-index: 9;
}

.decor-slot.left {
  left: 2px;
}

.decor-slot.right {
  right: 2px;
}

.decor-item {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 0.2rem 0.5rem rgba(0, 0, 0, 0.2));
}


.decor-callout {
  position: absolute;
  left: 56px;
  top: -218px;
  width: 300px;
  display: block;
  color: rgba(237, 227, 208, 0.96);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.02em;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  z-index: 120;
}

.decor-callout span {
  display: block;
  width: 260px;
  padding: 12px 14px 13px;
  border-radius: 16px;
  background: rgba(34, 30, 29, 0.76);
  border: 1px solid rgba(237, 227, 208, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
}

.decor-callout svg {
  position: absolute;
  left: -18px;
  top: 94px;
  display: block;
  width: 86px;
  height: auto;
  color: rgba(237, 227, 208, 0.94);
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.55));
}

.decor-placeholder {
  width: 86px;
  height: 86px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.22);
  border: 2px dashed rgba(0, 0, 0, 0.18);
  display: grid;
  place-items: center;
  color: rgba(0, 0, 0, 0.45);
  font-size: 14px;
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--ui-backdrop);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 200;
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  width: min(92vw, 36rem);
  max-height: 88vh;
  overflow: auto;
  border-radius: var(--radius-xl);
  background: var(--ui-bg);
  backdrop-filter: blur(1rem);
  -webkit-backdrop-filter: blur(1rem);
  border: 1px solid var(--ui-border);
  box-shadow: 0 1.6rem 3.5rem rgba(0, 0, 0, 0.18);
  padding: 1.2rem;
}

.modal-large {
  width: min(96vw, 58rem);
}

.modal h2 {
  margin: 0 0 0.35rem;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.modal p {
  margin: 0;
  color: var(--ui-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.modal-section {
  margin-top: 1rem;
}

.label {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ui-text);
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  font: inherit;
  color: var(--ui-text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: rgba(0, 0, 0, 0.18);
  box-shadow: 0 0 0 0.2rem rgba(0, 0, 0, 0.06);
}

.toggle-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.95rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.toggle-row:last-child {
  border-bottom: none;
}

.toggle-title {
  font-size: 0.94rem;
  font-weight: 700;
}

.toggle-help {
  margin-top: 0.25rem;
  color: var(--ui-muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.switch {
  position: relative;
  width: 58px;
  height: 34px;
  flex: 0 0 auto;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.12);
  transition: background var(--transition);
}

.slider::before {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  left: 4px;
  top: 4px;
  border-radius: 999px;
  background: #fff;
  transition: transform var(--transition);
  box-shadow: 0 0.2rem 0.5rem rgba(0, 0, 0, 0.14);
}

.switch input:checked + .slider {
  background: #111;
}

.switch input:checked + .slider::before {
  transform: translateX(24px);
}

.theme-page-trigger {
  width: 100%;
  border: none;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.06);
  color: #111;
  padding: 0.95rem 1rem;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.selected-theme-inline {
  margin-top: 0.55rem;
  font-size: 0.84rem;
  color: var(--ui-muted);
}

.themes-header {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.back-btn {
  border: none;
  background: rgba(0, 0, 0, 0.06);
  width: 44px;
  height: 44px;
  border-radius: 999px;
  font-size: 1.4rem;
  cursor: pointer;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.theme-card {
  border: 2px solid transparent;
  border-radius: 1rem;
  background: rgba(0, 0, 0, 0.04);
  padding: 0.75rem;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), background var(--transition);
}

.theme-card:hover {
  transform: translateY(-2px);
}

.theme-card.selected {
  border-color: #8e74ff;
  background: rgba(142, 116, 255, 0.08);
}

.theme-preview {
  border-radius: 0.75rem;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  padding: 0.75rem 0.6rem 0.4rem;
  display: flex;
  align-items: end;
  justify-content: center;
}

.theme-preview-books {
  width: 100%;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 6px;
}

.theme-preview-book {
  border: 2px solid #000;
  border-bottom-width: 2px;
  border-radius: 6px 6px 0 0;
}

.theme-preview-shelf {
  width: 100%;
  height: 12px;
  margin-top: 8px;
}

.theme-name {
  margin-top: 0.75rem;
  text-align: center;
  font-size: 0.98rem;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  gap: 0.65rem;
  margin-top: 1.15rem;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 0.82rem 1.15rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition), opacity var(--transition), background var(--transition);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: #111;
  color: #fff;
}

.btn-secondary {
  background: rgba(0, 0, 0, 0.06);
  color: #111;
}

.btn-danger {
  background: rgba(176, 34, 34, 0.12);
  color: #8d1f1f;
}

.achievements-progress-wrap {
  margin-top: 1rem;
}

.progress-track-achievements {
  height: 22px;
}

.achievements-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-top: 18px;
  padding: 0 26px;
}

.achievements-stat {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.achievements-stat:first-child {
  justify-content: flex-start;
}

.achievements-stat:last-child {
  justify-content: flex-end;
}

.achievement-stat {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 1rem;
  font-weight: 700;
}

.stat-icon {
  font-size: 1.35rem;
}

.achievement-note {
  margin-top: 1rem;
  font-size: 0.88rem;
  color: var(--ui-muted);
}

.decor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.decor-card {
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.03);
  display: grid;
  place-items: center;
  padding: 2px;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), background var(--transition);
}

.decor-card:hover {
  transform: translateY(-2px);
}

.decor-card.selected {
  border-color: #8e74ff;
  background: rgba(142, 116, 255, 0.08);
}

.decor-card.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.decor-card img {
  width: 110%;
  height: 110%;
  object-fit: contain;
  display: block;
}

.decor-fallback {
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.48);
  text-align: center;
}

.widget-shell.dark-mode .progress-percent,
.widget-shell.dark-mode .progress-label {
  color: #ffffff;
}

.widget-shell.dark-mode .icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 1.2rem 2.5rem rgba(0, 0, 0, 0.28);
}

.widget-shell.dark-mode .icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.widget-shell.dark-mode .progress-track {
  background: rgba(255, 255, 255, 0.14);
}

.widget-shell.dark-mode .modal {
  background: rgba(30, 30, 30, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.widget-shell.dark-mode .modal h2,
.widget-shell.dark-mode .label,
.widget-shell.dark-mode .theme-name {
  color: #ffffff;
}

.widget-shell.dark-mode .modal p,
.widget-shell.dark-mode .toggle-help,
.widget-shell.dark-mode .selected-theme-inline,
.widget-shell.dark-mode .achievement-note {
  color: rgba(255, 255, 255, 0.72);
}

.widget-shell.dark-mode input[type="text"],
.widget-shell.dark-mode input[type="number"],
.widget-shell.dark-mode select {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.widget-shell.dark-mode .toggle-row {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.widget-shell.dark-mode .slider {
  background: rgba(255, 255, 255, 0.16);
}

.widget-shell.dark-mode .switch input:checked + .slider {
  background: #ffffff;
}

.widget-shell.dark-mode .switch input:checked + .slider::before {
  background: #191919;
}

.widget-shell.dark-mode .btn-secondary,
.widget-shell.dark-mode .theme-page-trigger,
.widget-shell.dark-mode .back-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.widget-shell.dark-mode .btn-danger {
  background: rgba(255, 120, 120, 0.15);
  color: #ffb3b3;
}

.widget-shell.dark-mode .theme-card,
.widget-shell.dark-mode .decor-card {
  background: rgba(255, 255, 255, 0.07);
}

.widget-shell.dark-mode .theme-card.selected,
.widget-shell.dark-mode .decor-card.selected {
  background: rgba(142, 116, 255, 0.15);
}

.widget-shell.dark-mode .decor-fallback,
.widget-shell.dark-mode .decor-placeholder {
  color: rgba(255, 255, 255, 0.58);
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
}

.remove-decor-btn {
  margin-top: 16px;
  border: none;
  border-radius: 10px;
  background: #222;
  color: #fff;
  font: inherit;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.remove-decor-btn:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

.widget-shell.dark-mode .top-left-controls .icon-btn img,
.widget-shell.dark-mode .top-right-controls .icon-btn img {
  filter: brightness(0) invert(1);
}

.hidden {
  display: none !important;
}


@media (max-width: 560px) {
  .top-right-controls {
    bottom: 12px;
    right: 12px;
    gap: 8px;
  }

  .decor-callout {
    left: 60px;
    top: -150px;
    width: 230px;
    font-size: 17px;
  }

  .decor-callout span {
    width: 205px;
    padding: 10px 12px 11px;
    border-radius: 14px;
  }

  .decor-callout svg {
    left: -12px;
    top: 76px;
    width: 70px;
  }
}

/* Mobile sales-page layout tuning */
@media (max-width: 640px) {
  .top-right-controls {
    bottom: 28px !important;
    right: 24px !important;
    gap: 12px !important;
    z-index: 160 !important;
  }

  .icon-btn {
    width: 50px !important;
    height: 50px !important;
    min-width: 50px !important;
    min-height: 50px !important;
  }

  .icon-btn img {
    width: 54% !important;
    height: 54% !important;
  }

  .header-area {
    top: 24px;
    left: 64px;
    right: 64px;
  }

  .progress-track {
    height: 16px;
  }

  .progress-percent {
    font-size: 20px;
    min-width: 52px;
  }

  .progress-label {
    margin-top: 8px;
    font-size: 22px;
  }

  .shelves-scroll {
    top: 124px;
    bottom: 86px;
    padding-bottom: 24px;
    scrollbar-width: none;
  }

  .shelves-scroll::-webkit-scrollbar {
    width: 0;
  }

  .shelves-container {
    padding-left: 18px;
    padding-right: 18px;
  }

  .shelf-row {
    padding-top: 42px;
    margin-bottom: 56px;
  }

  .books-row {
    gap: 5px;
    min-height: 320px;
  }

  .shelf-board {
    height: 24px;
  }

  .decor-slot {
    bottom: 24px;
    width: 132px;
    height: 132px;
  }

  .decor-callout {
    left: 54px;
    top: -154px;
    width: 240px;
    font-size: 18px;
    z-index: 140;
  }

  .decor-callout span {
    width: 212px;
    padding: 10px 12px 11px;
    border-radius: 14px;
  }

  .decor-callout svg {
    left: -12px;
    top: 78px;
    width: 72px;
  }

  .book-spine-text.small {
    font-size: 20px;
  }

  .book-spine-text.medium {
    font-size: 24px;
  }

  .book-spine-text.large {
    font-size: 28px;
  }
}

@media (max-width: 390px) {
  .top-right-controls {
    bottom: 24px !important;
    right: 20px !important;
    gap: 10px !important;
  }

  .icon-btn {
    width: 46px !important;
    height: 46px !important;
    min-width: 46px !important;
    min-height: 46px !important;
  }
}
