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

html, body {
  height: 100%;
  overflow: hidden;
  background: #111;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

/* ── Full-page iframe (isolated document — no CSS bleed) ── */
#preview {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

/* ── Transition veil ── */
#veil {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
  z-index: 8888;
}
#veil.visible {
  opacity: 1;
  pointer-events: all;
}

/* ── Floating modal ── */
#modal {
  position: fixed;
  left: 20px;
  bottom: 20px;
  width: 244px;
  z-index: 9999;
  border-radius: 13px;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 2px 0 0 rgba(255,255,255,0.04) inset,
    0 12px 48px rgba(0, 0, 0, 0.6),
    0 0 0 0.5px rgba(0,0,0,0.5);
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
}

/* ── Header / drag handle ── */
.modal-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 11px 10px 10px;
  cursor: grab;
  border-radius: 13px 13px 0 0;
  user-select: none;
}
.modal-header:active { cursor: grabbing; }

.drag-hint {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.18);
  flex-shrink: 0;
  line-height: 1;
}
.current-name {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.modal-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.3);
  font-size: 15px;
  line-height: 1;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
  font-family: inherit;
}
.btn-icon:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* ── Body ── */
.modal-body { border-top: 1px solid rgba(255, 255, 255, 0.07); }
#modal.minimized .modal-body { display: none; }
#modal.minimized { border-radius: 13px; }

.section { border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.section:last-child { border-bottom: none; }

/* ── Category pills ── */
.categories-section {
  display: flex;
  align-items: center;
  padding: 6px 6px;
  gap: 2px;
}

.cat-arrow {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.45);
  font-size: 16px;
  line-height: 1;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s, opacity 0.15s;
  font-family: inherit;
}
.cat-arrow:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}
.cat-arrow.faded {
  opacity: 0.15;
  pointer-events: none;
}

.cat-pills-scroll {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  padding: 2px 2px;
}
.cat-pills-scroll::-webkit-scrollbar { display: none; }

.cat-pill {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.4);
  border-radius: 20px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  font-family: inherit;
}
.cat-pill:hover {
  border-color: rgba(255, 255, 255, 0.28);
  color: rgba(255, 255, 255, 0.85);
}
.cat-pill.active {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
  font-weight: 600;
}

/* ── Design list ── */
.list-section {
  max-height: 148px;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}
.list-section::-webkit-scrollbar { width: 3px; }
.list-section::-webkit-scrollbar-track { background: transparent; }
.list-section::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.design-item {
  padding: 5px 14px 5px 18px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: color 0.1s, background 0.1s;
  position: relative;
  font-family: inherit;
}
.design-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.9);
}
.design-item.active {
  color: #fff;
  font-weight: 600;
}
.design-item.active::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.65);
}

/* ── Mode toggle ── */
.mode-section {
  display: flex;
  align-items: center;
  padding: 7px 12px;
  gap: 8px;
}
.section-label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.28);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  flex: 1;
}
.mode-toggle {
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 2px;
}
.mode-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.3);
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.mode-btn:hover { color: rgba(255, 255, 255, 0.7); }
.mode-btn.active {
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
}

/* ── Swatches ── */
.swatches-section {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 12px;
  min-height: 38px;
  align-items: center;
}
.swatches-loading {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.18);
}
.swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  transition: transform 0.15s;
  position: relative;
  cursor: default;
}
.swatch:hover {
  transform: scale(1.45);
  z-index: 2;
  border-color: rgba(255, 255, 255, 0.3);
}

/* ── Tooltips ── */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(5, 5, 5, 0.95);
  color: rgba(255, 255, 255, 0.88);
  font-size: 10px;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 10001;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ── Action buttons ── */
.actions-section {
  display: flex;
  gap: 6px;
  padding: 8px 10px 10px;
}
.action-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: rgba(255, 255, 255, 0.55);
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.action-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff;
}
.action-btn.copied {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.24);
  color: #4ade80;
}
.action-btn.failed {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.24);
  color: #f87171;
}
